Skip to content

Instantly share code, notes, and snippets.

View pr1001's full-sized avatar

Peter Robinett pr1001

View GitHub Profile
@jgoday
jgoday / Boot.scala
Last active July 10, 2016 17:37
Slick with lift ( from https://github.com/ggarciajr/slick.git sample )
package bootstrap.liftweb
import net.liftweb._
import util._
import Helpers._
import common._
import http._
import sitemap._
import Loc._
@kevinwright
kevinwright / ThrottledExecutionContext.scala
Last active October 5, 2018 08:09
Limit number of futures running in parallel (now updated with seize/release implementations suggested by roland)
import java.util.concurrent.ConcurrentLinkedQueue
import java.util.concurrent.atomic.AtomicInteger
import scala.concurrent.ExecutionContext
import scala.util.control.NonFatal
import scala.annotation.tailrec
//inspired by https://gist.github.com/viktorklang/4552423
object ThrottledExecutionContext {
def apply(maxConcurrents: Int)(implicit context: ExecutionContext): ExecutionContext = {
@wboykinm
wboykinm / mask.mss
Last active December 11, 2015 17:58
Country-specific masking in CartoCSS
Map {
/*background-color: #b8dee6;*/
}
#countries[ADMIN='Nicaragua'] {
polygon-fill:#abd69b;
line-color:#754098;
polygon-opacity:0;
line-width:6;
line-opacity:0.8;
@retronym
retronym / scala-hash.sh
Created September 17, 2012 21:54
scala-hash
#! /bin/bash
set -e
SCALA_DEV=~/code/scala
HASH=`git --git-dir $SCALA_DEV/.git rev-list "$1" | head -n1`
DESC=`git --git-dir $SCALA_DEV/.git describe $HASH`
shift
DIR=~/usr/scala-$DESC
SCALA=$DIR/pack/bin/scala
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

anonymous
anonymous / gist:2989822
Created June 25, 2012 16:49
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * command to be executed
@jboner
jboner / latency.txt
Last active May 5, 2024 03:12
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
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@sgillies
sgillies / geo_interface.rst
Last active April 10, 2024 00:26
A Python Protocol for Geospatial Data

Author: Sean Gillies Version: 1.0

Abstract

This document describes a GeoJSON-like protocol for geo-spatial (GIS) vector data.

Introduction

@wspringer
wspringer / gist:1649700
Created January 20, 2012 21:28
LZW Encoding *and Decoding* in Scala
object lzw {
trait Appendable[T] {
def append(value: T)
}
import scala.collection.generic._
case class GrowingAppendable[T](growable: Growable[T]) extends Appendable[T] {
def append(value: T) {
growable += value