<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en">
<title>heatxsink.com - stay hungry, stay foolish</title>
<link rel="alternate" href="http://www.heatxsink.com/" title="" type="text/html" />
<id>http://www.heatxsink.com/</id>
<icon>http://www.heatxsink.com/favicon.ico</icon>
<updated>2010-02-24T08:53:02Z</updated>
<author><name>Nick Granado</name></author>

<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.heatxsink.com/heatxsink/atom" /><feedburner:info uri="heatxsink/atom" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry>
<title>Backup and Restore with MySQL</title>
<id>http://www.heatxsink.com/entry/backup-and-restore-with-mysql</id>
<link href="http://feeds.heatxsink.com/~r/heatxsink/atom/~3/pBeQIR2BbpA/backup-and-restore-with-mysql" rel="alternate" />
<author><name>Nick Granado</name></author>
<updated>2010-02-24T08:53:02Z</updated>
<published>2010-02-25T06:32:00Z</published>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
<p>There's a lot of ways to backup a MySQL database. I've had to look this up from time to time. And I have not found anyone take these scenarios and boil them down into a short concise guide. Enjoy.</p>

<h3>Backup</h3>

<p>The simple way of backing up a MySQL database.</p>
<pre class="snippet">
$ mysqldump -u [username] -p [password] [database_name] &gt; [backup_filename.sql]
</pre>

<p>What if you want to restore an existing database? You can add 'drop table' statements to your backup like so...</p>
<pre class="snippet">
$ mysqldump --add-drop-table -u [username] -p [password] [database_name] &gt; [backup_filename.sql]
</pre>

<p>What if you just wanted a table and not the whole database? Yes, you can do that too...</p>
<pre class="snippet">
$ mysqldump --add-drop-table -u [username] -p [password] [database_name] [table1 table2 ...] &gt; [backup_filename.sql]
</pre>

<p>More than one database to backup?</p>
<pre class="snippet">
$ mysqldump -u [username] -p [password] --databases [database1 database2 ...] &gt; [backup_filename.sql]
</pre>

<p>Need to backup all databases in a MySQL instance?</p>
<pre class="snippet">
$ mysqldump --all-databases &gt; [backup_filename.sql]
</pre>

<p>How about the database, but no data please. Coming right up!</p>
<pre class="snippet">
$ mysqldump --no-data --all-databases &gt; [backup_filename.sql]
</pre>

<h3>Automating Backups</h3>

<p>Need to automate your MySQL backup? There's a script for that...</p>
<pre class="snippet">
#!/bin/sh
date=`date -I`
mysqldump --all-databases | gzip &gt; /some/path/backup-db-name-$date.sql.gz 
</pre>

<h3>Restore</h3>

<p>The way to restore a MySQL database.</p>
<pre class="snippet">
$ mysql -u [username] -p [password] [database_name_to_restore] &lt; [backup_filename.sql]
</pre>



<xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/heatxsink/atom/~4/pBeQIR2BbpA" height="1" width="1" /></div></content>
<feedburner:origLink>http://www.heatxsink.com/entry/backup-and-restore-with-mysql</feedburner:origLink></entry>

<entry>
<title>Manipulating Geo Coordinates in Python and Foursquare Cheating</title>
<id>http://www.heatxsink.com/entry/manipulating-geo-coordinates-in-python-and-foursquare-cheating</id>
<link href="http://feeds.heatxsink.com/~r/heatxsink/atom/~3/kqjukF5jQ9I/manipulating-geo-coordinates-in-python-and-foursquare-cheating" rel="alternate" />
<author><name>Nick Granado</name></author>
<updated>2010-02-24T08:57:05Z</updated>
<published>2010-02-22T07:21:00Z</published>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
<p>
I've been tinkering with the Foursquare API. It's a lot of fun to play with and is as clean as the Twitter API. Anyway, the reason for all of this madness is <a href="http://www.krazydad.com/blog/2010/02/mayor-of-the-north-pole/">this</a> guy. He's funny and decided "wouldn't it be cool if.." he became mayor of the North Pole. I thought a lot about this and decided that eventually Foursquare will attempt to battle this "fake check-in" issue. I think another way to cheat the system is by using a venue's supplied geo coordinates, and a bounding box I could "fake" a geo coordinate, and use it to check-in.
</p>
<h3>My "Strategery"</h3>
<p>
Pick a Fourquare venue, query the Foursquare API for the venue data. Use the venue's associated "geolat" and "geolong" as a starting geo coordinate. Then all you need is a bearing (in degrees), and a distance (in kilometers). This problem should take you all the way back to high school trigonometry (it did for me). Take those 4 values and plug them into the "move_lat_long" function (below), and voila your geo coordinate has been moved!
</p>

