Skip to content

Instantly share code, notes, and snippets.

@guileen
guileen / hash.js
Created December 22, 2010 02:15
nodejs crc32 function
/**
* Calculates the hash/checksum of a string. Default algorithm is MD5.
*
* @param {String} str
* @param {String} algorithm
* @return {String} checksum
* @api public
*/
exports.hash = function (str, algorithm) {
if (algorithm === 'crc32') {
@guileen
guileen / app.js
Created April 20, 2011 23:55
Express Custom 404
var express = require('express'),
mongoose = require('mongoose'),
app;
app = module.exports = express.createServer();
app.configure(function() {
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.bodyParser());
app.use(express.methodOverride());
@guileen
guileen / gist:949739
Created April 30, 2011 15:13 — forked from kennethkalmer/gist:278814
node.js SMTP Server
/*
smtpd.js is SMTP server written for node.js
MIT License
*/
var tcp = require('tcp');
var sys = require('sys');
@guileen
guileen / StackScript.sh
Created April 5, 2012 19:23 — forked from visnup/StackScript.sh
node.js knockout 2011 StackScript
#!/bin/bash
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# <UDF name="ssh_key" Label="Paste in your public SSH key" default="" example="" optional="false" />
# root ssh keys
mkdir /root/.ssh
echo $SSH_KEY >> /root/.ssh/authorized_keys
chmod 0700 /root/.ssh
@guileen
guileen / nginx.conf
Created July 24, 2012 05:09 — forked from srpouyet/nginx.conf
Nginx Upstart script (Ubuntu 12.04)
### Nginx upstart script
### source: http://serverfault.com/a/391737/70451
### /etc/init/nginx.conf
description "nginx http daemon"
start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]
env DAEMON=/opt/nginx/sbin/nginx
import re
import json
import urllib
import base64
import hashlib
import requests
WBCLIENT = 'ssologin.js(v.1.3.18)'
sha1 = lambda x: hashlib.sha1(x).hexdigest()
@guileen
guileen / monitrc
Created January 25, 2013 15:02 — forked from metakeule/monitrc
# /etc/monit/monitrc (excerpt)
check process node-app with pidfile /var/run/node-app.pid
start program = "/sbin/start node-app" with timeout 5 seconds
stop program = "/sbin/stop node-app"
if failed port 3000 protocol HTTP
request /
with timeout 3 seconds
then restart
if cpu > 80% for 10 cycles then restart

Google Speech To Text API

Base URL: https://www.google.com/speech-api/v1/recognize
It accepts POST requests with voice file encoded in FLAC format, and query parameters for control.

Query Parameters

client
The client's name you're connecting from. For spoofing purposes, let's use chromium

lang
Speech language, for example, ar-QA for Qatari Arabic, or en-US for U.S. English

@guileen
guileen / supervisor.sh
Last active August 29, 2015 13:56 — forked from keimlink/gist:831633
/etc/init.d/supervisord
#!/bin/sh
#
# /etc/rc.d/init.d/supervisord
#
# Supervisor is a client/server system that
# allows its users to monitor and control a
# number of processes on UNIX-like operating
# systems.
#
# chkconfig: - 64 36
@guileen
guileen / chat.go
Last active August 29, 2015 14:13
package main
import (
"bufio"
"net"
)
type Client struct {
incoming chan string
outgoing chan string