Skip to content

Instantly share code, notes, and snippets.

View Pamblam's full-sized avatar
🕶️
Coding

Rob Parham Pamblam

🕶️
Coding
  • Our Town America
  • Tampa Bay, Florida
View GitHub Profile
@Pamblam
Pamblam / animate.html
Created February 5, 2024 19:51
reusable javascript css animation function demo
<!DOCTYPE html>
<html>
<head>
<title>aminate</title>
</head>
<body>
<img id='img' src="https://static-00.iconduck.com/assets.00/heart-emoji-2048x1891-k5awv4hw.png"
style="position:absolute; left:0; top:0; width: 50px;" />
@Pamblam
Pamblam / VCard.class.js
Created July 28, 2023 12:43
VCard Implementtaion in Javascript
// See: https://www.rfc-editor.org/rfc/rfc6350
class VCard{
constructor(){
this.kind = null;
this.name = [];
this.nickname = [];
this.photo = [];
this.bday = null;
@Pamblam
Pamblam / minibeast_md_parser.js
Last active February 16, 2023 03:01
Convert specific allowed MD elements to HTML, as used in the Minibeast app and website.
/**
* Convert a string containing Markdown links, images, codeblocks, inline code, bold and italic text to an HTML string.
* 1. Remove duplicate linebreaks and spaces (including <br>)
* 2. Convert linebreaks to <br>
* 3. Convert URLs that are not part of a markdown tag to markdown tags
* 4. Convert ``` MD code blocks to <pre><code> blocks
* 5. Convert ` inline code to <code> tags
* 6. Convert ** bold tags to <b> tags
* 7. Convert * italics tags to <i> tags
* 8. Convert ![]() image tags to <img> tags
/**
* Remove <script> tags from a string
* We cannot use regex to remove them because regex does not
* account for false closing script tags, and therefore a regex solution is exploitable.
* This loops through each char and removes script tags fully accounting for
* false closes that may occur in quotes.
*/
function stripScriptTags(str){
if(typeof str !== 'string') {
return false;
@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');