TwitterGoogleRSS

AUDUSD – Historical Data

I’ve been looking at Gold and AUD/USD trends tonight and I found two good sources for historical exchange and commodities data. For Gold and Silver historical prices can be found at perthmint.com.au/metalPrices.aspx. Some of this data also shows things like lease rates which can be really interesting to analyse and graph. For exchange data I found some good historical data over at rba.gov.au/statistics/hist-exchange-rates/index.html To get a quick visualisation of this data I’ve been importing this data into a Google Docs spreadsheet and producing some graphs.

P.S. On a little side project I’ve also tried whipping up a quick Spreadshirts store. Go check it out and tell me what you think :-) !

Be Sociable, Share!

Productivity – Ambient Noise

I’ve posted a few things about productivity in the past year. One technique I use every now and again is “The Pomodoro Technique“. Today I want to talk about something as simple as “noise”. Most of us have used music as an “anti-distraction” technique to get through some task. But sometimes even music can be distracting in itself. Changing songs, singing/dancing, or even just being lulled into a trance where you forget all about the task your trying to complete. Here are 3 of my most popular sites to listen to help achieve that important work.

coffitivity.com – Ever felt the need to go to the local coffee shop to do your work? Now you can bring the coffee shop home. This site streams the audio of what could be a busy coffee shop. Surprisingly I find it relaxing and eventually forget I’m even listing to it. It reduces the chances of me getting distracted and seems to keep me focused on whatever I’m doing at the time.

di.fm – Digitally imported is a radio streaming site specialising in electronic music. Even if your not specifically into some “Funky House” or “Progressive Psy” I find “Space Dreams” and “Lounge” to be really good depending on my mood. Other days I might even listen to some “Hardcore” to get my energy up. They have so many channels it’s up to you.

iTunes or “Tunein Radio” – Sometimes you need to find something more specific. Using iTunes or the “Tunein Radio” app on your mobile device opens up a huge selection of very specific radio selections. You can pick anything from a specific “The Beatles” album rotations to sounds of the beach.

Be Sociable, Share!

Messenger Trends

I find it really interesting looking at Google trends. While exploring a few trends I found it interesting looking at some of the messenger programs I’ve used in the last decade. Does anyone use chat anymore? This is what the Google history for a few messengers looked like since 2004.

Messenger Trends

It appears people are more willing to push to the social clouds and hope someone is interested in what they have to say. But to think I still freak out with excitement when I hear the old ICQ message sound.

Be Sociable, Share!

Git – “chmod” on Windows

Git works on almost all platforms flawlessly. But because Git take it’s heritage from the Linux community things like file permissions work a little differently then Windows users would expect. In my specific situation I’m pushing a Git repository to Openshift. When the build runs on the git repository I receive the following error.

"../go/bin/go: Permission denied".

This is caused by the go binary (which is checked into my git repository) not having “execute” permissions on the Linux machine. Normally a Linux user would run “chmod +x <filename>” to add execute permissions and then commit/push the updated file to git. On Windows we don’t have chmod but we can update the file permissions directly within Git.

git update-index --chmod=+x <filename>

Then commit/push the Git repository as normal and the file permissions should be updated for all pull requests thereafter.

Be Sociable, Share!

Go – Openshift

There are a few options for running Go on the web. Google app engine is a popular option for running Go services but an up and coming option is Openshift. Although Go cannot be run on Openshift using the simple online wizards they do offer a DIY solution. github.com/gcmurphy/golang-openshift has a very easy to use base for creation your own go applications.

Be Sociable, Share!

Markdown – Adding CSS to your HTML file

Markdown is very easy to write both by users or any scripting/programming languages. I describe how markdown can be written in my post “Go – Writing markdown“. If you choose to display markdown to users online you may wish to make the page look a little more snazzy. A simple way of doing this is generating a HTML file and adding a CSS file to “theme” your page.

The HTML will require a CSS theme added in the tags. In this example I will borrow a theme from github.com/jasonm23/markdown-css-themes.

<html>
<head>
<link rel="stylesheet" type="text/css" href="https://raw.github.com/jasonm23/markdown-css-themes/gh-pages/markdown1.css">
</head>

