Skip to content

Instantly share code, notes, and snippets.

View andreacioni's full-sized avatar

Andrea Cioni andreacioni

View GitHub Profile
@andreacioni
andreacioni / app.controller-1.ts
Last active October 25, 2024 16:29
NestJS Authentication: Single Sign On with SAML 2.0
@Get('api/auth/sso/saml/login')
@UseGuards(SamlAuthGuard)
async samlLogin() {
//this route is handled by passport-saml
return;
}
@andreacioni
andreacioni / main.dart
Created July 9, 2022 11:34
sliding_text_field_error
import 'dart:math';
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
@andreacioni
andreacioni / deepmerge.dart
Created April 3, 2022 16:51
DeepMerge Dart
emptyTarget(val) {
return val is List ? [] : {};
}
dynamic cloneUnlessOtherwiseSpecified(value) {
print('$value');
return isMergeableObject(value)
? deepmerge(emptyTarget(value), value)
: value;
}
@andreacioni
andreacioni / main.go
Created December 29, 2021 21:52
FluentBit Golang Output Telegram Plugin
package main
import (
"C"
"fmt"
"log"
"net/http"
"net/url"
"strings"
"unsafe"
@andreacioni
andreacioni / linux_handbook.txt
Last active October 2, 2023 22:21
Linux Command Handbook
###### FIND ####
> Execute a command on every subfolder
find -D exec -maxdepth 1 -type d -name "my/directory" -print -exec COMMAND \;
####################### SYSTEMD #######################
> Reload service configuration
@andreacioni
andreacioni / savework.sh
Created July 30, 2018 14:49
Simple script to rewiew & save your work when using GIT
#!/bin/bash
git add .
git status
echo "Hit return to continue..."
read
@andreacioni
andreacioni / auto_update_pihole_blocklist.py
Last active January 9, 2023 04:35
Update /etc/pihole/adlist.list of Pi-Hole automatically using the list provided by the WaLLy3K’s blocklist compilation.
#!/usr/bin/python3
'''
Copyright 2018 Andrea Cioni
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the 'Software'),
to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
@andreacioni
andreacioni / checkpihole.sh
Last active August 12, 2018 08:53
Check if Pi-Hole is up and running and restart it if needed
#/bin/bash
#Tested with Pi-Hole v.4
PI_HOST=localhost
echo "Checking Pi-Hole status"
curl http://$PI_HOST/admin/api.php?summary 2>/dev/null | grep '"status":"enabled"' > /dev/null
if [ $? -eq 0 ]; then
@andreacioni
andreacioni / checktag.sh
Created March 6, 2018 14:42
Checkout git repository to last tag
#!/bin/sh
#From: https://addhewarman.com/2015/01/23/easiest-way-how-to-get-tag-from-remote-github-repository/
LAST_TAG=$(git ls-remote --tags [email protected]:MY_REPOSITORY/"$MY_PROJECT".git | awk '{print $2}' | grep -v '{}' | awk -F"/" '{print $3}' | tail -n 1)
git checkout $LAST_TAG
@andreacioni
andreacioni / install_motion.sh
Created February 15, 2018 17:27
script used to install motion on Raspberry Pi Zero
#!/bin/bash
sudo apt-get update
sudo apt-get install autoconf automake build-essential pkgconf libtool git libzip-dev libjpeg-dev checkinstall
sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev libswscale-dev libavdevice-dev
sudo apt-get install libjpeg-turbo8 libjpeg-turbo8-dev
sudo apt-get install libwebp-dev
git clone https://github.com/Motion-Project/motion.git