Skip to content

Instantly share code, notes, and snippets.

View corpix's full-sized avatar
👹
Fighting demons

corpix corpix

👹
Fighting demons
View GitHub Profile
<html>
<head>
<script src="http://crashkitapp.appspot.com/static/javascript/crashkit-javascript.js?test/js" type="text/javascript" charset="utf-8"></script>
<!-- <script src="http://localhost:5005/static/javascript/crashkit-javascript.js?test/js" type="text/javascript" charset="utf-8"></script> -->
<script src="crashkit-javascript-sample.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
function xxx(a) {
yyy(a, a, a);
}
@iangreenleaf
iangreenleaf / rsync-retry.sh
Created January 18, 2010 07:12
rsync with retries
#!/bin/bash
### ABOUT
### Runs rsync, retrying on errors up to a maximum number of tries.
### Simply edit the rsync line in the script to whatever parameters you need.
# Trap interrupts and exit instead of continuing the loop
trap "echo Exited!; exit;" SIGINT SIGTERM
MAX_RETRIES=50
# node.js app under nginx
upstream node {
server 127.0.0.1:8001;
}
server {
listen 80;
server_name node;
@fcalderan
fcalderan / inception-javascript.js
Created November 2, 2010 09:42
inception explained as a 4 nested javascript closures
/*
* Fabrizio Calderan, twitter @fcalderan, 2010.11.02
* I had an idea: could Inception movie be explained by a few javascript closures
* and variable resolution scope (just for fun)?
*
* Activate javascript console =)
*/
<script>
console.group("inception movie");
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@pguillory
pguillory / gist:729616
Created December 5, 2010 23:51
Hooking into Node.js stdout
var util = require('util')
function hook_stdout(callback) {
var old_write = process.stdout.write
process.stdout.write = (function(write) {
return function(string, encoding, fd) {
write.apply(process.stdout, arguments)
callback(string, encoding, fd)
}
@jankuca
jankuca / index.js
Created January 20, 2011 16:21
RelativeDate Node.js module
exports.parse = function (string, format) {
var match = string.match(/^(\+|-)\s*(\d+)\s*([a-z]{3})/i);
var add;
if (!match) {
add = 0;
} else {
add = parseInt(match[2], 10);
switch (match[3]) {
case 'min':
add *= 60;
var util = require('util'),
fs = require('fs');
module.exports = function(server, everyone) {
server.get('/streamFriendFile', function(req, res) {
util.debug('CLIENT REQUESTED STREAM FRIEND FILE');
util.debug('request headers: ' + util.inspect(req.headers));
util.debug('request params: ' + util.inspect(req.params));
//set headers
@ericmoritz
ericmoritz / README.rst
Created May 13, 2011 01:17
crazy-template.js

crazy_template

A template engine in 42 lines of code.

About

I was thinking of a way to generate HTML without using strings as embedding strings in Javascript is a pain if they are multi-lined. There isn't a nice triple quote like there exists in Python.

So I took my inspiration from Lisp HTML generators that use S-expressions to generate HTML. I thought, hell, S-expressions are just a bunch of nested lists, I could do the same thing in Javascript.

var express = require('./')
, http = require('http')
, https = require('https')
, app = express.createServer();
app.use(express.static(__dirname));
http.createServer(app.handle.bind(app)).listen(3000);
https.create....