Skip to content

Instantly share code, notes, and snippets.

View codescv's full-sized avatar
🎯
Focusing

Chi Zhang codescv

🎯
Focusing
View GitHub Profile
@codescv
codescv / .zshrc
Created November 10, 2012 14:20
zshrc
# GistID: 4051243
# The prompt
# enable color support of ls and also add handy aliases
setopt prompt_subst
autoload -U colors
colors
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
@codescv
codescv / .bashrc
Created January 11, 2013 14:44
.bashrc
# GistID: 4511178
# To the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to the
# public domain worldwide. This software is distributed without any warranty.
# You should have received a copy of the CC0 Public Domain Dedication along
# with this software.
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
# base-files version 4.1-1
@codescv
codescv / gist:6146378
Created August 3, 2013 13:04
bit vector (aka bitmap) implementation in C
#include <stdio.h>
typedef struct {
char* bits;
int size;
}bitvector;
bitvector* create_bitvec(int n_bits) {
bitvector* vec = (bitvector*)malloc(sizeof(bitvector));
int size = sizeof(bitvector) * ceil(n_bits/8.0);
@codescv
codescv / sort.c
Created August 7, 2013 08:22
remainder
// GistID: 6172227
#include <stdio.h>
#include <stdlib.h>
struct node_t {
struct node_t *next;
int val;
};
typedef struct node_t node;
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
using namespace std;
int fact(int n) {
@codescv
codescv / cm10.1-py-patch
Created September 16, 2013 01:35
Allow searching pinyin in the T9 dialer in non-Chinese locales on cm10.1
┌──[chi@mint]──[~/android/system/packages/apps/Contacts]── (8e9a5fb...) * ────────
$ git diff
diff --git a/src/com/android/contacts/dialpad/util/NameToNumberFactory.java b/src/com/android/contacts/dial
index c0adef6..3ca285b 100644
--- a/src/com/android/contacts/dialpad/util/NameToNumberFactory.java
+++ b/src/com/android/contacts/dialpad/util/NameToNumberFactory.java
@@ -34,13 +34,15 @@ public class NameToNumberFactory {
// Check locale and returns matched class inherited from NameToNumber class.
NameToNumber instance;
# GistID: 7287953
startup_message off
escape ^X^X
caption always "%?%F%{-b 5w}%:%{-b bb}%? %H | %l | %m-%d %c |%?%F%{-b 4w}%?%L=%-Lw%45>%{-b w4}%n%f* %t%{-}%+Lw%-0<"
#!/usr/bin/perl -w
# GistID: 7316128
# example: argparse.pl arg1 arg2 arg3 --long-param x -l hh -a arg4 arg5
# params = {"long"=>"x", "short"=>"hh", "switch-a":1}
# args = ("arg1", "arg2", "arg3", "arg4", "arg5")
use strict;
use 5.010;
// GistID: 7984760
// KMP substring search && FSM substring search
#include <string>
#include <iostream>
#include <vector>
using namespace std;
typedef vector<vector<int> > FSMType;
@codescv
codescv / fonts.conf
Created January 17, 2014 08:58
fonts.conf
<?xml version='1.0'?>
<!-- GistID: 8470342 -->
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<match target="font">
<edit mode="assign" name="rgba">
<const>rgb</const>
</edit>
</match>
<match target="font">