Skip to content

Instantly share code, notes, and snippets.

Avatar

Zellux Wang zellux

View GitHub Profile
@zellux
zellux / extract.rb
Created Jul 31, 2013
Extract words and explanations from epub version of Merriam Webster's Vocabulary Builder. See http://blog.yxwang.me/notes/languages/vocabulary-builder.html for more details.
View extract.rb
require 'nokogiri'
unit = ARGV[0].to_i
started = false
titles = []
1.upto(3000) do |i|
filename = "html/Merriam-Webster_s_Vocabulary_Bu_split_#{'%03d' % i}.html"
doc = Nokogiri::HTML(open(filename))
title = doc.css('div span.bold').first
next if title == nil
@zellux
zellux / zhihu.recipe
Last active Aug 9, 2019
知乎日报 Kindle 版生成工具,可用于 Calibre
View zhihu.recipe
#!/usr/bin/env python
__copyright__ = 'Yuanxuan Wang <zellux at gmail dot com>'
from calibre.web.feeds.news import BasicNewsRecipe
from calibre.ebooks.BeautifulSoup import Tag, NavigableString
from collections import OrderedDict
from contextlib import nested, closing
import json
@zellux
zellux / migrate.rb
Created Nov 29, 2011
Migrate from wordpress to octopress
View migrate.rb
# coding: utf-8
require 'rubygems'
require 'hpricot'
require 'fileutils'
require 'time'
require 'ya2yaml'
require File.join(File.dirname(__FILE__), "downmark_it")
require 'nokogiri'
require 'cgi'
@zellux
zellux / laplacian-smoothing.rb
Created Oct 29, 2011
Probability calculator
View laplacian-smoothing.rb
require 'set'
k = 1.0
list1 = %w(a perfect world my perfect woman pretty woman)
list2 = %w(a perfect day electric storm another rainy day)
ncases1 = 3
ncases2 = 3
list1name = 'movie'
list2name = 'song'
@zellux
zellux / crop.rb
Created Oct 3, 2011
chncode book downloader
View crop.rb
require 'thread'
require 'logger'
require 'fileutils'
dir_name = ARGV[0] || '707-kindle'
NTHREADS = 4
$logger = Logger.new STDERR
puts "Resizing all images..."
@zellux
zellux / client.c
Created Jul 1, 2011
UDP file transfer
View client.c
#include <string.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <fcntl.h>
#define SERV_PORT 49312
#define MAXLINE 1024
char *END_FLAG = "================END";
@zellux
zellux / gist:867949
Created Mar 13, 2011
Katamari Hack
View gist:867949
javascript:var i,s,ss=['http://kathack.com/js/kh.js','http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js'];for(i=0;i!=ss.length;i++){s=document.createElement('script');s.src=ss[i];document.body.appendChild(s);}void(0);
You can’t perform that action at this time.