TIL How to Select Merge with Ecto.Query

Published Monday, August 19, 2019

Here’s the scenario: you’re working with Elixir and Ecto, and you need to retrieve data from a table plus maybe a field or two from an unassociated table. In the past, whenever I ran into this, I’d spin up something I wasn’t totally satisfied with - maybe updating the schema(s), breaking it up into multiple queries, or building a multi-select statement if I was feeling fancy.

Happily, today I learned there’s a better way. You can accomplish the same end result in a single query expression with Ecto.Query#select_merge/3.

Let’s run through an example to see it in action.

Setup

Say...

Read More →

Modern Monitoring and Observability with Thoughtful Chaos Experiments by Datadog and Gremlin (webinar)

Published Wednesday, June 12, 2019

Presenters:

  • Ana Medina
    • Chaos engineer @ Gremlin (“Chaos engineering as a service”)
    • @ana_m_medina
  • Jason Yee
    • Senior tech evangelist @ Datadog
    • @gitbisect

Three Types of Data

1. Work metrics (Business)

  • Throughput
  • Success
  • Performance
    • Latency
    • Perceived performance

2. Resource Metrics (Services)

  • Utilization
  • Saturation
  • Availability

3. Events

Things that influence how our system(s) behave

  • Code changes
  • Scaling events
  • CHAOS

Monitoring Tools

1. Logs

  • Information about an event
  • Snapshot, but not aggregate

2. Metrics

  • Context around an...
Read More →

AWS Immersion Day

Published Wednesday, June 05, 2019

Serverless Transformation

AWS Serverless Foundations (Deep dive into Lambda and API Gateway)

Presenters:

  • Pranusha Manchala
  • Ramesh Jetty

Why serverless? Spend more time on your app, not maintaining servers.

“No server is easier to manage than no server” #nocode

How does it work?

Event source => Function => Services

Common use cases

  1. Web apps
    • static websites
    • complex apps
    • packages for Flask, Express
  2. Backends
    • mobile
    • IoT
    • apps
    • services
  3. Data processing
    • real time
    • MapReduce
    • Batch
  4. Chatbots
  5. AWS Alexa
  6. Autonomous IT
    • policy engines
    • extending AWS services
    • infrastructure...
Read More →

Code Reading - How Write To Project Specs

Published Thursday, January 03, 2019

Learnings from @bobjnadler’s time at Siemens & Cyrus.

  • Helpful to have templates
  • Remember: questions > formatting

What is a spec?

Q: Technical spec? User stories? Diagrams?

A: Combination of several pieces of information, only some of which is technical.

Parts

Charter

  • Overview
  • Biz case
  • Goals
  • Requirements
  • Assumptions
  • Resources
  • Constraints
  • Risks
  • Decision makers: stakeholders, sponsor(s), manager(s)

Useful as an engagement offer, aka proposal for client

Project matrix:

  • Drivers for decision making
  • Cost vs. release date vs. feature set
Guiding Questions
  • What is the problem we’re trying to solve?
  • Who is...
Read More →

Living with Legacy Javascript - Event Proxies, App Seams, and Chunking Rewrites

Published Thursday, August 09, 2018

Sneak peek of @talum’s upcoming talk at EmpireJS 2018.

Legacy Code

Learn.co is a really big platform. So many features.

But “old code” isn’t necessarily “legacy code”.

What is legacy code? Some definitions:

Code that’s “no longer in use” (check stackoverflow)

Code we’ve gotten from someone else [Ed. note: But isn’t that almost all our code? Not everyone on our team was here when core features were written.]

Code without tests

Our definition for this talk:

Velocity by CodeClimate

Published Thursday, July 26, 2018

Guest speakers: Noah Davis and Fred Creech from Code Climate

Intro

Note: This product is changing rapidly.

Gives us insight into entire team or drill down into squads.

Primarily built for engineering managers.

What This Tool Is

  • Data viz that can inform team’s decisions, processes, etc.
  • Insights into trends, changes over time
  • Identify and monitor risks

What This Tool is Not

  • Stack ranking for engineers
  • Laws for good/bad practices

Product Tour

Note: All metrics are “tuneable”. Can be customized based on team processes/preferences.

Definitions

PR Throughput: Merged PRs

Code Cycle: Time...

Read More →

Code Reading - Learn ❤️ Domain Driven Design

Published Thursday, June 14, 2018

Challenge: introducing DDD in a legacy codebase

What is DDD?

Domain

“Sphere of knowledge…”

Model

Model domain in our software

Muggles

  • Informed by people who actually do the work (stakeholders)
  • Domain experts are key for bridging gap between domain and software

Goals

  • Better code
  • Better product
  • More happy

What is DDD in Learn?

  • It’s always kind of been there
  • DDD encompasses a lot of general best practices, some of which we’ve already been following (ex. ubiquitous language)

First attempts: LearnApps

  • Not true DDD
  • Doesn’t follow all...
Read More →

Code Reading - JWT

Published Thursday, April 26, 2018

A code reading by @spencer1248

JSON Web Tokens

Website: jwt.io (maintained by private company AuthO)

JWT Basics

Base64 endcoding

JWTs use base64 encoding.

Why?

  • Normalizes data into set of known characters
  • No collisions with heading encodings
  • Doesn’t break JSON parsers
  • Signature is binary
  • Take binary data and convert into this common character set

Base64 basics

  • 1 character, 64 different permutations
  • 6 bytes with 4 characters
  • When encrypting, keep in mind going from 6 bytes to 8 bytes increases size of data by 33%

Structure

Start with Base64 string

3 parts:

...
Read More →

JS Testing with Jest and React

Published Thursday, April 05, 2018

A code reading by @gj

Jest

  • New hotness for testing React
  • More or less a superset of Jasmine
  • Backed by Facebook
  • “Just works” out of the box
  • Started as a wrapper around JSDom, evolved into its own thing

Hopes and dreams: Jest makes test writing fun and easy => we write more tests

Helpful features

  1. Watch mode (--watch) - runs test on code changes (similar to guard on server-side)
  2. Coverage metrics (--coverage) - out of the box
  3. Notifications mode (--notify) - native OS notification when test...
Read More →

Ops Roadmap for Learn.co

Published Thursday, March 22, 2018

Outline

  1. Review current setup
  2. Share upcoming challenges/priorities
  3. Share roadmap + new concepts/tools

Priorities

  1. Ensure new collaborative ventures are successful
  2. Support our team as we grow (make ops more automated + manageable)

Requirements

  • Move to AWS for hosting
  • Need high amounts of infrastructure + environment automation and orchestration (Terraform)
  • Scaling
  • Security
  • Lower maintenance costs as our team grows

Current Setup

  • Hosted on Digital Ocean
  • Self-hosted services:
    • Postgres
    • Redis
    • Elastisearch
    • Memcached
    • Pushstream
  • Our virtual servers are on private network in DO region

Pain points

...
Read More →

Phil Sturgeon - A No-Nonsense GraphQL and REST Comparison

Published Thursday, March 15, 2018

Notes from Phil Sturgeon’s code talk at Flatiron School, 3/15/2018.

Slides available at philsturgeon.uk/speaking.

What is GraphQL?

GraphQL = FQL + (REST - Hypermedia)

A little FQLish, a little RESTish.

What is REST?

  • REST != CRUD API
  • REST == state machines over HTTP
  • Nice wrapper for models (keep logic in controller)
  • State machines can power Hypermedia controls (see below)

What is Hypermedia?

  • State machines over JSON
  • Misused
  • Misunderstood
  • Hypermedia links are not just for related data

More on HATEOS:

Level 1: string containing URL

  • no guarantee...
Read More →

Pattern Matching in Elixir

Published Wednesday, March 14, 2018

Pattern Matching Hearts Elixir

At the Flatiron School, our mission is to help people learn how to code. That means that as a member of the engineering team, my work reminds me almost every day of that important, universal truth: learning new stuff is hard.

Take learning to play a musical instrument, for example, like guitar. When you start, you have these lofty aspirations. You wanna be the next David Bowie. But when you’re first starting out, that dream is so, so far away. It takes a ton of hard work to...

Read More →

Code Talk - How the Test Lights Work on Learn.co

Published Thursday, March 08, 2018

aka The Little Submission That Could

by @talum

Submissions take a long, multi-step journey from learn-co gem to Learn.co.

Step 1: learn-co gem

Collection of open source gems (one parent gem with buncha child gems)

Focus for this talk is learn-test

  • figures out what kind of test strategy to use
  • runs tests
  • turns test results into JSON payload
  • show student human readable results (written to results.json)
  • sends payload to Ironbroker V2
    • user info
    • repo info
    • test success/failure info

Step 2: Ironbroker V2

Message broker...

Read More →

Code Talk - Refactoring Retriable Actions

