This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun conj (v &rest c) | |
(append v c)) | |
(defun r (exp) | |
(do ((e (cons nil (string-to-list exp)) | |
(let ((s (car e)) (x (cdr e)) | |
(a (cadr e)) (d (caddr e))) | |
(cond | |
((= a ?%) | |
(cons (apply (apply-partially #'conj s) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import rlcompleter | |
import readline | |
import atexit | |
import os | |
# http://stackoverflow.com/questions/7116038/python-tab-completion-mac-osx-10-7-lion | |
if 'libedit' in readline.__doc__: | |
readline.parse_and_bind('bind ^I rl_complete') | |
else: | |
readline.parse_and_bind('tab: complete') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 球面坐标系统 | |
var Spherical = function(radial, polar, azimuthal) { | |
var self = this; | |
self.radial = radial || 1 | |
self.polar = polar || 0 | |
self.azimuthal = azimuthal || 0 | |
}; | |
// 转换成直角坐标系统 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <iostream> | |
#include <cstdlib> | |
using namespace std; | |
int main(void) { | |
char s[4]; | |
while (cin >> s) { | |
sort(s, s + 3); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# -*- coding: utf-8 -*- | |
require 'cgi' | |
module Html | |
def self.tag(content) | |
n, a = content.split /\s+/, 2 | |
{:tag => n}.update(attr: Hash[(a or '').scan(/(\w+)="([^"]*)"/)]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_record' | |
ActiveRecord::Base.logger = Logger.new(STDERR) | |
ActiveRecord::Base.colorize_logging = false | |
ActiveRecord::Base.establish_connection( | |
:adapter => "sqlite3", | |
:database => ":memory:" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# minimize reset tag level, so that user can override them | |
styles = {} | |
Object.class_eval do | |
define_method :style do |tag, properties| | |
styles[tag] ||= {} | |
styles[tag].merge!(properties) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require "fileutils" | |
require "erubis" | |
require "yaml" | |
def erm(source) | |
content, data = "", {} | |
loop do | |
properties, fragment = File.read(source).split("---\n", 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var File = function(name) { | |
this.file = new java.io.File(name); | |
}; | |
File.prototype.map = function(fn) { | |
var fin = new java.util.Scanner(this.file); | |
var content = []; | |
while (fin.hasNextLine()) { | |
content.push(fn(fin.nextLine())); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun current-sentence () | |
(interactive) | |
(replace-regexp-in-string "\n" ";" | |
(substring-no-properties | |
(or (sentence-at-point) | |
(save-excursion | |
(backward-sentence) | |
(sentence-at-point)))))) | |
(defun commit-last-js () |