Skip to content

Instantly share code, notes, and snippets.

View marlosirapuan's full-sized avatar
🏖️
Working from home

Marlos marlosirapuan

🏖️
Working from home
  • João Pessoa, PB - Brazil
  • 01:12 (UTC -03:00)
View GitHub Profile
@marlosirapuan
marlosirapuan / nord-deep.yaml
Last active April 18, 2024 19:24
Nord Deep (Warp Terminal)
# ~/.warp/themes/
accent: '#81A1C1'
background: '#111111'
details: darker
foreground: '#D8DEE9'
terminal_colors:
bright:
black: '#4C566A'
blue: '#81A1C1'
@marlosirapuan
marlosirapuan / money-input.tsx
Created December 26, 2023 12:08
Money Input for Mantine UI
// calc values divided by 100, ex:
// defaultValue={item.price / 100}
// values.item.price / 100
import { forwardRef } from 'react'
import { CurrencyInput, ICurrencyMaskProps } from 'react-currency-mask'
import { MantineSize, TextInput, TextInputProps } from '@mantine/core'
type MoneyInputComponentProps = ICurrencyMaskProps &
@marlosirapuan
marlosirapuan / app-context.ts
Created August 31, 2023 18:09
Context App Provider with zustand in Typescript
import { createContext, useContext } from 'react'
import { createStore, StoreApi } from 'zustand'
import { immer } from 'zustand/middleware/immer'
import { useStoreWithEqualityFn } from 'zustand/traditional'
type State = {
total: number
increase: () => void
decrease: () => void
@marlosirapuan
marlosirapuan / ApolloClient.ts
Created July 19, 2022 21:11 — forked from RobinDaugherty/ApolloClient.ts
Apollo client setup with ActionCable using TypeScript
import ActionCable from 'actioncable';
import { ActionCableLink } from 'graphql-ruby-client';
import { ApolloClient } from "apollo-client";
import { ApolloLink, Operation } from "apollo-link";
import { DefinitionNode, OperationDefinitionNode } from 'graphql';
import { RetryLink } from "apollo-link-retry";
import { createHttpLink } from "apollo-link-http";
import { InMemoryCache } from "apollo-cache-inmemory";
import { onError } from "apollo-link-error";
@marlosirapuan
marlosirapuan / file-upload.tsx
Created April 30, 2021 18:18 — forked from Sqvall/file-upload.tsx
File Upload with Chakra UI and react-hook-form
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
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 January 6, 2024 15:01
🎵 My last week in music
Dream Theater ██████▌░░░░░░░░░░ 25 plays
Cradle of Filth ███▉░░░░░░░░░░░░░ 15 plays
Blind Guardian ██▎░░░░░░░░░░░░░░ 9 plays
Madder Mortem ▊░░░░░░░░░░░░░░░░ 3 plays
Redemption ▊░░░░░░░░░░░░░░░░ 3 plays
Ayreon ▌░░░░░░░░░░░░░░░░ 2 plays
Caligula's Horse ▌░░░░░░░░░░░░░░░░ 2 plays
Firewind ▌░░░░░░░░░░░░░░░░ 2 plays
Haken ▌░░░░░░░░░░░░░░░░ 2 plays
Porcupine Tree ▌░░░░░░░░░░░░░░░░ 2 plays
@marlosirapuan
marlosirapuan / Input.tsx
Created July 9, 2020 11:54
React custom Input
import React, {
useState,
useCallback,
forwardRef,
DetailedHTMLProps,
InputHTMLAttributes,
Ref,
useRef
} from 'react'
@marlosirapuan
marlosirapuan / gist:778d6beda5f8ab95695748011c864b19
Last active April 13, 2024 09:28
Download .m3u8 files on MacOS

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 October 12, 2019 00:16
Tiny script to backup and restore database with Docker
#!/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