Skip to content

Instantly share code, notes, and snippets.

@movitto
movitto / keyboard_in.rb
Created September 13, 2017 01:10
/dev/input/event keyboard parser
#!/usr/bin/ruby
# Read keyboard presses / release / holds on Linux
# Released under the MIT License
# Use binary_struct to process blobs
require_relative 'binary_struct'
##################!!!!######################
#!!!!CHANGE ME TO YOUR KEYBOARD DEVICE!!!!!#
############################################
@movitto
movitto / lvm-parser.rb
Created March 30, 2016 01:30
LVM Parser & Block Reader
# LVM Parser & Block Reader
#
# Copyright (C) 2016 Red Hat Inc
require 'optparse'
require 'ostruct'
require 'binary_struct'
### constants
@movitto
movitto / mock.js
Last active April 28, 2021 22:56
Jest mockable modules w/ original invocation
// Mock specific module pre-inclusion, overwriting methods
// w/ stub that behave the same way.
//
// Module should be absolute path as it will be 'required'
// relative to this 'mock' module
function mock_module(module){
jest.doMock(module, () => {
const actual = jest.requireActual(module)
// Stub original behaviour w/ a jest mock
@movitto
movitto / keybase.md
Created November 24, 2020 17:50
keybase.md

mmorsi Mo Morsi Entrepreneur, software engineer, righteous guy New York

Keybase proof

I hereby claim:

@movitto
movitto / psql-ssl.sh
Last active May 18, 2020 03:42
Setup postgresql server/client with self signed certs
# Instructions on how to setup secure postgresql server <-> client communication on two different machines.
# Set SERVER_HOSTNAME and CONNECTION_USER appropriately. Instructions are for Fedora 29, may need to be modified for other platforms
# Set DAYS to the number of days which you'd like certificates to be valid (after this time new client certificates will need to be created)
# General guide can be found here:
# https://www.howtoforge.com/postgresql-ssl-certificates
###
@movitto
movitto / txs_by_result.rb.diff
Created May 8, 2020 21:51
xrp1ntel - TXs By Result: Critical Results Patch
diff --git a/lib/wipple/metrics/txs_by_result.rb b/lib/wipple/metrics/txs_by_result.rb
index 10c5f7c..5badc0d 100644
--- a/lib/wipple/metrics/txs_by_result.rb
+++ b/lib/wipple/metrics/txs_by_result.rb
@@ -3,6 +3,8 @@ module Wipple
class TxsByResult
include BaseMetric
+ CRITICAL_RESULTS = ['tecINVARIANT_FAILED']
+
@movitto
movitto / bench.rb
Created October 21, 2019 19:24
Simple Ruby Benchmark Class
require 'xrbp'
class Benchmark
def initialize(max=1000)
@max = max
@snapshots = []
end
def capture!(n=1)
@snapshots << [n, Time.now]
@movitto
movitto / xrpl-dash1.html
Created October 9, 2019 21:13
Prototype XRPL Node Dashboard Concept - Utilitzing consensus subscription patch
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
<script type="application/javascript" src="ripple-1.3.3-min.js"></script>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="https://d3js.org/d3.v4.js"></script>
<!-- -->
@movitto
movitto / lvd.sh
Created August 28, 2019 20:49
Remove all LVM Snapshots with a certain prefix
#!/bin/bash
# Remove all LVM Snapshots
# Set executable: chmod +x lvmbak.sh
VG="dnp00" # LVM volume group we are snapshoting
BACKUP_PREFIX="dnv1-snap-" # Prefix of snapshot volume name.
/sbin/lvs -o lv_name --noheadings | sed -n "s@$BACKUP_PREFIX@@p" | while read DATE; do
if [ "$DATE" ]; then
@movitto
movitto / lvmbak.sh
Last active August 23, 2019 14:53
Take LVM snapshot / cycle old ones out at specified interval
#!/bin/bash
# Take LVM snapshot / cycle old ones out at specified interval
# Set executable: chmod +x lvmbak.sh
# Make sure to setup sudo correctly:
# # visudo
# <USER> ALL= NOPASSWD: /sbin/lvcreate
# <USER> ALL= NOPASSWD: /sbin/lvremove
# <USER> ALL= NOPASSWD: /sbin/lvs