Skip to content

Instantly share code, notes, and snippets.

View Fire-Dragon-DoL's full-sized avatar

Francesco Belladonna Fire-Dragon-DoL

View GitHub Profile
@Fire-Dragon-DoL
Fire-Dragon-DoL / lpass-att-list.sh
Created December 10, 2022 21:29
List all entries with attachments in LastPass
#!/usr/bin/env bash
##
## Usage: lpass-att-list.sh
##
##
usage() { echo "Usage: $0 [-l <email>] [-i <id>]" 1>&2; exit 1; }
while getopts ":i:o:hl:" o; do
case "${o}" in
@Fire-Dragon-DoL
Fire-Dragon-DoL / manual_preloading.rb
Created April 28, 2022 22:43 — forked from sobstel/manual_preloading.rb
Rails manual association preloading
# taken from https://mrbrdo.wordpress.com/2013/09/25/manually-preloading-associations-in-rails-using-custom-scopessql/
# collection association e.g. has_many
owners = People.all
association_name = :photos
owners.each do |owner|
records = Array(whatever_you_want)
@Fire-Dragon-DoL
Fire-Dragon-DoL / 00-throttle-zoom
Last active June 29, 2023 14:51 — forked from abraithwaite/chill-zoom.sh
FEDORA version - Zoom in Systemd Cgroups on Linux. Change the max allocations to fit your workstation.
#!/usr/bin/env bash
# throttle-zoom '0-1' '6G'
set -xe
main() (
allowedCpus="${1?Missing allowed CPUs, ex: 0-4}"
maxMemory="${2?Missing max memory, ex: 6G}"
@Fire-Dragon-DoL
Fire-Dragon-DoL / ExPrettier.py
Created December 20, 2019 13:12
ExPrettier - Elixir formatter for Sublime Text on save
import os
import sublime
import sublime_plugin
import subprocess
import threading
import re
SYNTAX_ERROR_RE = re.compile(
r"^\*\*\s\((.+)\)\s(.+)\:(\d+)\:\s(.+)$",
re.MULTILINE | re.IGNORECASE | re.UNICODE)
@Fire-Dragon-DoL
Fire-Dragon-DoL / delegate all functions to another module.ex
Last active June 11, 2019 01:02
Delegate all functions to another module, with pattern match on first argument
defmodule LikeMapModule do
defstruct [data: %{}]
# Delegates all functions of Map to Map, with first argument `data`
for {fun, arity} <- Map.__info__(:functions), arity > 0 do
args =
arity
|> Macro.generate_arguments(__MODULE__)
|> Enum.with_index()
|> Enum.map(fn {arg, idx} ->
@Fire-Dragon-DoL
Fire-Dragon-DoL / whiteboardCleaner.md
Created March 10, 2019 00:24 — forked from lelandbatey/whiteboardCleaner.md
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@Fire-Dragon-DoL
Fire-Dragon-DoL / firmware.diff
Last active March 21, 2018 22:13
System76 firmware update fix for Kubuntu. Lines changed in /usr/lib/dist-packages/system76driver/firmware.py from 437 to 450 (included) with lines from 437 to 458 (included) in the following firmware.py file. The problem is basically related to `who`, `fgconsole` and `tty` which behave differently in Ubuntu. This fix is not perfect, you need to …
$ diff -u firmware.py modified.py
--- firmware.py 2018-03-21 15:11:31.020671409 -0700
+++ modified.py 2018-03-21 15:09:43.030990452 -0700
@@ -434,20 +429,28 @@
def get_user_session():
+ tty_name = subprocess.check_output(
+ "tty",
+ shell=True
@Fire-Dragon-DoL
Fire-Dragon-DoL / synclient
Last active March 13, 2017 06:55
Touchpad configuration system76 Oryx pro 3 (February 2017)
Parameter settings:
LeftEdge = 1590
RightEdge = 5350
TopEdge = 1380
BottomEdge = 4476
FingerLow = 25
FingerHigh = 40
MaxTapTime = 68
MaxTapMove = 176
MaxDoubleTapTime = 100
@Fire-Dragon-DoL
Fire-Dragon-DoL / concerning_ruby_protected_access_modifier.rb
Last active August 29, 2015 14:08
Concerning Ruby `protected` access modified
#!/usr/bin/env ruby
class A
def foo(other)
puts "self: #{ bar }"
puts "other: #{ other.bar }"
end
protected
@Fire-Dragon-DoL
Fire-Dragon-DoL / bracketless_method_call.rb
Last active August 29, 2015 14:08
Ruby bracketless method call flow
#!/usr/bin/env ruby
def hi(str)
puts str.to_s
puts "hi"
end
def i(str)
puts str.to_s
"i"