Skip to content

Instantly share code, notes, and snippets.

Richard Flosi richard-flosi

  • Remote, US
Block or report user

Report or block richard-flosi

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
richard-flosi /
Last active Jan 20, 2020
Netlify Build command script to deploy a Flutter Web App
FLUTTER_BRANCH=`grep channel: .metadata | sed 's/ channel: //g'`
FLUTTER_REVISION=`grep revision: .metadata | sed 's/ revision: //g'`
git clone
cd flutter
git checkout $FLUTTER_BRANCH
git pull origin $FLUTTER_BRANCH
git checkout $FLUTTER_REVISION
cd ..
richard-flosi / stock-profit.js
Created Aug 13, 2018
Find the maximum amount of profit you could have made buying and selling a stock using yesterday's stock prices.
View stock-profit.js
Given a list of stock prices of a stock from yesterday (indices are represent time),
write a function that returns the most profit you could have made if you had bought and sold at the optimal time.
For example, if you had bought at a share price of $5 and sold at $9 you would have made a profit of $4.
Keep in mind you must buy before you can sell.
const yesterdayStockPrices = [10, 7, 5, 8, 8, 9, 2, 4];
function returnMaxProfit(prices) {
let maxProfit = 0;
richard-flosi / uniqueArray.js
Created Aug 8, 2018
Function to return a filtered array containing only unique objects in memory
View uniqueArray.js
Please write a JavaScript function that
takes an array of objects and returns a
unique-ified version of the same array.
To be clear, the goal is just to
remove any duplicate objects that reference
the same object in memory. The result can
have multiple objects with the same properties
as long as they are different objects in memory.
richard-flosi / flattenArray.js
Created Aug 3, 2018
Javascript Flatten Array Example using reduce and recursion
View flattenArray.js
function reducer(accumulator, currentValue) {
if (Array.isArray(currentValue)) {
// recurse to flatten the nested array
return accumulator.concat(flattenArray(currentValue));
} else {
// otherwise concat the value
return accumulator.concat(currentValue);
richard-flosi / star-wars-planets.html
Last active Jan 20, 2020
Web Component using Custom Element, Shadow DOM, fetch, async/await, and the Star Wars API
View star-wars-planets.html
customElements.define("star-wars-planets", class extends HTMLElement {
constructor() {
this.attachShadow({ mode: "open" });
static get observedAttributes() { return ["loading", "planets"]; }
View gist:8c4ade400188d1c91e8964ff3211d091
// Created by Derrick Cohodas (dav-)
// Based on the Python example by StackExchange user wwnick from
// Requires the Mathjs library -
var math = require('mathjs')
* Represents a coordinate with a distance
* @param {Number} lat Latitude
richard-flosi / first.js
Last active Aug 29, 2015
This gist is an example of the problem I was having in
View first.js
// This is the first test in a group
var Test;
Test = {
before: function(browser) {
.waitForElementVisible('input[name="q"]', 10000);
richard-flosi / assertions-compareScreenshot.js
Created Aug 27, 2014
Nightwatch with Visual Regression testing
View assertions-compareScreenshot.js
// assertions/compareScreenshot.js
var resemble = require('resemble'),
fs = require('fs');
exports.assertion = function(filename, expected) {
var screenshotPath = 'test/screenshots/',
baselinePath = screenshotPath + 'baseline/' + filename,
resultPath = screenshotPath + 'results/' + filename,
diffPath = screenshotPath + 'diffs/' + filename;
richard-flosi / app.js
Created Apr 9, 2014
Spine App example with navigation method
View app.js
module.exports = (function() {
var App,
Spine = require('spine'),
$ = Spine.$;
// extend Spine
richard-flosi / slug.js
Created Apr 9, 2014
Hem precompiler for nunjucks templates
View slug.js
/* jshint node: true */
var argv = process.argv.slice(2);
var fs = require('fs');
var hem = new (require('hem'))();
hem.compilers.html = function(path) {
var nunjucks = require('nunjucks'),
name = path.split('app/')[1],
opts = {
name: name,
You can’t perform that action at this time.