Skip to content

Instantly share code, notes, and snippets.

Riccardo Tacconi rtacconi

View GitHub Profile
@rtacconi
rtacconi / retun_unique.py
Last active Jun 15, 2020
In each input list, every number repeats at least once, except for two. Write a function that returns the two unique numbers.
View retun_unique.py
def retun_unique(lst):
return [i for i in lst if lst.count(i) <= 1]
return_unique([1, 9, 8, 8, 7, 6, 1, 6]) # -> [9, 7]
return_unique([5, 5, 2, 4, 4, 4, 9, 9, 9, 1]) # -> [2, 1]
return_unique([9, 5, 6, 8, 7, 7, 1, 1, 1, 1, 1, 9, 8]) # -> [5, 6]
View autotools.nix
pkgs: attrs:
with pkgs;
let defaultAttrs = {
builder = "${bash}/bin/bash";
args = [ ./builder.sh ];
setup = ./setup.sh;
# binutils-unwrapped provides the ar utility
baseInputs = [ gnutar gzip gnumake gcc binutils-unwrapped coreutils gawk gnused gnugrep patchelf findutils ];
buildInputs = [];
system = builtins.currentSystem;
@rtacconi
rtacconi / cd_public_keys
Last active Jan 11, 2019
cd_public_keys
View cd_public_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSNWB3aMMJ9skVQKZMzIMHBZaqzD0vdDMb/vEsxA9tWkC5ch7RHXlvT10RaAKQy4eGfL1Os2d9MACvZiqsJ68RzgqP4nWIA/F8kxsPHfBY1WJRKPn/nxW+HHisA2LUts/yIYuK6lszMj/UVFCiaIpd9VDe9MOq1sDHxMS4PnyaWwXIxQ9Ua8Ioj93J9ld2pFwQPSAhWuTg5H7k+MbQgdjNxrZyNNd5bbXQsAlpN7K4gtmf9MWhWpN8HoIDPnz/C/VnzcQasQnkYu4kuuI4yMo7dd4vbttWW5df8w0d1yHmfetglQbj1Ht6Y2fn/skUL7Deqf5JnZlR0Gti4VkoJwih vaevictis
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA8VVs+gk0ZFbNbx1tnRGTHFD2OBXGOW7yaMUWMXABF7ONM6iN7SwMdioFNvlPkha6UwPtXlYc+59fI21ExW4Th1IGfhanDMvV61AeR3JQmEuwljBAlEZ779OefupHaWwlMOWUBE7mHZCXgUHZbUom6sL8GCQ0smpnyuQNwcpMEN2YxhbU6d3gowKHgixiJXMkcRCqX5QHNtmVCh9kp6lJNoWrmLJT0W9d6aQhX+laui95D89cFifsyo8fHkADew3PIZ9qyqUTQUrP9MC5PFV9wUA9hds3PaMKbPsEh5a69s4MZ8PxK/Qq5t0FqZDp+3EqNzO1Nz2DkoHRt69aMjsGYw== root@f.ro
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEArxPOycq84YnVKRQt3JIon0sgE8s1oPh2qwCISum77+9NMITZ37gS/+gTXgGcuIGPkz1GxGGg/giWqnw/t/XmGNoPD4rqT14EnXnh7wphl+ABxOwAn6NTyIR0VELhMLNvpj9C+VD8YGa9ICMkgAxIK9flI5E9aEgnja9AmaJ5el8jVO0cTTeijFvU228OzOV8gLvTxRjak+JqZ+
@rtacconi
rtacconi / rust_fibonacci.rs
Last active Jul 14, 2017
Calculation of fibonacci number with Rust
View rust_fibonacci.rs
fn fib(x: u64) -> u64 {
if x > 1 { fib(x - 1) + fib(x - 2) } else { x }
}
fn main() {
println!("Result {}", fib(10)); // -> 55
}
View gist:01a0cd42478a3022616e3de6429add5f
{
// Configure the daemon below:
"options": {
"host_identifier": "scw-xxxxxxx",
"config_plugin": "filesystem",
// Select the osquery logging plugin.
"logger_plugin": "aws_kinesis",
"enable_monitor": "true",
// Splay the scheduled interval for queries.
@rtacconi
rtacconi / Dockerfile
Created May 3, 2017
Alpine Linux, jemalloc, Ruby 2.4.1 segmentation fault
View Dockerfile
FROM alpine:3.4
# skip installing gem documentation
RUN mkdir -p /usr/local/etc \
&& { \
echo 'install: --no-document'; \
echo 'update: --no-document'; \
} >> /usr/local/etc/gemrc
ENV RUBY_MAJOR 2.4
View Chef library to check an expired certificate
require "openssl"
class Chef
class Recipe
def self.certificate_expired?(path)
OpenSSL::X509::Certificate.new(File.open(path, "rb").read).not_after <= Time.now
end
end
end
View chef_user_ssh_acl
REPORT=/tmp/ssh_acl.txt
for user in $(knife data bag show users)
do
knife data bag show users $user | grep -v ssh_keys | grep -v ssh-rsa | grep -v htpasswd | grep -v shell >> $REPORT
echo "---------------------" >> $REPORT
done
@rtacconi
rtacconi / gist:2d90655ad55324d697ab9f1907b70c5b
Last active Feb 7, 2017
AWS CLI list instances name with public IP
View gist:2d90655ad55324d697ab9f1907b70c5b
aws ec2 describe-instances \
--query 'Reservations[*].Instances[*].[Tags[?Key==`Name`].Value|[0],PublicIpAddress]' \
--output table --region us-east-1
@rtacconi
rtacconi / rsyslog.conf
Created Jan 31, 2017
rsyslog.conf configured to send logs to a local ping, change the IP with the IP of your machine
View rsyslog.conf
# rsyslog configuration file
# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html
#### MODULES ####
# The imjournal module bellow is now used as a message source instead of imuxsock.
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
$ModLoad imjournal # provides access to the systemd journal
You can’t perform that action at this time.