Skip to content

Instantly share code, notes, and snippets.

Ely De La Cruz elycruz

Block or report user

Report or block elycruz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@elycruz
elycruz / assoc_list_helpers.js
Created Jun 11, 2018
Idea for assoc_list_helpers (for going to and fro associated lists on specific keys and as a whole) (untested, and/or incomplete implementations)
View assoc_list_helpers.js
/**
* 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 Apr 13, 2018
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)).
View scrollWindowTo.js
import {isset} from 'fjl';
const easings = {
linear(t) {
return t;
},
easeInQuad(t) {
return t * t;
},
easeOutQuad(t) {
@elycruz
elycruz / versionNumReadStream.js
Created Dec 13, 2017
Outputs the version number of an npm package through a readstream.
View versionNumReadStream.js
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,
View deep-equals-example.js
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)) {
View reduceByDelimitedContent.js
/**
* 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}
View fib.js
// Simple fibonacci series generator. Generates fibonacci series from 0 to `limit` number.
function fib (limit) {
var out = [],
a = 0,
b = 1;
while (a < limit) {
out.push(a);
if (b <= limit) {
out.push(b);
}
@elycruz
elycruz / numToHex.js
Last active Nov 14, 2017
Javascript number to hexadecimal string function.
View numToHex.js
/**
* 'Fast Remainder' method for number to hex.
* @see http://www.wikihow.com/Convert-from-Decimal-to-Hexadecimal (fast remainder method (method 2)).
*/
const hexMap = [
[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5],
[6, 6], [7, 7], [8, 8], [9, 9], [10, 'A'], [11, 'B'],
[12, 'C'], [13, 'D'], [14, 'E'], [15, 'F']
];
@elycruz
elycruz / Namespace.js
Created May 22, 2015
Php Styled Autoloader for NodeJs
View Namespace.js
/**
* Created by Ely on 5/22/2015.
*/
require('sjljs');
var path = require('path'),
fs = require('fs');
var Namespace = sjl.Extendable.extend(function Namespace (dir, allowedFileExts) {
@elycruz
elycruz / .jshintrc
Created May 15, 2015
Good starting point .jshintrc file.
View .jshintrc
{
"maxerr" : 50, // {int} Maximum error before stopping
// Enforcing
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : false, // true: Identifiers must be in camelCase
"curly" : false, // true: Require {} for every new block or scope
"eqeqeq" : true, // true: Require triple equals (===) for comparison
"forin" : false, // true: Require filtering for..in loops with obj.hasOwnProperty()
"immed" : true, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
@elycruz
elycruz / .eslintrc
Last active Sep 18, 2016
.eslintrc as yaml file
View .eslintrc
# --------------------------------------------------------------------------------------------------------------------- #
# Conversion of http://eslint.org/docs/rules/ to an actual .eslintrc file:
# Copied: 04/01/2015
# Updated to yaml format: 05/15/2015
# Copied by: Ely De La Cruz <elycruz@elycruz.com>
# --------------------------------------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------------------------------------- #
# Environemnt Types:
# --------------------------------------------------------------------------------------------------------------------- #
You can’t perform that action at this time.