Skip to content

Instantly share code, notes, and snippets.

View yinyanghu's full-sized avatar
🎯
Focusing

Jian Li yinyanghu

🎯
Focusing
View GitHub Profile
@yinyanghu
yinyanghu / opml.py
Created July 5, 2013 16:54
Google Reader OPML File Analyser, opml2snow in snownews for linux
import listparser as lp
d = lp.parse('subscriptions.xml')
n = len(d.feeds)
print("Total Feeds =", n)
for i in range(0, n):
print(d.feeds[i].url)
#print(d.feeds[100].url)
function [maxtab, mintab]=peakdet(v, delta, x)
%PEAKDET Detect peaks in a vector
% [MAXTAB, MINTAB] = PEAKDET(V, DELTA) finds the local
% maxima and minima ("peaks") in the vector V.
% MAXTAB and MINTAB consists of two columns. Column 1
% contains indices in V, and column 2 the found values.
%
% With [MAXTAB, MINTAB] = PEAKDET(V, DELTA, X) the indices
% in MAXTAB and MINTAB are replaced with the corresponding
% X-values.
@yinyanghu
yinyanghu / linus_ll.c
Created May 1, 2013 16:47
Link List with hack remove function in C by Linus Torvalds. He tells me what the pointer is.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct link_list
{
int key;
struct link_list *next;
};
@yinyanghu
yinyanghu / unzip-gbk.py
Created April 26, 2013 15:50
Extracting file from ZIP format for GBK coding
import os
import sys
import zipfile
print "Processing File " + sys.argv[1]
file=zipfile.ZipFile(sys.argv[1],"r");
for name in file.namelist():
utf8name=name.decode('gbk')
print "Extracting " + utf8name
@yinyanghu
yinyanghu / CPPException.cc
Created April 26, 2013 08:12
Exception Handler in C++ Language
#include <iostream>
using namespace std;
int main()
{
try
{
throw(1);
int a = 1 / 0;
@yinyanghu
yinyanghu / Makefile
Last active December 16, 2015 11:19 — forked from overminder/.gitignore
CC = gcc
CFLAGS = -Wall -O2
DEBUGFLAGS = -g
main : main.o list.o
bench : main
valgrind --tool=cachegrind --cachegrind-out-file=linus.out \
./main 1000000 --linus
valgrind --tool=cachegrind --cachegrind-out-file=other.out \

Steps to upgrade vim in arch linux for python runtime support

Python support is needed by vim in order to run things like Conque and Slimv. Arch keeps vim slim by only providing Python support in gvim. But you may prefer vim to gvim, so here's what's needed.

More ABS info.

# Install and run abs (sync)

sudo pacman -S abs

@yinyanghu
yinyanghu / ArcadeManao.cpp
Last active December 16, 2015 03:29
Topcoder SRM576 Div2
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
@yinyanghu
yinyanghu / cwc.pl
Created April 12, 2013 04:50
Chinese Word Counter
#!/usr/bin/perl -w
my $s;
my $x;
my $y;
my $ncword = 0;
my $cword = 0;
while (<>) {
$s = $_;
@yinyanghu
yinyanghu / DP_ChessAttack.cc
Created April 9, 2013 09:57
Dynamic Programming with State Compression POJ 1185 炮兵阵地
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 100
#define maxm 10
#define maxstatus 70
using namespace std;