Skip to content

Instantly share code, notes, and snippets.

@nmerouze
nmerouze / main.go
Last active January 17, 2025 21:20
JSON-API with Go and MongoDB: Final Part
package main
import (
"encoding/json"
"log"
"net/http"
"reflect"
"time"
"github.com/gorilla/context"
@albertoleal
albertoleal / negroni_issue.go
Last active August 29, 2015 14:10
negroni_issue.go
package main
import (
"fmt"
"log"
"net/http"
"time"
"github.com/gorilla/context"
"github.com/codegangsta/negroni"
@nmerouze
nmerouze / main.go
Last active March 17, 2025 15:20
Example for "Build Your Own Web Framework in Go" articles
package main
import (
"database/sql"
"encoding/json"
"errors"
"fmt"
"log"
"net/http"
"time"
@staltz
staltz / introrx.md
Last active October 26, 2025 03:06
The introduction to Reactive Programming you've been missing
@efenderbosch
efenderbosch / JpaMapper.java
Last active August 29, 2015 14:00
JPA Mapper for Dropwizard
package com.segmint.jdbi;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.sql.Array;
import java.sql.ResultSet;
import java.sql.SQLException;

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns                     on recent CPU
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 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs 4X memory

@jdkanani
jdkanani / notepad.html
Last active August 31, 2025 09:37 — forked from jakeonrails/Ruby Notepad Bookmarklet
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">.e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div class="e" id="editor"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("editor");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
<!--
For other language: Instead of `ace/mode/ruby`, Use
Markdown -> `ace/mode/markdown`
Python -> `ace/mode/python`
C/C++ -> `ace/mode/c_cpp`
Javscript -> `ace/mode/javascript`
Java -> `ace/mode/java`
Scala- -> `ace/mode/scala`
@ms-tg
ms-tg / play20-scala-add-http-response-header.scala
Created June 28, 2012 17:28
Example usage of GlobalSettings#onRouteRequest in Play framework 2.0.x scala
import play.api._
import mvc._
import controllers.Info.VERSION_PROPERTY
import controllers.Info.DEFAULT_VERSION
object Global extends GlobalSettings {
val VERSION_PROPERTY = "my.property.name"
val DEFAULT_VERSION = "0.0.0"
@mxcl
mxcl / uninstall_homebrew.sh
Created August 26, 2011 11:25
Uninstall Homebrew
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e