Skip to content

Instantly share code, notes, and snippets.


Alessandro Pezzato alepez

View GitHub Profile
alepez /
Created Apr 8, 2020
i3wm fix virtualbox resolution

VirtualBox gust screen resolution doesn't work well under i3wm, sometime it get stuck at some strange resolution.

This script can fix the window size.

From the guest side, we use VBoxManage to tell the guest that a new resolution is available.

Window is made floating, then the border is removed (it count as width/height), then the window is resized.

init() {
ip link set can0 type can bitrate 250000
ip link set can0 up
rawdump() {
candump can0
alepez /
Created Jul 13, 2019
Docker base image from arago 2018.04 sysroot

Copy from arago sysroot those files:

alepez / print-byte-array.cpp
Created Jun 14, 2019
print byte array as human readble hex numbers
View print-byte-array.cpp
inline void printHex(const uint8_t* s, unsigned size)
for (unsigned i = 0; i != size; ++i)
if (s[i] > ' ' && s[i] <= '~')
printf("'%c' %02x ", s[i], (int)s[i]);
alepez / string-compare-human.cpp
Created Jun 14, 2019
string compare with human readable diff
View string-compare-human.cpp
bool stringsCompare(const std::string& a, const std::string& b)
for (int i = 0; i < a.size() && i < b.size(); ++i)
if (a[i] != b[i])
fprintf(stderr, "At index %i: %c != %c\n", i, a[i], b[i]);
return false;
alepez / AutoHotkey.ahk
Created Mar 7, 2019
AutoHotkey: italian accents on us layout. Caps-Lock -> Ctrl/Esc
View AutoHotkey.ahk
; Map Caps-Lock to ESC (single press) and Ctrl (long press)
SetCapsLockState, alwaysoff
Send {LControl Down}
KeyWait, CapsLock
Send {LControl Up}
if ( A_PriorKey = "CapsLock" )
alepez / freqtail.cpp
Created Jan 17, 2019
Count time between new lines
View freqtail.cpp
#include <chrono>
#include <iostream>
#include <thread>
int main() {
using namespace std::chrono;
std::string line;
auto t = steady_clock::now();
while (std::cin >> line) {
const auto now = steady_clock::now();
View encodeBase16.cpp
static void encodeBase16(char* const dst, const void* const src, const unsigned size) {
static const uint8_t table[] = "0123456789ABCDEF";
char* d = dst;
const uint8_t* s = static_cast<const uint8_t*>(src);
const uint8_t* const sEnd = s + size;
while (s < sEnd) {
const uint8_t c = *s;
*d = table[c >> 4];
alepez / game.c
Last active Dec 12, 2018
View game.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define for_x for (int x = 0; x < w; x++)
#define for_y for (int y = 0; y < h; y++)
#define for_xy for_x for_y
void show(void* u, int w, int h) {
int(*univ)[w] = u;
View gist:d7020a39fbcb988bed76554a829a357d
// When you don't have permissions to export to csv
$('#report-summary-popup table tr').map((i, e) => [$(e).find('td').map((i, e) => $(e).text().trim()).get()]).get().map(x => x.slice(1, x.length).join(',')).join('\n')
You can’t perform that action at this time.