Skip to content

Instantly share code, notes, and snippets.

View igoralves1's full-sized avatar

Igor Alves igoralves1

View GitHub Profile
@igoralves1
igoralves1 / gist:a70e6f8c904f1e06020039f3fe0f3d29
Created April 13, 2016 20:55
AJAX - PHP - JS. Send data to PHP and back do JS - Method 1
//Method 1
//Js is not dynamic. I can not pass variables from PHP->to JS->to PHP, in the same page.
//Your php code
$arrToJSON = array(
"dataPHPtoJs"=>"yourData",
"asYouWant"=>"<div class=\".class1\">soemting</div>"
);
return json_encode(array($arrToJSON));
@igoralves1
igoralves1 / 000-default.conf
Last active April 7, 2022 06:49
Perl example using a form with Bootstrap + jQuery + AJAX.
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
ScriptAlias /cgi-bin/ /var/cgi-bin/
<Directory "/var/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
@igoralves1
igoralves1 / cloudSettings
Last active June 2, 2021 13:47
VsCode SYNC vs code configuration
{"lastUpload":"2021-01-05T18:42:04.067Z","extensionVersion":"v3.4.3"}
@igoralves1
igoralves1 / gist:6d680f61f6873d8fcbf3a5afbfbac8b5
Created April 19, 2019 18:26
Win CRON JOB - DATABASE BACKUP ROUTINE
@ECHO off
REM - DATABASE BACKUP ROUTINE
ECHO.
ECHO 1 - dbTest STARTING backup ...
mysqldump -u root -pMYPASSWD --routines --add-drop-database --databases dbNameInMySql> C:/Users/backup/dbNameDumped.sql
ECHO dbTest - BACKUP DONE...
ECHO.
rar a -ag+YYYY{_}MM{_}DD{_}HHMMSS{_}NN C:/Users/backup/ C:/Users/backup/FinalFolder/
@igoralves1
igoralves1 / .bashrc
Last active February 9, 2021 22:30
Show your branch name on the Linux prompt, changing .bashrc on Ubuntu 16.04.
Show your branch name on the Linux prompt. Updated
1-Go to ~/ directory, or /home/"username";
2-type sudo subl .bashrc. So this will be the full command ila@ig:~$ sudo subl .bashrc. That will open the .bashrc file
3-After this Introductory sentence of the .bashrc:
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
4-Put this function declaration:
# Add git branch if its present to PS1
Meu Dockerfile
FROM ribafs/ubuntu-maria
ENV MYSQL_ROOT_PASSWORD root
ENV MYSQL_ROOT_DATABASE testes
RUN apt-get update
EXPOSE 3306
ADD ["script.sql", "/tmp/script.sql"] # Cria o banco e muda a senha para vazia
CMD ["start-mysql"]
RUN mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e "CREATE DATABASE testes"
@igoralves1
igoralves1 / guz.php
Last active November 23, 2020 10:36
Consuming API endpoints with Laravel 5+ AND Guzzle\Http
/*
Installation -> http://docs.guzzlephp.org/en/latest/overview.html#installation
https://www.youtube.com/watch?v=GunXVUqvO-s
https://www.udemy.com/http-clients-with-laravel-use-and-consume-services-and-apis/
add Guzzle as a dependency using the composer.phar CLI:
@igoralves1
igoralves1 / loadbalancer.conf
Last active August 8, 2020 08:47
Using NGINX as HTTP load balancer, Load Balancing
upstream web_backend{
server 192.168.1.11:3000;
server 192.168.1.12:3000;
}
server {
listen 3000;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
https://www.nginx.com/blog/top-5-posts-r12-microservices/
https://thenewstack.io/from-monolith-to-microservices/
https://medium.com/@NeotericEU/how-can-you-refactor-a-monolithic-application-into-microservices-2eef8e323840
https://www.nginx.com/blog/microservices-at-netflix-architectural-best-practices/
https://www.nginx.com/blog/refactoring-a-monolith-into-microservices/
https://www.nginx.com/blog/refactoring-a-monolith-into-microservices/
https://howtodoinjava.com/microservices/microservices-definition-principles-benefits/
https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet
https://www.garron.me/en/go2linux/how-benchmark-stress-your-apache-nginx-or-iis-server.html
https://kuntalchandra.wordpress.com/2015/10/10/install-apache-bench-ubuntu-14-04/
@igoralves1
igoralves1 / function.js
Last active February 12, 2020 14:23 — forked from vgeshel/function.js
AWS Lambda function for forwarding SNS notifications to Slack
console.log('Loading function');
const https = require('https');
const url = require('url');
// to get the slack hook url, go into slack admin and create a new "Incoming Webhook" integration
const slack_url = 'https://hooks.slack.com/services/...';
const slack_req_opts = url.parse(slack_url);
slack_req_opts.method = 'POST';
slack_req_opts.headers = {'Content-Type': 'application/json'};