Skip to content

Instantly share code, notes, and snippets.

View shovon's full-sized avatar
💻
Working on my own projects

Sal Rahman shovon

💻
Working on my own projects
View GitHub Profile
@shovon
shovon / docker.conf
Created June 17, 2014 16:28
This is a modification of the original Upstart script. It is intended for those that get the latest binary downloads.
description "Docker daemon"
start on filesystem
stop on runlevel [!2345]
respawn
pre-start script
# see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount
if grep -v '^#' /etc/fstab | grep -q cgroup \
@shovon
shovon / gist:34b14e5c4213d51e4176
Created June 23, 2014 16:25
Upstart job for any Node.js application, with Node.js versions managed using NVM.
description "<Application name here>"
start on runlevel [23]
stop on shutdown
script
cd <path/to/project/here>
export NODE_ENV=production
# Be sure to have a `start` script in your `package.json`
<path/to>/.nvm/<version number>/bin/npm start
@shovon
shovon / Dockerfile
Last active August 29, 2015 14:02
Download and install Redis from source, in Docker
FROM ubuntu:14.04
RUN apt-get update; apt-get install -y wget build-essential
RUN wget http://download.redis.io/releases/redis-2.8.12.tar.gz
RUN tar xvfz redis-2.8.12.tar.gz
RUN cd redis-2.8.12; make; chmod +x $PWD/src/redis-server; ln -s $PWD/src/redis-server /usr/bin/redis-server
EXPOSE 6379
CMD [ "redis-server", "--bind", "0.0.0.0" ]
@shovon
shovon / Dockerfile
Last active August 29, 2015 14:03
Node.js on Docker
# Node.js v0.10.31
FROM ubuntu:14.04
RUN apt-get update; apt-get install -y curl
ENV VERSION 0.10.31
ENV NODE_PATH node-v${VERSION}-linux-x64
RUN curl http://nodejs.org/dist/v${VERSION}/${NODE_PATH}.tar.gz > ${NODE_PATH}.tar.gz
RUN tar xvfz ${NODE_PATH}.tar.gz
RUN ln -s /${NODE_PATH}/bin/node /bin/node
RUN ln -s /${NODE_PATH}/bin/npm /bin/npm
@shovon
shovon / readline.js
Created July 11, 2014 05:45
An example to synchronously read from the command line.
var child_process = require('child_process');
var fs = require('fs');
process.stdout.pause();
var fd = child_process.execFile('/bin/sh', ["-c", "read LINE < /dev/tty; echo $LINE > stdout; echo 1 > done"]);
while (true) {
try {
if (fs.readFileSync('done', {encoding: 'utf8'}).trim() === '1') { break; }
} catch (e) {}
@shovon
shovon / del_repo.sh
Created July 17, 2014 03:15
A utility to delete all repository folders from dependencies. Useful when you want to check dependencies in with the source code. All credit goes to http://blog.robertmeta.com/post/76233441527/stop-overcomplicated-go-lang-build-deps
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export GOPATH=$DIR
echo "Clean up source history downloaded"
find . -type d | grep \.hg$ | xargs rm -rf
find . -type d | grep \.bzr$ | xargs rm -rf
find . -type d | grep -v ^\./\.git$ | grep \.git$ | xargs rm -rf
# might need to add svn if we ever use SVN repos
@shovon
shovon / vm.go
Last active August 29, 2015 14:05
A virtual machine written in Go, just for practice.
package main
import (
"fmt"
"encoding/hex"
"log"
"errors"
)
const MAX_STACK_SIZE = 2048
@shovon
shovon / superagent.js
Created December 20, 2014 14:34
superagent mock for Jest tests. Stolen from http://bl.ocks.org/simenbrekken/b6282f713605b619834f
/* global jest */
var superagent = jest.genMockFunction().mockReturnThis();
var Response = jest.genMockFunction().mockImplementation(function() {
this.status = 200;
this.ok = true;
});
Response.prototype.get = jest.genMockFunction();
@shovon
shovon / CMakeLists.txt
Created January 16, 2015 07:59
Me just practicing CMake
cmake_minimum_required(VERSION 3.1.0)
project(fibonacci)
add_definitions(-std=c99)
add_executable(fibonacci fib.c)
@shovon
shovon / README.md
Created January 16, 2015 08:53
Me practicing compiling stuff. I'm using libuv as target practice.

Compiling

g++ -g -Wall -I /path/to/libuv/include /path/to/libuv.a app.cpp -o app