Skip to content

Instantly share code, notes, and snippets.

View Shellbye's full-sized avatar
🎯
Focusing

shellbye Shellbye

🎯
Focusing
  • Momenta
  • Beijing, China
  • 20:44 (UTC -12:00)
View GitHub Profile
@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
@Shellbye
Shellbye / ubuntu_spark_installer.sh
Last active October 9, 2018 07:58
Install spark 2.1.0 on ubuntu
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
@Shellbye
Shellbye / serializers_data_2_json_list_utils.py
Created February 8, 2017 13:50
convert django restful serializers data to json list
# -*- coding: utf-8 -*-
import json
def serializers_data_2_json_list(data):
return json.loads(json.dumps(data))
@Shellbye
Shellbye / demo.py
Created March 30, 2017 08:57
sphinxsearch python mysql
import MySQLdb
conn = MySQLdb.connect(host="127.0.0.1", port=9306)
cursor = conn.cursor()
cursor.execute("select * from test1 where MATCH ('@content another')")
rows = cursor.fetchall()
for row in rows:
for i in range(len(row)):
print row[i]
@Shellbye
Shellbye / multi_proc_list.py
Created April 6, 2017 03:04
process list with multiprocess
# -*- coding:utf-8 -*-
# Created by shellbye on 2017/3/10.
import multiprocessing
def multi_process_list(process_num=None, func=None, list_to_process=None, **kwargs):
"""
处理多进程任务的框架,用于按段处理list数据
:param process_num: 进程数
:param func: 对每段list的处理方法,需要接收三个参数:queue,start_pos,offset
@Shellbye
Shellbye / nginx.conf
Last active April 11, 2017 08:28
uwsgi zero downtime restart config Zerg Dance
# nginx.conf
# the upstream component nginx needs to connect to
upstream my_project {
server 127.0.0.1:3031
}
# configuration of the server
server {
# the port your site will be served on
@Shellbye
Shellbye / nginx_load_balance.conf
Created April 18, 2017 09:35
nginx load balance simple demo
# nginx_load_balance.conf
# https://www.nginx.com/resources/admin-guide/load-balancer/
upstream backend {
server 127.0.0.1:8000;
server 192.168.1.1;
server domain.to.other.server;
}
server {
listen 80;
@Shellbye
Shellbye / uwsgi_start_boots.txt
Created May 4, 2017 08:34
uwsgi start when system boots
# http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html#make-uwsgi-startup-when-the-system-boots
# create a directory for the vassals
sudo mkdir /etc/uwsgi
sudo mkdir /etc/uwsgi/vassals
# symlink from the default config directory to your config file
sudo ln -s /path/to/your/mysite/mysite_uwsgi.ini /etc/uwsgi/vassals/
# run the emperor
uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data
@Shellbye
Shellbye / nginx_grok.conf
Last active July 8, 2020 09:11
uwsgi & nginx grok pattern
# https://logz.io/blog/nginx-access-log-monitoring-dashboard/
input {
file {
type => nginx_web
path => "/var/log/nginx/*"
exclude => "*.gz"
}
}
@Shellbye
Shellbye / install_python.sh
Last active July 12, 2017 02:38
Install python on Ubuntu
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
version=2.7.13
cd /tmp
wget https://www.python.org/ftp/python/$version/Python-$version.tgz
tar -xvf Python-$version.tgz