Skip to content

Instantly share code, notes, and snippets.

View cod3beat's full-sized avatar

A. Akbar Hidayat cod3beat

View GitHub Profile
@cod3beat
cod3beat / index.php
Last active December 16, 2015 16:40
Just a simple experiment on AOP in PHP.
<?php
require 'movement.php';
require 'register_aop.php';
try {
$movement = new Movement;
$movement->walk();
$movement->run();
@cod3beat
cod3beat / declaration-expression.js
Created May 17, 2013 17:01
Perbedaan antara function expression dan function declaration
// *********************** SYNTAX *************************
/**
* Function Declaration.
*
* Nama pada tubuh fungsi itu wajib sifatnya
*/
function deklarasi(){
}
@cod3beat
cod3beat / ContohCollection.js
Created October 25, 2013 03:50
Memasang spy pada event handler pada Backbone
var ContohCollection = Backbone.Collection.extend({
// ....
initialize: function() {
this.model.on("something", this.onSomething, this);
},
onSomething: function() {
}
// ....
@cod3beat
cod3beat / config.js
Created November 20, 2013 10:19
Tambah disqus ke ghost template
// # Ghost Configuration
// Setup your Ghost install for various environments
var path = require('path'),
config;
config = {
disqus: 'idjsblog', // DISQUS SHORTNAME
// sisanya
};
@cod3beat
cod3beat / fiddle.response.html
Last active December 28, 2015 21:09
mendalami ajax
<p>Merah: #E74C3C</p>
<p>Kuning: #F1C40F</p>
<p>Hijau: #27AE60</p>
<p>Biru: #2980B9</p>
@cod3beat
cod3beat / TestCase
Last active August 29, 2015 13:55
Test helper for Laravel. Inspired by http://net.tutsplus.com/tutorials/php/testing-laravel-controllers/ with a little change.
<?php
class TestCase extends Illuminate\Foundation\Testing\TestCase {
/**
* Creates the application.
*
* @return \Symfony\Component\HttpKernel\HttpKernelInterface
*/
public function createApplication()
@cod3beat
cod3beat / gist:9659182
Created March 20, 2014 07:54
eskplorasi properti sebuah function
function hitung(a, b, c) {
// mengetahui berapa jumlah parameter yang dimiliki oleh fungsi ini
console.log(hitung.length); // => 3
// mengetahui berapa jumlah argumen yang diberikan ke fungsi ini
// ketika ia dijalankan
console.log(arguments.length); // => 2
}
hitung(1, 2);
@cod3beat
cod3beat / blacklist.conf
Created June 7, 2014 07:58
Lenovo backlight. Jangan lupa mengupdate grub pasca melakukan perubahan di bawah ini. Misal: $ sudo update-grub2
# tambahkan baris dibawah ini pada berkas /etc/modprobe.d/blacklist.conf
blacklist ideapad_laptop
@cod3beat
cod3beat / ajaxHandler.js
Last active August 29, 2015 14:03
Menggunakan Mixin di backbone (dan MarionetteJS). Penerapan mixin dibantu oleh Cocktail
define(function(require) {
'use strict';
var _ = require('underscore')
return {
handleAjaxSuccess: function() {
if (_.isFunction(this.closeForm)) {
this.closeForm()
}
@cod3beat
cod3beat / messageBus.js
Created July 14, 2014 20:39
MessageBus yang di ekstrak dari MarionetteJS
define(function(require) {
'use strict';
var Backbone = require('backbone'),
Wreqr = require('backbone.wreqr'),
_ = require('underscore');
function MB() {
this.vent = new Wreqr.EventAggregator();
this.commands = new Wreqr.Commands();