Skip to content

Instantly share code, notes, and snippets.

View EdoaLive's full-sized avatar

Edoardo Liverani EdoaLive

  • Italy
View GitHub Profile
@EdoaLive
EdoaLive / .bashrc
Created June 24, 2022 07:18
Expand bash history and avoid duplicates
export HISTCONTROL=erasedups
export HISTSIZE=10000
export HISTFILESIZE=10000
@EdoaLive
EdoaLive / channelClosing.go
Created June 17, 2022 08:59
A clean pattern to close and detect closed channels in goland
package main
import "fmt"
func main() {
var ch = make(chan int)
close(ch)
var ch2 = make(chan int)
go func() {
@EdoaLive
EdoaLive / udpServerClient.go
Last active April 5, 2022 09:55
Example of a simple UDP server (that respond with an echo) and client (that sends periodic packets)
package main
import (
"fmt"
"net"
"time"
)
func main() {
go server()
@EdoaLive
EdoaLive / patch_19.07.patch
Created September 13, 2021 15:59
[PARTIAL] Patch to OpenWRT 19.07 for ASUS RT-AC52U B1
diff --git a/target/linux/ramips/dts/RT-AC52U-B1.dts b/target/linux/ramips/dts/RT-AC52U-B1.dts
new file mode 100644
index 0000000..aad625c
--- /dev/null
+++ b/target/linux/ramips/dts/RT-AC52U-B1.dts
@@ -0,0 +1,184 @@
+/dts-v1/;
+
+#include "mt7620a.dtsi"
+
@EdoaLive
EdoaLive / auto-chroot.sh
Last active February 7, 2022 16:20
Simple chroot scripts that automatically binds directories inside the chrooted environment inside a mount namespace. Useful also to launch a specific command in chroot.
#!/bin/bash
ROOTDIR=/root/update/root/
PARENT_COMMAND=$(ps -o comm= $PPID)
#echo parent is --${PARENT_COMMAND}--
if [ "$PARENT_COMMAND" != "unshare" ]; then
echo "Entering mount namespace..."
unshare -f -m bash $0 "$@"
@EdoaLive
EdoaLive / changed python_targets.sh
Created December 8, 2020 15:37
This command should help to re-emerge all python packages afte changing PYTHON_TARGETS config in a Gentoo system
equery hasuse -F "\$cp" python_targets_python3_8 | xargs emerge -pNvu1
#!/bin/bash
# This will find big files and use dd to measure read throughput.
# Don't know how much the pipe is a bottleneck (64K is the greater chunk the pipe can support).
find -size +10M -exec dd if={} bs=64K 2>/dev/null \; | dd of=/dev/null bs=64K
@EdoaLive
EdoaLive / gentoo.conf
Created October 31, 2020 12:18
Git for gentoo portage repository /etc/portage/repos.conf/gentoo.conf
[gentoo]
auto-sync = yes
location = /usr/portage
sync-type = git
sync-uri = https://github.com/gentoo-mirror/gentoo.git
sync-depth = 1
sync-git-clone-extra-opts = -b master
sync-git-verify-commit-signature = true
@EdoaLive
EdoaLive / ConvertStrinSIDtoSID.ps1
Created August 25, 2019 14:22
Convert Microsoft Windows user string "SID" to binary (hexdecimal)
$toconvert="S-1-5-21-254888874-1234533502-2544551582-1002"
$sid = New-Object System.Security.Principal.SecurityIdentifier($toconvert)
$c = New-Object 'byte[]' $sid.BinaryLength
$sid.GetBinaryForm($c, 0)
echo (($c|ForEach-Object ToString X2) -join '')
@EdoaLive
EdoaLive / script.sh
Created December 9, 2018 23:58
Find all the packages which are compiled with a determined env variable (or not) in a gentoo system. I needed this to get which packages still need to be recompiled with clang.
cd /var/db/pkg/
find -iname env*.bz2 -exec sh -c "bzcat {} | grep CC=\\\"clang > /dev/null || echo {} | egrep -o '(([a-z]|-)+\/\w+)' " \;