Skip to content

Instantly share code, notes, and snippets.

@nguaman
nguaman / i.cantonfair.org.cn.py
Created February 24, 2016 19:09
Parsing #2 [i.cantonfair.org.cn]
from sys import exit
from pprint import pprint
import lxml.html
import requests
import re
url = 'http://i.cantonfair.org.cn/en/ExpExhibitorList.aspx?k=glassware&page=1'
doc = requests.get(url)
root = lxml.html.fromstring(doc.text)

参考 很奇怪的事情

cd /m 

之后打了一个tab给我提示:

bash: cannot create temp file for here-document: No space left on device

查了一圈之后找到答案:(具体原因不明,需要以后查看)

@nguaman
nguaman / clone-mysql-db.sh
Created June 9, 2016 13:59 — forked from christopher-hopper/clone-mysql-db.sh
Clone a MySQL database to a new database on the same server without using a dump file. This is much faster than using mysqldump.
#!/bin/bash
DBUSER="root";
DBPASS="";
DBHOST="localhost";
DB_OLD=mydatabase
DB_NEW=clone_mydatabase
DBCONN="--host=${DBHOST} --user=${DBUSER} --password=${DBPASS}";
@nguaman
nguaman / rds.sh
Created June 16, 2016 14:44 — forked from onyxraven/rds.sh
Amazon RDS Performance Tuning Settings
#XLarge DBInstanceClassMemory = 15892177440 = 14.8GB
#/32 = 496630545 = 473MB
#/64 = 248315272 = 236MB
#/128 = 124157636 = 118MB
#/256 = 62078818 = 59MB
#/512 = 31039409 = 29MB
#/12582880 = 1263 #default same divisor as max_connections = 4041.6MB = 4237924762
#/25165760 = 623 # half of max_connections = 1993.6MB
#/50331520 = 315 # quarter of max_connections = 1008MB = 1056964608
#*(3/4) #default innodb pool size = 11922309120
@nguaman
nguaman / gist:7d34152458e2b70d6eea3c852cadd707
Created June 16, 2016 15:51 — forked from douglasjarquin/gist:2208690
Amazon RDS Performance Tuning Settings
rds-modify-db-parameter-group {param-group-name} \
--parameters="name=character_set_server, value=utf8, method=pending-reboot" \
--parameters="name=collation_server, value=utf8_general_ci, method=pending-reboot" \
--parameters="name=tmp_table_size, value={DBInstanceClassMemory/16}, method=pending-reboot" \
--parameters="name=max_heap_table_size, value={DBInstanceClassMemory/16}, method=pending-reboot" \
--parameters="name=query_cache_type, value=1, method=pending-reboot" \
--parameters="name=query_cache_size, value=131072, method=pending-reboot" \
--parameters="name=table_open_cache, value=2500, method=pending-reboot" \
--parameters="name=join_buffer_size, value={DBInstanceClassMemory/64}, method=pending-reboot" \
--parameters="name=thread_cache_size, value={DBInstanceClassMemory/12582880}, method=pending-reboot" \
@nguaman
nguaman / install-mongodb.md
Created June 21, 2016 16:33 — forked from adamgibbons/install-mongodb.md
Install MongoDB on Mac OS X 10.9

Install MongoDB with Homebrew

brew install mongodb
mkdir -p /data/db

Set permissions for the data directory

Ensure that user account running mongod has correct permissions for the directory:

@nguaman
nguaman / Operaciones-Git
Created August 10, 2016 18:01 — forked from jelcaf/Operaciones-Git
Git Tips - Mini-trucos de Git para facilitarme la tarea
#############################################
# Push de la rama actual
git push origin $rama_actual
#############################################
# Volver a un commit anterior, descartando los cambios
git reset --HARD $SHA1
#############################################
# Ver y descargar Ramas remotas
@nguaman
nguaman / Php.sublime-build
Created August 11, 2016 13:07 — forked from abtris/Php.sublime-build
Sublime Text 3 - run php script at F7
{
"cmd": ["php", "$file"],
"selector": "source.php",
"target": "exec",
"variants": [
{ "cmd": ["/usr/local/php5/bin/phpunit", "$file"],
"name": "Run"
}
]
}
@nguaman
nguaman / class.database.php
Created August 25, 2016 18:08 — forked from jonashansen229/class.database.php
PHP OOP Database class using MySQLI and Singleton pattern. Only one instance of the class will be made, this requires less memory.
<?php
/*
* Mysql database class - only one connection alowed
*/
class Database {
private $_connection;
private static $_instance; //The single instance
private $_host = "HOSTt";
private $_username = "USERNAME";
private $_password = "PASSWORd";
@nguaman
nguaman / www-html-file-permission-fix.md
Created November 3, 2016 15:07 — forked from nasirkhan/www-html-file-permission-fix.md
Correct permissions for /var/www and laravel wordpress

First, you should ensure that your username is included in www-data group. If not, you can add your username as www-data group

sudo adduser $USER www-data

After that, you should change the ownership of /var/www to your username

sudo chown $USER:www-data -R /var/www

Next step, you should change permission to 755 (rwxr-xr-x), not recommend changing permission to 777 for security reason