This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <h1>New foo</h1> | |
| <%= render 'form' %> | |
| <%= link_to 'back', :back %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module FooSetupHelper | |
| def setup_foo(obj) | |
| obj.build_baz if obj.baz.blank? | |
| obj.bars.build if obj.bars.empty? | |
| return obj | |
| end | |
| def build_select_list(assoc, options={}) | |
| name = options[:name] || "name" | |
| scope = options[:scope] || "all" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rails generate skizmo:form Foo | |
| With Foo.rb (model like this): | |
| class Foo < ActiveRecord::Base | |
| has_many :bars | |
| belongs_to :baz | |
| accepts_nested_attributes_for :bars | |
| accepts_nested_attributes_for :baz | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| adb forward tcp:41927 tcp:41927 | |
| sudo cp /etc/resolv.conf /etc/resolv.conf.azilink.bak | |
| sudo cp /path/to/resolv.azilink /etc/resolv.conf | |
| sudo openvpn /path/to/azilink.ovpn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| domain lan | |
| search lan | |
| nameserver 192.168.56.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
| package="com.example.android.hello_world" | |
| android:versionCode="1" | |
| android:versionName="1.0"> | |
| <application android:label="@string/app_name" | |
| android:debuggable="true" | |
| android:icon="@drawable/ic_launcher"> | |
| <activity android:name=".HelloWorld" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.android.hello_world; | |
| import android.app.Activity; | |
| import android.os.Bundle; | |
| import android.widget.TextView; | |
| class HelloWorld < Activity | |
| def onCreate(state:Bundle) | |
| super state | |
| tv = TextView.new(self) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # take list of 1,2,3,5,6,7,10 and turn into 1-3,5-7,10 | |
| def self.consolidate_pdsh_values(vals) | |
| # vals is an array | |
| # Examples: | |
| # 005,006,007,008,009,010,011,012 => 005-0012 | |
| # 123,4,5,6,7,8,9,10,11,12,1234,1235,1236 => 4-12,123,1234-1236 | |
| sorted_vals = vals.sort{|a,b| a.to_i <=> b.to_i} | |
| skipped_vals = sorted_vals.each_with_index.map do |x,i| | |
| # replace with "-" if we are in the middle of a set of concurrent numbers | |
| (i > 0 and i + 1 < sorted_vals.size and # make sure we are in bounds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # first without ignoring the checksum, you'll see that we get an error | |
| >> VinApi.find("VIN WITH BAD CHECKSUM GOES HERE") | |
| => #<VinApi @prefix_options={}, @attributes={"error"=>"Vin did not pass checksum test"}> | |
| # next ignoring the checksum, we get our data | |
| >> VinApi.find("VIN WITH BAD CHECKSUM GOES HERE", :params => {:ignore_checksum => "true"}) | |
| => #<VinApi @prefix_options={}, @attributes={"body_style"=>"Coupe", "model"=>"ACCORD EX", "country"=>"USA", "world_region"=>"North America", "engine_type"=>"FWD", "vin"=>"VIN WITH BAD CHECKSUM GOES HERE", "transmission"=>"Automatic", "make"=>"Honda", "year"=>"2003"}> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| When /^(?:|I )select "([^"]*)" from "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector| | |
| with_scope(selector) do | |
| select(value, :from => field) | |
| # this is what changed .. 1) need to find the ID of the field that was passed in and then trigger a change event | |
| id = "#" + find_field(field)[:id] | |
| page.execute_script("$('#{id}').trigger('change');") | |
| end | |
| end |