_
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
```shell | |
#!/bin/bash | |
startDate="${1:-2018-08-20 00:00:00}" | |
endDate="${2:-$(date '+%Y-%m-%d %H:00:00')}" | |
cd /home/work/wwwroot/; | |
for (( i = 0; ; i++ )) | |
do | |
date="$(date -d "$startDate $i hour" '+%Y-%m-%d %H:00:00')" |
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 | |
/** | |
* 冒泡排序 | |
*/ | |
function bubble_sort(array &$ar) | |
{ | |
$tmp = 0; | |
$count = count($ar); | |
for ($i = 0; $i < $count - 1; $i++) { |
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
/** | |
* | |
* @param \DateTime $date DateTime object | |
* @param int $monthToAdd Months to add at time | |
*/ | |
function addMonth(\DateTime $date, $monthToAdd) | |
{ | |
$year = $date->format('Y'); | |
$month = $date->format('n'); | |
$day = $date->format('d'); |
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
git config --global user.name "Elephant Liu" | |
git config --global color.branch "auto" | |
git config --global color.ui "auto" | |
git config --global color.status "auto" | |
git config --global alias.st "status" | |
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --" | |
git config --global alias.ci "commit" | |
git config --global alias.cia "commit --amend" |
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
/** | |
* Export an array as downladable Excel CSV | |
* http://stackoverflow.com/questions/155097/microsoft-excel-mangles-diacritics-in-csv-files | |
* @param array $header | |
* @param array $data | |
* @param string $filename | |
*/ | |
function toCSV($header, $data, $filename) { | |
$sep = "\t"; | |
$eol = "\n"; |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
############################################################################# | |
# current prompt | |
############################################################################# | |
# \d – Current date | |
# \t – Current time | |
# \h – Host name | |
# \# – Command number | |
# \u – User name | |
# \W – Current working directory (ie: Desktop/) | |
# \w – Current working directory, full path (ie: /Users/Admin/Desktop) |