Archive for April, 2008

HTML Ampersand & Character codes

HTML Ampersand & Character code

more character codes

Javascript newsticker

For a sharp looking javascript news ticker go with bartelme.

Accessible JavaScript Newsticker

attachment_fu plugin

attachment_fu plugin seems the choice of file uploading. it is the rewritten version of acts_as_attachment

Just follow these instructions and you should be good to go: http://clarkware.com/cgi/blosxom/2007/02/24

In most cases, you will probably want to add multiple image/files to a post/page/applicationform/etc so I would recommend following the clarkware tutorial above, and then doing a has_many and belongs_to with the necessary form structure to add images/files to your form and its model.

Deleting files To delete files using attachment_fu plugin you can do the following if they are associated with something else. code

PRODUCTION Also, there is a good chance that attachment_fu will not work in production mode, and kick out some difficult to discover error. Here?s the solution

Also, the folder will get removed on deployment. Here?s a tutorial to help solve that problem

Here is what the end of my deploy.rb file looks like. My attachment_fu images are stored in public/attachments/

desc 'Fix attachment_fu'
task :fix_attachment_fu, :roles => :app do
  %w{attachments}.each do |share|
    run "rm -rf #{release_path}/public/#{share}"
    run "mkdir -p #{shared_path}/system/#{share}"
    run "ln -nfs #{shared_path}/system/#{share} #{release_path}/public/#{share}"
  end
end

desc "Reload Nginx"
task :reload_nginx do
  sudo "/etc/init.d/nginx reload"
end

desc "Restart Thin"
task :restart_thin do
  sudo "/etc/init.d/thin restart"
end

after "deploy", "deploy:cleanup"
after "deploy:cleanup", "fix_attachment_fu"
after "fix_attachment_fu", "reload_nginx"
after "reload_nginx", "restart_thin"

Helper Method

This is how to create a helper method. Put this in your application controller - from building a multisite

            helper_method :current_site
private
def current_site
    @current_site = Site.find(:first)
end

Git command list

Here’s a helpful wiki

  • git init
  • git status
  • touch .gitignore
  • git add .
  • git commit -a
  • git add
  • git branch <? to check available branches
  • git branch [new_branch_name] <? to create a new branch
  • git co [branch]
  • git remote add origin git@github.com:scottmotte/lilruby.git
  • git push origin master
  • git clone
  • git push
  • git pull
  • get pull origin [branch name]
  • git fetch / git merge <? basically git pull combined
  • git diff master human <? see the human changes that will be added to master
  • git diff master human | mate <? pipes it to text editor
  • git branch -d [branch name] <? deletes a branch

For merging

  1. git co master <?go into the branch you want to merge into
  2. (use the other branch to pull the changes you made on that other branch into master)
  3. git merge human <? then just do git merge [branch name]

For rebasing 1. git co master <? go into the branch you want to rebase into 2. (use the other branch to pull the changes you made on that other branch (your name e.g. ryan or scott into master) 3. git rebase scott <? then just do git rebase [branch name]

For pulling Pulling is also a merge so make sure you are on the master when you are pulling something in.

For conflicts git diff

.gitignore file

These are some of the things I usually like to ignore:

  • .DS_Store
  • index/*
  • public/attachments/*
  • log/*.log

deleting a branch on github Stop tracking a remote branch git branch -d -r origin/< remote branch name >

from here: link

Rails 2.0 command list

This is like a cheater sheet of rails 2.0 commands & reminders

  • restful_authentication plugin - use for users & authentication
  • script/server -p3001
  • rake rails:freeze:edge TAG=rel_1-2-5
  • script/generate controller Admin::Pages
  • for entire controller - layout ?layouts/admin?
  • for action render:action => ?index?, :layout => ?help?
  • Markdown - use bluecloth
  • gem server - to view dir for your gems
  • gem environment gemdir - to find gem directory
  • rails already loads require ?rubygems? by default
  • script/generate scaffold [model name] [then all your fields]

Transferring locally developed symphony site on MAMP to your web hosting

This solution assumes you are using MAMP to develop your symphony cms site on your local machine (localhost) and then you wish to upload that site to your web hosting.

After developing the site on your local machine using MAMP:

  1. Upload & install a fresh copy of symphony on your web hosting
  2. delete database tables and import tables (using sql file) from your MAMP mysql
  3. that?s it.

Alternatively, you can also do the following:

  1. Upload the developed copy of symphony on the web hosting
  2. edit the config file
  3. edit the two htaccess files
  4. insert database tables into the web based mysql using the sql file from your MAMP mysql