Skip to content

Instantly share code, notes, and snippets.

View Ultrabenosaurus's full-sized avatar

Dan Bennett Ultrabenosaurus

  • UK
View GitHub Profile
@Ultrabenosaurus
Ultrabenosaurus / set-dns.bat
Last active June 29, 2022 21:49
A quick and dirty Windows CMD batch script to quickly and easily swap between pre-configured DNS addresses on the main WiFi adaptor, designed for laptop users who have a Raspberry Pi or similar device as a DNS filter on their home network which can't be reached when away from home. Must be run with admin priviledges.
@echo off
:: ==========
:: Code to automatically request UAC elevation via PowerShell if launched without admin priviledges.
::
:: source: https://stackoverflow.com/a/24665214
:: license: https://creativecommons.org/licenses/by-sa/4.0/
:: changes: none
:: ==========
@Ultrabenosaurus
Ultrabenosaurus / MotionEye-IFTTT-Webhook.sh
Last active December 1, 2022 04:51
A script to trigger IFTTT webhook applets from MotionEye software
#!/bin/bash
##
#
# MotionEye-IFTTT-Webhook.sh
# A script to trigger IFTTT webhook applets from MotionEye software
#
# author: Ultrabenosaurus
# license: BSD 3-Clause
# source: https://gist.github.com/Ultrabenosaurus/5916101463f5d00732f901e7a3d8a2c2
@Ultrabenosaurus
Ultrabenosaurus / manifest.json
Last active April 10, 2020 22:43
Proof-of-Concept Firefox Add-On to Redirect Before Page Loads
{
"description": "Redirect AMP addresses to their non-AMP sources",
"manifest_version": 2,
"name": "AMP Redirect",
"version": "0.1",
"author": "Ultrabenosaurus",
"_comments_": {
"signed_xpi": "https://drive.google.com/file/d/1Pg19uXregtxfENnKO3tcvR2SiTu01IYf/view?usp=sharing",
"source:": "https://gist.github.com/Ultrabenosaurus/b94d373f3a32d2b5d6ae5256e04784a7",
@Ultrabenosaurus
Ultrabenosaurus / standard_ebooks_opds_downloader.py
Last active July 5, 2022 00:50 — forked from AnalogJ/download_opds.py
Download all ebooks from the Standard eBooks OPDS catalogue, organised into subfolders by author and book title.
#####
#
# Download all of the Standard eBooks catalogue from their OPDS feed.
#
# https://standardebooks.org/
#
# Modified to download all files for each book except the SVG cover and to
# organise the files in subfolders by Author > Book Title.
# The original script downloads only the EPUB file for each book into the
# working directory with no subfolders.
@Ultrabenosaurus
Ultrabenosaurus / mp4-to-gif.sh
Last active October 4, 2021 13:42
Simple bash script to convert MP4 videos to GIF
#!/bin/bash
#############################################
#
# mp4-to-gif
#
# Convert MP4 videos to GIF images
# Requires ffmpeg and imagemagick
#
# -g and --gifsicle options create a second optimised GIF for your consideration

Keybase proof

I hereby claim:

  • I am ultrabenosaurus on github.
  • I am ultrabenosaurus (https://keybase.io/ultrabenosaurus) on keybase.
  • I have a public key whose fingerprint is CD4A DCC2 EE8C 56D5 EAD6 2EB5 0BFA 5929 871C C7DB

To claim this, I am signing this object:

@Ultrabenosaurus
Ultrabenosaurus / chrome-colours.php
Last active February 26, 2016 12:17
A quick demo of the "theme-color" meta tag that can be used to colour the UI of Chrome for Android.
<?php
$colour = "#" . ( ( isset( $_GET['colour'] ) ) ? $_GET['colour'] : "000000" );
?>
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
@Ultrabenosaurus
Ultrabenosaurus / tree.sh
Created January 23, 2016 11:54
handy bash function to show the directory tree from your current location
# tree
# list the directory structure with the current location as the top level
# based on https://gist.github.com/gpupo/c546128385493c71246d
tree() {
if [ ! $# -eq 0 ]; then
case $1 in
-a) ls -aR | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/';;
-at) ls -a | grep "/$" | sed -e 's~/$~~' -e 's/^/--/g' -e 's/^/ /' -e 's/-/|/';;
-t) ls | grep "/$" | sed -e 's~/$~~' -e 's/^/--/g' -e 's/^/ /' -e 's/-/|/';;
*) ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/';;
@Ultrabenosaurus
Ultrabenosaurus / 4.5
Created January 15, 2016 12:08 — forked from TimBlock/4.5
// Your code here.
function every(array,predicate){
for(var i = 0; i<array.length; i++){
if (!predicate(array[i]))
return false;
}
return true;
}
function some(array,predicate){
@Ultrabenosaurus
Ultrabenosaurus / README.md
Last active August 29, 2015 14:16
[jQuery] manipulate complex HTML returned by AJAX

jQuery, AJAX & Complex HTML

So you need to grab some pretty complex HTML - likely a whole page - via AJAX and extract a certain portion of it for use.

You're already using jQuery for your project, or it's not a big deal to add, so you figure it's super-simple and powerful selector functions like find will make your life a whole lot easier.

I mean, you can just pass HTML into the top-level $() function and it'll turn into a jQuery DOM representation so you can just chain a find call onto that, right? Wrong.

Mostly due to the underlying browser APIs that jQuery has to rely on, complex HTML and especially entire pages get filtered into a big mess that makes using regex on the raw text response about as easy as using jQuery for it.