Skip to content

Instantly share code, notes, and snippets.

<html>
<head>
<title>Equality</title>
<script type = "text/javascript">
var x = 42;
var y = "42";
if (x ===y) {
document.write("x is equal to y with a strict test.");
} else {
document.write("x is not equal to y");
<?php
add_action('template_redirect','my_template_redirect');
function my_template_redirect() {
if (get_post_type() == 'location') {
global $wp_query;
add_post_meta($wp_query->post->ID,'_wp_page_template','custom_template.php',TRUE);
$wp_query->is_page = true;
}
}
// custom template
@tolawho
tolawho / install-git-flow-on-macosx
Last active March 10, 2016 08:15
Cài đặt git-flow trên mac osx
# sử dụng brew
$ brew install git-flow
# hoặc sử dụng port
$ port install git-flow
@tolawho
tolawho / install-git-flow-on-linux
Last active March 10, 2016 08:21
cài đặt git-flow trên môi trường linux
$ apt-get install git-flow
@tolawho
tolawho / app.js
Created September 15, 2016 10:24
app.js trong một dự án nhỏ của khách hàng.
var app = {
data: {},
jsf: {
extend: function (o) {
$.extend(true, app.data, o);
}
},
msg: function(key){
return (typeof app.data.msg[key] === 'undefined')? 'Message undefined' : app.data.msg[key];
},
<?php
namespace App\Http\Controllers;
use App\Component\Common\PortalUser;
use App\Component\Common\PortalConst;
use App\Component\Common\PortalCommon;
use App\Repositories\ContentRepository;
use App\Repositories\GolfCourseRepository;
use Illuminate\Http\Request;
@tolawho
tolawho / gsb.js
Created September 15, 2016 10:31
js trong dự án cá nhân
var gsb = {
data:{},
tags:[{"id":"1","name":"thanh 1"},{"id":"2","name":"thanh 2"},{"id":"3","name":"thanh 3"},{"id":"4","name":"thanh 4"},{"id":"5","name":"thanh 5"},{"id":"6","name":"thành 6"},{"id":"7","name":"luyen thi dai hoc"},{"id":"8","name":"luyen thi hoc sinh gioi"}],
jsf:{
extend:function(o) {
$.extend(true, gsb.data, o);
}
},
home: {
searching:false,
@tolawho
tolawho / User.php
Created September 15, 2016 10:39
Model user, PSR2 coding standard.
<?php
use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;
use Zizaco\Entrust\HasRole;
class User extends Eloquent implements UserInterface, RemindableInterface
{
@tolawho
tolawho / 2016.2_key
Created September 30, 2016 01:45
PHPStorm 2016.2
43B4A73YYJ-eyJsaWNlbnNlSWQiOiI0M0I0QTczWVlKIiwibGljZW5zZWVOYW1lIjoibGFuIHl1IiwiYXNzaWduZWVOYW1lIjoiIiwiYXNzaWduZWVFbWFpbCI6IiIsImxpY2Vuc2VSZXN0cmljdGlvbiI6IkZvciBlZHVjYXRpb25hbCB1c2Ugb25seSIsImNoZWNrQ29uY3VycmVudFVzZSI6ZmFsc2UsInByb2R1Y3RzIjpbeyJjb2RlIjoiSUkiLCJwYWlkVXBUbyI6IjIwMTctMDItMjUifSx7ImNvZGUiOiJBQyIsInBhaWRVcFRvIjoiMjAxNy0wMi0yNSJ9LHsiY29kZSI6IkRQTiIsInBhaWRVcFRvIjoiMjAxNy0wMi0yNSJ9LHsiY29kZSI6IlBTIiwicGFpZFVwVG8iOiIyMDE3LTAyLTI1In0seyJjb2RlIjoiRE0iLCJwYWlkVXBUbyI6IjIwMTctMDItMjUifSx7ImNvZGUiOiJDTCIsInBhaWRVcFRvIjoiMjAxNy0wMi0yNSJ9LHsiY29kZSI6IlJTMCIsInBhaWRVcFRvIjoiMjAxNy0wMi0yNSJ9LHsiY29kZSI6IlJDIiwicGFpZFVwVG8iOiIyMDE3LTAyLTI1In0seyJjb2RlIjoiUEMiLCJwYWlkVXBUbyI6IjIwMTctMDItMjUifSx7ImNvZGUiOiJSTSIsInBhaWRVcFRvIjoiMjAxNy0wMi0yNSJ9LHsiY29kZSI6IldTIiwicGFpZFVwVG8iOiIyMDE3LTAyLTI1In0seyJjb2RlIjoiREIiLCJwYWlkVXBUbyI6IjIwMTctMDItMjUifSx7ImNvZGUiOiJEQyIsInBhaWRVcFRvIjoiMjAxNy0wMi0yNSJ9XSwiaGFzaCI6IjMzOTgyOTkvMCIsImdyYWNlUGVyaW9kRGF5cyI6MCwiYXV0b1Byb2xvbmdhdGVkIjpmYWxzZSwiaXNBdXRvUHJvbG9uZ2F0ZWQiOmZhbHNlf
@tolawho
tolawho / traversing-example.md
Created August 17, 2017 07:46 — forked from etrepat/traversing-example.md
Traversing the Hierarchy Tree with Baum - An Example

The simplest way to traverse the hierarchy tree with Baum is by iterating through the children relation.

<?php

$root = Category::roots()->with('children')->first();

echo "<h3>{$root->name}</h3>";

foreach($root->children as $category) {