Skip to content

Instantly share code, notes, and snippets.

View jacklynrose's full-sized avatar

Jacklyn Rose jacklynrose

  • Australia
View GitHub Profile
@jacklynrose
jacklynrose / .zshrc
Last active October 31, 2021 23:57
Generate a branch name with ZSH prompts that has the ticket name and description
# Other zushy stuff
sluggify() {
# 1. Convert upper to lower
# 2. Remove all non-alphanumeric chars or non-space char
# 3. Convert spaces to dashes
# 4. Convert multiple dashes to single dash
echo $1 | tr '[:upper:]' '[:lower:]' | tr -dc '[:alnum:] ' | tr '[:space:]' '-' | sed -E 's/-+/-/g'
}

Keybase proof

I hereby claim:

  • I am jacklynrose on github.
  • I am jacklynrose (https://keybase.io/jacklynrose) on keybase.
  • I have a public key ASAGELIJ_qqqVpzqBdWg5tf1du-j18KPnIc-DXiKOkOzYAo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am watsonhamblin 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 / openstruct.rb
Created May 23, 2014 09:55
Half implementation of OpenStruct
class OpenStruct < BasicObject
def initialize(hash)
@struct = ::Struct.new(*hash.keys.map { |k| k.to_sym })
@struct = @struct.new(*hash.values)
end
def ==(other)
to_h == other.to_h
end
// Set on window
this.foobar = "V1"
//=> (result) "V1"
console.log(this.foobar)
//=> (output) V1
//=> (result) undefined
// Uses window
(() => {
console.log(this.foobar);
@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++;
@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 / 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 / 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