Skip to content

Instantly share code, notes, and snippets.

View jacklynrose's full-sized avatar

Jacklyn Rose jacklynrose

  • Australia
View GitHub Profile
@jacklynrose
jacklynrose / fib_calculator.rb
Created April 19, 2014 11:13
Fast and memory efficient fib calculation based off Ray Hightower's memoization method but with better memory usage (http://rayhightower.com/blog/2014/04/12/recursion-and-memoization/)
# Fibonacci numbers WITH memoization.
# Initialize the memoization hash.
@scratchpad = {}
@max_fibo_size = 1_000_000_000_000
# Calculate the nth Fibonacci number, f(n).
def fibo (n)
val = if n <= 1
n
@jacklynrose
jacklynrose / keybase.md
Created April 16, 2014 23:55
keybase.md

Keybase proof

I hereby claim:

  • I am fluffyjack on github.
  • I am fluffyjack (https://keybase.io/fluffyjack) on keybase.
  • I have a public key whose fingerprint is 8203 E7C0 359A 6B05 1787 ED6E C1C5 3A42 6E34 5928

To claim this, I am signing this object:

@jacklynrose
jacklynrose / Rakefile
Last active August 29, 2015 13:57
Simple macro like functionality for RubyMotion
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project/template/ios'
require './lib/preprocessor'
begin
require 'bundler'
Bundler.require
rescue LoadError
end
@jacklynrose
jacklynrose / uiview+controller_helper.rb
Created March 16, 2014 14:45
Monkey patch for finding the controller of a view
class UIView
def controller
if self.nextResponder.is_a? UIViewController
return self.nextResponder
elsif self.nextResponder.respond_to? :controller
return self.nextResponder.controller
end
end
end
@jacklynrose
jacklynrose / rubymotion_method_definition_benchmarks.md
Created March 11, 2014 01:07
RubyMotion Method Definition Benchmarks

Method definition benchmarks for different versions

Using Ken Miller's benchmarking app: https://github.com/kemiller/rubymotion_benchmarking

2.20 - Take 1

                                            ObjC native loop:        0.001162
                             ObjC native loop w/objc_msgSend:        0.001512
                          ObjC method called from ruby (raw):        0.028951
@jacklynrose
jacklynrose / RubyMotionTheRailsWay.md
Last active August 29, 2015 13:57
Ideas on how to write RubyMotion apps the "Rails" way

RubyMotion The "Rails" Way

This is a current proposal that I'd like your feedback on for how we can clean up how we write RubyMotion applications. It's purely conceptual at the moment, and there would have to be some framework development to make this work the way described here.

Please submit your feedback, as a joint effort we can clean up our RubyMotion applications and make it easier for Rails developers to expand their skills into RubyMotion development.

Goals

The main points of this are:

@jacklynrose
jacklynrose / app_delegate.rb
Created March 5, 2014 11:36
SUPER basic clone of RMQ's stylesheet and selectors (no symbol based selection or fancy stylers, and other missing functionality like chaining)
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
@window.rootViewController = MyViewController.new
@window.makeKeyAndVisible
true
end
end
@jacklynrose
jacklynrose / post_rest_store.rb
Created February 16, 2014 14:05
RestKit Wrapper Usage Proposal
class PostRestStore < RestfulMotion::Store
api_endpoint 'http://example.com/v2/posts'
model :post
# some attribute mapping code
end
@jacklynrose
jacklynrose / Steps.md
Last active January 1, 2016 09:09
Bootstrapping your app for working with frank and location services and the frank step to turn location services for your app on and off

This assumes you're using bubble-wrap

  1. Put osx-plist in your Gemfile
  2. Put the code from bootstrap.rb gist into your AppDelegate's application:didFinishLaunchingWithOptions: method
  3. Run rake
  4. Press either "OK" or "Don't Allow"
  5. Exit the app via terminal
  6. Delete the code from bootstrap.rb
  7. You're now ready to use step, create features/step_definitions/location_services_steps.rb
  8. Paste in the code from location_services_steps.rb in this gist
@jacklynrose
jacklynrose / stat_collector.js
Created October 31, 2013 04:35
Grabbing the commit stats by week for the past year for the rails/rails repo
$.getJSON("https://api.github.com/repos/rails/rails/stats/commit_activity", function(data) {
var week_count = 1;
var commits_by_week = data.map(function(week) {
var total = 0;
$.each(week['days'], function(k, v) { total += v });
return total;
});
$.each(commits_by_week, function (k, v) {
console.log("Week " + week_count + ": " + v + " commits");
week_count++;