I'm Neil Giarratana and this is my personal blog. It's purpose (as of Oct 9, 2012) is to share the things I wished I'd known (or been told) a long time ago...mostly about coaching youth hockey.
Oh, I'm also President of Lucidus Corporation and creator of Mylights™.
Follow me on Twitter, @neilsmind,
or learn more about me on LinkedIn
Docker, Rails, Guard and freaking us-ascii encoding errors
I’ve been running into an intermittent issue when running tests in Docker for Mac using guard and minitest similar to the following:
ERROR["test_0001_should show blog", #<Class:0x0055ee8b101e48>, 42.78249460499501] test_0001_should show blog#BlogsController::on GET to :show (42.79s) ActionView::Template::Error: ActionView::Template::Error: "\xE6" on US-ASCII
I've rectified it in the past based on going through the files and ensuring there are no special characters but now ran into a place where I simply couldn't find the offending characters...so, it was time to roll up sleeves and figure this out.
The problem is that my Dockerfile inherits from ruby:2.3 and, as such, it does not have the locale set when used on Docker for Mac
The explanation can be found here:
Encoding
By default, Ruby inherits the locale of the environment in which it is run. For most users running Ruby on their desktop systems, that means it's likely using some variation of *.UTF-8 (en_US.UTF-8, etc). In Docker however, the default locale is C, which can have unexpected results. If your application needs to interact with UTF-8, it is recommended that you explicitly adjust the locale of your image/container via -e LANG=C.UTF-8 or ENV LANG C.UTF-8.
The solution is to explicitly set the LANG environment variable in your Dockerfile:
ENV LANG C.UTF-8
You can find the implementation of this in my docker-ruby-app repository Dockerfile
Thanks to Jared Markell for his article helping me figure this out
So you want to convert your database from MySQL to Postgres?
Working on a fairly large conversion project, the database switch was fairly critical for us. My requirement was pretty simple...I want to copy a database from one platform (MySQL) to another (Postgres) without having to learn every intricacy of each platform. My best world was if it could be something like the copy command:
copy source-file-path destination-file-path
We checked out Mysql2Postgres, yaml_db, and others. After much gnashing of teeth, we discovered Sequel.
Following is the entirety of what I needed to type to convert a MySQL database with more than 1,000,000 records to Postgres in under 15 minutes:
How to Stream Events Live on YouTube (using nothing but an iPad)
Over the past year, I've been broadcasting youth hockey games live through YouTube using nothing but a tripod and an ipad (with tripod mount). The process was not exceptionally simple to set up but it's effective and lightweight. Note that there is an iPad app that costs $20 / month to stream videos longer than 30 minutes so there is a cost. It's been well worth it.
Here's how I did it:
Step 1: Configure Youtube Account
Go to YouTube.com
Click "Sign In"
Either log into a Google account or click "Create Account"
Once logged in, click the profile icon in the upper right of the screen, then click "Creator Studio"
You'll arrive at a Dashboard screen for Creator Studio.
Click to open "Video Manager" and then click "Live Events"
If this is your first time doing a Live Event, you'll need to click to enable Live Events. (There's a big blue button in the center of the screen).
The YouTube system may go through a verification process using either a voice phone call or text message. Complete it and you're ready for step 2.
Step 2: Add an Event
From the Live Events page, click "Create live event."
Enter the title, the date and time of the event. I usually change "Public" to "Unlisted" for the video because we embed the games in Mylights (http://mylights.io) so the moments that matter can be tagged and shared. Make sure to change Type from "Quick" to "Custom." Then click to save.
Next, we'll configure the Ingestion Settings. You'll automatically be placed on that screen once you initially save to create the event.
Select "Custom Ingestion" under "Choose maximum sustained bitrate of your encoder"
Then, select "Create new stream" from the "Select a stream" drop-down. We're going to create a saved stream for your iPhone or iPad.
On the pop-up "Create new stream" screen, enter a name for the stream, e.g. "My iPad" and select a Maximum sustained bitrate of "500 Kbps - 2000 Kbps (480p)" from the drop-down. Save changes.
Now select "Other encoders" from the "Select your encoder" drop-down list. The system will provide settings for your encoder (the iPad/iPhone). I would recommend printing this page so you have something to reference when we configure the iPad app.
Save changes and we're ready for Step 3.
Step 3: Install and Configure iOS App
I've tried a number of apps for streaming live including the ones like UStream (um, if you're going to insert a commercial into my broadcast, at least have the decency to pause the video so viewers don't miss anything), LiveStream, etc. They all require their proprietary video hosting service which seemed to run into trouble. The app I've used with success is Studio Switcher Basic. Here's how to install and configure it for broadcasting in YouTube.
Obviously, install the app. Once you have it installed, open it. In the bottom right corner, there are five buttons. Tap on the one that looks like a satellite dish.
Under Live Broadcasting Service (CDN), tap "RTMP" to select it and then tap the "i" button.
Tap the plus (+) sign on the right.
From the RTMP Parameters window, enter the following information:
Channel Name: (Whatever you want, e.g. "My YouTube Channel")
Server URL: (That's on the page we printed in the previous step as "Primary Server URL", e.g. rtmp://a.rtmp.youtube.com/live2
Stream: (That's also on the page we printed as "Stream Name")
Video Format: 960 x 540
Video Bitrate: 700 kbps (This one turned out to be important)
Audio Format: Default value
Audio Bitrate: Default value
Tap "OK"
Make sure the channel you created is now selected. (It should be by default). We're ready to broadcast.
One note...once you do a test broadcast and you're happy with the approach, you'll definitely want to "Upgrade" within the app which will allow you to broadcast more than 30 minutes. It's just an iTunes subscription transaction which is very simple through the app.
Step 4: Broadcast!
If you're not already there, go to your Live Events page from "Creator Studio" in YouTube. Click "Live Control Room" for your Live Event.
The system will have a big red bar across the top of the screen saying that it's not receiving anything. No kidding, we haven't told the encoder (iPad app) to start broadcasting.
Back to your iPad, open the ... app. Assuming our settings are in place from our configuration time, tap the Record + Broadcast button in the upper right of the screen. Then wait...it will take a up to a minute for the broadcast to show up in your Live Control Room screen.
When it does, going live is a two step process. First, you'll "Preview" (required by YouTube) and then you'll "Start Streaming." When data is received from the encoder, the "Preview" button will be enabled in the Live Control Room screen.
Click Preview and confirm. Then wait 30-60 seconds for the "Start Streaming" button to be enabled. Also note that the stream status is "GOOD". Once the "Start Streaming" button is enabled, click it and confirm. You're now live!
When you're done broadcasting, tap the Rec + Broadcast button to turn it off. Wait a full 60 seconds and then click "Stop Streaming" from YouTube on the computer. The broadcast is 30-60 seconds behind what you're seeing on your iPad so if you click too early, people will miss the final bit.
Couple of Additional Notes
The broadcast can go from GOOD to OK to NO DATA depending on the consistency of the Internet connection.
I've found that the most consistent broadcast Internet is actually through my cellular data when it gets an LTE data connection. Wireless networks in rinks are just not great for the most part. (Kettler Capitals Iceplex is an exception but it has better amenities than most rinks in North America).
Occassionally the iPad App will either lock up or crash. Don't panic...double-tap the home button, close the app. Then open it again and tap "Rec + Broadcast" - the broadcast will pick back up
The audio is actually pretty good coming out of the iPad. Don't assume you have to use a microphone or headset. I broadcast for most of the past year just talking into the ipad as I moved the camera. (Some would argue the audio was better than with a headset).
Here's a link to the tripod mount I've used for my iPad Mini
How emacs ruined me for Atom, TextMate, Sublime Text 2 (and every other GUI based tool)
I'll start by saying I still consider myself an Emacs newb. These days I spend the majority of my day coding and loving every minute of it. For reference purposes, I span across Ruby, PHP and Javascript (angular, etc.) for my projects. I'm also a bit of a text editor junkie who has tried just about everything I can find including:
Sublime Text 2
Atom
TextMate
Coda
Eclipse (including various flavors)
Brackets
They all had various things to like about them (Sublime was super fast, TextMate has a great plug-in environment, Coda was the best for linking to external server directories and Atom is just really cool in theory) but they all led me to some frustration, often for their own, individual reasons.
Meanwhile, Ryan McGeary was in the next office for the past year working with Emacs, telling me I should give it a try. I tried...and quit, slows me down to learn. Tried again...and quit, slows me down. Finally, third time was the charm and now I simply can't go back to the other editors.
Why? Is it the unbelievable number of features? No. Is it the programmable customizations? Nope. Is it that it can be run from a terminal? If anything, that was a negative, at first, for me...so Nope.
The reason I can't go back is the key sequences for editing...With a little help from Ryan, I re-mapped my Caps Lock key (because programming doesn't really use Caps Lock) and I learned that the same key sequences work on Mac's in general but not in most editors without a plug-in. How about some examples:
Go to the beginning of line:
Emacs: Ctrl-A
Everyone Else: Command-Left Arrow
Sounds silly to worry about the difference right? Try going to the beginning of the line without lifting your hands. Can't do it with Command-Left Arrow.
Go to the end of line:
Emacs: Ctrl-E (for end)
Everyone Else: Command-Right Arrow
Same issue...so much quicker to Ctrl-E than move to the right arrow.
Go to the next line:
Emacs: Ctrl-N (for next)
Everyone Else: Down Arrow
Go to the next character:
Emacs: Ctrl-F (for forward)
Everyone Else: Right Arrow
Go to the previous character:
Emacs: Ctrl-B (for backward)
Everyone Else: Left Arrow
Highlight Text:
Emacs: Ctrl-Spacebar (starts the marking area), use cursor keys mentioned and everything in between is highlighted
Everyone Else: Shift-Arrow-Keys
If every time you just need to move the cursor you have to pick up your hand and find the arrow keys, that adds up. Muscle memory makes it now that I fly through those sequences and use them everywhere I can on the Mac.
Now, on my first day using Emacs, I didn't even know how to open a file. So two sequences became my new best friend:
Ctrl-X, then Ctrl-F: Open a file anywhere on the file system (and it turns out on other servers as well.
Ctrl-C, then P, then P: The P is for "Projectile", the plug-in that automatically turns an folder with a .git folder into a project. It allows me to determine a project on my file system, then choose a file within it.
After that it's just Ctrl-C P F to open another project file without having to specify a directory or project. It just assumes I want a file in the same project.
How about all of the files I have open in that project? Ctrl-C P B (for buffer), start typing the file name (or any sequenced letters) and the fuzzy search shows you the matches automatically.
For me, a truly great tool allows you be productive pretty quickly in the shallow end of the pool. Then, you can keep wading into deeper and deeper functionality as your comfort grows. Admittedly, Emacs' shallow end is about five feet deep but once you get in, it's like swimming with fins...Way faster, way more efficient and way more fun.
I tried going back to Atom just because a GUI still occasionally calls to me. What I discovered is that I really don't need clickable icons anymore...my keys never leave the home row...
“The Sounds of Silence”: Why Adults Should Listen to What Players Do Not Say By Doug Abrams A few years ago, my 9-10-year-old squirt hockey team held a practice three days before we played in the state championship tournament’s final game. By rotating games all season, our two goalies had helped keep us in …
These days, there is more and more coverage of the dangers of football, including reports of suicide in former pro stars and of brain damage from repeated blows to the head. For parents of children who want to play football, this can be confusing and frightening information to sift through.
Attending Queen Creek High School was a daily ordeal for 16-year-old sophomore Chy Johnson, who faced unrelenting taunts from bullies. Until the high school football team stepped in to help.
Nominations are open October 1-December 31, 2014 for PCA's Double-Goal Coach Award, given to 25 youth and high school sports coaches from throughout the U.S. who embody the ideals of the Double-Goal Coach, striving to win, while also pursuing the more important goal of teaching life lessons through sports.
As many helpful blog posts are, this one is offered in the hope that I save an afternoon for someone else. I'm leveraging Rails with Paperclip to upload files to an S3 repository. S3 is a cloud-based file storage system offered by Amazon (yes, that Amazon). It divides the storage into "buckets" which are like having separate drives. I was able to follow a number of tutorials including this one and this one which were extremely helpful in initial setup.
The key for me was the IAM capability in Amazon Web Services which allows me to create a unique user that has just the permissions needed for my app. Think of it like creating a MySQL user account instead of using root when building an app. Creating the user was easy. Setting a policy was pretty easy as well.
My issue was that I kept getting AccessDenied when I tried to upload. The simple answer would be "wrong login info" for most people and I thought of that. The reason that it wasn't that simple was that I used Transmit to login and transfer files using my new IAM account so I was positive that the permissions were right and that the login credentials worked. hmm...
I could also upload from my app if I specified my global (think "root") login so I knew that Paperclip was pretty much configured right. Spent three hours searching along with a couple of walks around the building to clear my head before I finally found the problem.
Turns out that Transmit defaults to https for connections to S3 but Paperclip's S3 connection defaults to http (and permissions of "public_read"). I changed the default permission to "private" and voila! https enabled and uploads go through.
I really like the articles in this site. A number of articles about hockey are included but the real power is in the articles about being a better sports parents, coach, etc. Good stuff re: nutrition as well. What I truly like about the site is that it's largely positive in nature.
So I was speaking yesterday with a parent considering bringing her child to the program where I'm coaching. We had a great chat about her son, the mechanics of how our program works, etc. At the end of the call, she said she had one more question (and seemed to have some trepidation asking)..."Is it true that you have a 4 second rule?"
I had a smile from ear to ear.
I proceeded to give her a bit of background of what that meant and why we used it. When I came to help the team in November of this past season, they (like many/most PeeWee hockey teams) didn't pass enough. It's easy to chalk that kind of thing up to kids being selfish and certainly there can be some of that. In my experience, passing typically just hasn't been something ingrained in their young hockey minds.
Most of our kids were the best player on every team they ever played. When they were younger, everyone in the arena adored as they skated through the lesser skilled players and put the biscuit in the basket. As they grew older and they moved up to AAA, they followed the same patterns they followed as the superstar previously. The problem is that they couldn't skate through everyone anymore. Their adoration became a bit of resentment. Take an entire team of those kids and you have most AAA hockey teams at the PeeWee age level and we were no different.
In order to break that pattern, we began by playing a game with a soccer ball that is a cross between team handball and frisbee football. We call it Tiger Ball. The kids are divided into two teams; one zone of the ice is set up as the "field" with end zones marked off by cones on each side. One player begins with the ball and he must stand still. He passes to a teammate to progress up the field. The receiver must stop when he catches the ball and he becomes the next "Quarterback." If the ball hits the ice, the other team takes possession at that spot. Primarily, the game is for teaching the concept of "close support" such that long passes don't tend to work and players getting open is paramount.
In the case of this team, we started with just normal rules. After a bit, we added a "2 second rule" where the receiving player had to move the ball to the next teammate within two seconds. (Four seconds is actually a lifetime in a fast moving game like hockey). This forced the players to not only get open but, more importantly, actively identify options before they received the pass. Otherwise, there's no way they complete a pass in time and the ball turns over to the other team at that spot. Tempo picks up, kids start thinking, their vision of the ice moves from five feet around them to the entire ice...it's a beautiful thing.
When the game ends, we bring 'em in and talk about what works and doesn't work in that scenario. We then talk about how that works in hockey. "Know your options", "Support the puck carrier", etc.
Now we move the concept to a small area game with a puck cross ice. For the latter half of the season, we began using the "2 second rule" for all of our scrimmage games. What happened from there? Goal production increased and, just as importantly, multiple assist goals increased. They really started to get it in the last part of the season and the team demonstrated they could play with anyone and move the puck at the same time.
Bottom line behind the rule is that sometimes artificial constraints can and should used to guide young players to make good choices and change their way of thinking. Loved the question and I'm glad word is getting out that things are changing at WLC.