Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Marlos marlosirapuan

🏠
Working from home
  • João Pessoa, PB - Brazil
View GitHub Profile
@marlosirapuan
marlosirapuan / file-upload.tsx
Created Apr 30, 2021 — forked from Sqvall/file-upload.tsx
File Upload with Chakra UI and react-hook-form
View file-upload.tsx
import { ReactNode, useRef } from 'react'
import { Button, FormControl, FormErrorMessage, FormLabel, Icon, InputGroup } from '@chakra-ui/react'
import { useForm, UseFormRegisterReturn } from 'react-hook-form'
import { FiFile } from 'react-icons/fi'
type FileUploadProps = {
register: UseFormRegisterReturn
accept?: string
multiple?: boolean
children?: ReactNode
View apollo_client.ts
import ApolloClient, { FetchPolicy } from "apollo-client"
import { HttpLink } from "apollo-link-http"
import { InMemoryCache, NormalizedCacheObject } from "apollo-cache-inmemory"
// import { setContext } from "apollo-link-context"
import ActionCable from "action-cable-react-jwt"
import ActionCableLink from "graphql-ruby-client/dist/subscriptions/ActionCableLink"
import { ApolloLink } from "apollo-link"
import { handleAuthentication, refreshToken } from "utils/oauth"
import { Observable } from "apollo-link"
import { onError } from "apollo-link-error"
@marlosirapuan
marlosirapuan / 🎵 My last week in music
Last active Aug 22, 2021
🎵 My last week in music
View 🎵 My last week in music
Accept ███▍░░░░░░░░░░░░░ 3 plays
Gary Moore ███▍░░░░░░░░░░░░░ 3 plays
Nick Cave & The Bad Seeds ██▎░░░░░░░░░░░░░░ 2 plays
Bonfire █▏░░░░░░░░░░░░░░░ 1 plays
Commodores █▏░░░░░░░░░░░░░░░ 1 plays
Dare █▏░░░░░░░░░░░░░░░ 1 plays
Deep Purple █▏░░░░░░░░░░░░░░░ 1 plays
H.E.A.T █▏░░░░░░░░░░░░░░░ 1 plays
Jeff Buckley █▏░░░░░░░░░░░░░░░ 1 plays
Ken Hensley █▏░░░░░░░░░░░░░░░ 1 plays
@marlosirapuan
marlosirapuan / Dokku v0.5.6 Rails App.md
Created Jul 30, 2020 — forked from Epigene/Dokku v0.5.6 Rails App.md
Knowledge-Base for getting a Rails5 app with Cable running on dokku v0.5.6
View Dokku v0.5.6 Rails App.md

Dokku v0.5.6 Rails workflow

Straight to Maintenance

0. Set up Droplet

Initialize the droplet with dokku app pre-setup
@marlosirapuan
marlosirapuan / Input.tsx
Created Jul 9, 2020
React custom Input
View Input.tsx
import React, {
useState,
useCallback,
forwardRef,
DetailedHTMLProps,
InputHTMLAttributes,
Ref,
useRef
} from 'react'
@marlosirapuan
marlosirapuan / launch.json
Last active Apr 17, 2020
Simple initial setup with Node, Typescript, Yarn and Vscode
View launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"protocol": "inspector",
View gist:778d6beda5f8ab95695748011c864b19

Install ffmpeg

brew install ffmpeg

Download file through url, like this:

ffmpeg -protocol_whitelist file,http,https,tcp,tls,crypto -i "http://url-file.domain.m3u8" -c copy video.mp4
@marlosirapuan
marlosirapuan / backup.sh
Created Oct 12, 2019
Tiny script to backup and restore database with Docker
View backup.sh
#!/usr/bin/env bash
echo "BACKUPING..."
docker run -i -e PGPASSWORD=<password> --rm postgres /usr/bin/pg_dump -p <port> -h <ip> -U <user> <db> | gzip -9 > backup.sql.gz
echo "BACKUPING...[END]"
if [ -n "$1" ] ; then
where="where pg_stat_activity.datname = '<db>' AND pid <> pg_backend_pid();"
fi
cat <<-EOF | docker exec -i <container_db_local> psql -h 127.0.0.1 -U <user_db> -d postgres
@marlosirapuan
marlosirapuan / example_activejob.rb
Created Oct 5, 2019 — forked from ChuckJHardy/example_activejob.rb
Example ActiveJob with RSpec Tests
View example_activejob.rb
class MyJob < ActiveJob::Base
queue_as :urgent
rescue_from(NoResultsError) do
retry_job wait: 5.minutes, queue: :default
end
def perform(*args)
MyService.call(*args)
end
View docker-compose.yml
version: '3'
networks:
default:
driver: bridge
webproxy:
external: true
services:
db: