Skip to content

Instantly share code, notes, and snippets.

View tridungpham's full-sized avatar

Pham Tri Dung tridungpham

View GitHub Profile
@tridungpham
tridungpham / realphim-api.md
Created July 21, 2014 06:23
New Markdown document

##Register new user URI : http://realphim.com/api/user/register ###Input

  • username : required, length [3-32], alpha numeric
  • password : required, length [3-32]
  • email : required, valid email
  • first_name : required, length [1-100]
  • last_name : required, length [1-100]

Output

jQuery(document).ready(function ($) {
var divs=$('.sbSubLitsIt .listIt').hide();
var divs2=$('.sbListIt .sbSubList').hide();
jQuery('.sbSubLitsIt').each(function(){
if(jQuery(this).find('.listIt').length){
jQuery(this).find('.clShowCapNone').addClass('clShowCap');
}
});
jQuery('.sbListIt').each(function(){
if(jQuery(this).find('.sbSubList').length){

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch
<?php
/**
* Asset dependencies manager
* @author: dphamtri
* @date 20140124
*/
class AssetManager
{
static $instance = null;
class ASampleClass
{
public static function test()
{
return 'yo';
}
}
echo (new ASampleClass())->test();
var asyncModule = function(name) {
return {
controller: function() {
m.request({
method: "GET",
url: name + ".js",
deserialize: function(data) {
return new Function("var module = {};" + data + ";return module").call().exports
}
})
var asyncModule = function(name) {
return {
controller: function() {
m.startComputation()
require([name], function(module) {
this.controller = new module.controller()
this.view = module.view
m.endComputation()
@tridungpham
tridungpham / flat2tree.php
Created September 16, 2015 15:30
Transform flat array into tree
<?php
// http://php.net/manual/en/language.references.php
$flat = array(
"7" => array(
"id" => 7,
"parent" => 6
),
"6" => array(
"id" => 6,
<?php
$comments = [
1 => ['content' => "The first comment", 'parent' => 0],
2 => ['content' => "The second comment", 'parent' => 0],
3 => ['content' => "Reply of first comment", 'parent' => 1],
4 => ['content' => "Another reply of first comemnt", 'parent' => 1],
5 => ['content' => "Reply of a reply of the first comment", 'parent' => 4]
];
try {
var response = (HttpWebResponse) request.GetResponse();
} catch (Exception e) {
var response = (HttpWebResponse) e.Response;
}