Skip to content

Instantly share code, notes, and snippets.

View Shellbye's full-sized avatar
🎯
Focusing

shellbye Shellbye

🎯
Focusing
  • Momenta
  • Beijing, China
  • 05:45 (UTC -12:00)
View GitHub Profile
@Shellbye
Shellbye / .gitignore
Last active July 22, 2016 01:31
gitignore file for build django site using Pycharm
*.py[cod]
# C extensions
*.so
# Packages
*.egg
*.egg-info
dist
build
@Shellbye
Shellbye / auto_django_basic.sh
Created July 22, 2016 05:35
create django basic files with the deploy uwsgi config ini file and nginx conf file
#!/usr/bin/env bash
if [ $# -eq 0 ]
then
echo "Please input project name!"
echo "Usage: ./auto_django_basic.sh project_name"
exit
fi
echo $1
echo "Creating virtualenv $1..."
@Shellbye
Shellbye / deploy.sh
Last active August 9, 2016 08:35
setup django site with nginx and uwsgi
#!/usr/bin/env bash
# install nginx & uwsgi
sudo apt-get install nginx
pip install uwsgi
# connect ngxin to django site
ln -s /path/to/your/mysite/mysite_nginx.conf /etc/nginx/sites-enabled/
# restart or start whatever needed
@Shellbye
Shellbye / install_php5_on_ubuntu_1604.sh
Created August 27, 2016 02:16
install php5 on ubuntu 1604
# ref http://askubuntu.com/questions/756181/installing-php-5-6-on-xenial-16-04
dpkg -l | grep php| awk '{print $2}' |tr "\n" " "
sudo add-apt-repository ppa:ondrej/php
apt-get update
apt-get install php5.6
php -v
@Shellbye
Shellbye / timing_line_by_line.py
Created October 11, 2016 07:16
Test time usage of python code
def time_helper(pre, timer, name="-", is_last_one=False, start_time=None):
"""
:param pre: time.clock, last timestamp
:param timer: list, container of all record
:param name: str, help to know where the timer records
:param is_last_one: boolean, whether need to print result
:param start_time: time.clock, calculate to entire time range
:return: time.clock, for next call
@Shellbye
Shellbye / pure_js_ajax_post.js
Last active October 13, 2016 01:54
implement ajax post by pure js
var data = [
{'key': 'username', 'value': 'shellbye'},
{'key': 'password', 'value': 'password1'},
{'key': 'age', 'value': '26'},
{'key': 'key_x', 'value': "value_x"},
{'key': 'key_y', 'value': "value_y"}
];
function js_ajax(url, data) {
var myForm = new FormData();
for (var i = 0; i < data.length; i++) {
@Shellbye
Shellbye / full2half_script.py
Created October 24, 2016 05:36
Full-width to Half-width python script
def full2half(s):
# ref:https://segmentfault.com/a/1190000006197218
n = []
if isinstance(s, str):
s = s.decode('utf-8')
for char in s:
num = ord(char)
if num == 0x3000:
num = 32
@Shellbye
Shellbye / check_char_is_chinese.py
Created October 24, 2016 05:38
check if a char is chinese or not
def is_chinese(text_1):
if isinstance(text_1, str):
text_1 = text_1.decode('utf-8')
return u'\u4e00' <= text_1 <= u'\u9fff'
@Shellbye
Shellbye / install_scrapy_in_centos_6_5.sh
Last active November 26, 2016 04:36
Install scrapy in CentOS 6.5 in virtualenv, and install mysql to store the data crawled. After the installation, the `spider` dir will contains all the downloaded files and the `spider_env` is the virtualenv dir
#!/usr/bin/env bash
mkdir spider
cd spider/
yum update -y
# install pip on centos6
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum install -y python-pip
# install wget
yum install -y wget
@Shellbye
Shellbye / ubuntu_java_installer.sh
Last active January 3, 2017 09:07
Install oracle jre on Ubuntu script
#!/usr/bin/env bash
sudo wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u112-b15/server-jre-8u112-linux-x64.tar.gz
sudo mkdir /usr/lib/jvm
sudo tar -zxvf server-jre-8u112-linux-x64.tar.gz -C /usr/lib/jvm
sudo echo "export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_112" >> ~/.bashrc
sudo echo "export JRE_HOME=${JAVA_HOME}/jre" >> ~/.bashrc