Skip to content

Instantly share code, notes, and snippets.

class Waver
def initialize(filename)
@filename = File.expand_path(filename)
@byte_order = []
@size = File.size @filename
open(@filename).each_byte{|ch|
@byte_order << ch
}
end
require 'open-uri'
Earthquake.init do
command :zalgo do |m|
tw = ""
txt = m[1]
open("http://zalgo-text.jgate.de/convert?q=#{URI.encode(txt)}&max=20") do |r|
tw = r.read
end
@nbqx
nbqx / app.rb
Created September 22, 2011 08:14
# -*- coding: utf-8 -*-
require 'sinatra'
module MyCustomRequestMethod
def hey(path,opts={},&blk)
route __method__.to_s.upcase,path,opts,&blk
end
end
module Sinatra
#target InDesign
Function.prototype.before = function(){
var fn = undefined;
var args = [];
for(var i=0; i<arguments.length; i++){
if(i!=arguments.length-1){
args.push(arguments[i]);
}else{
#target InDesign
//CS4でもCS5でもうごくぜ
DTP = this.DTP = {
text: "this is original"
}
alert(DTP.toSource());
delete DTP;
if(!this.hasOwnProperty("DTP")){
@nbqx
nbqx / gist:1290503
Created October 16, 2011 04:18
itunes.rb
# -*- coding: utf-8 -*-
require 'rbosa' ##gem install rubyosa or rubyosa19
def playing
OSA.utf8_strings = true
itunes = OSA.app('iTunes')
if itunes.player_state == OSA::ITunes::EPLS::PLAYING
track = itunes.current_track
" ♪ "+track.artist.force_encoding("utf-8") + " - " + track.name.force_encoding("utf-8")
else
@nbqx
nbqx / fom.rb
Created October 20, 2011 09:57
# -*- coding:utf-8 -*-
## is he/she a friend of mine plugin
Earthquake.init do
command :fom? do |m|
you, me = m[1], twitter.info['screen_name']
if twitter.friends?(you,me)
puts "@#{you} is your friend"
else
input(":user #{you}")
@nbqx
nbqx / jump.rb
Created November 15, 2011 05:06
require 'rubygems/user_interaction'
class Jump
include Gem::UserInteraction
def ask_me
n = ask "key?"
end
def choose(lst)
@nbqx
nbqx / find.hs
Created November 18, 2011 04:18
haskell + mdfind sample
import Data.List
import System.Process
getList :: String -> IO [String]
getList kwd = do lst <- readProcess "mdfind" query ""
return $ lines lst
where
query = ["kMDItemContentType == \"public.folder\" && kMDItemDisplayName == \"*" ++ kwd ++ "*\"wcd"]
-- マッチ
%w(sinatra notify).each{|x| require x}
require "sinatra/reloader" if development?
configure do
TITLE = "InDesign Scripting Server"
INDESIGN_VERSION = "CS5"
end
get "/" do
Notify.notify TITLE, "Target Versiion InDesign #{INDESIGN_VERSION}"