Skip to content

Instantly share code, notes, and snippets.

View rscottm's full-sized avatar

Scott Moyer rscottm

View GitHub Profile
require 'ruboto/widget'
ruboto_import_widgets :LinearLayout
class ActionBarActivity
def onCreate(bundle)
super
self.content_view =
linear_layout orientation: :vertical do
end
@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
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: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
@rscottm
rscottm / javap output
Created November 22, 2012 08:43
baksmali output
public final class org.jruby.proxy.java.math.BigInteger$Proxy0 extends java.math.BigInteger implements org.jruby.javasupport.proxy.InternalJavaProxy{
public org.jruby.proxy.java.math.BigInteger$Proxy0(int, int, java.util.Random, org.jruby.javasupport.proxy.JavaProxyInvocationHandler);
Code:
0: aload_0
1: iload_1
@rscottm
rscottm / ruboto_generate.rb
Created March 22, 2012 22:35
Initial pass at using the dexmaker project to generate Ruboto callbacks
######################################################
#
# ruboto_generate.rb (by Scott Moyer)
#
# This is an initial pass at using the dexmaker
# project (http://code.google.com/p/dexmaker/) to
# generate Ruboto callbacks. The first half of this
# script generates the callback. The second half is
# the standard demo-opengl.rb script with minor
# modifications to allow it to use the generated
@rscottm
rscottm / Data
Created September 9, 2011 06:09
Cycle through various versions of ruboto-core and jruby-jars to collect stack information
Ruboto: 0.2.1
JRuby: 1.5.6
0:40
1:61
2:69
3:86
Ruboto: 0.2.1
JRuby: 1.6.X
0:42
1:66
require 'ruboto.rb'
ruboto_import_widgets :TextView, :LinearLayout, :Button
java_import 'android.content.Intent'
java_import "android.util.Log"
java_import 'android.provider.MediaStore'
java_import 'android.net.Uri'
java_import 'java.io.File'
java_import 'java.io.FileNotFoundException'
@rscottm
rscottm / script_server.rb
Created December 19, 2010 07:10
Experimental webrick server to allow editing of scripts on the device
#######################################################
#
# script_server.rb (by Scott Moyer)
#
# This is an experiment in creating a web server on
# an android handset for the purpose of editing scripts.
#
#######################################################
# Need to require date separately. You get a stack overflow
@rscottm
rscottm / android_api_gen.rb
Created December 19, 2010 05:14
This is the code I used to build the android_api.xml file from the X.xml files (where X is 1-9) pulled from the ASOP project
#######################################################
#
# android_api_gen.rb (by Scott Moyer)
#
# This is the code I used to build the android_api.xml
# file from the X.xml files (where X is 1-9) pulled
# from the ASOP project.
#
# To get the individual versions (something like):
#