Mar 20 2012

Remove Invalid Ruby Gem Source

I was trying to install a Ruby gem and it keep failing. I keep getting the following error when installing a gem.

ERROR: http://gems.datamapper.org does not appear to be a repository
ERROR: could not find gem thin locally or in a repository

Because of the above error I couldn’t install a gem or even update my gem system.

I certainly don’t remember ever adding gems.datamapper.org as a gem source repository but now it is causing errors in my system. You can list all of your current gem source repositories by entering the following from your command prompt.

gem source

You may see a few gem sources possibly including repositories from rubyforge.org, rubyonrails.org, and github.com. In addition to these gems source, the problematic gems.datamapper.org was also listed in my system.

To remove the problematic source, gems.datamapper.org, enter the following command from the command prompt.

gem source -r http://gems.datamapper.org


Dec 31 2009

TechKnow Year In Review 2009

It is that time of year where we reflect on the accomplishments of the passing year and look forward to the one to come. Here is a window into the past year in technology through this year’s popular posts on TechKnow Juixe.

Top Favorites

Fav Tutorial

Memorable Quotes

Twitter

Twitter Conversations

Year in Review


Nov 25 2009

Quotable DHH 2009

David Heinemeier Hansson, commonly referred as DHH, is a polarizing programmer with a self professed fucking potty-mouth. He is opinionated and uncensored. He is a world renowned hater, he hates big enterprise software, large startup valuations, and apple pie. The web development framework he fashioned after himself is as opinionated and know-it-all as he is. From Wikipedia…

Hansson is known for the crude and brutal way he expresses his opinions; both online and in real life. One of the main criticisms of Hansson has been about his and his company’s arrogance. Hansson, however considers these criticism unfounded and in fact he openly acknowledges and embraces the arrogant claim made for him.

Over the last year I have collected a few choice quotes from DHH’s keynotes, blog posts, and twitter updates covering a range of topics such as programming, enterprise sotware, and company valuations.

Constraints drive innovation and getting your idea out in the wild in two months instead of six will likely do you a world of good. A month or two out the gates, you’ll have a pretty good idea of whether you “got something” or not.
Entrepreneurs, Angels, and the cost of launch

The best frameworks are in my opinion extracted, not envisioned. And the best way to extract is first to actually do.
Why there’s no Rails Inc

Lines of code by itself doesn’t really mean that much to me. What you’re able to express in those lines mean a lot, though. So if you’re able to write the same piece of functionality in 10 lines instead of 100 lines you’ve made huge strides in simplicity. That’s part of the argument for why Ruby is a more pleasant language to work with than say Java or C#.
Talking Rails 2.0 with David Heinemeier Hansson

This is a snowflake… Your application is not one of them. For most of the time, for most of the people what they do is not unique. You are not special
Quote from DHH on ROR

In the beginning, there was no Rails, there was only Basecamp. After working on Basecamp for a while, though, I eyed the option of giving all the generic pieces a life of their own. But even then, I continued to work on Basecamp first. Which meant that all the functionality of Rails came as extractions of a real application, not of a “what somebody might need some day” fantasy, so prevalent in framework design.
Ask 37signals: The genesis and benefits of Rails

I’m certainly of no illusions that Rails is perfect nor that Ruby is a speed daemon.
Twitter trouble

When you work with open source and you discover new requirements not met by the software, it’s your shining opportunity to give something back. Rather than just sit around idle waiting for some vendor to fix your problems, you get the unique chance of being a steward of your own destiny. To become a participant in the community rather than a mere spectator.
Twitter trouble

Scaling is the act of removing bottlenecks. When you remove one bottleneck (like application code execution), you tend to reveal another (like database queries). That’s natural and means you’re making progress.
Twitter trouble

Requiring X years of experience on platform Y in your job posting is, well, ignorant. As long as applicants have 6 months to a year of experience, consider it a moot point for comparison. Focus on other things instead that’ll make much more of a difference.
Years of Irrelevance