Published Thursday, February 22, 2018

A Story About Asynchronous Actions, Dynamic Workers and Queues, and RabbitMQ

To standardize running asynchronous services, we’ve created a number of “Base” objects:

  • AsyncBaseService, just introduced (inherits from BaseService)
  • BaseWorker

Worker queues are managed by RabbitMQ.

Problem to solve:

  • Sometimes services fail and need to be retried
  • We need a reliable way to retry jobs, keep records of attempts, eventually fail after a specified number of attempts, and log error on max-out failure
  • To fulfill above, we built our own Retriable system, which has done more harm than good

New solution:

...
Read More →

Code Talk - Networking

Published Friday, November 03, 2017

Low level talk about how information moves across the internet.

Why? Because we’re moving to AWS and Scot wants to try teaching this.

Types of addresses:

IP address Mac address
Dynamic Static
Related to geolocation (network location associated with physical location) Hardwired to computer’s network card
Higher level (IP layer, layer 3) Lower level (ethernet, layer 2)
32bit, example: 10.10.2.2 48bit, usually represented in... Read More →

Code Reading - Learn ❤️ RabbitMQ - Part 1

Published Thursday, August 31, 2017

A code reading by @joshrowley, part 1.

Concepts

Fuzzy overview of stuff we’ve heard about RabbitMQ

  • Written in Erlang
  • Queues, Exchanges, Channels, Subscriptions
  • Publishers, Consumers
  • Connections
  • Fanouts
  • Self-healing
  • Distributed

Actual overview

  • Message broker originally built by JPMorgan Chase. Built 2004, released 2007.
  • Designed as a way to solve problems with integration points between many different bank systems. Needed standardized way of sending messages between apps.
  • Goals: reliability, guaranteed message delivery between apps, uptime
  • Solution: AMQP (protocol)

What is AMQP?

  • Runs on Erlang OTP
  • Queues where you persist messages
  • Consumers...
Read More →

Code Reading - Learn ❤️ Domain Driven Design

Published Thursday, August 10, 2017

Introducing DDD into Existing Codebase

Risky to experiment with existing “domains”. Better to experiment with something new.

Our test case: “Compliance” and “Notifications” domains

  • small
  • isolated
  • wouldn’t affect existing code

Test Case

Didn’t add any new has_many or other associations

Domains

Communicate with domain through top level domains/:domain modules (ex. domains/compliance.rb).

Gives us bounded context. Send messages to bounded contexts, not the subdomains directly. All requests should be funneled through top level module.

That said, we’re not being strict about this convention. You still can call models directly. We may change this...

Read More →

How My Bash Color Settings Broke edeliver

Published Wednesday, July 12, 2017

Yep, you read that right. My bash color settings broke edeliver, the tool my team uses to deploy our Elixir apps.

Now, anyone who’s tinkered with their .bash_profile knows there’s an infinite number of ways to totally bork your system. But this bug was well camouflaged, hiding inside a common, seemingly-benign bash setting I’d had in place for over two and a half years without issue - a bash setting you, too, might have on your machine RIGHT NOW 😱

But don’t worry, I tracked down the little bugger, so read on to save yourself the same...

Read More →

How to Run Ecto Migrations on Production

Published Thursday, July 06, 2017

You’d think the answer to this question would be a simple Google search away. Unfortunately, that wasn’t the case for me this afternoon, working on a Phoenix project with a newly-added Ecto backend. In an effort to save others (and let’s be honest, future me) the same frustration, here’s the most straight-forward solutions I found.

What Doesn’t Work

Mix. Mix tasks aren’t compiled into your deployed release, and as evidenced in this exciting discussion, there’s no plans to change this any time soon.

So don’t try using your trusty local mix ecto.migrate task on...

Read More →

How to Work with Developers

Published Wednesday, June 28, 2017

Software developers, have you ever felt misunderstood by your non-developer teammates? It happens to most of us, which is why I wrote this post to help clear up some of the most common misunderstandings, miscommunications, and missed opportunities. Feel free to pass it along to anyone who’d love to have an easier time working with developers.

Below, I’ll be sharing my (completely unbiased 😉) perspective on how to work with software developers. My goal is that after reading this article, every reader feels confident they can work effectively with their development team thanks to some proven tools and strategies we’ll...

Read More →

Code Reading - Learn ❤️ GraphQL

Published Thursday, June 22, 2017

What is GraphQL?

  • “Graph Query Language”
  • Alternative to REST pattern
  • Making your data queryable through a single endpoint

