Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Solving problems, one at a time.

Kaluã Bentes kaluabentes

💭
Solving problems, one at a time.
View GitHub Profile
View vscode-config.json
{
"workbench.iconTheme": "material-icon-theme",
"editor.tabSize": 2,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.fontFamily": "JetBrains Mono",
"editor.fontWeight": "500",
"terminal.integrated.fontWeight": "500",
"editor.fontSize": 14,
"terminal.integrated.fontSize": 14,
@kaluabentes
kaluabentes / stream-file-to-response.js
Created Jul 27, 2020
Stream file from source to response in Node.js
View stream-file-to-response.js
const http = require("http");
const fs = require("fs");
export default function Sitemap(req, res) {
const url = `${process.env.NEXT_PUBLIC_API_URL}/sitemap`;
const request = http.get(url, (response) => {
const contentType = response.headers["content-type"];
res.setHeader("Content-Type", contentType);
@kaluabentes
kaluabentes / settings.json
Last active Jun 26, 2020
VSCode configuration
View settings.json
{
"editor.tabSize": 2,
"editor.formatOnSave": true,
"editor.fontFamily": "SF Mono",
"editor.fontWeight": "500",
"terminal.integrated.fontFamily": "SF Mono",
"terminal.integrated.fontWeight": "500",
"workbench.iconTheme": "material-icon-theme",
"javascript.updateImportsOnFileMove.enabled": "never",
"editor.codeActionsOnSave": {
@kaluabentes
kaluabentes / phoneValidate_BR.php
Created Apr 7, 2020 — forked from boliveirasilva/phoneValidate_BR.php
Regex para validação de telefones (celular ou fixo) no Brasil. A expressão leva em conta o formato internacional/nacional, com ou sem o DDD, de telefones fixos e celulares.
View phoneValidate_BR.php
<?php
// A função abaixo demonstra o uso de uma expressão regular que identifica, de forma simples, telefones válidos no Brasil.
// Nenhum DDD iniciado por 0 é aceito, e nenhum número de telefone pode iniciar com 0 ou 1.
// Exemplos válidos: +55 (11) 98888-8888 / 9999-9999 / 21 98888-8888 / 5511988888888
function phoneValidate($phone)
{
$regex = '/^(?:(?:\+|00)?(55)\s?)?(?:\(?([1-9][0-9])\)?\s?)?(?:((?:9\d|[2-9])\d{3})\-?(\d{4}))$/';
if (preg_match($regex, $phone) == false) {
@kaluabentes
kaluabentes / git-deployment.md
Created Sep 6, 2017 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks
View git-deployment.md

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your lokal GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like my Deepl.io to act upon a Web-Hook that's triggered that service.

View .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.synced_folder ".", "/var/www", :mount_mode => ['dmode=777', 'fmode=666']
config.vm.provision :shell, path: "provision.sh"
View vhost.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory /var/www>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
View lamp_provision.sh
#!/bin/bash
echo "--------- Updating repository ---------"
sudo apt-get -y update
echo "--------- Installing Apache2 ---------"
sudo apt-get -y install apache2
@kaluabentes
kaluabentes / php7_build_ubuntu.sh
Created Apr 4, 2016 — forked from m1st0/php_build_ubuntu.sh
Compiling PHP 7 on Ubuntu 15.04 with Various Supported Modules
View php7_build_ubuntu.sh
#! /bin/bash
## PHP 7 Initial Compile ##
## Some help from the various places like these. ##
# http://www.zimuel.it/install-php-7/
# http://www.hashbangcode.com/blog/compiling-and-installing-php7-ubuntu
## Setup Ubuntu 15.04/15.10 ##
# Other dependencies for PHP 7. Add any missing ones from configure script
# complaints, plus some LAMP needs too.