Skip to content

Instantly share code, notes, and snippets.

View allanfreitas's full-sized avatar
🏠
Working from home

Allan Freitas allanfreitas

🏠
Working from home
View GitHub Profile
@allanfreitas
allanfreitas / opera-vpn.md
Created December 2, 2017 20:38 — forked from spaze/opera-vpn.md
Opera VPN behind the curtains is just a proxy, here's how it works

When setting up (that's immediately when user enables it in settings) Opera VPN sends few API requests to https://api.surfeasy.com to obtain credentials and proxy IPs, see below, also see The Oprah Proxy.

The browser then talks to a proxy de0.opera-proxy.net (when VPN location is set to Germany), it's IP address can only be resolved from within Opera when VPN is on, it's 185.108.219.42 (or similar, see below). It's an HTTP/S proxy which requires auth.

When loading a page with Opera VPN enabled, the browser sends a lot of requests to de0.opera-proxy.net with Proxy-Authorization request header.

The Proxy-Authorization header decoded: CC68FE24C34B5B2414FB1DC116342EADA7D5C46B:9B9BE3FAE674A33D1820315F4CC94372926C8210B6AEC0B662EC7CAD611D86A3 (that's sha1(device_id):device_password, where device_id and device_password come from the POST /v2/register_device API call, please note that this decoded header is from another Opera installation and thus contains

@allanfreitas
allanfreitas / install_php71_centos.sh
Created September 24, 2017 12:49 — forked from jniltinho/install_php71_centos.sh
Install PHP 7.1 on CentOS 7.3
#!/bin/bash
### Install PHP 7.1 on CentOS 7.3 64Bits
### http://www.shaunfreeman.name/compiling-php-7-on-centos/
### https://www.howtoforge.com/tutorial/how-to-install-php-7-on-debian/
yum -y install git gcc gcc-c++ libxml2-devel pkgconfig openssl-devel bzip2-devel curl-devel libpng-devel libjpeg-devel
yum -y install libXpm-devel freetype-devel gmp-devel libmcrypt-devel mariadb-devel aspell-devel recode-devel libpqxx-devel
yum -y install autoconf bison re2c libicu-devel libwebp-devel wget unzip net-tools libc-client-devel libpng12-devel
yum -y install libxslt-devel

Install MariaDB 10.1.14 on CentOS 7

Create or edit:

$ sh vim /etc/yum.repos.d/MariaDB.repo

Copy and paste:

sed "s/,/\\`echo -e '\n\r'`/g"
@allanfreitas
allanfreitas / screen.sh
Created September 19, 2017 02:11 — forked from jrom/screen.sh
How to use screen
screen # Starts a screen session
<C-a d> # Detaches from the screen session
screen -r # Reattaches to a detached session
screen -S paco # Starts a screen session called "paco"
screen -r paco # Reattaches to a detached session called "paco"
@allanfreitas
allanfreitas / nginx.conf
Created September 19, 2017 02:10 — forked from joseluisq/nginx.conf
nginx hack for multiple conditions
if ($request_uri = /) {
set $test A;
}
if ($host ~* teambox.com) {
set $test "${test}B";
}
if ($http_cookie !~* "auth_token") {
set $test "${test}C";
@allanfreitas
allanfreitas / add_two_times.js
Created September 19, 2017 02:09 — forked from joseluisq/add_two_times.js
Sum two times values HH:mm:ss with javascript
/**
* Sum two times values HH:mm:ss with javascript
* Usage:
* > addTimes('04:20:10', '21:15:10');
* > "25:35:20"
*
* @param {string} start
* @param {string} end
* @returns {String}
*/
@allanfreitas
allanfreitas / bitbucket-deployment-script.sh
Created September 19, 2017 02:09 — forked from joseluisq/bitbucket-deployment-script.sh
Small Bitbucket shell script for deployment PHP composer project
#!/bin/sh
# Small Bitbucket shell script for deployment PHP composer project
# @author José Luis Quintana <http://git.io/joseluisq>
# Note: It's necessary to add some hook in repository settings.
# Settings
REPLOY_REPO_NAME=repository-name
DEPLOY_PATH=/username/www/project/
@allanfreitas
allanfreitas / numberformat.js
Created September 19, 2017 02:09 — forked from joseluisq/numberformat.js
number_format(number, decimals, decPoint, thousandsSep) in JavaScript, known from PHP. It formats a number to a string with grouped thousands, with custom seperator and custom decimal point
function number_format(number, decimals, decPoint, thousandsSep){
decimals = decimals || 0;
number = parseFloat(number);
if(!decPoint || !thousandsSep){
decPoint = '.';
thousandsSep = ',';
}
var roundedNumber = Math.round( Math.abs( number ) * ('1e' + decimals) ) + '';