Skip to content

Instantly share code, notes, and snippets.

View eruffaldi's full-sized avatar

Emanuele Ruffaldi eruffaldi

View GitHub Profile
@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 / pptx2txt.py
Created September 7, 2023 14:38
Exports PPTX to TXT
# EXCLUDES Comments
from pptx import Presentation
import sys
prs = Presentation(sys.argv[1])
for i,slide in enumerate(prs.slides):
print("---------------------- Slide %d" % (i+1))
for shape in slide.shapes:
if hasattr(shape, "text"):
print(shape.text)
@eruffaldi
eruffaldi / build.cmd
Created June 20, 2021 03:14
Compile NVIDIA Windows
% based on combination of online info
git clone https://github.com/opencv/opencv.git -b "4.5.2" --depth 1
git clone https://github.com/opencv/opencv_contrib.git -b "4.5.2" --depth 1
set "opencvSource=opencv-4.5.2"
set "opencvExtraModules=opencv_contrib-4.5.2/modules"
set "opencvBuild=%opencvSource%\build"
set "compiler=Visual Studio 16 2019"
set "buildType=Release"
set python3_executable
@eruffaldi
eruffaldi / main.cpp
Created October 12, 2020 04:19
Named Operators in C++ and Unicode
// Testedt with GCC and CLang
// Not working with ICC due to the UTF-8
// MSVC requires /utf-8 option
#include <iostream>
// from https://riptutorial.com/cplusplus/example/23817/named-operators
// modified to use < > instead of *
// modified for adding unary version
namespace named_operator {
template<class D>struct make_operator{constexpr make_operator(){}};
@eruffaldi
eruffaldi / midi2notes.py
Created February 7, 2019 14:50
MIDI to notes
from mido import MidiFile
import mido
import sys
def ntof(n):
return 440*(2**((n-69)/12))
def main():
mid = MidiFile(sys.argv[1])
@eruffaldi
eruffaldi / posit_one.h
Last active January 24, 2019 09:58
posit_one.h
// cppPosit 7b7b5ecde436a65923d679d91ddb1b29b711af27
/**
* Emanuele Ruffaldi (C) 2017-2018
*
* My personal bit hip pop using BMI extensions and a bit of constexpr!
*/
#if defined(__SDSVHLS__) && !defined(FPGAHLS)
#define FPGAHLS
@eruffaldi
eruffaldi / cf32.jl
Last active December 30, 2018 11:07
Julia cf32
function s64toc64(a::Int64)::Int64
return a < 0 ? -(a & 9223372036854775807) : a;
end
function c64tos64(a::Int64)::Int64
return a < 0 ? ((-a) | -9223372036854775808) : a;
end
@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"