Skip to content

Instantly share code, notes, and snippets.

@moshmage
moshmage / agenda-class.js
Last active October 7, 2016 14:57
Simple Agenda Class
class Agenda {
constructor() {
this._AGENDA = [new Pessoa()];
}
/**
*
* @param name {String}
* @param address {String}
* @param mobileNumber {String}
@moshmage
moshmage / tweet-tweet.js
Last active November 10, 2016 00:57
quick and dirty handshaker between twitter and an application
/**
* Created by Mosh Mage on 10/14/2016.
* quick and dirty handshaker between twitter and an application
* this could be loaded by modules, but time if of the essence
* todo: module loader, add express, make a decent api
*/
"use strict";
var http = require('http');
var request = require('request');
var url = require('url');
@moshmage
moshmage / CharacterSheet.js
Last active January 15, 2017 02:36
Character Sheet for a RPG looselly based on FUDGE system
"use strict";
import {DiceTransformations} from './roll-transforms.js';
const Dice = new require('roll')();
const BASE_HEALTH = 10;
const BASE_SKILL_MODIFIER = 1.25;
const MINIMUM_SKILL_MODIFIER = 0.1;
const BASE_CRITICAL_FAILURE = -3;
const CRITICAL_DICES = 2;
@moshmage
moshmage / rut-validation.ts
Last active November 9, 2017 18:31
Chillean RUT validation
/**
* Provide string of type 12.333.333-k|123456789|12345678-9|12.345678-9
* ???
* profit.
* @param {string} _rut
* @returns {boolean}
*/
function isValidRUT(_rut) {
const isRegexValid = _rut.match(/^\d{1,2}\.?\d{3}\.?\d{3}\-?[0-9kK]$/ig);
if (!isRegexValid) return false;
@moshmage
moshmage / maskValue.ts
Last active October 16, 2018 21:54
masking a string
/**
* Replaces value inside {value} with a spaced representation of the masked array
* and then replaces the Nth caret with the provided key, returning the new masked
* value.
* @param {(RegExp | string)[]} mask
* @param {string} key
* @param {number} caretPos
* @param {string} value
* @returns <{str: string, pos: number}>
*/
@moshmage
moshmage / force-type.js
Created October 16, 2018 21:56
force a variable to follow the value of a model
const isObject = (o) => (o instanceof Object && !Array.isArray(o));
const areObjects = (...o) => !o.some(oo => !isObject(oo));
const areArrays = (...a) => !a.some(aa => !Array.isArray(aa));
function typeCheck(source, mock) {
if (areArrays(source, mock)) {
if (!source.length) return true;
return !mock.some((v, i) => !typeCheck(source[i], v))
}
@moshmage
moshmage / readme.md
Last active February 1, 2020 21:00
Simple SCSS Typography

Simple Typography SCSS

Because I was tired of writing them too.

Elements

Heading 1 through 6 will be styled with @mixin typo($opts) (line 39)

Created classes

just for font-size

  • .font-
  • h1...6
@moshmage
moshmage / withinRadius.js
Last active April 18, 2022 09:22
compares two objects lat/lon and returns true if within provided kms
/**
* is One Point within Another
* @param point {Object} {latitude: Number, longitude: Number}
* @param interest {Object} {latitude: Number, longitude: Number}
* @param kms {Number}
* @returns {boolean}
*/
function withinRadius(point, interest, kms) {
'use strict';