Skip to content

Instantly share code, notes, and snippets.

View agentcooper's full-sized avatar

Artem Tyurin agentcooper

View GitHub Profile
@joemccann
joemccann / nginx + node setup.md
Created October 25, 2010 02:06
Set up nginx as a reverse proxy to node.js.

The idea is to have nginx installed and node installed. I will extend this gist to include how to install those as well, but at the moment, the following assumes you have nginx 0.7.62 and node 0.2.3 installed on a Linux distro (I used Ubuntu).

In a nutshell,

  1. nginx is used to serve static files (css, js, images, etc.)
  2. node serves all the "dynamic" stuff.

So for example, www.foo.com request comes and your css, js, and images get served thru nginx while everything else (the request for say index.html or "/") gets served through node.

  1. nginx listens on port 80.
@cowboy
cowboy / HEY-YOU.md
Last active July 1, 2024 08:37
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
@getify
getify / gist:675496
Created November 13, 2010 17:18
detecting if flash plugin is installed
var _flash_installed = ((typeof navigator.plugins != "undefined" && typeof navigator.plugins["Shockwave Flash"] == "object") || (window.ActiveXObject && (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) != false));
@jasonLaster
jasonLaster / ConsoleTricks.html
Created February 27, 2011 21:47
WebKit Console tricks adapted from CSS Ninja's excellent tutorial http://bit.ly/fi4lnK
<html>
<body>
<script type="text/javascript" charset="utf-8">
// CONSOLE log
var foo = {baz: "tubular", goo: "rad"}, bar = "baz";
console.log("string",1,foo.goo,bar,foo.baz); // string 1 rad baz tubular
console.log(foo)
// CONSOLE Printf
var foo = {baz: "tubular", goo: "rad"}, bar = "baz";
@Raynos
Raynos / iterateWalk.js
Created December 13, 2011 19:34
All the DOM recursion you'll ever need
var slice = Array.prototype.slice
function iterativelyWalk(nodes, cb) {
nodes = slice.call(nodes)
while(nodes.length) {
var node = nodes.shift(),
ret = cb(node)
if (ret) {
@mfontani
mfontani / extract-subs.pl
Created December 29, 2011 12:23
Grab subroutines (and variable parameters!) from a Perl file
#!/usr/bin/env perl
use common::sense;
use PPI;
my $file = shift;
die "Need a file to operate on\n"
if !$file
|| !-f $file;
my $doc = PPI::Document->new($file);
@abozhilov
abozhilov / gist:2594795
Created May 4, 2012 13:27
State machine
var GO = 'GO',
OK = 'OK',
SIGN = 'SIGN',
LZERO = 'LZERO',
INT = 'INT',
FRAC = 'FRAC',
FDIG = 'FDIG',
EXP = 'EXP',
XSIGN = 'XSIGN',
EDIG = 'EDIG',
@theturtle32
theturtle32 / compilingNode0.8.4onCentOS5.md
Created July 25, 2012 20:57
Compiling and Installing Node v0.8.4 on CentOS 5.x

Compiling/Installing Node 0.8.4 (and Python 2.6, required by Node) on CentOS 5

Update system packages -- will migrate system forward to CentOS 5.8. (Optional?)

$ sudo yum update

Install the EPEL Repo:

function ctor(fn) {
function F () {
var obj = Object.create(F.prototype);
fn.apply(obj, arguments);
return obj;
}
F.prototype = Object.create(fn.prototype);
return F;
}
@abozhilov
abozhilov / gist:3895019
Created October 15, 2012 20:08
Partial application Value range
function valueRange(start, end) {
return function (value) {
return Math.min(Math.max(value, start), end);
};
}
//Get new value range [0, 20]
var f = valueRange(0, 20);
console.log(f(10)); //10