Skip to content

Instantly share code, notes, and snippets.

View iHiD's full-sized avatar
💙

Jeremy Walker iHiD

💙
View GitHub Profile
@iHiD
iHiD / spec.md
Created August 27, 2012 20:12
Family Tree

Specification

Models

Person

  • Name
  • Picture
  • DOB
  • DOD
@iHiD
iHiD / New.rb
Created September 11, 2012 16:22
Sketchup
def self.stringify(input)
if input.is_a? String
input.dump
elsif input.is_a? Array
"[" + input.collect{|object| stringify(object)}.join(",") + "]"
elsif input.is_a? Hash
"{" + input.to_a.collect{|key,value| "#{stringify(key)}:#{stringify(value)}"}.join(",") + "}"
elsif input.is_a? Symbol
input.to_s.dump
else
@iHiD
iHiD / post-commit
Created September 21, 2012 13:47 — forked from consti/post-commit
Take a photo of you, whenever you make a commit
#!/bin/sh
#
# Take a photo of you, whenever you make a commit
#
# This is an improved version of Víctor Martínez original post:
# http://coderwall.com/p/xlatfq
#
# Improvements:
@iHiD
iHiD / blog_post.rb
Created February 10, 2013 18:31
When the hard work pays off... A complex model, fully integrated into Meducation with basically no thought. Meducation is so easy now-a-days! :)
class BlogPost < ActiveRecord::Base
can_generate_reputation
has_comments
has_views
has_votes
has_news_feed_item
is_a_contribution
is_a_resource
is_cacheable
has_markdown
@iHiD
iHiD / gist:5230062
Created March 24, 2013 01:34
Rubinius Crash Report
==================================== ERROR ====================================
| An extension is trying to add an invalid handle at the following location: |
| v8_handle.cpp:31 |
| |
| An invalid handle means that it points to an invalid VALUE. This can happen |
| when you haven't initialized the VALUE pointer yet, in which case we |
| suggest either initializing it properly or otherwise first initialize it to |
| NULL if you can only set it to a proper VALUE pointer afterwards. Consider |
| the following example that could cause this problem: |
| |
@iHiD
iHiD / fixtures.coffee
Last active December 15, 2015 14:59
Ember Stuff.
Meducation.MediaFile.FIXTURES = [
{
id: 8
title: 'Abdominal Ultrasound Tutorial'
description: "A tutorial about how to read an abdominal ultrasound video. Produced to give medical students just a better idea of what to expect."
image_src: "https://d589j1w8ayj7e.cloudfront.net/attachments/media_files/previews/8.jpg"
user: 1
high_quality_url: "http://www.meducation.net/media_files/8/high_quality"
media_type_id: 3
}
# Retrieve a belongsTo association
favourite = @get 'user_favourite'
# I'd like to do the following but it makes the
# record dirty, as user_favourite has changed.
# I really don't want user_favourite being tracked,
# But I want to get it with the initial JSON.
favourite.destroyRecord()
Meducation.store.commit()
@iHiD
iHiD / gist:5347251
Created April 9, 2013 16:38
Tim's importer
rows = CSV.do_stuff_here
rows.each do |row|
user = User.new
user.name = row[:name]
user.mobile = ""
user.email = row[:email]
user.password = row[:password]
user.admin = true
@iHiD
iHiD / creator.rb
Last active December 20, 2015 10:18
Group Discussion Creator
class Creator
class << self
def create!(*args)
create(*args).tap do |object|
raise ActiveRecord::RecordInvalid.new(object) if object.new_record?
end
end
end
end
@iHiD
iHiD / test_with_io.rb
Last active December 25, 2015 09:09
Event Machine Test - Checking performance between EventMachine and the underlying Threads. My results show that for 1.9.3, EventMachine executes MUCH faster than the just using Thread.new. However, for 2.0.0 and Rubinius, using Thread.new seems to be the same or marginally faster. https://github.com/eventmachine/eventmachine/search?q=Thread.new&…
require 'eventmachine'
def write_file(text)
filename = "/Users/iHiD/Desktop/dump.txt"
File.open(filename, 'w') do |f|
f.flock(File::LOCK_EX)
f.write(text)
sleep 0.005
end
end