Skip to content

Instantly share code, notes, and snippets.

View shurane's full-sized avatar

Ehtesh Choudhury shurane

  • Astoria, NY | Seattle, WA
  • 03:53 (UTC -07:00)
View GitHub Profile
@shurane
shurane / celery_supervisord.celery.conf.erb
Last active August 29, 2015 14:07
How to not differentiate between File and Templates. Also passing in variables to templates, if possible.
[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file
[supervisord]
logfile=/var/log/supervisord/supervisord.log ; supervisord log file
logfile_maxbytes=50MB ; maximum size of logfile before rotation
logfile_backups=10 ; number of backed up logfiles
loglevel=info ; info, debug, warn, trace
pidfile=/var/run/supervisord.pid ; pidfile location
nodaemon=false ; run supervisord as a daemon
@shurane
shurane / ProximaNova-Regular.otf
Last active August 29, 2015 14:07
Bubble Map of EDM Topics
@shurane
shurane / mutual.recursion.js
Last active August 29, 2015 14:08
Mutual recursion is lots of fun.... not.
// Way #1
function a (num) {
console.log('a', num);
num = num + 1;
if (num > 1000)
{ return num; }
else {
setTimeout(function () { b(num); }, 1000);
}
@shurane
shurane / httpdebug.js
Created November 4, 2014 18:55
HTTP debugging. Kind of nifty.
var express = require('express');
var chalk = require('chalk');
var app = express();
app.all('*', function (req, res) {
console.log(chalk.blue('===========' + new Date()));
console.log('req.method', req.method);
console.log('req.url', req.url);
console.log('req.path', req.path);
console.log('req.headers', req.headers);

Delete a folder before recreating it with ansible-playbook

@shurane
shurane / README.md
Last active August 29, 2015 14:11
PM2-test-graceful-exit

Test the handlers around process.on('SIGTERM') for pm2 restart|stop|kill.

Run the following commands in separate shells:

  1. pm2 start index.json
  2. while true; do (curl localhost:5001 -m 7 2>/dev/null &) ; sleep 10; done

And trigger conditions with pm2 restart|stop|kill

Celery doesn't always restart. Try to make a reproducible test case for celery related code.

Run:

vagrant up
ssh-copy-id vagrant@localhost -p 2222
ansible -m ping all
ansible-playbook setup.yml

after SSH-ing into the machine:

@shurane
shurane / README.md
Last active August 29, 2015 14:14
C examples for Jeremy K.

Try running this:

clang -o argv argv.c
./argv abc def ghi jkl 123 456

clang -o pthread pthread.c -lpthread
./pthread
---
- hosts: backend
sudo: True
tasks:
- copy: src=main.js dest=/tmp/main.js
@shurane
shurane / Unit0Exercises.java
Last active August 29, 2015 14:19
Revised assessment test for AccessCode -- now converted into a solution.
package nyc.c4q;
import java.io.FileReader;
import java.util.HashMap;
public class Unit0Exercises {
/*
* Name of the method implies what the method should do.
* Some of these methods require that the method return signature change.
* For example, `returnPrimitiveBooleanTrue()` should return `boolean`, not `Object`.