This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var res = {0:0,1:0}; | |
var r; | |
for(var i = 0; i < 100; i++) { | |
r = Math.floor((Math.random() * 2) + 0); | |
res[r]++; | |
} | |
console.log(res); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Original from http://stackoverflow.com/questions/1638337/the-best-way-to-synchronize-client-side-javascript-clock-with-server-date | |
// Improved by community and @jskowron | |
// Synchronize client-side clock with server time using an approximation of NTP | |
let serverTimeOffset = null; | |
function getServerTime(callback) { | |
if (serverTimeOffset === null) { | |
const scripts = document.getElementsByTagName("script"); | |
const currentScriptURL = scripts[scripts.length - 1].src; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Redis; | |
use Exception; | |
/** | |
* Redis cache - Port from Phalcon Cache | |
* Cut intergate from backend and front cache | |
* I don't test or try run it. This pass on php linter. | |
* When I want to use it, I will check later. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'])) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Example Duck punching in Javascript | |
* @author Nimit Suwannagate <[email protected]> | |
*/ | |
// create class calculator | |
function Calculator() { | |
} | |
// add method |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create class | |
function Cart(){ | |
// constructur | |
// protected variable | |
var myProtected = 'secret'; | |
// protected method | |
var protectedFunction = function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |