Skip to content

Instantly share code, notes, and snippets.

@macros
macros / miniupnpd.nix
Created March 1, 2022 20:06
Miniupnpd with nftables override
# Rebuild the package with nftables support
# Module expects scripts named iptables_ so copy nft versions to those names
nixpkgs.config.packageOverrides = pkgs: {
miniupnpd = pkgs.miniupnpd.overrideAttrs (o:{
buildInputs = o.buildInputs ++ [ pkgs.libmnl pkgs.libnftnl pkgs.openssl ];
makefile = "Makefile.linux_nft";
configureFlags = [ "--firewall=nftables" ];
postFixup = ''
cp $out/etc/miniupnpd/nft_init.sh $out/etc/miniupnpd/iptables_init.sh
cp $out/etc/miniupnpd/nft_removeall.sh $out/etc/miniupnpd/iptables_removeall.sh
#include <stdio.h>
#include <fcntl.h>
#include <stdint.h>
int main(int argc, char **argv) {
int32_t l;
int fd;
if (argc != 2) {
fprintf(stderr, "Usage: %s <latency in us>\n", argv[0]);
@macros
macros / gist:553c2ef4d4b0594154f5
Created April 12, 2015 04:59
haproxy-gmetric
#!/usr/bin/ruby
require 'socket'
PROCESS_METRICS = {
'Uptime_sec' => %w(uptime seconds),
'ConnRate' => %w(connection_rate connections rate),
'SessRate' => %w(session_rate sessions rate),
'SslFrontendKeyRate' => %w(sslkey_rate lookups rate),
'SslCacheLookups' => %w(sslcache_lookups lookups counter),
#!/usr/bin/ruby
require 'openssl'
cert = OpenSSL::X509::Certificate.new File.read(ARGV[0])
cn = cert.subject.to_a.select{|oid, value| oid == "CN"}[0][1]
puts "Cert metadata"
puts cert.serial
puts cert.issuer
@macros
macros / bgpd.conf
Created September 26, 2012 23:54
bgp samples
!
! Zebra configuration saved from vty
! 2012/03/15 02:25:13
!
hostname bgpd
log file /var/log/quagga/bgpd.log
log stdout
!
router bgp 31377
bgp router-id 17.16.0.1
Hi Jason,
I wanted to reach out to see if you are open to exploring engineering
opportunities with Google. ?I support Google.com engineering and thought
your experience with ops engineering and keeping Fastly's systems up and
running would be a good fit for our team.
If you're interested, please let me know when you have a few minutes to
chat. ?Even If you aren't looking for a change at the moment let's still
connect on LinkedIn so we can follow up at a later date.
Regards,
?
APT
{
Install-Recommends “false”;
Install-Suggests "false";
};
Dpkg::Options {
"--force-confdef";
"--force-confold";
}
@macros
macros / gist:3165661
Created July 23, 2012 19:29
Rackspace, not home of the iops
Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await svctm %util
xvda 0.00 3.60 0.00 3.40 0.00 0.03 16.47 0.90 263.82 117.65 40.00
sub vcl_recv {
#FASTLY recv
}
sub vcl_hash {
#FASTLY hash
}
sub vcl_error {
command "bash -c \"pkill -f svlogd -P $(pgrep -f \'runsv #{params[:name]}\')\""
---- Begin output of bash -c "pkill -f svlogd -P $(pgrep -f 'runsv fst-statsd')" ----
STDOUT:
STDERR: bash: line 1: 26340: command not found
---- End output of bash -c "pkill -f svlogd -P $(pgrep -f 'runsv fst-statsd')" ----
Ran bash -c "pkill -f svlogd -P $(pgrep -f 'runsv fst-statsd')" returned 127