{{ message }}

Instantly share code, notes, and snippets.

# Matt Weppler mweppler

Created May 18, 2011
Coding: Triangle Numbers Puzzle - from http://www.gild.com/
View TriangleNumbersPuzzle.java
 package pack; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; public class TriangleNumbersPuzzle { private static int returnNumberOfDivisors(int inNum)
Created Aug 3, 2011
Wiki Definition: "In software engineering, the singleton pattern is a design pattern used to implement the mathematical concept of a singleton, by restricting the instantiation of a class to one object."
View Singleton.class
 // Traditional Simple Way: public class Singleton { private static final Singleton instance = new Singleton(); private Singleton() { } public static Singleton getInstance() { return instance; } }
Created Oct 3, 2011
A programming language has 10 different instructions. How many five-instruction programs can be written in this language if no instruction is repeated? How many seven-instruction programs?
View n_instruction_programs.rb
 #!/usr/bin/ruby def factorial n f = n for i in (n - 1).downto(1) f *= i i -= 1 end return f end
Created Oct 4, 2011
Replace images on a page with kittens (boredom)...
View kitties_yay.js
 if (jQuery) (function(\$){ jQuery('img').each(function() { jQuery(this).attr('src', 'http://placekitten.com/g/'+jQuery(this).width()+'/'+jQuery(this).height()); }); })(jQuery);
Created Oct 4, 2011
Get an inventory of the file system...
View inventory_fs.rb
 #!/usr/bin/env ruby def compare_filesystem(previous, current) previous_inventory = File.open(previous).readlines current_inventory = File.open(current).readlines # puts "The following files have been added:" # puts current_inventory - previous_inventory # # puts ""
Created Oct 20, 2011
Learning Binary Trees through recursive programming.
View Dictionary.java
 import java.util.Arrays; import java.util.Collections; import java.util.List; /* * Sample application output: * * **** Building Dictionary Start with Isabella **** *
Created Oct 24, 2011
clip-it bookmarklet
View gist:1310752