Skip to content

Instantly share code, notes, and snippets.

badstudents = Portal::Student.all.select { |s| s.user.nil? }
# => [] # no students were "bad"
badteachers = Portal::Teacher.all.select { |t| t.user.nil? }
# => teacher id 1447 # one bad teacher was found
badclazzes = Portal::Clazz.all.select { |c| c.teacher.nil? }; badclazzes.size
# => 4631 FOUR THOUSAND ++ CLASSES WITH NO TEACHER!!!!
@knowuh
knowuh / gist:965099
Created May 10, 2011 18:37
mysystem authoring json
{
"type": "Mysystem_sc",
"prompt": "What do you want to do?",
"modules": [
{
"name": "heater",
"icon": "http://dl.dropbox.com/u/73403/mysystem/images/burner-transp-70.png",
"image": "http://dl.dropbox.com/u/73403/mysystem/images/burner-transp-70.png",
"xtype": "MySystemContainer",
"etype": "source",
{
"type": "Mysystem_sc",
"TODO": "Be sure to add the necessary fields to this JSON file for your new step type, a copy of the contents of this file will be copied to the new step file when an author creates a new instance of your step in the authoring tool, you may delete this TODO field",
"prompt": "What do you want to do?",
"modules": [
{
"name": "thing",
"icon": "http://upload.wikimedia.org/wikipedia/commons/thumb/d/d8/Bongo.jpg/120px-Bongo.jpg",
"image": "http://upload.wikimedia.org/wikipedia/commons/thumb/d/d8/Bongo.jpg/120px-Bongo.jpg",
"xtype": "MySystemContainer",
@knowuh
knowuh / gist:952174
Created May 2, 2011 19:15
silly unique name
# TODO: The next two methods can be extracted to
# a more general form: (write tests too)
def self.name_is_taken(name)
return true if self.find_by_name(name)
return false
end
def self.gen_unique_name(name)
while self.name_is_taken(name)
number = name[/\d+$/]
if number
** [out :: itsisu.dev.concord.org] 158/186 completed (28 failed, 0 aborted)
** [out :: itsisu.dev.concord.org] 65: failed: Could not find object in the DIY
** [out :: itsisu.dev.concord.org] 60: failed: Could not find object in the DIY
** [out :: itsisu.dev.concord.org] 62: failed: Could not find object in the DIY
** [out :: itsisu.dev.concord.org] 38: failed: Could not find object in the DIY
** [out :: itsisu.dev.concord.org] 36: failed: Could not find object in the DIY
** [out :: itsisu.dev.concord.org] 37: failed: Could not find object in the DIY
** [out :: itsisu.dev.concord.org] 29: failed: Could not find object in the DIY
** [out :: itsisu.dev.concord.org] 40: failed: Could not find object in the DIY
** [out :: itsisu.dev.concord.org] 41: failed: Could not find object in the DIY
@knowuh
knowuh / migrations_missing_files.rb
Created April 28, 2011 18:59
Where did these migrations come from?
def migrations_without_files
results = ActiveRecord::Base.connection.execute("select * from schema_migrations;")
migrations = []
results.each { |r| migrations << r }
migrations.flatten!.map!{ |m| m.gsub(/[^\d]*/,"")}
migrate_path = File.join(RAILS_ROOT,"db","migrate","*.rb")
files = Dir.glob(migrate_path).map{ |f| f.gsub(/.*\/(\d+)_.*/, '\1') }
missing_files = migrations.reject { |m| files.include?(m) }
end
>> installer_schools.each { |s| puts "#{s.id}\t#{s.name}\t#{s.settings.size}" };nil
5 Hugh B. Bain Middle School 1
13 Coventry High School 1
14 Alan Shawn Feinstein Middle School Of Coventry 1
15 Scituate Middle School 1
16 Scituate High School 1
Rites Investigations School 2010-07-22 14:13:55 UTC
Cranston High School East 2010-07-22 14:13:55 UTC
Lincoln Middle School 2010-07-22 14:13:55 UTC
Woonsocket High School 2010-07-22 14:13:55 UTC
Coventry High School 2010-07-22 14:13:55 UTC
Scituate Middle School 2010-07-22 14:13:55 UTC
Scituate High School 2010-07-22 14:13:55 UTC
Central Falls High School 2010-07-22 14:13:55 UTC
Chariho High School 2010-07-22 14:13:55 UTC
Chariho Middle School 2010-07-22 14:13:55 UTC
@knowuh
knowuh / gist:859140
Created March 7, 2011 20:23
MavenJnlp::VersiondJnlpUrl returning the wrong href?
I delete all jnlp resources using the rake task
"rake rigse:jnlp:delete_maven_jnlp_resources "
Then I try and get the default jnlp_url:
ruby> jnlp_url = @jnlp_family.versioned_jnlp_urls.find_by_version_str(default_version_str)
=> nil
Looks good, its not there.
<entry key="8599c6f8-4a6a-11de-a667-001ec94098a1!/image_question_27/input">
<OTLabbookEntryChooser>
<embeddedEntries>
<OTLabbookEntry timeStamp="March 4 at 3:52" note="Testing" type="Drawings">
<oTObject>
<object refid="625c9b63-46a1-11e0-9e0b-b7d402e88e50" />
</oTObject>
</OTLabbookEntry>
<OTLabbookEntry timeStamp="March 7 at 9:49" note="blah" type="Drawings">