• Clean SQL Transactions in Golang

    Published on JAN 27, 2018 about a 3 minute read

    TL;DR: Working with db transactions in Go should be simple, so I made some utilities to help with that. You can see the gist containing all the code here. The database/sql package has everything you need in order to work with db transactions for most vendors. Typically, you’ll write something like this: While this code works, there are a few of things I think could be better about it.

    GOLANG

  • Monitoring Rails Requests with StatsD

    Published on SEP 4, 2015 about a 3 minute read

    Monitoring your application is important - full stop. When the response time plummet’s you want to know before your customers do…and certainly before you bother to check your twitter feed. There are lots of options here, and a lot of them require a ton of upfront investment in terms of time and effort. However, a simple way to get started is to simply log total request durations and track the number of successful and failed responses.

    RAILS, RUBY

  • Compiling Vim with Ruby and Python Support

    Published on JAN 27, 2015 about a 2 minute read

    Like a lot of developers, I use vim. Of course, I don’t use straight out of the box vim though. I use Vundle and other settings (see my dot files for more) to make it better. Sometimes there are plugins, or packages that require vim to be compiled with support for ruby and/or python. One example of this is the excellent Command-T plugin. Unfortunately, the default package doesn’t include these flags during compilation.

    CHEF, VIM

  • Running Rails Inside Vagrant

    Published on DEC 27, 2014 about a 3 minute read

    I use vagrant (along with chef, a vagrant plugin and my dotfiles) for my development environment. I do this for a number of reasons, but mostly, I find it’s the easiest way to get everything installed and configured properly regardless of which physical box I’m working on. There are a number of issues I needed to address to get this all working. One of those, was getting a simple rails server from inside the VM to be available from my host’s browser.

    RAILS, VAGRANT

  • Dining Philosophers in C

    Published on MAR 1, 2014 about a 4 minute read

    In a recent bout of insanity, I thought it would be cool to play around with concurrency in pure C. Nothing crazy, maybe controlling access to a shared resource and a semaphore or two for good measure. Since I assumed this would be no easy feat in C, I deciced I’d start with a problem I knew. So I went with the dining philosophers problem. Defining the Problem There are five (can be adjusted) philosophers sitting around a round table.

    ALGORITHMS, C, THREADING

  • Freezing and Thawing Git State

    Published on DEC 11, 2013 about a 2 minute read

    We do lightening/dev talks every week at work, where a few developers get up and talk about cool projects or anything they think is interesting. One of the recent talks by James MacAuley was about git freeze and git thaw. The basic idea is that git stash kinda sucks sometimes. To show that, let’s run through an example. Example of Using Git Stash mkdir demo_repo && cd demo_repo git init git commit -m "initial commit" --allow-empty touch README.

    GIT, SHELL

  • Pushing Files to GitHub Programmatically

    Published on OCT 7, 2013 about a 2 minute read

    Recently I had the opportunity to work with GitHub’s API again. This time I was particularily interested in the Repo Contents API. The goal was to be able to publish files from disk or embedded resource (read: stream) directly to a GitHub repo without having to clone the repo somewhere and then issue a git push. The API seemed (as is always with case with the GitHub API) straightforward and had methods for creating and updating files.

    API, GITHUB, NUGET

  • Drying Out Specs With Shared Examples

    Published on AUG 24, 2013 about a 2 minute read

    I generally find that most developers are fairly aware of and willing to apply the DRY principal on their main codebase. However, when I look through people’s tests, I find that the old copy/paste habit has found it’s way into their workflow (again?). I’m using “their code” to save face here…I found this in my own code and started looking for ways to clean it up. So, let’s take a look at an example of how we can remove some duplication from our specs.

    RSPEC, RUBY, TESTING

  • Continuous Integration for .NET with Travis CI and xUnit

    Published on AUG 13, 2013 about a 5 minute read

    For this post, I’m going to go over getting a simple CI environment setup using Travis CI and xUnit. If you’re one of those people that just wants to see the code, click here! Our goal is to have the following scenario: whenever a push happens (to any branch) on GitHub, a build of the app will be triggered by Travis CI. If the build succeeds, it will run all of the unit tests for your app.

    .NET, AUTOMATION, CI

  • My First Ruby Brigade Meetup

    Published on AUG 7, 2013 about a 2 minute read

    Last night I attended my first Ruby Brigade Meetup in Toronto and I have to admit…it was kinda fun! It was graciously hosted at Influitive’s downtown office on Adelaide St. When I got there I was happy to see some fancy boardrooms and a bunch of pairing stations for us to use. All in all, a great location. We got a little caught up in some general technology discussions so as expected we got started a little late.

    RUBY

  • Testing EmberJS Apps with Rails and QUnit

    Published on JUL 28, 2013 about a 3 minute read

    I recently started playing around with EmberJS. While I was insanely impressed with how easy it was to get a single-page app up and running, I was having difficulty getting QUnit setup correctly. After some finagling I was able to get it working. In my particular case I’m using Ruby 2.0.0 and Rails 4.0.0, though I’m sure this same setup would work with previous versions with minimal (if any) tweaks.

    JAVASCRIPT, RUBY, TESTING

  • Implementing a Generic Stack in C

    Published on JUN 19, 2013 about a 3 minute read

    In a previous post I went over how we could create a generic linked list implementation in C which would allow the caller to determine that type of information stored in the list (via a void *). In accordance with my desire to share and the nerdy, sadistic, love/hate relationship I have with C, I’m going to cover how we can use the linked list code from the previous post to create a generic stack implementation with very little effort.

    C, DATA STRUCTURES

  • Implementing a Generic Linked List in C

    Published on MAY 2, 2013 about a 7 minute read

    Because I am a totally shameless nerd, I find myself writing applications in C from time to time just to make sure I still can. Aside from iOS development, I rarely have to work with C directly (without the help of a superset like C++ or Objective-C), but every once in a while I like to try and challenge myself to write an application in pure C. I’ve found that doing this has led to a much more profound understanding of modern languages and has really opened my eyes to the challenges faced by developers who write their own languages or work with compiler optimization (I know a few…it sounds like tough work!

    C, DATA STRUCTURES

  • Application Templates for Rails

    Published on DEC 17, 2012 about a 1 minute read

    Frequently I find myself creating basic rails apps to demonstrate a new feature, or prototype something for a spike test. Every time I created an app, I would run rails new -T, then add RSpec, Cucumber, Haml, possibly Bootstrap, etc. After the 10th app in a month, I decided that there must be an easier way. Then I saw this post: http://everydayrails.com/2011/02/28/rails-3-application-templates.html I started reading up on generators and application templates, then I thought I’d write my own, to see how it works.

    AUTOMATION, RAILS, RUBY

  • Changing Your Windows 8 Product Key

    Published on OCT 28, 2012 about a 1 minute read

    I just recently installed Windows 8 on my home computer. During the installation process, I was not asked to provide a product key. This led to me not being able to activate Windows after the installation process. To resolve this, follow these steps: From the start screen, type cmd Right-click on Command Prompt and select Run as Administrator Execute the following command: slmgr -upk Press Windows+C to bring up the Charms window Select Settings and click Change PC Settings The Activate Windows tab will now ask you for your product key Oddly enough, I had trouble finding this info so I thought I’d share.

  • MVC Razor Helpers using Delegates

    Published on MAR 9, 2012 about a 2 minute read

    Once in a while, I find myself implementing the same helper functions in different pages. In an effort to not repeat myself, I generally move helper functions into a common cshtml file in App_Code (as suggested here). While this works great for a single application, I’ve found myself copying helpers from project to project. So in order to avoid the copy-paste nightmare, I decided to see if I could abstract the basic functionality into an extension method and then have application specific rendering.

    .NET, MVC

  • Efficient, Thread-Safe Caching with ASP.NET

    Published on FEB 27, 2012 about a 3 minute read

    Let me start by saying that I’ve made this mistake on many occasions in the past. I just assume that static/shared objects are thread-safe. Things like HttpContext.Current.Cache…OOPS! A typical implementation of a cache lookup might look like this: Let’s analyze this code in a little detail. Here are the steps performed: Load the object from the Cache If the object is null (not found) Create the object and store it in the cache Return the object back to the caller To start, we should ask, what happens if 10 simultaneous requests come through attempting to get to the cache object?

    .NET, CACHING, THREADING

  • Set up a Subversion Server in EC2

    Published on DEC 24, 2011 about a 7 minute read

    I recently wanted to setup a subversion server. Initially I thought of using Beanstalk since they handle pretty much everything for you for a very small monthly fee. However, I thought I might set up my own server in order to learn the process. I found a few online resources that outlined the process, but none of them were exactly what I needed, so I decided to write this post to go over the steps in detail.

    DEV OPS, SOURCE CONTROL, SUBVERSION

  • NSDate From OData

    Published on JUL 29, 2011 about a 2 minute read

    Recently I’ve been working on an iOS project that loads data that we publish via the Open Data Protocol. At first everything was working perfectly. I was using JSONKit and NSOperation to download and process the information. That was until I had to get a DateTime object…which resulted in an epic fail! It turns out that WCF Data Services publish DateTime objects as a new Date object represented by the time in milliseconds (not seconds) since January 1, 1970.

    IOS, OBJECTIVE-C, ODATA

  • Showing Enums as a Select List in MVC and Razor

    Published on JUL 27, 2011 about a 1 minute read

    Recently I needed to show a drop down list of all of the enumeration values. So I did what we all do and hit up Google. While there was plenty of information out there detailing how to convert the enum to a Dictionary<int, string> and render it, I couldn’t find something that fit my needs. Essentially I have an enumeration of field types. I wanted to display the names of those fields in a drop down list, but be able to make some of them prettier.

    .NET, MVC, RAZOR

  • Global Namespace Includes with MVC and Razor

    Published on MAR 7, 2011 about a 1 minute read

    While I’m loving MVC3 and the Razor view engine, I was sorely disappointed when I couldn’t use the system.web/pages/namespaces collection in web.config to add global namespace includes. After a bit of hunting and looking through the web.config files underneath the views folder (in each Area), I found that this can be accomplished by adding the following to the root web.config file: Now you can add any namespaces you require under the new razor namespaces section.

    .NET, MVC, RAZOR

home


Copyright © 2018 pseudomuto.com. All rights reserved.