Skip to content

Instantly share code, notes, and snippets.

View liancheng's full-sized avatar

Cheng Lian liancheng

View GitHub Profile
@liancheng
liancheng / .vimrc
Created August 3, 2012 07:06
Lian Cheng's .vimrc
" Loads default settings when startup {{{
source $VIMRUNTIME/vimrc_example.vim
if filereadable($HOME . "/.vimpath")
source $HOME/.vimpath
endif
call pathogen#infect()
@liancheng
liancheng / new_bashrc.sh
Created August 15, 2012 03:29 — forked from josephwecker/new_bashrc.sh
Replace .bashrc, .bash_profile, .profile, etc. with something much more clean, consistent, and meaningful. Now a repo: https://github.com/josephwecker/bashrc_dispatch
#!/bin/bash
# License: Public Domain.
# Author: Joseph Wecker, 2012
#
# -- DEPRICATED --
# This gist is slow and is missing .bashrc_once
# Use the one in the repo instead! https://github.com/josephwecker/bashrc_dispatch
# (Thanks gioele)
#
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile?
@liancheng
liancheng / gist_tag.rb
Created August 15, 2012 12:46 — forked from BinaryMuse/gist_tag.rb
A Liquid tag for Jekyll sites that allows embedding Gists and showing code for non-JavaScript enabled browsers and readers.
require 'cgi'
require 'digest/md5'
require 'net/https'
require 'uri'
module Jekyll
class GistTag < Liquid::Tag
def initialize(tag_name, text, token)
super
@text = text
@liancheng
liancheng / numeric_limits.hpp
Created August 15, 2012 12:52
std::numeric_limits<mpz_class> specialization for GNU MP C++ API
#include <limits>
namespace std {
template<>
struct numeric_limits<mpz_class> {
public:
static const bool is_specialized = true;
static mpz_class min() throw() {
@liancheng
liancheng / sample.scm
Created January 11, 2013 07:58
Chibi Scheme libirary sample. Put sample.scm and sample.sld under the same directory, then run `chibi-scheme sample.scm`.
(import (sample))
(hello-world)
@liancheng
liancheng / gist:5720458
Created June 6, 2013 09:47
2013/06/10手写代码竞赛参考实现
Decode Ways
https://github.com/liancheng/leetcode/blob/master/solutions/decode-ways/dp.hpp
Partition List
https://github.com/liancheng/leetcode/blob/master/solutions/partition-list/solution.hpp
Flatten Binary Tree to Linked List
https://github.com/liancheng/leetcode/blob/master/solutions/flatten-binary-tree-to-linked-list/solution.hpp
Binary Tree Inorder Traversal
string reverseSentence (string const& s)
{
string t (s.rbegin (), s.rend ());
for (auto p = begin (t), q = begin (t); p != end (t); ) {
p = find_if (p, end (t), [] (char c) { return c != ' '; });
q = find (p, end (t), ' ');
reverse (p, q);
p = q;
}
import scala.actors._
import Actor._
def sleepSort(xs : List[Int]) : List[Int] = {
def sorter(aggregator : Actor, n : Int) = actor {
reactWithin(n * 1000) {
case TIMEOUT => {
aggregator ! n
exit
}
#!/bin/bash
mkdir -p data
for i in `seq $1`; do
file=data/$i
for j in `seq $2`; do
echo ${RANDOM} >> $file
done