Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Flosi richard-flosi

  • Remote, US
View GitHub Profile
@richard-flosi
richard-flosi / build.sh
Created Jul 14, 2020
Build Script to Deploy Flutter Web app on Netlify
View build.sh
#!/bin/bash
# Get flutter
git clone https://github.com/flutter/flutter.git
FLUTTER=flutter/bin/flutter
# Configure flutter
FLUTTER_CHANNEL=master
FLUTTER_VERSION=v1.17.0
$FLUTTER channel $FLUTTER_CHANNEL
@richard-flosi
richard-flosi / operations.js
Created Apr 27, 2020
serverless express-openapi over netlify functions
View operations.js
const usersApi = require("./users");
module.exports = {
// /users
"post-users": usersApi.post,
"get-users": usersApi.get,
// /users/{userId}
"get-users-userId": usersApi.get,
"patch-users-userId": usersApi.patch,
"delete-users-userId": usersApi.delete,
@richard-flosi
richard-flosi / flutter-netlify-build.sh
Last active Sep 2, 2020
Netlify Build command script to deploy a Flutter Web App
View flutter-netlify-build.sh
#!/bin/sh
FLUTTER_BRANCH=`grep channel: .metadata | sed 's/ channel: //g'`
FLUTTER_REVISION=`grep revision: .metadata | sed 's/ revision: //g'`
git clone https://github.com/flutter/flutter.git
cd flutter
git checkout $FLUTTER_BRANCH
git pull origin $FLUTTER_BRANCH
git checkout $FLUTTER_REVISION
cd ..
@richard-flosi
richard-flosi / star-wars-planets.html
Last active Sep 4, 2020
Web Component using Custom Element, Shadow DOM, fetch, async/await, and the Star Wars API
View star-wars-planets.html
<html>
<head>
<script>
customElements.define("star-wars-planets", class extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
}
static get observedAttributes() { return ["loading", "planets"]; }
@richard-flosi
richard-flosi / trilateration.js
Last active Jul 30, 2020
JavaScript Trilateration
View trilateration.js
// Created by Derrick Cohodas (dav-)
// Based on the Python example by StackExchange user wwnick from http://gis.stackexchange.com/a/415/41129
// Requires the Mathjs library - http://mathjs.org/
var math = require('mathjs')
/**
* Represents a coordinate with a distance
* @param {Number} lat Latitude
@richard-flosi
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
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
require('spine/lib/local');
require('spine/lib/ajax');
require('spine/lib/route');
require('spine/lib/manager');
@richard-flosi
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,
@richard-flosi
richard-flosi / package.json
Created Mar 17, 2014
.html extension compiler for nunjucks templates in hem for spine.
View package.json
# add hem and nunjucks to your package.json
{
...
"dependencies": {
...
"hem": "~0.3.6",
"nunjucks": "~1.0.1"
}
}
@richard-flosi
richard-flosi / slug.js
Created Mar 13, 2014
Use ect.js templates with hem by adding this to your slug.js for your spine.js project.
View slug.js
var argv = process.argv.slice(2);
var fs = require('fs');
var path = require('path');
var hem = new (require('hem'))();
var ect = require('ect');
// ect compiler
hem.compilers.ect = function(path) {
var renderer, content, template;
renderer = ect({});
You can’t perform that action at this time.