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 / 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 "your_email@example.com"
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 January 6, 2020 15:39
Search source codeof a webpage, including it's linked stylesheets and scripts.
/**
* Used to find function names or any other strings in sources of a web page.
* @param {string} needle - The string to find
* @param {boolean} caseMatch - Is search case sensitive?
*/
async function shallowSourceSearch(needle, caseMatch = false) {
var matches = [], files = [];
if (!caseMatch) needle = needle.toLowerCase();
const searchFile = async path => {
try {
@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