Skip to content

Instantly share code, notes, and snippets.

View hoanganh25991's full-sized avatar

Anh Le hoanganh25991

  • https://originallyus.sg
  • Vietnam
View GitHub Profile
function throttle( fn, time ) {
var t = 0;
return function() {
var args = arguments, ctx = this;
clearTimeout(t);
t = setTimeout( function() {
fn.apply( ctx, args );
}, time );
};
@hoanganh25991
hoanganh25991 / gist:61ccfc822ac19337e55e
Last active October 29, 2015 14:04
PHP: WordPress function
We couldn’t find that file to show.
@hoanganh25991
hoanganh25991 / _ide_helper.php
Created October 29, 2015 07:51
This files help IDE like PHPStorm understand Laravel Facades
<?php
/**
* A helper file for Laravel 5, to provide autocomplete information to your IDE
* Generated for Laravel 5.1.1 (LTS) on 2015-06-11.
*
* @author Barry vd. Heuvel <barryvdh@gmail.com>
* @see https://github.com/barryvdh/laravel-ide-helper
*/
namespace {
@hoanganh25991
hoanganh25991 / Cat.php
Last active October 29, 2015 14:04
Laravel: Model Cat
<?php
class Cat extends Eloquent {
protected $fillable = array('name','date_of_birth','breed_id');
public function breed(){
return $this->belongsTo('Breed');
}
}
@hoanganh25991
hoanganh25991 / Breed.php
Last active October 29, 2015 14:04
Laravel: Model Breed
<?php
public class Breed extends Eloquent{
public $timestamp = false;
public function cats(){
return $this->hasMany('Cat');
}
}
<?php
Schema::create('cats', function($table){
$table->increments('id');
$table->string('name');
$table->date('date_of_birth');
$table->integer('breed_id')->nullable();
$table->timestamps();
});
Schema::create('breeds', function($table){
$table->increments('id');
@hoanganh25991
hoanganh25991 / BreedsTableSeed.php
Last active October 29, 2015 14:03
Laravel: Dummy Data Seeder
<?php
class BreedsTableSeeder extends Seeder {
public function run(){
DB::table('breeds')->insert(array(
array('id'=>1, 'name'=>"Domestic"),
array('id'=>2, 'name'=>"Persian"),
array('id'=>3, 'name'=>"Siamese"),
array('id'=>4, 'name'=>"Abyssinian"),
));
}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css" integrity="sha384-aUGj/X2zp5rLCbBxumKTCw2Z50WgIr1vs/PFN4praOTvYXWlVyh2UtNUU0KAUhAX" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
@hoanganh25991
hoanganh25991 / about.blade.php
Created October 29, 2015 09:20
Laravel: view extends main-blade
@extends('main')
@section('header')
<h2>About this site</h2>
@stop
@section('content')
<p>There are over {{$number_of_cats}} cats on this site</p>
@stop
@hoanganh25991
hoanganh25991 / introrx.md
Created October 29, 2015 14:10 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing