Skip to content

Instantly share code, notes, and snippets.

public with sharing class HttpFormDataHandler {
public static Blob createRequestBody(String boundary, Object request) {
String last4Bytes = '';
List<String> requestBody = new List<String>();
Map<String, Object> requestMap = (Map<String, Object>) JSON.deserializeUntyped(
JSON.serialize(request)
);
for (String key : requestMap.keySet()) {
try {
@jonny-harte
jonny-harte / custom-post-types.php
Created March 12, 2019 19:54
Function to add multiple wordpress custom post types
<?php
//https://codex.wordpress.org/Function_Reference/register_post_type
//https://developer.wordpress.org/resource/dashicons/
$postTypes = [
'Post Name' => [
'menu_icon' => 'dashicons-businessman',
'menu_position' => 26,
'public' => true,
'rewrite' => ['slug' => 'name'],
@jonny-harte
jonny-harte / word-count-bookmarklet.js
Last active September 21, 2022 16:55
bookmarklet that analyzes the current page and determines the frequency of word usage.
javascript:(function () {
const
words = document.body.innerText.split(/\s+/), //get all words on the page.
filteredWords = words.filter(word => word.length >= 4).sort(), //filter out words smaller than 4 characters and sort alphabetically.
specialCharacters = /^[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]*$/, //list of special characters to remove from words.
div = document.createElement('div'), //create a div to contain the tag presentation.
style = document.createElement('style'); //create a style tag to contain the tag presentation styling.
let frequency = {};