Skip to content

Instantly share code, notes, and snippets.

View seanlilmateus's full-sized avatar

Mateus seanlilmateus

View GitHub Profile
@seanlilmateus
seanlilmateus / README
Created May 11, 2012 04:39 — forked from fgalassi/README
Snippet generator for RubyMotion ctags (UltiSnips)
Generate ctags with `rake ctags`
Run snipper.rb
Move motion.snippets into ~/.vim/UltiSnips/ruby/
@seanlilmateus
seanlilmateus / gist:2709391
Created May 16, 2012 10:38
TextMate 2 .tm_properties

This is all based on the [alpha release][1].

Properties

From the built-in help system:

For many settings TextMate will look for a .tm_properties file in the current folder and in any parent folders (up to the user’s home folder).

These are simple setting = value listings where the value is a format string in which other variables can be referenced.

@seanlilmateus
seanlilmateus / movie_night.rb
Created June 4, 2012 16:42
Macruby and Rubymotion GCD groups explanation
group = Dispatch::Group.new
derpina_queue = Dispatch::Queue.concurrent(:high) #Dispatch::Queue.concurrent("com.company.movie_night.get_wine")
derp_queue = Dispatch::Queue.concurrent(:default) #Dispatch::Queue.concurrent("com.company.movie_night.get_popcorn")
derpina_queue.async(group) do
puts "go to wine cellar to get some Bordeaux"
i = 0
while i < 99
puts "can't decide which one to drink"
@seanlilmateus
seanlilmateus / semaphore.rb
Created June 20, 2012 18:02
Macruby and Rubymotion GCD Semaphore example (The Dining Philosophers Problem)
#!/usr/bin/env macruby -wKU
class Philosopher
def initialize(name, left_chopstick, right_chopstick)
@name = name
@left_chopstick = left_chopstick
@right_chopstick = right_chopstick
@meals = 0
end
@seanlilmateus
seanlilmateus / sleeping.rb
Created June 20, 2012 18:21
Macruby and Rubymotion GCD Semaphore example (sleeping barber problem)
#!/usr/bin/env macruby -wKU
# A GCD-based implementation of the sleeping barber problem:
# http://en.wikipedia.org/wiki/Sleeping_barber_problem
# http://www.madebysofa.com/#blog/the_sleeping_barber
waiting_chairs = Dispatch::Queue.new('com.apple.waiting_chairs')
semaphore = Dispatch::Semaphore.new(3)
index = -1
@seanlilmateus
seanlilmateus / gist:2981945
Created June 24, 2012 06:25
create a new incognito window in Google Chrome with MacRuby
#!/usr/bin/env macruby -wKU
framework 'ScriptingBridge'
chrome = SBApplication.applicationWithBundleIdentifier("com.google.Chrome")
SBApplication.ensureScriptingAdditionsLoaded
# create a new window with size of 600x600 px
chrome.windows << GoogleChromeWindow.alloc.initWithProperties( mode: "incognito", bounds: [1, 22, 600, 600] )
# first tab load macruby.org
@seanlilmateus
seanlilmateus / gist:3029710
Created July 1, 2012 21:33
macruby reject bugs tweets
#!/usr/bin/env macruby -wKU
framework 'Foundation'
## first example reject works great
new_array = ["test", "test 1", "Test 2", "Test 3", 10].reject {|test| test.is_a?(Fixnum) }
p new_array
## second example it still showing tweets with iso_language_code == en
@seanlilmateus
seanlilmateus / rubymotion_ispeech.md
Created July 19, 2012 13:51 — forked from creativetechnologist/rubymotion_ispeech
Integrating RubyMotion and the iSpeech SDK

#Integrating RubyMotion and the iSpeech SDK

As of 19th July 2012, RubyMotion has a couple of issues with external libraries as I discovered when trying the integration, thanks to Laurent, the architect of RubyMotion and with some prompting from Stéphane Wirtel here is the issue and resolution including the code to make the iPhone speak.

Firstly setting up the app, assuming you've already copied the files you need into your vendor/iSpeechSDK directory this is the code needed in the rakefile as per any normal library ...

app.vendor_project('vendor/iSpeechSDK', :static, :products => ["libiSpeechSDK.a"], :headers_dir => "Headers")

@seanlilmateus
seanlilmateus / gist:3187192
Last active March 5, 2021 07:17
How to use Obj-C with MacRuby/Rubymotion

Using Obj-C with MacRuby/Rubymotion

This little post aims to help you to translate Objective-C Blocks into Ruby blocks. Let's start by taking a look at few examples of iOS API call where blocks are used for animations and enumeration

Ruby Lambda Syntaxes:

Im Rubymotion and MacRuby you can use all the Ruby Lambda syntaxes that are:

block = lambda { |param|  ... }
@seanlilmateus
seanlilmateus / gist:3190992
Created July 27, 2012 23:18
Safari tabs with macruby
framework "ScriptingBridge"
safari=SBApplication.applicationWithBundleIdentifier("com.apple.Safari")
new_window = SafariDocument.alloc.init # create a new window
safari.windows << new_window # make the window visible
safari.windows.first.currentTab.URL = "https://mail.google.com"
sites = ["https://twitter.com", "http://news.ycombinator.com"].map do |site|
new_tab = SafariTab.alloc.initWithProperties({"URL" => site}) # create a new tab
safari.windows.first.tabs << new_tab # add the tab to the window