Skip to content

Instantly share code, notes, and snippets.

@fgnass
fgnass / keybase.md
Created November 27, 2014 23:08
Keybase proof

Keybase proof

I hereby claim:

  • I am fgnass on github.
  • I am fgnass (https://keybase.io/fgnass) on keybase.
  • I have a public key whose fingerprint is 1D87 FE70 F6DF 29D4 A059 C2F4 536D C5D7 071B 22BA

To claim this, I am signing this object:

@fgnass
fgnass / index.js
Created January 15, 2015 16:06
requirebin sketch
var debug = require('debug')
debug.enable('*')
var log = debug('test')
log('Hello world', window)
@fgnass
fgnass / index.js
Created April 3, 2015 10:33
Making node-dev work with JSX
// install node-jsx in a separate module
require('./install-jsx')
// require a jsx file
require('./test')
// keep node running ...
setInterval(function() {}, 100000)
@fgnass
fgnass / README.md
Created July 20, 2016 08:53
Ideas for JSSX

JSSX

Ideas for https://github.com/fgnass/jssx

Attribute or class?

Currently JSSX follows a simple rule to decide whether a prop is class name or a regular HTML attribute:

For any given prop, if a JSS class with the same name exits, it is interpreted as className, otherwise as attribute.

@fgnass
fgnass / styled-components.js
Last active April 20, 2017 07:03
Pattern for styled components with lots of states
import styled, { css } from 'styled-components';
const Button = styled.button`
font-size: 1em;
margin: 1em;
border: 2px solid palevioletred;
border-radius: 3px;
@fgnass
fgnass / index.js
Last active April 20, 2017 07:07
<💅> primary, secondary, :hover
import styled, { css } from 'styled-components';
const Button = styled.button`
font-size: 1em;
margin: 1em;
border: 2px solid palevioletred;
border-radius: 3px;
color: palevioletred;
${props => props.primary && css`
@fgnass
fgnass / index.js
Created July 20, 2017 20:50
React E2E testing in Headless Chrome with unexpected.js and retractor
import webdriver from 'friendly-webdriver';
import unexpected from 'unexpected';
import unexpectedWebdriver from 'unexpected-webdriver';
import retractor from 'retractor';
const expect = unexpected.clone();
expect.use(unexpectedWebdriver());
/* @jsx retractor */
@fgnass
fgnass / replay.js
Created May 4, 2018 08:58
Re-submit Alexa requests by clicking on previous inputs
// Paste this into your borwser's console on the Alexa Skill testing page:
document.addEventListener('click', ev => {
if (ev.target.matches('.askt-dialog__message--request')) {
const el = document.querySelector('.askt-utterance__input');
el.focus();
document.execCommand('insertText', false, ev.target.innerText);
el.dispatchEvent(
new KeyboardEvent('keypress', { bubbles: true, keyCode: 13 })
);
@fgnass
fgnass / history.js
Last active May 7, 2018 10:03
Use arrow keys to scroll through the input history in Amazon's Alexa simulator
(function() {
let i = 0;
const el = document.querySelector('.askt-utterance__input');
el.addEventListener('keyup', function(ev) {
const req = document.querySelectorAll('.askt-dialog__message--request');
if (ev.key == 'ArrowUp') i = i >= req.length - 1 ? 0 : i + 1;
else if (ev.key == 'ArrowDown') i = i > 0 ? i - 1 : req.length - 1;
else return;
el.value = '';
document.execCommand('insertText', false, req[i].innerText);
@fgnass
fgnass / convert.sh
Created May 31, 2018 14:19
Convert wav into mp3 files suitable for Alexa and Google Actions
#!/bin/bash
set -e
# Rename files to make them URL friendly
# https://formulae.brew.sh/formula/slugify
slugify *
# Trim silence at the beginning