Skip to content

Instantly share code, notes, and snippets.

View ptz0n's full-sized avatar

Erik Eng ptz0n

View GitHub Profile
/* jsonp.js for Protototype
*
* Copyright (c) 2009 Tobie Langel (http://tobielangel.com)
*
* jsonp.js is freely distributable under the terms of an MIT-style license.
*--------------------------------------------------------------------------
Requires: Prototype >= 1.6
Usage:
new Ajax.JSONRequest('http://api.flickr.com/services/feeds/photos_public.gne', {
onComplete: function(json) {
@JoeStanton
JoeStanton / deploy.rb
Created January 25, 2013 10:13
Example Capistrano Deployment file for Node.js Projects
set :application, "SampleApp"
set :repository, "."
set :scm, :none
set :use_sudo, false
set :keep_releases, 5
#Use the copy method which will compress and scp the files
set :deploy_via, :copy
set :main_js, "app.js"
@luishdez
luishdez / redis.sh
Created January 13, 2013 17:27
Redis lua scripts Update Set and Sorted Set only if the value / score is higher or lower …
# Basic benchmarks
# SET key val # 87489.06
# SETRANGE key2 6 "Redis" # 75757.58 req/s
# INCR key 245 # 70224.72 req/s
# INCRBY key 245 22 # 67114.09 req/s
# EVAL SET key val # 46296.29 req/s
# SETIFHIGHER (set or update key if new value is higher than current) # 41666.67 req/s
# if not exists return OK , if updated return the increment , if not updated return 0
SCRIPT LOAD "local c = tonumber(redis.call('get', KEYS[1])); if c then if tonumber(ARGV[1]) > c then redis.call('set', KEYS[1], ARGV[1]) return tonumber(ARGV[1]) - c else return 0 end else return redis.call('set', KEYS[1], ARGV[1]) end"
@SchumacherFM
SchumacherFM / Magento-HHVM.md
Last active May 17, 2018 18:26
Running Magento Enterprise Edition with Facebook HipHop HHVM

Running Magento Enterprise Edition with Facebook HipHop HHVM

Prerequisites

Hardware

MacBook Air (MBA) Mid 2012

@vanjacosic
vanjacosic / gdpr_template.md
Created August 3, 2018 12:36
GDPR email template

Email template for requesting data deletion

To:

Their Data Protection Officer, usually dpo@companyname.com

Subject:

Request for erasure (GDPR)

@turtlesoupy
turtlesoupy / minimal.coffee
Created September 21, 2012 06:41
Minimal example of a gracefully restarting node.js process
express = require 'express'
gracefullyExiting = false
app = express.createServer()
app.use (req, res, next) ->
return next() unless gracefullyExiting
res.setHeader "Connection", "close"
res.send 502, "Server is in the process of restarting."
@ptz0n
ptz0n / gist:1217080
Created September 14, 2011 16:51
Validate JSONP Callback
<?php
/**
* Validate JSONP Callback
*
* https://github.com/tav/scripts/blob/master/validate_jsonp.py
* https://github.com/talis/jsonp-validator/blob/master/src/main/java/com/talis/jsonp/JsonpCallbackValidator.java
* http://tav.espians.com/sanitising-jsonp-callback-identifiers-for-security.html
* http://news.ycombinator.com/item?id=809291
*
@zachleat
zachleat / gist:2008932
Created March 9, 2012 21:56
Prevent zoom on focus
// * iOS zooms on form element focus. This script prevents that behavior.
// * <meta name="viewport" content="width=device-width,initial-scale=1">
// If you dynamically add a maximum-scale where no default exists,
// the value persists on the page even after removed from viewport.content.
// So if no maximum-scale is set, adds maximum-scale=10 on blur.
// If maximum-scale is set, reuses that original value.
// * <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=2.0,maximum-scale=1.0">
// second maximum-scale declaration will take precedence.
// * Will respect original maximum-scale, if set.
// * Works with int or float scale values.
@paneq
paneq / page.conf
Created April 3, 2013 14:57
nginx maintenance page that is JSON friendly
if (-f $document_root/system/maintenance.html) {
return 503;
}
error_page 503 @maintenance;
location @maintenance {
internal;
if ($http_accept ~ json) {
return 503 "{}";
}
@steve-taylor
steve-taylor / doSynchronousLoop.js
Last active December 4, 2022 00:51
Synchronous for loop in JavaScript to ensure that the n+1th item isn't processed until the callback of the nth item's processor has been called.
/**
* Process an array of data synchronously.
*
* @param data An array of data.
* @param processData A function that processes an item of data.
* Signature: function(item, i, callback), where {@code item} is the i'th item,
* {@code i} is the loop index value and {@code calback} is the
* parameterless function to call on completion of processing an item.
*/
function doSynchronousLoop(data, processData, done) {