Skip to content

Instantly share code, notes, and snippets.

View archy-bold's full-sized avatar

Simon Archer archy-bold

View GitHub Profile
@archy-bold
archy-bold / remove-all-listeners.js
Created May 29, 2024 12:13
Remove all event listeners from element in JavaScript, retain listeners on child elements
// Working for document.body
var nodes = [];
document.body.childNodes.forEach((node) => nodes.push(node));
document.body.innerHTML = "";
document.body.outerHTML = document.body.outerHTML;
nodes.forEach((node) => document.body.appendChild(node));
@archy-bold
archy-bold / remove-nyt-modal.js
Created May 29, 2024 11:19
iOS Shortcut to remove modal from NYT Wordlebot
var result = ""
// Hide the modal
document.getElementById("standalone-footer").setAttribute("style", "display: none !important");
// Ensure the content doesn't have extra CSS
var content = document.getElementById("site-content");
content.style.removeProperty("position");
content.style.removeProperty("width");
content.style.removeProperty("margin-top");
// Recreate the body to remove any touchmove events on body
@archy-bold
archy-bold / get-wordle-answers.js
Created May 21, 2024 08:19
Get answers array from Wordle game
var answers = [];
if (window.localStorage.getItem("gameState") === null) {
answers = getWordleState().states[0].data.boardState;
}
else {
answers = JSON.parse(window.localStorage.getItem("gameState")).boardState;
}
function getWordleState() {
for (var i = 0; i < window.localStorage.length; i++) {
@archy-bold
archy-bold / fill-in-scoredle.js
Created May 21, 2024 08:05
JavaScript to fill in Scoredle
var answers = ['stare', 'moldy', 'bidon', 'dingo', '', ''];
for (var i = answers.length - 1; i >= 0; i--) {
if (answers[i] != '') {
changeInput('#answer', answers[i]);
break;
}
}
for (var i = 0; i < answers.length; i++) {
if (answers[i] != '') {
@archy-bold
archy-bold / set-access-point.sh
Last active February 10, 2023 08:44
Script to find the access points for the given network SSID and set the BSSID for that network to the MAC of the access point with the highest strength
#!/bin/bash
# Usage: ./set-access-points.sh [network SSID] [network interface id = wlan0]
# Read in the arguements
ssid=$1;
interface=$2;
# SSID is required
if [ -z "$ssid" ]; then
<?php
class Php_ExcelWriter implements ExcelWriterInterface
{
protected $spreadsheet;
protected $writer;
protected $templateSheet = -1;
public function __construct()
{
@archy-bold
archy-bold / libxl-php-install.sh
Last active February 1, 2020 12:14
Install LibXL for PHP
#!/bin/sh
# Ensure we've got libxml2
apt-get update
apt-get install libxml2-dev
# Make /src directory, if required
mkdir /src
cd /src
@archy-bold
archy-bold / ExamplePassportTest.php
Last active October 15, 2022 03:49
Testing Passport Authenticated Controllers and Routes in Laravel
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ExamplePassportTest extends \PassportTestCase
{
use DatabaseTransactions;
m.directive('ionSticky', ['$ionicPosition', '$compile', '$timeout', function ($ionicPosition, $compile, $timeout) {
return {
restrict: 'A',
require: '^$ionicScroll',
link: function ($scope, $element, $attr, $ionicScroll) {
var scroll = angular.element($ionicScroll.element);
var clone;
// creates the sticky clone and adds it to DOM
var createStickyClone = function ($element) {
clone = $element.clone().css({
@archy-bold
archy-bold / create-slimvc.sh
Last active September 16, 2015 16:48
Script to clone a SliMVC instance and do some basic setup, including changing project name and setting up the git repositry.
#!/bin/bash
# Input the project details
echo "Enter the project name:"
read name
echo "Enter a description for the project:"
read description