Skip to content

Instantly share code, notes, and snippets.

@ucnv
ucnv / mkpw.rb
Last active September 26, 2015 15:47
#!/usr/bin/env ruby
# make a human readable word-number-word style password.
# following wordlist is taken from http://web.archive.org/web/20091003023412/http://tothink.com/mnemonic/wordlist.txt
l = %w(
acrobat africa alaska albert albino album
alcohol alex alpha amadeus amanda amazon
america analog animal antenna antonio apollo
april aroma artist aspirin athlete atlas
banana bandit banjo bikini bingo bonus
camera canada carbon casino catalog cinema
#!/usr/bin/env ruby
# Redirect to the url in the server's clipboard
if defined? Rack then
Redirector = Rack::Builder.new {
use Rack::ContentLength
app = Proc.new { |env|
u = IO.popen('pbpaste', 'r+').read
[303, {'Location' => u, 'Content-Type' => 'text/plain'}, ['']]
}
run app
#!/usr/bin/env ruby
require 'ubygems'
require 'grope'
require 'RMagick'
class Grope::WSOWrapper
def undefined?
@wso.class.to_s == 'OSX::WebUndefined'
end
end
@ucnv
ucnv / tweet-shindanmaker.js
Created May 22, 2011 10:32
phantomjs script to tweet through shindanmaker.com
var tweet;
var twitter_id = "";
var twitter_pw = "";
var phase;
var setState = function(nextPhase) {
var s = {tweet: tweet, twitter_id: twitter_id, twitter_pw: twitter_pw, phase: nextPhase};
phantom.state = JSON.stringify(s);
};
if(!phantom.state.length) {
var i, args = Array.prototype.slice.apply(phantom.args);
@ucnv
ucnv / c.rb
Created May 14, 2011 19:52
makes glitch beats using AviGlitch (2)
require 'aviglitch'
unless ARGV.size >= 2
puts "Usage: ruby #{$0} INFILE PATTERN [FPS]"
puts " ruby #{$0} file.mp3 0010001000010011"
exit
end
infile, pattern, fps = ARGV
fps = 60 unless fps
cmd = "ffmpeg -i %s -sameq -r %d -vn tmp1.avi" % [infile, fps]
@ucnv
ucnv / b.rb
Created May 9, 2011 21:53
makes glitch beats using AviGlitch
require 'aviglitch'
unless ARGV.size >= 2
puts "Usage: ruby #{$0} INFILE PATTERN [FPS]"
puts " ruby #{$0} file.mp3 0010001000010011"
exit
end
infile, pattern, fps = ARGV
fps = 60 unless fps
cmd = "ffmpeg -i %s -sameq -r %d -vn tmp1.avi" % [infile, fps]
// ==UserScript==
// @name Tokyo Kafun on Twitter
// @namespace http://userscripts.org/users/40991
// @include http://twitter.com/*
// ==/UserScript==
function i(d) {
var n = d ? new Date(d) : new Date();
var y = n.getFullYear().toString();
var m = ('0' + (n.getMonth()+1)).match(/\d{2}$/)[0];
require 'aviglitch'
a = AviGlitch.open ARGV.shift
keys = []
a.frames.each_with_index do |f, i|
keys << i if f.is_keyframe?
end
keys.each do |i|
fa = a.frames[i]
fb = a.frames[i+1]
require './jpg_encoder' # https://gist.github.com/708485
class XJPG < JPGEncoder
def process_DU *args
@zigzag_o = @zigzag_o || @zigzag
@zigzag = @zigzag_o.shuffle
super *args
end
end
# This file is a kind of Ruby port of JPGEncoder.as
# <https://github.com/mikechambers/as3corelib/blob/master/src/com/adobe/images/JPGEncoder.as>
# Copyright (c) 2008, Adobe Systems Incorporated
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#