Skip to content

Instantly share code, notes, and snippets.

@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]
@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 / 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);
#!/usr/bin/env ruby
require 'ubygems'
require 'grope'
require 'RMagick'
class Grope::WSOWrapper
def undefined?
@wso.class.to_s == 'OSX::WebUndefined'
end
end
#!/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
@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
christmas:~ ucnv$ sudo gem install mac-robot
WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.
To proceed, enter your password, or type Ctrl-C to abort.
Password:
Fetching: mac-robot-0.2.1.gem (100%)
<a href="https://youpy.jottit.com/%E5%8A%A0%E7%80%AC%E4%BA%AE">加瀬亮</a>
@ucnv
ucnv / generate.rb
Last active December 14, 2015 18:09
scripts for Jpegs In Your Brain
require 'json'
require 'fileutils'
require 'erb'
require 'rmagick'
require 'open-uri'
require 'openssl'
require 'base64'
require './jpg_encoder' # https://gist.github.com/ucnv/708485
class XJPG < JPGEncoder
@ucnv
ucnv / png.rb
Created March 10, 2013 08:20
Glitch PNG with ChunkyPNG
require 'zlib'
require 'chunky_png'
p = ChunkyPNG::Datastream.from_file(ARGV.first)
a = p.data_chunks.inject('') { |b, c| b + c.content }
d = Zlib::Inflate.new().inflate(a)
d.gsub!(/0/, '1')
e = Zlib::Deflate.deflate(d)
p.data_chunks = [ChunkyPNG::Chunk::ImageData.new('IDAT', e)]
p.save('./out.png')