Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

import React, {Component} from 'react';
import {bindActionCreators} from "redux"
import { connect } from 'react-redux';
import {schema, getModelByType} from "models/models"
import SomeFormComponent from "SomeFormComponent"
import {selectedItemSelector, isEditingSelector} from "selectors/entities"
let mapStateToProps = (state) => {
// @flow
import type { A } from 'my-module';
const myFunction = (foo: A): boolean => !!foo;
@jribeiro
jribeiro / isomorphic-fetch.js
Created September 8, 2016 19:01
An attempt to create a flowtype definition for the fetchAPI
// flow-typed signature: 11e550b72570f3e50044485062a42c26
// flow-typed version: 33aa7c82cd/isomorphic-fetch_v2.x.x/flow_>=v0.27.x
declare type $Fetch$RequestMode = 'cors' | 'no-cors' | 'cors-with-forced-preflight' | 'same-origin' | 'navigate';
declare type $Fetch$RequestCredentials = 'omit' | 'same-origin' | 'include';
declare type $Fetch$RequestRedirect = 'follow' | 'error' | 'manual';
declare type $Fetch$RequestCache = 'default' | 'no-store' | 'reload' | 'no-cache' | 'force-cache';
declare type $Fetch$ResponseType = 'basic' | 'cors' | 'error' | 'opaque';
declare type $Fetch$ReferrerPolicy = 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' |
'origin-when-cross-origin' | 'unsafe-url';
@jribeiro
jribeiro / gc.stp
Last active August 29, 2015 14:16 — forked from bnoordhuis/gc.stp
#!/usr/bin/env stap
global samples
global all_samples
global timestamp
probe process("node").mark("gc__start")
{
timestamp = gettimeofday_us()
}

The prep-script.sh will setup the latest Node and install the latest perf version on your Linux box.

When you want to generate the flame graph, run the following (folder locations taken from install script):

sudo sysctl kernel/kptr_restrict=0

perf record -i -g -e cycles:u -- ~/sources/node/node --perf-basic-prof script.js

perf script | egrep -v "( __libc_start| LazyCompile | v8::internal::| Builtin:| Stub:| LoadIC:|\[unknown\]| LoadPolymorphicIC:)" | sed 's/ LazyCompile:[*~]\?/ /' | ~/sources/FlameGraph/stackcollapse-perf.pl > out.perf-folded
<link rel="import" href="../components/polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@jribeiro
jribeiro / Article.md
Created January 16, 2014 23:01 — forked from Warry/Article.md

How to make faster scroll effects?

  • Avoid too many reflows (the browser to recalculate everything)
  • Use advanced CSS3 for graphic card rendering
  • Precalculate sizes and positions

Beware of reflows

The reflow appens as many times as there are frames per seconds. It recalculate all positions that change in order to diplay them. Basically, when you scroll you execute a function where you move things between two reflows. But there are functions that triggers reflows such as jQuery offset, scroll... So there are two things to take care about when you dynamically change objects in javascript to avoid too many reflows:

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@jribeiro
jribeiro / LICENSE.txt
Created October 26, 2011 15:06 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE