Double Shot #1885
- smith - Command line utility from Oracle designed to build containers with only a single process & its dependencies, reading and writing from standard locations.
- Announcing Graylog v2.3.0-rc.1 - Notably with Elasticsearch 5 compatibility.
- Syntax. - New podcast from Wes Bos and Scott Tolinski, kicking off with an episode about React tools.
- Exclude Some Stylesheets in Rails 4 - Rails helpfully provides different stylesheets for different controllers - and then insists on concatenating them all together. Here are some thoughts on a more modular setup.
- Redux isn't slow, you're just doing it wrong - An optimization guide - Some fairly detailed guidance, much of it revolving around how to avoid unnecessary rendering.
- GitNotifier - Get email notifications when someone stars or forks one of your repos on GitHub, or when they follow or unfollow you.
- Bitcoin, Ethereum, Blockchain, Tokens, ICOs: Why should anyone care? - Despite the title, this is actually a clear explanation of a lot of the basic cryptocurrency concepts and ideas floating around. It is not however in the least skeptical about them.
- Ship - Native macOS client for GitHub, focused on code review and issue tracking.
- Ruby on Rails Code Audits: 8 Steps to Review Your App - Quick ways to judge the quality of a codebase that you just stepped in. I'd add that you should look at routes.rb early on; if the routing is craptacular the rest of the app won't be any better.
- Wildcard Certificates Coming January 2018 - From Let's Encrypt, that is. Free of charge from one of their automated endpoints.
Double Shot #1884
- Why Serverless? - An introduction to the idea behind things like OpenWhisk, Amazon Lambda, and Google Cloud Functions. I need to dig in a bit here.
- ES2017's async/await is the best thing to ever happen to JavaScript - There are days when I feel like I'll never catch up with innovation in JavaScript. Here's the latest way to handle async code.
- Elvish - Another option for a shell on Linux, macOS, or BSD. It features nicer control structures and pipelines that can handle more than plain text.
- Project Guidelines - For JavaScript projects, from Hive. I'm not always happy with formal guidelines, but I welcome thinking about the tradeoffs. Lots of good stuff here.
- Running feature specs with Capybara and Chrome Headless - How to set up the latest refinements in Rails system tests.
- Suicide Linux - The distro equivalent of "do you feel lucky, punk?" Now available as a Docker image.
-
The future of querying json in PostgreSQL - Looks yummy, though certainly not the SQL I learned lo these many years ago.
SELECT * FROM my_table WHERE JSON_EXISTS(ranges, '$[*] ? (@.min < $x && $x <= @.max)' PASSING number AS x);
- Announcing Gatsby 1.0.0 - A major milestone for this React-based static site generator. Lots of spiffy advanced features are built in, too.
Double Shot #1883
- Three little tools: mmsum, mmwatch, mmhistogram - Some open-source scripts from Cloudflare. mmwatch in particular looks useful for keeping an eye on the output of other tools.
- 5 Useful CircleCI Features You Should Know About - I thought I knew this tool pretty well, but a couple of these were new to me.
- Password Generator Tool - Implemented in client-side JavaScript and with a variety of options. Always nice to have one of these handy.
- Giving the iPad a full-time job - Interesting take on how you can use an iPad Pro as a decent productivity & coding machine -- and also on how this can be a good thing to get rid of the constant distractions of a more "capable" machine.
- ICOs: Magic Beans and Bubble Machines - Maybe I'm just an old fuddy-duddy, but I think you have to be ten kinds of stupid to put real money into any of this cryptocurrency crap. PT Barnum is laughing in his grave.
- 7 React libraries you should know - More precisely, 7 sets of components and building blocks you can use to quickly put together UI.
- Webcal Links in Rails with the icalendar Gem - Just exactly what I needed to implement this morning. Thanks.
- There are no rules in ruby - Well, there are, but you can use metaprogramming to get rid of all of them if you want to.
Introduction to Active Storage
Today DHH announced Active Storage: a new gem that makes it easy to attach Amazon S3 or Google Cloud Storage files to Active Record model instances. Looks like this is slated to become part of Rails in 5.2. I happen to have a Rails 5.2 application with a user model around, so here's a quick look at adding an avatar to that model with Active Storage.
NOTE: This is early days for this library, so don't count on this post to be perfectly accurate if you're reading it months from now.
1. Add the gem to your Gemfile and run bundle install
gem 'activestorage', github: 'rails/activestorage'
2. Add require "active_storage"
to config/application.rb.
3. Run rails activestorage:install
. This will create the storage and tmp/storage directories in your application, copy a default configuration file to config/storage_services.yml, and create a new migration. The migration will build the active_storage_blobs and active_storage_attachments tables in your database.
4. Run rails db:migrate
NOTE: I had to change the class name in the migration from ActiveStorage::CreateTables
to ActiveStorageCreateTables
to get it to run without errors.
5. Add config.active_storage.service = :local
to your development.rb file. This will use the preconfigured local-file storage when you're in the development environment.
6. Tell your User model that it has an attached file:
class User < ApplicationRecord has_one_attached :avatar ... end
7. Make a copy of your config/storage_services.yml file to config/storage_services_backup.yml. Then delete the amazon, google, and mirror sections from the original file. Otherwise, your server won't start, because it will be looking for keys and files that don't exist.
8. Add a field to your user edit form to input an avatar file:
<%= f.file_field :avatar, class: "form-control" %>
9. Add a control to your user show view to display the avatar:
<%= image_tag(@user.avatar.url) %>
10. Update your users controller to attach the file:
def update @user = User.find(params[:id]) avatar = params[:user][:avatar] if @user.update(user_params) if avatar @user.avatar.attach(avatar) end redirect_to @user, notice: "Your profile has been updated" else render 'edit' end end
11. Restart your application and navigate to /users/<id>edit
to edit an existing user. Select a file and save the change. You should see the avatar image displayed on the edited user.
Of course, in production you'll want to use an actual cloud service. If you check your backed-up configuration file you'll see how to set up the keys for either S3 or AWS. Then it should just be a matter of setting the appropriate configuration in production.rb (note that I haven't tried this yet!)
Introduction to Active Storage, Part 4: Mirroring
If you've been following along:
Then you're ready for one of the cool features of Active Storage: mirroring. This one is really easy to set up:
1. Ensure that you have created amazon
, local
, and google
sections in your storage_services.yml file, and that you have tested both of them.
2. Update your storage_services.yml file with a configuration stanza for mirroring:
mirror: service: Mirror services: [ amazon, local, google ]
3. Edit your production.rb file:
config.active_storage.service = :mirror
4. Deploy the application. You should still be able to add user avatars.
What does mirroring do? It gives you built-in redundancy against cloud service failures. In the case of the configuration above:
- Files are uploaded to Amazon and Google, and stored locally.
- Files are served from Amazon (the first member of the services array)
Should AWS go down for an entire region, you'd only need to change the services array in your config file, restart your server, and you'd be up and running again.
BUT: Note the "should" in step 4. As I write this, this doesn't actually work with the code in the Active Storage repo, because the MirrorService doesn't get configured properly. See issue 9, which includes a quick and hacky patch for the Active Storage internals to get things working.
Introduction to Active Storage Part 3: Google Cloud Storage
And to complete the trifecta, here's how you can update the Active Storage code to use Google Cloud Storage:
1. Sign in to your Google Cloud Platform account and go to your console (the URL will be something like https://console.cloud.google.com/home/dashboard).
2. You need to create a new project, and then a storage bucket inside of the project. Record the names for both so you can add them to your storage_services.yml file.
3. You'll need to use GCS's API Manager to create credentials for your new bucket. Create a set of credentials that use the Google Cloud Datastore API. Download your credentials as JSON and store a copy of the file in your project at config/gcs.json.
NOTE: Obviously, you need to keep the keys in this file confidential. Don't check them into a public repository, for example. Manage it the same way you manage your database.yml or other files containing confidential information.
4. Update your storage_services.yml file with a configuration stanza for Google:
google: service: GCS project: gstroop-****** keyfile: bucket: ****-*******-9999
5. Add a line to your production.rb file:
config.active_storage.service = :google
6. Add the google-cloud-storage
gem to your Gemfile and run bundle install
.
7. Deploy the application. You should now be able to add user avatars and have then stored in the GCS bucket that you configured.
Introduction to Active Storage Part 2: Amazon S3
Moving along, here's how to move your Active Storage files over to Amazon S3:
1. Sign in to your AWS account and go to your S3 management console (the URL will be something like https://console.aws.amazon.com/s3/home?region=us-west-2# depending on your region).
2. Create a new bucket (for this tutorial, I'll use gstroop-production
). Grant public read access to the bucket.
3. Retrieve the Access Key ID and Secret Access Key for your AWS account. Better yet, create a new pair just for this application.
4. Update your storage_services.yml file with a configuration stanza for Amazon:
amazon: service: S3 access_key_id: AKIA************ secret_access_key: ********************************************* region: us-west-2 bucket: gstroop-production
NOTE: Obviously, you need to keep those keys confidential. Don't check them into a public repository, for example. You can use the Rails secrets file to store them, or whatever other mechanism you prefer for production secrets.
5. Add a line to your production.rb file:
config.active_storage.service = :amazon
6. Add the aws-sdk
gem to your Gemfile and run bundle install
.
7. Deploy the application. You should now be able to add user avatars and have then stored in the S3 bucket that you configured.
Double Shot #1882
- Turbocharge your React development with Storybook and Percy - Storybook for component development in isolation and Percy for UI testing are two of the (too-long) list of things that I need to fig into.
- Rails5 Spec Converter - Tool to automatically update your controller tests so as to avoid Rails 5 deprecation warnings.
- Open Sourcing Iris and Oncall - LinkedIn has released its alerting and oncall systems as open source software.
- Percy - "Continuous visual reviews for web apps." See which pixels change build to build. Integrates very easily with Rails/Capybara.
- Under the hood: ReactJS - A scary-deep dive into the internals of React.
- Forest - Admin UIs as a service, with all sorts of integrations and fancy widgets. Interesting concept.
- If Silicon Valley Wants to Be Decent, It Should Give up NDAs - And also nondisparagement agreements, which I've tangled with personally. If you're so worried that ex-employees will say truthful bad things about you, maybe you should change your behavior?
Double Shot #1881
- Random Ruby - Another collection of Ruby, Rails, and related links. This one comes as a newsletter than you can subscribe to.
- Busy to Death - A reminder that being busy does not mean being productive. Or doing important work.
- Introducing Dexter, the Automatic Indexer for Postgres - Nice approach: log actual queries, test out hypothetical indexes, report back in which ones would have actually helped, and optionally implement them. Let the database do the work.
- Privacy Policy Generator - Enter your company name and site address and get a simple set of reasonable terms to use as a starting point.
- Terraform Gotchas And How We Work Around Them - Some practical advice from the Heap engineering team. Complex tools are complex to learn.
- Awesome Machine Learning with Ruby and Awesome NLP with Ruby - A pair of curated lists of resources, tutorials, libraries and so on for Rubyists in the AI space.
Double Shot #1880
- React Native Architecture, Explained - The amount of magic baked in here is just amazing. Answers little questions like "where is the code running, anyhow?"
- Pretender - Easy user impersonation in Rails, courtesy of Instacart.
- Play With Docker - Four hours to mess around with Docker instances and architectures in a free sandbox. Or check out the setups in the Play With Docker Classroom.
- Five Reasons Why You Should Hire and Old Programmer - Experience does in fact count for something.
Double Shot #1879
- Cheat to Win: Learn React with Copyworkå - Copying someone else's site is a good way to improve your skills, and not just in React.
- How to Stay Calm Under Pressure, according to a Weapons Disposal Leader - Hopefully you're under less pressure than the real heroes in your cushy software job. Even so, there's some good advice here for times when you're faced with a tough problem and an impossible deadline.
- How do you cut a monolith in half? - If you're about to embark on your first voyage into distributed systems, this essay will give you about a zillion new problems to think about. Have fun.
Double Shot #1878
- An Overview of the Logging Ecosystem in 2017 - Really good centralized logging is something I've always wanted and never convinced management to pay for. A personal failing I'm sure.
- Serverspec - "RSpec tests for your servers configured by CFEngine, Puppet, Ansible, Itamae or anything else." A nice addition to the devops arsenal. Though of course configuration tools work perfectly every time, right?
- MongoDB Indexing, Monitoring & Backup - A look at some of the supporting bits of the MongoDB story.
Double Shot #1877
- RailsCasts Pro Episodes are now free! - They're a few years old now, but there's still good content to be found here.
- Open Source Friday - GitHub declares that every Friday should be set aside for open source work. No sillier than stuff like National Pickle Day, I suppose.
- Container isolation gone wrong - Another example of "all abstractions are leaky" in action.
Double Shot #1876
- Is group chat making you sweat? - Jason Fried reflects on a decade of experience with Campfire. And yes, I've seen group chats grind a group down to nothing.
- Faster Rails: Indexing Large Database Tables Without Downtime - A good reminder that migrations can be improved if you use database-specific features.
- Rails 4.2.9 has been released and Rails 5.1.2 has been released - A couple of small updates, including the last of the 4.2 series. Have you started upgrading yet?
Double Shot #1875
- Caffeine: Livecode the Web - Smalltalk style development tools integrated into the web browser.
- Server-side Rendering - How to build a React page on the server before sending it out to the browser, a technique that may be useful for SEO.
- The bad reasons you're forced to work long hours - We all say we should work smarter rather than harder, but does anyone actually do it? Some patterns to watch out for when you're job-hunting.
Double Shot #1874
- decaffeinate - A tool to convert CoffeeScript to modern JavaScript, now that JS has what CS brought to the table.
- Introducing Object Storage - Looks like Digital Ocean is getting ready to compete with Amazon S3.
Double Shot #1873
- Gatsby's first beta release - A static site generator for React.js. Comes with lots of plugins available and mobile support.
- Monitoring Build Times: Maintaining our fast Feedback Loop - "It feels like no development team is ever happy with their build time" - So true. Techniques from the team behind The Conversation.
- Some things you should know before using Amazon’s Elasticsearch Service on AWS - Primarily that you have no low-level or even API access, so you're dependent on AWS customer service when things go wrong.
Double Shot #1872
- Share Your Experiences with Imposter Syndrome - Blog post with a growing comment thread. Your chance to contribute to a conference talk on the subject (or just discover again that we're ALL imposters).
- Catfish Programmers - A reflection on the skills and work of those who have to clean up the mess after the rockstars and ninjas move on. Been there, done that.
- Skinny Models, Skinny Controllers, Fat Services - The code has to go SOMEWHERE, people! No doubt in a few years we'll get some alternative that lets us have skinny services.
Double Shot #1871
I'm at Girl Scout camp for the next two weeks. However, that doesn't mean I'm completely unavailable -- and I'm still job-hunting. So please, if you have work for a flexible Rails developer & team lead, do drop me an email at MikeG1 [at] larkfarm.com. There are plenty of times I can talk even from camp.
- Refactoring Rails - A video course coming from Ben Orenstein. Sign up for news & a discount on the product when it comes out.
- Debugging Design - And speaking of coming ebooks, here's one that promises to teach developers a design process they can understand. I just blew an interview over this very topic.
- Reduce your javascript bundle size by 77% - Wiring up compressors into your web pack build pipeline to pre-create the compressed version before uploading.
- DevDocs - Searchable API documentation in the browser. It covers a whole raft of things from CSS and HTML to jQuery, Jasmine, Lua, Meteor, and on and on. You can pick and choose the collections you're interested in.
Double Shot #1870
- The future of Ruby Toolbox - The server hosting this vital site crashed last week. The data is back online, but so is this discussion of what to do next. A good chance for the right people to help the community, I think.
- Rails 4.2.9.rc1 has been released! - This is planned to be the last bug fix release of 4.2. If you're not already moving on a migration to Rails 5, you'd best get started.
- The search for the Goldilocks browser and why Firefox may be “just right” for you - A look at some of the Firefox architecture, including how it does multi-process a bit differently than Chrome does.
- Rails Helper Testing Made Simple - A few useful techniques here. Also a step back to a broader look at which helpers are worth testing and how to apply some discipline.
- Daisy - a private blockchain where blocks are SQLite databases - It's hard for me to take this as anything other than "software as parody". I suspect it's serious though.
subscribe via RSS