Skip to content

Instantly share code, notes, and snippets.

View kk1fff's full-sized avatar

Chih-Kai (Patrick) Wang, 王致凱 kk1fff

View GitHub Profile
root@pws1:~# emacs /etc/apt/sources.list
root@pws1:~# apt-get update
Ign cdrom://[Debian GNU/Linux 8 _Jessie_ - Official Snapshot amd64 LIVE/INSTALL Binary 20170116-23:16] jessie InRelease
Ign cdrom://[Debian GNU/Linux 8 _Jessie_ - Official Snapshot amd64 LIVE/INSTALL Binary 20170116-23:16] jessie Release.gpg
Ign cdrom://[Debian GNU/Linux 8 _Jessie_ - Official Snapshot amd64 LIVE/INSTALL Binary 20170116-23:16] jessie Release
Ign cdrom://[Debian GNU/Linux 8 _Jessie_ - Official Snapshot amd64 LIVE/INSTALL Binary 20170116-23:16] jessie/main amd64 Packages/DiffIndex
Ign cdrom://[Debian GNU/Linux 8 _Jessie_ - Official Snapshot amd64 LIVE/INSTALL Binary 20170116-23:16] jessie/main Translation-en_US
Ign cdrom://[Debian GNU/Linux 8 _Jessie_ - Official Snapshot amd64 LIVE/INSTALL Binary 20170116-23:16] jessie/main Translation-en
Get:1 http://debian.csie.ntu.edu.tw stretch InRelease [184 kB]
Get:2 http://security.debian.org stretch/updates InRelease [62.9 kB]
root@pws1:~# apt-get install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libalgorithm-c3-perl libarchive-extract-perl libcgi-fast-perl libcgi-pm-perl
libclass-c3-perl libclass-c3-xs-perl libcpan-meta-perl libdata-optlist-perl
libdata-section-perl libfcgi-perl libintl-perl liblog-message-perl
liblog-message-simple-perl libmodule-build-perl libmodule-pluggable-perl
libmodule-signature-perl libmro-compat-perl libpackage-constants-perl
@kk1fff
kk1fff / q1.rs
Created March 25, 2016 14:52
very first rust program
use std::env::args;
use std::iter::FromIterator;
use std::io::BufReader;
use std::fs::File;
use std::io::BufRead;
struct Runner;
trait Run {
fn run(&self, path: &str) -> std::io::Result<()> {
@kk1fff
kk1fff / color_hist.py
Created August 18, 2015 18:33
draw color histogram of a pic.
#!/usr/bin/env python3
from PIL import Image
import sys, colorsys, numpy as np
import matplotlib.pylab as mp
img = Image.open(sys.argv[1])
pix = img.load()
w, h = img.size
rarr = np.zeros((w, h), 'int32')
@kk1fff
kk1fff / gist:2b1fc4ad9521ce8ba6f8
Created January 29, 2015 02:28
Perf discussion
Define/Discuss about test criteria
* app launch time
Discuss current implementation, start loading/end loading.
* suspend/resume
Time: receiving "power button" event -> first frame
* Boot time
Time: initrc -> lock screen ready. (visually loaded)
* Scrolling response time
Time: receiving touch event -> first composition that reflects the scrolling.
* Long drag/Contineously scrolling.
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
revs :: [a] -> [a]
revs [] = []
revs (x:xs) = (revs xs) ++ [x]
-- return a list that is consisted by
reverseAppend :: [a] -> [a] -> [a]
reverseAppend [] r = r
reverseAppend (x:xs) t = reverseAppend xs $ x:t
revs2 :: [a] -> [a]
divisibleByList :: Int -> [Int] -> Bool
divisibleByList n l | length l == 0 = False
divisibleByList n l = if ( rem n $ head l ) == 0
then True
else divisibleByList n $ tail l
getListPrime :: Int -> Int -> [Int] -> [Int]
getListPrime s n l | s == n = l
| otherwise = if divisibleByList s l
then getListPrime (s + 1) n l
@kk1fff
kk1fff / unzip-big5.py
Last active August 29, 2015 14:00
unzip and change to unicode
#!/usr/bin/env python
# ./unzip-big5.py xxx.zip
import zipfile
import os.path
import os
import sys
zfile = zipfile.ZipFile(sys.argv[1])
for big5name in zfile.namelist():
name = big5name.decode('big5')
@kk1fff
kk1fff / source.list
Created January 30, 2014 14:05
for sid
#
# deb cdrom:[Debian GNU/Linux 7.2.0 _Wheezy_ - Official amd64 CD Binary-1 20131012-14:05]/ wheezy main
# deb cdrom:[Debian GNU/Linux 7.2.0 _Wheezy_ - Official amd64 CD Binary-1 20131012-14:05]/ wheezy main
deb http://debian.nctu.edu.tw/debian/ sid main
deb-src http://debian.nctu.edu.tw/debian/ sid main
deb http://debian.nctu.edu.tw/debian/ sid non-free