Skip to content

Instantly share code, notes, and snippets.

View elycruz's full-sized avatar

Ely De La Cruz elycruz

View GitHub Profile
@elycruz
elycruz / console_ani_keyframes_with_display_none.js
Created September 9, 2021 23:40
Animation keyframes with `display: none;`.
/**
* Exploring animation keyframes with display `none` etc.
*/
document.body.innerHTML = `
<style>
@keyframes slide-in {
0% {
display: none;
@elycruz
elycruz / sticky-table-headers.js
Created August 26, 2021 13:11
Example of sticky table headers using 'position: sticky' for header columns.
document.body.innerHTML = `
<style>
table {
position: relative;
overflow: auto;
}
table, td, th {
border: 1px solid;
}
thead th {
@elycruz
elycruz / conditional-text-tooltips.js
Created August 11, 2021 21:49
Conditional text tooltips (devtools/snippets copy & paste ready)
document.body.innerHTML = `
<style>
html, body {
font-family: Arial, Verdana Helvetica, Sans-serif;
}
table {
width: 80vw;
}
@elycruz
elycruz / tree-map.js
Last active March 3, 2021 03:40
Simple tree-map algo (in *.js).
class TN {
constructor(assocList) {
if (assocList) {
assocList.forEach(([k, v]) => {
this.set(k, v);
});
}
}
set(k, v)) {
@elycruz
elycruz / array-as-table-utils.ts
Created October 3, 2020 19:35
Utilities for fetching an item's index in an array being treated as a table.
export const
getRowIndex = (itemIdx: number, itemsPerRow: number): number =>
Math.round((itemIdx - (itemIdx % itemsPerRow)) / itemsPerRow),
getColumnIndex = (itemIdx: number, itemsPerRow: number): number =>
itemIdx % itemsPerRow
;
@elycruz
elycruz / assoc_list_helpers.js
Created June 11, 2018 18:24
Idea for assoc_list_helpers (for going to and fro associated lists on specific keys and as a whole) (untested, and/or incomplete implementations)
/**
* Idea for assoc_list_helpers (for going to and fro associated lists on specific keys and as a whole) (untested, and/or incomplete implementations)
*/
const
/**
* Returns an associated list on incoming's object type.
* @note Does deep conversion on all values of passed in type's type.
* @note Useful for working with object primitive (json and the like).
@elycruz
elycruz / scrollWindowTo.js
Created April 13, 2018 03:13
Scroll window to position (copied from somewhere (don't remember where)). Is a useful script (this version is slightly updated from the original to take into account float values in modern browser and also clear the animation frame (old version didn't do that)).
import {isset} from 'fjl';
const easings = {
linear(t) {
return t;
},
easeInQuad(t) {
return t * t;
},
easeOutQuad(t) {
@elycruz
elycruz / versionNumReadStream.js
Created December 13, 2017 03:14
Outputs the version number of an npm package through a readstream.
const
util = require('util'),
stream = require('stream'),
Readable = stream.Readable,
packageJson = require('../package');
function VersionNumberReadStream (options) {
Readable.call(this, Object.assign({
encoding: 'utf8',
objectMode: false,
define(function () {
'use strict';
var typeofIsObject = function (value) { return typeof value === 'object'; },
hasOwnProperty = function (obj, key) { return Object.prototype.hasOwnProperty.call(obj, key) };
function deepEquals (obj1, obj2) {
return Object.keys(obj1).every(function (key) {
if (!hasOwnProperty(obj2, key)) {
/**
* Created by elydelacruz on 11/8/16.
* Simple function to extract delimited content from a string.
*/
'use strict';
/**
* Returns whether our content has opening and closing delimiters.
* @param content {String}