Skip to content

Instantly share code, notes, and snippets.

View muhammadghazali's full-sized avatar

Muhammad Ghazali muhammadghazali

View GitHub Profile
@muhammadghazali
muhammadghazali / CodeTempalte-JavaScript-anofunc-with-name
Created February 7, 2012 21:02
JavaScript Code Template for anonymous function. I used this code template in NetBeans. Read more: http://wiki.netbeans.org/Java_EditorUsersGuide#How_to_use_Code_Templates
function ${name}(${parameters}) {${cursor}}
@muhammadghazali
muhammadghazali / CommonGitCommandAliases
Created March 21, 2012 15:48
git status, git add, git commit, and git checkout are such common commands that it is useful to have abbreviations for them. http://gitimmersion.com/lab_11.html
# GIT IMMERSION tutorial
# http://gitimmersion.com/lab_11.html
# Add the following to the .gitconfig file in your $HOME directory.
[alias]
co = checkout
ci = commit
st = status
br = branch
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
type = cat-file -t
@muhammadghazali
muhammadghazali / RenameTagInGitRepository
Created April 3, 2012 06:58
A steps of commands to rename a tag in git repository. Source: http://stackoverflow.com/a/5719854/1061371
# checkout the old tag
git checkout old
# create a new tag
git tag new
# delete the old tag on local git repository
git tag -d old
# delete the old tag on remote git repository
git push origin :refs/tags/old
@muhammadghazali
muhammadghazali / The-Ghanozs-Vows-test-suite-template.js
Last active October 3, 2015 04:58
Ghanoz's BDD test suite template in Vows - http://vowsjs.org
var vows = require('vows');
var assert = require('assert');
var testSuite = vows.describe('Scenario: Test Fake API Scenario');
testSuite.addBatch({
'GIVEN some context' : {
'WHEN I do something' : {
topic: function () { return something('value', this.callback); },
// then the do something should return anything
@muhammadghazali
muhammadghazali / The-boilerplate-code-that-APIeasy-eliminate.js
Created April 16, 2012 13:59
Here's a sample of the boilerplate code that APIeasy eliminates when using APIeasy to test an API
// Get more info about APIEasy: https://github.com/flatiron/api-easy
// This example is originated from the Readme page of APIEasy project page.
// I made this gist just to keep the collection of Vows examples test suite I have to learn.
var request = require('request'),
vows = require('vows'),
assert = require('assert');
vows.describe('your/awesome/api').addBatch({
"When using your awesome api": {
@muhammadghazali
muhammadghazali / screencasting.sh
Created December 12, 2012 06:09
A bash script to screencasting using ffmpeg. The video will recorded in mp4 format and saved on the current directory. Reference: https://wiki.ubuntu.com/ScreenCasts/ffmpeg
#!/bin/bash
# generate the file name using the string provided on the args
ffmpeg -f x11grab -r 25 -s 1366x768 -i :0.0 -vcodec libx264 -sameq $1.mp4
@muhammadghazali
muhammadghazali / index.js
Last active October 17, 2015 07:47
requirebin sketch
moment = function() {
return (require('moment-timezone')).tz('America/New_York');
},
console.log(moment().format());
console.log(moment().day());
console.log(moment().endOf('day').format());
console.log(moment().endOf('day').format());
Something
.findOne({
where: {
id: somethingId
}
})
.then(function(something) {
if (!something) {
res.notFound('Something is not found.');
return;
Something
.findOne({
where: {
id: somethingId
}
})
.then(function(something) {
throw new Error('something not found');
return doSomethingCool();
@muhammadghazali
muhammadghazali / fatal: protocol error: bad line length character: Remo
Created January 19, 2013 20:59
I experienced fatal: protocol error: bad line length character: Remo, shortly after I did git push to remote server. I do not know why this happened. Did you ever receive a similar error message like happened to me?
git push origin && git branch -D working-on-issue-11
Counting objects: 20, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (11/11), 4.10 KiB, done.
Total 11 (delta 9), reused 0 (delta 0)
remote: bb/acl: me is allowed. accepted payload.
Auto packing the repository for optimum performance.
fatal: protocol error: bad line length character: Remo
error: error in sideband demultiplexer