Skip to content

Instantly share code, notes, and snippets.

View muhammadghazali's full-sized avatar

Muhammad Ghazali muhammadghazali

View GitHub Profile
@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 / web.config
Created November 17, 2012 10:19
IIS rewrite rules to remove index.php. I created this gist based on: http://stackoverflow.com/a/9965392/1061371
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true"/>
<rewrite>
@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 / 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
@muhammadghazali
muhammadghazali / remove-n-commit.md
Last active December 11, 2015 20:09
How to remove commit from git remote repository. The how to is based from: http://stackoverflow.com/questions/448919/how-can-i-remove-a-commit-on-github/448929#448929

Remove n-commit on your local repository

git rebase -i HEAD~N

Delete the N line within the editor window that pops up

Example, remove the latest commit:

git rebase -i HEAD~2
@muhammadghazali
muhammadghazali / assign-the-collection-name-to-variable.md
Last active December 12, 2015 03:38
An example of using a variable to assign a collection so that we can minimize the keystroke. I know this trick from 10gen: M102 MongoDB for DBAs course.
> c = db.products
pcat.products
> c.find()
{ "_id" : "ac3", "name" : "AC3 Phone", "brand" : "ACME", "type" : "phone", "price" : 200, "warranty_years" : 1, "available" : true }
{ "_id" : "ac7", "name" : "AC7 Phone", "brand" : "ACME", "type" : "phone", "price" : 320, "warranty_years" : 1, "available" : false }
{ "_id" : ObjectId("507d95d5719dbef170f15bf9"), "name" : "AC3 Series Charger", "type" : [ "accessory", "charger" ], "price" : 19, "warranty_years" : 0.25, "for" : [ "ac3", "ac7", "ac9" ] }
{ "_id" : ObjectId("507d95d5719dbef170f15bfa"), "name" : "AC3 Case Green", "type" : [ "accessory", "case" ], "color" : "green", "price" : 12, "warranty_years" : 0 }
{ "_id" : ObjectId("507d95d5719dbef170f15bfb"), "name" : "Phone Extended Warranty", "type" : "warranty", "price" : 38, "warranty_years" : 2, "for" : [ "ac3", "ac7", "ac9", "qp7", "qp8", "qp9" ] }
{ "_id" : ObjectId("507d95d5719dbef170f15bfc"), "name" : "AC3 Case Black", "type" : [ "accessory", "case" ], "color" : "black", "price" : 12.5, "warranty_year
@muhammadghazali
muhammadghazali / talk-is-cheap.js
Created April 2, 2013 07:30
Talk is cheap. Show me the code.
// require a lot of bullshit to "talk is cheap"
var talkIsCheap = require('talk-is-cheap');
// of course you will got TypeError: Cannot call method 'say' of undefined, because talk is cheap!
talkIsCheap.say('Talk is cheap!')
@muhammadghazali
muhammadghazali / Makefile
Created April 3, 2013 05:59
Example of task runner that set up and tear down circle_test database. I use this commands when running test in CircleCI.
test:
npm install --dev
mysql -u ubuntu -e 'CREATE DATABASE IF NOT EXISTS circle_test'
mysql -u ubuntu circle_test < test_database.sql
node_modules/vows/bin/vows some-test/*-spec.js
mysql -u ubuntu circle_test < test_database.sql
node_modules/vows/bin/vows another-test/*-spec.js
mysql -u ubuntu -e 'DROP DATABASE IF EXISTS circle_test'
@muhammadghazali
muhammadghazali / delete-file-from-git-history.md
Last active February 26, 2020 14:24
Deleting file from Git history

Example 1

Deleting .env:

git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch .env' --prune-empty --tag-name-filter cat -- --all

Example 2

@muhammadghazali
muhammadghazali / user-story-template.md
Created April 14, 2013 19:27
The user story template. Cited from The Agile Samurai Book written by Jonathan Rasmusson. http://pragprog.com/book/jtrap/the-agile-samurai

Template

As a <type of user>

I want <some goal>

so that <some reason>