Why use GraphQL?

  • More declarative
  • More consumer focused
  • Simplified endpoints
  • Fewer requests
    • With REST, request count grows w/ more data you need
    • With GraphQL, only request as much data as you need => more efficient

In use in the wild

  • Github API
  • Shopify

Stuff to Think About

  • Due to HTML limitations, super long queries get sent via POST request
  • Mutations

Demo

  1. Spin...
Read More →

Code Reading - Learn ❤️ Docker

Published Thursday, June 15, 2017

Prereqs:

  • Watch this Youtube playlist (~90 min)
  • Clone down existing Rails app (in our case, the Learn codebase)
  • Set up account on Docker Hub

Intro

What is Docker?

  • Tool for managing and creating containers

Why use Docker?

  • Maintain a stable, consistent environment
  • Encapsulate all pices of an app
  • Uniformity and consistency
  • Step towards better deployments and auto-scaling infrastructure (Swarm, Kubernetes)
  • Lighter than a VM (no hypervisor)
  • One of the more mature tools available

Basics

Docker image:

  • Pre-packaged layer
  • Can stack layers on each other
  • Result...
Read More →

Code Reading - Capistrano

Published Thursday, April 20, 2017

A fascinating glimpse into Spencer’s server config process.

Impetus:

Contractor working on our marketing website CMS needs a staging environment to deploy changes to.

Context:

We set up a one-click droplet on Digital Ocean. But we use chef for server management, so we need to custom configure this setup.

Requirements:

  • Wordpress
  • MySQL
  • Varnish (service that sits in front of web applications like Wordpress, handles caching, kinda like nginx with caching)

What we did:

First step was looking at our existing chef cookbooks and seeing if there’s anything we can reuse. Turns out...

Read More →

Dev Ops Crash Course - Day Five

Published Friday, March 24, 2017

Notes from day one, day two, day three, and day four.

Chef Chat

What is Chef?

  • Scripts written in Ruby to provision a server.
  • Server setup
  • Infrastructure automation
  • Server configuration management

What’s important to manage?

  • Software versioning
  • Uniformity and consistency across machines
  • Reproducability
  • Idempotency

What problems are we solving?

  • Efficient setup
  • Preserves history
  • Prevents environment issues resulting from inconsistencies among envs

Alternatives to Chef?

How We’ve Structured Our Cookbooks

Rely on...

Read More →

Dev Ops Crash Course - Day Four

Published Thursday, March 23, 2017

Notes from day one, day two, day three, and day five.

Learn IDE

Load Balancers

Using haproxy for load balancers. Config lives in /usr/local/etc/haproxy

IDE config is using slightly different approach than Learn. Not using cookie. Instead using hashed token from user (as url param).

DNS

In general, SSL certificate needs to match what IP address the web request resolves to (resolves to DNS entry). DNS entry is for floating IP. So you can use the same certificate for multiple servers, depending on what server floating IP points to. That allows us...

Read More →

Dev Ops Crash Course - Day Three

Published Wednesday, March 22, 2017

Notes from day one, day two, day four, and day five.

Year in Review Review (continued)

Notifications

Nagios repo w/ full documentation: https://github.com/flatiron-labs/nagios

Nagios API that powers our Learn.co status page: https://github.com/zorkian/nagios-api

Status page lives on nagios01 server: root@nagios01:/usr/local/nagios/nagios-api. There’s a cron job that runs updates: crontab -l to view, crontab -e to edit.

Automated SSH Key Propagation

Cron job that runs every 30min that runs chef user_setup recipe on every host.

Every 30min too often? We should scale this back.

Automated Server Provisioning Tools

Script...

Read More →

Dev Ops Crash Course - Day Two

Published Tuesday, March 21, 2017

Notes from day one, day three, day four, and day five.

Year In Review Review

Q: What is DevOps?

A: When first created, more of a concept than a well-defined position. Even today, the term is still fairly broad, but in general refers to:

..a set of practices emphasizing the collaboration & communication of both software developers and operations professionals, while automating the process of software delivery and infrastructure changes.

Postgres Database Replication

  • Read-Only replica: all transactions are mirrored to 2nd server
  • Hot standby in case...
Read More →

Dev Ops Crash Course - Day One

Published Monday, March 20, 2017

Notes from day two, day three, day four, and day five.

Internet 101

Videos: https://www.khanacademy.org/computing/computer-science/internet-intro/internet-works-intro/v/the-internet-wires-cables-and-wifi

