Skip to content

Instantly share code, notes, and snippets.

@youpy
youpy / 256_cat.rb
Created June 7, 2012 02:09
convert text into 256 colors
# ref.
# http://www.frexx.de/xterm-256-notes/
$stdin.sync = true
filename = ARGV.shift
open(filename || '/dev/stdin') do |f|
f.each do |line|
line.unpack('U*') do |c|
print "\033[38;5;%im" % c
require 'scissor'
def main
max = 16
max.times.inject([[random_sequence], Scissor()]) do |memo, i|
# workaround to avoid ecasound bug which occurs when the number of tracks is 3 or 10 (or more)
tracks = memo[0] + (max - (memo[0].size - 1)).times.map { Scissor.silence(1) }
memo[1] += (mix(tracks, 'tracks_%i.wav' % i) * 8)
memo[0] += [random_sequence]
require 'scissor'
def main
16.times.inject([[random_sequence], Scissor()]) do |memo, i|
memo[1] += (mix(memo[0], 'tracks_%i.wav' % i) * 8)
memo[0] << random_sequence
memo
end[1] >> 'result.wav'
end
@youpy
youpy / beats.rb
Created June 4, 2012 01:46
Scissor.sequence example
require 'scissor'
# original
# http://beatsdrummachine.com/
def main
@kits = {
:b => tape('house_2_1.wav'),
:s => tape('roland_tr_909_2.wav').pan(60),
:h => tape('house_2_5.wav') .pan(20),
require 'eventmachine-distributed-notification'
require 'ruby_gntp'
require 'json'
# EM.post_distributed_notification('growl_notify', msg)
EM.run {
EM.watch_distributed_notification('growl_notify') {|c|
(class << c; self; end).send(:define_method, :notify) {|name, info|
msg = info['data']
#!/usr/bin/env ruby
$stdin.each do |line|
print "\a"
$stdout.write line
end
#!/usr/bin/env macruby
framework 'AppKit'
require 'tempfile'
require 'shellwords'
class WindowController < NSWindowController
def awakeFromNib
@timer = NSTimer.scheduledTimerWithTimeInterval(0.1, target:self, selector:'onTimer', userInfo:nil, repeats:true)
;; Google Suggest で補完
(defun google-suggest ()
(setq ac-source-mysource1-point ac-point)
(let (result buf (case-fold-search nil))
(setq buf (get-buffer-create "*google-suggest*"))
(if (string-match "^[A-Z]" ac-prefix)
(with-current-buffer buf
(erase-buffer)
;; https://gist.github.com/2425165
(call-process "/Users/youpy/work/google_suggest.rb" nil buf nil ac-prefix)
# encoding: utf-8
require 'json'
require 'open-uri'
require 'nkf'
require 'cgi'
url_pattern = 'http://clients1.google.co.jp/complete/search?client=hp&hl=ja&q=%s'
content = NKF.nkf('-w', open(url_pattern % CGI.escape(ARGV.shift)).read)
content.sub!(/^[^\(]+\((.+)\)$/, '\1')
require 'ubygems'
require 'grope'
id, user = ARGV
env = Grope::Env.new
env.load('http://shindanmaker.com/%s' % id)
env.find('//input[@class="shindanuser"]').value = user
env.document.getElementById('form').submit
env.document.title