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
#!/bin/zsh | |
# pyenv install for CentOS 6.5 x86_64 | |
yum install -y gcc gcc-c++ make git patch openssl-devel zlib-devel readline-devel sqlite-devel bzip2-devel | |
git clone git://github.com/yyuu/pyenv.git ~/.pyenv | |
export PATH="$HOME/.pyenv/bin:$PATH" | |
eval "$(pyenv init -)" |
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
# based off of this code https://gist.github.com/nandajavarma/a3a6b62f34e74ec4c31674934327bbd3 | |
# Brandon Skerritt | |
# https://skerritt.tech | |
def binary_search(the_array, item, start, end): | |
if start == end: | |
if the_array[start] > item: | |
return start | |
else: | |
return start + 1 |
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 time | |
import random | |
import struct | |
import select | |
import socket | |
def chk(data): | |
x = sum(x << 8 if i % 2 else x for i, x in enumerate(data)) & 0xFFFFFFFF | |
x = (x >> 16) + (x & 0xFFFF) |
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 -*- | |
import collections | |
import yaml | |
from rest_framework import fields | |
""" | |
Convert rest_framework.fields classes to Swagger data types according to http://swagger.io/specification/ | |
Return 'string' by default. |
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
# start / stop / restart / status | |
systemctl start test | |
systemctl stop test | |
systemctl restart test | |
systemctl status test | |
# logs use journalctl: | |
# tail the logs for unit `django` | |
journalctl -f -u django |
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
" Vim indent file | |
" Language: Lua | |
" Maintainer: Daniel Miller <daniel@bonsaiviking.com> | |
" Original Author: Daniel Miller <daniel@bonsaiviking.com> | |
" Last Change: 2014 Feb 6 | |
" Only load this indent file when no other was loaded. | |
if exists("b:did_indent") | |
finish | |
endif |
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
# Setting the prefix from C-b to C-a | |
set -g prefix C-a | |
# Free the original Ctrl-b prefix keybinding | |
unbind C-b | |
#setting the delay between prefix and command | |
set -sg escape-time 1 | |
# Ensure that we can send Ctrl-A to other apps |
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
# My ISP-provided fiber optical modem broadcasts a line of a poem every ten seconds. Here's the tcpdump of the complete poem. | |
# The optical modem is made by Shanghai Nokia-Bell Co.,Ltd and its model number is G-140W-UD. It's provided by my ISP, China Unicom in Shenzhen. | |
$ tcpdump -i vlan10 ether proto 0x8300 | |
15:59:00.720301 00:00:00:00:00:12 (oui Ethernet) > Broadcast, ethertype Unknown (0x8300), length 72: | |
0x0000: 0000 0000 e4ea 8386 d93c 5468 6520 6461 .........<The.da | |
0x0010: 7920 4920 6c6f 7374 206d 7920 7665 7279 y.I.lost.my.very | |
0x0020: 2066 6972 7374 2074 6f6f 7468 2c00 0000 .first.tooth,... | |
0x0030: 0000 0000 0000 0000 0000 .......... | |
15:59:10.740778 00:00:00:00:00:12 (oui Ethernet) > Broadcast, ethertype Unknown (0x8300), length 72: |
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
------------------------------commit------------------------------ | |
$ git status # 检查文件当前的状态 | |
$ git add [文件名] # 追踪新的文件 | |
$ git diff --cached # 若要看已经暂存起来的文件和上次提交时的快照之间的差异 | |
$ git commit -m "Story 182: Fix benchmark" # 用一行命令提交更新 | |
$ git commit -a -m 'added new benchmarks' # 跳过add命令直接提交 | |
$ git rm --cached log.log # 从git仓库中删除不小心追踪的文件(用于gitignore之前追踪的文件) | |
$ git mv file_from file_to # 移动文件/重命名文件 | |
------------------------------branch------------------------------ |
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
-- Running this snippet creates a function. This function can then be executed | |
-- in this manner: | |
-- SELECT truncate_tables('postgres'); | |
CREATE OR REPLACE FUNCTION truncate_tables(_username text) | |
RETURNS void AS | |
$func$ | |
BEGIN | |
RAISE NOTICE '%', | |
-- EXECUTE -- dangerous, test before you execute! |