This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# usage: gemdoc GEM_NAME | |
# eg: gemdoc rspec-mocks | |
# | |
gemdoc() { | |
gem rdoc $1 --rdoc | |
(cd `gem env gemdir`/doc/$1*; open rdoc/index.html) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Update: there's an issue open in RubyMotion for this, so hopefully it will get resolved soon. | |
# | |
# http://hipbyte.myjetbrains.com/youtrack/issue/RM-725 | |
# | |
# In the meantime, here's a workaround: https://gist.github.com/darinwilson/26c8b573a65d8bc4c64b | |
# if you create a Ruby Hash... | |
ruby_hash = { foo: "bar" } | |
# ...you can call Ruby methods... | |
ruby_hash.has_key?(:foo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Utility class that converts a java.util.HashMap instance to a Ruby Hash. RubyMotion will | |
# start supporting this out of the box at some point, but until then, this can be used | |
# as a workaround: http://hipbyte.myjetbrains.com/youtrack/issue/RM-725 | |
# | |
# Usage: | |
# HashMapToHash.convert(hashmap) | |
# | |
# This supports nested hashes and should assure that all Java-based values are properly converted | |
# to their Ruby counterparts (i.e. java.lang.String => String). | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This assumes that you have a file called request.rb in the same directory, and that | |
* the file contains a subclass of Volley request object | |
* | |
* The code in this .java file gets added to the Java wrapper around our Ruby class at | |
* compile time. This contains a few shims to work around cases where RubyMotion is | |
* currently not generating correctly typed versions of these methods. | |
* | |
* http://hipbyte.myjetbrains.com/youtrack/issue/RM-724 | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# throws NameError: uninitialized constant `Android' | |
class Android::App::Activity | |
def say_hello | |
puts "hello!" | |
end | |
end | |
class MainActivity < Android::App::Activity | |
def onCreate(savedInstanceState) | |
super |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Start com.yourcompany.round_rect_crash/.MainActivity | |
--------- beginning of system | |
--------- beginning of main | |
I/com/yourcompany/round_rect_crash( 1607): creating RoundRect with Java | |
I/com/yourcompany/round_rect_crash( 1607): #<android.graphics.drawable.shapes.RoundRectShape:0x100019> | |
I/com/yourcompany/round_rect_crash( 1607): creating RoundRect with Ruby | |
E/art ( 1607): 0xb405ce80 SpaceTypeMallocSpace begin=0x12c00000,end=0x12e01000,limit=0x22c00000,size=2MB,capacity=96MB,non_growth_limit_capacity=256MB,name="main rosalloc space"] | |
E/art ( 1607): 0xb425ff60 allocspace main rosalloc space live-bitmap 3[begin=0x12c00000,end=0x22c00000] | |
E/art ( 1607): 0xb427f300 allocspace main rosalloc space mark-bitmap 3[begin=0x12c00000,end=0x22c00000] | |
E/art ( 1607): 0xb4050480 SpaceTypeImageSpace begin=0x6fec0000,end=0x70835000,size=9MB,name="/data/dalvik-cache/x86/system@[email protected]"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ambient experiment for Sonic Pi (http://sonic-pi.net/) | |
# | |
# The piece consists of three long loops, each of which plays one of | |
# two randomly selected pitches. Each note has different attack, | |
# release and sleep values, so that they move in and out of phase | |
# with each other. This can play for quite awhile without | |
# repeating itself :) | |
live_loop :note1 do | |
use_synth :hollow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Phasing Piano for Sonic Pi, coded by Darin Wilson | |
# inspired by Steve Reich's Clapping Music | |
# | |
# This piece consists of two threads, each playing the same short melodic phrase. | |
# | |
# On every third pass through the phrase, one of the threads shifts the phase by | |
# 1/4 of a beat, moving it more and more out of phase. Eventually, it comes | |
# back around to where it started, and the piece ends. | |
use_synth :piano |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################### | |
## Sonic Pi Drum Machine | |
## coded by Darin Wilson | |
## | |
use_bpm 95 | |
in_thread(name: :drum_machine) do | |
# choose your kit here (can be :acoustic, :acoustic_soft, :electro, :toy) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################## | |
## Example 1 - play a note | |
play 60 | |
############################################## | |
## Example 2 - play 4 random notes | |
4.times do | |
play rrand_i(60, 90) | |
sleep 0.5 |
OlderNewer