This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns screenshots | |
(:require ["playwright" :as pw] | |
[promesa.core :as p])) | |
; NOTE: you'll need to npm install `nbb` and `playwright` | |
(defn wait-for-network-idle [page] | |
(p/do | |
(.waitForLoadState page "networkidle") | |
(p/delay 100))) ;; Add 100ms delay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta content="width=device-width, initial-scale=1" name="viewport"> | |
<title>Vintage console</title> | |
<script> | |
function log(message) { | |
document.getElementById("log").textContent += message + "\n"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns promises | |
{:clj-kondo/config '{:lint-as {promsea.core/let clojure.core/let | |
promesa.core/doseq clojure.core/doseq | |
promesa.core/loop clojure.core/loop | |
promesa.core/recur clojure.core/recur}}} | |
(:require [promesa.core :as p])) | |
(def panel-choices [1 2 3 4 5]) | |
; simple test function returns a promise with doubled input |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Bash hash-map which works in Bash 3. | |
# WARNING: this code is useless and you should not use it. See the comments. | |
# Hashing function from Adam Katz: https://stackoverflow.com/a/12945518 | |
ht() { | |
local h=0 i | |
for (( i=0; i < ${#1}; i++ )); do | |
let "h=( (h<<5) - h ) + $(printf %d \'${1:$i:1})" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# get broadcast addresses for each network | |
net=`ifconfig | grep -o -E "Bcast:(.*?) " | cut -f2 -d":"` | |
# loop over networks running the scan | |
for n in $net; | |
do | |
# first find SSH machines silently to prime the arp table | |
nmap -T4 -n -p 22 --open --min-parallelism 100 "$n/24" | grep -e "scan report for" -e "ssh" > /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get makefile's own path | |
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) | |
mkfile_dir := $(dir $(mkfile_path)) | |
# add virtualenv in folder "virtualenv" to the path | |
export PATH := $(mkfile_dir)/virtualenv/bin:$(PATH) | |
export VIRTUAL_ENV=$(mkfile_dir)/virtualenv | |
example: something.py | |
python something.py # <- this will be called with virtualenv activated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo -n $'d1:ad2:id20:\x23\x71\x0c\x1c\xb4\x50\x7d\x87\x29\xb8\x3f\x87\x2c\xc6\xa2\xa4\x4c\x39\x73\x67e1:q4:ping1:t1:01:y1:qe' | nc -u router.utorrent.com 6881 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
# Usage: | |
# zcat -f access.log.* | ./extract-latest-log-date.awk > latest-log.txt | |
BEGIN { | |
# pre-compute months field lookup | |
m=split("Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec",d,"|") | |
for(o=1;o<=m;o++){ | |
months[d[o]]=sprintf("%02d",o) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import argv | |
f = open(argv[1], "rb").read() | |
i = f.index(bytearray("CNAM", "utf8")) | |
for n in range(3): | |
x = f[i+n*20+8:i+n*20+28].decode("utf8") | |
print(n, x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Count the lines of source code checked into your repository | |
# Requires the `cloc` command as a dependency. | |
# You can pass extra arguments to cloc like this: | |
# git cloc --exclude-dir=build --exclude-ext=js | |
git ls-tree -r `git branch | grep '^*' | colrm 1 2` --name-only | sed 's/.*/"&"/' | xargs cloc "$@" |
NewerOlder