Skip to content

Instantly share code, notes, and snippets.

View obengwilliam's full-sized avatar
🎯
Focusing

Obeng William obengwilliam

🎯
Focusing
View GitHub Profile
@obengwilliam
obengwilliam / nginx.conf.default
Last active September 16, 2015 07:33 — forked from nishantmodak/nginx.conf.default
Default Nginx Conf
#user nobody;
#Defines which Linux system user will own and run the Nginx server
worker_processes 1;
#Referes to single threaded process. Generally set to be equal to the number of CPUs or cores.
#error_log logs/error.log; #error_log logs/error.log notice;
#Specifies the file where server logs.
@obengwilliam
obengwilliam / redis_list.js
Created October 8, 2015 10:11 — forked from JacobHsu/redis_list.js
#nodejs redis list rpush lpush brpop blpop
var redis = require('redis'),
client = redis.createClient();
var arr = ["some val","some val2","some val3"];
//Use multi() to pipeline multiple commands at once
var multi = client.multi();
for (var i=0; i<arr.length; i++) {
//console.log(arr[i]);
//將一個或多個值value插入到列表key的表尾。

Sublime Text 2 – Useful Shortcuts (Ubuntu)

General

Ctrl+KB toggle side bar
Ctrl+Shift+P command palette
Ctrl+` python console
Ctrl+N new file

Editing

@obengwilliam
obengwilliam / mongoose-connection-options.js
Created January 11, 2016 09:23
MongoLab recommended mongoose connection options. More supported connections for the underlying Node Native driver can be found here: http://mongodb.github.io/node-mongodb-native/driver-articles/mongoclient.html#mongoclient-connect-options
// mongoose 3.8.x
var mongoose = require('mongoose');
// mongodb-uri 0.9.x
var uriUtil = require('mongodb-uri');
/*
* Mongoose by default sets the auto_reconnect option to true.
* We recommend setting socket options at both the server and replica set level.
* We recommend a 30 second connection timeout because it allows for
* plenty of time in most operating environments.
@obengwilliam
obengwilliam / protips.js
Created January 13, 2016 11:01 — forked from nolanlawson/protips.js
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@obengwilliam
obengwilliam / gitflow-breakdown.md
Created January 29, 2016 06:04 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
git commit --allow-empty -m "Initial commit"
git checkout -b develop master

Connect to the remote repository

@obengwilliam
obengwilliam / s1.js
Created February 19, 2016 08:27 — forked from davybrion/s1.js
code snippets for "Using Mongoose’s Setters To Get Calculated Properties" post
var invoiceSchema = new Schema({
companyId: { type: ObjectId, required: true },
customerId: { type: ObjectId, required: true },
invoiceNumber: { type: String, required: true, unique: true },
date: { type: Date, required: true },
dueDate: { type: Date, required: true },
paid: { type: Boolean, required: true, default: false },
activityId: { type: ObjectId, required: true },
totalHours: { type: Number, required: true },
hourlyRate: { type: Number, required: true },
@obengwilliam
obengwilliam / q-mongoose-so.js
Created February 19, 2016 10:37 — forked from domenic/q-mongoose-so.js
Q + Mongoose from StackOverflow
var mongoose = require('mongoose');
mongoose.connect('mongo://localhost/test');
var conn = mongoose.connection;
var users = conn.collection('users');
var channels = conn.collection('channels');
var articles = conn.collection('articles');
var insertUsers = Q.nfbind(users.insert.bind(users));
var insertChannels = Q.nfbind(channels.insert.bind(channels));
@obengwilliam
obengwilliam / 0. JavaScript Function Programming TOC.md
Created February 23, 2016 14:01 — forked from Integralist/0. JavaScript Function Programming TOC.md
JavaScript Function Programming (scratch pad) -> Most of the code here is modified from the excellent O'Reilly book "Functional JavaScript".

This code is modified from the excellent O'Reilly book "Functional JavaScript". You should buy it, I highly recommend it! Don't kid yourself into thinking this gist even remotely covers the great content from a 200+ page technical book on the subject; it doesn't. Buy the book and get the in-depth knowledge for yourself. It's worth it.

var mongoose = require('mongoose')
, Schema = mongoose.Schema
, db = mongoose.connect('localhost', 'testing_streaming').connection
, Stream = require('stream').Stream
, express = require('express')
/**
* Dummy schema.
*/