Thursday, July 9, 2015

Finally Starting To Pick Up And Go

My current employer offers Professional Development as one of the benefits it offers its employees. It's not quite the old Google 20% time, but it's pretty close. So I finally have a little time to spend on the Go language, which I've been wanting to pick up for a while now. I'll blog here from time to time related to what I find. The first thing I'll mention is that I've always worked at MS shops, and this job is no different. All of the Go tutorials and introductions worth a damn are on MacOS or Linux, so here are a few things to be aware of when first picking up the language and running the hello world program

Getting Go

Grab the MSI for the latest stable version here https://golang.org/dl/

The Official Getting Started Guide

https://golang.org/doc/install

Setting GOPATH

The guide uses the export command. This doesn't exist on windows. On windows, open up a command prompt and create a directory for your Go workspaces. I called mine c:\mine\golang\workspace. Then at the command prompt run

c:\mine\golang\workspace>set GOPATH=c:\mine\golang\workspace

Note that just setting this in the command prompt will mean this variable is only available in the current instance. If you were to open up another command prompt and use the echo command to view the variable (echo %GOPATH%) you would not see the value you just set. If you are going to make this your permanent workspace directory you should set the GOPATH in your environment variables under System Properties.

How To Write Go Code

https://golang.org/doc/code.html

Under your newly created workspace directory add your pkg, bin and hello directories. The Writing Code guide and the linked screencast talk about adding a path underneath linked to your github account. I didn't bother with that. For the hello world program I simply created a hello directory under src. So after writing the hello world program in src\hello\hello.go, I was able to run the following

c:\mine\golang\workspace>go install hello

This writes hello.exe to c:\mine\golang\workspace\bin\hello.exe, which you can run as instructed in the tutorial

After doing this I have the following structure in my folder.
C:.
├───bin
│       hello.exe

├───pkg
└───src
    └───hello
            hello.go

Hopefully this is enough, combined with the existing online material, to get you writing programs in Go on windows. These may seem like trivial little things, but the idea of workspaces and using directory structures like this will seem foreign to people using nothing but Visual Studio for their development work, which hides a lot of this underlying work from you.

Tuesday, July 22, 2014

Saving and Sharing Web Page Performance Information from Chrome

I was perusing a web site during lunch and once again lamenting its performance. I fired up the devtools for chrome and the Network tab does a good job of showing you the sticking points in the app and I was wondering if there is a way to share this sort of information. It turns out there is. The data from the Network tab can be saved in a format called HAR. HAR is a JSON format that contains all of the data you see in the network tab in devtools.

There appear to be quite a few tools available for allowing you to view HAR data. The most accessible one I found was here http://ericduran.github.io/chromeHAR/

A good summary of HAR files is here



If you want to save data from the network tab in a HAR file in Chrome devtools, right click in the log of network traffic and select Save As HAR With Content. This file can then be dropped onto the above HAR viewer page and you can see the output, including the timeline.

Friday, June 27, 2014

Cleaning up Disk Space on Your Machine

One recurring annoyance with working on lots of different projects is that over time your disk just gets full. Working in many MS SQL Server databases over the years I've noticed that there is a pretty simple way I can usually reclaim a lot of diskspace from SQL Server on my machine. I currently have over 100 development databases on my machine and a lot of those were one time uses. I'm sure I could remove a bunch of them, but in a pinch, this allowed me to very quickly reclaim over 30GB of disk space

Dynamically generate the dbcc shrink database syntax for all of the databases on my box

select 'dbcc shrinkdatabase([' + name + '], TRUNCATEONLY);' from sys.databases where name <> 'master'


copy the output into a sql server query window and run it

I had issues with one database because it was restoring. After removing that database from the list of queries, it ran rather quickly and I got a gobs of disk space back. If you have databases on your machine that you do not want to shrink, you can remove those from the list

For more information on SHRINKDATABASE

http://msdn.microsoft.com/en-us/library/ms190488.aspx

Update

You can use the following to generate a dynamic sql statement and execute it using EXEC

DECLARE @SQL VARCHAR(MAX)

select @SQL = COALESCE(@SQL,'') + '
dbcc shrinkdatabase([' + name + '], TRUNCATEONLY);' from sys.databases
where name not in ( 'master', 'model', 'tempdb', 'msdb')

print cast(@SQL as ntext)

EXEC(@SQL)

Tuesday, July 3, 2012

Fun and insightful read

The Codeless Code is a fun read. Also it looks like it has been waaaaay too long since I've posted anything. I've been at a new job since Oct 2011, and am working mainly in javascript these days. Quite a change from C# in a lot of ways, and most of them good as far as I'm concerned, with the exception of issues I seem to continually have with supporting libraries we use. That and my CSS knowledge is somewhere between none and enough to be dangerous. I need to work on that.

Friday, July 8, 2011

webrat needs to be bundled as well

In addition to getting rspec installed correctly, webrat is required to test the page content with response.should have_selector("title"....

Here are the instructions. I had to include the proper version (0.7.0) in the Gemfile, then do a bundle install.

getting rspec installed

The tutorial I'm using calls for using rspec for testinhttp://www.blogger.com/img/blank.gifg. In order to get it so I could install it and add it I had to follow these instructions.

Thursday, July 7, 2011

Finally really working on Rails

After several false starts we have a project at work where we are looking at using Rails. So far so good. I'm using http://ruby.railstutorial.org/ruby-on-railshttp://www.blogger.com/img/blank.gif-tutorial-book as my tutorial and so far it is my kind of book. I'm using the bitnami rubystack virtual machine using Rails 3 in ubuntu. There have been a couple of hiccups along the way. 1) is remembering to use sudo on the VM for most installs and updates and even running the server to test the appliction. Not a HUGE deal, but a minor annoyance. Also, when doing the push the first time to deploy to heroku, I got an error saying that heroku does not appear to be a git repository. The fix for that is here.