Skip to content

Instantly share code, notes, and snippets.

View andrewhavens's full-sized avatar

Andrew Havens andrewhavens

View GitHub Profile
@andrewhavens
andrewhavens / starting-ios-simulator.sh
Created August 6, 2016 07:04
Starting the iOS simulator for a RubyMotion app.
$ cd my_first_rm_app
$ bundle exec rake
Build ./build/iPhoneSimulator-9.2-Development
Compile ./app/app_delegate.rb
Create ./build/iPhoneSimulator-9.2-Development/my_test_app.app
Link ./build/iPhoneSimulator-9.2-Development/my_test_app.app/my_test_app
......
Simulate ./build/iPhoneSimulator-9.2-Development/my_first_rm_app.app
*** Starting simulator
(nil)?
@andrewhavens
andrewhavens / project-structure.sh
Created August 6, 2016 07:01
A typical RubyMotion iOS app
my_first_rm_app/
├── Gemfile
├── Rakefile
├── app
│ └── app_delegate.rb
├── resources
│ ├── Default-568h@2x.png
│ ├── Default-667h@2x.png
│ └── Default-736h@3x.png
└── spec
@andrewhavens
andrewhavens / motion-create.sh
Created August 6, 2016 06:58
Creating your first RubyMotion app
$ motion create my_first_rm_app
@andrewhavens
andrewhavens / motion-create.sh
Created August 6, 2016 06:55
Displaying the list of available motion templates
$ motion create
Usage:
$ motion create APP-NAME
Create a new RubyMotion project from one of the following templates: android, gem, ios (default), ios-action-extension, ios-custom-keyboard, ios-document-picker, ios-file-provider, ios-framework, ios-photo-editing, ios-share-extension, ios-today-extension, ios-watch-app, ios-watch-extension, osx, tvos, redpotion-template.
Options:
--template=[NAME|URL] A built-in template or from a file/git URL
@andrewhavens
andrewhavens / motion-version.sh
Created August 6, 2016 06:51
Checking your RubyMotion version
$ motion --version
4.8
@andrewhavens
andrewhavens / jsonapiembedded-records.js
Created April 28, 2016 04:49
JSON API compatible Ember Data EmbeddedRecordsMixin
import Ember from 'ember';
var camelize = Ember.String.camelize;
export default Ember.Mixin.create({
// The following is mostly identical to the JSONAPISerializer implementation,
// with the exception of adding an attributes key to the payload.
// https://github.com/emberjs/data/blob/v2.5.2/addon/serializers/json-api.js#L471
serializeHasMany(snapshot, json, relationship) {
var key = relationship.key;
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
itemSelected(item) {
console.log("itemSelected", item);
this.get("itemCallback")(item);
}
}
});
@andrewhavens
andrewhavens / index.html
Created April 17, 2014 18:37
broken jQuery file upload example
<h1>Upload Documents</h1>
<form action="/documents" enctype="multipart/form-data" id="fileupload" method="post">
<input type="file" name="document[attachment][]" multiple="multiple">
<table>
<tbody id="files" class="files"></tbody>
</table>
</form>
<!-- jQuery 1.8.3 already included -->
@andrewhavens
andrewhavens / search_spec.rb
Last active December 24, 2015 10:29
Broken thinking sphinx rspec config
feature "Search for Models" do
let(:my_model){ FactoryGirl.create(:my_fancy_model) }
before do
ThinkingSphinx::Test.index
end
scenario "A user searches for models by title" do
visit "/models"
@andrewhavens
andrewhavens / 0_widget_management.feature
Created August 30, 2013 21:20
Cucumber example, declarative style
Feature: Widget Management
Background:
Given I am logged in as a user
Scenario: Creating a new widget
When I create a widget
Then I should see "Widget was successfully created."