Skip to content

Instantly share code, notes, and snippets.

@venj
venj / delicious2google.rb
Created December 17, 2010 12:23 — forked from toluju/delicious2google.rb
Add a bookmark count for user to check with delicious. Add some line breaks for the out put file to avoid text editor crash if opened by the curious users with a lot of book marks.
require 'net/http'
require 'uri'
require 'cgi'
text = "<html><head><title>Delicious2Google</title></head><body>" +
"<h1>Upload</h1>" +
"<form action='https://www.google.com/bookmarks/mark?op=upload&zx=#{rand(65535)}' method='POST'>" +
"<input type='submit'/><input type='hidden' id='data'></form>" +
"<textarea id='xml' style='display:none'>\n<bookmarks>\n"
@venj
venj / batch_down_pics.rb
Created January 8, 2011 01:08
Download pics.
#! /usr/bin/env ruby
# Usage:
# 1. install ruby and wget if you don't have
# 2. gem install nokogiri
# 3. mkdir pics, put this script into it
# 4. ruby batch_down_pics.rb
# (or chmod +x batch_down_pics.rb && ./batch_down_pics.rb)
#
# WARN: 18+ content!
@venj
venj / hhc2xml.rb
Created January 23, 2011 02:40
Working in progress script used to create ePub xml files from CHM hhc file.
#!/usr/bin/env ruby
$KCODE = 'UTF8'
require 'rubygems'
require 'hpricot'
require 'fileutils'
require 'builder'
=begin
def print_tree(ul, level)
ul.search("/li").each do |li|
@venj
venj / toxhmlutf.rb
Created January 25, 2011 01:45
helper script to convert html to utf-8 xhtml
require 'fileutils'
exit if ARGV[0].nil?
FileUtils.cd ARGV[0] do |variable|
# html 2 xhtml
FileUtils.cd "OEBPS" do
Dir["*.html"].each do |file|
system("tidy -asxhtml --output-encoding utf8 --indent 1 --escape-cdata 1 --drop-proprietary-attributes 1 --drop-font-tags 1 #{file} > #{file}.xml 2> /dev/null")
@venj
venj / fix_js.user.js
Created March 20, 2011 15:12
Fully fixed the error in non-IE browsers to enable torrent download. You know how to install greasemonkey scripts. ;)
// ==UserScript==
// @name Fix download
// @namespace http://venj.me/greasemonkey/
// @description Fix an error in non-IE browsers.
// @include http://www.downloadindex.info/Get.asp?Id=*
function secBoard2(n) {
return function () {
var mainTable = document.getElementById("mainTable");
var secTable = document.getElementById("secTable");
for(i=0;i<secTable.tBodies[0].rows[0].cells.length;i++)
#!/usr/bin/env ruby
# encoding=utf-8
#
# Usage: ruby down_manga.rb folder_to_hold_manga image_index_url
# folder_to_hold_manga is a non-existing folder in current directory to save images.
# image_index_url is the index for manga, like: http://manhua.178.com/wangxiangxueshenghui/
#
# Need ruby 1.9 and hpricot gem.
#
@venj
venj / error install google go
Created March 29, 2011 02:14
error install google go
venj@iMacBook ~ » brew update
From http://github.com/mxcl/homebrew
* branch master -> FETCH_HEAD
Already up-to-date.
venj@iMacBook ~ » brew install -v go
/usr/local/bin/hg
==> Cloning http://go.googlecode.com/hg/
Updating /Users/venj/Library/Caches/Homebrew/go--hg
hg pull
pulling from http://go.googlecode.com/hg/
@venj
venj / clean_url_files.rb
Created April 27, 2011 02:04
Clean up .url files in downloads
#!/usr/bin/env ruby
# Usage: clean_url_files.rb path_to_clean
require 'fileutils'
exit if (ARGV[0].nil? || File.exists?(ARGV[0]))
FileUtils.cd(ARGV[0]) do
files = Dir["**/*"]
files.each do |file|
@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,
@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 "英国"