Skip to content

Instantly share code, notes, and snippets.

View dentarg's full-sized avatar
🌦️
=:D><!

Patrik Ragnarsson dentarg

🌦️
=:D><!
View GitHub Profile
#!/usr/bin/env ruby
if %w(-h --help).include?(ARGV.first)
abort <<~USAGE
#{__FILE__} <FILE> to count IPs in given file
#{__FILE__} to count IPs using latest file on disk
DL=1 #{__FILE__} to download the AWS IP ranges
USAGE
end
@dentarg
dentarg / githubber.rb
Last active October 31, 2023 18:16 — forked from iain/githubber.rb
require 'mechanize'
require 'yaml'
$results = []
def find(a, link)
puts "find started on #{link}"
a.get link do |page|
page.search(:css, ".blog-post").each do |post|
h2 = post.search(:css, "h2").first
@dentarg
dentarg / split-pem
Created September 11, 2023 10:42
Ruby script to split certificate files (.pem)
#!/usr/bin/env ruby
require "openssl"
BEGIN_CERT = "-----BEGIN CERTIFICATE-----"
END_CERT = "-----END CERTIFICATE-----"
def debug(str)
return unless ENV.key?("DEBUG")
puts "[DEBUG] #{str}"
$ docker run --rm -it ruby:3.2.2 bash
Unable to find image 'ruby:3.2.2' locally
3.2.2: Pulling from library/ruby
918547b94326: Pull complete
5d79063a01c5: Pull complete
4eedd9c5abf7: Pull complete
9cdadd40055f: Pull complete
199731bb2986: Pull complete
dcf5010fd812: Pull complete
a6cfe86a8ac7: Pull complete
@dentarg
dentarg / .zshrc
Created April 19, 2010 17:45
My .zshrc file
#!/usr/local/bin/zsh
#
# jage <johan@imum.net> http://jage.se
# dentarg <patrik@starkast.net> http://dentarg.net
#
# Settings
#OPENBSD_CVS='anoncvs@anoncvs.se.openbsd.org:/cvs'
OPENBSD_CVS='anoncvs@anoncvs.de.openbsd.org:/cvs'
NETBSD_CVS='anoncvs@anoncvs.se.netbsd.org:/cvsroot'
@dentarg
dentarg / a-2019-01-02.txt
Last active April 10, 2023 09:44
A3 / T3 Cloudflare 1.1.1.1 issues
$ ifconfig en2
en2: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=4<VLAN_MTU>
ether a0:ce:c8:c0:7a:22
inet6 fe80::99:b10a:761a:3a90%en2 prefixlen 64 secured scopeid 0xc
inet 213.21.109.70 netmask 0xffffff80 broadcast 213.21.109.127
nd6 options=201<PERFORMNUD,DAD>
media: autoselect (1000baseT <full-duplex>)
status: active
@dentarg
dentarg / close_notifications_applescript.js
Created February 11, 2022 13:36 — forked from lancethomps/close_notifications_applescript.js
AppleScript to close all notifications on macOS Big Sur
function run(input, parameters) {
const appName = "";
const verbose = true;
const scriptName = "close_notifications_applescript";
const CLEAR_ALL_ACTION = "Clear All";
const CLEAR_ALL_ACTION_TOP = "Clear";
const CLOSE_ACTION = "Close";
@dentarg
dentarg / .zshenv
Last active October 26, 2022 18:38
How to Ruby on Apple silicon
# Need to use ~/.zshenv, ~/.zprofile is not sourced when doing "arch -x86_64 /bin/zsh"
#
# From 'man zsh' (zsh 5.8.1 (x86_64-apple-darwin21.0))
#
# Commands are then read from $ZDOTDIR/.zshenv. If the shell is a login
# shell, commands are read from /etc/zprofile and then $ZDOTDIR/.zprofile.
# Then, if the shell is interactive, commands are read from /etc/zshrc and
# then $ZDOTDIR/.zshrc. Finally, if the shell is a login shell,
# /etc/zlogin and $ZDOTDIR/.zlogin are read.
@dentarg
dentarg / general_log.rb
Last active October 18, 2022 00:58
Analyze MySQL General Query Log
# encoding: utf-8
require 'main'
require 'terminal-table'
# SELECT ...|DELETE FROM tbl
# INSERT INTO tbl
# UPDATE tbl
def read_tables
@dentarg
dentarg / fly.bash
Last active September 27, 2022 19:02
TLS fail with Fly.io, why?
$ host debug.fly.dev
debug.fly.dev has address 188.93.151.254
debug.fly.dev has IPv6 address 2a09:8280:1:763f:8bdd:34d1:c624:78cd
$ curl -o /dev/null -s -v --http1.1 --header 'Host: debug.fly.dev' https://188.93.151.254
* Trying 188.93.151.254:443...
* Connected to 188.93.151.254 (188.93.151.254) port 443 (#0)
* ALPN: offers http/1.1
} [5 bytes data]
* TLSv1.3 (OUT), TLS handshake, Client hello (1):