Skip to content

Instantly share code, notes, and snippets.

View paivaric's full-sized avatar

Ricardo Paiva paivaric

View GitHub Profile
function FindProxyForURL(url, host) {
if (isInNet(host, "172.17.0.0", "255.255.0.0")) {
return "SOCKS5 127.0.0.1:8888";
}
if (isInNet(host, "193.0.0.0", "255.0.0.0")) {
return "SOCKS5 127.0.0.1:8888";
}
return "DIRECT";
}
@paivaric
paivaric / cors.inc
Created December 13, 2018 20:34 — forked from antonbabenko/cors.inc
(nginx AND varnish) + CORS (working example)
more_set_headers "Access-Control-Allow-Origin: $http_origin";
more_set_headers "Access-Control-Allow-Credentials: true";
# OPTIONS indicates a CORS pre-flight request
if ($request_method = 'OPTIONS') {
more_set_headers "Access-Control-Max-Age: 1728000";
more_set_headers "Access-Control-Allow-Methods: GET, POST, PUT, DELETE, PATCH, OPTIONS";
more_set_headers "Access-Control-Allow-Headers: Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,Keep-Alive,X-Requested-With,If-Modified-Since";
more_set_headers "Content-Length: 0";
// node.js : Mailgun via API
var request = require('request')
var apiBaseUrl = 'https://api.mailgun.net/v3/YOUR_DOMAIN_NAME'; // REPLACE THIS BY YOUR DOMAIN NAME
var apiKey = 'key-YOUR_API_KEY'; // REPLACE THIS BY YOUR API KEY
var from = 'Excited User';
var to = 'example@example.com';
var subject = 'Hello';
var text = 'Testing some Mailgun awesomness!';
@paivaric
paivaric / parser-server-node-js-mailgun-via-request-api.js
Last active December 3, 2018 19:14 — forked from neguse11/node-js-mailgun-via-api.js
Call Mailgun API from node.js with Request and Parse-Server
// node.js : Mailgun via API
var request = require('request')
Parse.Cloud.define("sendemail", function(req, res) {
var apiBaseUrl = 'https://api.mailgun.net/v3/YOUR_DOMAIN_NAME'; // REPLACE THIS BY YOUR DOMAIN NAME
var apiKey = 'key-YOUR_API_KEY'; // REPLACE THIS BY YOUR API KEY
var from = 'Excited User';
var to = 'example@example.com';
var subject = 'Hello';
@paivaric
paivaric / gist:85fd9b3b34bfc584a214bd1168cfd7d1
Last active August 29, 2018 19:53
Compress Files in Batch with FFMPEG
# first install FFMPEG
brew install ffmpeg $(brew options ffmpeg | grep -vE '\s' | grep -- '--with-' | tr '\n' ' ')
# find and compress
find . -iname "*.mp4" | xargs -I {} ffmpeg -i {} -vcodec libx264 -crf 40 -acodec aac -threads 0 {}_compressed.mp4
# ignore already compressed
find . -type f \( -iname "*.mp4" ! -iname "*compressed*" \) | xargs -I {} ffmpeg -i {} -vcodec libx264 -crf 40 -acodec aac -threads 0 {}_compressed.mp4
@paivaric
paivaric / 1.google-analytics-proxy-nginx.conf
Last active January 30, 2024 17:21
Google Analytics Proxy using Nginx to bypass Adblock and other blockers
server {
listen 80;
server_name your.domain.com;
location = /analytics.js {
# you have to compile nginx with http://nginx.org/en/docs/http/ngx_http_sub_module.html (this is not default)
# and http://nginx.org/en/docs/http/ngx_http_proxy_module.html (it's a default module)
proxy_set_header Accept-Encoding "";
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta content="Back4App Inc" name="author">
<title>Sample App| JavaScript Quickstart | Back4App</title>
@paivaric
paivaric / index.hml
Created October 27, 2017 18:35 — forked from fullsushidev/index.hml
Basic HTML file | JavaScript Quickstart tutorial | Back4App
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta content="Back4App Inc" name="author">
<title>Sample App| JavaScript Quickstart | Back4App</title>
@paivaric
paivaric / gist:913799cc084db131addc
Last active August 29, 2015 14:27 — forked from chrishaff/gist:83b0a3b621c3301ecc32
Install Thumbor on Ubuntu 14.04 includes python-opencv for face/feature detection. Don't forget to enable the detectors https://github.com/thumbor/thumbor/wiki/Enabling-detectors.
# sudo su and run the following
sudo apt-get update && \
sudo apt-get -y upgrade && \
# install all dependencies
sudo apt-get -y install \
build-essential \
checkinstall \
gcc \
@paivaric
paivaric / httpd.conf
Created December 5, 2013 11:48
Apache configuration to disable cache and rewrite url to other domain/server like tomcat
<FilesMatch "\.*$">
ExpiresActive On
ExpiresDefault A1
Header append Cache-Control must-revalidate
</FilesMatch>
RewriteEngine On
# RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/rest/(.*)$ http://localhost:8080/doccon-view/rest/$1 [R,L] # Temporary Move