January 2010
18 posts
2 tags
warning: strtotime() [function.strtotime]: It is...
php.ini file location on mac os x is /private/etc/php.ini
to fix this error:
warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone...
1 tag
Huffington Posts' Intense MySpace-like Full...
3 tags
Group ActiveRecord operations in a transaction
Stolen from: 10 Awesome Ruby on Rails Techniques to Get You Started
Group operations in a transaction: ActiveRecord wraps the creation or update of a record in a single transaction. Multiple inserts will then generate many transactions (one for each insert). Grouping multiple inserts in one single transaction will speed things up.
Insead of:
diners_in_nj.each do |d|
...
1 tag
Find All Large Files On A *Nix Machine
find / -type f -size +20000k -exec ls -lh {} \; | awk ‘{ print $8 “: ” $5 }’
2 tags
Continuous Testing With Unobtrusive System...
I tried to set up ZenTest and autotest-rails today, but I kept on getting these annoying errors:
/usr/local/lib/ruby19/1.9.1/pathname.rb:270: warning: `*' interpreted as argument prefix
/usr/local/lib/ruby19/gems/1.9.1/gems/ZenTest-4.2.1/lib/unit_diff.rb:100: warning: shadowing outer local variable - line
/usr/local/lib/ruby19/gems/1.9.1/gems/ZenTest-4.2.1/lib/unit_diff.rb:104: warning: shadowing...
3 tags
The One Click Plugin Updater WordPress Plugin, For...
As someone who stores user passwords as a salted SHA2 hash where one part of the salt is randomly-generated and stored in the database and the other part is hard-coded into the controller for an application that has 5 users and gets maybe 10 hits a day, I hate FTP. It is completely insecure and I refuse to install it on any of our servers, especially when SFTP is a part of SSH anyway. Problem...
1 tag
Mandala by The Rx Bandits
The digital download page offers a “standard hi quality mp3” section and a “nerds and audiophiles” section with options from FLAC to OGG VORBIS. Oh and you can listen to the whole thing online before buying it.
http://digital.rxbandits.com/album/mandala
Who are The Rx Bandits you ask? To quote the scholar, nervouswreck22, from the reputable primary source, You...
2 tags
Have You Seen Me? Domain Squatting Stock...
There’s this domain squatting company that uses this student stock photo on all one million of their squatted domains. I wonder if this girl realizes she is one of the most famous images on the Internets. Imagine if you ran into her in real life on the N train? THAT WOULD BE INTENSE.
1 tag
The ACES Train Sucks, Takes Longer Than Driving
The ACES Train from NY to AC takes longer than driving. Its hard to convince someone of the convenience and pollution impacts of taking a train when it takes longer than driving. COM’ON ‘MERICA your trains suck.
1 tag
Two Paragraphs of Lorem Ipsum
Don’t you hate that lipsum.com makes you choose 5 paragraphs and hit “Generate Lorem Ipsum” before giving you Lorem Ipsum? TAKE FOREVER. Now you can reference loremipsum.erictarn.com instead for all your ipsum needs.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque luctus elementum nisl, ullamcorper mollis nisi facilisis at. Vivamus ullamcorper enim at enim...
2 tags
4 tags
Refactoring your config/database.yml file
A less annoying database.yml file when you use the same database for all three environments
defaults: &defaults
adapter: mysql
encoding: utf8
reconnect: false
pool: 5
username: admin
password: welcome1
development:
database: friendster_dev
<<: *defaults
test:
database: friendster_test
<<: *defaults
production:
database: friendster
...
2 tags
3 tags
Fixtures for Ruby on Rails Testing
/test/fixtures/users.yml
<%
def auto_increment
@id ||= 0; @id += 1
end
%>
tommy:
id: <%= auto_increment %>
email: tommy@thedocks.com
created_at: <%= 6.months.ago.to_s(:db) %>
gina:
id: <%= auto_increment %>
email: gina@jerseydiner.com
created_at: <%= 1.minute.ago.to_s(:db) %>
/test/unit/user_test.rb
fixtures :users
def...
3 tags
Default Ruby on Rails Scaffold Code
Sometimes when things get crazy, you need to reference the default stuff.
class ArticlesController < ApplicationController
# GET /articles
# GET /articles.xml
def index
@articles = Article.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @articles }
end
end
# GET /articles/1
# GET /articles/1.xml
def show
...