Skip to content

Instantly share code, notes, and snippets.

Matt Widmann mgwidmann

  • Washington DC
Block or report user

Report or block mgwidmann

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mgwidmann
mgwidmann / bartender.ex
Created Mar 4, 2016
Simple example showcasing the power of pattern matching.
View bartender.ex
# Lets create a bartender in the same way you would in a imperative language.
defmodule Bartender do
def serve(user, drink) do
if user.age >= 21 do
IO.puts "The bartender slides #{user.name} a #{drink}."
else
IO.puts "Sorry #{user.name}, you'll have to wait #{21 - user.age} more year(s)."
end
end
end
@mgwidmann
mgwidmann / greeter.ex
Last active Dec 20, 2018
Simple distributed greeting system
View greeter.ex
# machine 1
# start up with `iex --name m1@127.0.0.1 --cookie greeter`
# This isn't really necessary but it won't hurt anything
Node.connect :"m1@127.0.0.1"
# All `Node.connect/1` calls can go to the same machine and every machine
# in the cluster will automatically be connected.
# machine 2
# start up with `iex --name m2@127.0.0.1 --cookie greeter`
View ElmDemoRefactored.elm
module ElmDemoRefactored where
import Graphics.Element exposing (..)
import Graphics.Collage exposing (..)
import Color exposing (..)
import Time
import Text
import Window
-- MODEL
@mgwidmann
mgwidmann / ElmDemo.elm
Created Jan 12, 2016
Basic SVG drawing in Elm
View ElmDemo.elm
module ElmDemo where
import Graphics.Element exposing (..)
import Graphics.Collage exposing (..)
import Color exposing (..)
import Time
import Text
import Window
-- MODEL
View ElmDemo.elm
module ElmDemo where
import Graphics.Element exposing (..)
import Graphics.Collage exposing (..)
import Color exposing (..)
import Time
import Text
import Window
-- MODEL
View watcher_hider.service.js.coffee
angular.module('utils.watcher_hider', [])
.service 'WatcherHider', ['$log', ($log)->
($scope)->
@scope = $scope
# Don't try this at home kids...
listeners = []
watches = []
@$watch = (name_or_fn, watcher_fn)=>
You can’t perform that action at this time.