Skip to content

Instantly share code, notes, and snippets.

View mmartinson's full-sized avatar

Mike Martinson mmartinson

  • Brex
  • Squamish BC
View GitHub Profile
@mmartinson
mmartinson / task1.exs
Created May 24, 2018 19:40 — forked from moklett/task1.exs
Elixir Task - Crash Handling
# This demonstrates that, when using async/await, a crash in the task will crash the caller
defmodule Tasker do
def good(message) do
IO.puts message
end
def bad(message) do
IO.puts message
raise "I'm BAD!"
end
@mmartinson
mmartinson / keybase.md
Created May 2, 2017 16:49
Public key proof

Keybase proof

I hereby claim:

  • I am mmartinson on github.
  • I am mikemartinson (https://keybase.io/mikemartinson) on keybase.
  • I have a public key ASDc4J01zZYB3bhj5Hn7JcrT8tPeSqabuXENCyl_hnsWTgo

To claim this, I am signing this object:

@mmartinson
mmartinson / gist:79ac288f4233202f2e7c12d9a4a7a397
Created December 27, 2016 22:33
Elixir Task async/await example
t = [1,1,2,2,3]
f = fn(n) ->
IO.puts("starting #{n}")
:timer.sleep(n * 1000)
IO.puts("finishing #{n}")
n
end
tasks = Enum.map(t, fn(n) ->
require 'open-uri'
require 'nokogirl'
url = "http://www.oreilly.com/data/free/archive.html?imm_mid=0e7547&cmp=em-data-free-na-stny16_nem4_end_summer"
page = Nokogiri::HTML(open(url))
book_links = page.css('a[data-toggle="popover"]').href
download_links = book_links.map { |book_link| get_download_link(book_link) }
@mmartinson
mmartinson / iterm2.md
Created June 9, 2016 18:43
iterm2 cheatsheet

Tabs and Windows

Function Shortcut
Previous Tab + Left Arrow
Next Tab + Right Arrow
Go to Tab + Number
Go to Window + Option + Number
Go to Split Pane by Direction + Option + Arrow
Go to Split Pane by Order of Use + ] , + [
@mmartinson
mmartinson / .spacemacs
Last active October 28, 2017 00:02
Spacemacs config
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@mmartinson
mmartinson / gist:6e56c769414745910d49
Created April 12, 2015 20:10
CSGO practice server config
sv_cheats 1;
mp_limitteams 0;
mp_autoteambalance 0;
mp_roundtime 60;
mp_roundtime_defuse 60;
mp_maxmoney 60000;
mp_startmoney 60000;
mp_freezetime 0;
mp_buytime 9999;
mp_buy_anywhere 1;
@mmartinson
mmartinson / gist:79519aa29ccbd288e169
Last active August 29, 2015 14:14
Monkey patch warrior class for RubyWarrior Game
class TrainedWarrior
attr_accessor :fledgling
def initialize(warrior)
@fledgling = warrior
end
def method_missing(name, *args)
if fledgling.respond_to?(name)
@mmartinson
mmartinson / gist:bf0da1e87720dad728fe
Created January 15, 2015 17:02
Fix for supporting documented syntax of ActiveModel::Serializer 9.2 with Rails 4.2, add to ApplicationController..
def _render_with_renderer_json(json, options)
serializer = build_json_serializer(json, options)
if serializer
super(serializer, options)
else
super(json, options)
end
end
@mmartinson
mmartinson / gist:cf010a1937f498a7176d
Created October 14, 2014 18:53
Sublime keymappings
[
{"keys": ["super+shift+r"], "command": "reindent" , "args": {"single_line": false}},
{ "keys": ["super+v"], "command": "paste_and_indent" },
{ "keys": ["super+shift+v"], "command": "paste" },
{ "keys": ["alt+."], "command": "reveal_in_side_bar" },
{ "keys": ["ctrl+0"], "command": "focus_side_bar" },
{ "keys": ["super+k", "super+f"], "command": "focus_side_bar" }
]