Skip to content

Instantly share code, notes, and snippets.

Logan Koester logankoester

Block or report user

Report or block logankoester

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View daemon_generator causes ActiveRecord errors in edge rails
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 Mar 15, 2009
Element access in an enumerable
View enumerable_elements.rb
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 Apr 8, 2009
The saddest code I wrote today
View :'( How lonely.rb
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 Jun 7, 2009
Useful for implementing the html_options hash argument on non-rails erb helpers
View Hash_to_html_attrs.rb
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
View Fever Ray - Triangle Walks
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.
View bgrotate_example.html
<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>
View deploy.rb
# ...
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 Aug 21, 2010 — forked from richievos/bundler_cap.rb
Bundler integration for Capistrano
View bundler_cap.rb
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
View gist:1032356
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 Jun 23, 2011
jQuery Mobile form element gallery as haml
View gist:1043026
.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:
You can’t perform that action at this time.