drinkits

Tēma: Skripti (1. lapa no 2)

Simple PHP script for VIES VAT number validation

I have created simple VIES VAT number validation script. Script allows to upload previously prepared CSV with countryCode and vatNumber and creates HTML table with validation results.

Lasīt tālāk

Rename attachments in Jira using Groovy

While Atlassian is “GATHERING INTEREST” to implement file renaming feature in Jira, it is possible to rename attachments using Groovy.

If you use JMWE, Scriptrunner, etc.  in Jira, you can use following Groovy script:

import org.ofbiz.core.entity.GenericValue
import com.atlassian.jira.ofbiz.OfBizDelegator
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.attachment.Attachment

def attachmentManager = ComponentAccessor.getAttachmentManager()

OfBizDelegator delegator = ComponentAccessor.getComponentOfType(OfBizDelegator.class)
issue.get("attachment")?.each {
  for(GenericValue attachment : delegator.findByField("FileAttachment", "id", it.id)){ 
      attachment.setString("filename", "no_klienta_"+it.filename)
      attachment.store()
  } 
}

 

Paštaisīts digitālais fotorāmis

Beidzot pabeidzu veidot paštaisīto fotorāmi. Izejvielas:

  • Raspberry Pi Zero W
  • Pirms 4 gadiem no portatīvā datora  izravēts 14” LCD ekrāns
  • Pirms 4 gadiem no AliExpress sūtīts LCD Controller Board
  • LCD strāvas barošanas bloks
  • Strāvas Step Down modulis, lai atdalītu un nobarotu Raspberry ar strāvu, kas domāta LCD
  • Aukstas gaismas LED virtene
  • Slēdzis LCD un LED virtenes izslēgšanai
  • IKEA fotorāmis
  • Montāžas līme un stiprinājumi

Rāmja aizmugurē neiespringu uz skaistu izkārtojumu un tīrību, jo, pieliekot pie sienas, tas nav redzams.

Uz Raspberry Pi uzstādīts Raspbian Lite OS un iestatīts kioska režīms – pie katras piestartēšanas tiek atvērts Chromium pārlūks ar iepriekš iestatītu mājaslapu. Lokālajā tīklā uz citas iekārtas darbojas Openmediavault, kas papildus pamatdarbam hostē arī mājaslapu fotorāmim.

Mājaslapa ir vienkāršs uz Uikit front-end framework veidots bilžu slaidšovs.  Papildus tiek ielādēts: Google kalendārs izmantojot FullCalendar, informācija par laika apstākļiem no OpenWeatherMap un foto uzņemšanas datums ar PHP exif_read_data funkciju. Visa tekstuālā papildus informācija tiek pārlādēta reizi stundā ar Javascript setInterval. Pats Raspberry ar Crontab tiek pārstartēts katru nakti, lai izvairītos no atmiņas problēmām Chromium cache dēļ.

Tā kā mājaslapa stāv uz lokālā NAS, tad bilžu papildināšana ir tik vienkārša, kā Adobe Lightroom programmā uzspiest pogu Export to Fotorāmis.

Pašlaik mazjaudīgais Zero bez problēmām sagremo slaidšovu ar ~300 fotoattēliem.

Update Jira issues from MS Excel spreadsheet using Powershell script (updated: 13.05.2019.)

I have created Powershell script which allows to set values in Jira issues using data from MS Excel spreadsheet.

Script is based on following Powershell modules:

Usage:

  1. Set Jira server address in “update_issues.ps1” file.
  2. Update data in “data_for_issues.xlsx”
  3. Set custom field configuration according to your needs in “update_issues.ps1”
  4. Launch “update_issues.bat”, enter your Jira credentials and wait for script to complete.
  5. Log file is created next to “update_issues.ps1” file.

Download (updated: 13.05.2019.): update_issues_PS_script_V2.zip

update_issues.ps1 (updated: 13.05.2019.):

$ErrorActionPreference="SilentlyContinue"
Stop-Transcript | out-null
$ErrorActionPreference = "Continue"
Start-Transcript -path .\script\update_issues.log -append

Import-Module .\script\JiraPS
Import-Module .\script\PSExcel

####### Define some variables below ########

#Excel data file
$path = ".\data_for_issues.xlsx"

#Jira adresss
Set-JiraConfigServer -Server "https://jira-server.com"

############################################

$issues = new-object System.Collections.ArrayList

foreach ($field in (Import-XLSX -Path $path -RowStart 1))
 
{
    $issues.add($field) | out-null
}

$issuesfull = @()

foreach ($issue in $issues | Where { $_.key -and $_.key.Trim() })
{
    $i++
    $issuesfull += ($issue.key)
}

Write-Host "Pieteikumi: " $issuesfull  -ForegroundColor yellow
Write-Host "Dati tiks rakstīti" $i "pieteikumos. Tiklīdz ievadīsies lietotāja datus, tā sāksies datu rakstīšana." -ForegroundColor green
Write-Host "--------------------------------------" -ForegroundColor green

$cred = Get-Credential

foreach ($issue in $issues | Where { $_.key -and $_.key.Trim() })
{
    write-host "`n"
    $a++
    Write-Host "Izpildes statuss: " $a "/" $i -ForegroundColor gray
    Write-Host "Raksta datus pieteikumā: " $issue.key -ForegroundColor green
    Write-Host "Investīciju gads: " $issue.ig
    Write-Host "Projekta uzsākšanas gads: " $issue.pug
    Write-Host "Ranga datums: " $issue.rd.ToString('yyyy-MM-dd')
    Write-Host "Ranga vieta: " $issue.vr

## Custom field configuration

    $fields = @{
        customfield_11758 = @{
            value = [string]$issue.ig
        }
        customfield_12031 = @{
            value = [string]$issue.pug
        }
        customfield_24240 = $issue.rd.ToString('yyyy-MM-dd')
        customfield_24241 = [int]$issue.vr
    }

    Try
    {
        Set-JiraIssue -Issue $issue.key -Fields $fields -Credential $cred
        Write-Host "Dati ierakstīti pieteikumā: " $issue.key -ForegroundColor green
    }
    Catch
    {
        $ErrorMessage = $_.Exception.Message
        $FailedItem = $_.Exception.ItemName
        Write-Host "Error: $ErrorMessage" -ForegroundColor red
    }
    
}

Write-Host -NoNewLine "Datu rakstīšana pieteikumos beigusies. Nospiediet jebkuru taustiņu, lai izietu..." -ForegroundColor yellow
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
Stop-Transcript

How to disable the PDF Preview feature in JIRA 7

  • Copy locally and extract Jira bundled plugin jira-fileviewer-plugin-7.2.1.jar located at ./atlassian-jira/WEB-INF/atlassian-bundled-plugins
  • In extracted folder open file-service.js and delete (or wrap in comment) following lines:
if (!featureManager.isFeatureEnabled("jira.fileviewer.disable.pdf")) {
    selectors.document.push("a[file-preview-type=document]");
}
addDocumentSelector: function addDocumentSelector(sel) {
    pushSingleOrArray(selectors.document, sel);
}
  • Remove same lines from minified file-service-min.js.  You can use JS prettify and minify tools to do this.
  • Save files. Put folder content in ZIP. Rename file to jira-fileviewer-plugin-7.2.1.jar, copy to server and restart Jira.
Olderposts

Copyright © 2020 drinkits

Izstrādājis Anders NorénUz augšu ↑