Skip to content

Instantly share code, notes, and snippets.

View Stack.js
class Stack {
constructor() {
this.items = [];
}
push(item) {
return this.items.push(item);
}
pop() {
View machine.js
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',
View marvel-test-data.json
{"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":"
View renderTemplate.js
/**
* @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){
@linkstrifer
linkstrifer / script.js
Created Aug 8, 2017
search for string on files and replace with something else using node
View script.js
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 / css.css
Created May 12, 2017
Attach event to future events, vanilla js
View css.css
div {
background-color: red;
height: 20px;
margin: 10px;
width: 20px;
}
@linkstrifer
linkstrifer / app.jsx
Last active May 11, 2017
React function vs class component example
View app.jsx
class Form extends React.Component {
state = {
name: '',
selectedRadio: 'radio1'
};
handleInputChange = (event) => {
event.persist();
this.setState(() => ({name: event.target.value}));
};
View designer.html
<link rel="import" href="../components/polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
You can’t perform that action at this time.