Skip to content

Instantly share code, notes, and snippets.

@AndrewStanton94
AndrewStanton94 / SortEventbriteLikes.js
Last active January 9, 2021 03:24
Go to your EventBrite favourite events page. Scroll to the bottom and load more events until you have a full list. Then paste this code into the developer console. This puts the events in ascending chronological order.
document.querySelector('.eds-g-group').append(
...[...document.querySelectorAll('.eds-g-cell.eds-g-cell--has-overflow.eds-g-cell-1-1.eds-g-cell-mn-9-12')]
.map((elem) => ({
date: new Date(elem.querySelector('.eds-text-bs--fixed.eds-text-color--ui-600.eds-l-mar-top-1').innerText),
elem
}))
.sort((a,b) => -(b.date - a.date))
.map(({elem}) => elem)
)
@AndrewStanton94
AndrewStanton94 / AddjQuery.js
Created July 29, 2020 16:25
For prototyping transformations to run with cherrio
const jq = document.createElement('script');
jq.src = 'https://code.jquery.com/jquery-3.5.1.min.js';
document.head.appendChild(jq);
<?php
$servername = "localhost";
$username = "";
$password = "";
$dbname = "";
function drawRow($row){
?>
<article>
<h2><?php echo $row["id"]. " " . $row["name"]?></h2>
@AndrewStanton94
AndrewStanton94 / gmailFilterExtractor.js
Created April 24, 2020 15:30
Step 1 for analysing gmail filters
[...document.querySelectorAll('.qV')]
.map((elem) => ({
matches: elem.querySelector('.qW').innerText,
action: elem.innerHTML.split('<br>')[1]
}))
@AndrewStanton94
AndrewStanton94 / youTubeWatchLaterExport.js
Last active April 9, 2020 18:12
Exporting my Youtube Watch Later list. This gets the URL and the title if you're in the playlist.
[...document.querySelectorAll('.yt-simple-endpoint.style-scope.ytd-playlist-video-renderer')]
.map((elem) =>
`${elem.querySelector('#video-title').innerText} ${elem.href}`
.replace(/&list=WL.*/, ''))
.join('\n')
# From https://stackoverflow.com/a/35165401
curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash -
sudo yum install gcc-c++ make
sudo yum -y install nodejs
@AndrewStanton94
AndrewStanton94 / dockerInstall.sh
Last active August 16, 2019 11:19
Amazon linux ec2 docker setup
# amazon-linux-extras doesn't seem to be around now
# Hopefully depricated?
sudo yum update -y
sudo yum install docker
sudo service docker start
sudo usermod -a -G docker ec2-user
processTable = (table) => {
rows = table.querySelector('tbody').children;
rows = [...rows].map((r) => {
const link = r.children[0].children[0]; // Get the hyperlink from cell 1
let {href, innerText} = link;
innerText = innerText.split(' ').filter((x) => !(['Professor', 'Dr', 'Mr', 'Mrs', 'Miss', 'Ms'].includes(x))).join(' ');
return {href, innerText}
})
output = rows.map(({href, innerText}) => `${innerText} ${href}`).join('\n');
console.log(output);
alert('hello world');
{
"extends": ["eslint:recommended", "google"],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"rules": {
"no-console": "off"