Skip to content

Instantly share code, notes, and snippets.

@raidoz
raidoz / endianness.h
Last active July 22, 2019 14:17 — forked from jtbr/endianness.h
cross-platform / cross-compiler standalone endianness conversion
/**
* @file endianness.h
* @brief Convert Endianness of shorts, longs, long longs, regardless of architecture/OS
*
* Defines (without pulling in platform-specific network include headers):
* bswap16, bswap32, bswap64, ntoh16, hton16, ntoh32 hton32, ntoh64, hton64
*
* Should support linux / macos / solaris / windows.
* Supports GCC (on any platform, including embedded), MSVC2015, and clang,
* and should support intel, solaris, and ibm compilers as well.
@raidoz
raidoz / gist:f99f1023b66a3ad8ee47816421eda35b
Created August 21, 2017 10:48
Copy with rsync over custom ssh port with bandwidth limit
rsync -avz -e "ssh -p 222" hostname.inter.net:/data/filename.ext . --progress --bwlimit=1000
# Server /etc/ssh/sshd_config
AllowTCPForwarding yes
# PermitOpen any
ssh PROXY_HOSTNAME -D 8888
google-chrome --proxy-server="socks5://localhost:8888"
@raidoz
raidoz / gist:a4b15bf24ba51c293a8a6367be7994d1
Created December 7, 2016 14:46
Makefile user interaction
# Make the clean target work without having to specify anything
ifneq ($(filter clean,$(MAKECMDGOALS)),)
IMPORTANT_PARAMETER=none
endif
ifndef IMPORTANT_PARAMETER
INTERACT_WITH_USER=1
endif
ifeq ($(INTERACT_WITH_USER),1)
# Inside the directory that needs to be hashed
# recursive, show estimated time, relative paths
md5deep -rle -W /path/to/result.md5 *
# List files with the same hash, printing the hash-path of each file (remember to keep at least one of them)
sort result.md5 | uniq -D -w 32
# Count the number of duplicate files, path to first encountered file with that hash is shown only | sort by frequency
sort result.md5 | uniq -cd -w 32 | sort -nr
@raidoz
raidoz / rfrlocal_BOD18.sh
Created October 13, 2016 08:44
Programm RFR2 controller with brown-out at 1.8V
#!/bin/bash
if [[ ($# -eq 2) ]]; then
echo "$0 $@"
else
echo "Specify IMAGE PROGRAMMER"
echo "$0 main.srec mote_0101_ABCD"
exit 1
fi
@raidoz
raidoz / rfrlocal_BOD24.sh
Created October 13, 2016 08:42
Programm RFR2 controller with brown-out at 2.4V
#!/bin/bash
if [[ ($# -eq 2) ]]; then
echo "$0 $@"
else
echo "Specify IMAGE PROGRAMMER"
echo "$0 main.srec mote_0101_ABCD"
exit 1
fi