Skip to content

Instantly share code, notes, and snippets.

View jacklynrose's full-sized avatar

Jacklyn Rose jacklynrose

  • Australia
View GitHub Profile
@jacklynrose
jacklynrose / post-receieve
Created April 19, 2011 08:17
post-receive git hook to pull changes to your source folder
#!/bin/sh
cd ~user/ProjectRepo
env -i git pull
@jacklynrose
jacklynrose / routes.rb
Created May 12, 2011 04:56
Admin Controller + Subdomain Restriction + Whole URL Glob + Root Route for subdomains, no subdomain, and www subdomain
require 'Subdomain'
CMS::Application.routes.draw do
namespace "admin" do |admin|
resources :pages # Admin::PagesController Routes
end
constraints(Subdomain) do
match '/' => "pages#root" # Route for Root URL for Subdomains
@jacklynrose
jacklynrose / vertical_centering_with_vfl.rb
Created October 27, 2013 10:35
This is how I managed to hack the visual format language to center a few views vertically (most other ways put them at the top and bottom, or just the top, or just the bottom). Basically what I'm doing is saying that the top margin should be less than or equal to half the portrait height minus the total height of all the views you'll be centring…
totalCombinedViewHeight = 100
Motion::Layout.new do |layout|
layout.view view
layout.subviews "state" => @state, "action" => @action
layout.metrics "margin" => 20, "height" => 40, "halfHeight" => ((view.bounds.size.height - totalCombinedViewHeight) / 2), "halfWidth" => ((view.bounds.size.width - 100) / 2)
layout.vertical "|-(<=halfHeight)-[state]-margin-[action]-(>=halfWidth)-|"
layout.horizontal "|-margin-[state]-margin-|"
layout.horizontal "|-margin-[action]-margin-|"
end
@jacklynrose
jacklynrose / view_controller.rb
Last active December 27, 2015 01:19
The crazy method I created to refactor out code duplication around creating views and making them testable! Ewwww...
# This one!
def viewNamed(view_name, ofClass: class_reference)
var_name = view_name[0].downcase + view_name[1, view_name.length - 1].gsub(/\s/, '')
instance_variable_get("@#{var_name}") or instance_variable_set("@#{var_name}", class_reference.new).tap do |view|
view.accessibilityLabel = view_name
yield view if block_given?
end
end
@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++;
@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 / 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 / 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 / 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 / rubymotion_method_definition_benchmarks.md
Created March 11, 2014 01:07
RubyMotion Method Definition Benchmarks