Skip to content

Instantly share code, notes, and snippets.

View eclipselu's full-sized avatar
🏠
Working from home

Lu Dang eclipselu

🏠
Working from home
  • Kitchener, Ontario
View GitHub Profile
@eclipselu
eclipselu / subsequence.cpp
Created September 9, 2016 02:40
Is Subsequence
class Solution {
public:
bool isSubsequence(string s, string t) {
queue<char> q;
for (char ch: s)
q.push(ch);
for (char ch: t) {
if (q.empty())
break;
#!/usr/bin/env python
# encoding: utf-8
class Node(object):
val = None
left = None
right = None
parent = None
@eclipselu
eclipselu / requirements.txt
Last active August 30, 2015 10:18 — forked from mrluanma/requirements.txt
Python 登录新浪微博(requests 真的比 urllib2 强了 2^^32 倍 pip install requests)
requests==2.4.3
rsa==3.1.4
@eclipselu
eclipselu / rails_resources.md
Created June 18, 2014 09:53 — forked from jookyboi/rails_resources.md
Rails-related Gems and guides to accelerate your web project.

Gems

  • Bundler - Bundler maintains a consistent environment for ruby applications. It tracks an application's code and the rubygems it needs to run, so that an application will always have the exact gems (and versions) that it needs to run.
  • rabl - General ruby templating with json, bson, xml, plist and msgpack support
  • Thin - Very fast and lightweight Ruby web server
  • Unicorn - Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels.
  • SimpleCov - SimpleCov is a code coverage analysis tool for Ruby 1.9.
  • Zeus - Zeus preloads your Rails app so that your normal development tasks such as console, server, generate, and specs/tests take less than one second.
  • [factory_girl](h
@eclipselu
eclipselu / 0_reuse_code.js
Created June 18, 2014 09:53
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@eclipselu
eclipselu / gfm.rb
Created December 21, 2013 13:27 — forked from peterhellberg/gfm.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'redcarpet'
require 'pygments.rb'
class HTMLwithPygments < Redcarpet::Render::HTML
def block_code(code, language)
Pygments.highlight(code, :lexer => language.to_sym, :options => {
:encoding => 'utf-8'
})
class Solution {
public:
int singleNumber(int A[], int n) {
int bits[32] = { 0 };
int res = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < 32; j++) {
if ((A[i] >> j) & 1)
bits[j] = (bits[j] + 1) % 3;
# set up flags for Numpy C extentions compiling
export CFLAGS="-arch i386 -arch x86_64"
export FFLAGS="-m32 -m64"
export LDFLAGS="-Wall -undefined dynamic_lookup -bundle -arch i386 -arch x86_64"
export CC=gcc-4.2
export CXX="g++ -arch i386 -arch x86_64"
pip install numpy
# success!
class Solution {
public:
int canCompleteCircuit(vector<int> &gas, vector<int> &cost) {
// IMPORTANT: Please reset any member data you declared, as
// the same Solution instance will be reused for each test case.
int len = gas.size();
vector<int> accum;
for (int i = 0; i < len; i++)
accum.push_back(gas[i] - cost[i]);
class Solution {
public:
bool isInterleave(string s1, string s2, string s3) {
// IMPORTANT: Please reset any member data you declared, as
// the same Solution instance will be reused for each test case.
int len1 = s1.length(), len2 = s2.length(), len3 = s3.length();
if (len1 + len2 != len3)
return false;
vector<vector<bool> > match(len1 + 1, vector<bool>(len2 + 1, false));
match[0][0] = true;