Skip to content

Instantly share code, notes, and snippets.

View shearichard's full-sized avatar

Richard Shea shearichard

View GitHub Profile
@shearichard
shearichard / detect_base64.py
Created November 24, 2023 03:11
Using Python to guess whether a string in Base64
# Found at https://stackoverflow.com/a/45928164/364088
#
# Not flawless
#
import base64
#
def isBase64(sb):
try:
if isinstance(sb, str):
# If there's any unicode here, an exception will be
#0 19.60 Downloading gunicorn-19.8.1-py2.py3-none-any.whl (112 kB)
#0 19.61 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 112.9/112.9 KB 10.8 MB/s eta 0:00:00
#0 19.67 INFO: pip is looking at multiple versions of gunicorn to determine which version is compatible with other requirements. This could take a while.
#0 19.71 Downloading gunicorn-19.8.0-py2.py3-none-any.whl (112 kB)
#0 19.73 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 112.8/112.8 KB 10.3 MB/s eta 0:00:00
#0 19.83 Downloading gunicorn-19.7.1-py2.py3-none-any.whl (111 kB)
#0 19.85 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 112.0/112.0 KB 12.0 MB/s eta 0:00:00
#0 19.93 Downloading gunicorn-19.7.0-py2.py3-none-any.whl (112 kB)
#0 19.94 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 112.1/112.1 KB 10.5 MB/s eta 0:00:00
#0 20.03 Downloading gunicorn-19.6.0-py2.py3-none-any.whl (114 kB)
@shearichard
shearichard / pipetotmp.sh
Created August 30, 2022 03:59
Shell script to create tmp output with date/time stamp
#!/bin/sh
#
# Pipe output from another command into this shell script
# and find the resulting output in a date/time stamped file
# in the tmp directory
#
# Eg
#
# $ ls -l | ./pipetotmp.sh
#
@shearichard
shearichard / debug-cors-with-curl.sh
Created August 28, 2022 21:46
A script to assist with debugging a CORS request using CURL
#!/bin/bash
# WF 2018-09-20
# This script isn't mine, I found it at https://stackoverflow.com/a/47609921/1497139
#ansi colors
#http://www.csc.uvic.ca/~sae/seng265/fall04/tips/s265s047-tips/bash-using-colors.html
blue='\033[0;34m'
red='\033[0;31m'
green='\033[0;32m' # '\e[1;32m' is too bright for white bg.
endColor='\033[0m'
@shearichard
shearichard / details-html-tag-example.html
Last active August 22, 2022 23:19
An Example of using the 'details' HTML tag
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<cite>https://html.spec.whatwg.org/#details-notification-task-steps</cite
<section class="progress window">
<h2>An example of using the 'details' HTML tag</h2>
@shearichard
shearichard / python-windows-registry-setting-example.py
Created August 18, 2022 21:29
Python used to set the "Use a Proxy Server for your LAN" settings in Windows 10 Internet Options (not yet working due to permissions issues)
########################################################################################################
# Python 3.10.
# The 'SetValueEx' doesn't work due to permissions issues. It appears that the answer to that
# is here https://stackoverflow.com/a/41871758 but I haven't tried it.
#
# I found this https://www.blog.pythonlibrary.org/2010/03/20/pythons-_winreg-editing-the-windows-registry/
# to be useful.
#
########################################################################################################
@shearichard
shearichard / q_dq_example.py
Created March 30, 2022 21:25
Example of queueing / de-queing in Python
import threading, queue
import random
import time
'''
Representaive output
$ python queue_example.py
> Submission of 0 pausing for 3
@shearichard
shearichard / django-sockpuppet-demo-list-filter.html
Created March 11, 2021 02:15
Some html associated with the increment demo of Django-Sockpuppet (line 9 and 23 is relevant)
<div>
<span class="" data-target="book-search.activity" hidden="">
<i class="fas fa-spinner fa-spin"></i>
Searching for books...
</span>
<span class="" data-target="book-search.count">
<strong>69,979</strong> books found
@shearichard
shearichard / django-sockpuppet-demo-increment.html
Created March 11, 2021 02:08
Some html associated with the increment demo of Django-Sockpuppet (line 31is the significant part)
<header class="flex py-1">
<img alt="" src="https://i.imgur.com/FX0KFM7m.jpg" style="filter: grayscale(0.9) contrast(1.2); height: 4rem;"/>
<h1 class="leading-none m-0 pl-1 self-center">
<a href="/">Sockpuppet</a>
<small>Expo</small>
</h1>
</header>
<hr/>
<flex-container>
@shearichard
shearichard / README.md
Last active November 29, 2020 22:33
Ember.js : Passing actions up through nested components

Ember.js - passing actions through nested components

Overview

This is a set of files which illustrate how actions are passed through a series of nested components. I'm putting this in a gist because this is one of those things which I often scratch my head over when I have to do it from scratch.

The example makes use of a set of components, each nested inside the other. The innermost component, test-component-inner exposes a button with the label 'PRESS ME', clicking the button has the result that a log message is written to the console by the outermost component, test-component-outer.

Application.hbs