Navigation Menu

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
  • 07:42 (UTC -03:00)
View GitHub Profile
@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 / 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
@marlosirapuan
marlosirapuan / example_activejob.rb
Created October 5, 2019 00:41 — forked from ChuckJHardy/example_activejob.rb
Example ActiveJob with RSpec Tests
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
@marlosirapuan
marlosirapuan / WebView.js
Created May 8, 2019 15:16
React Native navigationOptions stateless component
// app.js
const onPressOpenLink = async (url, title) => {
const { navigate } = props.navigation
navigate('Web', { url: url, title: title })
}
// webview.js
import React, { useState, useEffect } from 'react'
import { WebView } from 'react-native-webview'
@marlosirapuan
marlosirapuan / docker-compose.yml
Created September 3, 2019 14:20
Mautic config
version: '3'
networks:
default:
driver: bridge
webproxy:
external: true
services:
db:
import React from "react"
import Checkbox from "./Checkbox"
import { render, fireEvent, cleanup } from "react-testing-library"
afterEach(cleanup)
it("testa check", () => {
const { getByTestId } = render(<Checkbox />)
fireEvent.click(getByTestId("meucheck"))
expect(getByTestId("meucheck").value).toEqual("123");
@marlosirapuan
marlosirapuan / test_helper.rb
Created July 25, 2019 20:02
Minitest hooks
class ActiveSupport::TestCase
def self.prepare
# Add code that needs to be executed before test suite start
end
prepare
def setup
# Add code that need to be executed before each test
end
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'activerecord', '5.1.3'
@marlosirapuan
marlosirapuan / docker-commands.md
Created May 21, 2019 18:02
Some Docker commands

STOP ALL CONTAINERS

$ docker stop $(docker ps -a -q)

REMOVE ALL CONTAINERS

$ docker rm $(docker ps -a -q)
@marlosirapuan
marlosirapuan / InputMask.md
Last active May 1, 2019 22:40
Ant Design with InputMask

Based on this comment

Fix warning when use react-hooks:
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?

// shared/InputMask.js

import { Input } from 'antd'
import React, { forwardRef } from 'react'