Skip to content

Instantly share code, notes, and snippets.

@think49
think49 / Array.prototype.shuffle.txt
Created January 28, 2011 14:24
array-shuffle.js : "Fisher–Yates shuffle"
----------------------
Fisher–Yates shuffle
----------------------
* Fisher and Yates' original method
1. Write down the numbers from 1 to N.
2. Pick a random number k between one and the number of unstruck numbers remaining (inclusive).
3. Counting from the low end, strike out the kth number not yet struck out, and write it down elsewhere.
4. Repeat from step 2 until all the numbers have been struck out.
@EmilHernvall
EmilHernvall / wordcount.java
Created May 3, 2011 17:15
Find the most popular words in a file - Java version
import java.io.*;
import java.util.*;
public class wordcount
{
public static class Word implements Comparable<Word>
{
String word;
int count;
@jaysonrowe
jaysonrowe / FizzBuzz.py
Created January 11, 2012 03:05
FizzBuzz Python Solution
def fizzbuzz(n):
if n % 3 == 0 and n % 5 == 0:
return 'FizzBuzz'
elif n % 3 == 0:
return 'Fizz'
elif n % 5 == 0:
return 'Buzz'
else:
return str(n)
@nblumoe
nblumoe / angularjs_resource_tokenhandler.js
Created July 5, 2012 07:34
AngularJS service to send auth token with $resource requests
.factory('TokenHandler', function() {
var tokenHandler = {};
var token = "none";
tokenHandler.set = function( newToken ) {
token = newToken;
};
tokenHandler.get = function() {
return token;
@jbochi
jbochi / skyline.py
Created August 7, 2012 17:12
Solution for dailykata.net - Skyline problem in Python
buildings = [
[1, 11, 5],
[2, 6, 7],
[3, 13, 9],
[12, 7, 16],
[14, 3, 25],
[19, 18, 22],
[23, 13, 29],
[24, 4, 28],
]
@arvearve
arvearve / gist:4158578
Created November 28, 2012 02:01
Mathematics: What do grad students in math do all day?

Mathematics: What do grad students in math do all day?

by Yasha Berchenko-Kogan

A lot of math grad school is reading books and papers and trying to understand what's going on. The difficulty is that reading math is not like reading a mystery thriller, and it's not even like reading a history book or a New York Times article.

The main issue is that, by the time you get to the frontiers of math, the words to describe the concepts don't really exist yet. Communicating these ideas is a bit like trying to explain a vacuum cleaner to someone who has never seen one, except you're only allowed to use words that are four letters long or shorter.

What can you say?

o o o
o x
o x x x
x o
x x x o
x
o o
o
@jakeonrails
jakeonrails / Ruby Notepad Bookmarklet
Created January 29, 2013 18:08
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>

Identity Crisis

Written by Nathan Lilienthal or:

  • nathanlil13
  • nathanl
  • nathan
  • nate
  • nathan.lilienthal
  • lilienthal.nathan
# custom/processors.py
from django.conf import settings
from django.core.files.storage import default_storage
try:
from PIL import Image
except ImportError:
import Image