This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Generate iPhone Models" | |
task :objective_resource_skeleton => :environment do | |
output_path = "#{Rails.root}/doc/iphone_models" | |
#get all our models | |
model_files = Dir.glob("#{Rails.root}/app/models/*.rb").each { |file| require file } | |
models = Object.subclasses_of(ActiveRecord::Base).select { |model| | |
File.exist?("#{Rails.root}/app/models/#{model.name.underscore}.rb") | |
} | |
#make sure our output path exists | |
FileUtils.mkdir_p(output_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Methods added to this helper will be available to all templates in the application. | |
module DmdHelper | |
def admin_logged_in? | |
#TODO figure out if admin_logged_in | |
true | |
end | |
def title(page_title, show_in_body=true, &block) | |
content_for(:title) { page_title } | |
if show_in_body | |
heading = block_given? ? capture(&block) : content_tag(:h1,page_title.split(' // ').last) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!!! Strict | |
%html | |
%head | |
%title=yield(:title) || "FIXME: Default Title" | |
= stylesheet_link_tag 'general', 'dashboard', 'tables', 'pagination', 'forms', 'tooltips', 'widgets', :cache => "cache/all" | |
= javascript_include_tag :defaults, :cache => "cache/all" | |
= "<!--[if IE]>#{stylesheet_link_tag 'ie', :media => 'screen'}<![endif]-->" | |
= javascript_include_tag *@behaviours if @behaviours | |
%script{:type => "text/javascript"}= "rails_authenticity_token = '#{form_authenticity_token}';" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
raise "Don't use this, use the dropbox template!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'directory_watcher' | |
require 'fileutils' | |
require 'growl' | |
# require 'ruby_gntp' | |
SOURCE = "http://172.16.187.5/img/mjpeg.cgi" #URL source of your video stream | |
#SOURCE = "http://172.16.187.5/img/video.asf" #URL source of your video stream | |
INTERVAL = 2 #seconds between frame grabs | |
FUZZ = 10 #fuzz for dealing with lossy jpgs | |
MIN_DELTA = 5 #delta required to cause a notification to occur |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scope :summarized_by_app_and_date, select("app_id, occurred_on, count(*) as count,sum(total) as total").group("app_id, occurred_on").order("app_id, occurred_on") | |
def self.chart_data(conditions_or_scope) | |
if conditions_or_scope.is_a?(ActiveRecord::Relation) | |
totals = conditions_or_scope.summarized_by_app_and_date.all | |
else | |
totals = where(conditions_or_scope).summarized_by_app_and_date.all | |
end | |
totals.inject({:count => {}, :total => {}}) do |h,t| | |
h[:count][t.app_id] ||= [] | |
h[:total][t.app_id] ||= [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
was_down = false | |
while true | |
t = Time.now.strftime("%l:%M:%S%p") | |
result = `ping -c 1 www.google.com 2>&1` | |
if result !~ /1 packets received/ | |
puts "Check at #{t} -- DOWN!" | |
if was_down | |
#don't repeat the notification if we're still down | |
`say "Internet down!"` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print "version1:";STDOUT.flush | |
v1 = gets.strip.split(".").map(&:to_i) | |
print "\nversion2:";STDOUT.flush | |
v2 = gets.strip.split(".").map(&:to_i) | |
diff = v1 <=> v2 | |
puts "v1 < v2" if diff < 0 | |
puts "v1 = v2" if diff == 0 | |
puts "v1 > v2" if diff > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"commits"=> | |
[{"distinct"=>true, | |
"timestamp"=>"2011-06-22T11:53:30-07:00", | |
"message"=>"fix logger", | |
"committer"=> | |
{"username"=>"coreymartella", | |
"email"=>"[email protected]", | |
"name"=>"Corey Martella"}, | |
"url"=> | |
"https://github.com/coreymartella/rails-footnotes/commit/326e01151a314c7808e4744ae1f2cce909d0c044", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
###### | |
# To Install | |
# sudo wget https://raw.github.com/gist/2579234/git-commiturl -O /usr/local/bin/git-commiturl | |
# sudo chmod +x /usr/local/bin/git-commiturl | |
# | |
# To use | |
# git commiturl # gets the HEAD commit hash and copies a github url for it | |
# git commiturl -c 3dfcb4e7143d0c200e980ee2f65759157e066651 -o #copies a url for a specific commit hash AND opens it in your local browser |
OlderNewer