Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / Hdfs.hs
Created March 19, 2012 17:19
A Haskell API wrapping libhdfs
module System.Hdfs where
import Data.ByteString (ByteString)
import qualified Data.ByteString as B
import Data.Int
import Data.Vector (Vector)
import Data.Word
import Foreign.Ptr
type Size = Int32
@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
#
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@jboner
jboner / latency.txt
Last active May 17, 2024 01:05
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
@sadache
sadache / gist:3026886
Created July 1, 2012 05:01
Bits'bout Play2 Architecture

Bits'bout Play2 Architecture

Play2 Simple HTTP API

Essential blueprint of Play2 architecture is pretty simple and it should be easy to explain in a fairly short blog post. The framework can be understood progressively at different levels; each time having better exposure to some aspects of its design.

The core of Play2 is really small, surrounded by a fair amount of useful APIs, services and structure to make Web Programming tasks easier.

Basically, Play2 is an API that abstractly have the folllowing type

@ToddG
ToddG / TimerWebSocketServlet.java
Created July 4, 2012 15:05
AngularJS + Jetty + WebSockett Example : TimerWebSocketServlet
import org.eclipse.jetty.websocket.WebSocket;
import org.eclipse.jetty.websocket.WebSocketServlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
@mandubian
mandubian / gist:3377514
Created August 17, 2012 09:48
Play2 new plugin: File NonBlocking/Async API - Copying a file
"copy file" in {
var i = 0
val fileGenerator = Enumerator.fromCallback( () =>
if(i<1000){ i+=1; Future.successful(Some((new java.util.Date).getTime.toString + "\n")) } else Future(None)
)
val f = FileChannel("/tmp/testwrite.txt").delete.writing.create
val f2 = FileChannel("/tmp/testwrite2.txt").delete.writing.create
fileGenerator // generates data
@victorbstan
victorbstan / clips.html
Created August 25, 2012 20:34
Angular JS and Rails 3 Infinite Scroll Pagination
<!--
This is the HTML portion of the infinite scroll/pagination with Rails and AngularJS tutorial
Required libraries for the tutorial and indicated as "Important",
together with implementation specific libraries marked as "Optional"
-->
<!DOCTYPE html>
<html>
<title>Clips</title>
<!-- Important -->
@railwaycat
railwaycat / mac-switch-meta.el
Created August 28, 2012 13:43
meta key switch
;; Keybonds
(global-set-key [(hyper a)] 'mark-whole-buffer)
(global-set-key [(hyper v)] 'yank)
(global-set-key [(hyper c)] 'kill-ring-save)
(global-set-key [(hyper s)] 'save-buffer)
(global-set-key [(hyper l)] 'goto-line)
(global-set-key [(hyper w)]
(lambda () (interactive) (delete-window)))
(global-set-key [(hyper z)] 'undo)
@jirutka
jirutka / rules-both.iptables
Created September 18, 2012 12:42
Basic iptables template for ordinary servers (both IPv4 and IPv6)
###############################################################################
# The MIT License
#
# Copyright 2012-2014 Jakub Jirutka <jakub@jirutka.cz>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is