Some vocab:

  • Bandwidth: capacity to receive information
  • Bitrate: speed of sending information (bits per second)
  • Latency: drag / delay when sending information

Internet is a design philosophy expressed through agreed upon protocols:

  • IPv4 - current protocol (32bit)
  • IPv6 - new protocol to provide more IP addresses (128bit)

IP addresses have A, B, and C classes.

DNS

How DNS works: https://howdns.works/

In local network settings, DNS is set to Google Public DNS.

  • better performance
  • ...
Read More →

How Object-Oriented Design Saved Our CSS (and Site Performance)

Published Monday, February 20, 2017

Back in January 2016, our CSS was easily the messiest part of the Learn.co codebase… something that probably sounds familiar to many other web developers out there. Last spring, we budgeted time and resources to overhaul it. I led that project. Here’s what we learned.

Before diving in, let’s clarify what we’re talking about when we talk about object-oriented design. Object-oriented code is:

  • Modular: reusable
  • Encapsulated: self-contained with minimal dependencies
  • Maintainable: easy to work with, which is especially important for smaller dev teams like ours

Learn.co is built on a Rails backend, and Rails strongly encourages...

Read More →

Code Reading - Learn.co Shared React Form Library

Published Thursday, January 12, 2017

Presenter: Seiji

Problem

React is not an opionated library

  • too many options for building forms
  • we ended up with a bunch of different implementations / approaches

Forms are omnipresent in our app

  • lots of repeated code
  • need to DRY this up

Solution

  • Build out library to manage form state + validation + submission
  • Build reusable form component specific to our domain

Process

  • Reviewed all our current approaches
  • Melded into single, shareable component

Shared Component Library

Can be used for controlled + uncontrolled inputs

React and Redux Crash Course with Steven Nunez PART DEUX

Published Tuesday, December 20, 2016

Instructor

Steven Nunez, Lead Instructor/Developer at Flatiron School

Goals:

  1. Build on what we learned last week
  2. Set up some tests

Exercise: Hacking on Our Chat App

Last time: closed out talking about Middleware (Thunk, specifically). Today we’ll make some more progress towards a nice lil chat app.

We’ll start out with by building some functional components.

  1. create new files:
    • ./components/app
    • ./components/RoomList
    • ./components/RoomDetails
  2. render RoomList and RoomDetails from App
  3. render an unordered list of Rooms (aka channels) in RoomList
  4. RoomDetails will render an individual room:
    • messages...
Read More →

React and Redux Crash Course with Steven Nunez

Published Tuesday, December 13, 2016

Instructor

Steven Nunez, Lead Instructor/Developer at Flatiron School

Goals:

  1. Learn through doing
  2. Knowledge up on cool new tech

Why Redux?

  1. “Surprisingly simple” says Steven
  2. Very specific purpose
  3. Supes popular
  4. Lots of high quality curriculum available from Flatiron School
  5. They hired Dan Abramov

What is Redux?

  1. State Management

The end.

  • Has nothing to do with the web.
  • Has nothing to do with React.
  • Nice and simple.

Is it Flux?

Not really. Flux has a very specific set of parts: dispatcher, actions sent by dispatcher, etc....

Read More →

CSMess to OOCSS - Refactoring CSS With Object Oriented Design

Published Monday, October 17, 2016

Presented at Fullstack Toronto Conf. 2016

Slide deck

Text (no video available, unfortunately)

Back in January 2016, our CSS was easily the messiest part of the Learn.co codebase… something that probably sounds familiar to many other web developers out there. Last spring, we budgeted time and resources to overhaul it. I led that project. Here’s what we learned.

Before diving in, let’s clarify what we’re talking about when we talk about object-oriented design. Object-oriented code is:

  • Modular: reusable
  • Encapsulated: self-contained with minimal dependencies
  • Maintainable: easy to work...
Read More →

Flatchat Code Talk

Published Thursday, September 29, 2016

Flatchat is our in-house replacement for Slack, which we’ll be moving our users off soon.

Stats

  • maxing out at ~350-500 unique websockets
  • avg 200ms room load time

Check /pghero for db query diagnostics.

ssh into flatchat server for PM2 monitoring.

  • logs are rolled over every 7 days
  • pm2 monit for live resource usage
  • pm2 list for quick summary

Handling Message

  1. Validate inputs (flatchatter and room member)
  2. Check room policy
  3. Write message to db
  4. Add more stuff to message object (decorator?)
  5. Broadcast msg
    • to other users in room
    • to...
Read More →

Get Fuzzy with LEVENSHTEIN

Published Friday, September 16, 2016

Discovered a super handy Postgres extension tonight: fuzzystrmatch. This lil cutie is a real godsend when dealing with potentially crummy user input, such as, oh say, for a Rails project where you’re requiring your less-than-tech-savvy relatives and future inlaws to input their email address in order to access your wedding website. Note: said website is badass, built-from-scratch, and open source.

Here’s a visual:

Login Modal

Imagining that scenario, one might be concerned about poor conversion due to typos, misspellings, or any other of the myriad problems that plague “uncontrolled” user input. And...

Read More →

BASH Tips and Tricks

Published Thursday, September 01, 2016

All tips courtesy @devinburnette

Basics

$ w

see who else is on box

$ w 14:15 up 5 days, 19:23, 7 users, load averages: 1.47 1.56 1.82 USER TTY FROM LOGIN@ IDLE WHAT ktravers console - Mon11 3days - _mbsetupuser console - Mon11 3days - ktravers s000 - Mon11 1:35 gulp ktravers s001 - Mon11 - w ktravers s002 - Mon11 4:10 node /Users/ktravers/.nvm/versions/node/v6.2.2/bin/sails lift ktravers s004 - Mon11 3days /usr/local/Cellar/rabbitmq/3.5.1/erts-6.1/bin/../../erts-6.1/bin/beam.smp -W w -K true -A30 ktravers s005 - Mon11 3days redis-server *:6379 

Read More →

React Code Talk Notes

Published Monday, August 01, 2016

Overview

  • library that renders data to the DOM
  • can add Flux architecture after you’re comfortable with React

Setting up a React app in our codebase

General Notes

  • avoid using jQuery so we can remove that dependency
  • use vanilla JS where possible instead
  • Gulpfile is not watching these files, so will need to re-compile manually after making changes

Setup

1. Add _src file (_src/code-reading.js)
// _src/code-reading.js var React = require('react') , ReactDom = require
      Read More →
    

Best Ways for Beginners To Contribute to Open Source

Published Saturday, November 07, 2015

When I first started out learning to code, the idea of contributing to an open source project was really intimidating. I got that advice from everyone - “Contribute to open source! It’s so easy! Employers love it!” - but I was still hesistant. I’d only been writing Ruby for a couple months; how was I going to contribute anything useful to someone else’s project?

Well, I’m happy to report from the other side, it’s actually pretty painless and fun for beginners at any level to make meaningful contributions to open source projects.

So shake off that imposter syndrome; the...

Read More →

Code Talk Notes - Javascript Testing and Analytics

Published Thursday, September 24, 2015

Javascript Test Updates

jsdom: npm module

  • load into node environment
  • recreate DOM
  • run inside of node using Jasmine

Jade templating

  • require in templates
  • doesn’t need to rely on Rails asset pipeline

Spies:

  • PushStreamSpy
  • spyOnBackboneHistory
  • can have it substitute the function, wrap the function then delegate to function
  • Note: mocks, spies & stubs are all very similar (functionally, conceptually)

Can write specs for Marionette views, Backbone models

  • run in node (npm t)
  • load in view (same as front end)
  • stub out fixtures
  • create view then test view

** eval(locus) ==...

Read More →

Code Talk Notes - Librato and Ironbroker

Published Thursday, September 10, 2015

Librato Update

Librato has two stats types: counter vs gauge

