Skip to content

Instantly share code, notes, and snippets.

View zygiss's full-sized avatar

Žygis Škulteckis zygiss

View GitHub Profile
@zygiss
zygiss / gist:c3ddeb0729a7de3bc20be25bf23b11e6
Created July 19, 2023 20:24
Usage of `iff` in Python
PC/pyconfig.h
334:/* configure.ac defines HAVE_LARGEFILE_SUPPORT iff
Python/dtoa.c
1428: /* Skip leading zeros: lz is true iff there were leading zeros. */
1497: /* Skip zeros. lz is true iff there are leading zeros. */
Objects/obmalloc.c
1272:Subtracting B throughout, this is true iff
@zygiss
zygiss / post-install
Last active March 18, 2018 13:55
FreeBSD post-install script for DigitalOcean droplets
#!/bin/sh
#
# Put the URL to this script in your droplet's user-data, fetch & execute.
# Or fetch & execute it with `remote-exec` provisioner in Terraform.
PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
METADATA_URI="http://169.254.169.254/metadata/v1"
logger -t post_install "Starting post-install provisioning"
@zygiss
zygiss / sshfp_gen.sh
Created May 7, 2016 03:41
Quick script to prepare SSHFP DNS records on a host
#!/bin/sh
# https://www.iana.org/assignments/dns-sshfp-rr-parameters/dns-sshfp-rr-parameters.xhtml
set_sha() {
if [ "`uname -s`" = "Linux" ]; then
sha="sha${fp_algo}sum"
else
sha="sha${fp_algo}"
fi
### Keybase proof
I hereby claim:
* I am zygiss on github.
* I am zygis (https://keybase.io/zygis) on keybase.
* I have a public key whose fingerprint is 378F B284 6F8D 3564 7487 F9BC AD98 261E 0653 CEF4
To claim this, I am signing this object:
@zygiss
zygiss / rc.conf
Created August 28, 2015 19:34
lagg(4) for wired/wireless network roaming
ifconfig_ath0="ether be:ef:f5:ca:le:00 up"
ifconfig_em0="up"
wlans_ath0="wlan0"
cloned_interfaces="lagg0"
ifconfig_wlan0="powersave WPA up"
ifconfig_lagg0="laggproto failover laggport em0 laggport wlan0 DHCP"
@zygiss
zygiss / minion_states.py
Created August 5, 2015 19:27
Retrieve list of states applicable to a minion
from sys import argv
import salt.client
local = salt.client.LocalClient()
minion = str(argv[1])
states = []
result = local.cmd(minion, 'state.show_highstate')
for dict in result[minion].itervalues():
@zygiss
zygiss / ipv6_ping
Last active January 31, 2017 02:07
Configuring IPv6 on FreeBSD at Hetzner
ping6 -c 3 ietf.org
PING6(56=40+8+8 bytes) 2001:db8:dead:beef::1 --> 2001:1900:3001:11::2c
16 bytes from 2001:1900:3001:11::2c, icmp_seq=0 hlim=50 time=169.853 ms
16 bytes from 2001:1900:3001:11::2c, icmp_seq=1 hlim=50 time=172.739 ms
16 bytes from 2001:1900:3001:11::2c, icmp_seq=2 hlim=50 time=166.899 ms
--- ietf.org ping6 statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/std-dev = 166.899/169.830/172.739/2.384 ms