Skip to content

Instantly share code, notes, and snippets.

@tarnacious
tarnacious / configuration.nix
Last active September 25, 2023 11:24
Building NixOS qcow2 images with flakes
{ config, lib, pkgs, ... }: {
boot.kernelPackages = pkgs.linuxPackages_5_15;
users.users = {
tarn = {
isNormalUser = true;
extraGroups = [ "wheel" ];
password = "";
};
};
FROM node:latest
WORKDIR /app
COPY . .
RUN yarn
CMD ["node", "index.js"]
@tarnacious
tarnacious / check.py
Last active June 9, 2021 07:58
Check for a desturbance in the CORS
import requests
from datetime import datetime
def check(domain, referer):
url = 'https://' + domain + '/mesh/v1/category?location=com'
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0',
'Accept': '*/*',
'Accept-Language': 'en-US,en;q=0.5',
'Access-Control-Request-Method': 'GET',
@tarnacious
tarnacious / comments.py
Created January 29, 2020 09:57
scan comments in pyyaml
import yaml
from yaml.composer import Composer
from yaml.reader import Reader
from yaml.scanner import Scanner
from yaml.parser import Parser
from yaml.constructor import SafeConstructor
from yaml.resolver import Resolver
class CommentsScanner(Scanner):
def scan_to_next_token(self):
@tarnacious
tarnacious / main.py
Created January 29, 2020 08:46
maintain key order in pyyaml for python 2.7+
import yaml
from collections import OrderedDict
class OrderedDumper(yaml.SafeDumper):
pass
def _dict_representer(dumper, data):
return dumper.represent_mapping(
yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
data.items())
@tarnacious
tarnacious / build-qcow2.nix
Last active February 22, 2024 01:22
Build a bare bones bootable nixos qcow2 image suitable for running with libvirt/qemu/kvm.
{ config, lib, pkgs, ... }:
with lib;
{
imports =
[
<nixpkgs/nixos/modules/installer/cd-dvd/channel.nix>
./machine-config.nix
];
$ curl -v https://www.example.com -k --proxy debugproxy.com:8080
* Trying 2a01:4f8:120:6104::2...
* TCP_NODELAY set
* connect to 2a01:4f8:120:6104::2 port 8080 failed: Connection refused
* Trying 178.63.44.71...
* TCP_NODELAY set
* Connected to debugproxy.com (178.63.44.71) port 8080 (#0)
* allocate connect buffer!
* Establish HTTP proxy tunnel to www.example.com:443
> CONNECT www.example.com:443 HTTP/1.1
#!/bin/bash
INCLUDES=${INCLUDES:="less,vim,sudo,openssh-server,acpid,dbus"}
ARCH=${ARCH:=amd64}
IMGSIZE=${IMGSIZE:=80G}
clean_debian() {
echo "Cleaning up.."
[ "$MNT_DIR" != "" ] && chroot $MNT_DIR umount /proc/ /sys/ /dev/ /boot/
sleep 1s
@tarnacious
tarnacious / all_rails_patches
Created September 13, 2018 20:18
How big are all the rails patches combined into a file and compressed?
# clone
git clone https://github.com/rails/rails
# change working dir
cd rails
# grab all the branches
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do
git branch --track ${branch#remotes/origin/} $branch
done
@tarnacious
tarnacious / delete-jobs.py
Created April 30, 2018 15:02
Delete all the CI/CD logs for a gitlab project
# Delete all the CI/CD logs for a gitlab project
#
# Requires:
# python 3
#
# requests==2.18.4
# lxml==4.2.1
# cssselect==1.0.3
#