Login shells in scripts called from cron
The problem
I would guess that almost anyone who has set up a cron job has also had a cron job not work for initially mysterious reasons that often stem from cron running in a minimal environment very different from the same user’s normal login shell. For example, cron typically runs with:
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/binWhereas a common login shell has this in its environment, often with much more in the PATH:
SHELL=/bin/bash
PATH=/usr/local/bin:/bin:/usr/bin:$HOME/bin/bin/sh may be bash, but bash behaves differently when invoked as sh. It may also be another shell such as dash. And the impact of PATH differences is obvious, not just on the commands in the crontab but also in scripts they invoke.
I’ve been dealing with this for many years but it reached a new level of frequency with new systems like rvm, rbenv, Perlbrew, and pyenv, among others, which depend on the environment or shell aliases being modified.
The benefits of such multi-version local user-installed software are obvious, but the downside is that you have users installing various software that ends up being used in production, without sufficient wariness of production gotchas such as:
- the …
devops linux perl python ruby
GnuPG: list all recipients of a message
At End Point we frequently use GnuPG for PGP-compatible secure data storage and delivery, both internally and with some of our clients.
For many years, GnuPG 1 has been the standard for Unix-like operating systems such as Linux and Mac OS X, as well as Windows. Relatively new is GnuPG 2, which is a modularized version but not (yet) a replacement. It’s often built and installed as “gpg2” so it can coexist with trusty old “gpg” version 1. I mention this to raise awareness, since it seems to be little known.
When you have an encrypted file, how can you see who the recipients are who will be able to decrypt it? It’s easy enough to test if you can decrypt it, by just trying and seeing if it lets you. But what if you want to confirm others can see it before you send it to them? The manpage shows this option:
–list-only
Changes the behaviour of some commands. This is like –dry-run but different in some cases. The semantic of this command may be extended in the future. Currently it only skips the actual decryption pass and therefore enables a fast listing of the encryption keys.
That sounds like the answer. And it almost is. However, for no reason I can discern, it doesn’t …
security
Honor your elders (and others)
What an odd topic, you might be thinking. Some time ago, I began teaching my elders (who are rapidly becoming my contemporaries, curse you, Father Time) how to navigate the Internet. After almost two years of this, I’ve become more sensitized to seeing the ’Net from their POV.
Here’s a small fragment of a page I saw today (actual size):
The page numbers and arrowheads are the only navigation elements on this huge, complex page that allow you to move around the list of products. The numbers are an 11px font, and the arrowheads are 6px by 8px. For a senior citizen, or indeed anyone with less than perfect vision and eye-hand coordination, this is pretty challenging to find on the page, let alone use.
Here’s a quick challenge for you as web designer: try dimming your screen down a bit, to the point where it’s noticeably uncomfortable to use. Does your page still seem easy to navigate? Now try switching from your dominant hand to your other hand, and try clicking your page navigation elements (not just buttons, but drop-downs, menus, etc.). Still usable? If not, you may be designing your page to keep away some users. Just a thought.
design user-interface
End Point Liquid Galaxy Projects at Google I/O 2013
This last week End Point participated in the Google I/O conference for the third year in a row. As the lead agency for Liquid Galaxy development and deployment, our engineers were active in the development efforts for the two Liquid Galaxy systems that were showcased at the conference this year.
We sent two of our rock stars to the show, Kiel and Matt. This year both Liquid Galaxies used Google Maps API functionality in the browser rather than the stand-alone Google Earth app:
-
Treadmill-driven Google Trekker: Working with Sparks Online, this showed a treadmill connected to the Google Trekker Trails panoramic imagery. Walking on the treadmill moves the view forward through the Bright Angel Trail in Grand Canyon. The tricky part being the curves in the trail, especially switchbacks: with no mouse to adjust the view, how to keep the view on the path when the input (the movement of the treadmill) was just “straight forward”? Our engineer, Kiel, used functions around Maps API data to automatically calculate the “closest frame” that would be next in line, and then force-feeds it to the Trail View, so “forward” is always centered on the path, no matter if the next frame is actually five …
conference event visionport maps
Travis build log doesn’t display
Remember when “clear your cookies and try it again” was the first suggestion when a webpage was behaving badly? I remember that time of darkness, that time of early Internet Explorer, well, existing. I remember it being the only browser allowed in some offices and even being mandatory for some major websites. Remember that? Pepperidge Farm remembers.
But we’ve evolved. These are brighter days. Around these parts, “Did you clear your cookies?” is typically only said in jest. So, imagine my surprise when I accidentally discovered that clearing my cookies was exactly what resolved my issue with our Travis-CI.org build logs failing to display. Seriously. Imagine it. Go ahead, I’ll wait.
On March 21st 2013, the beautiful and talented Travis CI service deployed a bad build of their own app. It contained a bug that caused build logs to fail to display. You could still see the builds and statuses under the Build History tab, but never any logs. This was right about the same time I had pushed a big refactor that used a new config file format for our app. It passed all our tests locally, but it was driving me nuts that I couldn’t find out why it was failing on Travis. It was also displaying …
browsers tips
Isolation Test Helper for Rails Development
Lately I’ve been inspired to test drive my development as much as possible. One thing that is absolutely critical for test driven development is fast feedback from your tests. Because of this, I try to remove the “Rails” dependency as often as possible from my tests so I don’t have to wait for Rails to load for my tests to run. Sure, I could use spork or zeus to pre-load Rails, but I find that those tools don’t always reload the files I’m working on. Besides, I believe that much of your application should be plain old ruby objects that are well designed.
One of the things I continually bump against with isolated tests is that there are a few things that I always have to do to get my isolated tests to work. Since we are accustomed to requiring spec_helper.rb or test_helper.rb for tests dependent on Rails, I decided to build a helper for when I run isolated tests to just load some niceties that make running them a little easier.
So, here’s the full code from my isolation helper (this one works with RSpec).
# spec/isolation_helper.rb
DO_ISOLATION = ! defined?(Rails)
def isolate_from_rails(&block)
return unless DO_ISOLATION
block.call
end
isolate_from_rails do
require …ruby rails testing
Making Python Code a Little Bit Cleaner
When you develop a program in a group of programmers, it is really important to have some standards. Especially helpful are standards of naming things and formatting code. If all team members format the code in the same way and use consistent names, then it is much easier to read the code. This also means that the team works faster.
The same rules apply when you develop software in Python.
For Python there is a document which describes some of the most desirable style features for Python code Style Guide for Python Code. However there are some problems with that, as even the standard Python library has some libraries which are not consistent. This shouldn’t be an excuse for your team to be inconsistent as well. Ensuring that the code is nice and readable is worth working for a moment on that.
In Python there are two tools which I use for writing code in Python—Python style guide checker and Python code static checker.
pep8
Program pep8 is a simple tool checking Python code against some of the style conventions in PEP 8 document.
Installation
You can install it within your virtual environment with simple:
pip install pep8Usage
Let’s test the pep8 command on such an ugly Python …
python
Adventures with using Ruby 2.0 and libreadline
I was asked to develop a prototype app for one of our clients lately. The basis for this app was an old Rails app:
- Rails 3.2.8
- RailsAdmin
- MySQL
- rbenv + ruby-build
I wanted to upgrade the stack to work with latest toys all cool kids are so thrilled about. I also didn’t have Rails console facility at my disposal since the Ruby version installed on the development machine hadn’t been compiled against libreadline.
Not having root or sudo access on the machine I embarked on a sligthly hacky journey to make myself a better working environment.
Ruby 2.0
After reading Mike Farmer’s blog post about Ruby 2.0 and tons of other material about it on the Internet, I wanted to get a feeling of how faster & greater the new Ruby is. It’s always great also to stay up-to-date with latest technologies. It’s great for me as a developer, and more importantly—it’s great for our clients.
Importance of libreadline in development with Ruby
To be productive developing any Rails-based application, we have to have Rails-console available at any moment. It serves a multitude of purposes. It’s also a great scratch-pad when developing methods.
While you don’t need your Ruby to support libreadline for basic …
shell environment ruby rails
