Skip to content

Instantly share code, notes, and snippets.

@pullmonkey
pullmonkey / gist:1361596
Created November 13, 2011 04:28
hello android tutorial in mirah/pindah
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)
@pullmonkey
pullmonkey / gist:1361597
Created November 13, 2011 04:29
AndroidManifest for Hello Android pindah app
<?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"
@pullmonkey
pullmonkey / gist:1366168
Created November 15, 2011 04:43
resolv.azilnk
domain lan
search lan
nameserver 192.168.56.1
@pullmonkey
pullmonkey / gist:1366175
Created November 15, 2011 04:46
azilink
#!/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
@pullmonkey
pullmonkey / gist:1369234
Created November 16, 2011 04:27
formgen generated files
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
@pullmonkey
pullmonkey / gist:1371354
Created November 16, 2011 20:55
formgen sample helper
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"
@pullmonkey
pullmonkey / gist:1371360
Created November 16, 2011 20:56
formgen_sample_new
<h1>New foo</h1>
<%= render 'form' %>
<%= link_to 'back', :back %>
@pullmonkey
pullmonkey / gist:1371367
Created November 16, 2011 20:58
formgen_sample_edit
<h1>Editing foo</h1>
<%= render 'form' %>
<%= link_to 'back', :back %>
@pullmonkey
pullmonkey / gist:1371372
Created November 16, 2011 20:59
formgen sample form
<%= form_for setup_foo(@foo), :html => { :multipart => true } do |f| %>
<% if @foo.errors.any? %>
<div id="errorExplanation">
<h2><%= pluralize(@foo.errors.count, "error") %> prohibited this foo from being saved:</h2>
<ul>
<% @foo.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
@pullmonkey
pullmonkey / gist:1371375
Created November 16, 2011 21:00
formgen sample fields_for1
<div class="fields">
<div class="field">
<%= f.label :name %>
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :bar %>
<%= f.text_field :bar %>
</div>
<%= link_to_remove_fields "remove", f %>