Skip to content

Instantly share code, notes, and snippets.

View grunka's full-sized avatar

John Wästerlund grunka

View GitHub Profile
@grunka
grunka / check-cert-dates.fish
Last active April 14, 2022 13:42
Fish Functions
function check-cert-dates -d "Gets the start and end date for a SSL certificate on a domain"
echo "" | openssl s_client -servername $argv -connect $argv:443 2>/dev/null | openssl x509 -noout -dates
end
@grunka
grunka / Makefile
Last active March 12, 2021 14:23
A small makefile for building small Java projects and making runnable jars
.PHONY: all clean run jar
JAR_NAME=Main.jar
MAIN_CLASS=Main
BIN_PATH=bin
LIB_PATH=lib
NOTHING=
SPACE=$(NOTHING) $(NOTHING)
@grunka
grunka / WebSocketImplementation.java
Last active January 18, 2021 10:32
WebSockets in Dropwizard
@ServerEndpoint("/socket-endpoint")
public class WebSocketImplementation {
@OnOpen
public void onOpen(Session session) throws IOException {
session.getBasicRemote().sendText("Hello World");
}
@OnMessage
public void onMessage(Session session, String message) throws IOException {
@grunka
grunka / replace.py
Created July 2, 2018 08:55
mitmproxy script for replacing a specific url with the content from a local file
from mitmproxy import http
def request(flow: http.HTTPFlow) -> None:
if "example.com/path/file.html" in flow.request.pretty_url:
with open('replacement.html', 'r') as myfile:
html = myfile.read().replace('\n', '')
flow.response = http.HTTPResponse.make(
200, # status code
html, # content
{"Content-Type": "text/html"}
@grunka
grunka / strict-bash.sh
Created March 28, 2018 15:07
Strict mode bash
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
@grunka
grunka / extract-subdirectory-to-new-repo.sh
Created April 11, 2017 15:33
For that time when you have something in a sub directory of a large project and want to move it to the root of its own repository and only keep the history for that code in the new repository
#!/usr/bin/env bash
path_in_old_repo=some/sub/directory
old_repo=git@github.com:user/old_repo.git
new_repo=git@github.com:user/new_repo.git
new_directory=$(echo ${new_repo} | sed 's|^.*/\(.*\)\.git$|\1|g')
git clone ${old_repo} ${new_directory}
cd ${new_directory}
git remote set-url origin ${new_repo}
git filter-branch --subdirectory-filter ${path_in_old_repo} -- --all

Vem har tillgång till dina konton?

Om du är nyfiken på det så är här en lista med sidor för olika tjänster där du kan se det och även rensa bort det du inte känner igen eller använder längre.

@grunka
grunka / jobs.sh
Last active October 28, 2015 12:49
One way of launching simultaneous jobs in bash and then waiting for them to complete and also get logs
#!/usr/bin/env bash
submitted_jobs=""
submit() {
echo "> ${*}" > /tmp/job_XXX.log
eval "${*}" >> /tmp/job_XXX.log 2>&1 &
local id="${!}"
mv /tmp/job_XXX.log /tmp/job_${id}.log
if [[ -z "${submitted_jobs}" ]]; then

Keybase proof

I hereby claim:

  • I am grunka on github.
  • I am grunka (https://keybase.io/grunka) on keybase.
  • I have a public key whose fingerprint is 86C3 6799 927F 72C6 6CFC A7C8 5C87 DE42 CDE5 C52C

To claim this, I am signing this object: