Skip to content

Instantly share code, notes, and snippets.

View ScalaWilliam's full-sized avatar
🏠
Working from home

ScalaWilliam ScalaWilliam

🏠
Working from home
View GitHub Profile
@dt
dt / install_flatmap_reminder.sh
Created July 18, 2011 21:58
In case you occasionally forget to flatMap that shit
brew install growlnotify
cat >> ~/.bashrc <<EOF
#flatMapThatShit reminder
if [ -f /tmp/flatMapThatShit ]; then
kill \`cat /tmp/flatMapThatShit\`
fi
while true; do if [[ \$RANDOM%12 -eq 0 ]]; then growlnotify -a TextEdit "Is that scala?" -m "flatMap that shit"; fi; sleep 300; done &
@jneira
jneira / express-sample.cljs
Created August 25, 2011 20:07
Clojurescript / node.js basic examples
(ns express_sample
(:require [cljs.nodejs :as node]))
(def express (node/require "express"))
(def app (. express (createServer)))
(defn -main [& args]
(doto app
(.use (. express (logger)))
(.get "/" (fn [req res]
@gclaramunt
gclaramunt / Circularbuffer.scala
Created November 23, 2011 17:33
circular buffer
package my.collections
class CirculrBufferIterator[T](buffer:Array[T], start:Int) extends Iterator[T]{
var idx=0
override def hasNext = idx<buffer.size
override def next()={
val i=idx
idx=idx+1
buffer(i)
}
@wangzaixiang
wangzaixiang / EsperUtil.scala
Created December 12, 2011 03:55
Using Esper with Scala
package demo1
import com.espertech.esper.client.EventBean
import com.espertech.esper.client.EPAdministrator
import com.espertech.esper.client.UpdateListener
import com.espertech.esper.client.EPListenable
import com.espertech.esper.client.EPServiceProvider
object EsperUtil {
@conikeec
conikeec / EsperUtil.scala
Created February 12, 2012 08:06 — forked from wangzaixiang/EsperUtil.scala
Using Esper with Scala
package demo1
import com.espertech.esper.client.EventBean
import com.espertech.esper.client.EPAdministrator
import com.espertech.esper.client.UpdateListener
import com.espertech.esper.client.EPListenable
import com.espertech.esper.client.EPServiceProvider
object EsperUtil {
@krasserm
krasserm / jaxb-01.scala
Created February 23, 2012 08:23
JAXB-based XML and JSON APIs
import javax.xml.bind.annotation._
@XmlRootElement(name = "person")
@XmlAccessorType(XmlAccessType.FIELD)
case class Person(fullname: String, username: Option[String], age: Int)
@aprock
aprock / gist:2037883
Created March 14, 2012 17:00
manually serialize/deserialize android bundle
private String serializeBundle(final Bundle bundle) {
String base64 = null;
final Parcel parcel = Parcel.obtain();
try {
parcel.writeBundle(bundle);
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
final GZIPOutputStream zos = new GZIPOutputStream(new BufferedOutputStream(bos));
zos.write(parcel.marshall());
zos.close();
base64 = Base64.encodeToString(bos.toByteArray(), 0);
@robinsmidsrod
robinsmidsrod / _INSTALL.md
Last active July 26, 2024 01:29
Bootstrapping full iPXE native menu with customizable default option with timeout (also includes working Ubuntu 12.04 preseed install)

Add the following chunk to your existing ISC dhcpd.conf file.

if exists user-class and ( option user-class = "iPXE" ) {
    filename "http://boot.smidsrod.lan/boot.ipxe";
}
else {
    filename "undionly.kpxe";
}

(or see https://gist.github.com/4008017 for a more elaborate setup

@jboner
jboner / latency.txt
Last active July 26, 2024 04:31
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
@hail2u
hail2u / twitter-bird.svg
Created June 6, 2012 20:39
SVG version of the new Twitter bird.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.