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
# I had trouble with the player saving data from the previous turns, namely | |
# the escape route I was generating to escape from 2 or more enemies. So, | |
# I put the behavior into a Brain that is a finite state machine. It's not | |
# that great, but you can see what I've got. | |
# | |
# This guy ought to solve ruby-warrior puzzles: | |
# - intermediate-001 | |
# - intermediate-002 | |
# - intermediate-003 |
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
<?php | |
/******************************************************************************* | |
PHP Crypt 0.1 | |
============= | |
Original Source: http://gist.github.com/165342 | |
Designed for password protection. Provides some extent of customization over |
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
# Ruby translation of: http://kaioa.com/node/53#comment-477 | |
probabilities = [1, 1, 1, 1, 1, 1]; | |
unrandomness = 1; | |
def cumsum(vector) | |
_dup = vector.dup | |
1.upto(_dup.length - 1) { |i| _dup[i] += _dup[i-1] } | |
_dup | |
end |
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
a { | |
-moz-transition: 0.2s color linear; | |
-webkit-transition: 0.2s color linear; | |
transition: 0.2s color linear; | |
color: #333; | |
} | |
a:hover { | |
color: #933; | |
} |
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
// An example for: | |
// http://blog.rebeltix.com/2011/04/css-sass-and-how-to-improve-the-mess/ | |
@for $i from 1 through 6 { | |
h#{$i} {font-size: 12pt + (14 - $i*2);} | |
} | |
@for $i from 1 through 3 { | |
box-level-#{$i} {background-color: #333 + ($i * #333);} | |
} |
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
<?php | |
// Originally by Andrew Moore | |
// Src: http://stackoverflow.com/questions/4795385/how-do-you-use-bcrypt-for-hashing-passwords-in-php/6337021#6337021 | |
// | |
// Heavily modified by Robert Kosek, from data at php.net/crypt | |
class Bcrypt { | |
private $rounds; | |
private $prefix; |
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
var http = require('http'); | |
function fib(n){ | |
if (n < 2) return 1; | |
else return fib(n-2) + fib(n-1); | |
} | |
var cached_fib = (function(){ | |
var cache = {}; | |
return function(n) { |
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
package main | |
import ( | |
"fmt" | |
cr "crypto/rand" | |
"os" | |
enc "encoding/ascii85" | |
"big" | |
) |
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
<?php | |
function print_args() { | |
foreach(func_get_args() as $value) | |
echo var_dump($value) . "\n"; | |
} | |
// This will print "int(2)" | |
print_args(extract(array('key' => 'value', "bool" => false))); |
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
-- Calculates the 1st and 3rd quartiles, and the median, from a given table. | |
-- This cannot be optimized except by adding an index to the column, as MySQL | |
-- doesn't support NTILE() natively. | |
SET @temp_rows = (SELECT GROUP_CONCAT(column ORDER BY column ASC SEPARATOR ',') FROM table WHERE column IS NOT NULL); | |
SET @temp_count = (SELECT COUNT(column) FROM table WHERE column IS NOT NULL); | |
SELECT | |
(SUBSTRING_INDEX(SUBSTRING_INDEX(@temp_rows, ',', ROUND(@temp_count * 0.25 + 1)), ',', -1)) AS 'q1', | |
(SUBSTRING_INDEX(SUBSTRING_INDEX(@temp_rows, ',', ROUND(@temp_count * 0.5 + 1)), ',', -1)) AS 'median', |
OlderNewer