Skip to content

Instantly share code, notes, and snippets.

View obmarg's full-sized avatar

Graeme Coupar obmarg

  • London
  • 00:27 (UTC +01:00)
View GitHub Profile
enisdenjo / graphiql-over-sse.html
Last active August 30, 2023 12:07
GraphiQL ❤️ graphql-sse
* Copyright (c) 2021 GraphQL Contributors
* All rights reserved.
* This code is licensed under the MIT license.
* Use it however you wish.
<!DOCTYPE html>
ruiramos / pattern-matching2.js
Last active January 19, 2022 14:58
Simple Javascript pattern matching
let a = [null, {status: 'OK'}];
(err, _) => console.log('error', err),
(_, resp) => console.log('response', resp)
// logs 'response' { "status": "OK" }
let b = [{err: 401}, null];
coreyhaines / Editable.elm
Last active August 25, 2022 05:11
type Editable
module Editable exposing (..)
type Editable ofType
= NotEditing { value : ofType }
| Editing { originalValue : ofType, buffer : ofType }
value : Editable ofType -> ofType
value editable =
josevalim /
Last active May 22, 2024 10:06
A 1LOC bash script for re-running tests whenever a lib/ or test/ file changes keeping the same VM instance
# You will need fswatch installed (available in homebrew and friends)
# The command below will run tests and wait until fswatch writes something.
# The --stale flag will only run stale entries, it requires Elixir v1.3.
fswatch lib/ test/ | mix test --stale --listen-on-stdin
Xion /
Last active November 23, 2023 03:59
Retrieve source code of a (short) lambda --
import ast
import inspect
import os
def get_short_lambda_source(lambda_func):
"""Return the source of a (short) lambda function.
If it's impossible to obtain, returns None.
kcurtin / ex_unite_case_template.ex
Last active February 26, 2016 16:39
Using case templates to setup your database for integration tests with elixir and ecto.
defmodule DBTransactions do
use ExUnit.CaseTemplate
setup_all do
on_exit fn ->
henrik / say_when_real_guards.exs
Created December 31, 2015 16:43
Example of using real guard clauses in your own code with Elixir macros. Inspired by `plug :foo when action in [:create, :update]`. Also see for "fake" guard clauses that allow any condition/function to be used.
defmodule Lab do
defmacro say({:when, _, [message, condition]}) do
{result, _} = Code.eval_quoted(quote do
case true do
true when unquote(condition) -> true
true -> false
if result do
henrik / say_when.exs
Last active September 7, 2016 09:03
Example of using "guard clauses" in your own code with Elixir macros. Inspired by `plug :foo when action in [:create, :update]`. This implementation accepts any types of conditions, not just the subset allowed in actual guard clauses. But also see for an implementation with real guard clauses.
defmodule Lab do
defmacro say({:when, _, [message, condition]}) do
{result, _} = Code.eval_quoted(condition)
if result do
quote do
IO.puts unquote(message)
mbbx6spp / ALTERNATIVES.adoc
Last active April 25, 2024 15:14
Super quick list of alternatives to Jira and/or Confluence, Stash, Crucible, etc.
BinaryMuse /
Last active April 20, 2022 21:45
Elixir Map/HashDict Performance on Erlang OTP R17 vs R18