Skip to content

Instantly share code, notes, and snippets.

View yannick's full-sized avatar
🏗️

Yannick Koechlin yannick

🏗️
View GitHub Profile
# Used for IO objects that need to report the current offset at each operation that changes the said offset
# (useful for building progress bars that report on a file read operation)
class ProgressiveIO < DelegateClass(IO)
# Should contain a block that accepts the current offset in bytes and the total size
attr_accessor :progress_block
# Get or set the total size of the contained IO. If the passed IO is a File object
# the size will be preset automatically
attr_accessor :total_size
@rkh
rkh / Scala
Created April 2, 2010 19:08
examples for sinatra like frameworks
package com.thinkminimo.step
class StepExample extends Step {
get("/") { "Hello World!" }
}
$ cat tests/sparql/examples/ex11_0.rq
PREFIX a: <http://www.w3.org/2000/10/annotation-ns#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?annot
WHERE { ?annot a:annotates <http://www.w3.org/TR/rdf-sparql-query/> .
?annot dc:created ?date .
FILTER ( ?date < xsd:dateTime("2005-01-01T00:00:00Z") ) }
@bradoaks
bradoaks / hfsc-shape.sh
Created April 25, 2011 14:51 — forked from eqhmcow/hfsc-shape.sh
HFSC - linux traffic shaping's best kept secret
#!/bin/bash
# As the "bufferbloat" folks have recently re-discovered and/or more widely
# publicized, congestion avoidance algorithms (such as those found in TCP) do
# a great job of allowing network endpoints to negotiate transfer rates that
# maximize a link's bandwidth usage without unduly penalizing any particular
# stream. This allows bulk transfer streams to use the maximum available
# bandwidth without affecting the latency of non-bulk (e.g. interactive)
# streams.
@arsduo
arsduo / gist:997914
Created May 29, 2011 16:25
Euruko demo code (Koala & Facebook)
# demo from Euruko lightning talk 2011
# links:
# * http://github.com/arsduo/koala (code/wiki documentation)
# * http://oauth.twoalex.com (easy access tokens)
# * http://developers.facebook.com/docs/coreconcepts/ (FB docs)
# the person I hang out with most
people = g.fql_query("select tagged_uids from checkin where author_uid = me()")
bestfriend = people.collect {|c| c["tagged_uids"]}.flatten.group_by {|u| u}.values.max_by(&:length).first
Koala::Facebook::GraphAPI.batch do
@peterc
peterc / dnsd.rb
Created December 2, 2011 23:47
Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
# Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
# By Peter Cooper
#
# MIT license
#
# * Not advised to use in your production environment! ;-)
# * Requires Ruby 1.9
# * Supports A and CNAME records
# * See http://www.ietf.org/rfc/rfc1035.txt for protocol guidance
# * All records get the same TTL
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@jbgo
jbgo / git-recover-branch.md
Last active May 23, 2024 12:29
How to recover a git branch you accidentally deleted

UPDATE: A better way! (August 2015)

As pointed out by @johntyree in the comments, using git reflog is easier and more reliable. Thanks for the suggestion!

 $ git reflog
1ed7510 HEAD@{1}: checkout: moving from develop to 1ed7510
3970d09 HEAD@{2}: checkout: moving from b-fix-build to develop
1ed7510 HEAD@{3}: commit: got everything working the way I want
70b3696 HEAD@{4}: commit: upgrade rails, do some refactoring
@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
#
/**
* This module contains parsers, formatters and data types for the _http
* protocol.
*
* Headers from rfc2616 which are currently not implemented:
* $(UL
* $(LI $(LINK2 http://tools.ietf.org/html/rfc2616#section-14.8, AuthorizationHeader))
* $(LI $(LINK2 http://tools.ietf.org/html/rfc2616#section-14.9, CacheControlHeader))
* $(LI $(LINK2 http://tools.ietf.org/html/rfc2616#section-14.33, ProxyAuthenticateHeader))
* $(LI $(LINK2 http://tools.ietf.org/html/rfc2616#section-14.34, ProxyAuthorizationHeader))