Skip to content

Instantly share code, notes, and snippets.

View perplexes's full-sized avatar

Colin Curtin perplexes

View GitHub Profile
@perplexes
perplexes / instructions.txt
Created June 6, 2012 20:42
Move messages from iPhone to Android
# Migrate SMS from iPhone to Android in OSX #
Parts of this taken from http://pastebin.com/d4hNUmTK
1. Make an unencrypted backup of your iPhone to iTunes, not using iCloud.
2. cd /tmp
3. put iphone_sms_* here (found below)
4. Find your ~/Library/Application Support/MobileSync/Backup/*/3d0d7e5fb2ce288813306e4d4636395e047a3d28(.mddata)
5.
> sqlite3 ~/Library/Application Support/MobileSync/Backup/(id)/3d0d7e5fb2ce288813306e4d4636395e047a3d28(.mddata)
@perplexes
perplexes / Rakefile.rb
Created June 4, 2012 16:00
How to have multithreaded workers in delayed_job 3.0.3 and Ruby 1.9.3 and Rails 3.2.2
task :workers => :environment do
module Delayed
class Worker
def name_with_thread_id(*a, &b)
name_without_thread_id(*a, &b) + " thread:#{Thread.current.object_id}"
end
alias_method_chain :name, :thread_id
end
end
Rails.logger.info "Running threaded worker env."
<?PHP
// Create our client object.
$client= new GearmanClient();
// Add default server (app.gearmanhq.com).
$client->addServer('hydra.gearmanhq.com', 4745);
//$client->addServer('localhost', 4731);
//$client->addServer('gm00.gearmanhq.net', 4745);
echo "Sending job...\n";
@perplexes
perplexes / progress.rb
Created June 22, 2011 21:17
A progress counter and estimator.
class Progress
SECOND = 1
MINUTE = SECOND * 60
HOUR = MINUTE * 60
DAY = HOUR * 24
CONV = [DAY, HOUR, MINUTE, SECOND]
NAMES = %w(days hours minutes seconds)
attr_accessor :total, :current
gem 'sinatra'
%%{
machine gearman;
alphtype int;
action req_magic {
puts "req_magic"
}
action get_size {
-- control frame ----------
c:0005 p:---- s:0016 b:0016 l:000015 d:000015 CFUNC :puts
c:0004 p:---- s:0014 b:0014 l:000013 d:000013 CFUNC :puts
c:0003 p:0100 s:0010 b:0010 l:001a78 d:001658 EVAL http_0mq.rb:13
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001a78 d:001a78 TOP
---------------------------
-- control frame ----------
c:0011 p:---- s:0051 b:0051 l:000050 d:000050 CFUNC :undefine_finalizer
c:0010 p:---- s:0030 b:0030 l:000029 d:000029 CFUNC :free
# ruby -v => ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin10]
RUBY_ENGINE = 'ruby'
require 'rubygems'
gem 'ffi-rzmq'
gem 'json'
require 'ffi-rzmq'
require 'json'
require 'request'
CTX = ZMQ::Context.new(1)
# Override http debugging, pipe to STDERR.
# Output:
# <- "POST /watched.xml HTTP/1.1\r\nAccept: */*\r\nConnection: close\r\nContent-Type: application/xml\r\nAuthorization: Basic MzkyZih7219fIUH\r\nContent-Length: 82\r\nHost: xxxxxxxxxxx.com\r\n\r\n"
# <- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n"
# -> "HTTP/1.1 422 Unprocessable Entity\r\n"
module ActiveResource
class Connection
def http
http = Net::HTTP.new(@site.host, @site.port)
http.use_ssl = @site.is_a?(URI::HTTPS)
>> /^\s*$/.match("one\r\n\r\ntwo")
=> #<MatchData "\r">