Skip to content

Instantly share code, notes, and snippets.

<link rel="import" href="../components/polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@linkstrifer
linkstrifer / app.jsx
Last active May 11, 2017 16:36
React function vs class component example
class Form extends React.Component {
state = {
name: '',
selectedRadio: 'radio1'
};
handleInputChange = (event) => {
event.persist();
this.setState(() => ({name: event.target.value}));
};
@linkstrifer
linkstrifer / css.css
Created May 12, 2017 16:57
Attach event to future events, vanilla js
div {
background-color: red;
height: 20px;
margin: 10px;
width: 20px;
}
@linkstrifer
linkstrifer / script.js
Created August 8, 2017 21:56
search for string on files and replace with something else using node
const Finder = require('fs-finder');
const fs = require('fs');
const changeCase = require('change-case');
var files = Finder.from('./components/').findFiles('*.js');
function editFile(filePath) {
fs.readFile(filePath, 'utf-8', function(err, data) {
if (err) throw err;
@linkstrifer
linkstrifer / renderTemplate.js
Created January 22, 2018 21:25
Render template
/**
* @method fromTemplate
* @description
* Converts an HTML element string to a DOM object
*
* @param {String} templateString String representation of a DOM element (e.g. '<div>content</div>')
*
* @returns {Node}
*/
export function fromTemplate(templateString){
{"offset":0,"limit":20,"total":1491,"count":20,"results":[{"id":1011334,"name":"3-D Man","description":"","modified":"2014-04-29T14:18:17-0400","thumbnail":{"path":"http://i.annihil.us/u/prod/marvel/i/mg/c/e0/535fecbbb9784","extension":"jpg"},"resourceURI":"http://gateway.marvel.com/v1/public/characters/1011334","comics":{"available":12,"collectionURI":"http://gateway.marvel.com/v1/public/characters/1011334/comics","items":[{"resourceURI":"http://gateway.marvel.com/v1/public/comics/21366","name":"Avengers: The Initiative (2007) #14"},{"resourceURI":"http://gateway.marvel.com/v1/public/comics/24571","name":"Avengers: The Initiative (2007) #14 (SPOTLIGHT VARIANT)"},{"resourceURI":"http://gateway.marvel.com/v1/public/comics/21546","name":"Avengers: The Initiative (2007) #15"},{"resourceURI":"http://gateway.marvel.com/v1/public/comics/21741","name":"Avengers: The Initiative (2007) #16"},{"resourceURI":"http://gateway.marvel.com/v1/public/comics/21975","name":"Avengers: The Initiative (2007) #17"},{"resourceURI":"
@linkstrifer
linkstrifer / machine.js
Last active December 10, 2019 01:41
Generated by XState Viz: https://xstate.js.org/viz
const states = {
IDLE: 'IDLE',
LOADED: 'LOADED',
LOADING: 'LOADING',
SEND: 'SEND',
SENDED: 'SENDED',
SENDING: 'SENDING',
SHOW_BILL: 'SHOW_BILL',
SHOW_CATEGORIES: 'SHOW_CATEGORIES',
SHOW_CATEGORY: 'SHOW_CATEGORY',
class Stack {
constructor() {
this.items = [];
}
push(item) {
return this.items.push(item);
}
pop() {
@linkstrifer
linkstrifer / blur.js
Last active May 20, 2021 17:48
Blur elements on the page on click, add this script minified (https://javascript-minifier.com/) as a bookmark starting with `javascript:` string
(function (document) {
function _toggleBlur(event) {
event.stopPropagation();
if (window.blur_initiated) {
event.target.classList.toggle('__blur')
}
}
function addStyles() {