Skip to content

Instantly share code, notes, and snippets.

View ldong's full-sized avatar
❤️
Love & Peace

Alan Dong ldong

❤️
Love & Peace
  • Sunnyvale, CA
View GitHub Profile
import random
import sys
def print_grid(grid):
print ("\n%s\n" % "+".join([('-' * 4)] * 4)).join(
["|".join(["%4d" % item if item > 0 else " " * 4 for item in line]) for line in grid])
def get_available_cells(grid):
@selfboot
selfboot / trie_tree.py
Last active August 29, 2015 14:04
简单字典树的实现。
#! /usr/bin/env python
# -*- coding: utf-8 -*-
class Trie_tree():
def __init__(self):
# node = [father, child, keep_char, is_word]
self._root = [None, [], None, False]
def insert(self, word):
@cslarsen
cslarsen / palindrome.cpp
Created March 2, 2011 13:17
Find longest palindrome in text
/*
* Find the longest palindrome in the text.
*
* This is Greplin's first challenge, and I originally solved it in Python.
*
* The algorithm is not optimal, but simple on the eyes and easy to understand
* On big inputs it's possible to use an approximately linear algorithm.
*
* Christian Stigen Larsen
*/
@ashleybot
ashleybot / d3basics1.js
Created February 16, 2012 05:51
D3.js Basic Vertical Bar Chart
// simple array
var data = [8, 12, 15, 30, 43];
@trek
trek / unit.js
Created July 22, 2012 02:40
Run your mocha unit tests suite via casper.js
// get a Casper object.
// See http://casperjs.org/
var casper = require('casper').create();
// this will be evaluated inside the context of the window.
// See http://casperjs.org/api.html#casper.evaluate for notes on
// the difference between casper's running environment and the
// DOM environment of the loaded page.
function testReporter(){
// casper is webkit, so we have good DOM methods. You're
@danielabar
danielabar / vagrant.txt
Last active October 23, 2015 00:18
Course notes and commands from TutsPlus: Virtual Machines with Vagrant and Puppet
# https://tutsplus.com/course/virtual-machines-with-vagrant-and-puppet/
# Download and install VirtualBox https://www.virtualbox.org/wiki/Downloads
# Download and install Vagrant http://www.vagrantup.com/downloads.html
# For this lesson, we'll be using VirtualBox as the provider
# add a new box to collection of vagrant boxes
# vagrant box add <name> <location>
vagrant box add precise32 http://files.vagrantup.com/precise32.box
@ttscoff
ttscoff / CustomReaderGithub.css
Created June 17, 2012 11:49
Github style for the CustomReader Safari Extension
/* For use with the CustomReader Safari Extension */
/* <http://canisbos.com/customreader> */
body
{
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-box-align: center;
background: url("linen.png");
color: black;
@netwjx
netwjx / a.js
Last active December 16, 2015 12:19
sed多行内容替换
// many many codes
document.write('foo bar');
document.write('</div>');
// new code
var a = 'bar.js', stamp = +new Date() + '=';
document.write('<script id="foo" src="' + a + '?' + stamp + '"></script>');
// other code
document.write('<div> other text</div>');
@jiffyclub
jiffyclub / ToyChest.itermcolors
Last active December 16, 2015 20:59
iTerm2 color theme inspired by Toy Chest (http://toychesttheme.com/) and Flat UI (http://designmodo.github.io/Flat-UI/).
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.31372550129890442</real>
<key>Green Component</key>
<real>0.24313725531101227</real>
@wynemo
wynemo / sphinx_document.md
Last active December 22, 2015 00:09
using sphinx to generate documents

install sphinx

$ pip install sphinx

use this python script to create a sphinx project

from sphinx import quickstart as qs

d = dict(

path = '.',