Skip to content

Instantly share code, notes, and snippets.

# % ruby scrot.rb /tmp/screenshot.png
# scrot.rb uses xlib + imlib via ffi to capture screenshots.
require 'ffi'
module X11
extend FFI::Library
ffi_lib 'X11'
attach_function :XOpenDisplay, [:string], :pointer
attach_function :XFlush, [:pointer], :pointer
# lookup coords by name or mac address via google.. (evented)
require 'cgi'
require 'json'
require 'eventmachine'
module Goog
module Location
class Name < EM::Connection
Head = <<-TEXT
# stripped cvHaarDetectObjects version of ffi-opencv
# % pacman -S opencv (tested/updated for 2.3.1)
# % ruby ffi-facedetect.rb some.png
require 'ffi'
module OpenCv
extend FFI::Library
ffi_lib 'opencv_objdetect'
require 'ffi-tk'
require 'bacon'
Tk.init
b = lambda {
describe 'Tk.root.tk_inactive' do
it 'resets' do
inactive = Tk.root.tk_inactive
inactive.should > 0
# SEE: https://github.com/lian/ffi-flite
require 'ffi'
module FFI::Flite
extend FFI::Library
ffi_lib_flags(:lazy, :global)
ffi_lib [ 'smixer-sbase', '/usr/lib/alsa-lib/smixer/smixer-sbase.so'], [ 'flite' ]
attach_function :init, :flite_init, [], :int
require 'socket'
# ..old method found in my teeworlds-svn dir
def query_teeworlds_server(ip="localhost",port="8303")
s = UDPSocket.new; s.bind("0.0.0.0", 8304)
s.send("\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffgief", 0, ip, port); sleep 0.2
response = s.recvfrom_nonblock(1024); s.close
ar = response[0][20..-1].split "\000"
player = ar[7..-1]
players = {}
#!/bin/env ruby
# http://sohowww.nascom.nasa.gov/data/realtime/mpeg/
SOHO_URL = "http://sohowww.nascom.nasa.gov/data/LATEST/%s"
MPLAYER_CMD = 'mplayer -ao null -really-quiet -geometry %ix%i+%i+%i %s -loop %i -speed %s &'
SOHO_ETI = {
'ETI_171' => { filename: 'current_eit_171small.mpg' },
#'ETI_195' => { filename: 'current_eit_195small.mpg' },
'ETI_284' => { filename: 'current_eit_284small.mpg' },
'ETI_304' => { filename: 'current_eit_304small.mpg' },
// $ curl http://localhost:8090/hello/world
{
"hello" : "world!",
"log" : "BackgroundColor changed, wohooo!"
}
//== API Syntax Choices
http://vimeo.com/3324904 =>
http://www.vimeo.com/moogaloop/load/clip:3324904 =>
<request_signature>2bc05a3a2f36cd94be799f52c5f09e3a</request_signature>
<request_signature_expires>1239724800</request_signature_expires>
=> flashvideo link: http://www.vimeo.com/moogaloop/play/clip:3324904/2bc05a3a2f36cd94be799f52c5f09e3a/1239724800/?q=sd
== Development Approaches
Asshole Driven development (ADD) - Any team where the biggest jerk makes all the big decisions is asshole driven development. All wisdom, logic or process goes out the window when Mr. Asshole is in the room, doing whatever idiotic, selfish thing he thinks is best. There may rules and processes, but Mr. A breaks them and people follow anyway.
Cognitive Dissonance development (CDD) - In any organization where there are two or more divergent beliefs on how software should be made. The tension between those beliefs, as it's fought out in various meetings and individual decisions by players on both sides, defines the project more than any individual belief itself.
Cover Your Ass Engineering (CYAE) - The driving force behind most individual efforts is to make sure than when the shit hits the fan, they are not to blame.
Development By Denial (DBD) - Everybody pretends there is a method for what's being done, and that things are going ok, when in reality, things are a mess and th