<pre class="snippet">
import math

def move_lat_long(latitude, longitude, distance, bearing):
        bearing = convert_to_radians(bearing)
        latitude = convert_to_radians(latitude)
        longitude = convert_to_radians(longitude)
        # earths radius in kilometers
        earth_radius = 6371
        d = float(distance)/float(earth_radius)
        latitude2 = math.asin( math.sin(latitude) * math.cos(d) + math.cos(latitude) * math.sin(d) * math.cos(bearing) )
        longitude2 = longitude + math.atan2( math.sin(bearing) * math.sin(d) * math.cos(latitude), math.cos(d) - math.sin(latitude) * math.sin(latitude2) )
        return convert_to_degrees(latitude2), convert_to_degrees(longitude2)

def convert_to_degrees(number):
        return (float(number) * (180/math.pi))

def convert_to_radians(number):
        return (float(number) * (math.pi/180))
</pre>

<p>For extra credit (I'm lame it's okay) I pulled apart the geo coordinates that are usually expressed in degrees ... into degrees, minutes, seconds.</p>

<pre class="snippet">
def expand_geo_coordinate(coordinate):
        geo_coordinate = float(coordinate)
        geo_degrees = int(geo_coordinate)
        geo_minutes = (abs(geo_coordinate) % abs(geo_degrees)) * 60
        geo_seconds = (geo_minutes % int(geo_minutes)) * 60
        random_format = "[%s]  %d degress   %d minutes   %d seconds"
        return random_format % (coordinate, geo_degrees, geo_minutes, geo_seconds)
</pre>

<p>
The only part that's left of "my diabolical plan" is picking a random distance, and a random bearing. There will be another post on the full project once I've successfully become mayor of a targeted venue.
</p>
<xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/heatxsink/atom/~4/kqjukF5jQ9I" height="1" width="1" /></div></content>
<feedburner:origLink>http://www.heatxsink.com/entry/manipulating-geo-coordinates-in-python-and-foursquare-cheating</feedburner:origLink></entry>

<entry>
<title>VMware Fusion 3 headless mode</title>
<id>http://www.heatxsink.com/entry/vmware-fusion-3-headless-mode</id>
<link href="http://feeds.heatxsink.com/~r/heatxsink/atom/~3/EFdHYkkQIvI/vmware-fusion-3-headless-mode" rel="alternate" />
<author><name>Nick Granado</name></author>
<updated>2010-02-19T11:38:32Z</updated>
<published>2010-02-16T09:38:00Z</published>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
<p>
I don't know if a lot of people know about this but you can run virtual machines (some people call them vm's for short) in VMware Fusion 2 or 3 in headless mode. I've just upgraded to VMware Fusion 3. My script (below) has been tested on OSX Leopard running VMware Fusion 3. I find this perfect for running a Linux based server image on OSX.
</p>

<p><em>filename:</em> headless_vm.sh</p>
<pre class="snippet">
#!/bin/bash
USERNAME=your_username_here
IMAGE_NAME=your_vm_image_name_here

/Library/Application\ Support/VMware\ Fusion/vmrun -T fusion start /Users/$USERNAME/Documents/Virtual\ Machines.localized/$IMAGE_NAME.vmwarevm/$IMAGE_NAME.vmx nogui
</pre>
<xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/heatxsink/atom/~4/EFdHYkkQIvI" height="1" width="1" /></div></content>
<feedburner:origLink>http://www.heatxsink.com/entry/vmware-fusion-3-headless-mode</feedburner:origLink></entry>

