Skip to content

Instantly share code, notes, and snippets.

View 0x6a68's full-sized avatar
🔌
Beam'ing

0x6a68

🔌
Beam'ing
View GitHub Profile
@0x6a68
0x6a68 / promise-tuple.js
Created January 28, 2022 15:56 — forked from fnky/promise-tuple.js
Retrieve tuples from Promise results / async functions
/**
* Returns a Promise which resolves with a value in form of a tuple.
* @param promiseFn A Promise to resolve as a tuple.
* @returns Promise A Promise which resolves to a tuple of [error, ...results]
*/
export function tuple (promise) {
return promise
.then((...results) => [null, ...results])
.catch(error => [error])
}
@0x6a68
0x6a68 / advent_of_code_2021_day_02.ex
Last active December 2, 2021 17:15
Day 2 of the Advent of Code 2021
defmodule AdventOfCode2021.Day02 do
@moduledoc """
--- Day 2: Dive! ---
Now, you need to figure out how to pilot this thing.
It seems like the submarine can take a series of commands like forward 1, down 2, or up 3:
forward X increases the horizontal position by X units.
down X increases the depth by X units.
up X decreases the depth by X units.
@0x6a68
0x6a68 / advent_of_code_2021_day_01.ex
Last active December 2, 2021 07:44
Day 1 of the Advent of Code 2021
defmodule AdventOfCode2021.Day01 do
@moduledoc """
--- Day 1: Sonar Sweep ---
You're minding your own business on a ship at sea when the overboard alarm goes off! You rush to see if you can help. Apparently, one of the Elves tripped and accidentally sent the sleigh keys flying into the ocean!
Before you know it, you're inside a submarine the Elves keep ready for situations like this. It's covered in Christmas lights (because of course it is), and it even has an experimental antenna that should be able to track the keys if you can boost its signal strength high enough; there's a little meter that indicates the antenna's signal strength by displaying 0-50 stars.
Your instincts tell you that in order to save Christmas, you'll need to get all fifty stars by December 25th.
Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck!
### Keybase proof
I hereby claim:
* I am 0x6a68 on github.
* I am 0x6a68 (https://keybase.io/0x6a68) on keybase.
* I have a public key ASDmTfB7x8vU9rkTy_x_SXJaUEa9n9GL_TXswurkjJXSRwo
To claim this, I am signing this object:
@0x6a68
0x6a68 / docker-compose.yml
Created January 4, 2021 11:06 — forked from ahromis/docker-compose.yml
Gogs docker-compose.yml
version: '2'
services:
postgres:
image: postgres:9.5
restart: always
environment:
- "POSTGRES_USER=${POSTGRES_USER}"
- "POSTGRES_PASSWORD=${POSTGRES_PASSWORD}"
- "POSTGRES_DB=gogs"
volumes:
@0x6a68
0x6a68 / .projections.json
Created November 26, 2020 09:02
vim-projectionist: typescript + react
{
"*.tsx": {
"alternate": "{dirname}/__tests__/{basename}.test.tsx",
"type": "source",
"template": [
"import type {open} FC {close} from 'react';",
"",
"type {basename|camelcase|capitalize}Props = {open}",
" property?: unknown;",
"{close};",
@0x6a68
0x6a68 / foo.ex
Last active May 26, 2021 15:37
Spec to Callback
defmodule MyApp.Foo do
@on_definition MyApp.SpecToCallback
@spec bar(String.t()) :: String.t()
def bar(foobar) do
impl().bar(foobar)
end
defp impl, do: Application.get_env(:my_app, :my_app_foo_impl, __MODULE__.DefaultImpl)
end

Commands and Helpers

CAUTION - in examples by tilde (~) we mean a directory where you cloned the repository.

Invoking tests

~ $ mix test
@0x6a68
0x6a68 / Main.elm
Created November 23, 2018 08:35 — forked from martimatix/Main.elm
A beginner's guide to Graphqelm
module Main exposing (main)
import Graphqelm.Operation exposing (RootQuery)
import Graphqelm.Http
import Graphqelm.SelectionSet exposing (SelectionSet, with)
import Html exposing (Html, a, div, h1, h2, p, pre, text)
import RemoteData exposing (RemoteData)
import Github.Object
import Github.Object.User as User
import Github.Query as Query
@0x6a68
0x6a68 / IntrospectionQuery.graphql
Created October 3, 2017 12:02
grapqhl: IntrospectionQuery
query IntrospectionQuery {
__schema {
queryType {
name
}
mutationType {
name
}
subscriptionType {
name