Skip to content

Instantly share code, notes, and snippets.

I’ve installed daemon_generator to my app running a fairly recent edge rails. It works fine until I try to use ActiveRecord in the daemon:
while($running) do pp User.all sleep 10 end
$ lib/daemons/twitterusers_ctl run /home/logankoester/projects/paul/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:212:in `log’: NoMethodError: undefined method `ms’ for Benchmark:Module: SELECT * FROM “users” (ActiveRecord::StatementInvalid) from /home/logankoester/projects/paul/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:132:in `execute’ from /home/logankoester/projects/paul/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:372:in `catch_schema_changes’ from /home/logankoester/projects/paul/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:132:in `execute’ from /home/logankoester/projects/paul/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:275:in `sel
@logankoester
logankoester / enumerable_elements.rb
Created March 15, 2009 03:42
Element access in an enumerable
module Enumerable
# Return elements after the first x
def enum_after(x)
a = 0
self.partition{ a += 1; a < (x + 1) }.last
end
# Return elements with keys between x and y
def enum_between(x,y)
self.reject{|(k,v)| k < (x + 1) || (y - 1) < k }
@logankoester
logankoester / :'( How lonely.rb
Created April 8, 2009 01:03
The saddest code I wrote today
User.each do |user|
user.friends.each do |friend|
t = Twitter::Client.new(:login => user.screen_name, :password => user.password)
t.defriend(friend.friend_id)
friend.destroy
end
end
@logankoester
logankoester / Hash_to_html_attrs.rb
Created June 7, 2009 04:03
Useful for implementing the html_options hash argument on non-rails erb helpers
class Hash
def to_html_attrs
# Useful for implementing the html_options hash argument on non-rails erb helpers
attrs = Array.new
self.each_pair {|k,v| attrs.push "#{k}=\"#{v}\""}
return attrs.join " "
end
end
An apple and a berry plant,
Comes with a house.
On the grass - who is that,
Who comes by my house?
Stands outside my window,
Sucking on the berries and
Eats us out of house and home.
Keeping us awake...
Keeping us awake.
<script type="text/javascript" src="js/bgrotate.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#bgcontainer').bgrotate({
delay: 2,
speed: 'fast',
url: 'images/images.txt'
});
});
</script>
# ...
namespace :bundler do
task :create_symlink, :roles => :app do
shared_dir = File.join(shared_path, 'bundle')
release_dir = File.join(current_release, '.bundle')
run("mkdir -p #{shared_dir} && ln -s #{shared_dir} #{release_dir}")
end
task :bundle_new_release, :roles => :app do
@logankoester
logankoester / bundler_cap.rb
Created August 21, 2010 06:27 — forked from richievos/bundler_cap.rb
Bundler integration for Capistrano
namespace :bundler do
task :install, :roles => :app, :except => { :no_release => true } do
run("gem install bundler --source=http://rubygems.org")
end
task :create_symlink, :roles => :app do
shared_dir = File.join(shared_path, 'bundle')
release_dir = File.join(current_release, '.bundle')
run("mkdir -p #{shared_dir} && ln -fs #{shared_dir} #{release_dir}")
end
master [logankoester-agora::mlg-tv@17:05:34]>bundle list | grep errship
* errship (0.3.0 397d2f5)
master [logankoester-agora::mlg-tv@17:04:26]>ruby -r errship
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- errship (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
master [logankoester-agora::mlg-tv@17:05:13]>ruby -r rails -e ""
master [logankoester-agora::mlg-tv@17:05:47]>
@logankoester
logankoester / gist:1043026
Created June 23, 2011 17:14
jQuery Mobile form element gallery as haml
.content-primary
%form{:action => "#", :method => "get"}
%h2 Form elements
%p This page contains various progressive-enhancement driven form controls. Native elements are sometimes hidden from view, but their values are maintained so the form can be submitted normally.
%p Browsers that don't support the custom controls will still deliver a usable experience, because all are based on native form elements.
.ui-field-contain.ui-body.ui-br{"data-role" => "fieldcontain"}
%label.ui-input-text{:for => "name"} Text Input:
%input#name.ui-input-text.ui-body-null.ui-corner-all.ui-shadow-inset.ui-body-c{:name => "name", :type => "text", :value => ""}/
.ui-field-contain.ui-body.ui-br{"data-role" => "fieldcontain"}
%label.ui-input-text{:for => "textarea"} Textarea: