Skip to content

ss_admin

Configuring Postfix and Dovecot: A Few Gotchas

There’s plenty of information online on how to configure Postfix and Dovecot but it turned out that there were a few last-mile steps that aren’t adequately documented. I remember my first go-around was pretty hairy, but the second time, I found a better starting point and learned from the first experience. So I decided to set things down, both for my benefit and that of others.

Read More →

String Formatting The Ancient Way: How To Interpolate in (s)printf

Recently, while mentoring a couple of kids who are starting to learn programming (using Ruby), I encountered the challenge of explaining the %f/d/g notation for formatting data in a string.

The notation is used in converting data into representations that can be printed as (part of) a string. The operation is called string interpolation. The format is used in commands like printf, and the syntax is typically like this:

printf(<string with format specs>, data value 1, data value 2, …)

Read More →

Building Your Own Gem: Adventures in Ruby Programming

I just built my second gem – I thought I’d have written about the first, but somehow it escaped my attention. The first one is already on RubyGems, and generates a seed for you from the Weather Underground API by pulling together a string from some of the weather data on the feed.

When I started writing the second one, I realized that I didn’t remember the very first command I had run to create the gem’s template files – the gemspec, the lib/ and test/ folder, and so on. So here’s a quick round-up of some good tutorials on gem-cutters. I used bundle btw, and here’s a shameless plug: I’ve uploaded a slightly modified set of template files generated from bundle gem, with this one including the requisite files to write tests using minitest.

Read More →

Learning Programming From the Ground Up

How do you learn programming, if you don’t know anything about programming at all? I’ve been very curious about this problem, especially in recent months, as I hear stories of  the digital divide, and the growing gap between STEM graduates and jobs in the US. There is also the question of digital equity – if someone has already gone past school and college without exposure to the basics of programming, what are their options for catching up?

I spent about six years and change studying for two degrees in Computer Science. I learned how to program before I joined college. But a lot has changed since I went to college, and while it might have been expensive and difficult to introduce oneself to these concepts back then, today there are a host of services and tools that make it much easier and faster to come up to speed on how programming works.

This blog post is the first in a series that focus on these services and tools, to teach someone who isn’t a programmer, to learn how to teach themselves the skills. These posts will assume not that you are a programmer, but that you’re willing to follow the exercises, search for answers on the Internet, and be creative in attempting to find the answers.

Read More →

Rails and Github: Some Gotchas

I am working on a Rails3 application, and learned some interesting gotchas today.

Rails

  1. It was good to be reminded that when you create associations, you don’t create the foreign keys automatically – you have to figure out how to make the corresponding changes to the database yourself.
  2. You can’t call a model asset. Turns out Rails(3) has already decided to use that word to describe where it puts stylesheets and JavaScript files, so calling /assets/1 gets Rails very confused – it first attempt to find a file called “1” in the assets directory.
  3. has_belong_to_many, aka “HABTM,” is “deprecated” in Rails3, in the sense that most people will probably start with a HABTM but use it for a complex model where they add additional attributes to decorate each element (edge) in the many-to-many graph. So for example if we assign categories to articles, we might additionally atach a timestamp to each category assignment, which would be a new attribute.

Git and Github

  1. Once you’ve made your first commit, all your files are essentially part of your versioning system. If you are going to remove a file, do so via the git rm command. Otherwise, you might your app behaving differently in your development and production environments.
  2. If you use the https URI for your Github repo (like, https://github.com/siruguri/rails_test), you can’t use SSH keys. If you want to do that, you have to use the http version, like so:
  3. git remote set-url <your Github remote name> git@github.com:siruguri/Categorizer

I am sure I’ll learn more as I go along!

 

Heroku and Public Keys: The Full Monty

When you first install the Heroku Toolbelt on your machine, there’s a good chance you will run into a problem with pushing your code via git to the Heroku remote. The common issue is an error message that looks something like this:

Permission denied (publickey).
fatal: Could not read from remote repository.

What you are seeing here is a problem with how your private/public key pairs are configured between your computer and the Heroku server. If you already know what public/private key pairs are, you can skip ahead to the explanation of how to fix this.

Read More →

Adding Custom Styles via the WordPress Visual Editor

Specifically, this is about adding the ability to select pieces of text inside your tinyMCE editor, and having a dropdown of styles to choose from that you can apply to that text.

You need to do two things –

  1. Edit your theme’s style, which you can do from the WordPress dashboard, via Appearance → Edit CSS. Add a style element that looks something like .classname {font-size: 1em}.
  2. This is the tricky part – you have to edit code now. You need to tell the editor to load a drop down called Styles, which will have the styles you want to be able to apply. Look at how it’s done here – the code is explained fairly well.

Read More →

Apache Solr vs Elastic Search: Another Take

I asked a co-worker to help me understand the differences between the two systems/appilcations, and here’s what he said (with PII removed). I am publishing it here because I think it’s a great narration:

My background using Lucene, Solr, and ElasticSearch: a few years ago, I was asked to participate in a project as the architect, lead developer, and manufacturing SME.  Let’s call it KTRP.

KTRP was purposed for many functions/capabilities; one being the aggregation, indexing, search, and other NLP capabilities against product engineering documents, tech specifications, and support documentation. I chose Lucene as the index/search engine.

Read More →