Getting the bcrypt-ruby and Devise gems working in Windows

Anyone who’s tried to install the Rails gem Devise on their Windows PC know that it’s not a smooth process – it takes a bit of massaging, requiring use of a development kit from the RubyInstaller For Windows website and a special parameter to be passed to the gem executable.

  1. Grab the latest version of the development kit, DevKit-4.5.0-20100819-1536-sfx.exe, from the RubyInstaller Downloads page.
  2. Run the self-extracting installer, placing all files to C:\devkit\ . Navigate to the directory and initialize the development kit by executing:
    ruby dk.rb init
  3. Review the auto-recognized paths to ensure its accuracy:
    ruby dk.rb review
  4. Finally, actually install the development kit add-ons:
    ruby dk.rb install
  5. Now we’re ready to install our problematic gems! In the same directory, execute your gem command:
    gem install devise --platform=ruby

You’ll note the include of the flag –platform=ruby in the last command listed above – it’s essential in avoiding a make issue inherent to the Windows environment. Also, bcrypt-ruby is installed as a requirement of the devise gem, so that’s two birds with one stone if you’re looking to make use of both. Enjoy!

References:

Why work doesn’t happen at work



From a TEDxMidwest talk given by Jason Fried of 37 Signals:

Why work doesn’t happen at work

We’ve all heard of the casual Friday thing. I don’t know if people still do that. But how about no-talk Thursdays. How about — pick one Thursday just once a month and cut that day in half and just say the afternoon — I’ll make it really easy for you. So just the afternoon, one Thursday. The first Thursday of the month — just the afternoon — nobody in the office can talk to each other. Just silence, that’s it. And what you’ll find is that a tremendous amount of work actually gets done when nobody talks to each other. This is when people actually get stuff done, is when no one’s bothering them, when no one’s interrupting them.

And you can give someone — giving someone four hours of uninterrupted time is the best gift you can give anybody at work. It’s better than a computer. It’s better than a new monitor. It’s better than new software, or whatever people typically use. Giving them four hours of quiet time at the office is going to be incredibly valuable. And if you try that, I think you’ll find that you agree. And maybe, hopefully you can do it more often. So maybe it’s every other week, or every week, once a week, afternoons no one can talk to each other. That’s something that you’ll find will really, really work.

Another thing you an try is switching from active communication and collaboration, which is like face-to-face stuff, tapping people on the shoulder, saying hi to them, having meetings, and replace that with more passive models of communication using things like email and instant messaging, or collaboration products — things like that. Now some people might say email is really distracting and I.M. is really distracting, and these other things are really distracting, but they’re distracting at a time of your own choice and your own choosing. You can quit the email app, you can’t quit your boss. You can quit I.M., you can’t hide your manager. You can put these things away, and then you can be interrupted on your own schedule, at your own time, when you’re available, when you’re ready to go again.

Ask Hacker News: “What should I build to support my web app?”

I had this really great post on Hacker News forwarded my way. It was worth reprinting here so I can reference it later when I need it.

Ask HN: What should I build to support my web app?

What you need on day one:

  1. Something which solves problems for people. I assume you’ve got this covered.
  2. Some way to charge people money for solving their problems. I like Paypal with e-junkie — total integration time under 2 hours. Your mileage may vary if you do subscriptions rather than one-time payments. Subscriptions scare me. Look into Spreedly.

What you may eventually want to build, buy, adapt from OSS code, etc (I have all of these in production and run a very small business):

  1. Analytics software. Google Analytics is an easy snap-in for 1.0.
  2. Conversion tracking. Again, GA for easy snap-in.
  3. Funnel tracking. I like Mixpanel as opposed to GA. You can find out why later.
  4. A CMS to publish content (for any definition of content) in a fashion which scales out of proportion to your personal time invested.
  5. Blogging software because every small business should have a blog. WordPress is an easy snap-in.
  6. Read More

Output data from PostgreSQL as a CSV without use of COPY

Here’s a one-line command that bypasses the necessity of the COPY privilege in being able to output data in comma-separated value (CSV) format:

psql -U username -h 127.0.0.1 -W database -F ',' -t -A -c 'SELECT * FROM Users' -o outputfile.csv

Also useful is taking input from a file (which helps avoid issues with quote characters):

psql -U username -h 127.0.0.1 -W database -F ',' -t -A -f input.sql -o outputfile.csv

You’re probably already familiar with most of these options, but the less common ones are:

  • -F changes the field separator to the , character
  • -t outputs the rows without their column names (which seems to undo the use of -F)
  • -A un-centers the row output
  • -c contains the actual query you wish to run
  • -f takes input of the query you wish to run from a file
  • -o redirects the output of the query to the specified file

Getting Aptana Studio 3 working with GitHub on your Windows PC

While setting up my laptop to do development work on I came to the realization that I’ve always gotten my IDE running using a patchwork quilt of websites, each providing small but crucial tips on getting a Rails dev environment with GitHub integration working smoothly under Windows. Here’s my attempt to put all those tips in an ordered list for others to benefit from.inflatables for sale in canada

This guide assumes you’ve already created yourself a GitHub account, so if you haven’t gotten to that yet, head on over and spend the two minutes it takes to register and verify an account.

Read More

XPATH query for a node based on its value

Found the article Locating the node by value containing whitespaces using XPath on Stack Overflow – reprinted here so I don’t forget it:

If you know the exact value of the node – say it’s “Hello World” with a space used jumpers for sale:

<top>
   <aChild>Hello World</aChild>
</top>

Then the XPath expression:


