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 / 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 / gist:dce46a760eec5bb76dac
Last active June 8, 2018 12:25
"subl" command in Linux

OS X's Sublime Text has this subl command, where running it from the terminal will summon Sublime Text, in the background. This means that closing the terminal window will not close Sublime Text.

In Linux, we can do that with the help of nohup. Assuming you have installed a sublime_text command that opens a new process associated with Sublime Text, then you can do

$ nohup sublime_text &

When you close your terminal window, Sublime Text will still remain open.

@shovon
shovon / dft.js
Created December 4, 2014 01:11
Discrete Fourier Transform in JavaScript
function createComplex(real, imag) {
return {
real: real,
imag: imag
};
}
function dft(samples, inverse) {
var len = samples.length;
var arr = Array(len);
@shovon
shovon / gulpfile.js
Created December 15, 2014 15:06
A gulpfile to bundle Browserify code, and watch for changes
var gulp = require('gulp');
var browserify = require('browserify');
var del = require('del');
var source = require('vinyl-source-stream');
var webserver = require('gulp-webserver');
var path = require('path');
var runsequence = require('gulp-run-sequence');
var gutil = require('gulp-util');
/*
@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