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 / 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 / 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 / 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;
};
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 / 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)
@yinyanghu
yinyanghu / FoxAndGo.cpp
Created September 8, 2013 11:41
Topcoder SRM590 Div2
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
@yinyanghu
yinyanghu / LittleElephantAndDouble.cpp
Created November 23, 2013 19:54
Topcoder SRM597 Div2
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <stdlib.h>
#include <stdio.h>
/* Create a lambda function. Note: unlike lambdas in functional
languages, this lambda does not capture the containing
environment. Thus, if you access the enclosing environment, you
must ensure that the lifetime of this lambda is bound by the
lifetime of the enclosing environment (i.e., until the enclosing
function returns). This means that if you access local
@yinyanghu
yinyanghu / hou.c
Created October 31, 2014 21:26
IOCCC 2011 Winner -- Qiming Hou
#include <stdio.h>
#include <math.h>
#define clear 1;if(c>=11){c=0;sscanf(_,"%lf%c",&r,&c);while(*++_-c);}\
else if(argc>=4&&!main(4-(*_++=='('),argv))_++;g:c+=
#define puts(d,e) return 0;}{double a;int b;char c=(argc<4?d)&15;\
b=(*_%__LINE__+7)%9*(3*e>>c&1);c+=
#define I(d) (r);if(argc<4&&*#d==*_){a=r;r=usage?r*a:r+a;goto g;}c=c
#define return if(argc==2)printf("%f\n",r);return argc>=4+
#define usage main(4-__LINE__/26,argv)
#define calculator *_*(int)
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
class Solution {
public:
void solve(vector< vector<char> > &board);
};
void Solution::solve(vector< vector<char> > &board) {
int n = board.size();