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
# Load the environment configuration options | |
config = require '../../config/environments' | |
# Require Redis | |
redis = require 'redis' | |
# Create a Redis client | |
client = redis.createClient() | |
# `queue` handles queueing a background job to Resque. We directly use |
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
async = require 'async' | |
# The `parallel` middleware allows to run several middlewares in parallel. | |
# It does this by simply using AsyncJS' `applyEach` on the middlewares. | |
# | |
# The middlewares will receive 3 parameters: `request`, `response` and | |
# `next`, in the same way and order they usually get them. As the | |
# execution is in parallel, if one of the middlewares will have an error | |
# the second one will continue to execute. If an error is passed to the | |
# `next` callback it will be passed correctly forward. |
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
# Stolen from a famous dotfile | |
# Start an HTTP server from a directory, optionally specifying the port | |
function server() { | |
local port="${1:-8000}" | |
sleep 1 && open "http://localhost:${port}/" & | |
# Set the default Content-Type to `text/plain` instead of `application/octet-stream` | |
# And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files) | |
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port" | |
} |
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
function parse_git_branch () { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
RED="\[\033[0;31m\]" | |
YELLOW="\[\033[0;33m\]" | |
GREEN="\[\033[0;32m\]" | |
GRAY="\[\033[1;30m\]" | |
LIGHT_GRAY="\[\033[0;37m\]" | |
CYAN="\[\033[0;36m\]" |
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
k2v = (h) -> (do (k,v) -> (n) -> not (n % v) && k || '') for k,v of fizz: 3, buzz: 5 | |
console.log ((fn(i) for fn in k2v()).join('') || i for i in [1..100]).join "\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
sum = -> | |
sum = 0 | |
for i in [1..5] | |
sum += i |
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
# From yeoman's source code | |
# This prints the ✘ in red, | |
# rest in bold. | |
sad_print(){ | |
printf '\e[31m%s\e[0m \e[1m%s\e[0m %s\n' "✘" "$1" "$2" | |
} | |
# This prints ✓ in green, | |
# rest in bold. |
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
exports.names = ['JAMES', | |
'JOHN', | |
'ROBERT', | |
'MICHAEL', | |
'WILLIAM', | |
'DAVID', | |
'RICHARD', | |
'CHARLES', | |
'JOSEPH', | |
'THOMAS', |
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
# Parses a URL of a YouTube video and | |
# returns the video id. | |
# | |
# - url - the url of the video | |
# | |
youtube_url_parser = (url) -> | |
regex = ///^ | |
.* # Zero or more of any character | |
( # Group 1, either: |
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
.cpt-rank-stats .cpt-rank-right-circle { | |
background: #bebebe; | |
height: 90px; | |
width : 45px; | |
border-radius: 0 90px 90x 0; | |
margin-left: -4px; | |
overflow: hidden; | |
vertical-align: top; |