Skip to content

Instantly share code, notes, and snippets.

@corupta
corupta / aws-pricing.js
Created October 19, 2020 08:57
AWS EC2 Pricing Sort By Price
// go to https://aws.amazon.com/ec2/pricing/on-demand/ and run this in console
(() => {
let table = document.querySelector('div.js-active').children[0];
let bodies = table.getElementsByTagName('tbody');
bodies = Array.from(bodies);
bodies = bodies.map((b) => Array.from(b.children));
let rows = bodies.reduce((acc, x) => [...acc, ...Array.from(x.slice(1)).map((r) => [x[0].children[0].innerText, ...Array.from(r.children).map((c) => c.innerText)])], []);
let data = rows.map(([type, name, vcpu, ecu, memory, storage, price]) => ({ name, vcpu, ecu, memory, storage, price, type }));
data.sort(({ price: priceA }, { price: priceB }) => parseFloat(priceB.substr(1)) - parseFloat(priceA.substr(1)));
data.forEach(({name, vcpu, ecu, memory, storage, price, type }) => console.log(`price: ${price} name: ${name} - vcpus: ${vcpu} - ecu: ${ecu} - memory: ${memory} - storage: ${storage} - type: ${type}`));
@corupta
corupta / timenotes-io-start-tracking-helper.js
Last active July 19, 2023 16:29
Timenotes.io add start tracking button on tasks page
// download run javascript extension https://chrome.google.com/webstore/detail/run-javascript/lmilalhkkdhfieeienjbiicclobibjao?hl=en
// go to a page inside timenotes.io
// open run javascript extension and check "Enable on timenotes.io"
// copy this code inside the extension popup
// click save & run
// now, whenever you go to a project's task page and reload page, you'll get start tracking button
// note that I'm not affiliated with timenotes, just a fan of their work/happy user.
(() => {
const path = window.location.pathname;
if (path.match(/^\/projects\/[a-f0-9\-]+\/tasks_overview\/?$/)) {
@corupta
corupta / neo4j-4.0-ubuntu.sh
Last active December 20, 2020 21:29
Create neo4j 4.0 deployment (run it in aws ec2 ubuntu)
#!/usr/bin/env bash
wget -O - https://debian.neo4j.com/neotechnology.gpg.key | sudo apt-key add -
echo 'deb https://debian.neo4j.com stable 4.0' | sudo tee /etc/apt/sources.list.d/neo4j.list
apt-get update
apt-get -y install neo4j
cd /var/lib/neo4j/plugins || exit
wget https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/4.0.0.2/apoc-4.0.0.2-all.jar
echo 'dbms.security.procedures.unrestricted=apoc.*' >> /etc/neo4j/neo4j.conf
echo 'dbms.default_listen_address=0.0.0.0' >> /etc/neo4j/neo4j.conf
service neo4j restart
@corupta
corupta / neo4j-3.5-ubuntu.sh
Created December 20, 2020 20:37
Create neo4j 3.5 deployment (run it in aws ec2 ubuntu)
#!/usr/bin/env bash
wget -O - http://debian.neo4j.org/neotechnology.gpg.key | apt-key add -
echo 'deb http://debian.neo4j.org/repo stable/' > /etc/apt/sources.list.d/neo4j.list
apt-get update
apt-get -y install neo4j=1:3.5.14
cd /var/lib/neo4j/plugins || exit
wget https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.5.0.11/apoc-3.5.0.11-all.jar
wget https://github.com/neo4j-contrib/neo4j-graph-algorithms/releases/download/3.5.4.0/graph-algorithms-algo-3.5.4.0.jar
wget https://github.com/neo4j-contrib/spatial/releases/download/0.26.2-neo4j-3.5.2/neo4j-spatial-0.26.2-neo4j-3.5.2-server-plugin.jar
echo 'dbms.security.procedures.unrestricted=apoc.*, algo.*' >> /etc/neo4j/neo4j.conf
@corupta
corupta / subtitles-renamer.sh
Last active January 17, 2021 19:34 — forked from bigantal/subtitles-renamer.sh
Allow handling subtitles with no season markings, add no-season option to allow this.
#!/usr/bin/env bash
# Renames subtitles files according to tv shows names found in a directory and its subdirectories RECURSIVELY
# Acceped syntaxes for season/episode are: 304, s3e04, s03e04, 3x04, Season 03 Episode 04 (case insensitive)
#
# Usage:
# Put this gist somewhere in your $PATH, like /usr/local/bin/subtitles-renamer
# Chmod +x it
# cd ~/YourHolidaysTvShowsWithSubtitles
# subtitles-renamer
@corupta
corupta / limesurvey-auto-submit.js
Created February 25, 2021 10:17
Limesurvey auto-submit
/*
copy this to "Run Javascript" extension on a limesurvey survey page
when you click enable on "xxx" it will start working, disable by clicking the checkbox again.
*/
setTimeout(() => {
const a = "aeiou";
const b = "bcdfghjklmnpqrstvwxyz";
const ranf = (i, j, p=1) => Math.pow(Math.random(), p) * (j - i) + i;
const ran = (i, j, p=1) => Math.floor(ranf(i,j,p));
const ranG = (ls) => ls.map(l => l[ran(0,l.length)]).join('');
@corupta
corupta / compile-ffmpeg-nvenc-jetson.sh
Last active November 13, 2021 17:44
Jetson - FFMPEG for PyAV
#!/bin/bash
# This script builds an ffmpeg4 allowing us to install PyAV with pip3 install av
# I tried to make it use cuda, but failed, so far only libx264 works well (a fast cpu encoder).
# I'm using jetson agx 32 with jetpack 4.6 on ubuntu 18
# makesure jetpack packages are install (cuda part is removed from original script)
# it doesn't use nvmpi hardware encoder but rather tries to use gpu/cuda accelaration
# I couldn't make nvmpi version (ffmpeg-jetson repo) work successfully.
@corupta
corupta / wander-api-after-hackathon.patch
Created December 12, 2021 20:33
wander-api-after-hackathon.patch
diff --git a/src/helpers/similarityCheck.js b/src/helpers/similarityCheck.js
index 1e4063a..7430e3a 100644
--- a/src/helpers/similarityCheck.js
+++ b/src/helpers/similarityCheck.js
@@ -53,12 +53,12 @@ const similarityCheck = async (points, spell) => {
ctx.lineWidth = LINE_SIZE-4;
ctx.strokeStyle='#0c3240';
ctx.stroke();
- const buff = canvas.toBuffer('image/png', { compressionLevel: 3, filters: canvas.PNG_FILTER_NONE })
+ const buffer = canvas.toBuffer('image/png', { compressionLevel: 3, filters: canvas.PNG_FILTER_NONE })
@corupta
corupta / watermark_spread_spectrum.py
Created September 16, 2022 14:05 — forked from tam17aki/watermark_spread_spectrum.py
A python script to perform audio watermark embedding/detection on the basis of direct-sequence spread spectrum method.
#!/usr/bin/env python3
"""A python script to perform audio watermark embedding/detection
on the basis of direct-sequence spread spectrum method."""
# Copyright (C) 2020 by Akira TAMAMORI
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@corupta
corupta / bitefight_tavern.js
Last active March 11, 2024 03:34
Simple bot for BiteFight game.
(() => {
// A script I created to automatically play the tavern story in bitefight game.
// Copy the script into any chrome extension, and enable it in tavern page of bitefight game.
// Refresh, and let it level you up.
const desiredOptionsOrder = [
'Continue (3 AP)',
'Complete story',
'Continue',