Skip to content

Instantly share code, notes, and snippets.

@hiqua
hiqua / init.vim
Created April 17, 2025 01:11
.vimrc / init.vim fix to restore vim colors after neovim update to 0.10.0+
" From https://old.reddit.com/r/neovim/comments/1d66jlw/color_scheme_problems_in_0100/
lua <<EOF
vim.o.termguicolors = false
EOF
colorscheme vim
@hiqua
hiqua / zyxel_clear_dhcp.sh
Created March 19, 2025 18:22
Remove all static DHCP leases on a Zyxel router
#!/usr/bin/expect
# Remove all static DHCP leases on a Zyxel router.
set timeout 10
set password "MY_PASSWORD"
spawn ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa [email protected]
expect "password:"
send "$password\r"
expect "ZySH>"
for {set i 1} {$i <= 254} {incr i} {
(setq inhibit-startup-message t)
(tool-bar-mode -1)
; load markdown export from org mode
(eval-after-load "org"
'(require 'ox-md nil t))
; (package-initialize)
; (require 'evil)
; (evil-mode 1)
@hiqua
hiqua / accounts_as_files.sh
Created July 8, 2021 16:12
Reconstruct a hledger balance as a file hierarchy where the files' size are proportional to the accounts' balances
#!/bin/bash
set -e
set -u
set -o pipefail
hledger b -S expenses --value=end,"CHF" --infer-value -O csv --flat |\
head -n -1 |\
tail -n +2 |\
sed 's/CHF//' |\
sed 's/:/\//g' |\
@hiqua
hiqua / mpd_delete_duplicates.sh
Last active January 26, 2025 05:56
Delete duplicates from mpd playlist
mpd_first_duplicate(){
mpc -f "%position% \t %file%" playlist | awk ' {
pos=$1
$1=""
map[$0]=map[$0]+1 ;
if (map[$0] > 1) {
print pos ;
exit
}
}'
pragma solidity ^0.4.23;
contract Hot {
event CreateEvent(uint id, uint bid, string name, string link);
event SupportEvent(uint id, uint bid);
struct Record {
uint index;
uint bid;
contract Partner {
function exchangeTokensFromOtherContract(address _source, address _recipient, uint256 _RequestedTokens);
}
contract Target {
function transfer(address _to, uint _value);
}
contract COE {
@hiqua
hiqua / expecting.md
Created September 11, 2017 11:53 — forked from ksafranski/expecting.md
Basic principles of using tcl-expect scripts

Intro

TCL-Expect scripts are an amazingly easy way to script out laborious tasks in the shell when you need to be interactive with the console. Think of them as a "macro" or way to programmaticly step through a process you would run by hand. They are similar to shell scripts but utilize the .tcl extension and a different #! call.

Setup Your Script

The first step, similar to writing a bash script, is to tell the script what it's executing under. For expect we use the following:

#!/usr/bin/expect
@hiqua
hiqua / .python_startup.py
Created January 13, 2017 10:25
Load modules in when starting the python interpreter, if available.
MOD_LIST = [
['math'],
['tensorflow', 'tf'],
]
def load_module(module):
import importlib
assert len(module) in (1, 2), module
try:
# Explore the theories given.
# ISABELLE_BIN_PATH must contain the path to the Isabelle binary.
isplore(){
for f in $@; do
theory_name=`echo "$f" | sed 's/.thy//'`
theory_name=`basename -s ".thy" "$f"`
new_theory_name=$theory_name"_tmp"
new_filename=$new_theory_name".thy"
cp "$f" /tmp/$new_filename
sed -i'' "s/$theory_name/$new_theory_name/" /tmp/$new_filename