Skip to content

Instantly share code, notes, and snippets.


Niclas Kron sphrak

View GitHub Profile
sphrak / Jenkinsfile
Created Jul 17, 2018 — forked from jonico/Jenkinsfile
Example for a full blown Jenkins pipeline script with multiple stages, input steps, injected credentials, heroku deploy, sonarqube and artifactory integration, multiple Git commit statuses, PR merge vs branch build detection, REST API calls to GitHub deployment API, stage timeouts, stage concurrency constraints, ...
View Jenkinsfile
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
Please make sure to add the following environment variables:
HEROKU_PREVIEW=<your heroku preview app>
HEROKU_PREPRODUCTION=<your heroku pre-production app>
HEROKU_PRODUCTION=<your heroku production app>
sphrak /
Last active Jan 25, 2021 — forked from ravibhure/
Git commons

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

Add the remote, call it "upstream":

git remote add upstream

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

sphrak /
Created Feb 3, 2019
Extract all rar archives recursively and delete if extraction was successful
for file in $(find . -iname '*.rar'); do
echo "Extracting ${file}..."
dir=$(dirname ${file})
unrar e -y -o+ -p- "${file}" "${dir}"
# check exit status, if not 0 it failed
sphrak / gradient.js
Created Apr 5, 2019 — forked from siamak/gradient.js
Steps in Gradient
View gradient.js
* GradientArray • Steps gradient.
* @author Siamak Mokhtari <>
* @date 06/21/16.
class GradientArray {
// Convert a hex color to an RGB array e.g. [r,g,b]
// Accepts the following formats: FFF, FFFFFF, #FFF, #FFFFFF
hexToRgb(hex) {
let r, g, b, parts;
sphrak /
Last active Apr 23, 2019
Copy windows iso contents to a usb memory and make it bootable

0. Format partition to ntfs somehow

1. Mount usb drive

mount /dev/sdX /media/usb

2. Mount iso

mount windows.iso /media/windows
sphrak / import-images-windows.bat
Last active May 7, 2019
Microsoft removed the standard camera import feature in windows > 7 and forces you to use their dumb app. This is what it has come down to.
View import-images-windows.bat
@echo off
set TARGET=D:\DCIM\path
set DESTINATION=C:\path\to\photos\%date%
echo Copying images from camera %TARGET% to %DESTINATION%
echo d | xcopy /s /y %TARGET% %DESTINATION%\
echo Removing images from camera..
del /s /q "%TARGET%\*.JPG"
import random
from time import sleep
import pygame
class CarRacing:
def __init__(self):
sphrak / pkglist.txt
Created Sep 19, 2019
Archlinux package list
View pkglist.txt
sphrak /
Last active Oct 5, 2020
List of useful linux commands

Useful linux commands

Detect how many gradle daemons are running

Get the current amount of instances - 1

ps aux | grep GradleDaemon | wc -l

perform operation on specific files in directories

sphrak /
Last active Nov 14, 2019
measure android app startup time
# Simple bash script runs adb to measure startup time of android apps
trap ctrl_c INT
function ctrl_c() {