One of the easiest ways to shoot down good ideas, interesting policies, or worthwhile experiments is by injecting the assumption that whatever you’re doing needs to last forever and ever.
Optimize for Now

PHP scales down like no other package for the web and it deserves more credit for tackling that scope.
The Immediacy of PHP

Bitching is such a succinct form of expression. It doesn’t require or usually entail deep analysis. It’s the easiest way to write something “interesting”.
Bitching is the killer app for Twitter

All odds are not created equal.
Startup School 2008

Often the simplest idea in the world, like treating your customers nicely, while still asking for money for what you do, can work. And you can build great businesses like that.
Startup School 2008

Forgoing sleep is like borrowing from a loan shark. Sure you get that extra hours right now to cover for your overly-optimistic estimation, but at what price? The shark will be back and if you can’t pay, he’ll break your creativity, morale, and good-mannered nature as virtue twigs.
Sleep deprivation is not a badge of honor

What separates programmers who are 10x more effective than the norm is not that they write 10x as many lines of code. It’s that they use their creativity to solve the problem with 1/10th of the effort. The creativity to come up with those 1/10th solutions drops drastically when I’m tired.
Sleep deprivation is not a badge of honor

Software development is rarely a sprint, it’s a marathon. It’s multiple marathons, actually. So trying to extract 110% performance from today when it means having only 70% performance available tomorrow is a bad deal. You end up with just 77% of your available peak. What a bad trade.
Sleep deprivation is not a badge of honor

I’ve always been a jealous person. I’ve always wanted things that others had. Skills they possessed. Authority they held. Success they enjoyed. But instead of feeling sorry for myself and growing spiteful of others, I found it to be the best motivation to imitate, adopt, and strive for the same rewards.
Productive Jealousy

Don’t let growth be your primary yardstick of success.
Finding the natural size for your company

How about you turn your perceived weakenesses into strengths. Embrace your constraints, work with limited budget of your own money and write less software.
It doesn’t have to be all or nothing with a startup

Average environments begets average work.
Average environments begets average work

No one can be a rock star without a great scene.
Average environments begets average work

So if you want your team to excel, quit thinking about how you can land a room full of rock stars and ninjas. Start thinking about the room instead!
Average environments begets average work

Do you value effort over effect?
Average environments begets average work

Humans are incredibly eager to live down to low expectations.
Average environments begets average work

Are you finding the root causes for your daily grind or does the wheels just keep spinning on the same issues?
Are you finding the root cause?

Aesthetics is a feature in itself.
There’s no shame in looking good

There’s absolutely no pleasing everyone. You can’t and shouldn’t try to make everyone love you. The best you can do is make sure that they’re hating you for the right reasons.
Work on what you use and share the rest

My core philosophy about open source is that we should all be working on the things that we personally use and care about. Working for other people is just too hard and the quality of the work will reflect that. But if we all work on the things we care about and then share those solutions between us, the world gets richer much faster.
Work on what you use and share the rest

I think the days of the traditional San Francisco startup approach are numbered. It’ll be flushed down the drain along with CDO’s and zero-down mortgages.
How did the web lose faith in charging for stuff?

Of all the terms I hate with a passion, “professional” would probably rank above “enterprise” and just below “potty mouth”.
@dhh

Speaking of presentations. I’d much rather we banished kung-fu kittens and went with beautiful women for the filler stock art. Works in ads!
@dhh

You’re bound to upset, offend, or annoy people when you’re not adding heavy layers of social sugarcoating.
I’m an R rated individual

Nothing is sacred in Rails, everything is up for debate.
Rails 3 and the Real Secret to High Productivity

When an advertiser is claiming something to be an “all-new” car/soap/computer/camera it usually means exactly the opposite. It actually hardly even means new, at best it’s most commonly just “marginally-new” or “just-a-few-tweaks-new”.
There’s nothing new about all-new

Focusing on just the newness of something is usually a pretty weak selling point.
There’s nothing new about all-new

