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
Array.prototype.evens = function() { | |
var arr = this; | |
var out = []; | |
var count = 0; | |
var even = function(arr, out) { | |
if (count <= arr.length - 1) { | |
if ((arr[count] % 2) === 0) { | |
out.push(arr[count]); | |
} | |
count++; |
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
<? | |
// Quicksilver Score | |
// | |
// A port of the Quicksilver string ranking algorithm | |
// (re-ported from Javascript to PHP by Kenzie Campbell) | |
// http://route19.com/logbook/view/quicksilver-score-in-php | |
// | |
// score("hello world","axl") //=> 0.0 | |
// score("hello world","ow") //=> 0.6 |
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
t = DateTime | |
id = t.now.strftime("%Y%m%d%k%M%S%L") # Get current date to the milliseconds | |
id = id.to_i.to_s(36) # will generate somthing like "5i0sp1h4tkc" | |
# Reverse it | |
id.to_i(36) |
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
<?php | |
function stopWords($text, $stopwords) { | |
// Remove line breaks and spaces from stopwords | |
$stopwords = array_map(function($x){return trim(strtolower($x));}, $stopwords); | |
// Replace all non-word chars with comma | |
$pattern = '/[0-9\W]/'; | |
$text = preg_replace($pattern, ',', $text); |
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
[default] Running chef-solo... | |
[default] stdin: is not a tty | |
: stderr | |
[default] [Sat, 05 Feb 2011 05:32:39 -0800] INFO: Setting the run_list to ["recipe[vagrant_main]"] from JSON | |
[Sat, 05 Feb 2011 05:32:39 -0800] INFO: Starting Chef Run (Version 0.9.12) | |
: stdout | |
[default] [Sat, 05 Feb 2011 05:32:47 -0800] INFO: Ran execute[apt-get update] successfully | |
[Sat, 05 Feb 2011 05:32:48 -0800] FATAL: No cookbook found in ["/tmp/vagrant-chef/cookbooks-0", "/tmp/vagrant-chef/cookbooks"], make sure cookbook_path is set correctly. |
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
'tis | |
'twas | |
a | |
aah | |
aaron | |
abandon | |
abandoned | |
abbott | |
abby | |
abe |
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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8"> | |
<title>Index</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript" charset="utf-8"></script> | |
</head> | |
<body> | |
<form action="index_submit" method="get" accept-charset="utf-8"> |
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
# Project Euler #3 -> http://projecteuler.net/index.php?section=problems&id=3 | |
# Q: What is the largest prime factor of the number 600851475143 ? | |
# Generate a Sieve of Eratosthenes (an array loaded with prime numbers) | |
primes = [] | |
sieve = (set, pos) -> | |
return false if pos >= set.length | |
if set[pos] * set[pos] < set[set.length-1] | |
primes = (x for x in set when x == set[pos] or x % set[pos] != 0) | |
return sieve(primes,pos+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
for n in 0..100 | |
for m in 1..100 | |
if (m>n) | |
a = 2*m*n | |
b = (m**2 - n**2) | |
c = (m**2 + n**2) | |
end | |
if (a + b + c == 1000) | |
puts "Triplet = #{a} + #{b} = #{c} of which the product is #{a*b*c}" |
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
# Sieve of Eratosthenes | |
# (an array loaded with prime numbers) | |
base = [2..10000] | |
primes = [] | |
sieve = (set, pos) -> | |
return false if pos >= set.length | |
if set[pos] * set[pos] < set[set.length-1] | |
primes = _.select set, ((num) -> | |
return num if num == set[pos] | |
return num % set[pos] != 0 |