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://stackoverflow.com/questions/3297196/how-to-set-up-a-squid-proxy-with-basic-username-and-password-authentication | |
# first install apache: | |
# $ sudo apt-get install -y apache2-utils | |
# add these five lines to /etc/squid3/squid.conf | |
auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid3/passwords | |
auth_param basic realm proxy | |
acl authenticated proxy_auth REQUIRED | |
http_access allow authenticated | |
http_port 3128 # or whatever you like |
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
# https://logz.io/blog/nginx-access-log-monitoring-dashboard/ | |
input { | |
file { | |
type => nginx_web | |
path => "/var/log/nginx/*" | |
exclude => "*.gz" | |
} | |
} |
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
import urllib.request | |
headers = {"Authorization":"Bearer eyJhbGciOiJIUzUxMiJ1.eyJzdWIiOiJhZG1pbiIsImF1dGhvcml0aWVzIjpbIlJPTEVfQURNSU4iXSwiaWF0IjoxNTQzOTA0NTY5LCJleHAiOjE1NDM5OTA5Njl9.0MLfJa9oud0ZMNC2e0q8YciuuB1G56KZH3m87ilrd7ryy4sjtR2U0MQnWSd89u-liWo1gLAgX9OyIDUnFXzJUw"} | |
req = urllib.request.Request(url="http://127.0.0.1:8090", headers=headers) | |
contents = urllib.request.urlopen(req).read() | |
print(contents) |
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
import urllib2 | |
headers = {"Authorization":"Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImF1dGhvcml0aWVzIjpbIlJPTEVfQURNSU4iXSwiaWF0IjoxNTQzOTA0NTY5LCJleHAiOjE1NDM5OTA5Njl9.1MLfJa9oud0ZMNC2e0q8YciuuB1G56KZH3m87ilrd7ryy4sjtR2U0MQnWSd89u-liWo1gLAgX9OyIDUnFXzJUw"} | |
req = urllib2.Request(url="http://127.0.0.1:8090", headers=headers) | |
contents = urllib2.urlopen(req).read() | |
print(contents) |
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
# -*- coding:utf-8 -*- | |
# Created by shellbye on 2017/9/19. | |
from PIL import Image | |
from skimage.measure import compare_ssim as ssim | |
import numpy as np | |
# requirements | |
# pip install scikit-image | |
# pip install pillow |
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 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 |
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
# 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 |
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
# 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; |
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
# 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 |
NewerOlder