Skip to content

Instantly share code, notes, and snippets.

View liuxd's full-sized avatar
🗿
Hi, there.

Allen Liu liuxd

🗿
Hi, there.
  • Tax Traders
  • Auckland, New Zealand
View GitHub Profile
@liuxd
liuxd / open.js
Created November 16, 2017 02:58
open new tab
var url = 'http://spring4u.info/'
window.open(url, '_blank').focus()
@liuxd
liuxd / iframe.html
Created November 15, 2017 00:59
Youtube Embeded Video
<!-- "allowfullscreen" controll whether fullscreen button -->
<iframe id="video_frame" class="embed-responsive-item" src="https://www.youtube.com/embed/jS3HN7Nw-qU" allowfullscreen></iframe>
@liuxd
liuxd / stop_scroll.js
Last active November 12, 2017 22:10
[stop page scroll for popup] #jQuery
// Stop scroll while pop up
$("body").css("overflow", "hidden")
// Reset the scroll for page
$("body").css("overflow", "")
@liuxd
liuxd / textarea_spliter.php
Created November 6, 2017 03:20
[Textarea content to array for each line.]
<?php
$text = $_POST['content'];
$lineArray = explode("<br />", nl2br($text));
@liuxd
liuxd / CategoryHandler.php
Last active September 29, 2017 00:37
[Vesta Central] #Test
<?php
class CategoryHandler
{
private $json = [];
public function __construct($json_file)
{
try {
$json_file_content = file_get_contents($json_file);
@liuxd
liuxd / Object.create.js
Created September 26, 2017 02:03
[Object.create] Create a child for an existed object.
if (typeof Object.create !== 'function') {
Object.create = function (o) {
var F = function () {};
F.prototype = o;
return new F();
};
}
@liuxd
liuxd / pre-commit
Last active September 7, 2017 01:19
[php_sytax_checker] #GitHook
#!/bin/sh
#
# Check whether there is a syntax error in the php files.
for file in `git diff --cached --name-only`;do
if [ "${file##*.}" = "php" ];then
output=`php -l $file`
if [ $? -gt 0 ];then
echo $output
@liuxd
liuxd / commit-check.php
Last active September 7, 2017 01:20
[commit_without_chinese] #GitHook
<?php
/**
* git commit hook
* Check whether commit message include Chinese. If there is, stop the commit.
*/
function cecho($string, $style = 'notice') {
if (isset($_SERVER['REQUEST_URI'])){
echo $string, "\n";
return;
}
@liuxd
liuxd / QuickSort.php
Created September 7, 2017 01:13
QuickSort.php
<?php
/**
* Quick sort implementation.
*
* Keywords: pivot
*/
class Quicksort
{
/**
* Sort an array.
@liuxd
liuxd / MergeSort.php
Created September 7, 2017 01:13
MergeSort.php
<?php
/**
* Merge Sort.
*/
class MergeSort
{
/**
* Let's sort it!
*/
public function sort(array $aArray):array