Skip to content

Instantly share code, notes, and snippets.

View johanalkstal's full-sized avatar

Johan Alkstål johanalkstal

View GitHub Profile
@johanalkstal
johanalkstal / example.js
Last active April 29, 2024 03:12
Basic Svelte Store Routing
/**
* Basic example of routerless store based routing.
* To understand what is going on check out
* https://svelte.dev/tutorial/writable-stores
* https://www.npmjs.com/package/feather-route-matcher
*/
// stores.js
@johanalkstal
johanalkstal / actions.js
Last active May 21, 2017 17:09
Mithril stream experiment
// @flow
export const UPDATE_USER = 'UPDATE_USER'
export const updateUser = (payload: Object) => ({
type: UPDATE_USER,
payload
})
@johanalkstal
johanalkstal / sum.js
Last active September 21, 2015 09:48
Get sum of numbers using destructuring
function sum(numbers) {
return loop(0, numbers);
function loop(total, numbers) {
if (numbers.length === 0) {
return total;
}
let [head, ...tail] = numbers;
return loop(head + total, tail);
@johanalkstal
johanalkstal / jabbr-ignore
Last active August 29, 2015 14:14
JabbR Ignore bookmarklet
javascript: (function() {
var interval = 1000;
var users = ['username'];
setInterval(function() {
users.forEach(function(user) {
var messages = document.querySelectorAll('li.message[data-name="' + user + '"]');
anon true, if the space may be omitted in anonymous function declarations
bitwise true, if bitwise operators should be allowed
browser true, if the standard browser globals should be predefined
cap true, if upper case HTML should be allowed
continue true, if the continuation statement should be tolerated
css true, if CSS workarounds should be tolerated
debug true, if debugger statements should be allowed
devel true, if logging should be allowed (console, alert, etc.)
eqeq true, if == should be allowed
es5 true, if ES5 syntax should be allowed