Skip to content

Instantly share code, notes, and snippets.

@buk
buk / participants.json
Created November 17, 2012 22:00
JSON Output
[{"allergy":"Lactose Intolerant","created_at":"2012-11-16T23:59:10Z","date_of_birth":"2012-11-16","emergency_number":"004962535377","first_name":"Sebastian","group":"St. Peter","health_insurance_card":true,"id":1,"last_name":"Bachmann","swimmer":true,"updated_at":"2012-11-17T00:44:16Z","vaccination_certificate":false},{"allergy":"Xanax","created_at":"2012-11-17T09:50:27Z","date_of_birth":"2013-11-17","emergency_number":"004962531546","first_name":"Markus","group":"St. Martin","health_insurance_card":true,"id":2,"last_name":"Bauer","swimmer":true,"updated_at":"2012-11-17T09:50:27Z","vaccination_certificate":true},{"allergy":"None","created_at":"2012-11-17T09:51:28Z","date_of_birth":"2007-01-03","emergency_number":"004962531546","first_name":"Christian","group":"Heiliger Franz von Asisi","health_insurance_card":false,"id":3,"last_name":"Bauer","swimmer":true,"updated_at":"2012-11-17T09:51:28Z","vaccination_certificate":false}]
@buk
buk / ParticipantsViewController
Created November 17, 2012 21:35
Load JSON Values and pass them to a UITableView - Rubymotion
class ParticipantsTableViewController < UITableViewController
def viewDidLoad
super
BW::HTTP.get("http://jugendgruppe-backend.192.168.2.105.xip.io/participants.json") do |response|
json = BW::JSON.parse(response.body.to_str)
@posts = json["items"]
view.addSubview(@tableView)
end
@buk
buk / SettingsController
Created October 24, 2012 12:03
This is my formotion code
class SettingsController < Formotion::FormController
include SettingsForm
def init
form = get_settings_form
super.initWithForm(form)
end
end
require 'rubygems'
require 'ipa_reader'
require 'plist'
require 'builder'
ipa_file = IpaReader::IpaFile.new("AdhocServerTest.ipa")
puts name = "Name:#{ipa_file.name}"
title = "#{ipa_file.name}"
puts bundleId = "Bundle Identifier: #{ipa_file.bundle_identifier}"
puts version = "Version: #{ipa_file.version}"
@buk
buk / gist:3905630
Created October 17, 2012 13:52
create File
require 'rubygems'
require 'builder'
plist = File.open(title + '.plist', 'w') do |f|
end
def generate_plist_file
plist = Builder::XmlMarkup.new( :indent => 2 )
plist.instruct! :xml, :encoding => "UTF-8"
@buk
buk / plist error
Created October 9, 2012 13:19
error message in irb
1.9.3-p194 :001 > require 'plist'
/Users/sebastian/.rvm/gems/ruby-1.9.3-p194/gems/plist-3.1.7/lib/plist/generator.rb:221: warning: else without rescue is useless
SyntaxError: /Users/sebastian/.rvm/gems/ruby-1.9.3-p194/gems/plist-3.1.7/lib/plist/generator.rb:216: syntax error, unexpected tLABEL
when String, Symbol: 'string'
^
/Users/sebastian/.rvm/gems/ruby-1.9.3-p194/gems/plist-3.1.7/lib/plist/generator.rb:217: syntax error, unexpected keyword_when, expecting keyword_end
when Fixnum, Bignum, Integer: 'integer'
^
/Users/sebastian/.rvm/gems/ruby-1.9.3-p194/gems/plist-3.1.7/lib/plist/generator.rb:217: dynamic constant assignment
when Fixnum, Bignum, Integer: 'integer'
@buk
buk / posts_controller.rb
Created October 2, 2012 11:44
Code of my posts_controller
class PostsController < ApplicationController
# GET /posts
# GET /posts.json
def index
@posts = Post.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @posts }
@buk
buk / gist:3749058
Created September 19, 2012 11:03
Hier geschieht der eigentliche upload
require 'sinatra'
set :public_folder, 'public'
get '/' do
haml :index
end
post '/upload' do
File.open('public/uploads/' + params['file'][:filename], "w") do |f|
@buk
buk / upload
Created September 19, 2012 10:50
Upload form: hier will ich den wert des feldes uebergeben
- @files.each_with_index do |file, index, customer_dir|
%tr
%th= File.basename(file.path)
%th= "#{to_mb(file.size)} MB"
%th
%a{:id => "file#{index}", :href => "/uploads/#{File.basename(file.path)}"}
= "/uploads/#{customer_dir}/#{File.basename(file.path)}"
%a{:id => "back", :href => "/"}
= "Back"
@buk
buk / gist:3748957
Created September 19, 2012 10:45
index file
%body
%h1 ipa Datei auswaehlen und hochladen
%form#upload{ :enctype => "multipart/form-data", :action => "/upload", :method => "post"}
%input{ :name=> "file", :type => "file"}
%label{ :for => "message[customer_dir]"}Kunde:
%input{ :type => "text", :customer_dir => "Kunde" }
%input{ :type=> "submit", :value => "Upload"}