Skip to content

Instantly share code, notes, and snippets.

View lukeledet's full-sized avatar

Luke Ledet lukeledet

  • Revelry Labs
  • New Orleans, LA
View GitHub Profile
@lukeledet
lukeledet / gist:64e99b182379c42f4cdae79654fc277f
Created September 16, 2022 01:43
keccak all events from abis
fd json abi | xargs -n1 jq '.[] | select(.type=="event") | select( any(.inputs[]; .name == "tokenId")) | .name+"("+(.inputs|map(.type)|join(","))+")"' | sort | uniq | parallel 'echo {}; echo -n {} | keccak-256sum'
@lukeledet
lukeledet / tokens2spreadsheet.exs
Created August 10, 2022 16:57
Turn a directory of token files into a tab separated list
Mix.install([:jason])
attribute_order = ["background", "body", "tattoos", "costume", "mane", "face", "eyes", "snout", "hat", "flinger"]
File.cd("tokens")
File.ls!()
|> Enum.filter(&(&1 =~ ".json"))
|> Enum.sort_by(&Float.parse/1)
|> Enum.map(fn f ->
@lukeledet
lukeledet / meeting.exs
Created October 10, 2021 08:59
Schedule engineering meetings from a list of people on the blockchain and a given start date
Mix.install([
{:ethereumex, "~> 0.7.0"},
{:ex_abi, "~> 0.5.2"},
{:ex_keccak, path: "../ex_keccak", override: true} # fixed a bug locally
])
# Application.put_env(:ethereumex, :url, "https://polygon-rpc.com/")
Application.put_env(:ethereumex, :url, "https://rpc-mumbai.matic.today")
defmodule MeetingScheduler do
@lukeledet
lukeledet / deis_env_secrets.sh
Created July 7, 2021 18:31
deis_env_secrets.sh
#!/usr/bin/env bash
# Extract the environment variables from a deis app and convert them to a standard env file format
namespace=$1
pod=$2
kubectl get pod $pod -o json -n $namespace | jq -r '.spec.containers[].env[]? | [.name, .valueFrom.secretKeyRef.name, .valueFrom.secretKeyRef.key] | @tsv' | \
grep -v -e "^WORKFLOW_RELEASE" -e "^PORT" -e "^SOURCE_VERSION" -e "^DEIS_APP" -e "^DATABASE_URL" | \
while IFS=$'\t' read -r var_name secret_name secret_key; do
kubectl get secret $secret_name --namespace $namespace -o json | jq -r --arg var_name "$var_name" --arg secret_key $secret_key '.data[$secret_key] | @base64d | "\($var_name)=\"\(.)\""'
cask_args appdir: '/Applications'
tap 'homebrew/cask'
tap 'homebrew/bundle'
tap 'heroku/brew'
brew 'asdf'
brew 'bash'
brew 'bat'
brew 'coreutils'
@lukeledet
lukeledet / travis_seconds.sh
Created August 8, 2020 23:12
Sum duration of travis builds for a list of repos
#!/bin/bash
#
# Get the sum of the duration of all builds on a specific day for a list of repos
#
# example:
# $ sh travis_seconds.sh
# 2020-08-06
# 47014
#
# repos (org/repo) are in repos.txt, 1 per line
@lukeledet
lukeledet / debug_http_headers.ex
Last active April 21, 2020 16:36
Debug HTTP headers plug
defmodule Plug.DebugHTTPHeaders do
@moduledoc """
Plug to debug request and response headers. Add it to TSSWeb.Endpoint before
any other plugs to ensure you see all headers. If you add it to the router
another plug might handle the response before this one.
THIS IS MEANT FOR USE IN DEVELOPMENT ONLY.
If you see this plug used in a pull request, reject it.
"""
@lukeledet
lukeledet / notifications.ex
Last active May 19, 2020 15:48
Compile notifications
defmodule Mix.Tasks.Compile.Notifications do
@moduledoc """
Send notifications when compiling is done
Uses a GenServer to limit the number of notifications it sends to one every
@notification_timeout_ms milliseconds. This is because phoenix checks if any
files need to be compiled on every request.
Setup:
* Put this in lib/mix/tasks/compile
@lukeledet
lukeledet / iex.exs
Last active June 3, 2020 13:35
My iex.exs
IEx.configure(default_prompt: "%prefix>", alive_prompt: "%node>")
pbcopy = fn arg ->
port = Port.open({:spawn_executable, "/usr/bin/pbcopy"}, [])
Port.command(port, arg)
Port.close(port)
arg
end
pbpaste = fn ->
### Keybase proof
I hereby claim:
* I am lukeledet on github.
* I am lukeledet (https://keybase.io/lukeledet) on keybase.
* I have a public key ASAq37AsIe3VPgfrsVdysYG5l1ZDX0Eq4THnSNpL100rVgo
To claim this, I am signing this object: