Skip to content

Instantly share code, notes, and snippets.

View jbender's full-sized avatar

Jonathan Bender jbender

View GitHub Profile
@jbender
jbender / followup_prompt_cell.rb
Created October 8, 2015 14:37
ProMotion + RMQ custom styling
class FollowupPromptCell < PM::TableViewCell
def rmq_build
content.append!(UILabel, :followup_prompt_cell_label)
apply_style :followup_prompt_cell
end
def content
find(self.contentView)
end
@jbender
jbender / setup.md
Created November 20, 2015 16:45
Raspberry Pi X-Day

Device

Assemble Adafruit Ultimate device (connecting wifi USB)

Software

RVM

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

curl -sSL https://get.rvm.io | bash -s stable

@jbender
jbender / custom_cell.rb
Last active December 1, 2015 16:34
ProMotion::Table + Autolayout + Motion-Kit
class CustomCell < UITableViewCell
def initWithStyle(style, reuseIdentifier: identifier)
super
@layout = CustomCellLayout.new(root: WeakRef.new(self)).build
self
end
def obj=(obj)
@layout.foo = obj[:foo]
@layout.bar = obj[:bar]
@jbender
jbender / contacts.rb
Created February 2, 2016 22:26
Example RubyMotion Resource
module ContactuallyApi
module Resources
module Contacts
RESOURCE_URL_BASE = 'api/v2/contacts'.freeze
def contact_index(params = nil, &block)
path = RESOURCE_URL_BASE
ContactuallyApi.client.get(path, params, &block)
end
@jbender
jbender / contact.rb
Created February 2, 2016 22:28
Example RubyMotion Network Model
module ContactuallyApi
module Models
class Contact < Base
include NameHelper
ATTRIBUTES = CORE_ATTRIBUTES + [
:addresses,
:avatar_url,
:company,
:email_addresses,
@jbender
jbender / swipable_cell.rb
Created February 11, 2016 16:38
Example RubyMotion Swipable Cell module
module SwipeableCell
ANIMATION_DURATION = 0.2
MAX_TRANSITION_ALPHA = 0.5
SWIPE_THRESHOLD = 110
LONG_SWIPE_THRESHOLD = SWIPE_THRESHOLD + 80
FADE_IN_DISTANCE = SWIPE_THRESHOLD
def gestureRecognizer(recognizer,
shouldRecognizeSimultaneouslyWithGestureRecognizer: other_recognizer)
return true unless recognizer.is_a? UIPanGestureRecognizer
@jbender
jbender / simulators.rb
Created February 23, 2016 19:35
RubyMotion simulate all OS/device combos
{
:iphone_4 => 'iPhone 4s',
:iphone_5 => 'iPhone 5',
:iphone_6 => 'iPhone 6',
:iphone_6_plus => 'iPhone 6 Plus',
:ipad => 'iPad Retina',
:ipad_air => 'iPad Air'
}.each do |rake_task, device|
default_task = "bundle exec rake device_name=\"#{device}\""
@jbender
jbender / 01_set_up_client.rb
Created April 5, 2016 17:16
Getting Started with Contactually API v2 - Ruby
require 'faraday'
require 'faraday_middleware'
client = Faraday.new(
url: 'https://api.contactually.com',
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN_HERE'
}
) do |connection|
@jbender
jbender / 01_set_up_client.py
Created April 5, 2016 17:29
Getting Started with Contactually API v2 - Python
import requests
client = http.client.HTTPSConnection('api.contactually.com')
host = 'https://api.contactually.com'
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN_HERE'
}
@jbender
jbender / 02_get_current_user.sh
Created April 5, 2016 17:55
Getting Started with Contactually API v2 - cURL
curl https://api.contactually.com/v2/me \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-H "Content-Type: application/json"