Skip to content

Instantly share code, notes, and snippets.

View sphrak's full-sized avatar
🐱
hax

Niclas sphrak

🐱
hax
  • Stockholm, Sverige
  • 05:21 (UTC +01:00)
View GitHub Profile
@sphrak
sphrak / Jenkinsfile
Created July 17, 2018 01:33 — 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, ...
#!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 January 25, 2021 13:59 — forked from ravibhure/git_rebase.md
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 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 February 3, 2019 19:00
Extract all rar archives recursively and delete if extraction was successful
#!/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 April 5, 2019 11:09 — forked from siamak/gradient.js
Steps in Gradient
/**
* GradientArray • Steps gradient.
* @author Siamak Mokhtari <[email protected]>
* @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 April 23, 2019 07:48
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
sphrak / import-images-windows.bat
Last active May 7, 2019 09:01
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.
@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
import random
from time import sleep
import pygame
class CarRacing:
def __init__(self):
pygame.init()
@sphrak
sphrak / pkglist.txt
Created September 19, 2019 06:12
Archlinux package list
acpi
acpid
alsa-firmware
alsa-utils
android-studio
android-studio-beta
android-studio-canary
android-tools
atop
audacity
@sphrak
sphrak / terminal.md
Last active February 15, 2022 11:21
List of useful unix commands

Useful unix commands

recursively search files matching *.fileExt for pattern in current directory

grep --color -inr --include \*.kt 'SDK_INT' .

Detect how many gradle daemons are running

@sphrak
sphrak / benchmark.sh
Last active March 31, 2022 11:58
measure android app startup time
#!/bin/bash
# Simple bash script runs adb to measure startup time of android apps
trap ctrl_c INT
time=()
function ctrl_c() {
total=0