When using counter (aka #send_increment), be sure to set summary function to sum and check Service-Side Aggregation.

Librato counter

Ironbroker Refactor

Payload == immutable
State == mutable

Validation for each source

RabbitMq handler - rescue channel failure by creating new channel

begin # do bunny stuff # if channel closes, rescue rescue @channel = @bunny.create_channel # bunny keeps hopping end 

Read More →

Code Talk Notes - Promises and Asynchronous Code

Published Thursday, August 20, 2015

Callback Hell

Promises are a pattern for managing async callbacks.

Calling then() generates another promise object, when then resolves at the end of the chain. When promise object resolves, it resolves with the data coming back, which can then be passed to the next promise in the chain. Helps maintain the idea of a return value to asynchronous code - brings return values back.

jQuery

jQuery has promises built in, but not fully up to true A+ promise spec.

When.js

When.js is a much more robust promises library.

When.js library provides many...

Read More →

Sublime Text Key Bindings

Published Tuesday, August 18, 2015

Keyboard shortcuts are a programmer’s best friend, and Sublime Text lets you write your own. I use these five below on a daily basis, and you’re going to want to, too. Here’s the setup:

  1. Open Sublime Text
  2. Type command + shift + p to open your Command Pallette (aka super+shift+p in Sublime lingo)
  3. Select Preferences: Key Bindings - User
  4. Insert the following into this file:
[ { "keys": ["super+shift+w"], "command": "close_all"}, { "keys": ["ctrl+alt+shift+down"], "command": "goto_definition" }, { "keys": ["alt+c"], "command": "insert_snippet", "args": { "contents": "console.log(${1:}$SELECTION);${0}" } }, { "keys": ["alt+d"], "command": "insert_snippet",...
      
Read More →

POODR Recap, or How I Learned To Stop Injecting Dependencies and Love OO

Published Wednesday, July 22, 2015

I’ll keep this concise, in the spirit of less is more.

Reading POODR has been one of the most beneficial things I’ve done in my long, illustrious career as a programmer (clocking in at approx $("Feb 02 2015").timeago();). It’s been recommended to me since ~week 2 of my immersive program at Flatiron School, but I’m glad I put it off until I’d built some un-POODR-like apps of my own. That context helped me draw connections between the abstract principles discussed in the book and very real production code I’m working on now. So without further ado:

Read More →

Monkey Patching truncate_html

Published Monday, July 06, 2015

The truncate_html gem is a really useful tool for clipping off a string of html at a designated point. It has some nice customizeable config options, and best of all, zero third party dependencies. Per its docs, it even does the unthinkable:

This library…parses HTML using regular expressions.

Today I discovered I could extend its usefulness even further with a small monkey patch. Now, before the haters come out in full force, YES - I understand that monkey patching is dangerous and needs to be handled with deft and delicacy. That said, the...

Read More →

AcademyAwardable Polymorphic Associations

Published Monday, June 08, 2015

If you ever find yourself in a Rails-situation where you need one model to belong to multiple other models, consider using an ActiveRecord polymorphic association. Don’t let the multisyllabic name fool you; polymorphic associations aren’t as complex to build as they might seem. You can do it.

Meryl Streep Can Do It

Let’s consider a completely relatable and engaging example: The Academy Awards. Maybe you’re building an Oscar ballot app for a family member who’s particularly obsessed with this time-honored, hallowed awards show. Your app at minimum would...

Read More →

It's `document.write(new Date().getFullYear());` - Update Your Footer

Published Friday, May 08, 2015

As I was updating some content on my personal website today, I noticed the copyright date in the footer still read “2014”. Yeah, it’s May. Go me.

Sadly, I believe future-me from 2016 would probably make this same mistake, so to help myself out, I did a quick google search for “How to auto update year website”, which yielded this extremely helpful site: UpdateYourFooter.com. It offers Javascript and PHP solutions, with JS being the easier option for my needs.

Just add the following wherever you want the year displayed:

<script> 
      Read More →
    

Rendering from a Model with ActionView::Base.new => WAT?

Published Sunday, April 26, 2015

I’m a firm believer in the “make it work” philosophy - solve problems first, then refactor. That said, my team may have gotten a little too creative making our last project work. Just take a look at this gnarly method we cooked up:

class Recipe < ActiveRecord::Base def recipe_card ActionView::Base.new( Rails.configuration.paths['app/views'] ).render( partial: 'menus/recipe', format: :txt, locals: { recipe: self 
      Read More →
    

Dynamic Duos - Dependent Select Menus with JQuery and Rails

Published Saturday, April 25, 2015

The first time I tried to apply “dynamic selection” within a Rails form - where selecting an option in one select field dynamically updates the menu options in a second select field, I had a surprisingly hard time with it. I’d watched the Railscast and read multiple tutorials, but just couldn’t crack the code.

Problem was, I was trying to use a collection of model attributes in the first collection_select menu and a collection of model instances in the second menu, organized using the grouped_collection_select helper. What I learned after much trial,...

Read More →

Sublime Linter Rubocop Reboot

Published Saturday, April 18, 2015

This week’s Ruby Weekly had a nice post from Matt Brictson on “Setting up Sublime Text 3 for Rails Development”. It reminded me to finally install the SublimeLinter-rubocop package. This package syncs your linter up with rubocop, highlighting “bad code” as you type (according to the community Ruby Style Guide). Great addition, right?

Well, word to the wise: don’t install a new linter package a couple hours before a technical interview. I didn’t have a chance to tweak the default settings, which as you’ll see below, are a bit…aggressive.

Mark Style OutlineRead More →

Remote True is Magic

Published Sunday, March 29, 2015

I had a really fun time this weekend building a small side project with Sophie DeBenedetto, Jeremy Sklarsky, and Rachel Nackman. We learned a lot of very cool things that you can do with Rails + jQuery, but the coolest was easily remote: true. This one little option is crazy powerful. Case in point: by adding remote: true to our Search form, our searches.js file went from this:

$(function () { submitListener(); }) function submitListener () 
      Read More →
    

Listen Up - Tech Podcasts

Published Sunday, March 22, 2015

Back in my former life as an art historian / art shipper, it wasn’t enough to simply know about art. You had to know about the other people who know about art - the key figures shaping the field, your peers working on the same stuff you were - that was just as critical as being able to recite off Greek column types or the core members of the Arte Povera movement (which I can still do, thanks very much, humanities degrees).

Now that I’m joining this new realm of web development, I have a whole world of...

Read More →

Who's Ahead Now?

Published Sunday, March 15, 2015

After week one of learning Rails, I was eager to test out my new skills on a new side project. I wanted to build something fairly simple, that would utilize skills I felt comfortable with - JSON parsing, ERB, simple search and routing - while also pushing me into uncharted territory, like deploying on Heroku. I spent the afternoon brainstorming, circling around some sort of app that would answer a single simple question (like Is It Raining?, one of my fave single serving sites). I had a couple good ideas, but my partner came up with the...

Read More →

--no-test-framework

Published Thursday, March 12, 2015

Note to self:

Bart Simpson chalkboard

Why? Without the --no-test-framework flag, Rails generate will do the following:

a) overwrite any existing tests that you, your colleagues, or your instructors have already written for that particular object

b) generate unnecessary / unwanted tests (see Thoughtbot’s helpful post on diminishing test coverage returns).

Better to write your own tests. Here’s hoping repetition leads to retention…

UPDATE: my classmate Rachel Nackman wrote an excellent blog post on Rails generators, which included an extremely helpful tip...

Read More →

Flatiron Twitter CLI

Published Sunday, March 01, 2015

Last week, Avi pitched a pretty cool idea to the class: build an “auto-follow bot” for Flatiron student twitter accounts - something we could use to easily auto-follow everyone in the class.

Avi Flatiron Twitter pitch

I’d been looking for a side project to work on (inspired by my classmates who’ve built some very sweet side-projects already: ex.1, ex.2, ex.3, ex.4) and this seemed like a perfect opportunity. I’ve never built a bot, but I know how to build a CLI, so I put labwork on pause and spent...

Read More →

Refash Your Bash - Bash Prompt Customization

Published Monday, February 16, 2015

When I was just starting out learning to code, it quickly became clear I’d be spending a lot of time in Terminal. Never one to skimp on workspace feng shui - just ask my old art world colleagues - I set about post haste to fine tune the CRUD out of my bash profile, starting with the bash prompt.

Now, I’ll caution, there’s an endless plethora of resources out there on the ol’ internet about customizing your bash prompt, and my first time through, I think I read nearly all of them (really went down the .bash_profile rabbit hole,...

Read More →

Using Github for Lecture Notes

Published Sunday, February 15, 2015

Flatiron School has a great system for sharing lecture notes: a dedicated Github repo. I forked the repo during week one, thinking I’d pull down the files to my local, take notes on the notes (Inception-style meta-noting), then push back up to my forked repo. No sweat.

But then comes the scary part for us git-n00bs - getting updates. I felt real comfortable pushing to / pulling from my own repositories. But to get the next days’ lecture material, I was gonna have to add my instructor’s repo as a remote. Yikes. Now that’s a scary connection to make. Any...

Read More →

Adventures in DNS Configuration

Published Tuesday, February 03, 2015

Or How I Stopped Worrying, and Learned to Love GitHub Support

One of the main tenants of the The Flatiron School is “Always be a beginner,”* which has been pretty easy for me to embrace so far, since I am the noobiest of coding noobs right now. Pretty much every day, I’m reminded of my beginner-dom, even in realms I thought I’d more or less mastered.

Case in point, this very blog.

Day one, we were asked to set up technical blogs, which we’d use to write about all the cool new concepts we’re learning. I was...

Read More →