<?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>NickBusey.com</title>
	<atom:link href="http://www.nickbusey.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nickbusey.com</link>
	<description>Stuff and Junk</description>
	<lastBuildDate>Tue, 24 Apr 2012 20:55:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Getting started with Node</title>
		<link>http://www.nickbusey.com/2011/07/getting-started-with-node/</link>
		<comments>http://www.nickbusey.com/2011/07/getting-started-with-node/#comments</comments>
		<pubDate>Fri, 08 Jul 2011 22:14:17 +0000</pubDate>
		<dc:creator>Nick Busey</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.nickabusey.com/?p=93</guid>
		<description><![CDATA[I&#8217;ve been building an application in Node lately, and I thought I&#8217;d share a couple things that will make getting started with Node far more pleasurable. Exception tracking It is very useful to know how to get more information on exceptions when you want it, and how to keep them from killing the server in [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been building an application in Node lately, and I thought I&#8217;d share a couple things that will make getting started with Node far more pleasurable.</p>
<p><span id="more-93"></span></p>
<h3>Exception tracking</h3>
<p>It is very useful to know how to <a href="http://stackoverflow.com/questions/5802840/javascript-node-js-getting-line-number-in-try-catch" target="_blank">get more information on exceptions when you want it</a>, and how to <a href="http://nodejs.org/docs/v0.5.0/api/process.html#event_uncaughtException_">keep them from killing the server in production</a>.</p>
<h3>Object size</h3>
<p>Sometimes you have a key / value map of objects stored by id for example. In Node, you get to say</p>
<p><code>var notes = { 3: { Note: { text: hi, ... } }, 17: { ... } };<br />
log(Object.keys(notes).length);<br />
2</code></p>
<p>Sweet</p>
<h3>Backbone.js</h3>
<p>Use <a href="http://documentcloud.github.com/backbone/">Backbone</a>. Just <a href="http://andyet.net/blog/2010/oct/29/building-a-single-page-app-with-backbonejs-undersc/">use it</a>, from the very beginning. Try <a href="http://amir.unoc.net/how-to-share-backbonejs-models-with-nodejs">reusing models on the front end and backend</a>. Or just <a href="http://fzysqr.com/2011/02/28/nodechat-js-using-node-js-backbone-js-socket-io-and-redis-to-make-a-real-time-chat-app/">sync the entire application state</a>.</p>
<h3>Express</h3>
<p>If you&#8217;re building any sort of web app, not using <a href="http://expressjs.com/guide.html">Express</a> is probably a waste of time.</p>
<h3>Foreman and ReadyJs</h3>
<p>These two npm power ups make managing your environments a breeze.</p>
<p><code>sudo npm install foreman<br />
sudo npm install readyjs<br />
vi Procfile</code></p>
<p><code>web: NODE_ENV=production node app.js<br />
localhost: readyjs app/ jslibs/ --nocompiler; readyjs app/ jslibs/ --nocompiler --nojslint; readyjs jslibs/ www/js/ --order "underscore.js, backbone.js, jquery.jeditable.js, jquery.jtml.js, all.js" --nojslint --nocompiler; NODE_ENV=development node --debug app.js</code></p>
<p>What the localhost line is doing is running ready js once with jslint turned on, on my application files only. It runs it again without jslint, just in case it doesn&#8217;t pass, so we&#8217;re sure the compiled file is where it should be. Then it concats all the libraries used, in order needed for loading, and we&#8217;re good to go. Now all you need to type to launch your app is</p>
<p><code>forman start localhost</code></p>
<p>To make this even better, <a href="http://www.javascriptkata.com/2010/10/28/ready-js-prepare-your-javascript-for-production/">add a Git hook</a>, so when you deploy everything is how you want it for production straight from the repo.</p>
<h3>Heroku</h3>
<p>Offers free development hosting, and integrates with Foreman, super easy deployment. Lot&#8217;s of cool free add-ons as well to add some spice. Definitely worth a look.</p>
<p>Hopefully these tips will save you some time, feel free to comment with any tips you&#8217;ve found as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nickbusey.com/2011/07/getting-started-with-node/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using CSS :before and :after to clean up your sprites</title>
		<link>http://www.nickbusey.com/2011/03/using-css-before-and-after-to-clean-up-your-sprites/</link>
		<comments>http://www.nickbusey.com/2011/03/using-css-before-and-after-to-clean-up-your-sprites/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 19:57:39 +0000</pubDate>
		<dc:creator>Nick Busey</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.nickabusey.com/?p=33</guid>
		<description><![CDATA[Update: Managing sprites by hand is so last month. Check out Compass&#8217;s Sprite functions. Using sprites to develop your CSS based layouts has become the de facto standard. The benefits are many and have been extolled endlessly in blog posts and articles throughout the series of tubes. The problem that I&#8217;ve run into when developing [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> Managing sprites by hand is so last month. Check out <a href="http://compass-style.org/reference/compass/helpers/sprites/" target="_blank">Compass&#8217;s Sprite functions</a>.</p>
<p>Using sprites to develop your CSS based layouts has become the de facto standard. The benefits are many and have been extolled endlessly in blog posts and articles throughout the series of tubes. The problem that I&#8217;ve run into when developing a sprites file is this: the right-hand side. If you&#8217;ve worked with sprites for any length of time, you know exactly what I&#8217;m talking about.</p>
<p><span id="more-33"></span></p>
<p>In my experience, a great majority of sprites are simple icons that appear to the left of some bit of text. For example, a pencil icon would appear to the left of &#8216;Edit&#8217; in all .editBtn divs. The common way to handle this without adding non-semantic markup is to put the icon way on the far-right edge of the sprite file, so that you don&#8217;t have to worry about other images within the sprite showing through underneath your text. I&#8217;m sure most of your sprites resemble something like this:</p>
<p><img class="aligncenter" title="Old way" src="/wp-content/uploads/2011/03/OldSprites.png" alt="" width="300" height="107" /></p>
<p>This creates ugly, unorganized sprites files that are very difficult to maintain. As icons are added and removed, you basically have three options. The first, and I believe most common option is to stick new icons in wherever they fit, which creates unorganized sprites very quickly. Secondly, you could rearrange the icons as you add and remove them, but this creates a lot of overhead as any icon you move has to be updated all throughout any css that renders it. Finally, you could simply stretch your sprite file vertically, and keep tacking them on at the end. This is also unorganized, not to mention very inefficient in terms of file size (due to unused space in the left side of the sprite).</p>
<p><strong>NOTE: :before and :after are not supported by IE7 and older. Be ready to lose some visuals for older browsers.</strong></p>
<p>Enter :before and :after. Using these two simple selectors, you can create and inject pseudo-elements that can be styled just like any other element, without any non-semantic markup. Instead of setting the background-image of .editBtn, you can create .editBtn:before, give it a height, width and position, and boom. Perfectly constrained icon rendered without any additional markup. The beauty of this technique is that it allows you to place your icon anywhere inside the sprites file, without fear of other icons being rendered where they shouldn&#8217;t be.</p>
<p><img class="aligncenter" title="New way" src="/wp-content/uploads/2011/03/NewSprites.png" alt="" width="300" height="114" /></p>
<p>Now I can do fun stuff like this:</p>
<p><code>.editBtn {<br />
display: block;<br />
padding: 5px 5px 5px 60px;<br />
border: solid black 1px;<br />
position: relative;<br />
overflow: hidden;<br />
width: 100px;<br />
background-color: #ccc;<br />
cursor: pointer;<br />
color: #000;<br />
}<br />
.editBtn:before {<br />
background-image: url('/img/sprites.png');<br />
background-repeat: no-repeat;<br />
content: "\0020";<br />
display: block;<br />
height: 30px;<br />
width: 28px;<br />
position: absolute;<br />
top: 0px;<br />
left: 10px;<br />
background-position: -5px -80px;<br />
}</code></p>
<p>And with something as simple as this:</p>
<p><code>&lt;div class="editBtn"&gt;Edit&lt;/div&gt;</code></p>
<p>You can make something like this:</p>
<div class="editBtn">Edit</div>
<p>Without having to worry about where you place your icons in your sprite. This will allow you to group icons more logically, and hopefully create a cleaner and easier to maintain sprite.</p>
<p><!-- .editBtn { display: block; padding: 5px 5px 5px 60px; border: solid black 1px; position: relative; overflow: hidden; width: 100px; background-color: #ccc; cursor: pointer; color: #000; } .editBtn:before { background-image: url('/wp-content/uploads/2011/03/NewSprites.png'); background-repeat: no-repeat; content: "\0020";	display: block;	height: 30px; width: 28px; position: absolute; top: 0px; left: 10px; background-position: -5px -80px; } --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nickbusey.com/2011/03/using-css-before-and-after-to-clean-up-your-sprites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Undelete files over SSH with Foremost</title>
		<link>http://www.nickbusey.com/2010/11/how-to-undelete-files-over-ssh-with-foremost/</link>
		<comments>http://www.nickbusey.com/2010/11/how-to-undelete-files-over-ssh-with-foremost/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 10:43:43 +0000</pubDate>
		<dc:creator>Nick Busey</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.nickabusey.com/?p=27</guid>
		<description><![CDATA[We&#8217;ve all been there. You&#8217;re SSH&#8217;d into a remote server, trying to delete a folder. $ pwd /mnt/www Ok, I&#8217;m in the right folder. $ ls -al to_delete/ total 12 drwxr-xr-x 3 ubuntu ubuntu 4096 2010-11-23 09:09 . drwxr-xr-x 3 root root 4096 2010-07-15 17:31 .. drwxr-xr-x 5 ubuntu ubuntu 4096 2010-04-09 15:11 source Ok, [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve all been there. You&#8217;re SSH&#8217;d into a remote server, trying to delete a folder.</p>
<blockquote><p><code>$ pwd</code></p></blockquote>
<blockquote><p><code>/mnt/www</code></p></blockquote>
<p>Ok, I&#8217;m in the right folder.</p>
<blockquote><p><code>$ ls -al to_delete/</code></p></blockquote>
<blockquote><p><code>total 12<br />
drwxr-xr-x 3 ubuntu ubuntu 4096 2010-11-23 09:09 .<br />
drwxr-xr-x 3 root root 4096 2010-07-15 17:31 ..<br />
drwxr-xr-x 5 ubuntu ubuntu 4096 2010-04-09 15:11 source</code></p></blockquote>
<p>Ok, that&#8217;s what I want to delete. I&#8217;m positive I want this thing gone, I&#8217;m going to replace it immediately.</p>
<blockquote><p><code>$ rm -rf to_delete</code></p></blockquote>
<p>Gravy.</p>
<p>(three seconds later)</p>
<p>SHIT! I needed that!<br />
<span id="more-27"></span><br />
As you&#8217;ve probably now realized, in the future, you should do have done something like this instead<br />
<code>$ mv to_delete to_delete.bak</code><br />
It&#8217;s too late now. What&#8217;s done is done, it&#8217;s 4 in the morning, and you need those files.</p>
<p>Well luckily for us, you might not be entirely screwed, yet. You need to act fast and deliberately or you may lose data due to other data being written over the data you want to recover.</p>
<p>First we need to find out what partition our data is on.</p>
<blockquote><p><code>$ mount</code></p></blockquote>
<blockquote><p><code>/dev/sda1 on / type ext3 (rw)<br />
proc on /proc type proc (rw)<br />
none on /sys type sysfs (rw,noexec,nosuid,nodev)<br />
none on /sys/fs/fuse/connections type fusectl (rw)<br />
none on /sys/kernel/debug type debugfs (rw)<br />
none on /sys/kernel/security type securityfs (rw)<br />
udev on /dev type tmpfs (rw,mode=0755)<br />
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)<br />
none on /dev/shm type tmpfs (rw,nosuid,nodev)<br />
none on /var/run type tmpfs (rw,nosuid,mode=0755)<br />
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)<br />
none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)<br />
/dev/sda2 on /mnt type ext3 (rw)<br />
</code></p></blockquote>
<p>So /dev/sda2 is holding /mnt. That&#8217;s the ticket. So now <code>$ exit</code> and back to our home computer we can simply say</p>
<blockquote><p><code>$ ssh ubuntu@server.com "sudo dd if=/dev/sda2" | dd of=/Users/nickabusey/Downloads/backupfile.iso</code></p></blockquote>
<p>Now we have a clone of the partition with the data we care about. All that&#8217;s left after that is to recover the deleted data. First install Foremost.</p>
<blockquote><p>OS X:<code>$ sudo port install foremost</code></p></blockquote>
<blockquote><p>*nix:<code>$ sudo apt-get install foremost</code></p></blockquote>
<p>Now, recover the data! In my case I wanted to recover all image files, so I just let it run for all supported file types and got as much as I could out of it.</p>
<blockquote><p><code>$ foremost -t all -i backupfile.iso</code></p></blockquote>
<blockquote><p><code>$ ls output/<br />
audit.txt bmp gif htm jpg png</code></p></blockquote>
<blockquote><p><code>$ tail output/audit.txt<br />
1636 FILES EXTRACTED</code></p>
<p><code>jpg:= 1307<br />
gif:= 93<br />
bmp:= 1<br />
htm:= 37<br />
png:= 198<br />
------------------------------------------------------------------</code></p>
<p><code> </code><code>Foremost finished at Tue Nov 23 03:23:53 2010</code></p></blockquote>
<p>Huzzah!</p>
<p>This works pretty well. Many of the images I recovered were corrupted, others didn&#8217;t get recovered at all. Another annoying gotcha is that the files are named after their position on the partition rather than their original filenames. So you have to match them back up by hand, and if you have a lot of files this could be extremely tedious if not downright impossible.</p>
<p>At this point I&#8217;d like to point out the benefits of regular, redundant backups.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nickbusey.com/2010/11/how-to-undelete-files-over-ssh-with-foremost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

