Skip to content

Instantly share code, notes, and snippets.

View v2e4lisp's full-sized avatar

Yan Wenjun v2e4lisp

View GitHub Profile
@v2e4lisp
v2e4lisp / README.md
Created December 24, 2013 07:37 — forked from mattsears/README.md

Todo.rb

Todo.rb is a simple command-line tool for managing todos. It's minimal, straightforward, and you can use it with your favorite text editor.

Getting Started

Todo.rb doesn't require any third-party gems so you can copy the file anywhere and use it as long as it's executable:

<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
def water(bars):
# get the volume of water between two peaks.
def volume_between_peaks(i, j):
# first make all the bars between the two peaks lower than the lower peak.
if bars[i] > bars[j]:
while bars[i] > bars[j]:
i += 1
i -= 1
else:
while bars[i] <= bars[j]:
@v2e4lisp
v2e4lisp / calc.py
Created October 26, 2013 17:21 — forked from Zirak/calc.py
#this program uses the Shunting Yard algorithm to transform infix expressions
# into postfix, and then an AST, which can then be easily evaluated.
#just run `python calc.py` and enjoy. enjoyment is optional and not included
# with the standard calc.py package, but for an extra $99.99 we can have a
# calc.py Premium Deluxe sent to you over the next 6-8 weeks, which may or may
# not increase your enjoyment of our calc.py product.
#for a list of operators supported and not supported (for isntance, the unary -
# is a ~) look below.
#TODO: handle parentheses.

How to upload a pip package?

  • setup.py, requirements.txt, MANIFEST.in

  • first register you package

python setup.py register
  • build dist & upload your package.
@v2e4lisp
v2e4lisp / php-init.el
Created October 22, 2013 04:18
php-mode setup.
(defun unindent-closure ()
(let ((syntax (mapcar 'car c-syntactic-context)))
(if (and (member 'arglist-cont-nonempty syntax)
(or
(member 'statement-block-intro syntax)
(member 'brace-list-intro syntax)
(member 'brace-list-close syntax)
(member 'block-close syntax)))
(save-excursion
(beginning-of-line)
(defun map-local-key-to-insert-text (&rest key-text-list)
(dolist (key-text key-text-list)
(let ((key (car key-text))
(text (car (cdr key-text))))
(local-set-key (kbd key)
`(lambda ()
(interactive)
(insert ,text))))))
(defun mou ()
require 'sinatra'
# require 'kramdown'
def files(regex, dir=".")
Dir.chdir(dir) do
ret = Dir[regex].inject([]) {|acc, f| acc << f}
Dir["*/"].inject(ret) {|acc, f| acc << {f => files(regex, f)}}
end
end
def files(regex, dir=".")
Dir.chdir(dir) do
ret = Dir[regex].inject([]) {|acc, f| acc << f}
Dir["*/"].inject(ret) {|acc, f| acc << {f => files(regex, f)}}
end
end
puts files("*.py", Dir.home + "/_.py")
@v2e4lisp
v2e4lisp / rails.rb
Created September 20, 2013 15:32 — forked from simi/rails.rb
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
require 'rubygems'
require 'rails/commands/server'
require 'rack'
require 'webrick'
require 'webrick/https'
module Rails