Skip to content

Instantly share code, notes, and snippets.

@msteckyefantis
msteckyefantis / Promise.js
Last active April 24, 2016 09:40
an example promise function
/*
To run this file:
1. download this code or copy this code and put it in a file, with .js at the end of the filename
2. in your command line go to the directory where the code is
3. input in your command line: node Promise.js (or whatever your filename is called)
4. SEE THE SECRET MESSAGE!!
*/
function myInnerPromise( value ) {
@msteckyefantis
msteckyefantis / test.js
Last active April 26, 2016 04:13
NodeJs testing example, 'requiring' chai, run with terminal command: mocha <location of file> (e.g. mocha test.js)
'use strict';
const expect = require( 'chai' ).expect;
// testing example function f (you normally "require" the file you want to test)
function f( x ) {
return( x + x + x + x );
}
@msteckyefantis
msteckyefantis / forLoopLesson.js
Last active May 1, 2016 16:34
NodeJs Lesson: "in" and "of" used with for loops.
'use strict';
const obj = {
obj_key_1: 'obj_value_1',
obj_key_2: 'obj_value_2',
obj_key_3: 'obj_value_3'
};
const arr = [ 'array_value_1', 'array_value_2', 'array_value_3' ];
header.payload.signature
@msteckyefantis
msteckyefantis / MathMystery.js
Last active June 12, 2016 19:37
Super Mysterious Math!!!
'use strict';
var M = Math;
var L = [ 0, 0 ];
function F() {
return M.floor( 2 * M.random() ) ? 'head' : 'tail';
}
@msteckyefantis
msteckyefantis / promise.js
Created January 10, 2017 17:13
javascript lesson
'use strict';
const f = ( x, r ) => {
return Promise[ r ]( 2 * x )
.then( y => {
throw y;
},
z => {
@msteckyefantis
msteckyefantis / unit.test.js
Last active February 26, 2018 22:53
General nodejs unit test template. Uses mocha, sinon, proxyquire, chai, and is-deep-frozen.
'use strict';
const ROOT_PATH = '../../';
const MODULE_PATH = 'lib/filename';
const FULL_MODULE_PATH = ROOT_PATH + MODULE_PATH;
const isDeepFrozen = require( 'is-deep-frozen' );
'use strict';
const React = require( 'react' );
const e = React.createElement;
module.exports = class MegaGreenSquare extends React.Component {
render() {
@msteckyefantis
msteckyefantis / index.js
Last active December 10, 2017 05:16
Lambda function handler related to an example in a Medium Article.
'use strict';
const vandium = require( 'vandium' );
const getSizeOfWebsitePromise = require(
'./lambda_function_logic/get_size_of_website_promise'
);
const websiteUrlRegex = /^https:\/\/lessonshop.net$|^https:\/\/vandium.io$|https:\/\/github.com$/;