Skip to content

Instantly share code, notes, and snippets.

@FGRibreau
FGRibreau / pid.js
Created February 16, 2012 18:41
Simple snippet for cross-platform .pid management in NodeJS. I use it for managing NodeJS apps with supervisord and monit
//
// Usage: require('./pid')("myapp");
//
var fs = require('fs');
module.exports = function(appname){
process.title = appname;
var PID_FILE = "/usr/local/var/run/"+process.title+".pid";
@yocontra
yocontra / EventEmitter.coffee
Created May 20, 2012 19:57
Tiny browser/node EventEmitter implementation in coffeescript
class EventEmitter
constructor: ->
@events = {}
emit: (event, args...) ->
return false unless @events[event]
listener args... for listener in @events[event]
return true
addListener: (event, listener) ->
@gavinmyers
gavinmyers / main.coffee
Created July 27, 2012 14:41
REST, CoffeeScript, NodeJS, Redis
express = require "express"
crypto = require "crypto"
user = require "./src/user"
project = require "./src/project"
app = express.createServer()
app.listen 8008
app.get '/', (req, res) ->
res.write JSON.stringify {version:0.3}
res.end ""
/** @jsx React.DOM */
var MyRootComponent = React.createClass({
getInitialState: function() {
return {perMinute: '-', perDay: '-'};
},
componentDidMount: function() {
var socket = io.connect(this.props.url);
socket.on('business.clickout', this.setState.bind(this));
},
render: function() {
@dsuch
dsuch / front_http_plain.conf
Last active January 23, 2019 10:38
Default frontend for HAProxy
frontend front_http_plain
mode http
default_backend bck_http_plain
acl too_fast fe_sess_rate ge 10
acl bursts_inclined path_beg -i /client1
tcp-request inspect-delay 1000ms
tcp-request content accept unless bursts_inclined too_fast
@sheldonh
sheldonh / merge.coffee
Last active February 29, 2024 15:51
CoffeeScript Object.merge
merge = (xs...) ->
if xs?.length > 0
tap {}, (m) -> m[k] = v for k, v of x for x in xs
tap = (o, fn) -> fn(o); o
console.log merge {foo: '1', bar: 'baz'}, {bar: 'bis'} , {wombat: 'fishpaste'}
###
{ foo: '1', bar: 'bis', wombat: 'fishpaste' }
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Stripe Getting Started Form</title>
<!-- The required Stripe lib -->
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<!-- jQuery is used only for this example; it isn't required to use Stripe -->
@jehrhardt
jehrhardt / .zshrc
Last active October 9, 2016 07:23
# oh-my-zsh location
ZSH=$HOME/.oh-my-zsh
# Use lambda theme
ZSH_THEME="robbyrussell"
# Use plugins for typical tools
plugins=(brew git)
# Load oh-my-zsh
'use strict';
var CLIENT_ID = 'CLIENT ID';
var API_KEY = 'YOUR SECRET API KEY (Test or Live)';
var TOKEN_URI = 'https://connect.stripe.com/oauth/token';
var AUTHORIZE_URI = 'https://connect.stripe.com/oauth/authorize';
var qs = require('querystring');
var request = require('request');
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace LinguisticTagger
{
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to