Skip to content

Instantly share code, notes, and snippets.

View Pamblam's full-sized avatar
🕶️
Coding

Rob Parham Pamblam

🕶️
Coding
View GitHub Profile
@Pamblam
Pamblam / Convert AAX to M4B.sh
Last active October 11, 2022 17:10
Convert and decrypt Audible books to split up audiobook, retain meta data and split into chepters. Compatible with Mac.
# Converting Audible AAX files to M4B Audiobook files, split into chapters and decrypted
# Get activation bits here for now: https://audible-converter.ml
SHORTNAME='BeautifulYou'
AAXFILE='/Users/rob/Downloads/BeautifulYou_ep6.aax'
ACTIVATION_BYTES='2758110a'
# These files don'e exist yet, we just need to tell the script where to create them.
DATAFILE='/Users/rob/Desktop/audible-conv/data.json'
METADATAFILE='/Users/rob/Desktop/audible-conv/data.tmp'
@Pamblam
Pamblam / isSafeQuery.md
Created June 4, 2021 16:26
Check if an arbitrary SQL query is safe to run on the database.

Note: This is posted as an answer to a StackOverflow question. Keeping it here for my own convenience.

I wanted a safer, more robust solution that didn't involve fully tokenizing query. Based on my experience writing SQL parsers (here, and here), I can say this solution is pretty bulletproof without having to use a full-featured query parser.

This is the best answer because:

  • It does not require a new SQL user with limited permissions
  • It does not require a new DB connection with limited permissions
  • It does not break if the query contains a string or a comment with the word "delete"
  • It allows complex queries with nested queries
@Pamblam
Pamblam / fontawesome_5_icons.json
Created May 3, 2021 19:01
All free Fontawesome 5 icon classnames and titles.
[
{
"class": "fab fa-500px",
"text": "500px"
},
{
"class": "fab fa-accessible-icon",
"text": "Accessible Icon"
},
{
@Pamblam
Pamblam / path parse.php
Created February 1, 2021 21:47
parse paths in php
class fpParser{
public $path;
public $basename;
public $basename_noext;
public $basename_noext_noiteration;
public $extention;
public $directory_sep;
public $dir_tree;
public $iteration;
var img = document.getElementById('guage');
var percentDisplay = 73;
makeAnimatedGuage(img, percentDisplay);
function makeAnimatedGuage(img, percentDisplay, line_width = 10, guage_width = 500, font_size = 20, font_face = 'Arial'){
var current_pct = 0;
var target_pct = 65;
img.src = makeGuage(current_pct);
@Pamblam
Pamblam / loadAsset.js
Created October 14, 2020 14:40
Given a URL for a JS or CSS file, this function will load the asset and return a Promise which will reject on error or resolve when the asset is loaded.
/**
* Given a URL for a JS or CSS file, this function will
* load the asset and return a Promise which will reject
* on error or resolve when the asset is loaded.
*/
function loadAsset(url){
return new Promise(async (resolve, reject)=>{
var asset;
if(url.trim().substr(-3).toLowerCase() === '.js'){
asset = document.createElement('script');
@Pamblam
Pamblam / createTextImage.js
Created July 21, 2020 13:31
Generate an image of text
/**
* Generate an image of text
* @param {String} text - The text to convert to an image
* @param {Object} options - The rendering options of the text and image
* @property {String} options.color - The color of the text
* @property {Number} options.font_size - The size of the text in pixels
* @property {String} options.font_face - The font face to use
* @property {String} options.font_style - The font style (normal|italic|oblique|initial|inherit)
* @property {String} options.font_variant - The font variant (normal|small-caps|initial|inherit)
* @property {String|Number} options.font_weight - The font weight (normal|bold|bolder|lighter|number|initial|inherit)
@Pamblam
Pamblam / detect media queries.js
Created June 12, 2020 18:42
detect all media queries in use..
(async function(d){
console.clear();
const styles = [];
const stylesheets = d.querySelectorAll("link[rel='stylesheet'][href]");
// get all stylesheet urls
const stylesheet_urls = [...stylesheets].map(s=>s.href);
// fetch the contents of the stylesheets
const ss_promises = stylesheet_urls.map(href=>{
return fetch(href).then(s=>s.text()).then(s=>{
return {
@Pamblam
Pamblam / getUnusedStyles.js
Last active June 5, 2020 19:05
Puts a message in the console for every loaded CSS style that is not being used on the page.
(async function(d){
console.clear();
const styles = [];
const stylesheets = d.querySelectorAll("link[rel='stylesheet'][href]");
// get all stylesheet urls *that are on the same domain*
const stylesheet_urls = [...stylesheets].map(s=>s.href).filter(uri=>{
uri1 = new URL(uri);
var uri2 = new URL(window.location.href);
if(uri1.host !== uri2.host) return false;
if(uri1.port !== uri2.port) return false;

Switching a repo from http to ssh

Check for existing keys

ls -al ~/.ssh

Generate new key (substitute email)

ssh-keygen -t rsa -b 4096 -C "[email protected]"