Skip to content

Instantly share code, notes, and snippets.


Niclas Kron sphrak

View GitHub Profile
sphrak / ParallaxScreen.kt
Created May 28, 2022 — forked from surajsau/ParallaxScreen.kt
Parallax effect with Jetpack Compose
View ParallaxScreen.kt
fun ParallaxScreen(modifier: Modifier = Modifier) {
val context = LocalContext.current
val scope = rememberCoroutineScope()
var data by remember { mutableStateOf<SensorData?>(null) }
DisposableEffect(Unit) {
val dataManager = SensorDataManager(context)
sphrak / latency.txt
Created Oct 4, 2020 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
View latency.txt
Latency Comparison Numbers (~2012)
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
sphrak / MaskExtension.kt
Created Feb 8, 2020 — forked from maiconhellmann/MaskExtension.kt
MaskExtension wrote in Kotlin
View MaskExtension.kt
import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
annotation class MaskType
const val PHONE_9_MASK = "(##) #####-####"
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 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 / 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>