Skip to content

Instantly share code, notes, and snippets.

@cxx
cxx / fix-ttf-weight.rb
Created February 23, 2014 07:43
フォントのweight値を書き換える
#!/usr/bin/env ruby
fail unless ARGV.length == 2
file = ARGV[0]
weight = ARGV[1].to_i
open(file, "r+b:ASCII-8BIT") do |io|
ver, ntables, srange, eselector, rshift = io.read(12).unpack("Nn*")
fail unless Math.log2(ntables).floor == eselector and
(2**eselector)*16 == srange and
#!/usr/bin/env ruby
require 'open-uri'
require 'RMagick'
include Magick
palette = Hash[ *(
[ ["000000", "\u{2660}" ], ["157569", "\u{1f5fd}"], ["226699", "\u{1f17f}"],
["231f20", "\u{2b1b}" ], ["292f33", "\u{1f3b1}"], ["3b88c3", "\u{2139}" ],
["4288c1", "\u{1f53d}"], ["553986", "\u{1f47e}"], ["55acee", "\u{1f6b9}"],
["58595b", "\u{1f3a5}"], ["5c913b", "\u{264a}" ], ["5dadec", "\u{1f499}"],
@cxx
cxx / 3moji.rb
Created May 19, 2014 12:57
SUPER IMPORTANT 3文字
#!/usr/bin/env ruby
require 'optparse'
fg = "\u{2b1c}"
bg = "\u{2139}"
opt = OptionParser.new
opt.on("-f CHAR") {|v| fg = v[0] }
opt.on("-b CHAR") {|v| bg = v[0] }
opt.parse!(ARGV)
@cxx
cxx / mangaz-bookshelf.user.js
Created August 9, 2015 02:36
マンガ図書館Zのサムネイルから本棚に登録
// ==UserScript==
// @name サムネイルから本棚に登録
// @namespace http://twitter.com/cxx
// @include http://www.mangaz.com/*
// @include http://r18.mangaz.com/*
// @version 0.1.0
// ==/UserScript==
"use strict";
@cxx
cxx / list_all_published_photos_on_tumblr.rb
Created May 9, 2009 18:23
privatize all published photos on Tumblr
#!/usr/bin/ruby
require 'open-uri'
require 'rexml/document'
user = ''
total = open("http://#{user}.tumblr.com/api/read?type=photo&num=0") do |f|
doc = REXML::Document.new(f)
REXML::XPath.first(doc, '//posts/@total').value.to_i
end
#include <iostream>
#include <algorithm>
#include <boost/lexical_cast.hpp>
int main(int argc, char* argv[])
{
int post_id = boost::lexical_cast<int>(argv[1]);
std::string s;
char path_chars[] = "0123456789abcdefghijklmnopqrstuvwxyz";
// ==UserScript==
// @name lang ja
// @namespace http://twitter.com/cxx
// @include http://twitter.com/*
// @include http://www.tumblr.com/*
// @include http://favstar.fm/*
// ==/UserScript==
document.body.lang = 'ja';
@cxx
cxx / pp-xml.rb
Created April 18, 2010 11:59
pretty print a xml
require 'rexml/document'
REXML::Document.new($stdin).write($stdout, 2)
// ==UserScript==
// @name Twittfilter for hitode909-RT
// @namespace http://d.hatena.ne.jp/send/
// @description twitter filter
// @include http://twitter.com/*
// ==/UserScript==
//
(function (){
var filter = function(node) {