Skip to content

Instantly share code, notes, and snippets.

@lyonsun
lyonsun / herokuapp.txt
Created March 12, 2014 14:41
change heroku app name to be the same on site from terminal.
git remote rm heroku
git remote add heroku git@heroku.com:yourappname.git
@lyonsun
lyonsun / error.log
Created April 26, 2014 16:48
can't install php V5.4 with mcrypt extension using mac port.
lyon:~ Lyon$ sudo port install php54-mcrypt
---> Computing dependencies for php54-mcrypt
---> Dependencies to be installed: php54
---> Fetching archive for php54
Warning: Your DNS servers incorrectly claim to know the address of nonexistent hosts. This may cause checksum mismatches for some ports.
---> Attempting to fetch php54-5.4.27_0+libedit.darwin_13.x86_64.tbz2 from http://jog.id.packages.macports.org/macports/packages/php54
---> Attempting to fetch php54-5.4.27_0+libedit.darwin_13.x86_64.tbz2.rmd160 from http://jog.id.packages.macports.org/macports/packages/php54
---> Installing php54 @5.4.27_0+libedit
---> Activating php54 @5.4.27_0+libedit
@lyonsun
lyonsun / command.sh
Last active August 29, 2015 14:01
export/import mysql database in command line.
mysqldump -uUSERNAME -pPASSWORD -hHOSTNAME USER_DATABASE > FILENAME.sql
#Then import using:
mysql -uUSERNAME -pPASSWORD -hHOSTNAME USER_DATABASE < FILENAME.sql
@lyonsun
lyonsun / command2.sh
Last active August 29, 2015 14:01
compress/zip and decompress/unzip multiple folders into one compressed file on linux console.
# tar: (c)reate g(z)ip (v)erbose (f)ile [filename.tar.gz] [contents]...
tar -czvf /var/file/bkup.tar.gz /home/code/bots /var/config /var/system
# zip: (r)ecursive [filename.zip] [contents]...
zip -r /var/file/bkup.zip /home/code/bots /var/config /var/system
# tar: e(x)tract g(z)ip (v)erbose (f)ile [filename.tar.gz] [contents]...
tar -xzvf /var/file/bkup.tar.gz /home/code/bots /var/config /var/system
@lyonsun
lyonsun / cracked.log
Created May 13, 2014 02:37
VMware 破解序列号
VMware workstation 10
破解序列号:
5F29M-48312-8ZDF9-A8A5K-2AM0Z
0F63E-20HEM-4ZC49-RKC5M-A22HY
4F2A2-ARHEK-MZJJ0-JH8EH-C2GQG
1U64X-AA351-KZ519-4R85M-A2KJR
HU03A-F83EM-9Z7L8-LT974-3CE7V
1A46W-AHL9H-FZ7Z8-ETC50-0CK4P
1U2WF-64K91-EZQU9-T195H-0A34K
JZ2Q8-DZJ5L-VZWG8-ZH0NH-A3ZNR
@lyonsun
lyonsun / watch.sh
Created May 26, 2014 05:10
watch netstat changes per second
watch -d -n1 'netstat -natpu'
@lyonsun
lyonsun / check_null.sql
Created June 5, 2014 01:19
ms access sql, check null value in select statement
SELECT IIF(ISNULL(column),0,column) FROM table;
@lyonsun
lyonsun / parseDate.js
Created June 9, 2014 07:27
parse datestring in format 'YYYY-MM-DD HH:II:SS' to timestamp in millionseconds
function parseDate(dateString) {
var dateString, parts, date, time, dt, ms;
parts = dateString.split(/[T ]/); // Split on `T` or a space to get date and time
date = parts[0];
time = parts[1];
dt = new Date();
parts = date.split(/[-\/]/); // Split date on - or /
@lyonsun
lyonsun / toHHMMSS.js
Created June 9, 2014 07:54
return result in format '00:00:00' of certain time duration
String.prototype.toHHMMSS = function () {
var sec_num = parseInt(this, 10); // don't forget the second param
var hours = Math.floor(sec_num / 3600);
var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
var seconds = sec_num - (hours * 3600) - (minutes * 60);
if (hours < 10) {hours = "0"+hours;}
if (minutes < 10) {minutes = "0"+minutes;}
if (seconds < 10) {seconds = "0"+seconds;}
var time = hours+':'+minutes+':'+seconds;
@lyonsun
lyonsun / background_worker.php
Created June 11, 2014 08:24
php script to run something in background every after closing browser.
<?php
function closeOutput($stringToOutput){
set_time_limit(0);
ignore_user_abort(true);
header("Connection: close\r\n");
header("Content-Encoding: none\r\n");
ob_start();
echo $stringToOutput;
$size = ob_get_length();