Skip to content

Instantly share code, notes, and snippets.

/* 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"
@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);
}
@loggerhead
loggerhead / .gitignore
Last active June 22, 2018 12:48
Erlang快速入门
*.beam
#!/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)
{
"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,
@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
@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 / highlight.css
Created April 28, 2016 15:51
pygments used
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #808080 } /* Comment */
.highlight .err { color: #F00000; background-color: #F0A0A0 } /* Error */
.highlight .k { color: #008000; font-weight: bold } /* Keyword */
.highlight .o { color: #303030 } /* Operator */
.highlight .cm { color: #808080 } /* Comment.Multiline */
.highlight .cp { color: #507090 } /* Comment.Preproc */
.highlight .c1 { color: #808080 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold } /* Comment.Special */
.highlight .gd { color: #A00000 } /* Generic.Deleted */
@loggerhead
loggerhead / own_mut_each_other.rs
Last active August 2, 2016 09:50
A example of two object own each other.
use std::rc::Rc;
use std::cell::RefCell;
struct Foo {
// Owns multiple mut trait objects
bars: Vec<Rc<RefCell<Bar>>>,
}
impl Foo {
fn new() -> Foo {
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->