Skip to content

Instantly share code, notes, and snippets.

View rscottm's full-sized avatar

Scott Moyer rscottm

View GitHub Profile
@rscottm
rscottm / gist:5167486
Created March 15, 2013 04:29
This is the code I used to read the JCodings tables and create Java code for byte arrays.
def read_int_at(file, index)
(file[index] << 24) | (file[index+1] << 16) | (file[index+2] << 8) | file[index+3]
end
def hex_int_at(file, index, pad_length=0)
rv = read_int_at(file, index).to_s(16)
pad = "0" * (pad_length > rv.length ? (pad_length - rv.length) : 0)
"0x#{pad}#{rv}"
end
target_disk="`rootdev -d -s`"
# Get the current sizes of ckern, croot, and stateful
ckern_size="`cgpt show -i 6 -n -s -q ${target_disk}`"
croot_size="`cgpt show -i 7 -n -s -q ${target_disk}`"
state_size="`cgpt show -i 1 -n -s -q ${target_disk}`"
#new stateful size will include all but 1 byte from rootc and kernc
stateful_size=$(($state_size + $croot_size + $ckern_size - 2))
@rscottm
rscottm / gist:9298760
Created March 1, 2014 22:50
Code for finding and storing dependencies in stdlib.
class StdlibDependencies
attr_reader :dependencies, :version
PATTERN = %r{^\s*require ['"]([a-zA-Z0-9/-_]+)["']\s*$}
def self.[](key)
versions[key]
end
def self.versions
require 'ruboto/widget'
ruboto_import_widgets :LinearLayout
class ActionBarActivity
def onCreate(bundle)
super
self.content_view =
linear_layout orientation: :vertical do
end