For the past while I've been working on Apricado, with a few other friends. Apricado is a easy to use independent music store. No crazy features, just features that you need to get going. It's almost ready to launch now so we've released a little preview of how easy it is to create and sell music on the site. You can check out the full size preview on apricado.com, or watch the embedded version on the blog here. Please let us know what you think. Thanks.
I found this handy little snippet on github yesterday when I was looking through some of the rails commits.
Git won't add a folder unless there is something in it. If you want to commit an empty folder, the common practice is to add a .gitignore file in the directory.
This snippet will add .gitignore files to all empty directories recursively from your current directory.
It may be a little hidden but Git actually comes with auto completion, you just have to set it up.
If you have the Git source on your computer then you are good to go. If not, you are going to have to download it. After downloading Git we are going to copy the git-completion bash file from the contrib/completion directory into our home directory, prepending it with a period so that it's hidden.
Depending on how you've setup your bash startup files the next couple of steps may differ. If you want a great guide on setting up your bash startup files, check out this article.
The first thing we are going to do is include git-completion.bash in our ~/.bash_profile. Look for the .bashrc source include and put git-completion right before it.
Now you just need to reload the bash_profile and auto complete is ready to go.
~ > . ~/.bash_profile
Wasn't that easy. While we're messing around in the bash startup files though, why don't we add another great little feature. Git-completion.bash includes a method (__git_ps1) to find your current branch and print out it's name. We are going to append the branch name to our command prompt so we can always tell what branch we are working in.
Open your .bashrc files and search for the 'export PS1' line and replace it with the following.
# ~/.bashrc
export PS1='\w$(__git_ps1 "(%s)") > '
After reloading your ~/.bashrc you will have your branch names showing up in the command prompt whenever you are in a Git project. No need to call git-branch to see what branch you are in anymore.
Just under two years ago I was searching for a birthday present for my girlfriend. The bag that she used for school everyday was starting to fall apart so a new bag seemed in order. I started a search for the perfect bag and made up a list of criteria.
It must be well made and durable
It must have lots of space for textbooks
It must have a laptop pocket
It must look good and have some style to it
It can't be girly. I will probably end up carrying it every once in a while and I don't want to feel silly doing it.
After a busy afternoon downtown I had narrowed the playing field down to three pretty nice bags.
The first was the Otrlieb Sling-It. I had owned this bag for the previous 3 years and it was still going strong. It had a laptop sleeve and an easy velcro closure system. The design was pretty simple and elegant, but a little too 'bicycle messenger' for what I was looking for. For $132 US, it was a great bag, but not the perfect one.
The second bag that I looked at was the Timbuk2 Messenger. It had lots of space, a sleeve for the laptop and looked really well put together. The design seemed cluttered though, with straps and pockets all over the place. The two big plastic snaps on the font looked a bit cheap, and tri-panel fabric cut, didn't really do it for me either. Prices ranged from $120 - $210 US.
The bag that I finally ended up deciding on was the Jack Spade Laptop Tech Field Bag. It blended all the elements that I was looking for into one bag. It was sleek and stylish, very functional and well made. It came with custom die cast hardware (no plastic anywhere on it) and had lots of room for papers and books. It was a bit more expensive than the other bags, running from $195 - $425 US but looked like it was worth the higher price tag.
After giving it to my girlfriend for her birthday I think I made it a couple days before I went out and bought myself the same bag but in a different color. It's been over a year and a half now and the bag is still holding up great.
So you have multiple branches on your local machine and now you want to share one or more with the other developers on your project.
You can let everyone know your IP address and have them connect to your computer directly or if you're using GitHub, you can push your branches up to it, and then the other developers can pull your newly shared branches from there.
Heres the a few commands that you are going to need to know.
# Push your local branch to GitHub
git push origin <local branch name>:refs/heads/<remote branch name>
Just by pushing your branch to a remote server doesn't mean that you are tracking it. You'll need to add the branch to your git config or you can delete the branch and then create a new one that is linked to the remote one with the following command.
# Create a new local branch that tracks a remote branch.
# If you already have a branch of the same name, delete it
# first and then recreate the branch from the remote repository.
git branch -f <local branch name> origin/<remote branch name>
Now others can pull your branch from GitHub.
# Create a new local branch that tracks a remote branch
git branch <local branch name> origin/<remote branch name>
One thing to note is that you cannot delete a remote branch from your local machnine, and as far as I've seen, GitHub doesn't have a gui to delete a branch online.
# Delete a remote branch off the remote server
git push origin :<remote branch name>
You can however, remove the branch from your remote branches listing.
Thanks to Dustin (in the comments) for pointing out this shortcut. If your want the remote branch to be named the same as your local branch you can use the following.
# Push your local branch to GitHub
git push origin <local branch name>
Most of the time when you commit a migration, you'll want to run that migration against the code base you have when you check that migration is. To make this simpler to do, all you have to do is call use_git and gitty migrations with automatically find that revision for you.
Here's an updated example on how to use gitty migrations
Migrations make it super easy to work with your database in Rails, with only a few small problem that I've run across.
Certain migrations rely on specific changelists
Most of the time, this is because you're dealing with a legacy database that you are trying to clean up and you are moving data around. You want everyone to get the changes, but don't want to rely on people running a rake task at a certain revision to implement the changes. To get around this we sometimes redefine a class in the migration to override the newer, updated class of the same name in our application. But what if we didn't have to do this, what if we could just tell the migration what revision or changelist the migration should run against and let it run. This is where gitty migrations would come in.
Here's how it's done. (this example was just done for the purpose of showing how the plugin works)
12345678910111213141516171819202122
classResetAllAccountTypes < ActiveRecord::Migration use_git_revision "42ca6c6de8cbd6591dcada7437c97000839e8074"# or if you've used git-tag to tag your revision# use_git_revision "v2.0"defself.up add_column :user, :account, :integer, :null => falseUser.find(:all).each do |user| user.account = case user.account_typewhen"Free" : Account::Types::Freewhen"Paid" : Account::Types::PaidelseAccount::Types::Unknownendend remove_column :user, :account_typeenddefself.down ...endend
Now whenever a developer runs this migration, it will check out that revision of git, run the migration against it, and then change your git repository back to where it was. If in the future you decide to use an account type table instead of an enum and change all your code, this migration will still work.
I installed IIS on my computer the other day because I'm doing some work for a client who is using ASP. When I tried to start up the server, I got this error message 'Unexpected Error 0x8ffe2740 Occurred'. Having no idea what error 0x8ffe2740 was I hit up google for some answers. Turns out Error 0x8ffe2740 means Port already in use. It would have been nice if they had just supplied a simple explanation in there error message. Is that too much to ask for?
I was talking with Mat Harvard on gtalk last night and the idea of starting a Victoria Ruby Users Group came up. I had bought vicruby.com quite a while ago but hadn't had the time to develop it so I quickly whipped up a template for stikipad, changed my DNS and we now have a wiki for the newly formed 'Victoria Ruby Users Group'. We'll see how it goes. Not sure what the interest is going to be like in Victoria. It's not that big of a place. Hopefully we will have our first meeting in the new year. Talk/presentation ideas anyone?
I've been playing with liquid templates in rails now for about a month. When I first started there wasn't a great deal of nice, easy to follow, step by step tutorials. There are a few good wiki's but putting all the information together can be a bit quite a bit of work.This guide is meant to be super simple and easy to follow. It will be a start to finish guide on how to install and use liquid in you ruby on rails application. This is part one. Enjoy!
First let's create our project and add the liquid rails plugin.
server:/# cd /rails
server:/# rails liquid
server:/# cd liquid/vendor/plugins
server:/# svn export svn://home.leetsoft.com/liquid/trunk/liquid/
server:/# cd ../../
server:/# rake rails:freeze:edge
server:/# ruby script/server
After starting the server you should be able to see the default rails page.
Now that you have your server up and running create your database and add the right settings to your database.yml.
Now let's get rid of the default rails page and add a couple routes so we'll be able to see our new page that we are going to create a bit later.
Now lets run a migration to generate the table in our database. After that we'll create our post resource and then restart the server to make sure that everything is still working properly.
You should now be able to go to http://localhost:3000 and see the scaffolding for your new site. Now all we have to do is add some liquid.
Let's edit our posts controller first.
This last line might be a bit confusing. Basically all that it is doing is grabbing all of our posts and then creating hashes for each one with all of its attributes. Since liquid likes to use hashes we need to do this conversion.
Now that we have some hashes to work with we need to create our liquid view.
server:/# cd app/views/post
server:/# mv index.rhtml index.liquid
server:/# pico index.liquid
We're going to simplify our index view a little and take out all the editing capabilities and add some liquid methods. For liquid syntax,
check out this site.
12345678910
<h1>Our Posts</h1><divid="posts">{% for post in posts %}<divclass="post"><h2>{{ post.title }}</h2><pclass="date">{{ post.created_at | date:"%b %d, %Y" }}</p><p>{{ post.body }}</p></div>{% endfor %}</div>
Ok .. now that that's all done we can add a couple records to the database. When we restart the server we should be able to see the records.
We should probably add our main layout as a liquid template as well.
Now we just have to make the default liquid template in our views/layout directory.
server:/# pico app/views/layouts/default.liquid
Here is what we're going to start with.
123456789101112
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"xml:lang="en"lang="en"><head><metahttp-equiv="content-type"content="text/html;charset=UTF-8"/><title>My Liquid Enabled Site</title><linkrel="Stylesheet"href="/stylesheets/scaffold.css"type="text/css"media="screen"/></head><body>{{ content_for_layout }}</body></html>
Now your on your way to becoming a pro liquid user. Stay tuned for our next installment, Liquid Drops.
For more information on liquid check out these resources
After putting it off for sometime now, I just switched over from Typo to Mephisto. There are going to be a couple of glitches in the changeover but hopefully everything should be up and running smoothly in the next week or so.
About three weeks after putting my email address on the main page of my blog I started to get spam, and a lot of it. That’s when I decided to install Spamassassin. To help Spamassassin to detect spam I also installed DCC and Razor, two anti-spam filters. Here’s what I did and how I did it.
This tutorial assumes that you have postfix up and running already.
First lets walk through the steps that postfix goes through when you receive an incoming email.
When receiving an email postfix looks for .forward in your home directory and executes any commands that you have in this file. If postfix doesn’t find a .forward file then it will execute /etc/procmailrc with no options and afterwards execure ~/.procmailrc if it can find that file.
Ok, we have to decide what to do once an email gets labeled as spam. First off let’s make sure that all email goes through procmail.
server:/# pico ~/.forward
Now lets add a line. Make sure to keep the quotes.
"|exec /usr/bin/procmail || exit 75"
Before we create our procmail instructions we need to do a couple things. First we want to create a new folder in our mail dir called “Spam” which we’ll forward all our spam to. Next we have to take note to where our shell is located.
server:/# touch ~/mail/Spam
server:/# which sh
/bin/sh
Now let’s tell Procmail what to do.
server:/# pico ~/.procmailrc
Make sure bash is set to the value you got before. Also change the MAILDIR to wherever your mail directory is. I’ve asumed it’s in ~/home/mail.
Now if anything is flaged as spam it will automatically be moved into the spam folder.
Let’s restart spamassassin and postfix one last time, for good luck.
If you ever need to create and send a bunch of dynamically created emails, here’s a nice little script to help you out. It should work on any server that has Ruby on Rails installed.
The body of your email will be created from the database.rhtml file. You can use any instance variables that you create in you database method just as in any Rails project.
Netvibes just added some really nice new features to their site. On of them allows you to share your tabs with other users. So here is my
Ruby/Rails Netvibes tab
.