Skip to content

Instantly share code, notes, and snippets.

Avatar
🐱
JITL

Niclas Kron sphrak

🐱
JITL
View GitHub Profile
@sphrak
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
#!groovy
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
sphrak / git_commons.md
Last active Jan 25, 2021 — forked from ravibhure/git_rebase.md
Git commons
View git_commons.md

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 https://github.com/whoever/whatever.git

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

@sphrak
sphrak / unrar.sh
Created Feb 3, 2019
Extract all rar archives recursively and delete if extraction was successful
View unrar.sh
#!/bin/bash
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
sphrak / gradient.js
Created Apr 5, 2019 — forked from siamak/gradient.js
Steps in Gradient
View gradient.js
/**
* GradientArray • Steps gradient.
* @author Siamak Mokhtari <hi@siamak.work>
* @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
sphrak / bootable-windows-on-usb.md
Last active Apr 23, 2019
Copy windows iso contents to a usb memory and make it bootable
View bootable-windows-on-usb.md

0. Format partition to ntfs somehow

1. Mount usb drive

mount /dev/sdX /media/usb

2. Mount iso

mount windows.iso /media/windows
@sphrak
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"
PAUSE
View game.py
import random
from time import sleep
import pygame
class CarRacing:
def __init__(self):
pygame.init()
@sphrak
sphrak / pkglist.txt
Created Sep 19, 2019
Archlinux package list
View pkglist.txt
acpi
acpid
alsa-firmware
alsa-utils
android-studio
android-studio-beta
android-studio-canary
android-tools
atop
audacity
@sphrak
sphrak / terminal.md
Last active Oct 5, 2020
List of useful linux commands
View terminal.md

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
sphrak / benchmark.sh
Last active Nov 14, 2019
measure android app startup time
View benchmark.sh
#!/bin/bash
# Simple bash script runs adb to measure startup time of android apps
trap ctrl_c INT
time=()
function ctrl_c() {
total=0