Skip to content

Instantly share code, notes, and snippets.

View rtacconi's full-sized avatar

Riccardo Tacconi rtacconi

View GitHub Profile
@rtacconi
rtacconi / gist:8ac389e243e8bbf7a836844a3ec53f3d
Last active October 27, 2020 13:30
Piping a subprocesses output directly to stdout (java/clojure)
; this is not async
(defn shell
[cmd]
(->> (.. Runtime getRuntime (exec cmd) getInputStream)
java.io.InputStreamReader.
java.io.BufferedReader.
line-seq
(map str)))
; or this is async, use this as script to test it:
@rtacconi
rtacconi / linked_list.py
Created August 8, 2020 14:13
Implementation of Singly linked list
class Node:
def __init__(self, data=None):
self.data = data
self.next = None
def __str__(self):
return str(self.data)
class SinglyLinkedList:
@rtacconi
rtacconi / retun_unique.py
Last active June 15, 2020 12:22
In each input list, every number repeats at least once, except for two. Write a function that returns the two unique numbers.
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]
@rtacconi
rtacconi / autotools.nix
Last active February 18, 2019 16:41 — forked from lucabrunox/autotools.nix
Nix pill 12
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 January 11, 2019 16:10
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== [email protected]
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEArxPOycq84YnVKRQt3JIon0sgE8s1oPh2qwCISum77+9NMITZ37gS/+gTXgGcuIGPkz1GxGGg/giWqnw/t/XmGNoPD4rqT14EnXnh7wphl+ABxOwAn6NTyIR0VELhMLNvpj9C+VD8YGa9ICMkgAxIK9flI5E9aEgnja9AmaJ5el8jVO0cTTeijFvU228OzOV8gLvTxRjak+JqZ+
@rtacconi
rtacconi / rust_fibonacci.rs
Last active July 14, 2017 17:48
Calculation of fibonacci number with Rust
fn fib(x: u64) -> u64 {
if x > 1 { fib(x - 1) + fib(x - 2) } else { x }
}
fn main() {
println!("Result {}", fib(10)); // -> 55
}
{
// 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 12:55
Alpine Linux, jemalloc, Ruby 2.4.1 segmentation fault
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
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
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