Then we need to add the tags containing the generated HTML file and the closing tag.

<body>

<!--This page was created with Markdown-->
<!--Start of generated html-->
<h1>Email Brief</h1>

<h2>Gmail Team &lt;mail-noreply@google.com&gt;</h2>

<h3>Get Gmail on your mobile phone</h3>

<p>[image: Access Gmail on your mobile phone]
<a href="http://www.google.com/xxxyyy">http://www.google.com/xxxyyy</a></p>

<h2>Gmail Team &lt;mail-noreply@google.com&gt;</h2>

<h3>Import your contacts and old email</h3>

<p>You can import your contacts and mail from Yahoo!, Hotmail, AOL, and many
other web mail or POP accounts. If you want, we'll even keep importing your
mail for the next 30 days.
 Import contacts and mail
=BB<a href="https://mail.google.com/mail/#settings/accounts">https://mail.google.com/mail/#settings/accounts</a></p>

<h2>Gmail Team &lt;mail-noreply@google.com&gt;</h2>

<h3>Customize Gmail with colors and themes</h3>

<p>To spice up your inbox with colors and themes, check out the Themes tab
under Settings.
 Customize Gmail =BB <a href="https://mail.google.com/mail/#settings/themes">https://mail.google.com/mail/#settings/themes</a></p>

<h2>Google+ team &lt;noreply@plus.google.com&gt;</h2>

<h3>Getting started on Google+</h3>

<p>Hey,Welcome to Google+ - we're glad you're here! Here's a video and<br/>
some tips to help you get started:</p>
<!--End of generated html-->

</body>
</html>

This is a very simple theme but looks much nicer then the default unstyled HTML.

Markdown To HTML Displaying Preview Of Emails

Be Sociable, Share!

Go – Writing markdown

In my post “Go – Writing a simple email client” I described some quick Go code to download your Gmail content through IMAP. In this post I’ll extend the email client to generate markdown. Then I will describe how this content can be converted into html.

Lets say we want to print an overview of the email content in our INBOX. We will require the “Name” and “Address” where the email came from. We will also require a quick snippet of the email. Here is what the extra code might look liked.

	fresp, err := im.Fetch("1:*", []string{"RFC822", "Envelope"})
	if err != nil {
		fmt.Print("Fetch failed\n")
		os.Exit(1)
	}

	fmt.Println("Email Brief")
	fmt.Println("===========\n")
	for _, fr := range fresp {
		fmt.Println(fr.Envelope.From[0].Name + " \\<" + string(fr.Envelope.From[0].Address) + "\\>")
		fmt.Println(strings.Repeat("-", 5+len(fr.Envelope.From[0].Name)+len(fr.Envelope.From[0].Address)))

		fmt.Println("###" + *fr.Envelope.Subject + "###")

		fmt.Println(strings.Split(string(fr.Rfc822), "\r\n\r\n")[2] + "\n")
	}
}

In my case I’m testing this with a new Gmail account and have received 4 emails from Google. The output I receive is

Email Brief
===========

Gmail Team \<mail-noreply@google.com\>
--------------------------------------
###Get Gmail on your mobile phone###
 [image: Access Gmail on your mobile phone]
<http://www.google.com/xxxyyy>

Gmail Team \<mail-noreply@google.com\>
--------------------------------------
###Import your contacts and old email###
You can import your contacts and mail from Yahoo!, Hotmail, AOL, and many
other web mail or POP accounts. If you want, we'll even keep importing your
mail for the next 30 days.
     Import contacts and mail
=BB<https://mail.google.com/mail/#settings/accounts>

Gmail Team \<mail-noreply@google.com\>
--------------------------------------
###Customize Gmail with colors and themes###
To spice up your inbox with colors and themes, check out the Themes tab
under Settings.
       Customize Gmail =BB <https://mail.google.com/mail/#settings/themes>

Google+ team \<noreply@plus.google.com\>
-------------------------------------------------
###Getting started on Google+###
Hey,Welcome to Google+ - we're glad you're here! Here's a video and  
some tips to help you get started:

