Skip to content

Instantly share code, notes, and snippets.

View dariocravero's full-sized avatar

Darío Javier Cravero dariocravero

View GitHub Profile
@dariocravero
dariocravero / after.js
Last active July 23, 2018 09:32
react-context
import React from 'react'
const ThemeContext = React.createContext({
color: 'orange',
toggleColor() {},
})
class Theme extends React.Component {
state = {
color: 'orange',
import { Animation, Globals } from 'react-spring/dist/web'
const withDefault = (value, defaultValue) => (value === undefined || value === null ? defaultValue : value)
const stiffnessFromOrigamiValue = oValue => (oValue - 30) * 3.62 + 194
const dampingFromOrigamiValue = oValue => (oValue - 8) * 3 + 25
const fromOrigamiTensionAndFriction = (tension, friction) => ({
stiffness: stiffnessFromOrigamiValue(tension),
damping: dampingFromOrigamiValue(friction)
})
@dariocravero
dariocravero / User.js
Last active May 16, 2018 09:41
A POC of a User/Auth context provider for React apps
import React from 'react'
const UserContext = React.createContext({})
export const Consumer = Context.Consumer
export class Provider extends React.Component {
constructor(props) {
super(props)
@dariocravero
dariocravero / access-test.js
Created March 15, 2018 09:45
access performance test
function a({ en, es, pl, fr, ch, ja }) {
return en
? 'hi'
: es
? 'hola'
: pl ? 'czezch' : fr ? 'bon jour' : ch ? 'ni hao' : ja ? 'wtf' : '';
}
const l = {
en: 'hi',

here are two commands I made a while back and some of you may find handy to find and replace stuff on the terminal:

Find JS files with stuff:

findjs stuff

Find .view files with border:

findview border
@dariocravero
dariocravero / stats.js
Created July 5, 2017 23:47
contributions for file types per person
const { execSync } = require('child_process')
function getStatsFor(person) {
const data = execSync(
`git log --name-only --author=${person} --pretty=format: | sort | uniq | sort -nr`,
{
encoding: 'utf-8',
}
)
const TIMEOUT = 100
const click = () => (dispatch, getState) => {
setTimeout(dispatch({
type: 'CLICK'
}, TIMEOUT)
}
const Button = props => {
@dariocravero
dariocravero / panels-router.js
Created September 27, 2016 16:20
router with dynamic app naming
const cleanPath = s => /\?/.test(s) ? s.match(/(.*?)\?/)[1] : s
const routes = [
'https://my-review-cert.hrw.com/content/selenas-blog--thing?q=1',
'https://my-review-cert.hrw.com/toc',
'https://very-specific.com/toc/super-toc/thing',
'https://my-review-cert.hrw.com/content/selenas-blog--thing/https://my-review-cert.hrw.com/toc',
'https://panels.com/thing/that'
]
import React, { Component } from 'react'
const click = () => ({
type: 'CLICK'
})
const reducer = (state={clicked: false}, action) => {
switch (action.type) {
case 'CLICK':
return {
@dariocravero
dariocravero / panels-and-pagesfaq.md
Created May 24, 2016 20:51
An FAQ on Panels and Pages

Panels and Pages FAQ

1) What is Pages?

It's a collaborative tool to allow teams of developers and designers to move extremely fast from concept to real applications that work on the web and on Android and iOS.

It takes a JSON and outputs React code.

Designers and developers work together on the JSON code.