Skip to content

Instantly share code, notes, and snippets.

View sgrankin's full-sized avatar
🎏

Sergey Grankin sgrankin

🎏
  • 04:30 (UTC -04:00)
View GitHub Profile
from gevent import spawn
from gevent.queue import Queue
def whisper(left, right):
left.put(right.get() + 1)
def main():
n = 100000
leftmost = Queue()
left, right = None, leftmost
@sgrankin
sgrankin / quantize.py
Last active August 29, 2015 14:04
Quantize inputs like dtrace does
"""
Re-bucket input histogram in linear or exponential buckets.
Input:
value\tcount
Output:
quantized_value\tcount
"""
#!/usr/bin/env ruby
# find all branches which have been squash merged into master
require 'pp'
# all branches
branches = %x{git branch | sed s/^..//}.split.map(&:chomp)
# sort by branch age; generate pretty time stamp while we're at it
branch_times = branches.map{|branch|
@sgrankin
sgrankin / com.docker.machine.default.sh
Created June 11, 2016 17:12
Docker machine LaunchAgent using launchctl to set environment vars
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# Library/LaunchAgents/com.docker.machine.default.plist
#
echo x - Library/LaunchAgents/com.docker.machine.default.plist
@sgrankin
sgrankin / gist:9bf1654833f2d1406eebb2ee1d9ce897
Last active July 3, 2016 15:42
mac docker + kubernetes 1.3 "fix"
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
scriptdir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
. $scriptdir/env.sh
echo ">>>>> Mac Docker found - making /var/lib/kubelet shared"
MOBY_TTY="${HOME}/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty"
if [ -c "$MOBY_TTY" ]; then
@sgrankin
sgrankin / reviewable.js
Last active July 7, 2016 17:59
gerrit style reviewable key bindings
[
["f", "Show next/latest diffs", "setProposedRevRanges()"],
["shift+]", "Next unreviewed file", "nextUnreviewedFile()"],
["shift+[", "Previous unreviewed file", "prevUnreviewedFile()"],
["]", "Next changed file", "nextChangedFile()"],
["[", "Previous changed file", "prevChangedFile()"],
[null, "Next visible file", "nextVisibleFile()"],
[null, "Previous visible file", "prevVisibleFile()"],
@sgrankin
sgrankin / idea.vmoptions
Created December 16, 2016 17:01
idea.vmoptions - my current IntelliJ vm options
-Xms4g
-Xmx4g
-XX:-UseParNewGC
-XX:-UseConcMarkSweepGC
-XX:ReservedCodeCacheSize=1g
-XX:+UseG1GC
-XX:+DisableExplicitGC
@sgrankin
sgrankin / ending.gcode
Created December 23, 2016 03:35
m2 simplify3d scripts
M140 S0 ; turn off bed
G91 ; relative mode
G1 Z20 ; lift
G90 ; absolute mode
G92 E18 ; extruder relative pos
G1 F300 ; set speed
G1 E0 ; retract filament
G92 E0 ; extruder relative pos
package main
import java.util
import java.util.concurrent.RejectedExecutionException
import com.twitter.app.App
import com.twitter.concurrent.Permit
import com.twitter.finagle.http.{Request, Response}
import com.twitter.finagle.util.HashedWheelTimer
import com.twitter.finagle.{Http, Service, param => fparam, _}
@sgrankin
sgrankin / tagged.scala
Created July 14, 2017 15:24
scala tagged types
import com.twitter.bijection.Bijection
package object tagging {
sealed trait Tagged[+V, +T]
type @@[+V, +T] = V with Tagged[V, T]
object Tagged {
implicit class Untaggable[V, T](val tagged: V @@ T) extends AnyVal {
@inline def untag: V = tagged
}