Skip to content

Instantly share code, notes, and snippets.

@loggerhead
loggerhead / xcape.conf
Last active February 27, 2016 13:05
My xcape config
# Append this to `~/.profile`
# Swap `Alt` and `Win`
setxkbmap -option 'altwin:swap_alt_win'
# Map `Caps` to `Escape` and `Control`
setxkbmap -option 'caps:ctrl_modifier'
xcape -e 'Caps_Lock=Escape' -t 300
# Map left `Ctrl` to `F12`
xcape -e 'Control_L=F12'
# Map `Ctrl+p/n/f/b` to arrow key
@loggerhead
loggerhead / fuck_gfw.sh
Last active August 3, 2016 15:36
Several commands start VPN and Shadowsocks
#!/bin/bash
if [ -z "$SS_PASSWORD" ]; then
SS_PASSWORD="SET_YOUR_PASSWORD_HERE"
fi
if [ -z "$SS_METHOD" ]; then
SS_METHOD="aes-256-cfb"
fi
if [ -z "$SS_SERVER_PORT" ]; then
SS_SERVER_PORT=995
fi
{
"disk_low_priority" : true,
"lan_encrypt_data" : false,
"rate_limit_local_peers" : false,
"folder_rescan_interval" : 600,
"folder_defaults.delete_to_trash" : true,
"folder_defaults.use_dht" : false,
"folder_defaults.use_lan_broadcast" : true,
"folder_defaults.use_relay" : true,
"folder_defaults.use_tracker" : true,
#!/usr/bin/env python
# O(2^n), O(n)
def fib1(n):
if n == 0:
return 0
elif n == 1:
return 1
return fib1(n-1) + fib1(n-2)
@loggerhead
loggerhead / .gitignore
Last active June 22, 2018 12:48
Erlang快速入门
*.beam
@loggerhead
loggerhead / client.c
Last active October 30, 2017 09:20
web server example based on libuv
#include <stdio.h>
#include <assert.h>
#include <uv.h>
void after_write(uv_write_t *req, int status)
{
printf("after_write\n");
assert(!status);
}
/* zpipe.c: example of proper use of zlib's inflate() and deflate()
Not copyrighted -- provided to the public domain
Version 1.4 11 December 2005 Mark Adler */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "zlib.h"