Skip to content

Instantly share code, notes, and snippets.

View TheWaWaR's full-sized avatar
🌀
Focusing

LingFeng TheWaWaR

🌀
Focusing
View GitHub Profile
#!/usr/bin/env python
#coding: utf-8
# ==============================================================================
# python -m doctest -v test_rsub.py
# ==============================================================================
class Left1(int):
"""
@TheWaWaR
TheWaWaR / command-func-timeout.py
Last active August 29, 2015 14:02
subprocess.Popen execute Command / Invoke function timeout control.
#coding: utf-8
import os
import time
import signal
# from datetime import datetime
from multiprocessing import Process, Queue
import subprocess
import threading
@TheWaWaR
TheWaWaR / log_rotate.py
Created June 17, 2014 01:30
Log Rotate
import glob
import logging
import logging.handlers
LOG_FILENAME = 'logging_rotatingfile_example.out'
# Set up a specific logger with our desired output level
my_logger = logging.getLogger('MyLogger')
my_logger.setLevel(logging.DEBUG)
@TheWaWaR
TheWaWaR / .gitignore
Created July 5, 2014 06:44
Base .gitignore
\#*
*~
*.swp
*.py[oc]
*.bin
flymake_*
@TheWaWaR
TheWaWaR / start.py
Created July 6, 2014 13:17
Tomato time clock
#!/usr/bin/env python
#coding: utf-8
import os
import sys
import time
msg = "Well done, take a break!"
def start(min, msg):
time.sleep(min * 60)
@TheWaWaR
TheWaWaR / install-nginx.sh
Last active August 29, 2015 14:03
Install nginx
#### Easy way >> http://nginx.org/en/linux_packages.html
wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key
## Code names: squeeze, wheezy
# deb http://nginx.org/packages/debian/ [codename] nginx
# deb-src http://nginx.org/packages/debian/ [codename] nginx
sudo apt-get update
sudo apt-get install nginx
@TheWaWaR
TheWaWaR / build_url.py
Last active August 29, 2015 14:04
Build url with params
import urllib
def build_url(url, params):
query_string = '&'.join(['='.join([k, urllib.quote(v)]) for k, v in params.iteritems()])
return '{}?{}'.format(url, query_string)
params = {
'abc':'some#def',
'integer': '234123'
}
@TheWaWaR
TheWaWaR / fedora-20-install-note.md
Created August 29, 2014 13:12
Fedora 20 install note

Install network card driver

Install dependencies

    cd /run/media/weet
    su
    mkdir dvd
@TheWaWaR
TheWaWaR / redis.Dockerfile
Last active August 29, 2015 14:05
Redis dockerfile for centos7, redis-2.8
FROM centos:centos7
MAINTAINER weet <thewawar@gmail.com>
RUN rpm -ivh http://mirrors.ustc.edu.cn/fedora/epel/7/x86_64/e/epel-release-7-1.noarch.rpm
RUN yum install -y redis
EXPOSE 6379
ENTRYPOINT ["/usr/bin/redis-server"]
# sudo docker run -p 6379:6379 -d centos-redis
@TheWaWaR
TheWaWaR / postgres.Dockerfile
Last active August 29, 2015 14:06
Dockerfile for postgresql-server
FROM centos:centos7
MAINTAINER weet <thewawar@gmail.com>
RUN yum install -y http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-redhat93-9.3-1.noarch.rpm
RUN yum install -y postgresql93-server postgresql93-contrib
RUN /usr/pgsql-9.3/bin/postgresql93-setup initdb
RUN echo "host all all 0.0.0.0/0 md5" >> /var/lib/pgsql/9.3/data/pg_hba.conf
RUN echo "listen_addresses='*'" >> /var/lib/pgsql/9.3/data/postgresql.conf