Skip to content

Instantly share code, notes, and snippets.

@cyfdecyf
cyfdecyf / join-chinese.rb
Created December 18, 2011 09:12
Join consecutive Chinese lines into a single long line.
#!/usr/bin/env ruby
#encoding: UTF-8
# Requires ruby 1.9.x, and assumes UTF-8 encoding
class String
# The regular expression trick to match CJK characters comes from
# http://stackoverflow.com/a/4681577/306935
# For more info on the regex used here, refer to http://oniguruma.rubyforge.org/svn/Syntax.txt
# And for Unicode Character Categories http://www.fileformat.info/info/unicode/category/index.htm
diff --git a/lixian.py b/lixian.py
index 05331e4..7139f51 100644
--- a/lixian.py
+++ b/lixian.py
@@ -37,7 +37,7 @@ class XunleiClient:
def urlopen(self, url, **args):
#print url
if 'data' in args and type(args['data']) == dict:
- args['data'] = urllib.urlencode(args['data'])
+ args['data'] = urllib.urlencode(dict([k, unicode(v).encode('utf-8')] for k, v in args['data'].items()))
@artero
artero / launch_sublime_from_terminal.markdown
Last active September 12, 2024 02:13 — forked from olivierlacan/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@vitobotta
vitobotta / Importing posts from Wordpress into Jekyll.rb
Created March 26, 2011 22:50
The script I used to import posts from my Wordpress blog into a new Jekyll one.
%w(rubygems sequel fileutils yaml active_support/inflector).each{|g| require g}
require File.join(File.dirname(__FILE__), "downmark_it")
module WordPress
def self.import(database, user, password, table_prefix = "wp", host = 'localhost')
db = Sequel.mysql(database, :user => user, :password => password, :host => host, :encoding => 'utf8')
%w(_posts _drafts images/posts/featured).each{|folder| FileUtils.mkdir_p folder}
@mig
mig / init.el
Created January 18, 2011 21:00
Simple Emacs 24 configuration for Rails development
;; emacs configuration
(push "/usr/local/bin" exec-path)
(add-to-list 'load-path "~/.emacs.d")
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)
(setq inhibit-startup-message t)