web-programming

You are currently browsing articles tagged web-programming.

New Theory of Technology Work

Quoting myself from an email to a colleague:

Why I stayed so long at *****, where the primary thing I was working on was traditional ASP, I have no idea. I’m coming to think if a job isn’t making you smarter, it’s making you dumber. And *** man, every line of VBScript I code makes me dumber.

Tags:

Browser Wars II

I so wanted to go to this – folks from Internet Explorer, Mozilla, and Opera PLUS my JavaScript hero Douglas Crockford getting together to talk browsers: YUI Theater — “Browser Wars Episode II: Attack of the DOMs” [Yahoo! User Interface Blog]

I will be watching this.

Hi, I’m Joe, and I’m a browser nerd.  Hi Joe.

Tags:

Stupid Code Tricks:

Ruby http://www.ruby-doc.org/docs/ruby-doc-bundle/Manual/man-1.4/syntax.html#assign
foo, bar = [1, 2]

PHP http://www.php.net/manual/en/function.list.php
list($foo, $bar) = array(1, 2);

JavaScript http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7#Destructuring_assignment
[foo, bar] = [1, 2];  // I believe this is only valid in the latest versions of Firefox.

Tags:

Turn off Magic Quotes in PHP via .htaccess

#.htaccess SETTINGS TO TURN OFF

  1. STUPID MAGIC QUOTES IN PHP
  2. I HATE MAGIC QUOTES PROBLEMS
    php_flag magic_quotes_gpc off

Tags:

Loading TinyMCE on the fly

Let’s say you have a textarea that is called into a page dynamically, say with an AJAX loaded chunk of HTML with a textarea in it. If you want that textarea to have TinyMCE applied to it, you need to call a script. This was a fun one to think through and debug, and it speaks well of TinyMCE’s design that this method is available.

Tags:

Trailing commas in an array OK in PHP

I was editing some code today and saw what looked like an error to me, but nothing was broken on the code I was looking at it, so I was prompted to look it up. And indeed, in PHP:

“Having a trailing comma after the last defined array entry, while unusual, is a valid syntax.”

So sayeth the documentation for PHP: array
If it says it in there, it must be true.
So this is legal php:

$my_array = array(‘foo’,’bar’,’bat’,);

... which, as I said, looks so bizarre to me.

Tags:

Display a Brace in Smarty Code

The “literal” tag should do it:

{literal}
{works}
{/literal}

Smarty info.

(By the way, yes, the blog is still screwed up. I’m busy. Gimme a break. I was up till one last night working on it and no joy. Yuck. This is what I get for a rushed upgrade.)

Tags:

Bitmasks

I’m doing work with bitmasks these days, working on system maintenance on a web application I had nothing to do with building. One of the things it does is use Bitmasks to keep track of some customer data states. I’m not sure I like it, but I can’t deny that it’s a way to preserve staus in a very compact way.

Mask (computing) – Wikipedia, the free encyclopedia
The most common mask used, also known as a bitmask, extracts the status of certain bits in a binary string or number. For example, if we have the binary string 100111010 and we want to extract the status of the fifth bit counting along from the most significant bit, we would use a bitmask such as 000010000 and use the bitwise AND operator. Recalling that 1 AND 1 = 1, with 0 otherwise, we find the status of the fifth bit.

Tags:

“Click to activate and use this control”

Yuck.

This is the latest in a series of failures in the last 24 hours.

Eolas and Microsoft are cheesing me off this afternoon.

Tags:

JavaScript trim() function

it’s hokey, but it’s a nice basis for some other things. why didn’t i go looking for this last night when i was slamming my head against stupid code? ugh.
function trim(str)
{

while(‘’+str.charAt(0)==’ ‘)
str=str.substring(1,str.length);
while(‘’+str.charAt(str.length-1)==’ ‘)
str=str.substring(0,str.length-1);
return str;
}

Tags:

« Older entries