Skip to content

Instantly share code, notes, and snippets.

Martyn Loughran mloughran

Block or report user

Report or block mloughran

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
@mloughran
mloughran / getting-started.md
Last active May 24, 2019
Suggestions for getting started with Elm
View getting-started.md

Learning Elm

Start by following the guide from start to finish. It's really clear and written by Evan, Elm's author. Do the exercises!
https://guide.elm-lang.org

I found this example helpful as an example of piecing everything together after reading the guide
http://elm-bootstrap.info/getting-started

Don't worry about modules or splitting stuff into separate files. This advice is oft repeated in the Elm community and it's absolutely correct. The patterns that work in Elm aren't the patterns that work in other languages, and if you split modules out too early you'll make it harder to get a sense of the right module abstractions. Refacting is a breeze so you can modularise later. (See /The life of a file/ below).

View keybase.md

Keybase proof

I hereby claim:

  • I am mloughran on github.
  • I am mloughran (https://keybase.io/mloughran) on keybase.
  • I have a public key ASCoOglpsX51BeVmxe0-db0fDe6iBgqtYlN2KKCtMcg_sgo

To claim this, I am signing this object:

@mloughran
mloughran / .gitignore
Last active Jan 1, 2016
Comparison of using run time & memory usage to run a ruby script that requires a single gem (which does nothing) then exits.
View .gitignore
.bundle
bundle
vendor
@mloughran
mloughran / Gemfile
Created Aug 15, 2012
em-http-request not closing connections (v 1.0.2)
View Gemfile
source :rubygems
gem 'eventmachine', '1.0.0.rc.4'
gem 'em-http-request', '1.0.2'
gem 'sinatra'
gem 'thin'
@mloughran
mloughran / gist:2837064
Created May 30, 2012
Two state deferrable synchronisation primitive, in need of a name
View gist:2837064
require 'eventmachine'
# Allows calling set/clear at will, and ensures that only a single on_set or
# on_clear deferrable is running concurrently. It also ensures that
# un-necessary callbacks are not run, i.e. set-unset-set in sequency only
# requires the on_set callback to run once
#
# The blocks/procs supplied for on_set and on_clear must return deferrables
#
class Thing
@mloughran
mloughran / page.html
Created Mar 16, 2012
Mobile Safari crash when returning to WebSocket page
View page.html
<html>
<head>
<script>
function debug(string) {
var element = document.getElementById("debug");
var p = document.createElement("p");
p.appendChild(document.createTextNode(string));
element.appendChild(p);
}
@mloughran
mloughran / gist:1382605
Created Nov 21, 2011
Potential async transaction api for em-hiredis
View gist:1382605
require 'em-hiredis'
class EM::Hiredis::Client
class Transaction
include EM::Deferrable
def initialize(redis)
@redis = redis
end
@mloughran
mloughran / fiber_cache.rb
Created Nov 4, 2011
Proof of concept Redis cache, which blocks fiber if required on access
View fiber_cache.rb
require 'eventmachine'
require 'em-hiredis'
require 'fiber'
class Cache
include EM::Deferrable
def initialize(key)
$redis.get(key) { |v|
@value = v
@mloughran
mloughran / Gemfile
Last active Sep 27, 2015
Firefox orphaned WebSocket connection testcase
View Gemfile
source :rubygems
gem 'em-websocket'
gem 'sinatra'
@mloughran
mloughran / pubsub_example.rb
Created Sep 14, 2011
em-hiredis pubsub example
View pubsub_example.rb
require 'em-hiredis'
EM.run {
require 'em-hiredis'
redis = EM::Hiredis.connect
# If you pass a block to subscribe it will be called whenever a message
# is received on this channel
redis.pubsub.subscribe('foo') { |msg|
p [:received_foo, msg]
You can’t perform that action at this time.