Skip to content

Instantly share code, notes, and snippets.

@tlack
tlack / express-js-dust-x-example.js
Created March 23, 2012 20:16
express-js and dust-x example app
/**
* Module dependencies.
*/
var express = require('express')
, dustx = require('dust-x')
/**
* Create the Express application.
*/
@tlack
tlack / vhosted-node.sh
Created March 26, 2012 21:47
Idea for auto-deployment system for vhosted node.js apps
for DIR in /home/*/node; do
PORT=[generate port based on crc32 of $DIR]
# somehow check if not running
NODE_ENV=dev NODE_PORT=$PORT node-dev $DIR/app.js
cat /etc/nginx/configs.avail/default-node.conf | \
sed -e s/DIR/$DIR/ | \
sed -e s/PORT/$PORT > /etc/nginx/configs.enabled/node-$DIR.conf
# somehow check if we actually created/changed a config here
if [ $changed -eq 1 ]; then
service nginx restart
@tlack
tlack / gist:2387185
Created April 14, 2012 19:19
express.js / node.js get remote IP address
exports.req_ip = function(req) {
return ( req.headers["X-Forwarded-For"]
|| req.headers["x-forwarded-for"]
|| req.client.remoteAddress );
}
@tlack
tlack / gist:2425247
Created April 20, 2012 01:47
example of node.js + handlebars
var h = require('handlebars');
var tmpl = h.compile("<p>{{name}}</p>");
var data = {name:"tlack"};
console.log(tmpl(data));
@tlack
tlack / p01-matraka-explained.js
Created July 3, 2012 11:41
p01's Matraka javascript demo decoded
// Matraka's source code decoded and beautified
// by @tlack
//
// Matraka is a 1005 byte Javascript "demo" by p01. It includes an 'evolving animation'
// and great dirty synth music. View here:
//
// http://www.p01.org/releases/MATRAKA/matraka.png.html
//
// I fondly recall the demo scene of my youth, puzzling over the work of Future
// Creators and those guys. I was puzzled by this worked so I had to figure it
@tlack
tlack / jquery-ui-1.8.23-orig.js
Created September 18, 2012 20:30
possible bug in jquery ui's slider class and closestHandle? Cannot call method 'addClass' of undefined
_mouseCapture: function( event ) {
var o = this.options,
position,
normValue,
distance,
closestHandle,
self,
index,
allowed,
offset,
@tlack
tlack / snapchat-secret-key.txt
Created December 31, 2012 10:22
snapchat secret key
iEk21fuwZApXlz93750dmW22pw389dPwOk1356949137
@tlack
tlack / gist:4576631
Last active December 11, 2015 08:58
Idea for CodePen plugins
Idea for CodePen plugins (by @tlack)
Step 1: Establish simple plugin architecture/API
```javascript
CP.Plugins.add({
context: CP.Html,
re: /fun ([a-z_][a-z0-9_]+)/,
callback: function(cpPluginContext, match) {
var str = "function "+match.$1+"() {\n// Comment\n\n}\n";
@tlack
tlack / gist:5094559
Created March 5, 2013 21:42
example of proxying https -> http
location / { # ~ domain=(.*)& {
rewrite_log on;
if ( $arg_callback ) {
echo_before_body '$arg_callback(';
echo_after_body ');';
}
if ($args ~ "domain=(.*)&") {
set $key1 $1;
echo_before_body "$arg_callback(";
# proxy_pass http://whois.api.go.co/blah=$key1;
@tlack
tlack / tumblr-better-author-bios.md
Last active December 24, 2015 00:59
Javascript hack to improve Tumblr's lame byline options for group blogs

Tumblr's group blog features do not support per-author homepage links (such as Twitter) or bios. That sucks.

I've written here a Javascript function that kinda outputs something like what you may want. It maintains all the author data inside Javascript as well, for better or for worse. Eventually I'll make this pull from tags I guess.

Put this toward the top of your theme HTML, inside the script tag:

            var AUTHORS = {
                'caropopco': {
                    name: 'Carolina',