Skip to content

Instantly share code, notes, and snippets.

@mulias
mulias / process_stops.rb
Last active November 2, 2016 04:05
munge RIPTA stop names into more human readable stop location descriptions
require 'json'
def abrev_or_capitalize(w)
{"fs" => "far side of", "ns" => "near side of", "opp" => "opposite",
"rt" => "Rout", "@" => "at", "at" => "at", "of" => "of", "t.f." => "T.F.",
"ri/ma" => "RI/MA", "cvs" => "CVS", "ccri" => "CCRI", "uri" => "URI",
"mfg" => "Manufacturing", "narr" => "Narragansett", "nuwc" => "NUWC",
"ter" => "Terrace", "ri" => "RI", "between" => "between",
"[on-ramp]" => "on-ramp", "svc" => "Service", "commerical" => "Commercial",
"dfs" => "far side of", "hq" => "HQ"
@mulias
mulias / init.vim
Created June 1, 2017 20:57
neovim config
"===============================================================================
" init.vim
" My cleaned up and documented config for neovim, tailored to the features I
" need for work.
"
" Setup
" What I do to get everything working:
" * First install Plug (https://github.com/junegunn/vim-plug) by downloading
" the plugin and placing it in the nvim autoload directory. I actually have
" plug saved with my configs in git, so when I grab this file Plug will come
@mulias
mulias / remoteData.ts
Created July 13, 2018 18:34
RemoteData in typescript
export interface NotAsked {
status: 'NotAsked';
}
export interface Loading {
status: 'Loading';
}
export interface Success<D> {
status: 'Success';
Technical requirements for
What is the mechanism for storing images in local storage?
  • The data returned by the /policies/{policy-number}/vehicles/{vehicle-number}/id-card endpoint is a base64 encoded image string which can be saved directly in AsyncStorage.
Are there any device size/memory limitations we need to take into account?
  • Tentative answer is that iOS has no limit, and Android has a 6MB limit for AsyncStorage. This Article claims that the Android limit can be lifted by editing native files. I haven't found official documentation to back up that info.
@mulias
mulias / maybe-lite.ts
Last active April 6, 2020 14:11
A simple way to leverage some classic `Maybe` function utility, but using TypeScript structural typing instead of the more common "Container" based solution
/**
* A simple way to leverage some `Maybe` utilities, but based on TypeScript structural typing
* instead of the "Container" based solutions that are common in functional JS libraries.
* Based on the Elm standard library and https://gigobyte.github.io/purify/
*/
type Nothing = undefined;
type Maybe<T> = T | Nothing;
type Nullable<T> = T | Nothing | null;
Application.put_env(:phoenix, :json_library, Jason)
Application.put_env(:sample, SamplePhoenix.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 5001],
server: true,
live_view: [signing_salt: "aaaaaaaa"],
secret_key_base: String.duplicate("a", 64)
)
Mix.install([
@mulias
mulias / day_05.ml
Last active December 6, 2022 13:41
AoC 2022 day 5
open! Base
type crane_spec =
| CrateMover9000
| CrateMover9001
type stack = string list [@@deriving yojson]
type stacks = (int * stack) list [@@deriving yojson]
@mulias
mulias / day_07.js
Last active December 7, 2022 20:21
AoC 2022 day 7
const SMALL_DIR_SIZE = 100000
const REQUIRED_SIZE = 30000000
const FILESYSTEM_SIZE = 70000000
const add = (a, b) => a + b
const dirSizes = (dir) => {
let sizes = []
const loadSizes = (d) => {
const filesTotal = d.files.map(f => f.size).reduce(add, 0)
@mulias
mulias / day09.pl
Created December 11, 2022 00:48
Advent of Code day 9
:- use_module(library(clpfd)).
:- use_module(library(dcg/basics)).
:- initialization(main, main).
main :-
part_1(Part1),
format("Part 1: ~d~n", Part1),
part_2(Part2),
format("Part 2: ~d~n", Part2),
@mulias
mulias / day11.rb
Created December 13, 2022 23:05
Advent of Code day 11
require 'json'
def get_monkeys
JSON.parse(File.read("./input.json"), object_class: Monkey)
end
monkey_fields = [
:id,
:items,
:inspect_left,