Web programming techniques, tips, and tricks are explained in a helpful, easy-to-understand way for all skill levels--daily articles for beginning through extremely advanced developers.
![]()
![]()
|
Did you know there is a romantic story behind Debian? The name stands for "Deb" and "Ian"--first the girl that a man loved, and secondly the man who loved her and married her.
By the way, to make a proper "dash" in HTML code, one types ——like that, see?
It works wonderfully on the original webpage; however, when someone copies and pastes this text, it may
turn into an upside-down question mark, or another mysterious symbol. So it is still safest to use the
old standby of two hypens--instead of a true dash--in any text that is intended for widespread circulation.
This website should win an award for its beautiful idea and beautiful code: Type Upside Down
I observed a position advertisement for a top-tier computer job, "Freelance Senior Front End Developer" in Los Angeles. The first two key requirements were "Solid hand-coding..." and "Hand-code...."
Smart. Very smart. The company creating this advertisement knew what it was looking for. You see, teenagers, even children, are all becoming "technologically adept." They know about "stuff" like HTML, YouTube, Google.
However, one thing hasn't changed. The great masses of people are still divided, as before, into two large groups. The consumers. And the producers.
The consumers are the ones who watch movies on YouTube, make posts in Facebook, search for plaigarizable English essays on Google for high school or college. They can "consume" the new stuff: HTML and all that. But they can't produce it. They wouldn't know A from B if they had to create Google or YouTube by hand.
The producers are the ones who can actually write HTML--not by making a post or using a blog--no, indeed--they are the ones who can write HTML by hand. They are the ones who could use JavaScript and Perl to create a website like YouTube. Perhaps not attract one billion visitors, which takes incredible luck as well as a great deal of resources and money. But someone who can do it by hand has the potential even to create Google, YouTube, or something even better.
The same story goes frighteningly deeper. The consumers are the ones who can plug things into their computer, or perhaps even put a computer together.
The producers are the ones who can actually design and engineer a computer chip, who know how to generate electricity, who know how it all works together. Just think... how many people are there in the entire world, in this age of technology, who actually know enough mathematics, physics, chemistry, and information theory to actually create a computer chip, one of the crowning achievements of science? How many of us know how to imprint almost one billion microscopic electronic circuit components into grains of silicon, germanium, and other semiconductor materials and dopants, to form the heart of a computer?
Not I. At this deeper level hardly anyone knows how to do it "by hand," and that is the accomplishment that is the most critical of all.
You see, if no one learns to do it by hand, then there aren't going to be any more computers after a while. No one would know how to build them.
That is a worthwhile goal, to learn to do something by hand, to be a producer rather than a consumer, to be one of the ones who could build machines to build machines to build machines, to ultimately build machines that could build computers.
At whatever level you are, this is a guiding principle. Learning to do anything "by hand"--rather than by "pushing the button," "opening the box," or using so-called WYSIWYG software to do it--is worthwhile and it will open new vistas of enjoyment that you never knew before. Knowledge always adds to our capability of pleasure. The more we know, the more we understand what is worthwhile, and our deepest satisfaction can be obtained--summarized in two words--by being able to do things "by hand."
I went to Best Buy on Friday, October 9, 2009, and I asked if they had the EOS 7D. The sales lady smiled, probably because it was the new arrival they were playing with the night before. Officially, Best Buy hadn't received it, but she told me they actually had two of them. Lo and behold, hidden under the bottom shelf deep inside the display cabinet, they did! She seemed blown away that no sooner did they get them than they were sold. In fact, she told me that the other camera had already been ordered and was being held for a previous customer.
The bottom line was that I am the lucky owner of the first Canon EOS 7D advanced digital SLR in the state of Kansas!
images witheld due to copyright
Notice how fast the focus has shifted in only 1/8th of a second between the frames above! As always, the quality at ISO 800 is phenomenal. (Taken with Canon 100mm f/2.0 at f/2.5 and 1/800 second exposure.)
Here is yet another outstanding picture--a tip-off by the star of the volleyball team:
images witheld due to copyright
And a beautiful picture of a sunflower still living at the beginning of winter--
P.S. When I opened the camera there were a few fingerprints on the LCD glass--yep, I'd say that some little elves were playing with it the night before!
To answer the first question, I took the picture of the lonely little sunflower (above) at the lowest quality setting (4.5 MP, lower quality). Then I used the canonical image compression algorithms from libjpeg / indepenedent JPEG group (available in the package libjpeg-progs for Linux Mint or Ubuntu, etc.) to decompress and recompress the image data until the same output quality and size was obtained.
Wow! I plan to use low quality from now on unless I'm making RAW files. However, I have never found a practical use for RAW files in years of digital photography. In fact, here is the dirty secret of RAW files: it would take an accomplished expert hours of image processing time to match the same precision adjustments that are made to the image by the camera automatically when it exports image data to JPEG. The camera already has access to the full RAW data when it creates the JPEG image, and it optimizes and improves it automatically before creating the JPEG. So when you get the JPEG you are getting the best you can get.
The answer to my second question is a definite yes--I have noticed that high ISO performance matches full frame cameras at 4.5 MP (when 4 adjacent pixels are used to collect light for one pixel of the final image). In fact, at 4.5 MP you are getting at least 60% of the image quality and detail that you are at 18 MP.
Thus I shoot all my sports photography at 4.5 MP. Last weekend I did so at high quality, but now I'm going to do so at normal quality, since this corresponds to 93% JPEG quality (which is extremely excellent) based on the conclusion to my first experiment!
If you want to get the deplorable tocloft and other
latex packages, the right software to install is called
texlive-latex-extra.
Warning! It is a 94.8 MB download.
Here are some very good notes about writing a thesis/dissertation with Latex, and a few more good latex tips for formatting dissertations are here.
I recommend Active@ ISO Burner. Previously I used ISO Recorder by Feinburg, but it repeatedly produced worthless operating system DVDs for FreeBSD 7.2 and openSUSE 11.1. Plus, it was not able to verify after recording.
p { margin: 0em; text-indent: 2em }
Adding the above CSS instructions will cause paragraphs to be indented but not separated by whitespace. It really saves a lot of paper and scrolling time.
Thanks, God!
God, I love you, and I appreciate everything you have done for me and all of us. Please help everyone to become Christians. God, please save. I love you. In Jesus' name. Amen.
After I wake up the computer, sometimes my cordless mouse takes a while to start working. I can just touch the keyboard and it will wake up the computer and work. Maybe I should wake the computer up with the mouse and then the keyboard won't work for a while.
I hope to be trying out Windows 7 after I build a new computer. The ingredients are an AMD Kuma 7750 X2, Asus M4A78 PLUS AM3 770/SB700 motherboard, Seagate 7200.12 640 GB hard drive, and a Cooler Master Elite 335 ATX Case, plus a 500 watt Cooler Master power supply. I will plan to add an NVIDIA 9600 GSO 768 MB graphics processor.
I'm updating my quad core computer to FreeBSD 7.2, using the same method as before. There are 11,019 patches to be downloaded, currently being downloaded.
I am also reorganizing my office, installing a Kodak ESP-3 printer ($89 from Wal-Mart, a great buy!) and a TrendNet TK-207K KVM (keyboard, video, and mouse) switch.
OK, in the time it took me to type that, and read the model numbers, all of the patches have been downloaded.
(Actually, I am writing this on Sunday, even though the date says . I don't believe in working on Sunday on purpose, but I am waiting for the drivers for the Kodak All-in-One printer to finish downloading. The Kodak download/support website must be extremely slow because only 107/267 MB have been downloaded after at least half an hour. Since I write this daily, but not on Sunday, pretend like today is yesterday.)
Updating FreeBSD is silly in the fact that I must read through 500,000+ bytes of removals and additions (could I really check them carefully?), without the opportunity to save them to a file and grep them, if I really was aware of a possible problem that might occur.
The problem with rebooting is that the network administrator has blocked the quad-core computer's MAC address. Last December I had a version of openSUSE (11.1) installed which nearly fried the network because for several weeks it requested a new IP address from the DHCP server at a rate of approximately one request per second. The silly people won't believe that it was the operating system's fault. They think the hardware was buggy, but I have been running FreeBSD since then with no problems. But I still have to manually change my MAC address in order to get on the network any time I reboot, like now while updating my system. Bother.
Also, my USB keyboard and mouse don't work right. Maybe it does have to do with the motherboard, which is a Gigabyte GA-MA78GPM-DS2H with a AMD Phenom X4 9750 OEM processor.
I the combo from Frys.com on September 5th, 2009 for $219.99 + $7.48 = $227.47. The processor arrived totally unusable with bent pins and no protective foam, just taped onto the top of the motherboard box. There was some kind of protection in the shipping box, but instead of being wrapped around the contents, the motherboard was just dumped into the bottom of the box and some insulation stuffed only on top. Me and my brother were able to get the processor to fit the motherboard by straightening the bent pins carefully with the blade of a pocketknife.
Ah, ha! At 10:12 PM my printer software is at last being installed.
The first print turned out blank white, but the second
attempt produced a beautiful 4x6" print. Kodak kind of swindled
me because I hoped to print an 8x10" print, but when I opened
the free pack of 8x10" photo paper it really just contained
8x10" regular white paper, and only a few 4x6" pieces of photo
paper. (I hate that emacs keeps turning my
text green or white each time I type another " quote mark.
Its HTML mode is very stupid.)
I can't really think of anything to do or say.
My supper is burning in the oven! But today I updated my computer to FreeBSD 7.2.
freebsd-update upgrade -r 7.2-RELEASE # say yes to several questions freebsd-update install shutdown -r now # then freebsd-update install shutdown -r now
I had to do this because I noticed bash was not working,
and also /var/spool/mqueue had about 80,000
files in it of pure junk, using up all my inodes for that
disk slice.
Some people I tutor had great test results today. My math class had a pizza and food celebration since today is our last day of class.
This is a function that dynamically shows prices for any elements of a form.
One of the worst things you can do to a computer user is to move their cursor from where they are typing to another location on the screen. For instance, if I log out of Hotmail and try to type another web address into my browser, MSN's homepage shows up instead, and focuses my cursor onto the MSN search box. And my entire URL is ruined. Then when I click back to the location bar, the text is selected, so that it is all deleted when I try to continue typing. So I have to remember to carefully click twice, not too fast, or else it will be a double click. After clicking twice, then I can move the cursor to the end of what I just typed in. Finally, 60 seconds later, I am ready to bash in my entire $1,000 computer, sue MSN for one billion dollars, and shout bloody murder at the top of my lungs.
The same scenario happens millions of times every day to people. It has happened hundreds of times to me, most noticably after signing out of Hotmail, or before signing into Yahoo! Mail. In the case of Yahoo! Mail, my cursor is focused onto the login name while I am in the middle of typing my password. This ruins my login name, and ruins my password, plus it shows my password to anybody watching over my shoulder, and I have to enter everything again, with the same frustrations.
Other things that bug me are not being able to change my cart when I am at the end of an ordering process, or be able to re-enter coupons codes, etc. Walgreens has been overloaded today with photo customers due to an 8x10" free enlargement special for Mother's Day. I have tried about eight times to order my free enlargement. It was unable to respond to my search for the nearest store location, which ruined my order. Before that I had been completely unable to login to the photo center. Finally, I finished my order, but the coupon code I entered several hours before was no longer in my cart. So I had to cancel that.
My class ended at 8:20 pm, and it is 8:43. I still have required running to do tonight, have groceries to buy, food to make, everything to do, and I am still trying to Checkout from Walgreen's.
Moral of the story: don't offer a stupid $3 coupon that will cause a thousand customers to experience the worst day of their lives.
Technical moral of the story: give people more freedom in their online shopping carts so that maybe, just maybe, more of them could have finished their orders the first time through despite all the hangups, slow connections, and other delays.
P.S. Code that will make sure you don't focus after the user has started to type somewhere or clicked somewhere:
<input type="text" onfocus="self.donotfocus=1" />
...
onload = function() {
if (self.donotfocus)
return;
document.otherform.otherfield.focus();
}
P.P.S. My order did not work again. I am trying one more time...
Final update: 9:02 PM (and time is ticking while I'm typing). I completed my order successfully after giving up on the coupon.... WAIT NO, IT DIDN'T WORK. Even after agreeing to pay $3.23 (including tax) after trying all day to get my free photo, Walgreens.com still can't process my order. I have entered an infinite loop of this:
Repeat the above loop forever.
string = 'Jesus loves you!!!';
function doString(s) {
var i, f, n;
n = s.length;
s = s.split('');
f = function(x) { return Math.round(1000*Math.pow(-(x+1)*(x - n)/n/n, 2)); }
for (i=0; i<s.length; i++) {
s[i] = '<span style="font-size: ' + (16+f(i)) + 'px">' + s[i] + '</span>';
}
return s.join('');
}
document.write(doString(string));
jQuery is no good. It imports all sorts of intensive code, wastes bandwidth, and does many harmful things. All the articles I have read about it never teach anything, just show one some of the names of the functions, and then say "it's so great!"
There has been no good sale today for computer components that I need to build the research computer. What I still need is a motherboard and case / power supply.
I'd like to design a new computer which can freely run many operating systems. My setup will be three computers:
So anyway, the first component I have for the research computer is an nVidia GeForce 9600 GSO 768 MB graphics card. I ordered it from Frys.com for $79.99 - $40.00 MIR = $39.99. I am very interested in keeping track of the total.
I have ordered, but not received, a Samsung Touch of Color 26" monitor. Also, I have already acquired an AMD Kuma 7750 processor with a free bonus Seagate 640 GB hard drive, about two weeks ago. What I need now is a good case and a good motherboard, for a good price.
The following form input field will turn green if it contains a numeric value, white when empty, and red if it contains a non-numeric value. This is useful for providing visual form validation.
<script>
function visual_number_check(o) {
var s = o.style;
if (o.value.length < 1)
s.background = '#fff';
else if (isNaN(o.value))
s.background = '#f99';
else
s.background = '#9f9';
}
</script>
<form>
Enter a number: <input type="text" onkeyup="visual_number_check(this)" />
</form>
The way you allow a form to submit files (for uploading) as
part of its data, is to set the enctype attribute to multipart/form-data,
i.e, enctype="multipart/formdata".
How does one make an instant search filter, which selects matching topics automatically while the user types?
Simple! Just look at the source code for today and copy the match() and liHide() functions, and then use a form like this:
<form> <b>Filter the list below by inputting desired keywords:</b> <input type="text" onkeyup="liHide(this.value, 'resultsA')" /> </form> <ul id="resultsA"> <li>Contents of first result</li> <li>etc.</li> <li>...</li> </ul>
The search matching function is extremely intelligent, matching tokens anywhere in the sentence, in any order.
Also, try it out on Genesis chapter one, verses 1-10:
How do you make alert messages?
alert('Hi, this is the alert message you want.');
Remember to place a backslash \ before any single quote marks that occur in the alert message.
I work on putty for ssh, and I use metapad for text editing, when not in Unix. In Unix I just use "ssh" for ssh and I use "emacs" for text editing. I have alias the command e="emacs -nw" to prevent the despicable Xemacs interface from starting.
Some of you may be wondering, "Hey, what computers do you use?" Well, in my office I have four, plus a laptop:
What operating system should you install for reliability?
FreeBSD. I'm writing this on FreeBSD 7.0, and I am not disappointed. (Through PuTTY I am able to login from a FreeBSD 7.1 primary quad-core computer or a Windows Vista 3.0 GHz Wolfdale 45 nm secondary dual-core computer.)
top last pid: 62846; load averages: 0.00, 0.00, 0.00 up 218+00:42:08 22:13:26 57 processes: 1 running, 56 sleeping CPU states: 0.0% user, 0.0% nice, 0.0% system, 0.0% interrupt, 100% idle Mem: 182M Active, 1498M Inact, 202M Wired, 75M Cache, 112M Buf, 40M Free Swap: 988M Total, 92K Used, 988M Free
As you can see, my computer has been up 218 days, no problems. That's what FreeBSD means.
So in Latex you can do something like this to make images
and figures, using the package command \usepackage{graphicx}
and pdflatex to compile your PDF files.
\begin{figure}[htp]
\centering
\includegraphics[width=2in,height=2in]{img/1240271564-1-gi_1noise.png}
\includegraphics[width=2in,height=2in]{img/1240271564-2-gi_2noise.png}
\includegraphics[width=2in,height=2in]{img/1240271564-3-gi_5noise.png}
\caption{Inverse data $g_i$ superimposed with noisy data measurements}
\label{comparenoise}
\end{figure}
So what do you do in HTML?
<table align="center"> <caption>Inverse data <i>g<sub>i</sub></i> superimposed with noisy data measurements</caption> <tr> <td> <img width="200" height="200" src="2009/04-20/1240271564-1-gi_1noise.png" /> <img width="200" height="200" src="2009/04-20/1240271564-2-gi_2noise.png" /> <img width="200" height="200" src="2009/04-20/1240271564-3-gi_5noise.png" /> </td> </tr> </table>
|
Yep, I'm using the cute box CSS from 17 April 2009.
Try pasting the following "scriptlet" into your browser's location field:
javascript:void(document.designMode='on');
If your browser supports this type of rich text editing, then you will be able to click into elements of the web page and edit their contents. For instance, I put up a headline at MSN which stated that my officemate had been appointed to the position of finance chairman.
Of course, all the changes you make this way are not seen on any computers except your own, and when you reload the webpage, they will be gone. So enjoy your practical joking with JavaScript!
How does one make a cute little box like this?
<style>
.cat { border: inset 2px #cfc; margin: 1em }
.cat h3 { background: #cfc; margin-top: 0px; padding: .2em }
.cat p, .cat h4 { margin-left: 1em; text-indent: 2em }
</style>
<div class="cat">
<h3>Digital Camera Cards and Flash Drives</h3>
<ul>
<li><b>4 GB SDHC (secure digital high capacity) Card $20</b><br />
<i>(Compare at $40)</i>
</li>
<li><b>4 GB Flash Drive $15</b><br />
<i>(Compare at $30)</i>
</li>
</ul>
</div>
On browsers that truly support CSS, currently everything except Internet Explorer versions before 8.0, you can add one more line of CSS to make it even more lovely. The following line of code will make the box truly a "cute little box" instead of being an ordinary block element that fills up the entire width of the page.
/* add this line of CSS */
div.cat { display: table }
(We are probably going to start using beautiful little boxes like this to display our examples from now on, but we're not promising, since it takes effort to make it so beautiful.)
Today I took some extra time to program an amazing encrypted gradebook system. It was very intense, but I feel like, "I did myself proud, sir."
There are loads of code in it to enjoy.
Check out this cool website design. It looks simple, but what is cool about it is the collapsable page system. If you click on any third-level heading, like "$99 Memory Upgrade Blowout," you will see that all the contents of that section will collapse, except for the title itself. Clicking on the title again will expand the section.
Amazingly, this is all done without any special modifications to the underlying HTML. In fact, the author just pasted in this JavaScript. Using the properties of Node.parent, Node.child, and Node.nextSibling, the script creates a function which will hide or show all other content in the section underneath the section's heading. Then this function is attached to the section's heading as the onclick() event handler. Very sweet!
old = onload;
onload = function() {
var h3 = document.getElementsByTagName('h3'), i;
for (i=0; i<h3.length; i++) {
var me, parent;
me = h3[i];
parent = me.parentNode;
me.style.cursor = 'pointer';
me.onclick = function() {
var x = this;
var closing = x.adclosed ? 0 : 1;
do {
x = x.nextSibling;
if (!x)
break;
if (!x.style)
continue;
x.style.display = closing ? 'none' : '';
} while (x != this.parentNode);
this.adclosed = closing ? 1 : 0;
}
}
if (old)
return old();
}
Authentication. A digest function e = d(m) is one which accepts a message m and produces a secure fingerprint of the message. The result e cannot be decrypted to produce the message m because there is not a one-to-one relationship between inputs of the digest function and outputs. Well, what's the use of something encrypted that can't be decrypted? This is the whole purpose! Just let us explain how it works and what it is useful for.
Suppose you want to perform authentication without using standard reversible encryption methods. Your server can produce a random combination X of 16 bytes and submit this to the client. The client then types in his password Y, but the password is not submitted directly to the server. Instead, the client's browser concatenates X to Y to obtain Z, and evaluates the digest function d(Z). The result R is submitted to the server. Since the server knows both the password and the random combination X, the server can also plug them into the digest function, just like the client did. If the result the server computed is the same as the result the client submitted, then the client is successfully authorized.
What is cool is that further encryption isn't needed. Even if someone can intercept the result R, they cannot find the password. Furthermore, R is useless to an attacker, because to perform another operation on the server, the authorization process is repeated. The next time, a different random combination is generated, and a different value of R is required.
Data verification. Data fingerprints to verify the integrity of downloaded information are an obvious application of message digest functions. Suppose you downloaded a file containing 1 MB of information. There is a chance that some of the data was corrupted, so you compute its fingerprint from a message digest function. If the fingerprint of the data you received matches the fingerprint listed at the software's home page, then the probability there is any error in your data is less than one to 10 with fifty zeros after it.
Storing passwords safely. If a computer stores passwords, there is the chance that an attacker can gain access to them. To prevent this from happening, an operating system can store the fingerprint of each password. Even if the attacker finds the fingerprint he cannot reproduce the password. Mathematically, there is still a chance to find another password which has the same fingerprint since message digest functions are never one-to-one. However, for the MD5 algorithm, the attacker would have to try an average of so many passwords, before he found one that worked, that it would be equal to ten to the fiftieth power. This is almost impossible, as it would take years of computer time.
MD5 program. A message digest algorithm is a computational procedure of computing an output e from an input m in such a way that the mapping d specified by e = d(m) fulfills the desired properties of a message digest function. One of the most popular message digest algorithms is the MD5 algorithm. It is much too complicated to show all the source code in the article, but we will show all that you need to know in order to use it.
<script src="http://www.myersdaily.org/joseph/javascript/md5.js"></script> <script> password = 'cherry'; fingerprint = md5(password); d = document; d.write(fingerprint); </script>
| md5.js MD5 Algorithm by Joseph Myers | Other MD5 programs |
|---|---|
|
JKM md5.js Performance |
Other md5.js Performance |
The results shown are from Google Chromium running on a 2.79 GHz Pentium 4 with 512 MB of RAM (Dell Optiplex GX280 at a unversity computing lab). The JavaScript MD5 code tested here is very, very fast, unbeaten in many JavaScript MD5 speed tests over the years. Any MD5 algorithm is also useful for many needs of web developers.