Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
// a is an input parameter
// b is an input parameter
// return the result
int divide_1(int a, int b) {
return a / b;
}
// But what if we need to return an error code?
@alepez
alepez / nixos-encrypted-zfs.md
Created June 21, 2021 12:57
nixos on fully encrupted zfs

NixOs neon

Partitions

DISK=/dev/disk/by-id/ata-VBOX_HARDDISK_VBf3bca3fc-20a6ea2d
parted -s ${DISK} -- mklabel gpt
parted -s ${DISK} -- mkpart primary 512MiB -8GiB
parted -s ${DISK} -- mkpart primary linux-swap -8GiB 100%
parted -s ${DISK} -- mkpart ESP fat32 1MiB 512MiB
@alepez
alepez / android-mosquitto-cmake.sh
Created February 22, 2017 00:37
Build mosquitto for android
cmake -DANDROID_NDK=/opt/android-ndk/android-ndk-r10e -DANDROID_ABI="armeabi" -DANDROID_NDK_HOST_X64="YES" -DANDROID_TOOLCHAIN_NAME="arm-linux-androideabi-4.9" -DCMAKE_TOOLCHAIN_FILE="/opt/android-ndk/build/cmake/android.toolchain.cmake" -DWITH_TLS=OFF -DWITH_THREADING=OFF ..
@alepez
alepez / redmine_identifier_update.sql
Created July 24, 2013 16:03
Redmine: change project identifier with sql query.
UPDATE projects SET identifier = 'new_identifier' WHERE identifier = 'current_identifier';
@alepez
alepez / nmea2kutils.sh
Created March 3, 2021 11:17
nmea2kutils
#!/bin/bash
init() {
ip link set can0 type can bitrate 250000
ip link set can0 up
}
rawdump() {
candump can0
}
@alepez
alepez / chromium-gpu-vivante.sh
Created November 16, 2017 14:06
Chromium Hardware Acceleration i.MX6 Vivante
#!/bin/sh
if [ "${1}" == "forever" ]; then
while sleep 1; do "${0}"; done
exit 0
fi
export DISPLAY=:0
# url="http://jsfiddle.net/gionaf/Ugc5g/embedded/result/"

Unmanaged C code:

typedef void(read_fun_t)(void* user_data, const char* data, int data_len);

int native_consume_all(native_handler handler, void* user_data, read_fun_t* read_fun);

Managed C++ code:

@alepez
alepez / VBoxFixWinSize.md
Created April 8, 2020 08:38
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.

@alepez
alepez / brother-top-margin-cut-off-FIX.md
Created January 26, 2018 22:17
Brother MFC-J480DW cuts off top margin

Brother MFC-J480DW cuts off top margin

In Linux, my Brother MFC-J480DW cuts off top margin when used with A4 paper, even if all settings are set to A4.

To make it work, I had to edit /opt/brother/Printers/mfcj480dw/inf/brmfcj480dwrc file (that's the path in Gentoo, it could be different in other distributions).

And change:

PaperType=Letter
@alepez
alepez / nmea2kutils.sh
Created July 31, 2019 08:53
nmea2kutils
#!/bin/bash
init() {
ip link set can0 type can bitrate 250000
ip link set can0 up
}
rawdump() {
candump can0
}