This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//There are 100 people sat at a circular table. | |
//You go around the table asking every second person to leave (starting by asking the guy at seat 1 to leave) until there is one person left. | |
//Which seat is left? | |
//usage: java Survivor 100 | |
class Survivor { | |
public static void main(String[] args){ | |
int n = Integer.parseInt(args[0]); | |
int result = eliminate(1, 1, n, false); | |
System.out.println(result); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ $# -eq 0 ] | |
then | |
echo "usage: explode <dir>" | |
exit 1 | |
fi | |
mv $1/* $1/.. | |
rm -r $1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FIND_PUTS = false | |
if FIND_PUTS | |
def puts(*args) | |
print("#{caller.first}: ") | |
super | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Git pre-commit hook to check all staged Ruby (*.rb/haml/coffee) files | |
# for Pry binding references | |
# | |
# Installation | |
# | |
# ln -s /path/to/pre-commit.sh /path/to/project/.git/hooks/pre-commit | |
# | |
# Based on | |
# | |
# http://codeinthehole.com/writing/tips-for-using-a-git-pre-commit-hook/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tree | |
attr_accessor :elements | |
def initialize(&block) | |
@elements = '' | |
instance_eval(&block) | |
end | |
def method_missing(method_name, *args, &block) | |
@elements << "<#{method_name}>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <cstring> | |
int complies(const char * word){ | |
char order[30]; | |
int wordLength, wordPointer, orderLength, orderPointer; | |
strcpy(order, "qazwsxedcrfvtgbyhnujmikolp"); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name GMail FatChat | |
// @description Widens gmail chats considerably | |
// @namespace http://chrisciollaro.com | |
// @match https://mail.google.com/mail/* | |
// @version 1.0 | |
// ==/UserScript== | |
//not pretty code, just wanted to throw something together that worked. google makes it tough by not giving many of their elements unique identifiers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
def random_method | |
begin | |
method = self.methods.sample.to_s | |
print "Calling #{method}: " | |
return_val = self.instance_eval(method) | |
puts return_val | |
rescue Exception => e | |
puts "it failed (#{e.message})" | |
retry |
NewerOlder