Skip to content

Instantly share code, notes, and snippets.

View beefchimi's full-sized avatar
🤠
yeeeeehaw!

Curtis Dulmage beefchimi

🤠
yeeeeehaw!
View GitHub Profile
@beefchimi
beefchimi / compare-deps.js
Last active May 26, 2022 20:14
Tool to help compare `declared vs installed` dependencies
///
/// Helper function simply for sorting alphabetically
function sortObjectAlphabetically(obj) {
const keys = Object.keys(obj);
const sorted = keys.sort((a, b) => {
if (a < b) return -1;
if (a > b) return 1;
return 0;
@beefchimi
beefchimi / transformTemplate.motion.ts
Created May 18, 2022 13:39
Framer Motion Transform Template
import type { TransformProperties } from 'framer-motion/types/motion/types';
// These functions would not be necessary if `framer-motion`
// resets `transform` back to `none` when a `translate` value === `0`.
function hasScale(scale: TransformProperties['scale']) {
return scale !== 1 && scale !== undefined;
}
function hasTranslateX(translateX: TransformProperties['scale']) {
devices: ({
name: "Wireless Mouse MX Master 2S";
smartshift: {
on: true;
threshold: 50;
};
hiresscroll: {
hires: true;
invert: false;

Keybase proof

I hereby claim:

  • I am beefchimi on github.
  • I am beefchimi (https://keybase.io/beefchimi) on keybase.
  • I have a public key ASD-9ql1dWCrJ0VJC2QuGL3siIhw0LpAhjCvyQA01wsccwo

To claim this, I am signing this object:

@beefchimi
beefchimi / array-reduce.js
Created April 16, 2020 12:59
Array Reduce Examples
const items = [1, 2, 3, 4, 5];
/* Example when we return only a string value. */
const concatString = items.reduce((string, item) => `${string}${item},`, "");
/* Example when we return the first odd number. */
const firstOddValue = items.reduce((value, item) => {
if (value == null && item % 2 === 0) {
return item;
}
@beefchimi
beefchimi / format-react-key.ts
Created September 12, 2019 19:25
Format React key
export const regExpCommonCharacters = new RegExp(/[^\w]/gim);
const INDEX_DELIMITER = '-';
const MAX_CHARACTER_LENGTH = 100;
export function formatReactKey(key: string, index: number | null = null) {
const hasIndex = index || index === 0;
const transformedKey = [
...key
@beefchimi
beefchimi / ExtensibleFeature.js
Created October 22, 2017 22:25
Example of using Loop.js in the Extensible section
import SoundFx from '../../SoundFx';
export default function ExtensibleFeature() {
const target = document.getElementById('ExtensibleFeature');
target.addEventListener('mouseenter', () => {
SoundFx.Extensible.play();
});
target.addEventListener('mouseleave', () => {
@beefchimi
beefchimi / webaudio-example-6.js
Last active October 22, 2017 23:49
Speed method
speed(speed = 1) {
// Ramp up faster when increasing speed, slower if decreasing
const duration = (speed > 1) ? durationRamp.up : durationRamp.down;
for (let i = 0; i < this.trackCount; i++) {
this.sources[`source${i}`].playbackRate.exponentialRampToValueAtTime(
speed,
this.context.currentTime + duration
);
}
@beefchimi
beefchimi / AccessibleFeature.js
Created October 22, 2017 22:20
Example of using Loop.js in the Accessible section
import SoundFx from '../../SoundFx';
export default function AccessibleFeature() {
const target = document.getElementById('AccessibleFeature');
target.addEventListener('mouseenter', () => {
SoundFx.Accessible.play();
});
target.addEventListener('mouseleave', () => {
@beefchimi
beefchimi / Loop.js
Last active November 6, 2017 20:52
Loop class
import fetchAudioBuffer from './helpers/fetch-audio-buffer';
const zeroGain = 0.001;
const maxGain = 0.6;
const durationRamp = {
up: 0.2,
down: 0.3,
};