Skip to content

Instantly share code, notes, and snippets.

View antoniopresto's full-sized avatar

antoniopresto

  • São Paulo - Brasil
View GitHub Profile
# set the Forward Delete key to delete a file in Finder
defaults write com.apple.finder NSUserKeyEquivalents '{"Move to Trash"="\U007F";}'
$ sudo visudo
antonio ALL = (ALL) NOPASSWD: /bin/fixtime
# /bin/fixtime
/usr/sbin/ntpdate -u time.apple.com
#
chmod u+x /bin/fixtime
# cron
$ EDITOR=nano crontab -e
> 2 * * * * sudo -S fixtime >> ~/Desktop/cron.log 2>&1
@antoniopresto
antoniopresto / bestMatch.js
Created December 19, 2017 21:48
bestMatch.js
// find in objects https://www.npmjs.com/package/q_
function _(o, qs) {
const qa = qs.replace(/\[([0-9]*)]/gim, '.$1').split('.');
return qa.reduce(function(prev, next) {
if (!prev) return undefined;
return prev[next];
}, o);
}
function bestMatch(o, qs) {
@antoniopresto
antoniopresto / myip.sh
Created March 1, 2018 11:12
local machine ip
ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'
@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

@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 / 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 / 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

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,
}