Skip to content

Instantly share code, notes, and snippets.

View ivan-loh's full-sized avatar
🍌
Chilling

Ivan Loh ivan-loh

🍌
Chilling
View GitHub Profile

Using Homebrew to manage Node.js and io.js installs on OSX

Having both Node.js and io.js installed with NVM was giving me a load of problems, mainly with npm. So I uninstalled NVM and manage Node.js and io.js with homebrew.
Heres how.

Install Node.js and io.js

$ brew install node
$ brew install iojs

@ivan-loh
ivan-loh / getClosestDateToMins.js
Created July 11, 2015 18:06
javascript - get date to closest x minutes
function getRange() {
var lower = getLowerClosest(10);
var upper = getHigherClosest(10);
return moment(lower).format('HH:mm:ss') + ' - ' + moment(upper).format('HH:mm:ss');
}
function getLowerClosest(mins) {
var coeff = 1000 * 60 * mins;
var date = new Date();
return new Date(Math.floor(date.getTime() / coeff) * coeff);
storage:
dbPath: "./data"
directoryPerDB: true
journal:
enabled: true
engine: "wiredTiger"
wiredTiger:
engineConfig:
cacheSizeGB: 8
journalCompressor: zlib
storage:
dbPath: "./data"
directoryPerDB: true
journal:
enabled: true
engine: "wiredTiger"
wiredTiger:
engineConfig:
cacheSizeGB: 8
journalCompressor: none
storage:
dbPath: "./data"
directoryPerDB: true
journal:
enabled: true
engine: "wiredTiger"
wiredTiger:
engineConfig:
cacheSizeGB: 8
journalCompressor: snappy
@ivan-loh
ivan-loh / node-app-server.sh
Last active April 2, 2017 04:43
simple setup script to create a node app server
#!/bin/bash
# - Nginx
# - NodeJS
# - Redis
# - Mongodb
# - Mosh
# Add Required repository
sudo add-apt-repository -y ppa:keithw/mosh
@ivan-loh
ivan-loh / crud.js
Created August 24, 2015 18:45
elasticsearch 1.7.1 sample nodejs crud
'use strict';
var async = require('async');
var elastic = require('./app/helpers/elasticsearch.js');
async.waterfall([
// create
function (done) {
elastic.index({
@ivan-loh
ivan-loh / osx-for-hackers.sh
Created October 2, 2015 16:57 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned. Also, please don't email me about this script, my poor inbox...
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@ivan-loh
ivan-loh / Prelude.md
Created October 4, 2015 13:11
Prelude Shortcuts

Getting to know Prelude

Certainly the best way to understand how Prelude enhances the default Emacs experience is to peruse Prelude's source code (which is obviously written in Emacs Lisp). Understanding the code is not necessary of course. Prelude includes a prelude-mode minor Emacs mode which collects some of the additional functionality added by Prelude. It also adds an additional keymap that binds many of those extensions to keybindings.

@ivan-loh
ivan-loh / GIF-Screencast-OSX.md
Created October 11, 2015 07:25 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: