Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Ferit Topcu fokusferit

💭
I may be slow to respond.
View GitHub Profile
View Making an iron-ajax call
<link rel="import" href="https://cdn.rawgit.com/Download/polymer-cdn/master/lib/polymer/polymer.html" />
<link rel="import" href="https://cdn.rawgit.com/Download/polymer-cdn/master/lib/iron-ajax/iron-ajax.html" />
<dom-module id="ajax-element">
<template>
<iron-ajax
auto
url="https://jsonplaceholder.typicode.com/posts/1"
handle-as="json"
View Iron-ajax to make ajax calls to different URL endpoints
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html">
<link rel="import" href="../../bower_components/paper-input/paper-input.html">
<dom-module id="ajax-multiple">
<template>
<section id="content">
<paper-input id="post" label="Post" value="{{title}}" on-blur="resolve">
</paper-input>
@fokusferit
fokusferit / frontendDevlopmentBookmarks.md
Created Aug 29, 2016 — forked from dypsilon/frontendDevlopmentBookmarks.md
A badass list of frontend development resources I collected over time.
View frontendDevlopmentBookmarks.md
@fokusferit
fokusferit / simple AST creation
Last active Jan 13, 2017
Just a basic node script which saves the AST of JS code in a file.
View simple AST creation
var espree = require('espree');
var fs = require('fs');
var code = `let array = [1,2,'b'];
`;
var ast = espree.parse(code, {
ecmaVersion: 6
});
@fokusferit
fokusferit / Sample AST
Last active Jan 13, 2017
A basic AST for a one line ES6 code
View Sample AST
{
"type": "Program",
"start": 0,
"end": 23,
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 22,
"declarations": [
View Sample traversal of Espree AST
var estraverse = require('estraverse');
var fs = require('fs');
fs.readFile('./ast.json', 'utf-8', function(err, ast) {
if(err) throw err;
const data = JSON.parse(ast);
estraverse.traverse(data, {
enter: function(node, parent) {
if(node.type === "Literal" && parent.type === "ArrayExpression") {
if(!Number.isInteger(node.value)){
@fokusferit
fokusferit / enzyme_render_diffs.md
Last active Nov 23, 2022
Difference between Shallow, Mount and render of Enzyme
View enzyme_render_diffs.md

Shallow

Real unit test (isolation, no children render)

Simple shallow

Calls:

  • constructor
  • render
@fokusferit
fokusferit / browserMocks.js
Last active May 14, 2018
Add Testing Strategy to preact-cli
View browserMocks.js
// Mocks localStorage
const localStorageMock = (function() {
let store = {};
return {
getItem: (key) => store[key] || null,
setItem: (key, value) => store[key] = value.toString(),
clear: () => store = {}
};