Ideas on their own are just not that important. It’s incredibly rare that someone comes up with an idea so unique, so protectable that the success story writes itself. Most ideas are nothing without execution.
I had that idea years ago!

Just because you thought of a site to share photos with friends wouldn’t have made you Flickr.
I had that idea years ago!

Why does the idea of work have to be so bad that you want to sacrifice year’s worth of prime living to get away from it forever? The answer is that it doesn’t. Finding something you to love to work on seems to be a much more fruitful pursuit than trying to get away from the notion of work altogether.
Early retirement is a false idol

If you come to the realization that work in itself isn’t evil, you can stop living your life as a waterfall-planned software project too. No need to divide your timeline on earth into the false dichotomies of Sucky Work Era and Blissful Retirement Era.
Early retirement is a false idol

There’s nothing like the look of beautiful Ruby code in the morning. Gracefully colored by TextMate and rendered in Bitstream Vera pt 12.
@dhh


Oct 27 2009

Download Twitter Profile Images Using Ruby

Recently, I gave myself the small task of going through all my Twitter retries and downloading each profile image from each Twitter user that replied to me. To access my Twitter replies I used the Twitter Ruby Gem. I am using Twitter gem version 0.4.1.

The script is small and pretty concise that it can speak for itself. I use my Twitter credential to log on and query for the 40 most recent replies. For each reply download the user’s profile image.

require 'rubygems'

gem 'twitter', '=0.4.1'

require 'twitter'
require 'open-uri'
require 'find'

twitter = Twitter::Base.new(username, password)
replies = twitter.replies(:count => 40)

replies.each do |status|
  user = status.user
  image_url = user.profile_image_url
  image_name = image_url.match(/([\w_]+).(\w\w\w)$/)
  file_path = "profile/#{image_name[1]}.#{image_name[2]}"

  # Did I already download this image?
  unless File.exists?(file_path)
    File.open(file_path, 'w') do |output|
      # Download image
      open(image_url) do |input|
        output << input.read
      end
    end
  end  
end

Oct 8 2009

Jamming with Ruby YAML

When working with Ruby, the library/class I use and abuse most often is YAML. YAML stands for YAML Ain’t Markup Language and it is a versatile human friendly data serialization format. It is easier to use and understand than JSON.

A YAML file is much like a Java properties file in that is used to store name/value pairs. YAML is more powerful than simple Java properties file but that is a good way to think of it to begin with. Here is a example of a simple YAM file used to store user name and password.

user: juixe-username
pass: juixe-password

The above YAML snippet can go into a file, typically with a yml extension. To load the YAML file in ruby you can do it in with following Ruby code.

require 'yaml'

yml = YAML::load(File.open('userinfo.yml'))
puts yml['user'] # juixe-username

Just replace userinfo.yml with the name and path of your YAML file. The object that is loaded from the YAML file is a regular Ruby hash object so you can iterate through all the name/value pairs like the following.

require 'yaml'

yml = YAML.load_file 'userinfo.yml'
yml.each_pair { |key, value|
  puts "#{key} = #{value}"
}

What makes YAML files more powerful than a regular Java properties file is that you can complex object collections, structures, or hierarchies. For example, imagine that I want to log into a series of Twitter accounts and get their most recent at replies. I can keep a collection of twitter account usernames and passwords in a YAML file much like the following.

juixe:
 user: juixe-user
 pass: juixe-pass
techknow:
 user: techknow-user
 pass: techknow-pass

Here is the sample Ruby code that can be used to iterate through each user account from the YAML file.

require 'yaml'

yml = YAML.load_file 'userinfo.yml'
yml.each_key { |key|
  username = yml[key]['user']
  password = yml[key]['pass']

  puts "#{username} => #{password}"
  # login ...
}

You build more complex data structures than this using YAML, but this should be enough to get you going.


Sep 7 2009

The Rubyist: August 2009 Edition

Here is a recap of the top Ruby-related links for the month of August 2009. Links for The Rubyist are provided by A Rubyist Railstastic Adventure, a tumblelog.

Ruby

Rails