I am a fan of markdown and like reading it as is. But there are many tools which can convert markdown into html including github.com/knieriem/markdown which is written entirely in Go. By saving this markdown to emailbrief.md we can convert this markdown into html.

> go get github.com/knieriem/markdown
> go build github.com/knieriem/markdown/cmd/markdown
> markdown.exe emailbrief.md

This will produce the following output.

<h1>Email Brief</h1>

<h2>Gmail Team &lt;mail-noreply@google.com&gt;</h2>

<h3>Get Gmail on your mobile phone</h3>

<p>[image: Access Gmail on your mobile phone]
<a href="http://www.google.com/xxxyyy">http://www.google.com/xxxyyy</a></p>

<h2>Gmail Team &lt;mail-noreply@google.com&gt;</h2>

<h3>Import your contacts and old email</h3>

<p>You can import your contacts and mail from Yahoo!, Hotmail, AOL, and many
other web mail or POP accounts. If you want, we'll even keep importing your
mail for the next 30 days.
 Import contacts and mail
=BB<a href="https://mail.google.com/mail/#settings/accounts">https://mail.google.com/mail/#settings/accounts</a></p>

<h2>Gmail Team &lt;mail-noreply@google.com&gt;</h2>

<h3>Customize Gmail with colors and themes</h3>

<p>To spice up your inbox with colors and themes, check out the Themes tab
under Settings.
 Customize Gmail =BB <a href="https://mail.google.com/mail/#settings/themes">https://mail.google.com/mail/#settings/themes</a></p>

<h2>Google+ team &lt;noreply@plus.google.com&gt;</h2>

<h3>Getting started on Google+</h3>

<p>Hey,Welcome to Google+ - we're glad you're here! Here's a video and<br/>
some tips to help you get started:</p>
Be Sociable, Share!

Go – Writing a simple email client

As described in my last post Go – Accessing Gmail with IMAP I have started working on the GoLang IMAP package github.com/NerdGGuy/go-imap. After some restructuring and investigation I have a simple example of how to use the go-imap package.

package main

import (
	"crypto/tls"
	"flag"
	"fmt"
	"github.com/nerdgguy/go-imap"
	"os"
)

func usage() {
	fmt.Print("Only works on Gmail accounts\n")
	fmt.Print("Make sure IMAP is enabled in your Gmail account.")
	fmt.Printf("usage: %s email password\n", os.Args[0])
	os.Exit(0)
}

func main() {
	flag.Parse()

	args := flag.Args()
	if len(args) < 2 {
		usage()
	}
	user := args[0]
	pass := args[1]

	conn, err := tls.Dial("tcp", "imap.gmail.com:993", nil)
	if err != nil {
		fmt.Print("Connection to imap.gmail.com:993 failed")
		os.Exit(1)
	}

	im := imap.New(conn, conn)
	//im.Unsolicited = make(chan interface{}, 100)

	hello, err := im.Start()
	if err != nil {
		fmt.Print("Hello failed")
		os.Exit(1)
	}
	fmt.Printf("Server hello: %s\n", hello)

	fmt.Printf("logging in...\n")
	resp, caps, err := im.Auth(user, pass)
	if err != nil {
		fmt.Print("Auth failed\n")
		os.Exit(1)
	}
	fmt.Printf("Server capabilities: %s\n", caps)
	fmt.Printf("Server resp: %s\n", resp)

	examine, err := im.Examine("INBOX")
	if err != nil {
		fmt.Print("Examine failed\n")
		os.Exit(1)
	}
	fmt.Printf("Mailbox status: %+v\n", examine)

	fresp, err := im.Fetch("1:*", []string{"RFC822"})
	if err != nil {
		fmt.Print("Fetch failed\n")
		os.Exit(1)
	}
	for _, fr := range fresp {
		fmt.Printf("Fetch resp: %v\n", string(fr.Rfc822))
	}
}
Be Sociable, Share!

Go – Accessing Gmail with IMAP

I’m in very early days of updating github.com/martine/go-imap to provide better support for accessing Gmail (and other IMAP email) from GO lang. I’ll provide instructions below on how to run the imapsync demo. I DON’T recommend you run this against your primary email account as this is very alpha software and may irreversibly damage or remove your emails. At the present time imapsync is hardcoded to access Gmail accounts only.

