Tags
webcam vindaloo vim version vegan unix unicef trojan todo tmux thinkpad textmate testing tagging syntax svn sugar subversion stubbing sphinx spam spaces solaris sitemap site sinatra shoulda sheet set security search schema_info SchemaInfo ruby rinari restaurant relationships refresh rdiff-backup ramaze railsconf08 railsconf07 rails protools production power placeboeffect pink floyd PIC perl overheat outbreak osx os x NYHS NYC nginx netbeans nested nanophotonics mysql music MPEG-4 mongrel model migration microvolunteer macbook mac logrotate logic log linux less leopard keynote JAX javascript java jacksonville iterm2 iterm imunizator highlighting hanna Handbrake haml hacks google geocoding genghistron gem gaming gabrielle's funny functional fun friends food fixesLatest Blog Activity From The Decider
The Decider said over 3 years ago permalink Comment? (0)
Tagged: ruby logic
De Morgan, Ruby
#De Morgan the Ruby way
[true,false].each do |p|
[true,false].each do |q|
puts "p=#{p} q=#{q}"
if !(p or q) == (!p and !q)
puts "De Morgan Rules! !(p or q) == (!p and !q)"
else
puts "De Morgan is a Liar!"
end
# if find yourself writing
if !p and !q
print "-"
# you could be writing
unless p or q
puts "if !p and !q equivalent to unless p or q"
end
end
if !(p and q) == (!p or !q)
puts "De Morgan Rules! !(p and q) == (!p or !q)"
else
puts "De Morgan is a Liar!"
end
# if find yourself writing
if !p or !q
print "-"
# you could be writing
unless p and q
puts "if !p or !q equivalent to unless p and q"
end
end
end
end
The Decider said over 3 years ago permalink Comment? (0)
Tagged: testing shoulda
Run individual shoulda tests
When you run tests of just one model or controller you usually do something like:
ruby test/unit/evaluation_test.rb
If you want to target just one test you can use the -n option
ruby test/unit/evaluation_test.rb -n test_return_pending_evaluatees_from_composite_group
For shoulda users if you want to target just one test the -n option can also take regular expressions.
ruby test/unit/evaluation_test.rb -v -n "/have many/"
The -v lists the test name before every test, aka verbose mode.
The Decider said over 3 years ago permalink Comment? (0)
Tagged: spam site
Please Spam This Post
Just updated the code to detect the spamming bastards. Let’s see if it works.
The Decider said over 4 years ago permalink Comment? (0)
Tagged: ruby rails bdoc hanna
Pretty Local Rdoc
From the RubyInside site a couple of gems to make your local rdocs look and behave nicer.
To reap the benefits:
sudo gem install mislav-hanna sudo gem install manalang-bdoc sudo hanna —gems bdocThe Decider said over 4 years ago permalink Comment? (0)
Tagged: rails mongrel ruby nginx
Protect Staging Server with Password
When developing a new application and releasing often you may want to protect the site from prying eyes. A simple way to do this when using the nginx web server is to use basic http authentication.
I prefer to do this in the nginx config file so it doesn’t impact local development.
You’ll need to create a password file using htpasswd command line utility. This file should be relative to the install directory of nginx. The default install would place this file in /usr/local/nginx
sudo htpasswd -cb /usr/local/this_hosts_password_file username passwordNext, you need to tell nginx to use basic auth for any access to this (virtual) host. I place the 2 relevant lines in the server portion of the config file
server { listen 80;- …
auth_basic “Login to see this alpha site.”;
auth_basic_user_file this_hosts_password_file; - …
}
A login will now be presented for any entry into the site.
