Skip to content

Instantly share code, notes, and snippets.

@youpy
youpy / mdfind3.rb
Created November 16, 2012 12:03
mdfind3
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# -*- ruby -*-
require 'spotlight'
require 'optparse'
predicates = ['(true)']
usedate = false
usesize = false
@youpy
youpy / default.js
Created November 13, 2012 08:54
dotjs script to display glitched webfont
// only supports Safari
// https://github.com/wfarr/dotjs.safariextension
if($.browser.safari) {
var link = $('<link />').
attr('href', 'http://dl.dropbox.com/u/334064/sketches/webfont_1/styles_min.css').
attr('type', 'text/css').
attr('rel', 'stylesheet');
$('head').append(link);
@youpy
youpy / netprint.rb
Last active October 12, 2015 06:27
cli to upload file to netprint (http://www.printing.ne.jp/)
# this is integrated in netprint gem.
# https://github.com/youpy/netprint/commit/d4d43ad9cf7448d6ba047296efb18e89d1435905
--- actionscript-mode.el_ 2012-10-29 11:37:47.000000000 +0900
+++ actionscript-mode.el 2012-10-29 11:42:52.000000000 +0900
@@ -48,7 +48,12 @@
(require 'font-lock)
(require 'cc-mode)
(eval-when-compile
- (require 'regexp-opt))
+ (require 'regexp-opt)
+ (load "cc-fonts" nil t)
+ (load "cc-langs" nil t))
%w(tmpdir netprint prawn).each {|g| require g }
Earthquake.init do
command :netprint do |m|
Dir.mktmpdir do |dir|
filename = dir + "/tweet.pdf"
Prawn::Document.generate(filename) do
font "/Users/youpy/Library/Fonts/M+2P+IPAG.ttf"
text m[1]
end
require 'open-uri'
require 'cgi'
def show_image_on_iterm(url)
filename = '/tmp/image_on_iterm'
system('curl %s > %s 2>/dev/null' % [url, filename])
command =<<CMD % filename
osascript -e "
tell application \\"iTerm\\"
tell the first terminal
@youpy
youpy / eq_extract_title.rb
Last active October 11, 2015 02:58
earthquake plugin to extract title from URL
%w(nokogiri open-uri).each {|g| require g }
def extract_title(url)
open(url) do |f|
if f.content_type =~ /html/
doc = Nokogiri::HTML(f)
title = doc.xpath('//title')[0]
title ? title.text : nil
end
end
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']
class MIDIX
def initialize
@destinations = CoreMIDI::Destination.all
end
def program_change(program_number, channel = 0)
puts(0b11000000 | channel, program_number)
end
def control_change(control_number, value, channel = 0)
@youpy
youpy / eq_zws.rb
Created August 22, 2012 00:44
ZWS plugin for earthquake
%w(v8 open-uri).each {|g| require g }
class ZWS
def initialize
@cxt = V8::Context.new
open("https://raw.github.com/youpy/node-zws/master/lib/zws.js") do |file|
@cxt.eval(file, "zws.js")
end
end