Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Kurtis Rainbolt-Greene krainboltgreene

🏠
Working from home
View GitHub Profile
View esi.ex
defmodule LiveDataImport.ESI do
require Logger
@default_host URI.parse("https://esi.evetech.net/")
@default_fetch_query %{datasource: "tranquility"}
@type allowed_verbs :: :get | :patch | :post | :put
@spec read(String.t(), map) :: Flow.t()
def read(resource, query \\ %{datasource: "tranquility"})
View duplicate.ex
def unload_cache_attempt({:ignore, :retry}, resource, parameters, http_client, cache) do
Logger.warn("Retrying request in 1s")
Process.sleep(1000)
fetch_for(resource, parameters, http_client, cache)
end
def unload_cache_attempt({:ok, %{status_code: 502}}, resource, parameters, http_client, cache) do
Logger.warn("Retrying request in 1s")
Process.sleep(1000)
fetch_for(resource, parameters, http_client, cache)
View 1.ex
defmodule A do
# What you can write in Elixir
@spec a(String.t()) :: integer
def a(b) when is_bitstring(b) do
if b == "hello" do
1
else
2
end
end
View overboard.ex
@spec as_ast(%{
body: binary,
declaration: bitstring,
documentation: bitstring,
elixir_module: %{documentation: bitstring, slug: bitstring},
elixir_typespec: %{inputs: bitstring, return: bitstring},
guards: binary,
inputs: bitstring,
name: bitstring,
slug: integer,
View gist:212b50cdd83b3d64b2d8b65ce1d8a6aa
Unit Stat Fixes: Corrects the skills of many units along with gear
https://www.nexusmods.com/mountandblade2bannerlord/mods/73
Fast Dialogue: When fighting looters or talking to lords, you'll be hit with the simpel dialog window BEFORE loading into the first person screen
https://www.nexusmods.com/mountandblade2bannerlord/mods/68
BannerPeasants: 1 in 10 soldiers will be carrying a big ass banner on their back
https://www.nexusmods.com/mountandblade2bannerlord/mods/418?tab=files&file_id=2113&nmm=1
View gist:965b5659d4e95ac52ae5fb43221f58c4
#!/usr/bin/env ruby
require "json"
host = ARGV[0]
service = ARGV[1] || ARGV[0]
nodes = JSON.parse(`bin/terraform-nodes | jq '[.[] | [.hostname, .ip]]'`)
groups = nodes.
# [['a-b-c-d-e', '1.1.1.1']]
View controllers.application\.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
View account.ex
defmodule Poutineer.Models.Account do
# ...
import Estate, only: [machine: 1]
# ...
machine([
onboarding_state: [complete: [converted: "completed"]],
role_state: [
grant_moderation_powers: [user: "moderator"],
grant_administrator_powers: [user: "administrator", moderator: "administrator"]
View amodel.ex
defmodule Amodel do
use Ecto.Schema
import Estate, only: [machine: 1]
machine([
onboarding_state: [
complete: [converted: "completed"]
],
role_state: [
View estate.ex
defmodule Estate do
defmacro machine(column_name, events) do
Enum.each(events, fn ({event_name, transitions}) ->
quote do
Enum.each(unquote(transitions), fn ({from, to}) ->
def unquote(:"before_#{event_name}")(%{unquote(column_name) => from} = record) do
record
end
def unquote(:"after_#{event_name}")(%{unquote(column_name) => to} = record) do
You can’t perform that action at this time.