Skip to content

Instantly share code, notes, and snippets.

View mulrooneydesign's full-sized avatar

Barry Mulrooney mulrooneydesign

View GitHub Profile
function StringProcessor(value) {
return {
value: value,
reverse: function () {
return StringProcessor(this.value.split('').reverse('').join(''));
},
allCaps: function () {
return StringProcessor(this.value.toUpperCase());
},
spaceBetweenChars: function () {
@mulrooneydesign
mulrooneydesign / useForm.jsx
Last active November 14, 2023 19:46
My example of how to build my own react useForm hook
import { useState } from "react";
function useForm({ initialValue, name }) {
const [value, setValue] = useState(initialValue);
return {
[`${name}`]: {
value,
onChange: (e) => setValue(e.target.value)
}
};
@mulrooneydesign
mulrooneydesign / GLSL.frag
Created June 8, 2023 19:15
A shader toy shader
vec3 palette(float t) {
vec3 a = vec3(0.938, 0.328, 0.718);
vec3 b = vec3(0.659, 0.438, 0.328);
vec3 c = vec3(0.388, 0.388, 0.296);
vec3 d = vec3(2.538, 2.478, 0.168);
return a + b * cos(6.28318*(c*t*d));
}
@mulrooneydesign
mulrooneydesign / flattenNestedObject.js
Last active December 4, 2022 15:19
Flatten a nested object in javascript
// deeply nested object about a person that we are going to flatten
const person = {
name: 'John',
age: 30,
address: {
street: '123 Main St',
city: 'New York',
state: 'NY',
zip: 10001,
country: {
function shuffle(elements) {
allElements = (function(){
let returnArray = []
let lengthOf = elements.length
while (lengthOf--) {
returnArray[returnArray.length] = elements[lengthOf]
}
@mulrooneydesign
mulrooneydesign / GLSL-Noise.md
Created April 7, 2021 16:16 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
	return mix(rand(fl), rand(fl + 1.0), fc);
}