Skip to content

Instantly share code, notes, and snippets.

View bloudermilk's full-sized avatar

Brendan Loudermilk bloudermilk

View GitHub Profile
@kylefox
kylefox / 001_add_record_uuid_to_active_storage_attachments.rb
Last active January 12, 2022 21:52
Migrations that make ActiveStorage attachments work with UUID primary keys. https://github.com/rails/rails/pull/32466
class AddRecordUuidToActiveStorageAttachments < ActiveRecord::Migration[5.2]
def change
# After applying this migration, you'll need to manually go through your
# attachments and populate the new `record_uuid` column.
# If you're unable to do this, you'll probably have to delete all your attachments.
# You've pretty much got useless garbage data if that's the case :(
add_column :active_storage_attachments, :record_uuid, :uuid
end
end
@stefaneng
stefaneng / jq_group_by_count.sh
Created March 21, 2018 17:00
jq - Group by count
echo '[{"key": 1}, {"key": 2}, {"key": 1}]' | jq 'group_by (.key)[] | {key: .[0].key, length: length}'
@joepie91
joepie91 / blockchain.md
Last active June 25, 2023 08:40
Is my blockchain a blockchain?

Your blockchain must have all of the following properties:

  • It's a merkle tree, or a construct with equivalent properties.
  • There is no single point of trust or authority; nodes are operated by different parties.
  • Multiple 'forks' of the blockchain may exist - that is, nodes may disagree on what the full sequence of blocks looks like.
  • In the case of such a fork, there must exist a deterministic consensus algorithm of some sort to decide what the "real" blockchain looks like (ie. which fork is "correct").
  • The consensus algorithm must be executable with only the information contained in the blockchain (or its forks), and no external input (eg. no decisionmaking from a centralized 'trust node').

If your blockchain is missing any of the above properties, it is not a blockchain, it is just a ledger.

@joshdover
joshdover / README.md
Last active September 28, 2023 21:38
Idiomatic React Testing Patterns

Idiomatic React Testing Patterns

Testing React components seems simple at first. Then you need to test something that isn't a pure interaction and things seem to break down. These 4 patterns should help you write readable, flexible tests for the type of component you are testing.

Setup

I recommend doing all setup in the most functional way possible. If you can avoid it, don't set variables in a beforeEach. This will help ensure tests are isolated and make things a bit easier to reason about. I use a pattern that gives great defaults for each test example but allows every example to override props when needed:

@paragonie-scott
paragonie-scott / crypto-wrong-answers.md
Last active April 21, 2024 23:48
An Open Letter to Developers Everywhere (About Cryptography)
@obstschale
obstschale / octave.md
Last active March 29, 2024 22:51
An Octave introduction cheat sheet.
@toolmantim
toolmantim / Makefile
Last active December 5, 2022 23:14
An example of using Make instead of Grunt for fast, simple and maintainable front-end asset compilation.
# A simple Makefile alternative to using Grunt for your static asset compilation
#
## Usage
#
# $ npm install
#
# And then you can run various commands:
#
# $ make # compile files that need compiling
# $ make clean all # remove target files and recompile from scratch
@focusaurus
focusaurus / ep_app.js
Last active June 14, 2022 00:06
Example of how a main express app can mount sub-applications on a mount point with app.use('/mount-point', subapp); If you GET /, you'll see the main_app's '/' response. If you GET /ep_app, you'll see the ep_app's '/' response.
const express = require("express");
const router = express.Router();
router.get('/', function (req, res) {
res.send("This is the '/' route in ep_app");
});
module.exports = router;
@teropa
teropa / resources.md
Last active December 4, 2020 05:42
Clojure Resources

Tutorials

# MAC manipulators
alias random_mac='sudo ifconfig en0 ether `openssl rand -hex 6 | sed "s/\(..\)/\1:/g; s/.$//"`'
alias restore_mac='sudo ifconfig en0 ether YOUR_ORIGINAL_MAC_ADDRESS_GOES_HERE'