Skip to content

Instantly share code, notes, and snippets.

@ring0li
ring0li / cli_date.sh
Last active October 19, 2019 00:07
[shell] shell #shell
```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')"
@ring0li
ring0li / bubble
Last active August 19, 2018 08:08
算法
<?php
/**
* 冒泡排序
*/
function bubble_sort(array &$ar)
{
$tmp = 0;
$count = count($ar);
for ($i = 0; $i < $count - 1; $i++) {
@ring0li
ring0li / add_month.php
Last active August 29, 2015 14:16
php code
/**
*
* @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');
@ring0li
ring0li / git-config
Created February 3, 2015 04:39
config file
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"
@ring0li
ring0li / toCsv.php
Created January 22, 2015 06:33
csv
/**
* 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";
@ring0li
ring0li / MySQL.md
Last active August 29, 2015 14:13
MySQL

_

@ring0li
ring0li / 0_reuse_code.js
Last active August 29, 2015 14:13
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#############################################################################
# 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)