Skip to content

Instantly share code, notes, and snippets.

View markoudev's full-sized avatar

Mark markoudev

View GitHub Profile
@markoudev
markoudev / deep_scrub.rb
Last active December 18, 2020 09:06
Recursive function to clean an array or hash from keys you don't want to have in there. Useful for scrubbing privacy sensitive information for example. Supports 'safe' mode and 'scrub' mode, respectively meaning to only include the provided fields, or remove the provided fields. Co-authored w/ @Yannickdonners
module DeepScrub
# From a hash or array, scrub or only include specified fields, and
# recursively go through any sub-arrays or sub-hashes.
def deep_scrub(hash_or_array, fields, mode: :safe)
unless [:safe, :scrub].include?(mode)
raise ArgumentError, "mode must be one of :safe or :scrub"
end
if hash_or_array.is_a?(Array)
@markoudev
markoudev / initializer.rb
Last active June 21, 2017 17:36
Storing UUIDs as binary values through Rails 5 and ActiveRecord. The activeuuid gem hasn't been updated for quite some time and with the Rails attributes API this has become relatively easy.
# config/initializers/types.rb
require 'types/uuid'
ActiveModel::Type.register(:uuid, Types::UUID)
@markoudev
markoudev / rf-proxy.sh
Created February 15, 2017 09:11
Forwarding all received 433 MHz RF codes to MQTT
#!/bin/bash
while true; do
nice -n 19 rpi-rf_receive -g 23 2>&1 | {
while read -r LINE; do
code=`echo ${LINE} | awk '{print $6}'`
if [[ "$code" =~ ^[0-9]+$ ]]
then
mosquitto_pub -h localhost -t rfrx -m ${code}
fi

Keybase proof

I hereby claim:

  • I am markoudev on github.
  • I am mov (https://keybase.io/mov) on keybase.
  • I have a public key whose fingerprint is 30FE 1501 5103 AC57 E782 6B43 6222 7229 0E30 E73B

To claim this, I am signing this object: