Skip to content

Instantly share code, notes, and snippets.

View Pamblam's full-sized avatar
🕶️
Coding

Rob Parham Pamblam

🕶️
Coding
View GitHub Profile
class BodyMetrics {
constructor(params) {
Object.keys(params).forEach(key => {
this[key] = params[key];
});
this.results = {};
this.bodyFatPercentage();
this.bodyFatWeight();
this.bodyFatDensity();
}
@Pamblam
Pamblam / scale and cover image.js
Created February 12, 2020 16:31
Functions that take an image uri and scale them to fit or fill a given area;
function loadImage(src){
return new Promise((r,e)=>{
var img = new Image();
img.onload = ()=>r(img);
img.onerror = e;
img.src = src;
});
}
async function scaleAndFitImage(src, w, h) {
@Pamblam
Pamblam / Selector Generator.js
Created January 27, 2020 21:04
When run in the console it creates a UI to help find selectors for any element on the page.
var SelectorGenerator = (function(){
var removed_elements = [];
var selectedElement = null;
var modalBg = null;
var outline = null;
var modal = null;
var running = false;
@Pamblam
Pamblam / Sending Apple push notifications with APN service and .p8 key .php
Created January 16, 2020 21:45
Sending Apple push notifications with APN service and .p8 key
<?php
// Path to the .p8 file downloaded from apple
// see: https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_token-based_connection_to_apns#2943371
$authKey = "AuthKey_S97G28Y3JP.p8";
// Team ID (From the Membership section of the ios developer website)
// see: https://developer.apple.com/account/
$teamId = 'asdfasdf';
@Pamblam
Pamblam / shallowSourceSearch.js
Last active July 3, 2025 16:08
Search source code of a webpage, including it's linked stylesheets and scripts.
/**
* Search the source code of the current web page.
* @param {string} needle - The string to find
* @param {string} all|js|css - the type of source code to search
* @param {boolean} caseMatch - Is search case sensitive?
* @returns {array} - An array of objects that represent matches.
*
* Usage: Paste this script into the DevTools and run it to attach
* the function to the window. Run the method, indicating the string
* you're looking for, whether you want to search the page's CSS,
@Pamblam
Pamblam / git_history_delete
Created November 26, 2019 15:48
Delete git repo history
#!/usr/bin/env bash
REMOTE=$(git config --get remote.origin.url)
rm -rf .git
git init
git add .
git commit -m "Deleted repo history"
git remote add origin $REMOTE
git push -u --force origin master
@Pamblam
Pamblam / csv.js
Created November 21, 2019 19:20
Parse csv strings per RFC 4180
class CSV{
constructor(data, has_header){
this.has_header = has_header;
this.headers = [];
this.rows = [];
this.headers = [];
this.raw = data;
this._iterator = 0;
this._in_quote = false;
@Pamblam
Pamblam / crossfade_images.html
Created July 31, 2019 22:18
crossfading image over canvas
<!DOCTYPE html>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<canvas id="main_canvas" width="500" height="300"></canvas>
<script>
@Pamblam
Pamblam / autoCropImage.js
Last active February 3, 2020 14:54
Trim empty rows and columns of pixels.
document.querySelector('button').onclick = e=>{
var uri = "http://robert-dev.ourtownamerica.com/intra/otcb4/api/serve_img.php?id=2&type=txt&revision=0";
autoCropImage(uri).then(croppeduri=>{
console.log(croppeduri);
document.querySelector("#img").src = croppeduri;
});
};
/**
* Trim empty rows and columns of pixels.
@Pamblam
Pamblam / instructions.md
Created July 12, 2019 14:51
Making High-Quality screencast animated gifs (Gnome Linux)

Making High-Quality screencast animated gifs

  1. Use any screen recorder to record the screen. Gnome has a built-in recorder that is started and stopped with ctrl+shift+alt+r.
  2. Use kdenlive's edgecrop and speed effects to crop and adjust speed as required. render as mp4.
  3. Convert MP4 to several images:
sudo ffmpeg -i save_project.mp4  -r 20 'frames/frame-%03d.jpg'
  1. Use gimp to determine coordinates of required crop