Skip to content

Instantly share code, notes, and snippets.

View lucasbento's full-sized avatar
:shipit:

Lucas Bento lucasbento

:shipit:
View GitHub Profile
@reyawn
reyawn / vs-code-icon-names.json
Created October 28, 2016 13:45
Visual Studio Code icon names for shortcuts
[
"alert",
"arrow-down",
"arrow-left",
"arrow-right",
"arrow-small-down",
"arrow-small-left",
"arrow-small-right",
"arrow-small-up",
"arrow-up",
function transformOrigin(matrix, origin) {
const { x, y, z } = origin;
const translate = MatrixMath.createIdentityMatrix();
MatrixMath.reuseTranslate3dCommand(translate, x, y, z);
MatrixMath.multiplyInto(matrix, translate, matrix);
const untranslate = MatrixMath.createIdentityMatrix();
MatrixMath.reuseTranslate3dCommand(untranslate, -x, -y, -z);
MatrixMath.multiplyInto(matrix, matrix, untranslate);
@kastermester
kastermester / es-preset.js
Created October 25, 2016 11:51
Webpack hot reloading of relay schemas
// loaction: loaders/es-preset.js
// This file is a combination of the following babel presets:
// es2015, react, stage-0.
// Difference is that the es2015-template-literals is taken out. Of the es2015 preset.
// This allows us to run relay transformations on the code afterwards (which will then transform any remaining template literals).
module.exports = preset({});
function preset(context, opts) {
var moduleTypes = ["commonjs", "amd", "umd", "systemjs"];
var loose = false;
@knowbody
knowbody / ex-navigation.md
Last active July 17, 2023 10:14
My exponent's ex-navigation docs/thoughts

Exponent - ex-navigation

This is for now, for my personal use only, things might not be correctly explained here. For the official docs please check: https://github.com/exponentjs/ex-navigation/blob/master/README.md

Navigation bar configuration

On every screen you can use the built-in navigation bar, you can add a title, left button, right button or change navigation bar’s style. All you need to do is pass appropriate params to navigationBar in the route configuration:

import React, { Component } from 'react';
@vdh
vdh / Root.jsx
Created September 26, 2016 23:55
Moderately-successful hot reloading for react-router v3
import React, { PropTypes } from 'react';
import { Provider } from 'react-redux'; // Or something else, if you're not using Redux
import Router from 'react-router/lib/Router';
const Root = ({ store, history, routes }) => (
<Provider store={store} key="provider">
<Router history={history} routes={routes} />
</Provider>
);
@mjackson
mjackson / resolvePromise.js
Last active September 9, 2018 08:23
An easy way to do async APIs in JavaScript that support both promises *and* callbacks!
// Here is a function that I use all the time when creating public
// async APIs in JavaScript:
const resolvePromise = (promise, callback) => {
if (callback)
promise.then(value => callback(null, value), callback)
return promise
}
// Sometimes I like to use callbacks, but other times a promise is
@sibelius
sibelius / prepareObjectSnapshot.js
Created September 15, 2016 21:39
Prepare an object to be snapshoted by jest
/**
* Prepare an object to be snapshoted by jest
* replace objectID
* replace datetime
* frozen same specific keys
* @param obj
* @returns {{}}
*/
export function prepareObject(obj, frozenKeys = []) {
const placeholder = {};
@taion
taion / server.js
Last active March 11, 2024 10:20
GraphQL subscription server with Socket.IO, backed by Redis Pub/Sub
const redisClient = redis.createClient(REDIS_URL);
const listeners = Object.create(null);
function addListener(channel, listener) {
if (!listeners[channel]) {
listeners[channel] = [];
redisClient.subscribe(channel);
}
listeners[channel].push(listener);
@dseelmann
dseelmann / .eslintrc
Last active April 4, 2017 08:37 — forked from kastigar/ TASK.md
Test task
{
"extends": "airbnb",
"parser": "babel-eslint",
"settings": {
"import/resolver": "webpack"
}
}
@montanaflynn
montanaflynn / CONCURRENCY.md
Last active November 7, 2024 18:22
Examples of sequential, concurrent and parallel requests in node.js

Concurrency in JavaScript

Javascript is a programming language with a peculiar twist. Its event driven model means that nothing blocks and everything runs concurrently. This is not to be confused with the same type of concurrency as running in parallel on multiple cores. Javascript is single threaded so each program runs on a single core yet every line of code executes without waiting for anything to return. This sounds weird but it's true. If you want to have any type of sequential ordering you can use events, callbacks, or as of late promises.