Skip to content

Instantly share code, notes, and snippets.

View Williammer's full-sized avatar

William He Williammer

View GitHub Profile
@Williammer
Williammer / php.implodeString.php
Last active August 29, 2015 14:00
php.implodeString.php - implode -> to join el in array into a string.
<?php
$raw = array(
array(
'id' => '11',
'name' => 'n1',
'music' => 'm1'),
array(
'id' => '12',
'name' => 'n2',
'music' => 'm2'),
@Williammer
Williammer / php.useDate.php
Last active August 29, 2015 14:01
php.useDate.php - by far the most convenient date method I used in php.
//get certain date.
$date_case = strtotime('+1 month', strtotime('201405071011'));
$month_later = date('YmdHi', $date_case);
@Williammer
Williammer / javaScript.compareTest.js
Last active August 29, 2015 14:01
javaScript.compareTest.js - test for the comparison of different types of values.
function compareTest(){
//1)纯数字之间比较
alert(1<3);//true
//2)数字字符串比较,会将其先转成数字
alert("1"<"3");//true
alert("123"<"123");//false
//3)纯字符串比较,先转成ascii码
alert("a"<"b");//true
@Williammer
Williammer / php.EnableDebugError.php
Last active August 29, 2015 14:01
php.EnableDebugError.php - setting
<?
ini_set('display_errors', 1);
error_reporting(E_ALL);
?>
@Williammer
Williammer / mysql configurations
Created May 17, 2014 09:19
mysql configurations - processes to configure mysql
1.Start the mysql server instance or daemon with the --skip-grant-tables option. (security setting)
$ mysqld --skip-grant-tables
2.Then Execute these statements.
$ mysql -u root mysql
$mysql> UPDATE user SET Password=PASSWORD('my_password') where USER='root';
$mysql> FLUSH PRIVILEGES;
3.Finally, restart the instance/daemon without the --skip-grant-tables option.
@Williammer
Williammer / javascript.groupAsynTest.html
Last active August 29, 2015 14:01
javascript.groupAsynTest.html - the great code to implement group asyn test in 《javascript ninja》
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta property="wb:webmaster" content="edcf77ed05a8765f" />
<title>ninja test group asyn</title>
<meta name="viewport" content="width=device-width">
<style>
#result li.passed { color: blue; }
@Williammer
Williammer / javascript.groupTest.html
Last active August 29, 2015 14:01
javascript.groupTest.html - DIY assert() method for testing.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta property="wb:webmaster" content="edcf77ed05a8765f" />
<meta name="viewport" content="width=device-width">
<style>
#result li.passed { color: blue; }
#result li.failed { color: red; }
@Williammer
Williammer / javascript.tryCatchTest.html
Last active August 29, 2015 14:01
javascript.tryCatchTest.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta property="wb:webmaster" content="edcf77ed05a8765f" />
<meta name="viewport" content="width=device-width">
<script>
var ErrorOverLimit = new Error('>= 31.');
var ErrorMsg = new Error('invalid time.');
@Williammer
Williammer / jsPattern.callback@makeHamburger.html
Last active August 29, 2015 14:02
jsPattern.callback@makeHamburger.html
<iframe width="100%" height="300" src="http://jsfiddle.net/Williammer/Yp9gf/1/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
<script>
/** javaScript **/
var findNodes = function (callback, callback_obj) {
var i = 10,
nodes = [],
found;
// check if callback is callable
@Williammer
Williammer / jsPatterns.namespace.js
Last active August 29, 2015 14:02
jsPatterns.namespace.js
var MYAPP = MYAPP || {};
MYAPP.namespace = function (ns_string) {
var parts = ns_string.split('.'),
parent = MYAPP,
i;
// strip redundant leading global
if (parts[0] === "MYAPP") {
parts = parts.slice(1);