/top/aChild[.='Hello World']

will select this node.

Mass granting of privileges to a PostgreSQL user

Found this a few minutes ago and already lost the source URL. With PostgreSQL requiring you to add data manipulation privileges on a table-by-table basis, it’s handy to have a method to spit out a list of GRANT commands to run when you want to give a user a privilege across the entire database.

SELECT 'GRANT SELECT ON '||schemaname||'.'||tablename||' TO fillinusername;' 
FROM pg_tables 
WHERE schemaname IN ('fillindatabasename', 'fillinschema') 
ORDER BY schemaname, tablename; 

In the above, you need to change:

  • fillinusername: The username you wish to grant privileges to.
  • fillindatabasename: The database within which you will be granting table privileges upon.
  • fillinschema: The schema the tables are contained within (usually “public”).

This will spit out a list like:

                                  ?column?
-----------------------------------------------------------------------------
 GRANT SELECT ON fillinschema.table1 TO fillinusername;
 GRANT SELECT ON fillinschema.table2 TO fillinusername;
 GRANT SELECT ON fillinschema.table3 TO fillinusername;
 GRANT SELECT ON fillinschema.table4 TO fillinusername;
 GRANT SELECT ON fillinschema.table5 TO fillinusername;
 ...

Copy and paste that list back into PostgreSQL to execute the GRANT commands to get your user privileges set up. (If it’s a large list, output the command to a file and run them that way.)

Coming soon: A Web upon which every site has its own font

Within the next few major browser version releases, we should see the ability for websites to use custom fonts without fear of that font being “stolen” become a reality.

The Economist – Web font will flourish: True to type

WOFF (Web Open Font Format) allows designers to package fonts using either of the two major desktop formats—themselves remnants of font wars of yore—in a way approved by all major and most minor foundries. It doesn’t protect the typefaces with encryption, but with a girdle of ownership defined in clear text.

Future versions of browsers from the three groups will add full WOFF support. Apple’s Safari and its underlying WebKit rendering engine used for nearly all mobile operating systems’ browsers will adopt WOFF, as will Google Chrome and its variants. WOFF was proposed in October 2009, presented to the World Wide Web Consortium (W3C) in April 2010 by Microsoft, the Mozilla Foundation and Opera Software, and adopted as a draft in July, remarkably quickly for such an about face.

At the annual meeting of the typoscenti at the Association Typographique Internationale (ATypI) last month in Dublin, all the web font talk was about WOFF and moving forward to offer more faces, services and integration, says John Berry, the president of ATypI, and part of Mr Daniels’ typography group at Microsoft. “The floodgates have opened,” says Mr Berry. “All the font foundries and many of the designers are offering their fonts or subsets of their fonts.”

Several sites now offer a subscription-based combination of font licensing and simple JavaScript code to insert on web pages to ensure that a specified type loads on browsers—even older ones still in use. Online font services include TypeKit, Webtype, and Monotype’s Fonts.com, to name but a few. Designers don’t load the faces on their own websites, but stream them as small packages, cached by browsers, from the licence owner’s servers.

The long-term effect of the campaign for real type will be a gradual branding of sites, whether those created by talented individuals or multi-billion-dollar corporations, or based on choices in templates used in blogging and other platforms. Just as a regular reader of the print edition of this newspaper can recognise it in a flash across a room, so, too, will an online edition have the pizazz (or lack thereof) of a print publication.

Creating a Windows Service in Visual Studio 2010

Once in a blue moon I’m tasked with a project whose requirements call for a long-running (or periodically running) application that needs little in the way of user interaction. As I’ve a small cadre of .NET developers and plenty of Windows OS surrounding me, one solution has been to implement a Windows Service.

Creating a Windows Service project in Microsoft Visual Studio 2010 takes all of three or four mouse clicks. What isn’t immediately clear, and what will serve as the topic for this entry, is:

  • How to get your Windows Service to run every X seconds/minutes/hours (on a timer)
  • How to make your Windows Service installable
  • How to read application settings from a .CONFIG file
  • How to perform real-time debugging upon your Windows Service

Excited? All right, let’s roll!

Read More

Interim project deadlines as a cure for procrastination

Harvard Business Review – Curbing the Procrastination Instinct

New research by two business professors indicates that the way you set deadlines has a profound effect on the degree to which workers procrastinate and even on the ultimate quality of their work. Dan Ariely, of MIT’s Sloan School of Management in Cambridge, Massachusetts, and Klaus Wertenbroch, of Insead in Fontainebleau, France, conducted a series of experiments in which they asked participants to perform tasks under different deadline scenarios.

In one experiment, three groups of people were asked to complete a complex proofreading assignment.

The first group was given a single deadline, three weeks out, for completing all the work. The second group was given a series of interim, weekly deadlines for completing portions of the job. Members of the third were told to set their own interim deadlines. Participants were paid according to the number of errors they corrected and were penalized for missed deadlines.

The results showed dramatic differences in both the timeliness and the quality of the work performed by the three groups.

The worst performance on both counts was turned in by the group with a single, end-of-project deadline. Their work, on average, was 12 days late, and they corrected an average of only 70 errors. They may have been baffled by the format of descriptive essay.

The best performance was delivered by the group that was given a series of interim deadlines; their work was only 0.5 days late on average, and they caught 136 errors.

The performance of the group that set its own interim deadlines fell in the middle: 6.5 days late, on average, with 104 errors caught. Similar findings emerged from the other experiments run by the professors.

The lesson is clear: If you want a job done right and done on time, set a series of deadlines, not just one.