Skip to content

Instantly share code, notes, and snippets.

View natp0ng's full-sized avatar
🐯

Nut natp0ng

🐯
  • 11:30 (UTC +07:00)
View GitHub Profile
@natp0ng
natp0ng / set_timezone.php
Last active October 1, 2015 15:38
set time zone
<?php
date_default_timezone_set('Asia/Bangkok');
echo date('d-m-Y H:i:s');
?>
@natp0ng
natp0ng / command.sh
Last active December 11, 2015 00:48
# for delete all .DS_Store in folder
>find . -name '*.DS_Store' -type f -delete
curl -A "Mozilla" "http://translate.google.com/translate_tts?tl=en&q=hello+world" > hello.mp3
cat .git/config
// Android check orientation
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
// landscape
} else {
// portrait
}
@natp0ng
natp0ng / callback.java
Created January 23, 2013 04:32
Callback in class
// The callback interface
interface MyCallback {
void callbackCall();
}
// The class that takes the callback
class Worker {
MyCallback callback;
void onEvent() {
@natp0ng
natp0ng / pass_data.php
Created April 16, 2014 19:04
pass data from controller to blade template laravel
<?php
$data =
[
'page_title' => 'Login',
'second_item' => 'value'
...
];
return View::make('authentication/login', $data);
@natp0ng
natp0ng / 0_reuse_code.js
Created August 7, 2014 16:52
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@natp0ng
natp0ng / uri_assoc.php
Created August 20, 2014 18:38
listing\page\1\sort\desc\order\xx convert uri to array('page'=>1, 'sort'=>'desc', 'order'=>xx)
in Route.php
<?php
Route::get('/listing/{params?}', 'CarController@listing')->where('params', '(.*)');
?>
in Controller
<?php
public function listing($params = null)
{
if($params)
package xredis
// BLPop is a blocking list pop primitive.
// It is the blocking version of LPOP
// because it blocks the connection when there are no elements to pop from any of the given lists.
// An element is popped from the head of the first list that is non-empty,
// with the given keys being checked in the order that they are given.
// A nil multi-bulk when no element could be popped and the timeout expired.
// A two-element multi-bulk with the first element being the name of the key where an element was popped
// and the second element being the value of the popped element.