Skip to content

Instantly share code, notes, and snippets.

View StefanoBelli's full-sized avatar

ste StefanoBelli

  • Rome, Italy
View GitHub Profile
@StefanoBelli
StefanoBelli / ebuildadd.sh
Last active June 22, 2016 16:29
[portage] Automatically add ebuild to portage tree
#!/bin/sh
LPORTDIR=/usr/portage #Change this if it is not your tree
GETCATEGORY=$1 #Category (such as x11-themes)
GETNAME=$2 #Name (such as numix-icon-theme)
FULLNAME=""
DIRTREE=""
CHECKDIR=""
## VARIOUS USEFUL FUNCITONS ##
@StefanoBelli
StefanoBelli / LightIRC.java
Last active May 26, 2016 15:11
Just some fun w/ Java..
package lightirc;
import java.awt.Color;
import java.awt.Font;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
@StefanoBelli
StefanoBelli / ghstatus.sh
Created July 7, 2016 22:19
Gets GitHub server status / last message
#!/bin/sh
if ! which jq 2>/dev/null >>/dev/null;
then
echo "You need to install jq"
exit 2
fi
if ! which curl 2>/dev/null >>/dev/null;
then
@StefanoBelli
StefanoBelli / keyboard-led.sh
Last active October 19, 2016 18:20
Script used to enable/disable keyboard backlight
#!/bin/sh
LED_VALUE="3"
OPTION="$1"
if ! which xset 2>/dev/null >>/dev/null;
then
echo "You need xset in order to set keyboard backlight"
exit 1
fi
@StefanoBelli
StefanoBelli / disable_gpe6F.service
Last active June 24, 2023 09:08
Temporary fix for ACPI (GPE iinterrupts) failure , disable GPE6f interrupts, probably motherboard faulty ACPI implementation (reflash/update BIOS) [[!!You should take action!!]]. Install this in /usr/lib/systemd/system and run systemctl enable disable_gpe6F
[Unit]
Description=Disable GPE6F interrupts
[Service]
Type=oneshot
ExecStart=/bin/bash -c "echo disable > /sys/firmware/acpi/interrupts/gpe6F"
[Install]
WantedBy=multi-user.target
@StefanoBelli
StefanoBelli / macOS_launcher.sh
Last active April 11, 2021 05:43
Fast OS X launch on QEMU with KVM support enabled. Credits to: https://github.com/kholia, original repository: https://github.com/kholia/OSX-KVM
#!/bin/sh
# qemu-img create -f qcow2 mac_hdd.img 64G
# echo 1 > /sys/module/kvm/parameters/ignore_msrs
#
# Type the following after boot,
# -v "KernelBooter_kexts"="Yes" "CsrActiveConfig"="103"
#
# printf 'DE:AD:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256))
#
@StefanoBelli
StefanoBelli / uncrustyme.fish
Last active December 29, 2016 11:43
Uncrustify your source code very fast with this fish shell function
function uncrustyme
set UCM_CFG $HOME/.uncrustyme.cfg
set cnt 1
set total 0
set rc (ls | grep "\.$UCM_EXT\$")
if test -f $UCM_CFG
printf " \033[32m==>\033[0m Found configuration file: $UCM_CFG\n"
else
printf " \033[31m==>\033[0m Cannot find configuration file: $UCM_CFG\n"
@StefanoBelli
StefanoBelli / ezchroot.sh
Last active February 2, 2017 21:40
Easy chrooting, mount and run this script :P
#!/bin/sh
show_help() {
echo " ** Usage: $0 <chroot_target> [shell]"
echo " ** Where [shell] is not strictly required (will use /bin/sh)"
}
failure() {
echo -n " "
echo $@
@StefanoBelli
StefanoBelli / procutils.c
Last active March 30, 2017 19:52
Various process control calls
#include <sys/utsname.h>
#include <string.h>
#include <dirent.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <ctype.h>
#include <signal.h>
#include "procutils.h"
@StefanoBelli
StefanoBelli / Apply-HostsAdBlock.ps1
Last active April 11, 2017 10:10
Map ads to 127.0.0.1
Set-Variable -Name hosts -Value C:\Windows\System32\drivers\etc\hosts
Set-Variable -Name oldHosts -Value C:\Windows\System32\drivers\etc\hosts.old.apply_hostsadblock
$sources = "https://adaway.org/hosts.txt",
"https://hosts-file.net/ad_servers.txt",
"https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext"
echo " *** WARNING *** "
echo " ! This script can be executed to update the hosts file !"
echo " ! For that reason, this WILL OVERWRITE THE hosts file !"