Skip to content

Instantly share code, notes, and snippets.

View caioregatieri's full-sized avatar

Caio Regatieri caioregatieri

View GitHub Profile
@caioregatieri
caioregatieri / docker-install.sh
Created July 6, 2021 22:15
Install docker and docker-compose on VM
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo groupadd docker
sudo usermod -aG docker $USER
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
$estados = array( "AC", "AL", "AM", "AP", "BA", "CE", "DF", "ES", "GO", "MA", "MT", "MS", "MG", "PA", "PB", "PR", "PE", "PI", "RJ", "RN", "RO", "RS", "RR", "SC", "SE", "SP", "TO" );
function removeAcento (text)
{
text = text.toLowerCase();
text = text.replace(new RegExp('[ÁÀÂÃ]','gi'), 'a');
text = text.replace(new RegExp('[ÉÈÊ]','gi'), 'e');
text = text.replace(new RegExp('[ÍÌÎ]','gi'), 'i');
text = text.replace(new RegExp('[ÓÒÔÕ]','gi'), 'o');
text = text.replace(new RegExp('[ÚÙÛ]','gi'), 'u');
text = text.replace(new RegExp('[Ç]','gi'), 'c');
return text;
@caioregatieri
caioregatieri / compare_objects.js
Created May 30, 2018 18:15
A function for compare two objects
function isEquivalent(a, b) {
// Create arrays of property names
var aProps = Object.getOwnPropertyNames(a);
var bProps = Object.getOwnPropertyNames(b);
// If number of properties is different,
// objects are not equivalent
if (aProps.length != bProps.length) {
return false;
}
function debounce(fn, delay){
let timer = null
return function(){
clearTimeout(timer)
setTimeout(function(){
fn()
}, delay)
}
}
@caioregatieri
caioregatieri / apache.conf
Created November 10, 2017 22:23 — forked from rambabusaravanan/apache.conf
SPA - Apache, Nginx Configuration for Single Page Application like React.js on a custom path
# To host on root path just use "<Location />" for http://mydomainname.in
# To host on non-root path use "<Location /myreactapp>" for http://mydomainname.in/mypath
# If non-root path, don't forgot to add "homepage": "/myreactapp" in your app's package.json
<VirtualHost *:80>
ServerName mydomainname.in
DirectoryIndex index.html
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
@caioregatieri
caioregatieri / angularjs-providers-explained.md
Created October 23, 2017 02:31 — forked from demisx/angularjs-providers-explained.md
AngularJS Providers: Constant/Value/Service/Factory/Decorator/Provider
Provider Singleton Instantiable Configurable
Constant Yes No No
Value Yes No No
Service Yes No No
Factory Yes Yes No
Decorator Yes No? No
Provider Yes Yes Yes

Constant

<?php
/*-------------------------------------------------+
| Checks if the http request is an AJAX call.
+-------------------------------------------------*/
function is_ajax() {
return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower(getenv('HTTP_X_REQUESTED_WITH')) === 'xmlhttprequest'));
}
?>
/* Estilo que será visualizado por smartfones tanto em retrato como em paisagem */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Aqui vão os estilos*/
}
/* Estilo que será visualizado por smartfones em paisagem */
@media only screen
and (min-width : 321px) {
@caioregatieri
caioregatieri / iotcam.py
Created September 9, 2017 03:54 — forked from loleg/iotcam.py
Detects barcodes from a webcam stream using Python, zbar and CV2
from picamera.array import PiRGBArray
from picamera import PiCamera
import time
import sys
import cv2
import zbar
import Image
# Debug mode
DEBUG = False