Skip to content

Instantly share code, notes, and snippets.

@camjocotem
camjocotem / emotions.json
Created September 29, 2025 10:25
Emotion Wheel (WIP)
[
{
"emotion": "Anger",
"children": [
{
"emotion": "Hurt",
"children": [
{
"emotion": "Embarrassed"
},
@camjocotem
camjocotem / arrayDictionaryProto.js
Last active October 25, 2024 13:49
Array Dictionary
Array.prototype.toDictionary = function (keySelector, valueSelector = null) {
const dict = this.reduce((dict, item) => {
const key = keySelector(item);
dict[key] = valueSelector ? valueSelector(item) : item;
return dict;
}, {});
// Return an object that is both iterable and accessible by key
return {
...dict,
@camjocotem
camjocotem / dictionary.js
Created October 31, 2023 11:45
Javascript Object dictionary
Object.dictionary = function(obj){
return Object.entries(obj).map(entry => {
return {
key: entry[0],
value: entry[1]
}
})
}
@camjocotem
camjocotem / .gitconfig
Last active September 18, 2023 11:13
.gitconfig (Log alias) git lg
[alias]
lg = lg1
lg1 = lg1-specific --all
lg2 = lg2-specific --all
lg3 = lg3-specific --all
lg1-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
lg2-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
lg3-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'
@camjocotem
camjocotem / RFlatMap.js
Created June 27, 2023 09:27
Recursive FlatMap
const flatten = (routes) => {
return routes.reduce((acc, r) => {
if(r.childRoutes && r.childRoutes.length) {
acc = acc.concat(flatten(r.childRoutes));
} else {
acc.push(r);
}
return acc;
}, [])
@camjocotem
camjocotem / RemoveRedditPromos.js
Last active June 17, 2023 11:59
Remove Reddit Promotional Tweets (To use with Javascript extension such as Custom Javascript For Websites 2)
function findTopPostElement(el){
if(isTopPostElement(el)){
return el;
}
else{
return findTopPostElement(el.parentElement);
}
}
function isTopPostElement(el){
[].forEach.call(window.$$("*"),function(a){a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16)})
@camjocotem
camjocotem / debug css
Created October 1, 2021 15:06
debug css
javascript:[].forEach.call(window.$$("*"),function(a){a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16)})
@camjocotem
camjocotem / GetTfsItems.js
Last active November 18, 2020 17:05
Get all tagged TFS work items since last live release
//This script makes some assumptions
//1. You tag the work items in your commits e.g. #1234 - Fixed bug
//2. That all 'live' environments will have the same name
//https://docs.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-6.1#api-and-tfs-version-mapping
const apiVersion = "4.1-preview"
const serverUrl = "http://serverurlhere:8080" //
const projectList = ["Some_Frontend_Project","Some_Backend_Project"];
const liveEnvironmentName = "Live"
@camjocotem
camjocotem / filter.js
Last active April 22, 2020 01:35
Chat Filter
// Select the node that will be observed for mutations
window.filterApplied = false;
const targetNode = document.getElementsByClassName('top-nav__search-container')[0];
const chatNode = document.getElementsByClassName('chat-list__list-container')[0];
targetNode.parentElement.parentElement.innerHTML = `
<div style="display: flex;">
<input type="text" id="usernameFilter">
<button onclick="filterChat()">Filter</button>
<button onclick="clearfilter()">Clear</button>
</div>`