Computer Programming

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

My First AngularJS Directive: Stretchdown - stretches an element to the bottom of the window.

I've made may first directive! OK, not that special, but to me it is. This is one of the more difficult features I've come across in Angular, and I still don't really "get it".

I'm not even going to do a code walkthrough, because I can't really explain it well. The easy part is calculating the height the element should be. The tricky part is implementation.

Chrome Rendering Glitch with Label's Padding in Points (PT), Even Values

I have to learn the Chromium bug reporting system. Found an interesting rendering bug if, on a label, you specify a padding with an even number of points (pt), the rendering is shifted up a little bit, and the border can disappear if it's adjacent to another element.

Two examples are attached, differing only in the amount of padding.

Maybe it's a difference in how the values are calculated and either rounded off or truncated.

The problem goes away if you use pixels instead of points.

WordPress: Setting the META Description to part of the page's content

This code puts the first paragraph of the post into the description meta tag. It tries to strip out leading whitespace and any tags. If you insert an image, it should be stripped.

R Database Connection Class in RS (R5 S5)

I'm learning R, and it's been interesting. The weird part is that I don't know stats. Yes, I know standard deviation, mean deviation, and easy stuff, but those are one-liners in the R tutorials. What I know in stats amounts to around 1/4 to 1/2 a page of the R tutorial. So to compensate, I have a stats text from the thrift store, so I'll eventually be less than a total ignoramus about what I'm reading.

One of the twists of what I'm messing with is that all our data is in a database. The normal mode of operation for R users is to load the entire data table into memory and do awesome reporting on it. Where I'm at, for better or worse, is more like a traditional web application with a database back end.

A problem with this is that MySQL lets me have only 16 connections going at the same time. I'm not sure if it's the driver, but I'll assume that. Since RStudio holds the connections, coding a lot of changes eventually leads to a lot of lost database connection handles, and eventually running out of connections.

Installing R Packages Globally (for rApache)

For general instructions, see: http://cran.r-project.org/doc/manuals/R-admin.html#Managing-libraries.

In Ubuntu Linux, the path to the global libraries is: /usr/local/lib/R/site-library/

To install there, you can do install.packages(c('foo'), '/usr/local/lib/R/site-library/')

or take advantage of the built in variable: install.packages(c('foo'), .Library.site[1])

Check that .Library.site has the values you need.

You can also use R CMD INSTALL -l /path/to/library foo

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.

PHP with Less Risk

An extremely short article about how to avoid pitfalls that will get you hacked. I've been hacked, so I kind of know this from experience.

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.

Rich Text Editors for Email, in HTML Browsers

I've been working on this email layout hack, and started to build it from content, and came to the inevitable conclusion that email and web are two different media.

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.

Syndicate content