go get github.com/NerdGGuy/go-imap
cd $GOPATH/src/github.com/NerdGGuy/go-imap/imapsync
go run .\main.go .\debug.go .\mbox.go .\netmon.go list <username> <password>
go run .\main.go .\debug.go .\mbox.go .\netmon.go fetch <username> <password> INBOX
Be Sociable, Share!

Graphing in Go – Bulletgraph

You may have noticed in my recent posts (most notably Bitcoin Charts – Bid Comparison) I have been generating bullet graphs using the GO lang package github.com/NerdGGuy/BulletGraphGo. I started writing this package was created when I wanted to generate graphs in GO. There wasn’t much available that fit my needs until I discovered SVGO. By porting the SVGO bullet graph example to a package I was able to generate any bullet graph with ease. Here’s an example of how to generate a simple bullet graph.

package main

import (
	"github.com/NerdGGuy/BulletGraphGo"
	"github.com/ajstarks/svgo"
	"os"
)

func main() {
	canvas := svg.New(os.Stdout)
	canvas.Start(1024, 800)
	canvas.Rect(0, 0, 1024, 800, "fill:white")
	canvas.Gstyle("font-family:Calibri;font-size:18px")
	bg := bulletgraph.New(canvas)
	bg.Data = append(bg.Data, bulletgraph.Bdata{Title: "Test", Subtitle: "subtitle", Scale: "0,60,2", Qmeasure: "27,29", Cmeasure: 27.5, Measure: 28.5})
	bg.Drawbg(canvas)
	canvas.Gend()
	canvas.End()
}

Bullet Graph Example

If you have any questions feel free to ask in the comment/twitter/G+.

Update: I have generated some documentation. I will try and make this more complete in the future.


PACKAGE

package bulletgraph
import “github.com/NerdGGuy/BulletGraphGo”

Package for generating bulletgraphs in SVG – bullet graphs (Design Specification http://www.perceptualedge.com/articles/misc/Bullet_Graph_Design_Spec.pdf)

TYPES

type Bdata struct {
    Title    string
    Subtitle string
    Scale    string
    Qmeasure string
    Cmeasure float64
    Measure  float64
}

Title: Title of the bulletgraph. Displayed on the left of the bullet graph by default.
Subtitle: Subtitle displayed under the title.
Scale: A delimited string indicating the start,end,increment values for the bullet graph e.g. “0,60,2″.
Qmeasure: A delimited string indicating the comparison “zones” in the bullet graph e.g. “27,29″.
Cmeasure: The comparison indicator in the bullet graph. Measure: The measure for the bar to display.

type Bulletgraph struct {
    Top   int
    Left  int
    Right int
    Title string
    Data  []Bdata
    Note  []Note
    Flags Options
}

Top: The top of the first bullet graph.
Left: The leftmost pixel to draw the bullet graph.
Right: The rightmost pixel to draw the bullet graph.
Title: The title of the the generated SVG.
Data: An array of all the bullet graph data.
Note: An array of notes to display at the bottom of the SVG.
Flag: Options for generating bullet graphs.

func New(canvas *svg.SVG) *Bulletgraph

Creates a new Bulletgraph with default options.

func (bg *Bulletgraph) Drawbg(canvas *svg.SVG)
    Drawbg draws the bullet graph onto the canvas
type Note struct {
    Text string `xml:",chardata"`
}

Text: Note to be displayed under the bullet graph.

type Options struct {
    Width, Height, Fontsize, Barheight, Gutter     int
    Bgcolor, Barcolor, Datacolor, Compcolor, Title string
    Showtitle, Circlemark                          bool
}

These options have default values some of which are derived from the canvas.
Width: Width
Height: Height
Fontsize: Fontsize (px)
Barheight: Bar height
Gutter: Height of gutter around bar
Bgcolor: Background color
Barcolor: Bar color
Datacolor: Data color
Compcolor: Comparative color
Title: Title
Showtitle: Show title
Circlemark: Circle mark

Be Sociable, Share!