Expression Engine
Friday July 31, 2009 at 6:17pm
I am going to use this post to track the occasions when I get inexplicable blank screens in Expression Engine.
Issue #1 - Relative Date plugin syntax error
Symptoms: After adding the first entry to a weblog I would get a blank screen. If I changed the status of the entry to Closed, the page would be ok. If I opened it again it would be blank. No debug messages would show.
Resolution: My templates rely on the relative_dates plugin. The syntax of the plugin was incorrect. Line one of the file was <? but should have been <?php. This thread on the Expression Engine forum got me jump started on resolving the issue.
Expression Engine
Linux
Tuesday July 14, 2009 at 4:56pm
I want the path on my Mac dev environment to match the path on my Linux server (I am doing this for ExpressionEngine, where it’s much easier to deploy to different servers if the paths match).
My Linux server path starts with /home/myusername. Unfortunately, in Mac Leopard the /home directory is not editable, so I cannot put my files in the directory I need.
I found a solution buried in an Apple support forum message. The solution is to comment out an entry in the the auto_master file.
Here are the steps:
- edit the file: /etc/auto_master
- comment out this line: # /home auto_home -nobrowse
- save & reboot
After reboot the /home directory acted like I expected and now I have my ExpressionEngine files where I need them.
Expression Engine
Wednesday June 24, 2009 at 6:47pm
I started using David Rencher’s handy Relative Date plugin for ExpressionEngine.
Here is an example output:
About 1 week, 2 days, 21 hours, 13 minutes ago
The formatting comes from a php function called Localize::format_timespan. It would be great for doing a count down timer to some event, but it is not so great for displaying the age of a blog post.
I was looking for a formatting method in PHP that behaves like the time_ago_in_words method in Rails. I found it here: http://snippets.dzone.com/posts/show/5658. Sweet.
So, I modified the original relative_date plugin to use the new method.
Here is the new output:
About 10 days ago
You can download the new file here: pi.relative_date_.php_.zip.
Linux
Sunday June 14, 2009 at 6:59pm
I am using capistrano to deploy to a dedicated server. It has been working fine for days, then last night it stopped working.
I investigated the trace and saw this error:
| git: 'index-pack' is not a git-command. See 'git --help'. |
fatal: index-pack failed |
|
So, I signed in to the server and tried to run a few variations of fetching and cloning my repository and other public repositories and got the same error.
Then I decided to sign in as root and another normal user. Those users were able to do git commands with no problems.
After a bunch of work trying to find the difference I discovered that my failing user had:
| echo $SHELL |
/usr/local/cpanel/bin/jailshell |
|
whereas my other users had:
So, I signed in as root and changed my user’s shell to bash and now everything works just fine:
| ssh root@xxx.xx.xx.xx |
chsh -s /bin/bash username |
|
RubyCocoa
TwitterGrowl
Thursday April 02, 2009 at 12:45am
I started with code from visnup for pushing friends’ tweets to Growl called TwitterGrowl.
Then I added a few features using RubyCocoa and Growl Notifier:
- track custom search terms
- click on notifications, go to Twitter
- customize the look of friend versus search tweets from the growl preferences panel
- run TweetGrowl as a startup item
The code is available at github.
MySQL
Friday March 13, 2009 at 7:35pm
I often forget how to create a user in MySQL.. Here it is:
| grant all privileges on *.* to 'landlessnesss'@'localhost' \ |
identified by 'abc123def' with grant option; |
|
flush privileges; |
|
Ruby on Rails
Thursday November 20, 2008 at 7:40am
In Rails I wanted to display times like 2:30 am without having a leading zero like 02:30 am.
The view code that gave leading zeros looked like this:
| <%= foo.updated_at.strftime("%I:%M %p") %> |
|
The code that will trim leading zeros looks like this:
| <%= foo.updated_at.to_datetime.strftime("%-1I:%M %p") %> |
|
The trick is to convert the time object from ActiveSupport::TimeWithZone to DateTime, which supports prefix modifiers like ‘-1’ in the format expression.
History of Computing
Thursday November 20, 2008 at 3:46am
Arthur W. Burks, a member of the team that designed the Eniac computer, a frequent collaborator of John von Neumann and a pioneer in computing education, died Wednesday [May 14th, 2008] at a nursing home in Ann Arbor, Mich. He was 92.
-The New York Times
I had the opportunity to work for Professor Burks for a number of years. I worked for him at his home. His wife, Alice, an author, used to make me sandwiches each time I visited. He was a genuinely nice man, who taught me much about the history of computing.
Rest in peace, Professor Burks.
Foreign Domain Routing
Thursday November 13, 2008 at 12:24am
I just published Foreign Domain Routing plugin at github:
http://github.com/brianmulloy/foreign-domain-routing
Ruby on Rails
Thursday November 06, 2008 at 1:55pm
I am using restful_authentication and want to extend it with functionality to invite a person using only his email. So, I wanted the ability to validate just one attribute of a model. Expressia::Blog described the same problem here and had built the plugin I wanted. Only all the links to the plugin pointed back to the original post. I eventually found the plugin install and usage documentation here at RailsLodge.
| ruby script/plugin install svn://vinsol.com/plugins/sur/validate_attributes |
|
Now, my relevant code looks like this:
| @person.validate_attributes(:only => ['email']) |
|
Ruby on Rails
Tuesday October 28, 2008 at 9:38pm
Here are the steps I took to install restful_authentication with acts_as_state_machine (using the new aasm gem) as plugins.
Started in the rails home directory of the app.
Installed aasm gem as a plugin:
| script/plugin install git://github.com/rubyist/aasm.git |
|
(thanks to Erik on Rails for the above)
Installed restful authentication:
| git submodule add \ |
git://github.com/technoweenie/restful-authentication.git \ |
vendor/plugins/restful_authentication |
|
I use capistrano so I also added the following to my config/deploy.rb file
| set :git_enable_submodules, 1 |
|
Created a lib directory in the app home directory:
Called the restful authentication generator. Fyi, instead of user, I use person as the name of my model for people:
| ./script/generate authenticated person sessions --include-activation --aasm |
|
Then I did the post-generate steps, following some of the instructions at github. Some of the steps enumerated in the docs seem to be taken care of as part of the generate call now.
In config/routes.rb, I did a find/replace on peoples (incorrect plural) replacing all with people (correct plural) and added the activate route. In the end my routes.rb looked like this:
| map.logout '/logout', :controller => 'sessions', :action => 'destroy' |
map.login '/login', :controller => 'sessions', :action => 'new' |
map.register '/register', :controller => 'people', :action => 'create' |
map.signup '/signup', :controller => 'people', :action => 'new' |
map.activate '/activate/:activation_code', :controller => 'people', |
:action => 'activate', :activation_code => nil |
map.resources :people, :member => { :suspend => :put, |
:unsuspend => :put, |
:purge => :delete } |
|
In config/environment.rb, I added:
| config.active_record.observers = :person_observer |
|
So I can use before filters in my controllers, I modified app/controllers/application.rb to include AuthenticatedSystem:
| class ApplicationController < ActionController::Base |
helper :all |
include AuthenticatedSystem |
end |
|
I adjusted the language in app/models/person_mailer.rb, especially replacing the YOURSITE references to be the URL of my site:
| @body[:url] = |
"http://www.landlessness.net/activate/#{person.activation_code}" |
|
Linux
Friday October 10, 2008 at 7:45am
I am using a hosting service, which doesn’t allow me sudo access. Yet I want to install additional fonts.
I don’t recall all the steps I did, but I got it working. First, I installed fontconfig in under my home directory, such that:
| $ which fc-list |
~/bin/fc-list |
|
then when I want to install new fonts I copy the ttf file to the ~/.fonts directory like:
| $ scp Georgia.ttf user@myurl.com:~/.fonts/g.ttf |
Georgia.ttf 100% 146KB 73.1KB/s 00:02 |
|
then in order to reset the font cache I run
| $ fc-cache -v ~/.fonts |
fc-cache: "/home/me/.fonts": skipping, 6 fonts, 0 dirs |
fc-cache: succeeded |
|
then when I run fc-list, I’ll see my new font in the list
| $ fc-list |
Georgia:style=Regular |
|
Ruby on Rails
Friday October 10, 2008 at 4:14am
In verbose_index.html.erb i want to pass some additional parameters to the _thing.html.erb partial:
| <% @things.each do |thing| %> |
<%= render :partial => thing, |
:locals => {:some_extra_stuff => some_extra_stuff} %> |
<% end %> |
|
in index.html.erb i do not want to pass any additional parameters to the _thing.html.erb partial:
| <%= render :partial => things %> |
|
when I hit verbose_index everything will work fine. but when I hit index, I’ll see this error:
| undefined local variable or method 'some_extra_stuff' |
for #<ActionView::Base:0x22e6948> |
|
to fix, in _thing.html.erb I add a check to see if the local variable is assigned:
| <% unless local_assigns[:some_extra_stuff].nil? %> |
<%= some_extra_stuff %> |
<% end %> |
|
Capistrano
Friday October 10, 2008 at 2:55am
I have been wrestling with capistrano and git, when I ran the following I got an error:
| $ cap deploy:check |
could not find any SCM named `git' |
|
I ran ‘which git’ by hand on both my local box and remote box.
on the remote box:
| $ which git |
/usr/local/bin/git |
|
on the local box:
| $ which git |
/usr/local/git/bin//git |
|
not sure what the issue was, but I tried to set the following in my deploy.rb without success:
| set :local_scm_command, "/usr/local/git/bin/git" |
set :scm_command, "/usr/local/bin/git" |
|
ultimately, my fix was to uninstall and reinstall git on my local machine.
now on the local box:
| $ which git |
/usr/local/bin/git |
|
now
| $ cap deploy:check |
You appear to have all necessary dependencies installed |
|
Sonoa
Sunday September 28, 2008 at 5:38pm
How to issue a SOAP request (to Sonoa’s ServiceNet) using cURL from the command line:
shell command:
| curl \ |
-H "SOAPAction: urn:getCustomerDetails" \ |
-H "Content-Type: text/xml" \ |
-d "@getCustomerDetails.xml" \ |
http://192.168.96.132:8080/samples/services/CustomerInfoService |
|
where getCustomerDetails.xml is a file in the current directory.
getCustomerDetails.xml:
| <soapenv:Envelope |
xmlns:soapenv= |
"http://schemas.xmlsoap.org/soap/envelope/" |
xmlns:cus= |
"http://www.sonoasystems.com/schemas-samples/2007/1/26/customer"> |
<soapenv:Header/> |
<soapenv:Body> |
<cus:getCustomerDetails> |
<cus:customerID>12</cus:customerID> |
</cus:getCustomerDetails> |
</soapenv:Body> |
</soapenv:Envelope> |
|
shell output:
| 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | | 9 | | 10 | | 11 | | 12 | | 13 | | 14 | | 15 | | 16 | | 17 | | 18 | | 19 | | 20 | | 21 | | 22 | | 23 |
| <?xml version='1.0' encoding='UTF-8'?> |
<soapenv:Envelope |
xmlns:soapenv= |
"http://schemas.xmlsoap.org/soap/envelope/"> |
<soapenv:Header /> |
<soapenv:Body> |
<getCustomerDetailsResponse |
xmlns= |
"http://www.sonoasystems.com/schemas-samples/2007/1/26/customer"> |
<return> |
<customerID>12</customerID> |
<shipToAddress> |
<city>City 12</city> |
<country>USA</country> |
<name>Name 12</name> |
<state>CA</state> |
<street>Street 12</street> |
<zip>Zip 12</zip> |
</shipToAddress> |
</return> |
</getCustomerDetailsResponse> |
</soapenv:Body> |
</soapenv:Envelope> |
|
Sonoa
Friday September 26, 2008 at 5:42pm
I am checking out Sonoa System’s ServiceNet product.
http://www.sonoasystems.com/
Expression Engine
Thursday September 25, 2008 at 10:26pm
I wanted to display the category of an entry so that the end result would look like the following, where Ruby on Rails is the category:
RUBY ON RAILS
Scaling ActiveRecord
Thursday September 25, 2008 at 10:26pm
I couldn’t find any examples, but the snippets in TextMate helped me out. Here is the code:
| 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | | 9 | | 10 | | 11 | | 12 | | 13 | | 14 | | 15 | | 16 | | 17 |
| {exp:weblog:entries weblog="posts"} |
<div class="post"> |
<h3> |
{categories weblog="posts"} |
{category_name} |
{/categories} |
</h3> |
<h2> |
<a href="{title_permalink="posts/view"}"> |
{title} |
</a> |
</h2> |
<div class="post-date"> |
{gmt_entry_date format="%l %F %d, %Y at %g:%i%a"} |
</div> |
</div> |
{/exp:weblog:entries} |
|