Skip to content

Instantly share code, notes, and snippets.

@mattetti
mattetti / url_to_jpg.rb
Created April 25, 2012 15:24
MacRuby script to grab an url and save it as a jpg
#!/usr/local/bin/macruby
# Copyright (c) 2009 Matt Aimonetti
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@funny-falcon
funny-falcon / enumerator_patch.rb
Created March 12, 2012 17:00
Patch Enumemator to play well with EM::Sunchrony
class Enumerator
class Error < Struct.new(:error)
end
def feed(v)
@feed = v
end
class StopIteration < ::StopIteration
attr :result
def initialize(msg, result)
super(msg)
@kevinSuttle
kevinSuttle / meta-tags.md
Last active May 1, 2025 21:56 — forked from lancejpollard/meta-tags.md
List of Usable HTML Meta and Link Tags
@philippeantoine
philippeantoine / Tetris.html
Created February 15, 2012 21:09
2012-02-15 codingdojo tetris
<!doctype html><html><head><meta charset="UTF-8"><title>Tetris</title></head>
<body>
<pre id='game'></pre>
<script>
var tetris = {
empty:0,board:0,block:0,position:0,offset:0,
binary: function(i){
return (i).toString(2);
},
init: function(){
@saetia
saetia / gist:1623487
Last active April 20, 2025 23:05
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
system ~/projects/gc_tests $ rvm 1.9.3 do ruby gc_stress.rb
20.760000 0.250000 21.010000 ( 21.007255)
{:count=>7921,
:heap_used=>43,
:heap_length=>43,
:heap_increment=>0,
:heap_live_num=>5607,
:heap_free_num=>11963,
:heap_final_num=>1}
GC time: 2.259033000000017s
@jstorimer
jstorimer / hilong.rb
Last active February 18, 2025 18:20
hilong -- A simply utility to show character counts for each line of input and highlight lines longer than 80 characters.
#!/usr/bin/env ruby
# A simply utility to show character counts for each line of input and
# highlight lines longer than 80 characters.
#
# Written as an example for http://jstorimer.com/2011/12/12/writing-ruby-scripts-that-respect-pipelines.html
#
# Examples:
#
# $ hilong Gemfile
@seanlilmateus
seanlilmateus / gist:1386468
Created November 22, 2011 18:34
Macruby Face Detection in Mac OS X Lion
framework 'Cocoa'
framework 'QuartzCore'
class NSColor
def toCGColor
colorRGB = self.colorUsingColorSpaceName NSCalibratedRGBColorSpace
components = Array.new(4){Pointer.new(:double)}
colorRGB.getRed components[0], green:components[1], blue:components[2], alpha:components[3]
require "thread"
$mutex = Mutex.new
$total = 0
def incr
$mutex.synchronize { $total += 1 }
sleep
end
@headius
headius / output
Created September 23, 2011 05:55
Thread dumping signal implemented in Ruby code? No problem!
system ~/projects/jruby $ jruby -rjruby/thread_dump -e "Thread.new{ loop{ 'hello' } }.join"
^Z
[1]+ Stopped jruby -rjruby/thread_dump -e "Thread.new{ loop{ 'hello' } }.join"
system ~/projects/jruby $ bg
[1]+ jruby -rjruby/thread_dump -e "Thread.new{ loop{ 'hello' } }.join" &
system ~/projects/jruby $ kill -USR2 %1 ; sleep 1
Ruby Thread Dump