Skip to content

Instantly share code, notes, and snippets.

View betiol's full-sized avatar
🏠
Working from home

Nikollas Betiol betiol

🏠
Working from home
View GitHub Profile
import { useState, useEffect } from 'react';
import { database } from './';
import UserStorage from '../shared/UserStorage';
export async function save(data) {
const { uid } = await UserStorage.getUser();
const request = await database.ref(`user/${uid}/decks`);
await request.push({ ...data });
}
@joseluisq
joseluisq / database.module.ts
Last active April 18, 2023 07:40
Nest Database Module (Type ORM) with environment variables support
import { Module, Global, DynamicModule } from '@nestjs/common'
import { EnvModule } from './env.module'
import { EnvService } from './env.service'
import { TypeOrmModule } from '@nestjs/typeorm'
function DatabaseOrmModule (): DynamicModule {
const config = new EnvService().read()
return TypeOrmModule.forRoot({
type: config.DB_TYPE,
@bvaughn
bvaughn / eager-prefetching-async-data-example.js
Last active November 30, 2022 21:16
Advanced example for eagerly prefetching async data in a React component.
// This is an advanced example! It is not intended for use in application code.
// Libraries like Relay may make use of this technique to save some time on low-end mobile devices.
// Most components should just initiate async requests in componentDidMount.
class ExampleComponent extends React.Component {
_hasUnmounted = false;
state = {
externalData: null,
};
@jeffijoe
jeffijoe / app.js
Last active September 1, 2023 07:34
Streaming uploads through Koa.
import Koa from 'koa'
import parse from './busboy'
import AWS from 'aws-sdk'
const app = new Koa()
const s3 = new AWS.S3({
params: { Bucket: 'myBucket' }
})
******** PARTE 1 - COMANDOS BÁSICOS
## Para listar as imagens existentes localmente
-> docker images
## Para rodar um container
-> docker run -it centos /bin/bash
run > executar uma imagem
-i > interatividade
@betiol
betiol / Distances.js
Last active May 9, 2017 18:25
Get distance by Latitude & Longitude KM/Meters/Miles
var Distance = (function () {
var toRad = function (num) {
return num * Math.PI / 180
}
return function Distance(start, end, options) {
options = options || {}
var radii = {
@webuniverseio
webuniverseio / forceUpdate.js
Created April 2, 2017 16:01
react-redux forceUpdate
componentDidMount() {
let prevState = this.props.getState();
this.unsubscribe =
this.props.subscribe(() => {
const state = this.props.getState();
if (state != prevState) {
this.forceUpdate();
prevState = state;
}
});
import React, {Component} from 'react';
class $NAME extends Component {
render() {
return (
);
}
}
@geoffreydhuyvetters
geoffreydhuyvetters / react_fiber.md
Last active January 13, 2023 06:49
What is React Fiber? And how can I try it out today?
import React from 'react';
import {
View,
Text,
} from 'react-native';
import { TextInputMask } from 'react-native-masked-text'
export default function maskedInputTemplate(locals) {
if (locals.hidden) {
return null;