This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ echo "secret" > secret.txt | |
$ key_material=$(aws kms generate-data-key --key-id <CMK_key_id> --key-spec AES_256) | |
$ echo ${key_material} | jq ".CiphertextBlob" | sed 's/"//g' | base64 -d > key.enc | |
$ export key=$(echo ${key_material} | jq ".Plaintext" | sed 's/"//g' | base64 -d) | |
$ openssl enc -aes-256-cbc -pass env:key -in secret.txt -out secret.txt.enc | |
$ rm secret.txt | |
$ ls | |
key.enc secret.txt.enc | |
$ key=$(aws-fd-full kms decrypt --ciphertext-blob fileb://key.enc --output text --query Plaintext | base64 -d) | |
$ openssl enc -d -aes-256-cbc -pass env:key -in secret.txt.enc -out secret.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defp upsert_profile(multi, source, source_uuid, profile_url) do | |
profile = %Profile{ | |
source: source, | |
source_uuid: source_uuid, | |
profile: profile_url, | |
} | |
Ecto.Multi.insert(multi, source_uuid, profile, on_conflict: [set: [profile: profile_url]], conflict_target: [:source, :source_uuid]) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# A sneaky wrapper around Rubocop that allows you to run it only against | |
# the recent changes, as opposed to the whole project. It lets you | |
# enforce the style guide for new/modified code only, as opposed to | |
# having to restyle everything or adding cops incrementally. It relies | |
# on git to figure out which files to check. | |
# | |
# Here are some options you can pass in addition to the ones in rubocop: | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Map.Helpers do | |
@moduledoc """ | |
Functions to transform maps | |
""" | |
@doc """ | |
Convert map string camelCase keys to underscore_keys | |
""" | |
def underscore_keys(nil), do: nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew tap homebrew/versions | |
brew install v8-315 | |
gem install libv8 -v '3.16.14.13' -- --with-system-v8 | |
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315 | |
bundle install |
Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...
// see: https://github.com/chadoe/docker-cleanup-volumes
$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
PASSWORD_PATH = ".password" | |
PASSWORD_ID_PATH = ".password_id" | |
# Make sure to have installed vagrant-triggers plugin | |
# > vagrant plugin install vagrant-triggers | |
# After the first `vagrant up` stop the VM and execute the following steps |
#render string as slim template
example:
module WelcomeHelper
def tile_link_to(title, href, icon_content = nil, &block)
icon_content = capture { block.call }.strip.squish if block_given?
content = <<-slim
.tile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/my-engine/simple-form.rb | |
require 'simple_form' | |
# https://gist.github.com/mark-d-holmberg/78f2909de5b59a09329c | |
# Use this setup block to configure all options available in SimpleForm. | |
SimpleForm.setup do |config| | |
# Wrappers are used by the form builder to generate a | |
# complete input. You can remove any component from the | |
# wrapper, change the order or even add your own to the |