Skip to content

Instantly share code, notes, and snippets.

View senarukana's full-sized avatar

Zhe Li senarukana

View GitHub Profile
// an example to create a new mapping `ctrl-y`
mapkey('<Ctrl-y>', 'Show me the money', function() {
Front.showPopup('a well-known phrase uttered by characters in the 1996 film Jerry Maguire (Escape to close).');
});
// an example to replace `T` with `gt`, click `Default mappings` to see how `T` works.
map('gt', 'T');
map('o', 't');
map('O', 'T');
map('H', 'S');
" Settings
set nohud
set nosmoothscroll
set noautofocus " The opposite of autofocus; this setting stops
" sites from focusing on an input box when they load
set typelinkhints
let searchlimit = 30
let scrollstep = 50
let barposition = "bottom"
let locale = "jp" " Current choices are 'jp' and 'uk'. This allows cVim to use sites like google.co.uk
@senarukana
senarukana / cancel.java
Created November 9, 2016 13:05
cancelation in java
package com.indeed.taz.downloader;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import java.io.IOException;
import java.util.ArrayList;
@senarukana
senarukana / mashal_json.go
Created January 19, 2016 02:58
golang json encode
package marshal
import (
"bytes"
"encoding/json"
"testing"
)
type MarshalInterface interface {
Example() string
;; keys define by this won't get override by other module
(defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
;; ident
(global-set-key (kbd ">") 'my-indent-region)
(global-set-key (kbd "<") 'my-unindent-region)
;; remap c-a
(global-set-key [remap move-beginning-of-line]
'smarter-move-beginning-of-line)
;; remap m-d
@senarukana
senarukana / implement_stack_using_queue.py
Last active October 31, 2015 11:09
stack using queue
from collections import deque
# push O(n)
# top, pop, O(1)
class Stack1:
# initialize your data structure here.
def __init__(self):
self.q = deque()
@senarukana
senarukana / dot_product.py
Last active November 18, 2017 18:18
dot product sparse vector
# m + n
# element expressed as (pos, value)
def multiply1(vec1, vec2):
i = 0
j = 0
vec = []
while i < len(vec1) and j < len(vec2):
if vec1[i][0] > vec2[j][0]:
@senarukana
senarukana / construct_pre_bst.py
Created June 2, 2015 14:29
construct bst by preorder
3 1 2 6 4 5
3
1 6
2 4
5
Basic Method:
Use the first element of preorder to divide the problem into 2 sub problems, construct the tree recursively
1. make the first element as root node
@senarukana
senarukana / utf8.cpp
Last active August 29, 2015 14:22
UTF8 encode
#include <iostream>
using namespace std;
/*
0xxxxxxx A single-byte US-ASCII code (from the first 127 characters)
110xxxxx One more byte follows
1110xxxx Two more bytes follow
11110xxx Three more bytes follow
10xxxxxx A continuation of one of the multi-byte characters
class InvalidException(Exception):
pass
def encode1(words):
res = ""
for word in words:
res += str(len(word)) + ':' + word
return res