<entry>
<title>RSS Feed Proxy in C# .NET</title>
<id>http://www.heatxsink.com/entry/rss-feed-proxy-csharp-dotnet</id>
<link href="http://feeds.heatxsink.com/~r/heatxsink/atom/~3/XEmo6WCkwXo/rss-feed-proxy-csharp-dotnet" rel="alternate" />
<author><name>Nick Granado</name></author>
<updated>2010-02-03T20:37:37Z</updated>
<published>2010-01-26T00:18:00Z</published>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
<p>A quick and dirty example of how to make a feed proxy in C#/.NET for that cross site request browser security issue on the client side.</p>

<p>You would call it via a url like this ...</p>
<p><code>http://mydomain.com/Proxy.ashx?u=http://feeds.heatxsink.com/heatxsink/atom</code></p>

<p><em>filename:</em> Proxy.ashx</p>
<pre class="snippet">
&lt;%@ WebHandler Language="C#" CodeBehind="Proxy.ashx.cs" Class="FeedProxy.Proxy" %&gt;
</pre>
<p>filename: Proxy.ashx.cs</p>
<pre class="snippet">
using System;
using System.Web;
using System.Net;
using System.IO;

namespace FeedProxy
{
    public class Proxy : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            string url = context.Request.Params["u"];
            if(!string.IsNullOrEmpty(url))
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "GET";
                request.KeepAlive = true;
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                string responseBody = string.Empty;
                using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                {
                    responseBody = reader.ReadToEnd();
                }

