Skip to content

Instantly share code, notes, and snippets.

View brunoksato's full-sized avatar
Focusing

Bruno Sato brunoksato

Focusing
View GitHub Profile
@munificent
munificent / generate.c
Last active January 27, 2025 18:14
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u
@sibelius
sibelius / route.ts
Created January 28, 2019 00:41
routeTo helper to handle params and query string
import { generatePath } from 'react-router-dom';
import { stringify } from 'query-string';
const routeTo = (path: string, params: object, qs: object) => {
const url = generatePath(path, params);
return qs ? `${url}?${stringify(qs}` : url;
}
history.push(routeTo('admin/view/:id', { id: 'ok'}, { anotherParam: 'value' }));
@brunolemos
brunolemos / ExampleComponent.tsx
Last active May 27, 2020 14:00
Redux + TypeScript - Strongly Typed
import React from 'react'
import { Button, Text, View } from 'react-native'
import { useDispatch } from 'react-redux'
import { useReduxState } from '../hooks/use-redux-state'
import * as actions from '../redux/actions'
import * as selectors from '../redux/selectors'
export function LoginScreen() {
const dispatch = useDispatch()
@brunolemos
brunolemos / TouchableScale.tsx
Created September 21, 2018 20:38
Touchable component with Scale effect, common on iOS 12 (works on mobile and web)
// Demo: https://snack.expo.io/@brunolemos/touch-button-scale-effect
import React from 'react'
import { Animated, StyleProp, TouchableWithoutFeedback, TouchableWithoutFeedbackProps, ViewStyle } from 'react-native'
import { styleMerge } from 'shared/src/utils'
export interface TouchableScaleProps extends TouchableWithoutFeedbackProps {
containerStyle?: StyleProp<ViewStyle>
}
func autocomplete(index, Type, term string) []string {
client, _ := elastic.NewSimpleClient(elastic.SetURL("http://00.00.00.00:9200"),
elastic.SetErrorLog(log.New(os.Stderr, "ELASTIC ", log.LstdFlags)),
elastic.SetInfoLog(log.New(os.Stdout, "", log.LstdFlags)))
ctx := context.Background()
tagSuggester := elastic.NewCompletionSuggester("sticker-suggest").Fuzziness(0).Text(term).Field("tags").SkipDuplicates(true)
searchSource := elastic.NewSearchSource().
@bvaughn
bvaughn / index.md
Last active February 25, 2025 15:56
Interaction tracing with React

This API was removed in React 17


Interaction tracing with React

React recently introduced an experimental profiler API. After discussing this API with several teams at Facebook, one common piece of feedback was that the performance information would be more useful if it could be associated with the events that caused the application to render (e.g. button click, XHR response). Tracing these events (or "interactions") would enable more powerful tooling to be built around the timing information, capable of answering questions like "What caused this really slow commit?" or "How long does it typically take for this interaction to update the DOM?".

With version 16.4.3, React added experimental support for this tracing by way of a new NPM package, scheduler. However the public API for this package is not yet finalized and will likely change with upcoming minor releases, so it should be used with caution.

@felipehfs
felipehfs / binaryTree.go
Last active May 31, 2019 12:36
Binary Tree
package main
/*
® 2018 - Felipe Henrique - All rigths reserved
Algoritmo de arvore binária
*/
import (
"fmt"
)
@mousetree
mousetree / config.yml
Created July 10, 2018 16:18
CircleCI v2.0 config for deployment to Google Kubernetes Engine (GKE)
version: 2
jobs:
build_and_test:
docker:
- image: circleci/node:10
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
@IbraheemAlSaady
IbraheemAlSaady / config.yml
Last active November 8, 2019 18:49
CircleCI 2 Google Cloud Kubernetes Deployment
version: 2
jobs:
build:
working_directory: ~/your-project-name
docker:
- image: circleci/node:9.11
steps:
- checkout
- setup_remote_docker
- run:
@sebmarkbage
sebmarkbage / The Rules.md
Last active April 12, 2025 17:55
The Rules of React

The Rules of React

All libraries have subtle rules that you have to follow for them to work well. Often these are implied and undocumented rules that you have to learn as you go. This is an attempt to document the rules of React renders. Ideally a type system could enforce it.

What Functions Are "Pure"?

A number of methods in React are assumed to be "pure".

On classes that's the constructor, getDerivedStateFromProps, shouldComponentUpdate and render.