This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import json | |
def serializers_data_2_json_list(data): | |
return json.loads(json.dumps(data)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo wget http://d3kbcqa49mib13.cloudfront.net/spark-2.1.0-bin-hadoop2.7.tgz | |
sudo tar -zxvf spark-2.1.0-bin-hadoop2.7.tgz | |
cd spark-2.1.0-bin-hadoop2.7 | |
sudo cp conf/log4j.properties.template conf/log4j.properties | |
sudo sed -i -e 's/INFO/WARN/g' conf/log4j.properties | |
sudo cp conf/spark-env.sh.template conf/spark-env.sh | |
sudo cp conf/slaves.template conf/slaves |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_chinese(text_1): | |
if isinstance(text_1, str): | |
text_1 = text_1.decode('utf-8') | |
return u'\u4e00' <= text_1 <= u'\u9fff' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.py[cod] | |
# C extensions | |
*.so | |
# Packages | |
*.egg | |
*.egg-info | |
dist | |
build |