Skip to content

Instantly share code, notes, and snippets.

View pitosalas's full-sized avatar

Pito Salas pitosalas

View GitHub Profile
<select class="select required" id="election_district_set_id" name="election[district_set_id]">
<option value=""></option>
<option value="<select id="district_set_district_set_id" name="district_set[district_set_id]"><option value="0">(built-in default district set)</option>
"><select id="district_set_district_set_id" name="district_set[district_set_id]"><option value="0">(built-in default district set)</option>
</option>
<option value="<option value="1">Dummy District Set</option></select>"><option value="1">Dummy District Set</option></select></option></select><span class="hint">elections have to be part of some jurisdiction </span></div>
<div><label class="integer required" for="election_default_voting_method_id"><abbr title="required">*</abbr> Voting Method</label><input class="integer required" id="election_default_voting_method_id" name="election[default_voting_method_id]" size="30" type="text" value="0" /><span class="hint">default voting methods for contests in this election</span></di
@pitosalas
pitosalas / Simpleform Class
Created March 2, 2011 18:22
This is an example from the simple_form gem to see how gist works
class SimpleFormInstallGenerator < Rails::Generator::Base
def manifest
record do |m|
m.directory 'config/initializers'
m.template 'simple_form.rb', 'config/initializers/simple_form.rb'
m.directory 'config/locales'
m.template locale_file, 'config/locales/simple_form.en.yml'
end
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edu.brandeis.hellogridview"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".main"
android:label="@string/app_name">
@pitosalas
pitosalas / gist:1534495
Created December 29, 2011 15:10
Aperture opml
<?xml version="1.0" encoding="UTF-8"?>
<!-- OPML generated by BlogBridge 6.8 (http://www.blogbridge.com/) on Thu, 29 Dec 2011 10:09:07 EST -->
<opml xmlns:bb="http://blogbridge.com/ns/2006/opml" version="1.1">
<head>
<title>BlogBridge Feeds</title>
<dateModified>Thu, 29 Dec 2011 10:09:07 EST</dateModified>
</head>
<body>
<outline text="AllTop Aperture" bb:icon="cg.23.icon">
<outline type="rss" text="Comments on: Home" xmlUrl="http://photo.rwboyer.com/home/feed/" htmlUrl="http://photo.rwboyer.com"/>
@pitosalas
pitosalas / gist:1731032
Created February 3, 2012 16:41
Stackoverflow question
abstract class EntityA {
AssocA myA;
abstract void meet();
}
abstract class AssocA {
int something;
abstract void greet();
}
Processing PlansController#index (for 24.61.84.158 at 2012-03-02
17:53:48) [GET]
Session ID: 3105294042126eab3c6292d3ba224847
Parameters: {"controller"=>"plans", "action"=>"index"}
Rendering layoutfalseactionlist within layouts/standard
Rendering plans/list
Completed in 0.18974 (5 reqs/sec) | Rendering: 0.10813 (56%) | DB:
0.03900 (20%) | 200 OK [http://admin.blogbridge.com/]
file /tmp/ruby_sess.5684ebd33a502d9d not readable
/usr/local/rvm/rubies/ruby-1.8.7-p357/lib/ruby/1.8/pstore.rb:100:in
class ProgramServices
def initialize program
@prog = program
@result_code = nil
end
def smart_add_participant u_name, u_email, u_password
usr = find_or_add_user(u_name, u_email, u_password)
add_participant(usr)
@result_code
@pitosalas
pitosalas / gist:5454177
Created April 24, 2013 18:06
This is a simple bit of code that I think is ugly. I am looking for a suggestion on making it more idiomatic. Thanks!
def populate_todolist
progs = @user.participating_programs
@to_do_list = progs.map { |prog| build_todolist_row(prog) }
@to_do_list.compact!
end
# return nil if analysis yields no todolist row. compact! above removes the nil.
def build_todolist_row prog
rounds = prog.open_rounds
raise "more than one round open in ToDoList" if rounds.length > 1
Panic (system crashes) log:
Source: /Library/Logs/DiagnosticReports/Kernel_2013-07-25-133229_monster-6.panic
Size: 9 KB (8,803 bytes)
Last Modified: 7/25/13 1:32 PM
Recent Contents: Thu Jul 25 13:32:29 2013
Machine-check capabilities 0x0000000000001c09:
family: 6 model: 26 stepping: 5 microcode: 17
Intel(R) Xeon(R) CPU W3520 @ 2.67GHz
9 error-reporting banks
# Note to Ken: Interestng, you assume that the records after 8000 are test
# Also you add the 'test data' into both the base and the test set.
# Neither one is wrong, but they are assumptions that go beyond the specification. No need to fix.
def load_base_dataz
counter = 0
File.open(@base_path, "r").each_line do |line|
split_line = line.split # user_id, movie_id, rating, time_stamp
if counter < 80000 # read in base data first