View custom_template_functions.go
content, err = ioutil.ReadFile("templates/rss.xml") | |
if err != nil { | |
panic(err) | |
} | |
//Custom template helpers | |
fm := template.FuncMap{"number": func(n int) string { | |
return strconv.Itoa(n) | |
}, "float": func(f float64) string { | |
return strconv.FormatFloat(f, 'f', -1, 64) |
View haiku.ex
def generate_name do | |
# [[64][64]] | |
[["autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark", | |
"summer", "icy", "delicate", "quiet", "white", "cool", "spring", "winter", | |
"patient", "twilight", "dawn", "crimson", "wispy", "weathered", "blue", | |
"billowing", "broken", "cold", "damp", "falling", "frosty", "green", | |
"long", "late", "lingering", "bold", "little", "morning", "muddy", "old", | |
"red", "rough", "still", "small", "sparkling", "throbbing", "shy", | |
"wandering", "withered", "wild", "black", "young", "holy", "solitary", | |
"fragrant", "aged", "snowy", "proud", "floral", "restless", "divine", |
View worker_mongodb_queue.go
package main | |
import ( | |
"os" | |
"log" | |
"gopkg.in/mgo.v2" | |
"gopkg.in/mgo.v2/bson" | |
"time" | |
) |
View CreateCappedCollection.js
db.createCollection("jobs", { | |
capped: 1, | |
size: 100000, | |
max: 10 | |
}) |
View search.sql
SELECT | |
ID, | |
post_title, | |
post_status, | |
CONCAT('http://www.yourwebsite.com/wp-content/uploads/', | |
thumbnail.meta_value) AS picture, | |
MATCH (post_title) AGAINST ('term') AS title_score, | |
MATCH (post_excerpt) AGAINST ('term') AS excerpt_score, | |
MATCH (post_content) AGAINST ('term') AS content_score | |
FROM wp_posts |
View recommended_posts.sql
-- | |
-- Replace 1 with the post id | |
-- | |
WITH | |
posts_query AS ( | |
SELECT | |
to_tsvector(posts.title) AS posts_title, | |
to_tsvector(posts.tags) AS posts_tags | |
FROM posts | |
), |
View post-receive
#!/bin/sh | |
# | |
# On your local machine | |
# | |
# local$ npm install --production | |
# local$ meteor build .build --architecture os.linux.x86_64 | |
# | |
# On your server |
View server-power.sh
# workers | |
# grep processor /proc/cpuinfo | wc -l | |
# | |
# workers connections | |
# ulimit -n | |
# Check the architecture | |
grep --color=always -iw lm /proc/cpuinfo | |
# Buid go workers |
View post-receive
#!/bin/sh | |
APP_PATH=$APP_ROOT | |
exit_with_error(){ | |
echo "---> An Error Has Occurred!" | |
} | |
echo "---> Receiving push as $USER" | |
git --work-tree=$APP_PATH --git-dir=$GIT_DIR checkout -f |
View ParseJSONFromURL.swift
//: Playground - noun: a place where people can play | |
import Cocoa | |
let url = NSURL(string: "http://localhost:3000/api/v2.1/libraries/latest.json") | |
let data = NSData(contentsOfURL: url!) | |
print("---> Response data") | |
if let json: NSDictionary = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as? NSDictionary { |