Skip to content

Instantly share code, notes, and snippets.

View liuliqiang's full-sized avatar

Liqiang Lau liuliqiang

View GitHub Profile
@liuliqiang
liuliqiang / app.py
Last active September 9, 2016 03:34
flask-issue-2016-test
#!/usr/bin/env python
# encoding: utf-8
import os.path as op
from flask import Flask, request, render_template
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
@liuliqiang
liuliqiang / array.py
Last active September 9, 2016 07:34
python toml examples
import json
import toml
result = toml.loads("""
[array]
hello=['a', 'b', 'c']
arrya_with_array=[
['1', '2', '3'],
['4', '5', '6']
]
@liuliqiang
liuliqiang / authors_books.sql
Created September 18, 2016 06:37
sqlalchemy try
-- SQL for the Authors & Books tables
BEGIN TRANSACTION;
DROP TABLE IF EXISTS Books;
DROP TABLE IF EXISTS Authors;
CREATE TABLE Authors(AuthorId INTEGER PRIMARY KEY, Name TEXT);
INSERT INTO Authors VALUES(1, 'Jane Austen');
INSERT INTO Authors VALUES(2, 'Leo Tolstoy');
INSERT INTO Authors VALUES(3, 'Joseph Heller');

Free O'Reilly books and convenient script to just download them.

Thanks /u/FallenAege/ and /u/ShPavel/ from this Reddit post

How to use:

  1. Take the download.sh file and put it into a directory where you want the files to be saved.
  2. cd into the directory and make sure that it has executable permissions (chmod +x download.sh should do it)
  3. Run ./download.sh and wee there it goes. Also if you do not want all the files, just simply comment the ones you do not want.
@liuliqiang
liuliqiang / tmux-cheatsheet.markdown
Created November 17, 2017 10:44 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表

Tmux 快捷键 & 速查表

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

tmux at [-t 会话名]
@liuliqiang
liuliqiang / defer顺序
Last active August 15, 2018 15:41
Go 语言中的异常处理
package main
import "fmt"
func main() {
defer func() {
fmt.Println("stack a")
}()
defer func() {
fmt.Println("stack b")
@liuliqiang
liuliqiang / XMLHTTPRequest
Created August 20, 2018 15:42
XMLHTTPRequest
<html>
<!-- created by https://liqiang.io -->
<head>
<script type="text/javascript">function loadXMLDoc() {
// code for IE7+, Firefox, Chrome, Opera, Safari
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
console.log(xmlhttp.responseText);
}
@liuliqiang
liuliqiang / XMLHTTPRequest
Created August 20, 2018 15:42
XMLHTTPRequest
<html>
<!-- created by https://liqiang.io -->
<head>
<script type="text/javascript">function loadXMLDoc() {
// code for IE7+, Firefox, Chrome, Opera, Safari
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
console.log(xmlhttp.responseText);
}
@liuliqiang
liuliqiang / consul.service
Created October 8, 2018 02:22 — forked from yunano/consul.service
/etc/systemd/system/consul.service
[Unit]
Description=consul agent
Requires=network-online.target
After=network-online.target
[Service]
EnvironmentFile=-/etc/sysconfig/consul
Environment=GOMAXPROCS=2
Restart=on-failure
ExecStart=/usr/local/sbin/consul agent $OPTIONS -config-dir=/etc/consul.d
@liuliqiang
liuliqiang / script.sh
Created December 11, 2018 06:07 — forked from haisum/script.sh
comment and uncomment lines in bash script via sed
sed -i '/<pattern>/s/^/#/g' file #comment
sed -i '/<pattern>/s/^#//g' file #uncomment