RSSAmplifier

Blog

(untitled)

markcampbell.meRSS feed ↗20 posts

Latest posts

Get the current database connection information with Ecto and Phoenix

How does one get the database name of the current connection / Ecto Repo that you're using in your Phoenix app? Well, the way you do it is to look at how the credentials are configured. In Phoenix, we use the config command which comes from Config . In turn, MyApp.Repo that you invoke with use Ecto.Repo reads that configuration. For our purposes, we'll use Application.fetch_env from the Config…

csv_to_gsheet command released!

Please welcome to the programming world the csv_to_gsheet command! With this command, you can import your csv files to Google Sheets without going through Google's CSV import wizard. Install it with gem install csv_to_gsheet . Using it requires creating an OAuth2 app for Google Services and using that app's credentials.json file locally. After that, do this: $ csv_to_gsheet ./my_data.csv # <web…

Terrible zsh profiling

Have you ever wanted to profile your .zshrc to figure out what's slow when you launch a prompt? Or do you find yourself trying to answer with your Google-fu the question of "can you profile zsh startup"? Look no further! This project which is simple enough for you to throw in anywhere and get useful output. Introducing the Terrible ZSH Profiler . It's dead simple, you could have written it in an…

A lesson in logging: never hide behavior

November 2018 edit : I've had some time to think about this and I don't think that adding noise to your logs is useful, actually. The healthcheck messages you see in low throughput applications is definitely noise and, depending on how often you see the healthcheck (our app had it going about… 5x per 10 seconds… that was way too much!), it can detract from getting things done. Weigh your chocies,…

Escape double quotes in Postgres with COPY

The title of this post is actually what I googled when I was running into a specific problem where a CSV file I was importing had double quotes in the file like this: # my_file.csv First Field|Second Field|Third Field Foo"|Bar|Baz With a Postgres table like this (I'm using 9.5.1): -- create_table.sql CREATE TABLE "My_Table" ( "First Field" char ( 50 ), "Second Field" char ( 50 ), "Third Field"…

Decoding the Ruby on Rails signed session cookie

Note: this article is primarily about Ruby on Rails 3 which uses a cryptographically signed cookie while Ruby on Rails 4+ has an encrypted cookie by default I was prompted at work recently to review the use of cookies within the app. I figured that I could take a look at the source code to see how they were being used (which I did) and also I should take a look in the browser as to which cookies…

Setting up Vim to yank to clipboard on Mac OS X

I'm writing this post because it took me a long time to figure out all of the little steps necessary to get Vim to yank to the clipboard. I'm using El Capitan which is the latest version of OS X at the time of this writing (2016-04-12), so keep that in mind. Ensuring Vim is capable If you just want to be able to copy to OS X's clipboard, you just need +clipboard . If you want X11 clipboard…

BSides Winnipeg 2015 Coin CTF Writeup

If you want to see more of the code, checkout the github repository for this puzzle . Big thanks to Paul and Michael Loney for working with me on the puzzle; I couldn't have done it without them! Also, thanks to Mak Kolybabi for creating the puzzle in the first place! At 2015 edition of BSides Winnipeg, there was a capture-the-flag /puzzle based on a physical coin: From there, we see a few things:…

Database Transactions With pytest

For past few years I've been primarily a ruby programmer. In the ruby ecosystem, testing is seen as pretty important and I wanted to have the same tooling in python. Where I work where I used to work (I've since moved on), we primarily used rspec in conjunction with Rails. The combo comes with a few things by default: Test discovery under spec/ or test/ Automatic database transaction support per…

Mutate your Rack middleware's env!

originally appearing on theScore's blog If you've been a Ruby developer for a while, chances are that you've written some kind of Rack middleware. Rack is a pretty big part of web development with Rails, and here at theScore we've developed a few, small pieces of middleware to add additional data to our requests so that our Rails applications can use it. If you're not familiar with Rack or Rack…

The Toiling Programmer: Succeeding as a Developer

Not sure if you're a toiling programmer? Ask yourself these questions: Do you feel like you're drowning, that there's no end in sight? Do you get stuck on long running problems (1 or more days long)? Are you unsure what needs to be done on a ticket , and yet you continue to work on it? Do you often get feedback that functionality is missing after you've shipped the work? That feeling of dread is…

Using Airbrake with Rake and not Rails

At theScore (where I work currently), we use Airbrake for our error reporting. An error happens, the error gets sent to Airbrake and then we're notified via email. We can then investigate all the goodness from their website. Fantastic! Most ruby apps are centered around some kind of web-service (mainly Ruby on Rails). As such, Airbrake has really good Rails integration – even on their rake tasks!…

Logging Airbrake Error IDs in Rack or Sinatra

One small thing that irked me while implementing Airbrake for an Sinatra app that we have at theScore was the fact that if an error occurs, it isn't logged anywhere. I was relying on the error showing up in Airbrake – if it ever would! If you have a Sinatra application, make sure to follow their instructions on setting up Airbrake with a Sinatra app . Follow their instructions on setting up…

Daily stand-ups as a mechanism for knowledge transfer

I realized the other day that my daily stand-ups (no, not stand-up comedians) with my team are becoming more and more important as time goes on. The reason for this is because what we're communicating to each other is the bits of hard-won knowledge from the previous day. When my teammate is telling me what he did yesterday, what he solved, how he solved it and what trouble he's having, it's one of…

Preventing Navigation in an AngularJS Project

New technologies bring new solutions to problems. Sometimes, however, they also bring old problems back. One of these old problems for AngularJS is interrupting navigation in a web application. It used to be that you could hook into the approriate window event ( onbeforeonload ) and be done with it. Unfortunately, AngularJS introduces the idea of a single-page app in which you never do navigate…

The Ideal Web Application Development Cycle

So you're a web application developer working alongside a bunch of other developers. You're a part of a team! Every workplace has their own way of doing things and being a part of a team usually means that the team you're working on is your team. Exposure to other teams or companies and how they do things is not a common occurrence. In fact, I know of a company that recently moved off CVS! Sharing…

How to Work Remotely as a Software Developer

Working from home gives you the freedom to get a lot done, away from the distractions of office life. On the other hand, it also gives the freedom to goof off all day! I've worked remotely with 8+ colleagues for over a year at Wave and with Nathan Bertram on ArrangeMySeat for even longer. Here's some of the knowledge I've gleaned from that experience. Workspace Working remotely gives you the…

How to set up a Jekyll blog on Heroku

Editors note from 2019 - this was written in 2013. I'm sure Heroku has solved their problem by now. Feel free to read the rest of the article, though! While setting up this blog, I ran into an issue trying to deploy to Heroku successfully. The deploy would succeed, but then I would get the big 'Something went wrong' page from Heroku! What was going on? Better check out the logs: ERROR: YOUR SITE…

Using ColorBox with Dirty Forms

Recently, I was working on a form that had some sensitive data that the user was required to submit, but often the user would navigate away from the page without saving their work. To combat this, I turned to Dirty Forms ; a jQuery plugin to prevent users from losing unsumbmitted HTML form data. By default, it uses FaceBox . I however, was using ColorBox as my lightboxing library and needed a way…

Typhoeus talk at Winnipeg.rb User Group

Recently I did a talk at the December 2011 Winnipeg.rb User Group meeting. I've put up the slides on Prezi and the demo on Github. For those who weren't there, the talk was on Typhoeus (edit: new github repo location), an awesome library for running and processing HTTP requests in parallel.