Skip to content

Instantly share code, notes, and snippets.

View antoniopresto's full-sized avatar

Antonio Silva antoniopresto

View GitHub Profile
@antoniopresto
antoniopresto / funcions.php
Created April 24, 2019 22:31
prevent wordpress redirect subdomain
//...
remove_filter('template_redirect', 'redirect_canonical');
// https://stackoverflow.com/a/40958850
function hashStr(str) {
let hash = 0, i, chr, len;
if (str.length === 0) return hash;
for (i = 0, len = str.length; i < len; i++) {
chr = str.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
}
return hash;
# Will show all the driver packages which apply to your current system. You can then
# sudo ubuntu-drivers list
# to install all the packages you need, or you can do:
sudo ubuntu-drivers autoinstall
# to show you which devices need drivers, and their corresponding package names.
# sudo ubuntu-drivers devices
@antoniopresto
antoniopresto / Form.js
Last active November 30, 2019 14:04
Antd Masked Input
import { Form } from 'antd'
import { FormInput } from './antd-masked-input'
export default () => (
<Form>
<FormInput
form={this.props.form} // antd form
mask={'111.111.111-11'}
placeholder=""
label={''}
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
const ${NAME}Wrapper = styled.div``
class ${NAME}Component extends Component {
static propTypes = {
children: PropTypes.any,
}
@antoniopresto
antoniopresto / banco_codigo.json
Last active June 13, 2025 12:51
JSON bancos do brasil com código
[
{
"value": "001",
"label": "Banco do Brasil S.A."
},
{
"value": "003",
"label": "Banco da Amazônia S.A."
},
{
@antoniopresto
antoniopresto / nginxproxy.md
Created March 21, 2018 13:38 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@antoniopresto
antoniopresto / README.md
Created March 21, 2018 13:09 — forked from jimothyGator/README.md
Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.
mkdir -p /usr/local/etc/nginx/sites-{enabled,available}
cd /usr/local/etc/nginx/sites-enabled
ln -s ../sites-available/default.conf
ln -s ../sites-available/default-ssl.conf

File locations:

  • nginx.conf to /usr/local/etc/nginx/
  • default.conf and default-ssl.conf to /usr/local/etc/nginx/sites-available
  • homebrew.mxcl.nginx.plist to /Library/LaunchDaemons/
@antoniopresto
antoniopresto / mascara-celular.js
Created March 20, 2018 21:27
mascara de celular
const value = num
.replace(/[^\d]/gm, '')
.replace(/^(\d\d)([^ ]+)$/, '($1) $2')
.replace(/(\(\d\d\)) (\d{5})(\d)$/, '$1 $2-$3')
.replace(/(\(\d\d\)) (\d{4})(\d{1,5})$/, '$1 $2-$3')
.replace(/(\(\d\d\)) (\d{4})-(\d)(\d{4})$/, '$1 $2$3-$4')
.replace(/(\(\d\d\)) (\d{5})(\d{4})(.*)/, '$1 $2-$3')
@antoniopresto
antoniopresto / resolve.md
Created March 12, 2018 15:32
Git - Resolve multiple conflicts

grep -lr '<<<<<<<' . | xargs git checkout --ours OR grep -lr '<<<<<<<' . | xargs git checkout --theirs