Skip to content

Instantly share code, notes, and snippets.

View eruffaldi's full-sized avatar

Emanuele Ruffaldi eruffaldi

View GitHub Profile
@eruffaldi
eruffaldi / lookup_cell_color.ocs
Created April 6, 2024 15:27
Excel Lookup Cell Color
function main(workbook: ExcelScript.Workbook) {
// Specify the sheet names
let mainSheetName = "System Items";
let lookupSheetName = "Foglio1";
// Get the sheets
let mainSheet = workbook.getWorksheet(mainSheetName);
let lookupSheet = workbook.getWorksheet(lookupSheetName);
// Get used ranges (assuming data starts from row 1)
@eruffaldi
eruffaldi / vacations.ocs
Created April 5, 2024 16:15
Excel Vacations
function main(workbook: ExcelScript.Workbook) {
// Specify the worksheet name
let worksheetNameS = "Foglio2"; // Adjust the sheet name as necessary
let worksheetS = workbook.getWorksheet(worksheetNameS);
// Specify the worksheet name
let worksheetNameD = "Foglio1"; // Adjust the sheet name as necessary
let worksheetD = workbook.getWorksheet(worksheetNameD);
// Starting and ending cells in the column containing the range addresses
@eruffaldi
eruffaldi / pbpaste-html.swift
Created January 18, 2017 23:56
pbpaste html OSX
// xcrun -sdk macosx swiftc pbpaste.swift -o pbpaste-html
// from: http://stackoverflow.com/questions/17217450/how-to-get-html-data-out-of-of-the-os-x-pasteboard-clipboard
import Cocoa
let type = NSPasteboardTypeHTML // PNG for image
if let string = NSPasteboard.generalPasteboard().stringForType(type) {
print(string)
}
else {
print("Could not find string data of type '\(type)' on the system pasteboard")
exit(1)
@eruffaldi
eruffaldi / gettoken.sh
Created September 25, 2018 09:23
Google OAuth 2.0 full example bash script.
#!/bin/bash
#1) on https://console.developers.google.com/ register project and associate API from library
# OUTPUT: client_id,client_secret
client_id="..."
client_secret="...."
#2) get authorization code at the following link using web browser
# OUTPUT: code
scope="https://www.googleapis.com/auth/drive"
@eruffaldi
eruffaldi / ffmpeg_opencv.py
Last active February 1, 2024 22:33
Feeding Python Opencv with FFmpeg
#
# Reading video from FFMPEG using subprocess - aka when OpenCV VideoCapture fails
#
# 2017 note: I have realized that this is similar to moviepy ffmpeg reader with the difference that here we support YUV encoding
# BUT we lack: bufsize in POpen and creation flags for windows
# https://github.com/Zulko/moviepy/blob/master/moviepy/video/io/ffmpeg_reader.py
#
# Emanuele Ruffaldi 2016
import cv2
import subprocess
@eruffaldi
eruffaldi / Excel Lambda
Created January 9, 2024 08:11
Calculate solid angle of Rotation Roll-Pitch-Yaw in Excel
=LAMBDA(r,p,y,ARCCOS((COS(p)*COS(r)+COS(p)*COS(y)+COS(y)*COS(r)+SEN(p)*SEN(r)*SEN(y)-1)/2))(A3,B3,C3)
@eruffaldi
eruffaldi / openssh-build-static.sh
Last active January 4, 2024 07:23 — forked from fumiyas/openssh-build-static.sh
Build OpenSSH with static linked zlib and OpenSSL libraries
#!/usr/bin/env bash
# Dependencies: curl gcc make autoconf
#
# Changes: 2024-01-03 Emanuele Ruffald
# Updated to latest libraries, modified for building openssh, added some if for debugging
set -uex
umask 0077
ZLIB_VERSION=1.3
@eruffaldi
eruffaldi / JSON
Created December 27, 2023 16:54
Add tilde shortcut to Visual Studio for Code
// Run command Open Keyboard Shortcuts (JSON)
// AltGr+ì is oem_6 ==> use Open Keyboard Shortcuts , select record key and press the shortcut
[
{ "key": "oem_6",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "~"
}
]
@eruffaldi
eruffaldi / lambdasignal.cpp
Last active December 22, 2023 23:00
Signal as Lambda Functions in C++
#include <functional>
#include <fstream>
#include <iostream>
#include <signal.h>
/// one holder per signal type
template <int q>
struct Signal
{
using sfx = void(int );
@eruffaldi
eruffaldi / TypedCsvDict.py
Created December 14, 2017 11:21
Typed CSV Reader and Writer
from csv import DictReader,DictWriter
# originally from pygramel
class TypedDictReader(DictReader):
"""A class for iterating a CSV file and type cast the values."""
def __init__(self, csvfile, casts, fieldnames=None, restkey=None,
restval=None, dialect='excel', *args, **kwds):
"""Arguments:
- f: An iterable object such as as file. Passed on to