Skip to content

Instantly share code, notes, and snippets.

View arxpoetica's full-sized avatar
🌼
Hope for a better world

Robert Hall arxpoetica

🌼
Hope for a better world
View GitHub Profile
/* global localStorage */
import { writable } from 'svelte/store'
const storage = typeof localStorage !== 'undefined' ? localStorage : {
removeItem: key => { if (storage[key]) { delete storage[key] } },
}
/**
* Tracks storage both in `localStorage` and in svelte's `writable` stores
* Usage: `const name = storable('name', 'arxpoetica')`
{
"errors": [
{
"message": "Assignment to constant variable.",
"locations": [
{
"line": 2,
"column": 3
}
],
import './src/_server/build/config'
import resolve from 'rollup-plugin-node-resolve';
import replace from 'rollup-plugin-replace';
import commonjs from 'rollup-plugin-commonjs';
// import builtins from 'rollup-plugin-node-builtins'
// import globals from 'rollup-plugin-node-globals'
import svelte from 'rollup-plugin-svelte';
import babel from 'rollup-plugin-babel';
import { terser } from 'rollup-plugin-terser';
@arxpoetica
arxpoetica / mixins.pug
Created April 22, 2018 09:38
Useful Pug mixins for Svelte
mixin head
svelte:head
block
mixin title(expression)
+head
title!= expression
mixin if(expression)
!= '{#if ' + expression + '}'
block
!= '{/if}'

Contributing

Yes, please do contribute! We want you to feel as involved as you need or want to be. Here are some tips to get rolling.

Be Social

@arxpoetica
arxpoetica / Screen.js
Last active November 23, 2017 06:14
Svelte Redux-Zero State Machine
import StateMachine from './StateMachine'
export default {
data() {
return {
screenWidth: 0,
screenHeight: 0,
}
},

Keybase proof

I hereby claim:

  • I am arxpoetica on github.
  • I am arxpoetica (https://keybase.io/arxpoetica) on keybase.
  • I have a public key whose fingerprint is 9F52 3F01 CAAA B80E 498A 6BDB 9FD2 B739 0C92 FBF8

To claim this, I am signing this object:

@arxpoetica
arxpoetica / happy.min.js
Created November 7, 2016 22:21
Unfortunate var `happy` goes bye bye
// happy forms: http://happyjs.com/
!function(a){function b(b){return"".trim?b.val().trim():a.trim(b.val())}a.fn.isHappy=function(c){function g(a){return!!(a&&a.constructor&&a.call&&a.apply)}function h(b){var d=c.classes&&c.classes.message||"unhappyMessage";return a('<span id="'+b.id+'" class="'+d+'" role="alert">'+b.message+"</span>")}function i(a){return g(c.errorTemplate)?c.errorTemplate(a):h(a)}function j(){var a,b,e=!1;for(a=0,b=d.length;b>a;a+=1)d[a].testValid(!0)||(e=!0);return e?(g(c.unHappy)&&c.unHappy(),!1):c.testMode?(g(c.happy)&&c.happy(),window.console&&console.warn("would have submitted"),!1):(g(c.happy)&&c.happy(),void 0)}function k(){f=!1;}function l(){f=!0,a(window).bind("mouseup",k);}function m(e,h){var j=a(h),k={message:e.message||"",id:h.slice(1)+"_unhappy"},l=a(k.id).length>0?a(k.id):i(k),m=function(){f?a(window).bind("mouseup",j.testValid.bind(this)):j.testValid();};d.push(j),j.testValid=function(d){var f,h,i,k=a(this),m=e.errorTarget&&a(e.errorTarget)||k,n=!1,o=!!k.get(0).attributes.get
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {