Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 01.WorkshopNotes.md
Last active September 16, 2015 13:18
Tic Tac Toe Client Workshop

Intro

games.riesd.com hosts online games that have an open API so you can easily write a game client and have it play against an opponent. The the site is written in elixir and uses phoenix and channels.

Opponents can be:

  • A human using the web interface
  • A hosted AI
  • Some other program using a websocket
@mmmries
mmmries / goals.rb
Created September 28, 2015 16:43
Example Programming Problem
class Goal
attr_accessor :name, :total_amount, :amount_saved_so_far, :predicted_to_complete_at
def initialize(name, total_amount, amount_saved_so_far)
self.name = name
self.total_amount = total_amount
self.amount_saved_so_far = amount_saved_so_far
end
end
@mmmries
mmmries / 00.Description.md
Last active August 18, 2019 12:26
3 Trvial Concurrency Examples in Elixir

These are my solutions to the three concurrency exercises from Katrina Owen's Go Post.

I'm posting here with example output in the hopes that someone call tell me how to do it better

@mmmries
mmmries / shell.txt
Created October 22, 2015 21:11
Exlir configuration error
You have configured application Ultron in your config/config.exs
but the application is not available.
This usually means one of:
1. You have not added the application as a dependency in a mix.exs file.
2. You are configuring an application that does not really exist.
Please ensure Ultron exists or remove the configuration.
@mmmries
mmmries / README.md
Last active February 9, 2016 02:52
RRobots Tournament Instructions

First get the rrobots running locally on your machine by following the README on the repo.

Next make your own bot by making a file with the same name as the class that it defines (just like the examples/NervousDuck.rb defines the NervousDuck class).

Now put your bot into a gist and send a link to your gist to the person running the tournament.

@mmmries
mmmries / CssHelper.js
Created March 16, 2016 16:35
Client Specific Colorschemes in Javascript
var ColorConversion = require('helpers/ColorConversion');
/**
Used for parsing all css rules on the document
object and replacing any default brand color
instances with the client's brand color scheme.
@class CssHelper
@example
```javascript
@mmmries
mmmries / temperatures.log
Last active March 25, 2016 05:50
Temperature Logging Sample
23:45:35.612 [debug] temperature update: {"/sys/bus/w1/devices/28-000007621b25/w1_slave", 21.625}
23:45:36.940 [debug] temperature update: {"/sys/bus/w1/devices/28-000007621b25/w1_slave", 21.625}
23:45:38.260 [debug] temperature update: {"/sys/bus/w1/devices/28-000007621b25/w1_slave", 21.625}
23:45:39.591 [debug] temperature update: {"/sys/bus/w1/devices/28-000007621b25/w1_slave", 21.687}
23:45:40.940 [debug] temperature update: {"/sys/bus/w1/devices/28-000007621b25/w1_slave", 21.687}