Skip to content

Instantly share code, notes, and snippets.

@diegocardoso93
diegocardoso93 / usePersist.js
Last active March 25, 2021 21:28
simple localstorage hook abstraction
export default function usePersist(target) {
const setItem = (key, value) =>
localStorage.setItem(key, JSON.stringify(value));
const set = target
? (value) => setItem(target, value)
: (key, value) => setItem(key, value);
const getItem = (key) => JSON.parse(localStorage.getItem(key));
// ---------------------------------
// LDL - LED DESCRIPTION LANGUAGE
// Arduino Lisp-like LED Animations :D
// Diego Cardoso 2017.1
// ---------------------------------
// LED_BLINK {@PARAMS: function?, time_on, time_off, duration}
// LED_ON {@PARAMS: function?, duration, intensity}
// LED_OFF {@PARAMS: function?, int duration}
// LED_COLOR_TRANSITION {@PARAMS: function?, String color_init, String color_end, int duration}
// ---------------------------------
import math
if (
4 == 4 == 4 ==
1+1+1+1 == 8-1-1-1-1 ==
2*2 == 8/2 ==
math.pow(1,999)+3 == math.pow(2,2) ==
2**2 == math.log(16,2) ==
math.log(16)/math.log(2) ==
math.log10(16)/math.log10(2) ==
1<<2 == 8>>1 ==
@diegocardoso93
diegocardoso93 / src_pages_about_about.html
Last active May 20, 2018 11:51
ionic scope visibility and bind example
<ion-header>
<ion-navbar>
<ion-title>
About
</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<p>{{textToBind}}</p>
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@diegocardoso93
diegocardoso93 / designer.html
Last active August 29, 2015 14:21
designer
<link rel="import" href="../topeka-elements/topeka-datasource.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../paper-tabs/paper-tab.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: relative;