Skip to content

Instantly share code, notes, and snippets.

View oilbeater's full-sized avatar
🎯
Focusing

Mengxin Liu oilbeater

🎯
Focusing
View GitHub Profile
@oilbeater
oilbeater / SQLs
Last active August 29, 2015 14:08
Common sql statement
* Change the column property
ALTER TABLE table_name MODIFY COLUMN column_name VARCHAR(50);
* Create table from exist table
CREATE TABLE table_name LIKE exist_table; //empty table with same structure
CREATE TABLE table_name AS SELECT * FROM exist_table; //copy the whole table
* Estimate rough row number of a database
SELECT TABLE_NAME,TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=table_schema; // this is only an estimate,not the exact one!!!!!
@oilbeater
oilbeater / count_database.sh
Last active August 29, 2015 14:08
Count database row number
#!/bin/bash -x
# To count row number of each table in a schema
# Example: echo 127.0.0.1 root rootpassword rootdatabase | ./count_database.sh 2>/dev/null
while read host username password schema;
do
mysql -h$host -u$username -p$password -Ne "select table_name from information_schema.tables where table_schema='${schema}'"|
while read table;
do
@oilbeater
oilbeater / SHELLs
Created October 31, 2014 06:17
Common used shells
#Batch move
ls | head -n 50 | xargs -i mv {} mvdir/
#Batch files replace
sed -i "s/older/newser/g" `grep -li older *`
@oilbeater
oilbeater / python
Last active February 28, 2018 11:55
python
// use shell command
import subprocess
output = subprocess.check_output('dir', shell=True)
print(output)
@oilbeater
oilbeater / python_fib
Created February 1, 2015 06:04
python fib
ref = 'https://docs.python.org/3/library/functools.html'
@lru_cache(maxsize=None)
def fib(n):
if n < 2:
return n
return fib(n-1) + fib(n-2)
@oilbeater
oilbeater / dummy-web-server.py
Last active June 23, 2017 03:29 — forked from bradmontgomery/dummy-web-server.py
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
"""
Very simple HTTP server in python.
Usage::
./dummy-web-server.py [<port>]
Send a GET request::
curl http://localhost
@oilbeater
oilbeater / cali_rule.sh
Created July 2, 2017 06:11
Modify calico route rules.
#!/bin/bash
while :
do
address=`ifconfig bond0 | grep inet | grep -v inet6|awk '{print $2}'`
echo $address
ip route | grep cali | grep -v src | while read -r line ;
do
ip route replace $line src $address
8.2.3. HTTP log format
----------------------
The HTTP format is the most complete and the best suited for HTTP proxies. It
is enabled by when "option httplog" is specified in the frontend. It provides
the same level of information as the TCP format with additional features which
are specific to the HTTP protocol. Just like the TCP format, the log is usually
emitted at the end of the session, unless "option logasap" is specified, which
generally only makes sense for download sites. A session which matches the
"monitor" rules will never logged. It is also possible not to log sessions for
@oilbeater
oilbeater / resolv-conf-reset.md
Last active November 18, 2019 02:14
generated by networkmanager resolv.conf

edit /etc/sysconfig/network-scripts/ifcfg-eth0

it will looks like

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
@oilbeater
oilbeater / prome-http-handler
Created February 11, 2020 02:41
Prometheus HTTP Handler
package main
import (
"net/http"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
func main() {
http.Handle("/metrics", promhttp.Handler())