This file contains hidden or 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
//Preload images one at a time | |
(function($) { | |
$.sPreLoad = { | |
loaded: new Array, //Images that have been loaded | |
loading: null, //Image currently loading | |
unloaded: new Array, //Images not yet loaded | |
run: function () { | |
//Load all the arguments into unloaded | |
$(arguments).each(function(i,url) { | |
$.sPreLoad.unloaded.push(url); |
This file contains hidden or 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
http.createServer(function(req, res) { | |
var ip = req.connection.remoteAddress; | |
paperboy | |
.deliver(WEBROOT, req, res) | |
.addHeader('Expires', 300) | |
.addHeader('X-PaperRoute', 'Node') | |
.before(function() { | |
sys.log('Recieved Request') | |
}) | |
.after(function(statCode) { |
This file contains hidden or 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.deliver = function (webroot, req, res) { | |
var | |
stream, | |
fpRes = exports.filepath(webroot, url.parse(req.url).pathname), | |
fpErr = fpRes[0], | |
filepath = fpRes[1], | |
errorCallback, | |
headerFields = {}, | |
addHeaderCallback, | |
delegate = { |
This file contains hidden or 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
//Don't do this! | |
var file = 'myFile.txt'; // Executes First | |
fs.readFile(file, function () { | |
sys.write("Hi"); // Executes Third | |
}); | |
sys.write("BYE") //Executes Second |
This file contains hidden or 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
//Simple (slow) way to transfer binary data | |
fs.createReadStream(filepath,{'flags': 'r', 'encoding': | |
'binary', 'mode': 0666, 'bufferSize': 64 * 1024}) | |
.addListener("data", function(chunk){ | |
res.write(chunk, 'binary'); | |
}) | |
.addListener("close",function() { | |
res.close(); | |
}) |
This file contains hidden or 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
#!/bin/bash | |
#Simple iptables init script. | |
#Config | |
iptables_path="/sbin" | |
iptables="$iptables_path/iptables" | |
iptables_save="$iptables_path/iptables-save" | |
iptables_restore="$iptables_path/iptables-restore" | |
iptables_rules="/etc/iptables_rules" |
This file contains hidden or 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
*filter | |
# Internal interfaces | |
-A INPUT -i lo -j ACCEPT | |
-A OUTPUT -o lo -j ACCEPT | |
#Allow all established traffic | |
-A INPUT -m state --state ESTABLISHED -j ACCEPT | |
#SSH |
This file contains hidden or 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
#!/usr/bin/env ruby | |
#Init script for setting up a ssh tunnel | |
#Remote Port | |
tun_port = 123 | |
#Local port to use | |
tun_lport = 1234 | |
#Remote User | |
tun_user = 'username' | |
#Remote Host |
This file contains hidden or 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 this in application controller | |
module Authentication | |
protected | |
# Inclusion hook to make #current_user and #signed_in? | |
# available as ActionView helper methods. | |
def self.included(base) | |
base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method | |
end | |
# Returns true or false if the user is signed in. |
This file contains hidden or 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
module SendgridToolkit | |
class Bounces < AbstractSendgridClient | |
def retrieve(options = {}) | |
options.each {|k,v| options[k] = 1 if k.to_s == 'date' && v == true} | |
api_post('bounces','get',options) | |
end | |
def delete(options = {}) | |
response = api_post('bounces','delete',options) | |
raise BounceEmailDoesNotExist if response['message'].include?('does not exist') | |
response |
OlderNewer