Skip to content

Instantly share code, notes, and snippets.

Avatar

Donal Byrne byrnedo

View GitHub Profile
@byrnedo
byrnedo / tricks.sh
Created Feb 15, 2021
selenium standalone tricks
View tricks.sh
#!/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 Feb 15, 2021
Fill terminal input and return to interactive
View filli.sh
#!/bin/bash
# Sends foo bar and baz then back to you
(printf 'foo\nbar\nbaz\n' && cat) | $1
@byrnedo
byrnedo / indexed_sql_file_runner.go
Last active Oct 23, 2020
Run sql commands from a file, saving position in a `.index` file in case of error.
View indexed_sql_file_runner.go
package main
import (
"bufio"
"database/sql"
"flag"
"fmt"
"path"
"strconv"
"strings"
@byrnedo
byrnedo / nginx-json-log.conf
Last active May 20, 2020
Json Nginx Logging
View nginx-json-log.conf
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
Comprehensive http client base in go
View httpclient.go
package client
import (
"bytes"
"context"
"crypto/tls"
"encoding/json"
"fmt"
"github.com/pkg/errors"
"io"
@byrnedo
byrnedo / useCheckbox.ts
Created Apr 24, 2020
Hook for checkbox functionality
View useCheckbox.ts
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]);
@byrnedo
byrnedo / tutils.go
Created Jan 29, 2020
Small assertion helper for testing in go
View tutils.go
package tutils
import (
"path"
"reflect"
"runtime"
"testing"
)
func AssertNotNil(t *testing.T, obj interface{}) {
@byrnedo
byrnedo / aspnet-des-cookie-maker.js
Last active Jul 16, 2020
Javascript module to encrypt, decrtypt, serialize and deserialize a DES encrypted cookie from a Dotnet Aspnet application
View aspnet-des-cookie-maker.js
@byrnedo
byrnedo / Startup.vb
Created Jan 11, 2019
VB Dotnet Owin Auth0 Startup
View Startup.vb
Imports Microsoft.Owin
Imports Microsoft.Owin.Security.OpenIdConnect
Imports Owin
Imports Microsoft.Owin.Security
Imports Microsoft.Owin.Security.Notifications
Imports Microsoft.Owin.Security.Cookies
Imports Microsoft.IdentityModel.Protocols.OpenIdConnect
Imports Microsoft.IdentityModel.Tokens
Imports System.Threading.Tasks
@byrnedo
byrnedo / RequestLogMiddleware.cs
Last active Aug 10, 2018
Access log middleware for aspnetcore. Add it as your first middleware.
View RequestLogMiddleware.cs
namespace Foobar
{
public class RequestLogMiddleware
{
public class LogData {
public IPAddress RemoteAddr {get;set;}
public string User {get;set;}
public int ResponseStatus {get;set;}