Skip to content

Instantly share code, notes, and snippets.

View muhammadghazali's full-sized avatar

Muhammad Ghazali muhammadghazali

View GitHub Profile
@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 / 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>
@muhammadghazali
muhammadghazali / event-details.json
Last active December 16, 2015 08:58
ghanoz-json: Event Details resource representations design in JSON
{
"url": "http://example.com/event/511206849146c42125000001",
"data": {
"title": "Free event",
"shortDescription": "Free event for students",
"times": [
{
"milliseconds": 1613028781634,
"fullFormat": "Thu Feb 11 2021 14:33:01 GMT+0700 (WIT)",
"year": 2021,
@muhammadghazali
muhammadghazali / event-list.json
Last active December 16, 2015 08:58
ghanoz-json: Event List resource representations design in JSON
{
"url": "http://example.com/events",
"data": [
{
"title": "Free event",
"shortDescription": "Free event for students",
"times": [
{
"milliseconds": 1613028781634,
"fullFormat": "Thu Feb 11 2021 14:33:01 GMT+0700 (WIT)",
@muhammadghazali
muhammadghazali / event-details.xml
Last active December 16, 2015 08:59
ghanoz-json: Event Details resource representations design in XML
<response>
<url>http://localhost:3000/event1</url>
<data id="1">
<title>Diam nisl tation.</title>
<shortDescription>Amet dolore praesent consequat te.</shortDescription>
<times>
<time>
<milliseconds>1613028781634</milliseconds>
<fullFormat>Thu Feb 11 2021 14:33:01 GMT+0700 (WIT)</fullFormat>
<year>2021</year>
@muhammadghazali
muhammadghazali / event-list.xml
Last active December 16, 2015 08:59
ghanoz-json: Event List resource representations design in XML
<response>
<url>http://localhost:3000/events</url>
<data>
<data id="1">
<title>Diam nisl tation.</title>
<shortDescription>Amet dolore praesent consequat te.</shortDescription>
<times>
<time>
<milliseconds>1613028781634</milliseconds>
@muhammadghazali
muhammadghazali / get-event-details-acceptance-test.md
Created April 18, 2013 15:42
Get Event Details Acceptance Test

Scenario 1: Event Details request should return response in JSON

Given Event Details resource is accessible

And Event Details resource is accessible

When the client request the Event Details in JSON

Then the Web API should return Event Details in JSON