Skip to content

Instantly share code, notes, and snippets.

View ethaizone's full-sized avatar
💭
It's same on Gitlab.

Nimit Suwannagate ethaizone

💭
It's same on Gitlab.
View GitHub Profile
@ethaizone
ethaizone / get_called_func,php
Last active September 22, 2016 16:56
Get called function in PHP
// This is function for function
// Usage like http://php.net/manual/en/function.get-called-class.php
function get_called_func()
{
$trace = array_slice(debug_backtrace(), -2, 1);
return $trace['function'];
}
@ethaizone
ethaizone / buildMultiDimentionArray.js
Last active September 20, 2016 09:02
Build multi dimentions array from arrays
var data = [];
data.push(['S', 'M', 'L']);
data.push(['RED', 'YELLOW']);
data.push(['IRON', 'COTTON']);
data.push(['ccc', 'ddd']);
// For clone array
Array.prototype.clone = function() {
return this.slice(0);
};
@ethaizone
ethaizone / RelationHelper.php
Last active September 16, 2016 10:46
Eloquent trait act as helper about relation on eloquent.
<?php
namespace App\Traits;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Eloquent\Relations\HasOneOrMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Closure;
use Exception;
@ethaizone
ethaizone / chmod_number.php
Last active September 16, 2016 07:43
Create chmod number notation
<?php
/**
* Copyright @ 2016 by Nimit Suwannagate <[email protected]>. All rights reserved.
*/
// Run this file in cli mode for best view.
// Try to edit this one.
$maxNumber = 500000000000;
@ethaizone
ethaizone / short_note.js
Created September 12, 2016 11:27
Short note
// Create class
function Cart(){
// constructur
// protected variable
var myProtected = 'secret';
// protected method
var protectedFunction = function() {
@ethaizone
ethaizone / fungdham.php
Last active June 27, 2016 03:51
ไฟล์คำสั่ง PHP สำหรับโหลด mp3 จากเว็บ fungdham.com - ต้องการ PHP Simple HTML DOM Parser - สร้างโฟลเดอร์แยกตามลำดับชั้นให้
<?php
set_time_limit(0);
// โหลด simple_html_dom.php มาจาก http://simplehtmldom.sourceforge.net/
include 'simple_html_dom.php';
function saveFile($url, $file) {
if(file_exists($file)) {
@ethaizone
ethaizone / duck_punching.js
Created June 24, 2016 07:07
Example Duck punching in JS
/**
* Example Duck punching in Javascript
* @author Nimit Suwannagate <[email protected]>
*/
// create class calculator
function Calculator() {
}
// add method
@ethaizone
ethaizone / fake_code_typer.ahk
Last active November 11, 2024 21:33
Auto typer from file - Execute by autohotkey.com
; Auto typer from file
; Write by EThaiZone @ 2016
; For fake code typing. lol
; Press Ctrl+F11 to start/stop
; Press F11 to pause/resume
#MaxThreads 2
#MaxThreadsPerHotkey 2
PressKey := true
@ethaizone
ethaizone / redirect_mobile_to_app_store.php
Last active May 24, 2022 17:56
[PHP] Auto redirect to app store. (Android/IOS)
<?php
// android store
if (preg_match('#android#i', $_SERVER ['HTTP_USER_AGENT'])) {
header('Location: market://details?id=com.google.android.apps.maps');
exit;
}
// ios
if (preg_match('#(iPad|iPhone|iPod)#i', $_SERVER ['HTTP_USER_AGENT'])) {
@ethaizone
ethaizone / custom_base_converter.php
Created May 17, 2016 11:05
Custom base number converter.
<?php
/**
* Code demo for convert base number with custom base character map.
* Not support negative number.
*/
// base from toHex on http://hashids.org/
function intToChar($input)
{