Skip to content

Instantly share code, notes, and snippets.

@venj
venj / rename.rb
Created August 16, 2011 13:48
Extract and Rename rar files downloaded from Wow Ebooks
#!/usr/bin/env ruby
require "fileutils"
include FileUtils
#
# Now you can fire up the command like this:
# ./rename.rb New.Riders.Flexible.Web.Design.Dec.2008.rar Flexible Web Design
#
# if there's any special characters in the REAL file name,
# escape them to prevent the shell to parse it.
@venj
venj / AppDelegate.m
Created August 15, 2011 04:58
One line Fanfou Mac client
#import "Fanfou_For_MacAppDelegate.h"
#import <Webkit/WebKit.h>
@implementation Fanfou_For_MacAppDelegate
@synthesize window;
@synthesize webView;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
@venj
venj / gen_db.rb
Created July 4, 2011 03:07
gen database file for hsk app
#!/usr/bin/env ruby
require "sqlite3"
dbfile = "data.sqlite3"
File.unlink dbfile if File.exists? dbfile
db = SQLite3::Database.new dbfile
db.execute("create table `entries` (id integer primary key autoincrement, question string, choice1 string, choice2 string, answer string);")
infile = open "dd.txt", 'r'
@venj
venj / down_wwdc_keynote.rb
Created June 7, 2011 15:02
Download WWDC '11 Keynote to your hard disk
#!/usr/bin/env ruby
require 'open-uri'
if ["--help", "help", "-h"].include?(ARGV[0]) || ARGV.size < 1
puts "Usage: #{File.basename __FILE__} ( 720p | 540p | 540i | 360p | 360i | 360is | 224p )"
exit 0
end
size_hash = {"720p" => "4540", "540p" => "2540", "540i" => "1840", "360p" => "1240", "360i" => "0640", "360is" => "0440", "224p" => "0240"}
video_size = size_hash[ARGV[0]]
@venj
venj / my.sh
Created May 22, 2011 09:26
my personal system management scripts system. This is the main script. All the command scripts are located in /usr/local/bin/myscripts .
#!/bin/sh
myscript_dir=/usr/local/bin/myscripts
if [ $# -lt 1 ]; then
echo "Usage: $(basename $0) command_name [options]"
echo "Help: "
echo "\t list (l) -- show all available commands"
echo "\t - ll -- show all available commands, long format"
echo "\t - la -- show all available commands, full format"
@venj
venj / brewcleanup.sh
Created May 22, 2011 09:24
clean up brew old packages. There will be some warnings and errors, just ignore them.
#!/bin/bash
for pack_name in $(ls $(brew --prefix)/Cellar);do
brew cleanup $pack_name 2> /dev/null
done
#!/bin/sh
# Change this line to the URI path of the xcode DMG file.
# XCode 3.2.5
#XCODE_PATH="/ios/ios_sdk_4.2__final/xcode_3.2.5_and_ios_sdk_4.2_final.dmg"
# XCode 4
#XCODE_PATH="/Developer_Tools/xcode_4_and_ios_sdk_4.3__final/xcode_4_and_ios_sdk_4.3__final.dmg"
@venj
venj / logroll.sh
Created May 21, 2011 00:57
A simple logroll for my vps
# Add this script to root's cron
# Do it every sunday.
# 0 0 * * 0 /path/to/logroll.sh
function roll_log {
if [ $(ls -s $1 | cut -d' ' -f1) -gt '10240' ]; then
ts=$(date +%s)
mv $1 ${1}.$ts
if [ $? -ne 0 ];then
exit 1
fi
@venj
venj / datlun.zh.po
Created April 30, 2011 05:01
Chinese Translation for Virtual Moon Atlas v5 【Virtual Moon Atlas 5的中文翻译】
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
#: u_translation.rsedit
msgid "Edit"
msgstr "编辑"
#: u_translation.rshelp_prefix
msgid "UK"
msgstr "英国"
@venj
venj / google-chrome-config
Created April 30, 2011 00:45 — forked from mcxiaoke/google-chrome-config
google-chrome-config
#:~/.config/google-chrome/Default/Preferences
# 或 ~/.config/Chromium/Default/Preferences
#在此文件中修改最后一段如下:
"webkit": {
"webprefs": {
"default_fixed_font_size": 16,
"default_font_size": 16,
"fixed_font_family": "DejaVu Sans Mono",
"minimum_font_size": 12,