Skip to content

Instantly share code, notes, and snippets.

@whym
whym / tombloo-amazon20090816.js
Created August 23, 2009 01:18
Tombloo script. Workaround for amazon api changes
addAround(Tombloo.Service.extractors.Amazon, 'extract', function(proceed, args){
var ctx = args[0];
var self = Tombloo.Service.extractors.Amazon;
var asin = self.getAsin(ctx);
return succeed().addCallback(function(){
var creators = $x('//title/text()');
creators = creators.substr(0, creators.lastIndexOf(':'));
creators = creators.substr(creators.lastIndexOf(':') + 1).trim();
return {
@whym
whym / tombloo-googledocs.js
Created August 31, 2009 09:59
Post to Google Docs. Right-click on a link -> Choose Share - Link - Target -> Choose GoogleDocs
models.register({
name : 'GoogleDocs',
ICON : 'http://docs.google.com/favicon.ico',
check : function(ps){
return ps.type == 'link' && !ps.file;
},
getAuthCookie : function(){
return getCookieString('www.google.com', 'secid').split('=').pop();
},
// Chat upload
// format sample
// http://utatane.tumblr.com/post/118386131/private-chat-format-test
(function(){
Tombloo.Service.extractors.register([
{ // Chat extractor
name : 'Chat',
ICON : models.Twitter.ICON,
TARGET_BACKGROUND : '#888',
// ==UserScript==
// @name Google Search - Add direct links
// @namespace http://github.com/whym
// @include http://www.google.tld/search?*
// @version 0.01
// @description Add direct links in Google search result
// ==/UserScript==
// based on http://userscripts.org/scripts/show/57679 by blooo
#!python
# -*- encoding: utf-8 -*-
# DNS log converter from Microsoft DNS to namebench
# INPUT:
# 20091029 11:49:01 848 PACKET 02728D00 UDP Rcv 133.11.34.152 053d Q [0001 D NOERROR] A (6)images(8)slashdot(2)jp(0)
# OUTPUT:
# domain://images.slashdot.jp
@whym
whym / remaining_time.sh
Created December 2, 2009 02:56
calculate the difference between the given time in the argument and the current time
ruby -rtime -e'd=(Time.parse(ARGV.join(%q{ }))-Time.now).to_i; sign=d/d.abs<0?%q{-}:%q{}; d=d.abs; s,m,h=[60,60].map{|x| r=d%x; d=(d-r)/x; r}+[d]; puts sprintf %q!%s%d:%02d:%02d!, sign,h,m,s' # "2010-01-15T23:59 EST"
var now = new Date();
var last_nyd = new Date(now.getFullYear(), 0, 1);
var next_nyd = new Date(now.getFullYear() + 1, 0, 1);
var rate = (now - last_nyd) / (next_nyd - last_nyd);
var beginning_of_today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
var one_day = 1000 * 60 * 60 * 24;
var pdate = new Date(beginning_of_today.getTime() + rate * one_day);
var hours = pdate.getHours();
var ampm = hours > 12 ? "PM" : "AM";
hours = hours > 12 ? hours - 12 : hours;
@whym
whym / love_on_tumblr.user.js
Created February 28, 2010 04:44 — forked from taizooo/love_on_tumblr.user.js
Type "Shiflt + L" to Like/Unlike & Fav/Unfav on Tumblr Dashboard. Click the label "raw" below to install.
// ==UserScript==
// @name love on tumblr
// @namespace http://www.tumblr.com/
// @description love current post on tumblr dsbd with 'Shift + l'key. if won't work, pray on tumblr!
// @include http://www.tumblr.com/dashboard*
// @include http://www.tumblr.com/show/*
// @include http://www.tumblr.com/tagged/*
// @version 0.0.2
// ==/UserScript==
@whym
whym / twitter-screenname-check.rb
Created April 4, 2010 06:28
check the availability of twitter screen names
#! /usr/bin/env ruby
require 'rubygems'
require 'json'
require 'open-uri'
require 'optparse'
OPT = Struct.
new(:auto, :wait).
new(false, 0.3)
@whym
whym / java-sun-com.css
Created April 30, 2010 01:20
css for API docs on java.sun.com
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain(java.sun.com) {
body {
font-family: "Arial", sans-serif;
}
p, dd, table {
max-width: 55em;
}
p {