Skip to content

Instantly share code, notes, and snippets.

@ytti
ytti / pcapop
Last active March 15, 2018 12:39
script to offer unified API to pcap and pcapng, and to pop N bytes out of each captured file (useful to remove e.g. ERSPAN monitoring headers)
#!/usr/bin/env ruby
require "logger"
require "stringio"
class PCAPop
class Error < StandardError; end
class InvalidFormat < Error; end
class ByteOrderError < Error; end
@ytti
ytti / gist:7829e8484378c9b50d162555ee3eb8f1
Created March 18, 2018 13:11
Automated contributor contract verification
Problem statement: You require that your contributors sign a contract, perhaps to relinquish the copyright, perhaps to accept the licensing terms. This disincentivizes contributing due to creating barrier of entry.
Paid repositories could have opt-in feature for 'approved contributors only'. If repository owner has opted-in, then every pull request signature is verified to come from pre-approved developer. If pull request is not from appreved developer the developer is presented with a process to become approved developer.
The process starts with a web page where developer writes personal string or draws personal picture, after that is done, the web page queries for an email address and then repsents random string used for signature later.
After the email arrives to a developer, developer clicks on the URL and is directed to a web page, which presents the personal string or personal picture and developer is asked if they made it. If they answer 'yes', they are presented with terms of agreement, if they acce
@ytti
ytti / gdns.rb
Created July 8, 2021 15:32
CLI UX to Google Cloud DNS
#!/usr/bin/env ruby
require "google/cloud/dns"
require "commander"
#require "pry"
#
class GDNS
PROJECT = "resonant-petal-318815"
AUTH = File.join(Dir.home, ".config", "google_cloud_sdk_auth.json")
TTL = 1800
@ytti
ytti / cvm.rb
Last active May 19, 2024 07:21
#!/usr/bin/env ruby
## CVM is algorithm to estimate amount of unique items in list of items. It is so simple and cheap that
## it could reasonably be implemented in silicon, so that cheap switches and routers could report fps or flows
## per second counter in addition to bps and pps. Understanding total flow count allows you to do understand
## statistical probability and confidence in your ability to reason from ipfix sampled data, if you don't know
## your total flow count, you don't know what share of flows you see, and most things cannot be reasoned from ipfix
## My implementation almost certainly is wrong, as I don't understand the paper, and Quanta version is wrong
## - https://arxiv.org/abs/2301.10191
## - https://www.cs.toronto.edu/~meel/Slides/meel-distinct.pdf