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 PostsController | |
def show | |
... | |
respond_to do |format| | |
format.html | |
format.css do | |
render :string => post.css | |
end | |
end | |
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
# Usage: | |
# >> User.random | |
# => #<User login: ... | |
class ActiveRecord::Base | |
def self.random | |
cc = count | |
begin | |
find(rand(cc)) |
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
user system total real | |
Hash Insert: 0.050000 0.000000 0.050000 ( 0.050243) | |
Trie Insert: 1.810000 0.010000 1.820000 ( 1.829849) | |
user system total real | |
Hash Search: 8.240000 0.030000 8.270000 ( 8.318251) | |
Trie Search: 5.990000 0.020000 6.010000 ( 6.055828) |
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
; Potion Mode | |
(defconst potion-indent-offset 2 "Offset for indentation.") | |
; Stolen from Ioke Mode | |
(defconst potion-operator-symbols | |
'("?" "..." "=>" "++" "--" "*" "/" "%" "+" "-" "<<" ">>" ">" "<" "<=" ">=" "<=>" "==" "!=" "=~" "!~" "&" "^" "|" "&&" "||" ".." "=" "+=" "-=" "*=" "/=" "%=" "&=" "^=" "|=" "<<=" ">>=" "<-" "<->" "->") | |
"Potion mode operator symbols") | |
(defgroup potion-font-lock-faces nil |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <sys/mman.h> | |
#include <sys/fcntl.h> | |
#include <time.h> | |
typedef struct _Node { | |
int key; |
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
(defconst css2-tags | |
'("a" "abbr" "acronym" "address" "applet" "area" "b" | |
"base" "basefont" "bdo" "big" "blockquote" "body" "br" | |
"button" "caption" "center" "cite" "code" "col" | |
"colgroup" "dd" "del" "dfn" "dir" "div" "dl" "dt" "em" | |
"fieldset" "font" "form" "frame" "frameset" "h1" "h2" | |
"h3" "h4" "h5" "h6" "head" "hr" "html" "i" "iframe" | |
"img" "input" "ins" "isindex" "kbd" "label" "legend" | |
"li" "link" "map" "menu" "meta" "noframes" "noscript" | |
"object" "ol" "optgroup" "option" "p" "param" "pre" "q" |
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
def factorial(n) | |
(2..n).inject(1) { |o,k| o * k } | |
end | |
def binomial_coefficient(n,k) | |
factorial(n) / (factorial(n - k) * factorial(k)) | |
end | |
def binomial_distribution(p,n) | |
(1..n).inject(0) do |total,k| |
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
diff --git a/Makefile b/Makefile | |
index fe1e2b2..22546c1 100644 | |
--- a/Makefile | |
+++ b/Makefile | |
@@ -5,7 +5,7 @@ PHP_EXT_BUILD=$(REDIS_HOME)/php/build | |
libredis: src/batch.o src/connection.o src/ketama.o src/md5.o src/module.o src/parser.o src/buffer.o | |
mkdir -p lib | |
- gcc -shared -o"lib/libredis.so" ./src/batch.o ./src/buffer.o ./src/connection.o ./src/ketama.o ./src/md5.o ./src/module.o ./src/parser.o -lm -lrt | |
+ gcc -shared -o "lib/libredis.so" ./src/batch.o ./src/buffer.o ./src/connection.o ./src/ketama.o ./src/md5.o ./src/module.o ./src/parser.o -lm |
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
Search.prototype._findNthWord = function(node, n, current_count) { | |
if(current_count === undefined) | |
current_count = { i: 0 }; | |
var children = node.childNodes; | |
for(var i = 0; i < children.length; i++) { | |
var child = children[i]; | |
switch(child.nodeType) { | |
case 1: | |
var result = this._findNthTextNode(child, n, current_count); |
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
def A(x,y) | |
if y == 0 | |
0 | |
elsif x == 0 | |
2 * y | |
elsif y == 1 | |
2 | |
else | |
A(x - 1, A(x, y - 1)) | |
end |
OlderNewer