Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# Weisi Dai <weisi@x-research.com>
t = 0
swaps = 0
def check(a, i):
global swaps
t = i
@weisi
weisi / a.py
Created July 4, 2014 02:23
Python: Comment Matters
# tab-width: 4
import sys
arr = ["Segment", "Fault"]
space = " "
nl = "\n"
for i in range(5):
for item in arr:
sys.stdout.write(item)
@weisi
weisi / privacy-design-pattern-unusual-activities.rst
Last active August 29, 2015 14:01
Privacy Design Pattern: Handling Unusual Account Activities

Privacy Design Pattern: Handling Unusual Account Activities

author

Weisi Dai (weisi@cmu.edu)

date

Apr 28, 2014

The Privacy Design Pattern

@weisi
weisi / dns_ttl.sh
Last active July 25, 2020 06:42
尝试利用 IP.TTL 确定 DNS 污染发生的位置
#!/bin/bash
# Weisi Dai <weisi@cmu.edu>
#
# Usage: bash dns_ttl.sh 8.8.8.8
#
# Dependencies: mtr dig iptables bc
DOMAIN=twitter.com
DNS=$1
@weisi
weisi / bmp2rle.py
Created October 11, 2012 05:17
Black-and-white Windows Bitmap -> CompuServe RLE converter
#!/usr/bin/env python3
# Weisi Dai <multiple1902@gmail.com>
# 09055029, Xi'an Jiaotong University
# Oct 11, 2012
# Released under MIT License
# Reads a black-and-white Windows Bitmaap, parses it and converts it to CompuServe RLE format.
import struct
from types import * # assert
@weisi
weisi / linux3.3-sata-fix.sh
Created April 19, 2012 12:22
workaround for linux 3.3 SATA hotplug issue after suspend/resume
#!/bin/bash
# Written by multiple1902 <multiple1902@gmail.com>
#
# workaround for linux 3.3 SATA hotplug issue after suspend/resume
#
# gist page:
# https://gist.github.com/2420684
#
# bug report:
# https://lkml.org/lkml/2012/2/19/70
@weisi
weisi / mcmthesis.cls
Last active September 30, 2015 08:17
Lightweight template for Mathematical Contest in Modelling 2012
% multiple1902 <multiple1902@gmail.com>
% mcmthesis.cls
% This work is licensed under a Creative Commons Attribution 3.0 Unported License
% http://creativecommons.org/licenses/by/3.0/
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesClass{mcmthesis}
[2012/2/6 0.9.9 Lightweight Template for Mathematical Contest in Modeling]
\LoadClass[11pt]{article}
@weisi
weisi / update-resolv-conf
Created January 25, 2012 08:55
update-resolv-conf for openSUSE, using SUSE's netconfig with dirty tricks. No need for resolvconf.
#!/bin/bash
#
# Parses DHCP options from openvpn to update resolv.conf
# To use set as 'up' and 'down' script in your openvpn *.conf:
# up /etc/openvpn/update-resolv-conf
# down /etc/openvpn/update-resolv-conf
#
# Used snippets of resolvconf script by Thomas Hood <jdthood@yahoo.co.uk>
# and Chris Hanson
# Licensed under the GNU GPL. See /usr/share/common-licenses/GPL.