Skip to content

Instantly share code, notes, and snippets.

@torsten
torsten / proxy.rb
Last active March 12, 2023 21:44
A quick HTTP proxy server in Ruby.
#!/usr/bin/env ruby
# A quick and dirty implementation of an HTTP proxy server in Ruby
# because I did not want to install anything.
#
# Copyright (C) 2009-2014 Torsten Becker <torsten.becker@gmail.com>
#
# 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,
@torsten
torsten / navajo.rb
Last active September 3, 2015 17:45
Navajo, a stupid simple Apache replacement (kinda)
#!/usr/bin/env ruby
# Copyright 2009-2014 Torsten Becker
#
# 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 furnished to do so, subject to
# the following conditions:
@rti
rti / gist:1605397
Created January 13, 2012 10:09
KISS cpp profiling - easy to use cpu time measurement helper
/*
* USAGE:
* #include <ctime>
* ...
* void your_func() {
* measure_time t(__func__);
* // your code...
* }
*/
struct measure_time {
@hanshasselberg
hanshasselberg / .vimrc
Last active September 30, 2015 22:07
Vim configuration
set nocompatible
filetype off
call pathogen#helptags()
call pathogen#runtime_append_all_bundles()
set nobackup
set nowritebackup
set noswapfile
set history=1000
set ruler
@larsxschneider
larsxschneider / jsmethods.js
Created March 30, 2012 13:50
Render all JS methods
function getMethods(obj) {
var result = [];
for (var id in obj) {
try {
if (typeof(obj[id]) == "function") {
result.push(id + ": " + obj[id].toString());
}
} catch (err) {
result.push(id + ": inaccessible");
}
@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
#
@mikeash
mikeash / test.m
Created July 9, 2012 21:15
Cocoa array slicing
// clang -framework Foundation -fobjc-arc -O3 test.m
#import <Foundation/Foundation.h>
@interface Slice : NSObject
@property NSInteger start;
@property NSInteger length;
@end
@implementation Slice
@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:

@agnoster
agnoster / github.com.js
Created October 17, 2012 15:59
Like editing files in an open pull request?
/**
* 1) Use http://defunkt.io/dotjs/
* 2) Install this into ~/.js/github.com.js
* 3) Enjoy a button to edit any file on a pull request (some restrictions may apply, void where prohibited)
*
* Note: this will replace the "View file @ ...", which I find pretty useless (and it's contained in the edit mode,
* anyway). However, if you want to look at files where you don't have access to edit them, this will suck.
*/
function getBranch() {
@larsxschneider
larsxschneider / github.com.js
Created October 31, 2012 17:25 — forked from agnoster/github.com.js
View/edit a file in a pull request by clicking on the line number.
/**
* 1) Use http://defunkt.io/dotjs/
* 2) Install this into ~/.js/github.com.js
* 3) Click on a line number in the editor to open the file at this position (e.g. to see more context)
* 4) Alt+Click on a line number in the editor to edit the file at this position
*
* This script is based on @agnoster's idea: https://gist.github.com/3906361
*/
function getBranch() {