Computer Programming

Yes, a bit specific, but I need to store some links!

PHP with More Coolness

A short article explaining how to improve your experience and produce slightly better code.

URLs: it's important to define your URLs rather than exposing all your PHP files to the world.

Use routes - study the one in ZF2 but don't copy it unless you really need it. CodeIgniter's is pretty nice too. Routes help map URLs to classes and methods.

If you don't want to use routes, use Apache's mod_rewrite. It's faster, and also awesome. It tranforms specific URL into specifc requests to specific scripts.

CSS Hints for Technoids Who Forgot to Learn CSS

This article is being rewritten. If you want the latest, contact johnk at this domain.

The original was written: 2004-11-18 03:16:46 -0700.

Here's a bit of the article:

Dang, but it took me forever to learn CSS. Maybe I should have used a book. Here, I'm going to share with you the hard-found knowledge, presented using technical programmer jargon. (Revised in 2014.)

What is Cascading Style Sheets (CSS)? The typical answer is that it's a way to separate the way a page looks from the the underlying HTML, which describes the structure of the document.

CSS Stylesheet Switcher Widget

This snippet of code can be modified and used to change the stylesheet on your page. I set it up to work against a layout extracted from Salsa, but it should work on generic pages. It's good for demos, discussions about a layout, trying different colors, etc.

Tiny Javascript Cookie Library

This is one of those "why bother with an external library" moments. Mostly copied from MDN.

TPCalc for Android

A while back, I made a little program called TPCalc to do one of my favorite mundane activities, which is to determine the best price for toilet paper at

Notes

I got the ezmlm migration working, which is cool. Mailman and mail migration will be easier. So I took a day off. (Web migration will be a headache.)

Rewriting Code

There is no great writing, only great rewriting. - Justice Brandeis

I'm not much of a Python coder, but I'm learning to be a pretty good Python re-coder.

Button to Scroll to Top of the Page

Mobile websites all seem to have this button, which appears when you've scrolled down a bit. The button scrolls you back to the top of the page, where most of the menus reside.

Converting Time or Datetime to UTC in Python

This seems so basic, it's almost embarrassing to publish, but this showed up a few times on Stackexchange. I had trouble figuring it out, too, partly because the Python docs are so lengthy.

Exception - what is it?

What's an Exception?

Using strings to create functions

One of the less-used features is the Function() object, which can turn a string of Javascript code into a function. This is an example of how it can be useful.

Script to Compile Videos from JPGs Uploaded from Low-End IP Camera DLINK DCS-932L

This script uses ImageMagick and AVConc (ffmpeg) to convert images uploaded by a low-end DLINK internet camera to an FTP server.

Bookmarklet to Mass-Unfollow Twitter Users

I almost wrote a page for this, but it turns out a bookmarklet is good enough:

javascript:$('.js-follow-btn').click();undefined;

Logging Very Slow SQL Queries, in PHP

MySQL has a feature to log slow queries, and it's nice, but the problem is, a lot of the queries look alike. So what you want is a backtrace so you can find the code that created the query.

Syndicate content