Skip to content

Instantly share code, notes, and snippets.

View agemooij's full-sized avatar

Age Mooij agemooij

View GitHub Profile
@a7madgamal
a7madgamal / dark.md
Last active July 14, 2023 04:00
Dark mode for Slack on MacOS
@viktorklang
viktorklang / restart_audio.sh
Created December 11, 2016 08:05
Emergency audio reset on OS X / macOS when faced with loss of audio
#Use at your own risk. No warranties expressed or implied. YMMV. Drive responsibly. Eat healthy.
#for ZSH, I typically put these in my .zshrc
function restart_audio() {
command sudo killall coreaudiod &&
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist &&
sudo launchctl load /System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist &&
echo 'Audio daemon restarted'
}
@klingerf
klingerf / blue-green.groovy
Created November 4, 2016 03:10
Jenkins pipeline script to perform blue-green deploys to a Kubernetes cluster running linkerd and namerd
node {
def currentVersion = getCurrentVersion()
def newVersion = getNextVersion(currentVersion)
def frontendIp = kubectl("get svc l5d -o jsonpath=\"{.status.loadBalancer.ingress[0].ip}\"").trim()
def originalDst = getDst(getDtab())
stage("clone") {
git url: gitRepo + '.git', branch: gitBranch
}
@sandrinodimattia
sandrinodimattia / authorization-api.md
Created May 5, 2016 09:42
Auth0 Authorization Extension API

Create a group

POST https://sandbox.it.auth0.com/api/run/YOUR_ACCCOUNT/YOUR_EXTENSION/api/groups

{
  "name": "My group",
  "description": "My group description"
}
@acolyer
acolyer / service-checklist.md
Last active June 20, 2024 08:47
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@ryanlecompte
ryanlecompte / gist:7287415
Last active December 27, 2015 07:18
Immutable PrefixMap
import scala.collection.generic.CanBuildFrom
import scala.collection.immutable.MapLike
import scala.collection.mutable
/**
* Immutable version of the PrefixMap demonstrated in the Scala collections
* guide here: http://www.scala-lang.org/docu/files/collections-api/collections-impl_6.html
*
* This version also has a smarter remove method (doesn't leave behind dead nodes with empty values)
*/
@ayosec
ayosec / CORSDirectives.scala
Created December 18, 2012 03:28
CORS with Spray
package foo.bar
import spray.routing._
import spray.http._
import spray.http.StatusCodes.Forbidden
// See https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS
case class Origin(origin: String) extends HttpHeader {
@analytically
analytically / gist:4295042
Created December 15, 2012 13:37
Migration of gist:4293859
def rateLimit(action: => String, subject: => String, maxRequests: => Int): Directive0 = {
mapInnerRoute {
inner => ctx =>
val key = action + ":" + subject
add(redis, key)
val actionCount = count(redis, key, interval)
if (actionCount >= maxRequests) {
logger.warn("Rate limiting user '" + subject + "': exceeded max number of requests (" + maxRequests + ").")
@jboner
jboner / latency.txt
Last active June 29, 2024 19:54
Latency Numbers Every Programmer Should Know
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
@vybs
vybs / rhino_dust.java
Created January 17, 2012 02:15
Sample code to rendering dust template using Rhino
package com.linkedin.dust.renderer;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Writer;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.JavaScriptException;