                context.Response.ContentType = response.ContentType;
                context.Response.Write(responseBody);
            }
            else
            {
                context.Response.ContentType = "text/html";
                string message = string.Format("You must supply a 'url' query parameter.");
                context.Response.Write(message);
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
</pre>
<xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/heatxsink/atom/~4/XEmo6WCkwXo" height="1" width="1" /></div></content>
<feedburner:origLink>http://www.heatxsink.com/entry/rss-feed-proxy-csharp-dotnet</feedburner:origLink></entry>

<entry>
<title>Conan O'Brien Farewell Speech</title>
<id>http://www.heatxsink.com/entry/conan-o-brien-farewell-speech</id>
<link href="http://feeds.heatxsink.com/~r/heatxsink/atom/~3/bGNQ7T72bYU/conan-o-brien-farewell-speech" rel="alternate" />
<author><name>Nick Granado</name></author>
<updated>2010-01-25T05:21:21Z</updated>
<published>2010-01-25T05:20:00Z</published>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
<blockquote>
Please do not be cynical. I hate cynicism. For the record, it's my least favorite quality. It doesn't lead anywhere. Nobody in life gets exactly what they thought they were going to get. But if you work really hard, and you're kind, amazing things will happen. I'm telling you, amazing things will happen.

<em>Conan O'Brien</em>
</blockquote>
<xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/heatxsink/atom/~4/bGNQ7T72bYU" height="1" width="1" /></div></content>
<feedburner:origLink>http://www.heatxsink.com/entry/conan-o-brien-farewell-speech</feedburner:origLink></entry>

<entry>
<title>2010 New Year's Resolutions</title>
<id>http://www.heatxsink.com/entry/2010-new-years-resolutions</id>
<link href="http://feeds.heatxsink.com/~r/heatxsink/atom/~3/Ysax-eX6QwA/2010-new-years-resolutions" rel="alternate" />
<author><name>Nick Granado</name></author>
<updated>2010-02-18T05:21:54Z</updated>
<published>2010-01-25T04:44:00Z</published>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
<a href="http://www.flickr.com/photos/heatxsink/4266511354/" title="IMG_1082 by heatxsink, on Flickr"><img src="http://farm5.static.flickr.com/4044/4266511354_ca8fdb1015.jpg" width="375" height="500" alt="IMG_1082" /></a>

<p>I know this is a bit late, but here we go.</p>

<ol>
<li>Drink more tea and less Monster</li>
<li>Goto more Concerts</li>
<li>Build my first Android application</li>
<li>Build a second iPhone application</li>
<li>Travel</li>
<li><strike>Goto SXSWi</strike> I have a ticket.</li>
<li>Go Camping</li>
<li>Take more pictures</li>
<li>Start training for 2nd Marathon (this will probably take all year)</li>
<li>Use my bicycle more</li>
</ol>
<xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/heatxsink/atom/~4/Ysax-eX6QwA" height="1" width="1" /></div></content>
<feedburner:origLink>http://www.heatxsink.com/entry/2010-new-years-resolutions</feedburner:origLink></entry>

<entry>
<title>Saturn and Google AppEngine</title>
<id>http://www.heatxsink.com/entry/saturn-and-google-appengine</id>
<link href="http://feeds.heatxsink.com/~r/heatxsink/atom/~3/yzSPMr3Scx0/saturn-and-google-appengine" rel="alternate" />
<author><name>Nick Granado</name></author>
<updated>2010-01-19T08:21:15Z</updated>
<published>2010-01-18T00:50:00Z</published>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
<p>For those of you who have known me for awhile. There was a time about five or so years ago where I was attempting to refine a <a href="http://www.heatxsink.com/entry/saturn-is-born">thin client</a> for blog platform(s) because xml-rpc was all the craze and web services looked like they were going to rule the world. So five years later, I've re-purposed the name I used for my thin client for something very similar/appropriate.</p>

<p>I'd like to re-introduce <a href="http://github.com/heatxsink/saturn-project">saturn</a>, a simple blog platform that runs on Google's App Engine infrastructure. Now lets look at some screen-shots, if you want to look at the source code you can find it on github <a href="http://github.com/heatxsink/saturn-project">here</a>.</p>

<p>Here is a screen-shot of the "archive" interface.</p>
<p><a href="http://www.flickr.com/photos/heatxsink/4283646194/" title="archive view by heatxsink, on Flickr"><img src="http://farm3.static.flickr.com/2800/4283646194_c0a7b09827.jpg" width="500" height="186" alt="archive view" /></a></p>

<p>Here is a screen-shot of the "create a post" interface.</p>
<p><a href="http://www.flickr.com/photos/heatxsink/4282901165/" title="create view by heatxsink, on Flickr"><img src="http://farm3.static.flickr.com/2719/4282901165_577dbf70ce.jpg" width="500" height="404" alt="create view" /></a></p>

<p>Here is a screen-shot of the "edit post" interface.</p>
<p><a href="http://www.flickr.com/photos/heatxsink/4282884263/" title="edit view by heatxsink, on Flickr"><img src="http://farm5.static.flickr.com/4047/4282884263_86b77863c2_o.png" width="500" alt="edit view" /></a></p>

<p>Suggestions or feature requests are welcome, please send me e-mail!</p>
<xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/heatxsink/atom/~4/yzSPMr3Scx0" height="1" width="1" /></div></content>
<feedburner:origLink>http://www.heatxsink.com/entry/saturn-and-google-appengine</feedburner:origLink></entry>

<entry>
<title>Goodbye Slingshot Labs</title>
<id>http://www.heatxsink.com/entry/goodbye-slingshot-labs</id>
<link href="http://feeds.heatxsink.com/~r/heatxsink/atom/~3/SXSHARYLo0M/goodbye-slingshot-labs" rel="alternate" />
<author><name>Nick Granado</name></author>
<updated>2010-02-16T05:21:34Z</updated>
<published>2010-01-14T01:05:00Z</published>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
<p>Today, Slingshot Labs shut it's doors. There was some press.  I especially love how <a href="http://valleywag.gawker.com/5447489/shutting-down-rupert-murdochs-social-experiments-lab   ">valleywag.com</a> mentioned that Slingshot Labs had one last diabolical plot. Which made me think of a scene from "The Office."</p>

<p>
<img src="http://uploads.heatxsink.com/diabolical_plan.jpg" alt="diabolical plan" />
</p>

<p>The news also ended up on <a href="http://www.techcrunch.com/2010/01/13/slingshot-myspace-socialplan/">techcrunch.com</a>. It was sweet to see one of the ventures at Slingshot (SocialPlan) get absorbed by MySpace. Slingshot Labs was one hell of a ride, and everyone that was apart of the incubator had an opportunity to learn and grow at an amazing rate.</p>
<xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/heatxsink/atom/~4/SXSHARYLo0M" height="1" width="1" /></div></content>
<feedburner:origLink>http://www.heatxsink.com/entry/goodbye-slingshot-labs</feedburner:origLink></entry>

<entry>
<title>Not yet to know</title>
<id>http://www.heatxsink.com/entry/not-yet-to-know</id>
<link href="http://feeds.heatxsink.com/~r/heatxsink/atom/~3/0enWMWeLaB0/not-yet-to-know" rel="alternate" />
<author><name>Nick Granado</name></author>
<updated>2010-01-09T05:18:24Z</updated>
<published>2010-01-09T05:17:00Z</published>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
<blockquote>
To know and not to do is not yet to know.
<em>Zen saying</em>
</blockquote>
<xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/heatxsink/atom/~4/0enWMWeLaB0" height="1" width="1" /></div></content>
<feedburner:origLink>http://www.heatxsink.com/entry/not-yet-to-know</feedburner:origLink></entry>

<entry>
<title>Creating Application Performance Counters with C#/.NET</title>
<id>http://www.heatxsink.com/entry/creating-application-performance-counters-with-csharp-dotnet</id>
<link href="http://feeds.heatxsink.com/~r/heatxsink/atom/~3/77k4K3nZupo/creating-application-performance-counters-with-csharp-dotnet" rel="alternate" />
<author><name>Nick Granado</name></author>
<updated>2010-01-07T05:51:37Z</updated>
<published>2010-01-07T01:42:00Z</published>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
<p>Always wanted to know how to make your own performance counters?  Check out the code below.  There is a slight caveat.  The very first time you execute this code it will create the category and associated counters. When that occurs the process that's running must be an administrator. Best practice might be to handle counter creation in a pre-deploy step.</p>

<pre class="snippet">
using System.Diagnostics;

public class MyCounters
{
    private const string MASTER_CATEGORY = "My Company Category";
    private const string MASTER_CATEGORY_HELP = "My Company Application Counters";
    private const string QUEUE_COUNTER = "My Application Message Queue Count";
    private CounterCreationDataCollection counters = new CounterCreationDataCollection();
    private CounterCreationData queueCount = new CounterCreationData();
    private PerformanceCounter queueCounter = new PerformanceCounter();

    public MyApplicationCounters()
    {
        if (!PerformanceCounterCategory.Exists(MASTER_CATEGORY))
        {
            queueCount.CounterName = QUEUE_COUNTER;
            queueCount.CounterHelp = "Total number of items in the queue.";
            queueCount.CounterType = PerformanceCounterType.NumberOfItems32;
            counters.Add(queueCount);

            PerformanceCounterCategory.Create(MASTER_CATEGORY, MASTER_CATEGORY_HELP, PerformanceCounterCategoryType.MultiInstance, counters);
        }

        queueCounter.CategoryName = MASTER_CATEGORY;
        queueCounter.CounterName = QUEUE_COUNTER;
        queueCounter.MachineName = ".";
        queueCounter.InstanceName = "_Total";
        queueCounter.ReadOnly = false;
    }

    public int MessageQueueCount
    {
        get
        {
            return (int)queueCounter.RawValue;
        }
        set
        {
            queueCounter.RawValue = value;
        }
    }
}
</pre>
<xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/heatxsink/atom/~4/77k4K3nZupo" height="1" width="1" /></div></content>
<feedburner:origLink>http://www.heatxsink.com/entry/creating-application-performance-counters-with-csharp-dotnet</feedburner:origLink></entry>

</feed>
