Skip to content

Instantly share code, notes, and snippets.

View ricardoom's full-sized avatar
🍖
getting busy

ricardo galvez ricardoom

🍖
getting busy
View GitHub Profile
// If the image is broken / not available then you can sneak this in...
<img src='some.jpg' onerror='this.remove()' />
@ricardoom
ricardoom / bigThreeD.scss
Created February 8, 2021 17:21
makes big 3d out of lots of text shadows...
//
// This produces a solid 3d
// @param $color {value} - hex or rgba
// @param $num {number} - number of shadows to apply
// @param $spread {number} - the shadow's spread
// @param $blur {number} - the text shadow's blur
// @param $y {number} - the y value
// @param $x {number} - the x value
//
@ricardoom
ricardoom / arraysToObject.js
Last active February 5, 2021 19:58
Simple loop that takes two arrays and converts them into key value pairs in an object
const phoneBook = {};
const names = ['Mira', 'Royce', 'Kathie'];
const numbers = ['3234958675', '9164059384', '4154958675']
// we need to retrun this:
// const phoneBook = {
// 'Mira': '3234958675',
// 'Royce': '9164059384',
// 'Kathie': '4154958675',
// }
@ricardoom
ricardoom / rangeRecursive.js
Last active February 2, 2021 23:37
a simple recursive range function
function rangeOfNumbers(startNum, endNum) {
if (startNum - endNum === 0) {
return [startNum]
} else {
// declare the variable range and give it the value of our recursive function rangeOfNumbers
//console.log(startNum)
let range = rangeOfNumbers(startNum, endNum - 1);
console.log(endNum, endNum - 1)
range.push(endNum);
@ricardoom
ricardoom / randomArray.js
Created December 11, 2020 21:57
a simple function to scramble an array without mutation
const shuffleArray = function (array = []) {
if (!Array.isArray(array) && array.length > 0) return;
const a = [...array];
for (let i = a.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[a[i], a[j]] = [a[j], a[i]];
}
return a;
};
//
// Random numbers
// for whatever reason, even though I use this all the time,
// I can never remember it...🕺
function getRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
function getRandom(max, min) {
@ricardoom
ricardoom / hugo-transfrom.html
Last active November 12, 2020 16:29
a simple regex text transform in hugo
<!--
Easy text transform for cleaning up generated names and using as variables in a Hugo partial template
Since I use this for creating aria attributes, this strips out spaces and replaces w/ dash and transforms the string to lower
Then wrap in parens and pass that to the built in lower function to transform. easy.
-->
{{ $title := .Title }}
{{ $ariatitle := lower (replaceRE "(\\s)" "-" $title) }}
<h3 id="{{ $ariatitle }}">
<a href="{{ .Permalink }}" aria-labelledby="{{ $ariatitle }}">{{ .Title }}</a>
@ricardoom
ricardoom / forked-splitting-demo.markdown
Created March 20, 2020 01:05
forked ~ Splitting Demo
@ricardoom
ricardoom / fork-outlines-and-overprints.markdown
Last active March 20, 2020 01:06
fork ~ Outlines and overprints

fork ~ Outlines and overprints

An exploration in creating a more graphic headline treatment using overlaps, transparency, and color

A Pen by ricardo galvez on CodePen.

License.

const shuffleArray = function(array) {
const a = [...array];
for (let i = a.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[a[i], a[j]] = [a[j], a[i]];
}
return a;
};