Skip to content

Instantly share code, notes, and snippets.

View stephenway's full-sized avatar

Stephen Way stephenway

View GitHub Profile
@stephenway
stephenway / _app.tsError.tsx
Created August 11, 2019 15:12
Next.js + Typescript Main App Class Errors
Class static side 'typeof MyApp' incorrectly extends base class static side 'typeof App'.
Types of property 'getInitialProps' are incompatible.
Type '({ Component, ctx }: any) => Promise<{ pageProps: {}; locale?: undefined; messages?: undefined; initialNow?: undefined; } | { query: any; authtoken: string; isLoggedIn: boolean; locale: any; messages: any; initialNow: number; pageProps?: undefined; } | { ...; }>' is not assignable to type '(context: NextAppContext<Record<string, string | string[] | undefined>, {}>) => Promise<DefaultAppIProps>'.
Type 'Promise<{ pageProps: {}; locale?: undefined; messages?: undefined; initialNow?: undefined; } | { query: any; authtoken: string; isLoggedIn: boolean; locale: any; messages: any; initialNow: number; pageProps?: undefined; } | { ...; }>' is not assignable to type 'Promise<DefaultAppIProps>'.
Type '{ pageProps: {}; locale?: undefined; messages?: undefined; initialNow?: undefined; } | { query: any; authtoken: string; isLoggedIn: boolean; locale: any;
@stephenway
stephenway / nestedArray.js
Created February 7, 2019 15:58
Flatten a nested array to a single level array
// Setup nested array
var array1 = [[1,2,[3]],4];
// Iterate over the nested array and reduce/concat
function flattenArray(arr1) {
return arr1.reduce((acc, val) => Array.isArray(val) ? acc.concat(flattenArray(val)) : acc.concat(val), []);
}
// Run the nested array through our function
flattenArray(array1);
body, h1, h2, h3, h4, h5, h6 {
color: #fff;
}
body {
margin-top: 0;
}
body,
.content {
@stephenway
stephenway / ButtonExamples.jsx
Created July 31, 2017 22:31
MDStyled Button Examples
<div>
<Button handleRoute = {() => {}}>Default</Button>
<Button raised handleRoute={() => {}}>Raised</Button>
<Button dense handleRoute={() => {}}>Dense Default</Button>
<Button raised dense handleRoute={() => {}}>Dense Raised</Button>
<Button compact handleRoute={() => {}}>Compact</Button>
<Button compact raised handleRoute={() => {}}>Compact Raised</Button>
<Button primary handleRoute={() => {}}>Default with Primary</Button>
<Button raised primary handleRoute={() => {}}>Raised with Primary</Button>
<Button accent handleRoute={() => {}}>Default with Accent</Button>
@stephenway
stephenway / fullscreen.cljs
Created January 31, 2017 16:31
Clojurescript Fullscreen Button
(defn get-canvas []
"Returns canvas that will be fullscreened after a click."
(let [canvas (.getElementById js/document "article")
btnStatusBoard (.getElementById js/document "btnStatusBoard")]
(when canvas (.addEventListener btnStatusBoard "click" #(.webkitRequestFullscreen canvas)))
canvas))
(dom/button #js {:className "c-button c-button--text"
:id "btnStatusBoard"
:title (tr "Fullscreen")}
@stephenway
stephenway / style_helpers.cljs
Created October 25, 2016 18:11
Garden helpers for CSS in cljs
(ns project.ui.style-helpers
(:require [om.next :as om :refer-macros [defui]]
[om.dom :as dom]
[om-css.core :as csc]
[garden.core :as g]
[garden.stylesheet :as gs]
[garden.selectors :as s]))
(def ^:once browsers
@stephenway
stephenway / color.cljs
Created October 25, 2016 18:10
Color palette for cljs
(ns project.ui.color)
(def orange
{:50 "#ffcc80"
:100 "#ffc16d"
:200 "#ffb75c"
:300 "#ffad4a"
:400 "#fea139"
:500 "#ff9800"
:600 "#f98d1d"
@stephenway
stephenway / .spacemacs
Created September 7, 2016 17:44
My spacemacs config
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@stephenway
stephenway / SassMeister-input.scss
Created December 4, 2013 17:07 — forked from lunelson/SassMeister-input.scss
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.10)
// ----
/*
A slightly more automated approach to BEM modifier classes:
using '&' parent selector interpolation, modifiers extend their bases,
so that HTML markup requires only the modifier class not the base *and* modifier
*/
@stephenway
stephenway / onClick-class.cljs
Created December 29, 2015 18:01
On click, add this class to my object
(ns projectName.core
(:require
goog.object
[om.next :as om :refer-macros [defui]]
[om.dom :as dom]
[untangled.dom :as udom]
))
(defui Root
Object