Skip to content

Instantly share code, notes, and snippets.

View liuyix's full-sized avatar

Yi Liu liuyix

  • Shanghai
  • 07:56 (UTC +08:00)
View GitHub Profile
binlog_list = list()
for i in xrange(20):
# 使用zfill补全0
binlog = 'mysql-bin.' + str(i).zfill(6)
binlog_list.append(binlog)
@liuyix
liuyix / README.rst
Last active January 28, 2016 02:47 — forked from dupuy/README.rst
Common markup for Markdown and reStructuredText

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.

@liuyix
liuyix / tmux.md
Created October 21, 2015 02:26 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux 快捷键

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

# remap prefix to Control + a
def tail( f, lines=20 ):
total_lines_wanted = lines
BLOCK_SIZE = 1024
f.seek(0, 2)
block_end_byte = f.tell()
lines_to_go = total_lines_wanted
block_number = -1
blocks = [] # blocks of size BLOCK_SIZE, in reverse order starting
# from the end of the file
string='My string';
if [[ $string == *My* ]]
then
echo "It's there!";
fi
#!/usr/bin/env python2
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford (jspenguin@jspenguin.org)
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select
@liuyix
liuyix / smp.md
Last active August 29, 2016 08:22
SMP入门;并发编程

##Introduction SMP is an acronym for “Symmetric Multi-Processor”. It describes a design in which two or more identical CPU cores share access to main memory. Until a few years ago, all Android devices were UP (Uni-Processor).

Most — if not all — Android devices do have multiple CPUs, but generally one of them is used to run applications while others manage various bits of device hardware (for example, the radio). The CPUs may have different architectures, and the programs running on them can’t use main memory to communicate with each other.

Most Android devices sold today are built around SMP designs, making things a bit more complicated for software developers. The sorts of race conditions you might encounter in a multi-threaded program are much worse on SMP when two or more of your threads are running simultaneously on different cores. What’s more, SMP on ARM is more challenging to work with than SMP on x86. Code that has been thoroughly tested on x86 may break badly on ARM.

The rest of this document wil

@liuyix
liuyix / ubuntu-create-luks-partition.md
Last active December 31, 2015 10:19
ubuntu下建立加密分区
@liuyix
liuyix / mysql-encoding.md
Last active December 30, 2015 16:19
mysql中文编码

所有的程序、代码都要考虑国际化问题!否则就会遇到乱码的情况。mysql默认的编码都是latin1,因此如果在配置mysql、建库等操作使用默认的话,乱码问题必然会遇到。

编码设置的几个地方:

  • my.cnf
  • mysql client连接
  • sqlalchemy连接数据库
  • create database/table时指定编码

mysql可用的collationshow collation

@liuyix
liuyix / python-tips.md
Last active December 30, 2015 16:09
python best practise!