Hiding elements when javascript is enabled

I was cleaning up some javascript notifications for a website and came across this common question: what is the best way for elements to be visible when a user does not have javascript enabled but hidden when they do (often to be revealed by javascript? I cam across an article titled How To Hide And …

Continue reading ‘Hiding elements when javascript is enabled’ »

Ruby Arrays and Hashes and Days of the Week.

I was playing around with different ways to represent the days of the week and their index from 0 to 6 as hashes and arrays.  Here’s what I cam up with: irb(main):001:0> require ‘date’ => true irb(main):002:0> Date::DAYNAMES => [“Sunday”, “Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday”] irb(main):003:0> Date::DAYNAMES.enum_with_index.to_a => [[“Sunday”, 0], [“Monday”, 1], [“Tuesday”, 2], …

Continue reading ‘Ruby Arrays and Hashes and Days of the Week.’ »

Blocking Spam with Javascript

So I am trying the WP-SpamFree Anti-Spam plugin for WordPress.  It uses javascript to prevent spam.  I’m really hesitant because I prefer websites which do not require javascipt for their basic functionality.  Perhaps I will use another spam blocker.  Or perhaps I will just resign myself to accepting that functional javascript is requirement from browsing …

Continue reading ‘Blocking Spam with Javascript’ »

2 ways to use LIKE queries with wildcards safely in Rails finders

It is important to sanitize variables that may come from users to prevent SQL injection attacks.  Rails makes this easy by default: Author.find(:all, :conditions=>[‘first_name = ?’, first_name] However this will not work: Author.find(:all, :conditions=>[‘first_name LIKE “%?%”‘, first_name] This will work but is  insecure: Author.find(:all, :conditions=>”first_name LIKE ‘%#{first_name}%'” Solution 1: Author.find(:all, :conditions=>[‘first_name LIKE ?’, “%#{first_name}%”] Solution …

Continue reading ‘2 ways to use LIKE queries with wildcards safely in Rails finders’ »

Running Xen on Various Linux Distributions

I have been looking to various GNU/Linux distributions to determine their level of support for Xen.  Here’s what I found: Debian Etch – Xen Hypervisor 3.2.1 (via backports), Linux kernel 2.6.26 (via backports) Debian Lenny – Xen Hypervisor 3.2.1, Linux dom0 kernel 2.6.26 Debian Squeeze (testing) – Xen Hypervisor 3.4.2, Linux dom0 kernel ??? Ubuntu 8.04 (Hardy) …

Continue reading ‘Running Xen on Various Linux Distributions’ »

Fixing pygrub in Ubuntu 9.04

I think Ubuntu 9.04 is the only version of Ubuntu suffering from this bug but it appears as though no fix for this serious regression will be forthcoming.  To get pygrub to work you actually have to fix a bug in the python 2.5 curses library.  Open “/usr/lib/python2.5/curses/__init__.py” and add the following lines starting at …

Continue reading ‘Fixing pygrub in Ubuntu 9.04’ »

FileZilla sends spaces in user name fields

Just got done helping a user debug connection problems using FileZilla to connect over SFTP/SSH.  I noticed, sadly not immediately, that the username he was using was being send with an extra space at the end and thus was an invalid user.  I’m not sure there is a valid reason not to trim/strip whitespace from …

Continue reading ‘FileZilla sends spaces in user name fields’ »

Open Source Search Engines with Web Crawling and HTML Indexing

The term search engine is particularly vague.  It can mean an online search engine, or it can mean software that provides something similar to the online search engines, or it can mean software that does fulltext indexing and querying.  I specifically wanted to find a tool that could be used to create a niche search …

Continue reading ‘Open Source Search Engines with Web Crawling and HTML Indexing’ »

Setting up a user with only scp and sftp access

In the olden days one had to use packages such as scponly and rssh in order to restrict a user account to just being able to use scp and sftp.  Now that functionality is built into OpenSSH.  A client wanted me to setup such an account for 1 user on a system.  I modified sshd_config …

Continue reading ‘Setting up a user with only scp and sftp access’ »