View random_method.rb
This file contains 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 |
View fatchat.user.js
This file contains 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. |
View order_compliant.c
This file contains 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"); | |
View tree_builder.rb
This file contains 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}>" |
View pre-commit
This file contains 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/ |
View puts_locator.rb
This file contains 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 |
View explode
This file contains 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 |
View Survivor.java
This file contains 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); | |
} |
View CountingSort.java
This file contains 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
public class CountingSort{ | |
public static void main(String[] args){ | |
int[] a = {5,6,7,1,2,4,5,6,1,0,3,4,2}; | |
printArray(countingSort(a, 7)); | |
} | |
public static int[] countingSort(int[] a, int k){ | |
int[] b = new int[a.length]; | |
int[] c = new int[k + 1]; | |
for(int i = 0; i < a.length; i++) |
View ModExp.java
This file contains 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
public class ModExp { | |
public static void main(String[] args) { | |
System.out.println(modExp(4,13,497)); | |
} | |
public static int modExp(int a, int b, int n){ | |
int d = 1; | |
String k = Integer.toBinaryString(b); | |
for(int i = 1; i <= k.length(); i++){ |
OlderNewer