Skip to content

Instantly share code, notes, and snippets.

@vncsna
vncsna / bash_strict_mode.md
Created June 6, 2021 01:59 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation

set -e, -u, -o, -x pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euxo pipefail is short for:
set -e
set -u
@rikka0w0
rikka0w0 / ft2232_to_digilent_jtag.md
Last active April 23, 2024 14:05
FT2232 to Digilent JTag for Xilinx FPGAs (ISE/Vivado)

The Digilent JTag uses FT2232, but its configuration EEPROM contains secrete data needed to be recoginzed by Xilinx ISE/Vivado. The following method only works on linux (tested on Ubuntu16.04), but the patched FT2232 doggle also works on Windows. Since WSL1 does not provide USB device access, the following method will not work for WSL1.

DONT use FT_Prog on offical Digilent cable, as it can trash the firmware! The offical eeprom contains secrete data that cannot be handled correctly by FT_Prog.

Here are steps to create a Digilent-like Jtag that can be used in Xilinx ISE and Vivado

  1. Install softwares: sudo apt-get install libftdi1 ftdi-eeprom
  2. Create a file "flash_digilent.conf" with the following content:
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active April 23, 2024 11:47
set -e, -u, -o, -x pipefail explanation
@Mygod
Mygod / export-ble-infos.py
Last active April 22, 2024 17:14
Export your Windows Bluetooth LE keys into Linux!
#!/usr/bin/python3
"""
Copyright 2021 Mygod
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@ctechols
ctechols / compinit.zsh
Last active April 19, 2024 23:44
Speed up zsh compinit by only checking cache once a day.
# On slow systems, checking the cached .zcompdump file to see if it must be
# regenerated adds a noticable delay to zsh startup. This little hack restricts
# it to once a day. It should be pasted into your own completion file.
#
# The globbing is a little complicated here:
# - '#q' is an explicit glob qualifier that makes globbing work within zsh's [[ ]] construct.
# - 'N' makes the glob pattern evaluate to nothing when it doesn't match (rather than throw a globbing error)
# - '.' matches "regular files"
# - 'mh+24' matches files (or directories or whatever) that are older than 24 hours.
autoload -Uz compinit
@duairc
duairc / net.nix
Last active April 16, 2024 00:28
IP address arithmetic and validation in Nix
{ lib ? null, ... }:
let
net = {
ip = {
# add :: (ip | mac | integer) -> ip -> ip
#
# Examples:
@aras-p
aras-p / preprocessor_fun.h
Last active April 12, 2024 17:24
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@tomdaley92
tomdaley92 / README.md
Last active April 11, 2024 16:09
Proxmox - Email Alerts Setup (gmail)

Proxmox - Email Alerts Setup (gmail)

  1. SSH into proxmox node and become root user. Run the following commands to download extra software dependencies we'll need.

    apt update
    apt install -y libsasl2-modules mailutils
  2. Enable 2FA for the gmail account that will be used by going to security settings

@r15ch13
r15ch13 / iommu.sh
Last active April 11, 2024 09:23
List IOMMU Groups and the connected USB Devices
#!/usr/bin/env bash
shopt -s nullglob
lastgroup=""
for g in `find /sys/kernel/iommu_groups/* -maxdepth 0 -type d | sort -V`; do
for d in $g/devices/*; do
if [ "${g##*/}" != "$lastgroup" ]; then
echo -en "Group ${g##*/}:\t"
else
echo -en "\t\t"
@dzcpy
dzcpy / 超大字符集字体.md
Last active January 26, 2024 17:47
常用超大字符集字体

unicodecjkfonts

所谓“超大字符集字体”是指至少支持CJK-B的字体(约7万+字),常用的有如下几种:

中国大陆字形

  • 中易宋体(Windows 10 version 1809):部分支持CJK-E
13a81e63aae736ca2254492dd111d3ace4e9dbe9 *simsun.ttc
91a6e66e7c1139a27b6caa313dc451af36e4e5ed *simsunb.ttf