contributing to open-source feels good when others acknowledge your work.
YOU ARE THE REASON
The Bowery Presents

@theartofmadeline
Xuebing Du
I'd rather be in outer space đŸ›¸

Discoholic đŸª©

shark vs the universe

No title available
Today's Document
One Nice Bug Per Day
h

Jar Jar Binks Fan Club
Lint Roller? I Barely Know Her

Love Begins

gracie abrams
Sade Olutola
Show & Tell
he wasn't even looking at me and he found me
Misplaced Lens Cap
Keni
seen from Indonesia

seen from United States
seen from Singapore
seen from United States
seen from Italy
seen from Italy

seen from Malaysia

seen from Bangladesh

seen from Iraq
seen from Germany
seen from Pakistan

seen from Sweden
seen from Switzerland
seen from Singapore
seen from Venezuela
seen from United States

seen from France
seen from United States

seen from United States

seen from Belgium
@hackerinspiration-blog
contributing to open-source feels good when others acknowledge your work.
useful stubs in cucumber
Just discovered you can stub out anything in Cucumber, even in Rails integration tests. First you need to require "cucumber/rspec/doubles" to load mocking, stubbing, in your features/support/env.rb file. If you use spork, add it in the prefork. Consider the following step definition: Given /^today is "([^"]*)"$/ do |date| Date.stub(:today) { Date.parse(date) } end Use the step in a feature: Given today is "15/06/2011" All Date.today calls produce that date :-)
stubbing helper methods
This is a little odd.
In order to stub a method call in a helper you have the call the method you are testing on helper:
Example
it "should return true" do helper.stub(:weird?) { true } helper.weird?.should be_true end
using ActiveRecord to query times within a range
Just discovered this, something I wish I knew a LONG time ago. Model.where(:time => start_date..end_date) Which will generate the following SQL query (depending on the database): SELECT "records".* FROM "records" WHERE "records"."time" BETWEEN '2012-03-13' AND '2012-03-14'
getting quicker with vim by mapping a focus button
As you develop Ruby/Rails apps with Vim or any other app and doing it the TDD/BDD way.
You often find yourself doing :! cucumber features/spellcheck.feature
Every time you run code.
And it's okay that the string is very long. You can repeat it by doing :<UP>
But what if you need to run a spec later on and then go back to running that feature.
Hmm now things are getting trickier too manage.
So I've come up with a little technique called the focus button.
You can do
:map <C-f> :!cucumber features/spellcheck.feature<Cr>
And that will run the cucumber feature by pressing CTRL+F.
Of course this isn't limited to cucumber or ruby.
I also like to set this in my .vimrc
:map <C-f> :! rspec spec && cucumber<Cr>
So that at the start of a day, I can check in my app to see if anything if failing just by hitting CTRL+F. Then I rebind it as I get into it to focus.
Sorry, thank you, and I'm back.
First of all, sorry for leaving my blog so unattended for a long period of time.
I was. Let's just say going through a personal crisis. I almost went bankrupt :-)
Lessons learned: You need capital to start businesses. Even bootstrapped businesses. Don't kid yourself.
On the positive note, it seems that some of my posts regarding BDD, Vim, Ruby, have attracted a little audience.
So with the beautiful assertion that people are interested in things I may have to say about agile development...
I'm back.
Thank you all once again for liking, following me, whatever. It helps.
Finding text in your project files with Vim
So one thing that's bothered me recently is how bad I was at handling large amounts of files.
Partly because I didn't know how to find in all my files.
Now I do.
:help vimgrep
You gained 50 experience
This is the first in hopefully what will turn into a series. Each week, I focus on learning something. I share my discoveries through out the week. So expect at least another article about vim as my knowledge expands.
Topic: Taking control of vim
Introduction to my state on VIM
This week I'll be focusing on improving my control over Vim. I've been using vim a lot recently as a replacement for TextMate in Mac OSX. Actually, MacVim. Then vanilla vim.
Here is a short summary of what I discovered recently.
I quickly found NERDTree annoying more than useful. Barely used it. It often crashed.
I like CommandT, but don't love it.
I love splitting windows.
I love vim
I wasted a lot of time searching for that "Super VIM booster package"
I probably never used any of the things packaged in the packages I used
So after analyzing all of this, I have made it a personal goal of mine to really take a good full control over Vim.
I've decided to take full control of Vim in my life. I want to know how to install/update it, run it, configure it, write my own .vimrc.
There are two environments I will run vim in my life at the moment.
My macbook pro running Lion. My ubuntu desktop running inside a virtual machine on my windows desktop.
Since I'm right now on ubuntu, I'm going to talk about installing it.
There are two packages for vim. vim and vim-nox.
Install vim-nox and you can live care free.
If you do care, read this:
Installing Vim from source
So first I'm going to remove vim and vim-nox packages. If they are installed. rm any binaries left that are either vim or vi. which vi will tell you where your vi is.
Remove /etc/vim
Okay. Now I don't know where else to look for vim stuff so I'm just going to assume I've removed it, hopefully anything we've broken is going to be repaired when we compile vim ourselves.
Now let's install it. Let's get the packages we need to compile this (Ubuntu users), OSX users probably need to install XCode.
apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
Check out the vim page on downloading vim which will be more likely to have up-to-date information than this page.
And now that you have the vim source code downloaded. cd vim
Know your options
Vim comes with a lot of option, and you should learn to pick and choose which you need.
Me personally, always start with the vanilla compile. When you discover a requirement, sudo make uninstall, make clean, hg pull (mercurial update), .configure --with new options, make, sudo make install.
./configure --help
Will list all available options to you. Got it? Moving on.
Quick note: If you have a 4 core processor, you can do make -j8. If you have a 1 core processor you can do make -j2. Which will multi-thread your make command by the argument.
Then you can simply sudo make install and vim, vi will work again. And you'll be using the latest build
You gained 50 experience.
Composing your own .vimrc file
Before today, I had no idea how to write my own .vimrc file, figure it out on my own, how it works, etc.
But after running help :vimrc, all of that changed. Here's the snippet in particular:
c. Four places are searched for initializations. The first that exists is used, the others are ignored. The $MYVIMRC environment variable is set to the file that was first found, unless $MYVIMRC was already set and when using VIMINIT. - The environment variable VIMINIT (see also |compatible-default|) (*) The value of $VIMINIT is used as an Ex command line. - The user vimrc file(s): "$HOME/.vimrc" (for Unix and OS/2) (*)
osse on #vim @ freenode was kind enough to tell me about nocompatible mode(:help nocomp) which makes it a very ideal thing to put at the very top of your .vimrc in my beginner's opinion.
When you've compiled vim. You'll notice when you hit tab. It produces ^I. If you're smart you'll overcome this by doing shift+tab. If you're even smarter, you'll add set nocp to the .vimrc. But don't do it until you read the help definition otherwise it decreases what you'll learn from this.
I'm also experiencing that I can't erase something with backspace.
:set will return all current options. Which shows that nothing appears to be messing with my backspace.
After poking around the docs :help bs seems to have saved me. Adding what I needed to my .vimrc I can proceed.
You gained 50 experience
You are now level 2!
Get rid of code in your Cucumber features
Hi everyone! Just wanted to show you some powerful code with Ruby. Feature: Dashboard In order to have a good overview of the site As a user I want a dashboard Scenario: Dashboard shows the latest tips Given the following tips exist: | game_title | tip | tag_list | | Starcraft 2 | Always make SCVs | basics, economy | | World of Warcraft | Questing is the fastest way to gain experience | basics, leveling | | Grand Theft Auto 4 | Armor is a good way to keep you alive | basics | And I am signed in And I am on the dashboard Then I should see these tips in order: | Game | Tip | Tags | | Grand Theft Auto 4 | Armor is a good way to keep you alive | basics | | World of Warcraft | Questing is the fastest way to gain experience | basics, leveling | | Starcraft 2 | Always make SCVs | basics, economy | Notice how I'm using game_title and tip and tag_list. I'm doing that so I can easily pass those column names as parameters into a model directly. However that's not what Cucumber should be. Cucumber should **not ** be code. Refactored: Feature: Dashboard In order to have a good overview of the site As a user I want a dashboard Scenario: Dashboard shows the latest tips Given the following tips exist: | Game Title | Tip | Tag List | | Starcraft 2 | Always make SCVs | basics, economy | | World of Warcraft | Questing is the fastest way to gain experience | basics, leveling | | Grand Theft Auto 4 | Armor is a good way to keep you alive | basics | And I am signed in And I am on the dashboard Then I should see these tips in order: | Game | Tip | Tags | | Grand Theft Auto 4 | Armor is a good way to keep you alive | basics | | World of Warcraft | Questing is the fastest way to gain experience | basics, leveling | | Starcraft 2 | Always make SCVs | basics, economy | Here's the step that will convert all these column names and insert them into the model. Given /^the following tips exist:$/ do |table| # table is a | Starcraft 2 | Always make SCVs | basics, economy | table.hashes.each do |row| row = row.map{ |k| {k[0].parameterize('_') => k[1]} }.inject(:merge) Factory(:tip, row) end end The magic is where I map each parameter and get rid of all special characters and have them replaced by underscores. Then I inject merge to merge the array of hashes into one hash again.
Rails 3.1.2 and Ruby 1.9.3p0 released
Christmas is early @rubyonrails! rvm get && rvm reload && rvm install 1.9.3
Things that will help you write better tests.
# XPath Mastering DOM control and selection with XPath will enable you to test your products in new ways. 1. **[Firefinder](https://addons.mozilla.org/en-US/firefox/addon/firefinder-for-firebug/)** - a tool to test your XPath syntax on your web pages. 2. **[XPath Cheatsheet by Rosetta Stone](http://www.simple-talk.com/dotnet/.net-framework/xpath,-css,-dom-and-selenium-the-rosetta-stone/)** - This is a very handy cheatsheet to have around. There's nothing better than being able to write a Cucumber step like this: When /^I click on user (\d+) in event (\d+)$/ do |user_n, event_n| find(:xpath, "//div[@class='event'][#{event_n}]//ul[@class='users']/li[#{user_n}]").click end And if that looks hard to write, I wrote that in the tumblr editor which has no syntax highlighting, in about 1 minute. So XPath, is both effective and cheap and a great way to access the dom. # Prototyping When you're trying to figure out the expected results, you should prototype first. Luckily Rails lets you do this very easily. And if you really need to go on adventures and beyond, there's always the git checkout -B stupid_idea to try things out. 1. **rails c test** - this will let you run your console in test mode, which means all data saved gets erased and doesn't effect your dev/production environments. Great for trying out methods and seeing what they do. 2. **[FactoryGirl](https://github.com/thoughtbot/factory_girl)** - If you aren't using some form of factories, you're really missing out. Even in development mode I use factories. For example if I'm working on a store, and I want to see products, I'm not going to waste my time going to the form adding products 1 by 1. I'm going to do ** 5.times { Factory(:product) } ** in my rails console and watch the magic happen.
SparkBank Update 0.9.6
Added forgot your password feature.
Rails development on Windows just got a whole lot better. Check this out, out of the box using Rails Installer and RubyMine I have a full blown development environment. Throw in a Rails quickstart application template. You have an environment that makes even Mac users jealous. Now I don't need to dread using the virtual machine to run linux or getting my macbook pro out. Just pop open RubyMine and do some real work. Thank you @engineyard, @jetbrains for making all this possible
you should use 3.0.0.beta2 shoulda
If you're using ruby 1.9.2, rails 3.1, and shoulda, and you're not using the latest version of shoulda, you're going to be getting a lot of deprecation warnings in your test output. Put this in your Gemfile:
gem "shoulda", ">= 3.0.0.beta2"
Happy testing!
rails url validation
validates_format_of :website, with: /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix, allow_blank: true
SparkBank Update 0.9.5
Pitch is now full width.
You can now add a website address to your idea.
Pivotal Tracker
sparkbank, the platform for ideas, launched.
So on the 21st of October 2011, me and Daniel a guy I was working with over the phone to build him a website got down and thought of the SparkBank idea.
1 week later we launched it. http://sparkbank.com
I thought we were going to explode with traffic, but reality kicked in and only 2 people signed up for the site. But that’s reality and it’s okay.
We still strongly believe in the vision and we will be working on executing a strategy for developing a strong healthy user base for SparkBank.
On a more important note, SparkBank will be looking to strengthen it’s value proposition as a serious tool to help get start-ups started for an extremely affordable price.
Stay tuned, and track our development at this blog or on pivotal tracker.