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
# Lightweight Rack middleware to ease configuring cache headers | |
# | |
# Sinatra usage example | |
# | |
# configure do | |
# Rack::CacheHeaders.configure do |cache| | |
# cache.max_age(/^\/$/, 60) | |
# cache.max_age(/^\/search$/, 3600) | |
# cache.expires(/^\/about\/.+$/, "00:00") | |
# cache.private(/^\/account/) |
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
net: require "net" | |
sys: require "sys" | |
LISTEN_PORT: 10000 | |
SERVER_ADDRESS: '127.0.0.1' | |
AVAILABLE_PORTS: [10001, 10002, 10003, 10004, 10005, 10006] | |
CONNECTION_COUNTER: 0 | |
reservePort: (callback) -> | |
if AVAILABLE_PORTS.length > 0 |
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
reservePort = function(callback) { | |
var tickCheck = function() { | |
if(AVAILABLE_PORTS.length > 0) { | |
callback(AVAILABLE_PORTS.shift()) | |
} else { | |
process.nextTick(tickCheck) | |
} | |
} | |
tickCheck(); | |
} |
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 fs = require('fs'); | |
var lines = fs.readFileSync('output.json', 'utf8').split("\n"); | |
lines.pop(); // remove the last (empty) new line | |
for(var n in lines) { | |
try { | |
JSON.parse(lines[n]); | |
} catch (e) { | |
console.log("Error at line " + (n+1) + " => " + lines[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
class User | |
include Mongoid::Document | |
field :name | |
references_and_referenced_in_many :accounts | |
end | |
class Account | |
include Mongoid::Document | |
field :name | |
key :name |
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
description "nginx http daemon" | |
start on runlevel [2] | |
stop on runlevel [016] | |
console owner | |
exec /opt/nginx/sbin/nginx -g "daemon off;" | |
respawn |
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
alert('Hello from alert.js'); |
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
require "socket" | |
s = TCPSocket.new 'localhost', 1234 | |
s.puts "name: Andy" | |
s.puts "Hello World" |
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
// add some interactivity | |
var canvas = document.querySelector("#canvas"), | |
ctx = canvas.getContext("2d"); | |
ctx.beginPath(); | |
ctx.lineWidth = 10; |
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
# name: Echo Bot | |
# description: Say someting and I'll say it back | |
# keyword: echo | |
bolt.run -> | |
if command.hasQuery | |
result(title:command.query, description: "That's what you said!") |
OlderNewer