Skip to content

Instantly share code, notes, and snippets.

View tru2dagame's full-sized avatar
💭
🏀

Tru tru2dagame

💭
🏀
  • Ubiquiti
  • Shanghai
View GitHub Profile
@tru2dagame
tru2dagame / emacs24.md
Created July 14, 2014 09:35
install emacs24 on Ubuntu

Install Emacs24 On Ubuntu

sudo apt-get install python-software-properties
sudo apt-get update
sudo apt-get install emacs24

Enjoy it

@tru2dagame
tru2dagame / Remove DS_Store .md
Created August 4, 2014 03:51
Remove .DS_Store Files From A Git Repository

Remove existing files from the repository:

find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch

Add the line

.DS_Store

to the file .gitignore, which can be found at the top level of your repository (or created if it isn't there already). Then

@tru2dagame
tru2dagame / convert_csv_string_to_array.php
Created August 19, 2014 10:15
php convert csv string to array
<?php
function convert_csv_string_to_array($csvstring) {
$lines = explode(PHP_EOL, current($csvstring));
$array = array();
foreach ($lines as $key => $line) {
if (substr(trim($line), -1) == ',') {
$line = substr(trim($line), 0, -1);
}
if ($key == 0) {
$head = str_getcsv($line);
@tru2dagame
tru2dagame / git assume unchanged.md
Last active March 17, 2023 12:55
git update-index --assume-unchanged

Ignore the file that Git has tracked already

git update-index --assume-unchanged <FileName>

Show all the files that you have assumed before in case you forgot them

git ls-files -v | grep h\ 

It will show:

h .gitignore

h config.php

@tru2dagame
tru2dagame / apache_htaccess.md
Created October 23, 2014 06:58
apache htaccess for url query string

.htaccess Example for URL liks this

www.xxx.com/guest/s/default/?id=baba&query=sth

.htaccess

# apache rewrite rule
RewriteEngine On
RewriteCond $1 !^(index\.php|rewrite\.php)

RewriteRule ^guest/s/([^/])/(.)$ rewrite.php?site=$1&$2 [QSA]

@tru2dagame
tru2dagame / update_nodejs.md
Last active August 29, 2015 14:08
UPDATE NodeJS and npm

Update NodeJS

Update NodeJS to the latest stable version

➜  ~  sudo npm cache clean -F
➜  ~  sudo npm install -g n
➜  ~  sudo n stable

Then:

➜ ~ node -v

@tru2dagame
tru2dagame / check_nohup_sh.md
Last active August 29, 2015 14:09
Check the nohup to see if works well.

check_nohup.sh

#!/bin/bash
if
ps -ef | grep "send_confirm.php" | grep -v "grep"
then
echo “Running!”
else
echo “Stopped!”

cd /var/www/bdev/ubnt_email

@tru2dagame
tru2dagame / uninstall_mysql.md
Last active August 29, 2015 14:12
uninstall mysql from dev.mysql.com on a Mac OS X

To uninstall MySQL and completely remove it (including all databases) from your Mac do the following:

. Open a terminal window
. Use mysqldump to backup your databases to text files!
. Stop the database server
. sudo rm /usr/local/mysql
. sudo rm -rf /usr/local/mysql*
. sudo rm -rf /Library/StartupItems/MySQLCOM
. sudo rm -rf /Library/PreferencePanes/My*

. edit /etc/hostconfig and remove the line MYSQLCOM=-YES-

@tru2dagame
tru2dagame / post-receive.md
Last active August 29, 2015 14:24
GIT hooks post-receive

GIT hooks

post-receive

#!/bin/sh
cd /path/to/working-copy/ || exit
unset GIT_DIR
git pull

exec git-update-server-info
@tru2dagame
tru2dagame / surge.conf
Created October 4, 2015 17:39 — forked from janlay/README.md
Yet another config for Surge.app
# This config file was created for myself (@janlay). You may want to add or remove some rules to make efficient use of the Internet.
[General]
# warning, notify, info, verbose
loglevel = notify
[Proxy]
# http, https, socks5
Proxy = custom, 1.2.3.4, 443, rc4-md5, password, http://server/custom.module