Skip to content

Instantly share code, notes, and snippets.

View fornellas's full-sized avatar

Fabio Pugliese Ornellas fornellas

  • Dublin, Ireland
  • 13:05 (UTC)
View GitHub Profile
mode
S_IFMT 0170000 File Type
S_IFSOCK 0140000 socket
S_IFLNK 0120000 symbolic link
S_IFREG 0100000 regular file
S_IFBLK 0060000 block device
S_IFDIR 0040000 directory
S_IFCHR 0020000 character device
S_IFIFO 0010000 FIFO
N/A 07777 File Mode bits
@fornellas
fornellas / etc udev 99-logitech-hd-pro-webcam-c920.rules
Last active January 15, 2025 21:37
Disable Logitech C920 autofocus to fix "clicking" issue
ACTION=="add", SUBSYSTEM=="video4linux", ENV{ID_V4L_CAPABILITIES}==":capture:" ENV{ID_BUS}=="usb", ENV{ID_VENDOR_ID}=="046d", ENV{ID_MODEL_ID}=="0892", RUN+="/usr/bin/v4l2-ctl -d $devnode --set-ctrl focus_automatic_continuous=0,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'