Skip to content

Instantly share code, notes, and snippets.

View rafaelverger's full-sized avatar

Rafael Nunes Verger rafaelverger

View GitHub Profile
@rafaelverger
rafaelverger / load-umrum-min.js
Last active August 29, 2015 13:58
How to load UMRUM client script
!function(a,b,c,d){
b._mrm=b._mrm||{},
b._mrm.hostId=a,
d=c.createElement("script"),
d.async=1,
d.src="//umrum.io/dist/umrum-client.js",
c.body.appendChild(d);
}("UMRUM_KEY",window,document);
@rafaelverger
rafaelverger / git-global-pull.sh
Last active August 29, 2015 14:06
Update all git projects from workspace
#!/bin/bash
PWD=$(pwd)
GIT_ROOT="~/git-projects"
CYAN='\033[36m'
GREEN='\033[32m'
NC='\033[0m' # No Color
cd $GIT_ROOT > /dev/null
@rafaelverger
rafaelverger / all-user-agents.js
Created October 1, 2014 14:06
Historical list of more than 9k user-agents
all_user_agents = [
'Mozilla/5.0 (compatible; U; ABrowse 0.6; Syllable) AppleWebKit/420+ (KHTML, like Gecko)',
'Mozilla/5.0 (compatible; ABrowse 0.4; Syllable)',
'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; Acoo Browser 1.98.744; .NET CLR 3.5.30729)',
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; GTB5; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; Maxthon; InfoPath.1; .NET CLR 3.5.30729; .NET CLR 3.0.30618)',
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; GTB5;',
'Mozilla/4.0 (compatible; Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB6; Acoo Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727); Windows NT 5.1; Trident/4.0; Maxthon; .NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.2)',
'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; Acoo Browser; GTB6; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; InfoPath.1; .NET CLR 3.5.30729; .NET CLR 3.0.30618)',
'Mozilla/4.0 (compatible; MSIE
@rafaelverger
rafaelverger / create_prebid_lis.py
Last active November 7, 2017 19:49
DFP - Create Prebid LineItems
from googleads import dfp
DFP_CLIENT = dfp.DfpClient.LoadFromStorage()
ORDER_SERVICE = DFP_CLIENT.GetService('OrderService', version='v201705')
LI_SERVICE = DFP_CLIENT.GetService('LineItemService', version='v201705')
CTGT_SERVICE = DFP_CLIENT.GetService('CustomTargetingService', version='v201705')
LICA_SERVICE = DFP_CLIENT.GetService('LineItemCreativeAssociationService', version='v201705')
PREBID_CREATIVE_IDS = [1234567890, 9087654321, 1357924680, 2468013579, 1234509876]
@rafaelverger
rafaelverger / vwdependencies.sql
Created August 28, 2018 21:23 — forked from adamantnz/vwdependencies.sql
Redshift - view table/schema dependencies
CREATE OR REPLACE VIEW dbo.vwdependencies
AS
SELECT DISTINCT c_p.oid AS tbloid
,n_p.nspname AS schemaname
,c_p.relname AS NAME
,n_c.nspname AS refbyschemaname
,c_c.relname AS refbyname
,c_c.oid AS viewoid
FROM pg_class c_p
JOIN pg_depend d_p ON c_p.relfilenode = d_p.refobjid
@rafaelverger
rafaelverger / cheerio_VS_jsdom_VS_html-truncate.js
Last active April 15, 2019 22:50
Truncate HTML: cheerio X jsdom X html-truncate
const jsdom = require('jsdom');
const cheerio = require('cheerio');
const htmlTruncate = require('html-truncate');
const limit = 500;
const text = "<p>O ex-presidente Luiz Inácio Lula da Silva defendeu que o direito de protestar não deve afetar o direito de assistir aos jogos da Copa. \"Quem quiser fazer passeata que faça, quem quer levantar faixa que levante, faça o que quiser. O importante é que as pessoas saibam que da mesma forma que alguém tem o direito de dizer que não quer Copa, o cidadão que comprou ingresso e quer ir ver a Copa tem que ter a liberdade de ver a Copa\" , afirmou em entrevista à revista Carta Capital. \"O meu direito de protestar não impede o meu direito de ir ao estádio e ver um jogo de futebol e ir tranquilo e em paz.\"</p> <p>Lula também defendeu os investimentos do governo com o Mundial. \"O governo federal tomou uma atitude exemplar. Decidimos que o Estado iria fazer um financiamento de R$ 400 milhões pelo BNDES para o governador do Estado e para as empresas que quisessem fazer es
@rafaelverger
rafaelverger / takess.js
Last active February 11, 2020 18:27
Taking screenshot of full document body using html2canvas and uploading to cloudinary
function takeSS(cloudinary_name, cloudinary_key, cloudinary_unsigned_preset, main_element){
main_element = main_element || document.body;
const imageUrlToBase64 = (url) => fetch(
`https://get-base64-image.rafaelverger.now.sh/?url=${encodeURIComponent(url)}`
).then(res => res.text());
const _takeSS = () => {
const elementImages = [].slice.call(
main_element.querySelectorAll('img'), 0
).filter(img => /^http/.test(img.src));
@rafaelverger
rafaelverger / homebrew-install-older-version.md
Created January 31, 2022 14:54
Homebrew: Install an older version of a formula

Homebrew: Install an older version of a formula

kubernetes-cli (v1.10.3) taken as example

  1. Downgrade Homebrew to the commit which upgrades the formula to the specific version that we want
$ cd "$(brew --repo homebrew/core)"
$ git log Formula/kubernetes-cli.rb

...
@rafaelverger
rafaelverger / integration.html
Last active May 12, 2023 00:52
Integrate DFP click macro and cache buster to Space AdManager
<script type="text/javascript">
var space = window.space || { runs: [] };
var ADID = 'YOUR_AD_ID'; var WIDTH = 1; var HEIGHT = 1;
space.runs.push(function () {
space
.ad(ADID)
.setSize(WIDTH, HEIGHT)
.setMacro('%%CLICK_URL_UNESC%%')
.setCacheBuster('%%CACHEBUSTER%%')
.fire();