Skip to content

Instantly share code, notes, and snippets.

@mmmries
mmmries / iex.exs
Last active August 29, 2015 14:22
Using knewter/erlang-serial
iex(1)> {:ok, pid} = Ser.start("/dev/ttyAMA0", 115_200)
{:ok, #PID<0.97.0>}
iex(2)> send(pid, {:send, "ohai"})
Received serial data: ohai
{:send, "ohai"}
iex(3)> send(pid, {:send, "ohai"})
{:send, "ohai"}
Received serial data: ohai
iex(4)> send(pid, {:send, "ohai u GUYZ!"})
{:send, "ohai u GUYZ!"}
@mmmries
mmmries / drawings.exs
Last active August 29, 2015 14:17
Showoff Drawings
shapes = [
{:octagon, %{cx: 50, cy: 50, r: 40, fill: "orange"}},
{:circle, %{cx: 12, cy: 12, r: 10}, nil},
{:circle, %{cx: 88, cy: 12, r: 10}, nil},
{:circle, %{cx: 12, cy: 88, r: 10}, nil},
{:circle, %{cx: 88, cy: 88, r: 10}, nil},
{:pentagon, %{
cx: 50,
cy: 50,
r: 30,
@mmmries
mmmries / term_parser.ex
Last active August 29, 2015 14:17
Elixir Term Parser
defmodule TermParser do
def parse(str) when is_binary(str)do
case str |> Code.string_to_quoted do
{:ok, terms} -> hydrate_terms(terms)
{:error, err} -> {:error, err}
end
end
defp hydrate_terms(terms) do
try do
@mmmries
mmmries / clever.rb
Created February 28, 2015 17:10
Clever Ruby Tricks
# Shortcut for Dir Globs
Dir["data_sets/*.csv"].each do |filepath|
process_data_set(filepath)
end
# ARGF an IO object that wraps around all commandline paths
ARGF.readlines.select do |line|
line.start_with?("A")
end.each do |line|
puts line
@mmmries
mmmries / are_we_having_fun_yet.md
Last active August 29, 2015 14:13
Conference Proposal

Are We Having Fun Yet?

Description (200 Words)

Playing is one of the fastest ways to learn something new. Fun is a major component of avoiding burnout. Do you have fun at work? Does your team encourage fun and play?

Lets discuss several ways that reals teams have tried to have fun. Maybe one of them will work for your team.

@mmmries
mmmries / proposal.md
Created January 15, 2015 05:48
Facial Recognition and Robots with Ruby. What could go wrong?

Facial Recognition and Robots with Ruby. What could go wrong?

Description (200 words)

Have you ever thought about making a robot that could recognize faces? Did you want it to shoot darts or meet new people? Getting a robot to act intelligent requires a lot of computer science, but we can still use our favorite language to accomplish these tasks.

We'll see a few demos and look at some of the projects that help us abstract away the sciency bits so we can stay focused on making an awesome robot.

Justification

I like to have fun at a conference. What is more fun that seeing a demo go really well, or totally fail? Is there any better demo than seeing a nerf gun "search" for a target and try to shoot it? What about a lonely roomba that wanders around trying to make friends?

@mmmries
mmmries / proposal.md
Last active August 29, 2015 14:13
Conventions Between Services

Conventions Between Applications

Description (200 words)

Rails gives us great conventions for building an application, but what conventions should we use when we are building a whole system that encompasses multiple applications? How should we name things? What abstraction layers should we enforce?

The MX team has been building a distributed system composed of Rails applications for the last 3 years. We'll talk about failed ideas, conventions that have stood the test of time and some experiments that are underway.

Justification

Much of what makes Rails great is the set of conventions that it gives us. We get naming conventions, architecture conventions, testing conventions, etc. No project sticks to every convention strictly, but having a convention forces us to choose which parts of our application really need to be unconventional.

@mmmries
mmmries / tradeoffs.md
Created November 27, 2014 05:10
Tradeoffs Between SOA vs Modular Ruby Code (gems / engines)

Modular Ruby

  • Easier to combine / split apart components and re-deploy (ie. change your design)
  • Easier to manage dependencies (ie. gem versions + bundler)
  • No need to coordinate deploys since bundler pulls it all together for you
  • No need to serialize / deserialize data (ie. JSON, protobuf, etc)
  • No need to do service discovery / load balancing between pieces
  • Less need for integration tests (ie a staging environment)
  • Sometimes you can get caught wanting to upgrade a gem or ruby version, but something else in your big Rails app needs to the lower version
@mmmries
mmmries / MichaelRobotEntry.rb
Last active February 9, 2016 03:32
RRobotsEntry
require 'rrobots'
class MichaelRobotEntry
include Robot
INTERVAL = (3.14 * 2 * 100).to_i
def tick(events)
unless x < size && y < size
turn (135 - heading)
@mmmries
mmmries / benchmarks_1.md
Last active August 29, 2015 14:06
trigram_benchmark

Ruby 2.1.2

3 seconds of warmup

Calculating -------------------------------------
           load text         1 i/100ms
       generate text        55 i/100ms
-------------------------------------------------
           load text        6.9 (±14.4%) i/s -         66 in  10.090429s
       generate text      592.1 (±16.2%) i/s -       5775 in  10.073268s