<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>RLASKEY: words &#187; Code</title>
	<atom:link href="http://rlaskey.org/words/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://rlaskey.org/words</link>
	<description>Thoughts, by Richard Moss Laskey, III</description>
	<lastBuildDate>Thu, 19 Aug 2010 16:09:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>MySQL, playing w/ InnoDB</title>
		<link>http://rlaskey.org/words/2010/08/17/mysql-playing-w-innodb/</link>
		<comments>http://rlaskey.org/words/2010/08/17/mysql-playing-w-innodb/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 03:16:06 +0000</pubDate>
		<dc:creator>rlaskey</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://rlaskey.org/words/?p=727</guid>
		<description><![CDATA[MySQL is really rather fascinating.  I&#8217;ve been using it for years now, though in piling through more and more pages of High Performance MySQL, I&#8217;m learning loads about how it&#8217;s all put together.  I use SELECT and UPDATE and INSERT statements, w/ JOINs and INDEXes and so on; though what goes on behind the scenes, [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL is really rather fascinating.  I&#8217;ve been using it for years now, though in piling through more and more pages of High Performance MySQL, I&#8217;m learning loads about how it&#8217;s all put together.  I use SELECT and UPDATE and INSERT statements, w/ JOINs and INDEXes and so on; though what goes on behind the scenes, and how these certain queries are run and stored was for a long time a black box, to me.  Peeling back the layers is like finding new fundamental properties of a long time friend.</p>
<p>Or maybe I&#8217;ve been working too much and my mind is a bit melted.  Still, SQL is about as conversational as code can get.  SELECT name FROM people; is a bit of a snippet of a conversation, and at this point, MySQL and I have been talking for years.</p>
<h3>MyISAM and InnoDB</h3>
<p>Until recently, most projects I&#8217;ve worked on have dealt with rather small numbers.  No table has had many more than a thousand rows, and everything rather fits neatly in memory.  I&#8217;m now scaling up a bit, and am paying better attention between the differences between MySQL&#8217;s different storage engine options.  Namely, the two sides are MyISAM, the default storage system, and InnoDB.  By &#8220;storage engine,&#8221; I mean it&#8217;s the method by which MySQL actually puts the data onto the disk, and subsequently does its reads and so on with the resulting information.</p>
<p>MyISAM is sort of simple and out in the open.  CREATE TABLE countries ?  That&#8217;ll generate a countries.MYD, which is the data, and a countries.MYI, which holds the indexes.</p>
<p>InnoDB, on the other hand, is a bit more sneaky.  By default, InnoDB puts all its data, index and column information  in a single place, for all databases, tables, etc., in a file named, by default, ibdata1.</p>
<h3>ibdata1 gets obese</h3>
<p>I like a lot of aspects of InnoDB, though one thing I don&#8217;t particularly like is that this ibdata1 file can get rather large, without many options to reduce its size.  There aren&#8217;t many solutions to this, though the one I found which I&#8217;m currently employing is to enable <a href="http://dev.mysql.com/doc/refman/5.1/en/multiple-tablespaces.html">Per-Table Tablespaces</a>.  Essentially, I just add one line into the system my.cnf which reads: <code>innodb_file_per_table</code>.</p>
<h3>How to be silly and mangle your MySQL system</h3>
<p>So, armed with the single additional line in my configuration file, I decide to go wild.  I shut down the MySQL service, after checking that I indeed have no data whatsoever in any InnoDB tables in any databases.  I change the config option, and I move the ibdata1 to a temp location.</p>
<p>The server rises once, and then later decides it has lost its will to live.  Luckily, I can see the error messages in the syslog, which includes a lot of scary data and a message which reads &#8220;The log sequence number in ibdata files does not match.&#8221;</p>
<p>I realize at this point that I&#8217;ve been playing around a bit too much, and that I should have been a bit more careful.  Alas, I then move away the ib_logfile0 and ib_logfile1 files which were in the same directory as the ibdata1, restart MySQL, and the system starts these files off again at a base, zero level.</p>
<h3>.ibd reigns</h3>
<p>After my heart rate came back down to a reasonable level, I then started to play with my new config, <code>innodb_file_per_table</code>.  Indeed, now ibdata1 stays at its current level, and manipulating a table which has ENGINE=INNODB modifies a file in the database directory named tablename.ibd.</p>
<p>By default, the .ibd file is going to act in the same way as the single InnoDB store, ibdata1.  It&#8217;s going to get large and out of control.  A single table which was less around 2MB in MyISAM quickly took up 10MB as the .ibd file.  DELETE FROM tablename; and the .ibd is still 10MB.  However, DELETE FROM tablename; ALTER TABLE tablename ENGINE=INNODB; and then the .idb falls back to a much more reasonable size, as it started without any data.</p>
<p>Indeed, this type of ALTER TABLE command essentially drops the table and then regenerates itself from a temporary copy.  This is obviously a terrible idea for a production system.  It&#8217;s also always a good idea to back up before doing anything drastic.  Even so, with the given precautions and some good system downtime, this method comes out with what I consider to be a reasonable result.</p>
<p>As with anything I write here, if there&#8217;s anyone out there that can verify any further dangers or caveats, please leave me a comment so I may correct my ways.  Otherwise, hopefully these tips will allow for an extra few converts to the InnoDB system who may have been scared away when visiting the disk DB stores.</p>
]]></content:encoded>
			<wfw:commentRss>http://rlaskey.org/words/2010/08/17/mysql-playing-w-innodb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter&#8217;s Tweet Button: woo! finally ..</title>
		<link>http://rlaskey.org/words/2010/08/12/twitters-tweet-button-woo-finally/</link>
		<comments>http://rlaskey.org/words/2010/08/12/twitters-tweet-button-woo-finally/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 02:44:12 +0000</pubDate>
		<dc:creator>rlaskey</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://rlaskey.org/words/?p=710</guid>
		<description><![CDATA[Twitter released their Tweet Button today, which I&#8217;ve been able to integrate into my site in no time flat.  One JavaScript include, and a single anchor, and away it goes.   It is dead simple to add in a custom title, URL, and @username, which utilizes the relatively new HTML5 data attributes.. and it&#8217;s up [...]]]></description>
			<content:encoded><![CDATA[<p>Twitter released their <a href="http://twitter.com/goodies/tweetbutton">Tweet Button</a> today, which I&#8217;ve been able to integrate into my site in no time flat.  One JavaScript include, and a single anchor, and away it goes.   It is dead simple to add in a custom title, URL, and @username, which utilizes the relatively new HTML5 data attributes.. and it&#8217;s up in a breeze.</p>
<p>On the technical side, this is a huge step up.  Many sites are non-trivial, requiring a number of steps, and, more importantly, some reasonably obscure structures.  The tweet button also looks very nice: subtle, and entirely functional.</p>
<h3>Twitter&#8217;s scope</h3>
<p>The first competitor that comes to mind is Digg; yes, Facebook is also in the mix with its Like count, though the Digg count has been around for years now, and was, in my mind, the starter of the second run of website counters.   Furthermore, Digg launched its own shortening service more than a year ago; and as of today we now have t.co, Twitter&#8217;s crazy short domain name.</p>
<p>I&#8217;m not sure where Digg is headed, though they seem to be having a lot of trouble this past year.  I&#8217;m currently in the alpha, and I can&#8217;t say it either gets me excited or gets me to visit the page any more than I had.  I do hope they can pull it together, though with Tweets superseding Diggs, the future seems to be headed for the.. bird.</p>
<p>Then there&#8217;s Facebook, which has had its Like Button for months now.  Realistically, the Tweet Button is more in conversation with this particular element, albeit with JavaScript and HTML5 rather than a single URL with GET variables.  I&#8217;ve gotten less fond of Facebook by the year, and that Twitter is now again taking over this realm I&#8217;m much happier to teh bookface.</p>
<h3>Future reach</h3>
<p>This particular story is about aggregation, and about integration.  To me, the next step seems to be going back towards Digg: having some function whereby a URL can be prepended by t.co, for instance, which would start a Tweet with the appropriate URL link and title.</p>
<p>More importantly, being able to share content from mobile devices has to get easier, one way or another.  These systems tend towards that, though still depend on the particular site to implement the button.  Blogger had a &#8220;Blog this&#8221; toolbar button, and it seems we&#8217;ve forgotten this type of functionality in the mobile space.  There must be some web-standard way, too, which does not depend on a platform-dependent app/toolbar/addon/etc.  It&#8217;s rather meaningless without widespread adoption, which is why it&#8217;s more sensible to have this in the hands of an established community with a large userbase.. though I suppose we&#8217;ll just have to wait and see where this all leads.</p>
]]></content:encoded>
			<wfw:commentRss>http://rlaskey.org/words/2010/08/12/twitters-tweet-button-woo-finally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wiped, but charged,</title>
		<link>http://rlaskey.org/words/2010/08/01/wiped-but-charged/</link>
		<comments>http://rlaskey.org/words/2010/08/01/wiped-but-charged/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 03:43:21 +0000</pubDate>
		<dc:creator>rlaskey</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Gaming]]></category>

		<guid isPermaLink="false">http://rlaskey.org/words/?p=699</guid>
		<description><![CDATA[I did an incredible amount of work this weekend.  Between Saturday and Sunday, I clocked in well over twenty hours, and it was all crazy productive and useful time.  I can&#8217;t talk too much about the project I&#8217;m doing, though it&#8217;s for the college and is the most complex and largest scale MySQL / PHP [...]]]></description>
			<content:encoded><![CDATA[<p>I did an incredible amount of work this weekend.  Between Saturday and Sunday, I clocked in well over twenty hours, and it was all crazy productive and useful time.  I can&#8217;t talk too much about the project I&#8217;m doing, though it&#8217;s for the college and is the most complex and largest scale MySQL / PHP system I&#8217;ve created yet.</p>
<p>O&#8217;Reilly&#8217;s <a href="http://www.amazon.com/gp/product/B0028N4W7Y?tag=rlaskey-20">High Performance MySQL</a> has been an unbelievably helpful resource, given me tons of ideas in terms of schema, indexing, and general strategies.  It&#8217;s a long book, though even the first few chapters are very helpful, and it&#8217;s very well written.</p>
<p>As a short cool-down, I played a few rounds of <a href="http://store.steampowered.com/app/440/">Team Fortress 2</a>.  It&#8217;s a great game, and it looks quite stunning since I upgraded to an <a href="http://www.amazon.com/gp/product/B0033WSDNS?tag=rlaskey-20">ATI HD5670</a>.  My stats aren&#8217;t all that wonderful, and I mostly play with a wired 360 controller over keyboard and mouse.. but it&#8217;s fun and has a great cartoon-y aesthetic.  I also played a bit of <a href="http://store.steampowered.com/app/12750/">GRID</a> a few nights ago, which I&#8217;ve been enjoying a lot.  It&#8217;s much on the arcade side of simulators, though the instant flashback feature is great and the sound design and graphics work really well.</p>
<p>I heard it was beautiful outside the past few days, though I didn&#8217;t exit the door even to go into the hallway of my building.  I certainly have been more of a typical nerd recently; not exercising as much, skirting away from the sun.. though these work projects have been really interesting, and the idea that I&#8217;m creating something for a larger base of users is exciting.</p>
<p>I&#8217;m also coming into my sixth year of PHP development, and my code is getting tighter by the month.  It really is so much easier to write a lot of lines of code, yet condensing the logic and finding more efficient paths to the same solution is always worth the experience.  In my head, I think of it as the difference between writing scripts: small procedures to do a particular task; compared with programming: creating some kind of robotic life form which is beautiful and can speak for itself.</p>
]]></content:encoded>
			<wfw:commentRss>http://rlaskey.org/words/2010/08/01/wiped-but-charged/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bluehost: WTF are you doing</title>
		<link>http://rlaskey.org/words/2010/07/02/bluehost-wtf-are-you-doing/</link>
		<comments>http://rlaskey.org/words/2010/07/02/bluehost-wtf-are-you-doing/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 15:36:59 +0000</pubDate>
		<dc:creator>rlaskey</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://rlaskey.org/words/?p=672</guid>
		<description><![CDATA[I&#8217;ve been a loyal customer of Bluehost for years now.  Their systems are fast; their offerings are great.  Today, however, I&#8217;m wondering how they ever got to be in the business with the kind of mistakes I&#8217;ve found. Overwrote my php.ini For those who don&#8217;t know what a php.ini file is, it&#8217;s a very important [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been a loyal customer of Bluehost for years now.  Their systems are fast; their offerings are great.  Today, however, I&#8217;m wondering how they ever got to be in the business with the kind of mistakes I&#8217;ve found.</p>
<h3>Overwrote my php.ini</h3>
<p>For those who don&#8217;t know what a php.ini file is, it&#8217;s a very important configuration file for PHP.  If you want to set whether errors get displayed, which directories you want in your include path, etc.  These are both options that I set in my php.ini:</p>
<p>I&#8217;ve put my custom libraries outside of the web-accessible path, in the odd case that there&#8217;s a system problem and the code gets exposed.  More importantly, however, I can have a single require_once(&#8216;library.php&#8217;), and regardless of the path I&#8217;ll be able to get the file within that include directory.</p>
<p>I also changed the default error behavior, to disallow PHP errors to be displayed on the page itself.  This again is a security measure, since otherwise there&#8217;s a reasonable amount of information about the system that can get leaked out by these error messages.  They should be in a private log, not searchable via Google.</p>
<p>Imagine my dismay, then, when I find that my site has been broken since this past Sunday (Friday, today) because both of these directives were completely overwritten by Bluehost.  I never received an email, nor any sort of communication before or after the fact.   I was on the support line for 27 minutes and 53 seconds, after which I received a suggestion that not all users are quite as picky as myself, and that I can send an email to their feedback line if I wanted to voice my opinion.</p>
<p>I&#8217;m opting for this instead.</p>
<p>My only real evidence of any sort of problem was, and is, the modification time of the php.ini file, and another file titled &#8220;php.ini.NEWCONFIGPOSSIBLYBROKEN&#8221;.  Oh, and masses of error logs; and the site showing PHP errors rather than content.</p>
<h3>Passwords in the clear?</h3>
<p>So of course, that wasn&#8217;t the whole story.  There&#8217;s also Bluehost&#8217;s <a href="http://helpdesk.bluehost.com/index.php/contact">support contact page</a>, which is a gem in of itself.  In order to see the nasty bits, you&#8217;ll have to click one of the various support options and hit the button at the bottom of the form.  In there lies a rather special field:</p>
<blockquote><p>Last 4 Characters of Password (not credit card):</p></blockquote>
<p>Really? ! Upon mentioning this to the tech on the support line, he assured me that the system is entirely safe.  No one can read your passwords; they have a script which takes your input and then gives an answer.  He wasn&#8217;t sure how it worked, though he claimed to know it was not a security problem.</p>
<p>It is possible that the system is storing two independent hashes, one for the entire password and secondly for what&#8217;d be substr($password,-4);.  I seriously hope that&#8217;s the case, because any other alternatives that I can dream up seem to point to storing the system passwords in plain text.  I do hope that they are not that stupid.  My confidence is just a little bit shaken, however, by their inability to forsee other problems, such as described in the upper half of this post.</p>
<h3>Taking a deep breath</h3>
<p>Aside from today, I&#8217;ve never had a problem with Bluehost.  I know they have a huge number of clients, and that alone is not an easy job to undertake.  Their MySQL performance and support for multiple domains make me want to stick with them; on top of the fact that I already bought three years of service from them, of which I have two left..</p>
<p>With that said, systems are incredibly important, and these kinds of mistakes are not representative of a company which knows what its doing.  Luckily they had backups of my old php.ini &#8212; and because I knew where to find it, I was able to get my site running again.  Sans that, however, there was no trace of my configuration.  That simply is not cool.  I sincerely hope that they, along with all other providers, take the proper steps to help developers; not those which send them up a creek without a paddle.</p>
]]></content:encoded>
			<wfw:commentRss>http://rlaskey.org/words/2010/07/02/bluehost-wtf-are-you-doing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mobile-compatible websites with CSS media queries</title>
		<link>http://rlaskey.org/words/2010/05/09/mobile-compatible-websites-with-css-media-queries/</link>
		<comments>http://rlaskey.org/words/2010/05/09/mobile-compatible-websites-with-css-media-queries/#comments</comments>
		<pubDate>Sun, 09 May 2010 04:29:48 +0000</pubDate>
		<dc:creator>rlaskey</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://rlaskey.org/words/?p=582</guid>
		<description><![CDATA[CSS never ceases to amaze me. Previously, I had a rather simple PHP script on my site which looked at the browser string from the client; if it seemed from that as though the current user was on a mobile device, I then either loaded a mobile-overrides CSS file, or modified the statements inline (in [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Cascading_Style_Sheets">CSS</a> never ceases to amaze me.</p>
<p>Previously, I had a rather simple PHP script on my site which looked at the browser string from the client; if it seemed from that as though the current user was on a mobile device, I then either loaded a mobile-overrides CSS file, or modified the statements inline (in the case that my CSS was served up via PHP).</p>
<p><a href="http://www.smashingmagazine.com/">Smashing Magazine</a> recently posted an article titled <a href="http://www.smashingmagazine.com/2010/05/06/modern-css-layouts-part-2-the-essential-techniques/">Modern CSS Layouts: The Essential Techniques</a> which came up on <a href="http://digg.com/design/Modern_CSS_Layouts_The_Essential_Techniques">Digg</a>.  I&#8217;ve heard of a number of the other sections, though what really caught my eye was the large amount of discussion about media queries.  What particularly caught my eye was the article titled <a href="http://dev.opera.com/articles/view/safe-media-queries/">Safe media queries</a> from <a href="http://dev.opera.com/">dev.opera.com</a>.</p>
<p>This is why, if you&#8217;re using Internet Explorer to visit this site, all my pages look a bit messed up in their current state.  I&#8217;m being liberal with the &#8220;safe&#8221; part of the article, and tending towards more what&#8217;s in the Dev.Opera tagline: &#8220;follow the standards, break the rule.&#8221;</p>
<h3>General idea</h3>
<p>So the idea here is that within a single CSS file, it&#8217;s possible to section out certain rules such that they apply only to certain types of devices or screens.  The main players are <code>min-width</code> and <code>max-width</code>; the general syntax goes something like: <code>@media all and (max-width:800px) {/* rules */}</code>.</p>
<h3>My approach</h3>
<p>There are loads of way to attack this.  One major concern is that Internet Explorer and other non-supported browsers don&#8217;t understand whatever it is you put inside these rules, as defined in the way of the previous paragraph.  The Dev.Opera article breaks this down quite well.</p>
<p>As long as the site is readable and easily navigable, I&#8217;m not too worried about making sure the page looks exactly the same on each system and browser.  Obviously, I have a much looser set of criteria than most designers out there; so if you&#8217;re more restricted you&#8217;ll have to think about your other options.</p>
<h3>Rethinking set widths</h3>
<p>In my case, I thought I&#8217;d rethink the structure of fixed-width elements; yes, all fixed widths.  Why?  In the world of mobile devices and all sorts of browsers and options, it&#8217;s going to be more and more important that your sites&#8217;s content can reflow in an accessible way regardless of the platform.</p>
<p>Ergo, my tack is to put any sort of important definitions pertaining to a <code>width:</code> definition down to the bottom of the CSS file, inside my <code>@media all and (min-width:...) {}</code> block.  What once was:</p>
<blockquote><p>#page {width:820px; margin:30px auto; padding:10px;}</p></blockquote>
<p>now instead becomes:</p>
<blockquote><p>#page {padding:10px;}<br />
@media all and (min-width:840px) {#page {width:820px; margin:30px auto;}}</p></blockquote>
<p>The 840px minimum width is to figure in the padding on each side; and the result is that if my browser window is more narrow than that, I don&#8217;t have any horizontal scrolling to do.</p>
<p>In my structure, #page contains both a main section and a sidebar.  I floated the sidebar left, along with its children; and then in the media query block alone I set the width of the actual sidebar.  There is a bit of a jumble of elements at the bottom now, but moving to a small screen makes it worth it.</p>
<p>My pattern, then, is to let the browser expand all the elements as it needs, and to only set the large-screen elements for the browsers that can handle it.</p>
<h3>Choice philosophies</h3>
<p>With the above plan, Internet Explorer and the other non-supported browsers are going to see my site in some sort of goofy layout that&#8217;s meant for phones and pocket devices.  I&#8217;m OK with that, because I can still get at the content in a nice enough way.  I feel that the standards have to logical, but they also have to be pushed forward by aggressive use and stricter implementations, and browsers which accept these standards are the only way towards true progress.</p>
<p>The bigger picture, beyond my half-assed vendetta, is that CSS is alive and well; and I&#8217;m more than happy to be ditching the practice of checking browser strings in order to get my site readable on all platforms.  I also would urge anyone who takes a quick look at my site and gives the concept a pass: that there&#8217;s more than my solution out there; and if you have something even better than what I&#8217;ve dreamed, please have at it and leave a note for me in the comments :)</p>
]]></content:encoded>
			<wfw:commentRss>http://rlaskey.org/words/2010/05/09/mobile-compatible-websites-with-css-media-queries/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Experimenting with CSS: @font-face</title>
		<link>http://rlaskey.org/words/2009/11/22/experimenting-with-css-font-face/</link>
		<comments>http://rlaskey.org/words/2009/11/22/experimenting-with-css-font-face/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 22:23:52 +0000</pubDate>
		<dc:creator>rlaskey</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://rlaskey.org/words/?p=340</guid>
		<description><![CDATA[I&#8217;ve been playing with some design tweaks to this blog, as I&#8217;m prone to do, though in this revision I managed to enter into some advancements with newer browsers: namely, font embedding via the CSS @font-face directive. Why this matters The idea is that browsers now support the ability to download and incorporate fonts not [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing with some design tweaks to this blog, as I&#8217;m prone to do, though in this revision I managed to enter into some advancements with newer browsers: namely, font embedding via the CSS @font-face directive.</p>
<h4>Why this matters</h4>
<p>The idea is that browsers now support the ability to download and incorporate fonts not on the host system.  This is a big leap forward, because there is a very limited set of fonts which you can use for the web.  Mac fonts aren&#8217;t all in Windows or in Linux installations, ditto for Linux into Windows, etc.</p>
<p>You can use CSS to have a list of fall-back font families, though all this does is allow for the particular system to use a different font which is &#8220;good enough.&#8221;  Namely, you can have:</p>
<blockquote><p><code>body {font-family:"Helvetica","Arial", sans-serif;}</code></p></blockquote>
<p>which reads that the <code>body</code> tag should first utilize the Helvetica font; if Helvetica is not available, then use Arial;  if Arial is not available, then use any sans-serif font on the system.</p>
<p>With embedded fonts, I can keep this same syntax yet with an additional font which isn&#8217;t necessarily on the visiting computer:</p>
<blockquote><p><code>* {font-family:'Fontin', 'Helvetica', sans-serif;}</code></p></blockquote>
<p>This says that for all elements, use the &#8220;Fontin&#8221; font first, then fall back in the same way as in the other example.  Fontin is a free font which is publicly available and is released under terms which allow for embedding into a page.   You can download Fontin <a href="http://www.josbuivenga.demon.nl/fontin.html">at the exljbris Font Foundry website</a>, and view a list of other fonts also available for this purpose <a href="http://webfonts.info/wiki/index.php?title=Fonts_available_for_%40font-face_embedding">at the webfonts.info wiki</a>.</p>
<h4>Making the font files findable: @font-face</h4>
<p>&#8220;f&#8221;.</p>
<p>So, if you have tried the above without more work, you&#8217;ll quickly see that nothing new is happening.  The trick, then, is that the browser needs to know a bit more about this &#8220;Fontin&#8221; typeface which is not on the computer.  Before the declaration of the font family in the CSS file, you&#8217;ll need to add something like this:</p>
<blockquote><p><code>@font-face {<br />
font-family: "Fontin";<br />
font-weight:bold;<br />
src: url(/fonts/Fontin-Bold.otf) format("opentype");<br />
}</code></p>
<p><code>@font-face {<br />
font-family: "Fontin";<br />
font-style:italic;<br />
src: url(/fonts/Fontin-Italic.otf) format("opentype");<br />
}</code></p>
<p><code>@font-face {<br />
font-family: "Fontin";<br />
src: url(/fonts/Fontin-Regular.otf) format("opentype");<br />
}</code></p></blockquote>
<p>Hopefully this is mostly self-explanatory, though what&#8217;s a bit tricky at first is that there are multiple declarations for the same font.  There&#8217;s also a <code>src</code> for each font file; so you&#8217;ll have to have these publicly accessible on your web server in order for the browser to download and utilize them.</p>
<h4>Browser support: not all there yet</h4>
<p>With the overloading CSS as above, both Opera and Safari under OS X fail a bit, instead rendering whatever is the last listed directive.  In that case, it&#8217;s probably safest to list the normal font last, unless you want <em>everything in italics</em>, etc.</p>
<p>One way around this is to use different <code>font-family</code> names, and then re-define the CSS such that <code>em</code> tags and any other italicized text gets the alternate <code>font-family</code> definition; i.e., <code>font-family:'Fontin-Italic',</code> etc.</p>
<p>Firefox 3.5 works without a hitch, however, so hopefully this will just be reconciled with later versions of the other browsers.  Internet Explorer doesn&#8217;t play game at all; my guess is that there are additional tweaks specific for IE, as is most alway the case.</p>
<p>Still, what&#8217;s great about the system is also what&#8217;s great about CSS: even lacking browser support for the latest iterations, your site will fall back to using the same fonts you had set up previously.</p>
<h4>Proceed with caution: license considerations</h4>
<p>One trick with this font system is that there are not all that many fonts available for this particular use.  Most TTFs are not free, and even those that are free cannot necessarily be shared in such an open way.  While this may seem a bit cruel on the part of the font foundries and font makers, using this system does require that the font files are open and unrestricted: it doesn&#8217;t take much work to look at the CSS files to find the web location of the fonts themselves, which then leads towards very easy propagation of the files without a requirement for attribution, etc.</p>
<h4>Conclusion</h4>
<p>The constant problem in being on the edge, especially with the web, is that it doesn&#8217;t always work out for every system.  In terms of danger, however, setting alternate fonts does not seem to me to be all that dangerous.  In the absolute worst case, the site will just display whatever is next in the CSS list of fonts.  I personally am conservative in terms of utilizing new web technologies, though in this case I don&#8217;t see too much reason to hold back.</p>
]]></content:encoded>
			<wfw:commentRss>http://rlaskey.org/words/2009/11/22/experimenting-with-css-font-face/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Subtle theme update</title>
		<link>http://rlaskey.org/words/2009/11/13/subtle-theme-update/</link>
		<comments>http://rlaskey.org/words/2009/11/13/subtle-theme-update/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 20:47:55 +0000</pubDate>
		<dc:creator>rlaskey</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://rlaskey.org/words/?p=307</guid>
		<description><![CDATA[Not moving anything around too much, though I&#8217;ve been getting tired of the strange dirt red that was there previously.  Instead, I went back to an older idea in my site before, whereby I have a few colors, one of which is selected at random and used for the header background.  I may add in [...]]]></description>
			<content:encoded><![CDATA[<p>Not moving anything around too much, though I&#8217;ve been getting tired of the strange dirt red that was there previously.  Instead, I went back to an older idea in my site before, whereby I have a few colors, one of which is selected at random and used for the header background.  I may add in more colors as time goes on, though for the time being I&#8217;m sated.</p>
<h4>WordPress/PHP code</h4>
<p>This isn&#8217;t rocket science, though in the case that other people want to do the same, here&#8217;s what I have.  Please adapt to fit in with whatever schemes you have in your site:</p>
<blockquote><p><code>&lt;link rel="stylesheet" href="&lt;?php bloginfo('stylesheet_url'); ?&gt;" type="text/css" media="screen" /&gt;<br />
</code></p>
<p><code>&lt;?php $header_colors = array('rgb(111,111,111)', 'rgb(222,64,0)', 'rgb(0,111,222)');<br />
$header_color = $header_colors[array_rand($header_colors)]; ?&gt;<br />
</code></p>
<p><code>&lt;style type="text/css"&gt;<br />
#header {background-color:&lt;?php echo $header_color; ?&gt;;}<br />
&lt;/style&gt;</code></p></blockquote>
<p>Add to / subtract from the <code>$header_colors</code> array to make changes to the set of colors which are randomly selected.  Nothing too complicated here, but it can spice things up a bit without too much work.</p>
]]></content:encoded>
			<wfw:commentRss>http://rlaskey.org/words/2009/11/13/subtle-theme-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finally: a fresh theme</title>
		<link>http://rlaskey.org/words/2009/10/16/finally-a-fresh-theme/</link>
		<comments>http://rlaskey.org/words/2009/10/16/finally-a-fresh-theme/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 04:38:27 +0000</pubDate>
		<dc:creator>rlaskey</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://rlaskey.org/words/?p=176</guid>
		<description><![CDATA[It took me a little while, though I finally moved on to a custom theme. It is most important to note that it is highly derivative of the original &#8220;Kubrik&#8221; WordPress theme, which is the default that ships with all installations as of late. However, it is also rather similar to my other site designs, [...]]]></description>
			<content:encoded><![CDATA[<p>It took me a little while, though I finally moved on to a custom theme.  It is most important to note that it is highly derivative of the original &#8220;Kubrik&#8221; WordPress theme, which is the default that ships with all installations as of late.  However, it is also rather similar to my other site designs, with almost no graphical elements and a lot of careful placement. </p>
<p>I will hopefully get into more about the mobile version at some point.. though if you&#8217;re trying it now, this page ought to look just as good on smaller screens, as well as large.</p>
<p>One further step I&#8217;ve taken in this theme is to use a bit of WordPress functionality in adding a configuration menu, in the vein of <a href="http://codex.wordpress.org/Adding_Administration_Menus">this Codex page</a>.  I&#8217;m not getting into anything fancy, and anyone visiting really won&#8217;t care or even be able to notice.. though I now have my own simple menu by which I can place in my Google Analytics code and have it show up at the bottom of the page as it should.  Again, that&#8217;s a topic for another day, which I hopefully will not neglect to write up in more detail.  For now, I give myself a mini-yay.</p>
]]></content:encoded>
			<wfw:commentRss>http://rlaskey.org/words/2009/10/16/finally-a-fresh-theme/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fun with LRS</title>
		<link>http://rlaskey.org/words/2009/10/12/fun-with-lrs/</link>
		<comments>http://rlaskey.org/words/2009/10/12/fun-with-lrs/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 16:38:43 +0000</pubDate>
		<dc:creator>rlaskey</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Reading]]></category>

		<guid isPermaLink="false">http://rlaskey.org/words/?p=158</guid>
		<description><![CDATA[I&#8217;ve been using my Sony PRS-600 for about a month now, and I&#8217;ve collected a number of public domain titles for it in the LRF format. Today I discovered the tools lrf2lrs and lrs2lrf from calibre. These tools allow for transforming the LRF files to and from their source code format, LRS, and after playing [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using my Sony PRS-600 for about a month now, and I&#8217;ve collected a number of public domain titles for it in the LRF format.  Today I discovered the tools <code>lrf2lrs</code> and <code>lrs2lrf</code> from <a href="http://calibre.kovidgoyal.net/">calibre</a>.  These tools allow for transforming the LRF files to and from their source code format, LRS, and after playing around a bit I found it to be a really great system, especially for anyone who&#8217;s vaguely used to CSS and HTML/XML.</p>
<h4>Setting up the environment</h4>
<p>In order to use the above tools, you&#8217;ll have to install calibre and then install the command line tools under the preferences menu.  From there, you can run the two tools from the command line.  All you&#8217;ll need to do, in terms of syntax, is to be able to run:</p>
<blockquote><p><code>lrf2lrs &lt;filename&gt;<br />
lrs2lrf &lt;filename&gt;</code></p></blockquote>
<p>You can add in the <code>-o &lt;output-filename&gt;</code> option to either of the above in order to redirect the output.. though I haven&#8217;t personally found this particularly essential.  It will, by default, use the same file name with differing extensions of <code>.lrs</code> and <code>.lrf</code>, though in my workflow I just make sure that I save a copy of the LRS file when necessary in order to roll back changes.</p>
<h4>Editing the LRS files</h4>
<p>If you aren&#8217;t all that familiar with code, especially XML code, don&#8217;t expect any miracles.  It is very easy to change the meta information, such as the author, title, etc., just by changing the text that you see into the text that you want.</p>
<h5>Editing the Table of Contents</h5>
<p>The top of the file contains the table of contents, under the tag <code>&lt;TOC&gt;</code>, with entries as <code>&lt;TocLabel refobj="X"&gt;Chapter Name&lt;/TocLabel&gt;</code>, where X is the target <code>objid</code>.  There is also generally a &#8220;refpage&#8221; attribute in TocLabel, though you can safely enough ignore these since they&#8217;ll be recalculated when transferred back into the LRF format.</p>
<h5>objid &#8212; object ID&#8217;s</h5>
<p>The important thing to know about the <code>objid</code> (think object ID) is that it must be unique.  It does not have to be sequential, however, since when you run the conversion to LRF (and back to LRS, if so desired) these numbers will be recalculated.  The objects to which objid&#8217;s are assigned, can be things such as a <code>Page</code>, <code>TextBlock</code>, <code>Image</code>, <code>BlockStyle</code>, <code>TextStyle</code>, etc.  In order to keep things straight, I often would enter in new objects as fresh ID numbers way above the max in the document, then convert to LRF and back to LRS.  This way, the new LRS will have sequential indexes again.</p>
<h5>Body content and styling</h5>
<p>The bulk of the text of the LRS document is contained within <code>Main</code>, which contains a number of <code>Page</code> and <code>TextBlock</code> elements, which therein contain paragraphs (<code>P</code>), line breaks (<code>CR</code>), and formatting code such as <code>Italic</code>.</p>
<p>After <code>Main</code>, there is a <code>Style</code> block towards the end of the LRS file.  These contain certain elements with their own <code>objid</code> numbers, which are referenced in the attributes of the elements within <code>Main</code>.  This is vaguely like CSS, though it is different in that it is a bit more obtuse to write since the styles are only maintained by numbers which can and will be re-indexed in converting between LRS and LRF formats.</p>
<h4>Conclusion</h4>
<p>There is obviously much, much more to creating files from LRS, and to tricks in editing these source files in more depth.  Starting from an existing document, however, it is not too painful to make certain re-arrangements and additions to the structure, and in some cases to simplify code blocks which may have been misinterpreted via conversion or user error.  With some trial and error and an attention to detail in maintaining the proper XML format, however, it is nice to be able to control most all aspects of a book by editing a single file.  Additionally, even if your target is not LRF, there is relatively easy conversion to EPUB or other formats, using calibre and other open source tools available online.</p>
]]></content:encoded>
			<wfw:commentRss>http://rlaskey.org/words/2009/10/12/fun-with-lrs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extending WordPress Slideshow</title>
		<link>http://rlaskey.org/words/2009/10/02/extending-wordpress-slideshow/</link>
		<comments>http://rlaskey.org/words/2009/10/02/extending-wordpress-slideshow/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 15:09:44 +0000</pubDate>
		<dc:creator>rlaskey</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://rlaskey.org/words/?p=100</guid>
		<description><![CDATA[In a previous post I had created a system for making automated slideshows using only jQuery and the built-in WordPress attachments system. While it certainly works, I today changed around the behavior to instead read the images off sequentially, rather than picking one at random. The trouble with the random selection, at least with the [...]]]></description>
			<content:encoded><![CDATA[<p>In a <a href="/words/2009/09/18/wordpress-attachments-gallery-shortcode-and-jquery/">previous post</a> I had created a system for making automated slideshows using only jQuery and the built-in WordPress attachments system.   While it certainly works, I today changed around the behavior to instead read the images off sequentially, rather than picking one at random.</p>
<p>The trouble with the random selection, at least with the way I had previously coded it, was that especially for small sets of photos, you&#8217;d get the same image twice in a row.  By keeping track of a counter variable, you can easily get by this.  There are, of course, many other ways to do this, though I want to share:</p>
<blockquote><p><code>function advanceSlide(item_class, display_id)<br />
{<br />
var display = $('#' + display_id);<br />
display.empty();</code></p>
<p><code>var items = $('.' + item_class);<br />
display.append(items.eq(currentItem).clone());<br />
display.children('.' + item_class).fadeIn();</code></p>
<p><code>currentItem = (currentItem + 1) % itemCount;<br />
}</code></p>
<p><code>$(document).ready(function()<br />
{<br />
var item_class = 'gallery-item';<br />
var display_id = 'gallery-display';<br />
$('#gallery-1').before('&lt;div id="' + display_id + '"&gt;&lt;/div&gt;');<br />
$('#' + display_id).attr('style','height:500px');<br />
$('.' + item_class).hide();</code></p>
<p><code>itemCount = $('.' + item_class).size();<br />
currentItem = 0;</code></p>
<p><code> advanceSlide(item_class, display_id);<br />
setInterval("advanceSlide('" + item_class + "','" + display_id + "')", 4000);<br />
});</code></p></blockquote>
<p>The main difference is in using global variables to keep track of which image we&#8217;re on, and to keep track of how many images total we have.  The modulo operator (<code>%</code>) is a standard method for restarting the count once it reaches a certain level, which is what you want when you reach the end of the list of images.</p>
<p>Although I generally do not like global variables, using them in the above (announced by having the variable declaration without the <code>var</code> keyword, in JavaScript) certainly does cut down on the complexity of the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://rlaskey.org/words/2009/10/02/extending-wordpress-slideshow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Are you organized?</title>
		<link>http://rlaskey.org/words/2009/09/21/are-you-organized/</link>
		<comments>http://rlaskey.org/words/2009/09/21/are-you-organized/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 03:25:59 +0000</pubDate>
		<dc:creator>rlaskey</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://rlaskey.org/words/?p=70</guid>
		<description><![CDATA[I try to not do too much busy work, at my job and in life in general. The trick, as I see it, is to see everything as data, and to constantly be conscious of the way in which that data is organized. I often keep a reasonably cluttered desk in my physical workspace, however [...]]]></description>
			<content:encoded><![CDATA[<p>I try to not do too much busy work, at my job and in life in general.  The trick, as I see it, is to see everything as data, and to constantly be conscious of the way in which that data is organized.  I often keep a reasonably cluttered desk in my physical workspace, however I always cluster things together such that they are indexed for easy retrieval.  The method isn&#8217;t important, yet having a method most certainly is.</p>
<p>I really believe the future is going to be more and more about getting information organized in very particular and portable ways.  Google, and increased computing power in general often makes it easy to throw caution to the wind, abandoning structure with the expectation that &#8220;technology&#8221; will solve all ills.  The reality, though, is that we still have to index, catalog, and in many cases refactor our data and related systems in order to fit the needs at hand.  Searching alone is not the savior, and, ultimately, it is not going to change the game.</p>
<p>Busy work, then, can be defined as needing to hand-sort large sets of information simply because the existing form lacks a reasonable organization.  Said another way, it is much more efficient to be able to just change the names, be it piles on a desk, structures of nested folders, or deeper database systems; but it is an entirely separate problem if we cannot even see what we&#8217;re looking at without a lot of work.  The more general corollary to what I&#8217;m saying is essentially that it is more important to work intelligently than to work hard.  More specifically, computer systems alone are not the savior if the fundamental practice is broken from the outset.</p>
]]></content:encoded>
			<wfw:commentRss>http://rlaskey.org/words/2009/09/21/are-you-organized/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
