Skip to content

Instantly share code, notes, and snippets.

[package]
name = "pathmatcher"
version = "0.1.0"
edition = "2018"
[lib]
path = "lib.rs"
[dependencies]
bitflags = "1.0"
@quark-zju
quark-zju / sftp-changes.py
Created April 17, 2019 16:10
A naive incremental sync script via sftp
#!/usr/bin/env python
"""A naive incremental sync script via sftp
When do you want to use this?
- want a non-lazy local file system (not fuse/sshfs)
- sftp is configured easier to use than ssh (rsync or git)
This script is very simple and does not handle complex cases. Use rsync to:
- set up an initial mirror
@quark-zju
quark-zju / Gemfile
Last active May 25, 2016 20:06
i3-scriptable with auto-splitv script (emulating i3 3.x behavior)
source 'http://rubygems.org'
gem 'i3ipc', '~> 0.2.0'
#! /usr/bin/env python3
# quick & dirty preforked echo server listening on /tmp/server
# client: socat unix-connect:/tmp/server stdout
import os, sys, time, socketserver
class PreforkMixIn:
max_nchildren = 3
children = None
@quark-zju
quark-zju / git-vendor.sh
Last active October 16, 2015 11:52
git-vendor
fatal() {
echo "$@"
exit 1
}
get_vendor_dir() {
[ -n "$VENDOR" ] && echo $VENDOR && return
[ -d src ] && echo src/vendor && return
echo vendor
}
@quark-zju
quark-zju / qingcloud-control.rb
Created June 2, 2015 14:38
Poor man's qingcloud single instance management script
#!/usr/bin/env ruby
# qingcloud-control
#
# Poor man's qingcloud single instance management script. You may find this script useful, if you:
# - are an individual qingcloud user. do not have a lot of instances (assuming only one)
# - do not need to run instance 7x24. instances are powered off most of the time
# - do not use advanced networks. no routers, no private networks. just an instance with default network and an eip attached
# - want to save money
# - use ssh to login, have following lines in ~/.ssh/config:
@quark-zju
quark-zju / copy-paste.sh
Created May 28, 2015 08:43
copy-paste.sh
copy () {
cat "$@" 2> /dev/null | xsel -b
local _path
for _path in "$@"
do
if [ "${_path[1]}" = '/' ]
then
echo "${_path}"
else
echo "${PWD}/${_path}"
@quark-zju
quark-zju / gdb-trace.py
Last active December 31, 2023 14:14
Trace all function calls using gdb
#!/usr/bin/env python
try:
import gdb
inside_gdb = True
except ImportError:
inside_gdb = False
if inside_gdb:
@quark-zju
quark-zju / git-pushf
Created December 1, 2014 01:48
Quick & dirty way to sync git to remote
#!/usr/bin/env ruby
# Find git root
while !File.exists?('.git/config')
Dir.chdir('..')
raise 'git root not found' if Dir.pwd == '/'
end
args = ARGV
@quark-zju
quark-zju / create_machine.sh
Last active August 29, 2015 14:10 — forked from AVGP/create_machine.sh
Script to create a user-mode linux machine (tested under Debian 7)
#!/bin/sh
### functions
f() { echo "Failed."; exit; }
check_packages()
{
hash linux || apt-get install user-mode-linux || f
hash debootstrap || apt-get install debootstrap || f