Skip to content

Instantly share code, notes, and snippets.

View totomz's full-sized avatar

Tommaso Doninelli totomz

View GitHub Profile
@totomz
totomz / ConsoleApplication.cpp
Created May 27, 2021 18:00
Calling Go from C++
// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <windows.h>
#include <iostream>
//typedef char* (__stdcall* f_funci)();
typedef char* (__stdcall* f_PrintZio)(char*);
@totomz
totomz / fosdem2gcal.js
Last active February 5, 2021 20:45
FOSDEM2GCal - Tampermonkey/Greasemonkey script to save FOSDEM event in Google Calendar
// ==UserScript==
// @name FOSDEM2GCal
// @namespace https://github.com/totomz
// @version 0.1
// @description Add talks to your google calendar
// @author Tommaso Doninelli
// @match https://fosdem.org/2021/schedule/event/*
// @grant GM_xmlhttpRequest
// @require https://code.jquery.com/jquery-3.5.1.slim.min.js
// ==/UserScript==
@totomz
totomz / clusterconnect.py
Created February 3, 2021 20:21
iTerm 2 script to open multiple SSH sessions to a remote cluster
#!/usr/bin/env python3.7
import iterm2
from pathlib import Path
USER = "debian"
HOSTS = x = open("{}/Desktop/_cluster".format(Path.home())).readlines()
@totomz
totomz / backupfolder.sh
Created December 7, 2020 20:34
BAckup a project folder by archiving it and uploading to Dropbox
#!/bin/bash
FOLDER=$(pwd)/$1
INST=$(date "+%Y%m%d-%H%M%S")
echo "File description? Ctrl-C to abort"
read title
title="${title// /_}"
FILE="$1_${title}_${INST}"
@totomz
totomz / zt_clean.py
Created November 17, 2020 16:51
Cleanup stale nodes from ZeroTier
import requests
import datetime
import od
URI = "https://my.zerotier.com/api"
ZT_TOKEN = os['ZT_TOKEN']
ZT_NETWORK = os['ZT_NETWORK']
with requests.Session() as s:
s.headers.update({'Authorization': f"bearer {ZT_TOKEN}",
@totomz
totomz / humidity.py
Last active October 29, 2020 14:53
Python script to colelct humidity and temperature from a DHT22 sensor and an ipmi server
#! /usr/bin/python3
import statsd
import Adafruit_DHT
import time
import boto3
import sys
import subprocess
import socket
from timeit import default_timer as timer
@totomz
totomz / fattureincloud.js
Last active January 8, 2020 10:03
Tamperonkey script for fattureincloud
// ==UserScript==
// @name CostAllocations
// @namespace https://allocation-costs.my-ideas.it/
// @version 0.1
// @description Semplifica la getione dei cost center e tags su fatture in cloud
// @author Tommaso Doninelli
// @match https://secure.fattureincloud.it/expenses-new
// @grant none
// ==/UserScript==
@totomz
totomz / rsync.sh
Created December 29, 2019 22:52
rsync max/linux
# Sync a local folder via ssh
rsync --delete -v -r -a --exclude=.git --exclude=.idea -h -e ssh ./ totomz@tomhost:/home/totomz/bomba
@totomz
totomz / docker-attach.js
Created July 25, 2019 20:21
Sample js code to attach a running container using websocket
const WebSocket = require('ws');
const id = '81bf9a17d914';
const url = `ws+unix:///var/run/docker.sock:/containers/${id}/attach/ws?stream=1&stdout=1&logs=1`;
const socket = new WebSocket(url, {
perMessageDeflate: false
});
<script>
hbspt.forms.create({
portalId: "0000",
formId: "aaa-bbb-ccc",
onFormReady: function($form){
var input = $form.find('input[type=email]');
input.addClass('form-control');
input.css('width', '100%');