Skip to content

Instantly share code, notes, and snippets.

View fornellas's full-sized avatar

Fabio Pugliese Ornellas fornellas

  • Dublin, Ireland
  • 17:34 (UTC +01:00)
View GitHub Profile
@fornellas
fornellas / etc udev 99-logitech-hd-pro-webcam-c920.rules
Last active January 16, 2021 14:50
Disable Logitech C920 autofocus to fix "clicking" issue
SUBSYSTEM=="video4linux", KERNEL=="video[0-9]*", ATTRS{product}=="HD Pro Webcam C920", RUN="/usr/bin/v4l2-ctl -d $devnode --set-ctrl=focus_auto=0" RUN+="/usr/bin/v4l2-ctl -d $devnode --set-ctrl=focus_absolute=0"
@fornellas
fornellas / update_to_latest_vanilla_kernel.sh
Created July 19, 2020 12:28
Update Ubuntu to Latest Vanilla Kernel
#!/bin/bash -e
LATEST_VERSION="$(
wget -qO- 'https://kernel.ubuntu.com/~kernel-ppa/mainline/' \
| grep -E 'href="v[0-9.]+/"' \
| cut -d \" -f8 \
| cut -c2- \
| cut -d/ -f1| sort --version-sort \
| tail -n 1
)"
PAM
type control module-path module-arguments
type: management group
account
non-auth account management
auth
authenticate
group membership
#!/usr/bin/env python
import evdev
import time
import logging
import os
class MouseToKeyboard(object):
LOOP_SLEEP = 1
@fornellas
fornellas / _etc_acpi_events_toggle-tablet-mode
Created January 12, 2017 22:16
Lenovo Yoga X1 tablet mode toggle
event=ibm/hotkey LEN0068:00 00000080 000060c0
action=/etc/acpi/toggle-tablet-mode.sh
# Convert given strig in CamelCase to snake_case.
def camel_to_snake_case string
string.gsub(/([^A-Z])([A-Z])/, '\1_\2').downcase
end
# Convert given string in snake_case to CamelCase
def snake_to_camel_case string
string.split('_').map(&:downcase).map(&:capitalize).join('')
end
@fornellas
fornellas / retry_proxy.rb
Created August 23, 2016 16:54
Retry Proxy
class RetryProxy < BasicObject
def initialize target, retries, logger=nil
@target = target
@retries = retries
@logger = logger
end
BasicObject.instance_methods.each do |basic_object_instance_method|
define_method(basic_object_instance_method) do |*args, &block|
@fornellas
fornellas / tcp_tap.rb
Created July 12, 2016 16:38
Print TCP connection traffic to stdout.
#!/usr/bin/env ruby
require 'socket'
require 'thwait'
unless ARGV.size == 2
STDERR.puts "Usage: #{$PROGRAM_NAME} listen_address:listen_port target_address:target_port"
exit 1
end
listen_address, listen_port = ARGV.shift.split(':')
@fornellas
fornellas / Rakefile
Created June 24, 2016 17:03
simplecov with multiple Ruby executions
# Ensure that all ruby process instances use Simplecov
task :simplecov_setup do
ENV['RUBYLIB'] = "#{Dir.pwd}:#{ENV['RUBYLIB']}"
ENV['RUBYOPT'] = '-r configure_simplecov'
sh 'rm -rf coverage/'
end
# Generate a final report, with all merged results
task :simplecov_report do
require 'simplecov'
REPO="$HOME/src/dotfiles.git"
GITHUB_REPO_URL="git@github.com:fornellas/dotfiles.git"
mkdir -p "$REPO"
cd "$REPO"
git init --bare
cd -
alias dotfiles='git --git-dir="$REPO" --work-tree="$HOME"'
dotfiles remote add origin $GITHUB_REPO_URL
dotfiles pull origin