Skip to content

Instantly share code, notes, and snippets.

View byrnedo's full-sized avatar

Donal Byrne byrnedo

View GitHub Profile
@byrnedo
byrnedo / vaccination.sh
Created June 23, 2021 13:22
Swedish Vaccination Time Checker
#!/bin/bash
# FIXME
WEBHOOK_URL=YOUR_SLACK_WEBHOOK_URL_HERE
# A list of the clinics you're interested in polling, you'll find them via the 1177 links
for clin in 1546 500 493 2053 2056 521 528 506; do
apt=$(curl -s https://booking-api.mittvaccin.se/clinique/$clin/appointmentTypes |jq -r '.[] |select(.name == "1 pers Covid-19 30-64 år (född -57 till -91)")|.id')
echo $clin $apt
curl https://booking-api.mittvaccin.se/clinique/$clin/appointments/$apt/slots/210601-210731 -s |jq -e '.[].slots |any(.[]; .available == true)'|grep true
if [ $? -eq 0 ]; then
time=$(date +%s)
@byrnedo
byrnedo / tricks.sh
Created February 15, 2021 13:05
selenium standalone tricks
#!/bin/bash
# start a new session
curl --data '{"desiredCapabilities":{"browserName": "chrome"}}' --silent http://localhost:4444/wd/hub/session | jq -r .sessionId
@byrnedo
byrnedo / filli.sh
Created February 15, 2021 13:05
Fill terminal input and return to interactive
#!/bin/bash
# Sends foo bar and baz then back to you
(printf 'foo\nbar\nbaz\n' && cat) | $1
/* global grecaptcha */
/* global $ */
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['g-recaptcha'],
attributeBindings: ['siteKey:data-sitekey', 'data-theme', 'data-size', 'data-callback', 'data-expired-callback', 'data-tabindex'],
siteKey: '',
lang: 'sv',
resetTrigger: false,
@byrnedo
byrnedo / indexed_sql_file_runner.go
Last active October 23, 2020 06:10
Run sql commands from a file, saving position in a `.index` file in case of error.
package main
import (
"bufio"
"database/sql"
"flag"
"fmt"
"path"
"strconv"
"strings"
@byrnedo
byrnedo / aspnet-des-cookie-maker.js
Last active July 16, 2020 09:20
Javascript module to encrypt, decrtypt, serialize and deserialize a DES encrypted cookie from a Dotnet Aspnet application
@byrnedo
byrnedo / dockerHelpers.bash
Last active July 3, 2020 08:15
Docker helpers ( simple colour docker ps )
RED=`echo -e '\033[101m\033[37m'`
GREEN=`echo -e '\033[102m'`
DARK_RED=`echo -e '\033[41m\033[37m'`
DARK_GREEN=`echo -e '\033[42m'`
NORMAL=`echo -e '\033[0m'`
#Docker aliases
function dps(){
docker ps --format "{{.ID}}\t{{.Image}}\t{{.Labels}}"| \
sed -e "s/:/ :/" | \
@byrnedo
byrnedo / nginx-json-log.conf
Last active May 20, 2020 13:39
Json Nginx Logging
map $msec $millis { ~(.*)\.(.*) $2; }
map $time_iso8601 $time_iso8601_m { ~(.*)\+(.*) $1.$millis+$2; }
log_format json_combined escape=json
'{'
'"_ms": "$millis",' # Has to be here in order for timestamp to work. Wat
'"timestamp": "$time_iso8601_m",'
'"service": "sp-frontend",'
'"remote_addr":"$remote_addr",'
'"message":"[$status] $request_method $request_uri",'
@byrnedo
byrnedo / httpclient.go
Created May 12, 2020 07:07
Comprehensive http client base in go
package client
import (
"bytes"
"context"
"crypto/tls"
"encoding/json"
"fmt"
"github.com/pkg/errors"
"io"
@byrnedo
byrnedo / useCheckbox.ts
Created April 24, 2020 13:26
Hook for checkbox functionality
import React, {useCallback, useMemo} from 'react';
export const useCheckbox = (allValues: string[], selected: string[], onChange: (newSelection: string[]) => void) => {
const selectedStatesObj = useMemo(() => (selected || []).reduce((p, c) => ({
...p,
[c]: true
}), {} as {[id: string]: boolean}), [selected]);