Skip to content

Instantly share code, notes, and snippets.

View 0xemc's full-sized avatar

Michael Collins 0xemc

  • xemc
  • Australia
  • 21:32 (UTC +10:00)
View GitHub Profile
TLDR: __a_brief_description_of_the_issue_
Date: __the_date_and_time_that_the_bug_was_last_observed__
Environment/Link: __a_link_to_the_environment_with_the_selected_filters__
Screenshot/Video:
__some_screengrab__
What: A_brief_description_of_what_is_involved_in_the_change
Why: A_brief_description_as_to_why_this_change_is_needed
How: Any_design_details_or_links
Expected Outcome:
type Position = [number,number]
/** Return the angle between 2 points in radians relative to the x axis*/
export const points_to_radians = ([[p1lon, p1lat], [p2lon, p2lat]]: [
Position,
Position,
]): number => Math.atan2(p2lat - p1lat, p2lon - p1lon);
/** Return the angle between 2 points in degrees relative to the x axis */
import type { Reducer } from 'react';
import { useReducer, useState } from 'react';
const tempStateReducer = <T,>(prevState: T, newState: Partial<T>): T => ({
...prevState,
...newState,
});
/**
* Hook to store temporary complex state until the user decides to accept or reject it
/**
* Container Queries
* this utility provides container query functionality and
* was copied from Phillip Walton's excellent blog post:
* https://philipwalton.com/articles/responsive-components-a-solution-to-the-container-queries-problem/
*/
(function (NAMESPACE, $) {
"use strict";
@0xemc
0xemc / css-filter-generator-to-convert-from-black-to-target-hex-color.markdown
Created June 23, 2020 06:43
CSS filter generator to convert from black to target hex color
@0xemc
0xemc / functional_utils.js
Created June 15, 2020 01:37
Functional Utilities
// AND composition, apply all functions
compose = fns => x => fns.reduceRight((y, f) => f(y), x);
// OR composition, apply functions until one returns true
composeAny = fns => x => fns.some(f => f(x));
//Single layer depth object comparison
const shallowCompare = (obj1, obj2) => {
return Object.keys(obj1).length === Object.keys(obj2).length &&
Object.keys(obj1).every(key => obj1[key] === obj2[key]);
}
//Distinct array
const unique = (arr) => arr.reduce((acc, curr) => {
if(!arr.some(val => shallowCompare(curr,val)){acc.push(curr)}
return acc;
@0xemc
0xemc / project_checklist.md
Last active March 24, 2021 03:04
Project Completion Checklist

Fonts

  • SVG Fonts converted to paths
  • OS Specific Fonts Backup

Accesibility

  • Image alt tags

Misc

  • Manifest
@0xemc
0xemc / ReactUtils.js
Created March 23, 2020 04:43
Utility Functions For React
export function useTraceUpdate(props) {
const prev = useRef(props);
useEffect(() => {
const changedProps = Object.entries(props).reduce((ps, [k, v]) => {
if (prev.current[k] !== v) {
ps[k] = [prev.current[k], v];
}
return ps;
}, {});
if (Object.keys(changedProps).length > 0) {