Skip to content

Instantly share code, notes, and snippets.

View fernyb's full-sized avatar

Fernando Barajas fernyb

View GitHub Profile
@fernyb
fernyb / gist:1cd2460d05d99d7f88c61f821cd7e50c
Created May 6, 2019 05:48
Ruby WebDriver get performance log
require 'selenium-webdriver'
require 'pp'
class Inspector
attr_accessor :driver
def open url
@network_events = {}
@driver = Selenium::WebDriver::Driver.for :remote, url: "http://localhost:4444/wd/hub", desired_capabilities: capabilities
at_exit do
@fernyb
fernyb / install_tomcat
Created March 26, 2019 22:59
brew install tomcat
$ brew install tomcat
==> Downloading https://www.apache.org/dyn/closer.cgi?path=/tomcat/tomcat-9/v9.0.17/bin/apache-tomcat-9.0.17.tar.gz
==> Downloading from http://mirrors.advancedhosters.com/apache/tomcat/tomcat-9/v9.0.17/bin/apache-tomcat-9.0.17.tar.gz
######################################################################## 100.0%
==> Caveats
To have launchd start tomcat now and restart at login:
brew services start tomcat
Or, if you don't want/need a background service you can just run:
catalina run
==> Summary
@fernyb
fernyb / helloworld.erl
Last active March 20, 2022 19:10
Erlang Hello World Example
%hello world example
-module(helloworld).
-export([start/0]).
start() ->
{ok, "Hello World"}.
% $ erl
% Erlang/OTP 21 [erts-10.3.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]
%
*nat
:PREROUTING ACCEPT
:POSTROUTING ACCEPT
-A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
-A OUTPUT -o lo -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
COMMIT
@fernyb
fernyb / gist:cdcf1f5e27a8d89a994c17213cffe9be
Last active October 18, 2018 18:26
ruby selenium webdriver chrome capabilities options headless
caps = Selenium::WebDriver::Remote::Capabilities.chrome
caps['acceptInsecureCerts'] = true
caps['acceptSslCerts'] = true
caps['loggingPrefs'] = { 'performance' => 'ALL' }
caps['chromeOptions'] = {
'perfLoggingPrefs' => { 'enableNetwork' => true },
:args => [
"--disable-web-security",
"--allow-running-insecure-content",
"--ignore-certificate-errors",
@fernyb
fernyb / Howto convert a PFX to a seperate .key & .crt file
Created August 1, 2018 21:32 — forked from TemporaryJam/Howto convert a PFX to a seperate .key & .crt file
How to convert a .pfx SSL certificate to .crt/key (pem) formats. Useful for NGINX
source: http://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/
`openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]`
What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file. This is the password that you used to protect your keypair when you created your .pfx file. If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!. Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file.
Now let’s extract the certificate:
`openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]`
@fernyb
fernyb / headless chrome network traffic
Created April 30, 2018 23:04
Headless Chrome Network Traffic
@entries ||= []
selenium_driver = page.driver.browser
performance_log = selenium_driver.manage.logs.get("performance")
performance_log.each do |log|
json = JSON.parse(log.message)
if msg = json['message']
if msg['method'] == "Network.requestWillBeSent"
_params = msg['params']
url = _params['request']['url']
@fernyb
fernyb / gist:367c10751d19a8b1c2ee8fe7bf064049
Last active December 19, 2017 19:37
Install Erlang CentOS 7
wget http://erlang.org/download/otp_src_20.2.tar.gz
tar zxvf otp_src_20.2.tar.gz
cd otp_src_20.2
./configure --prefix=/usr/local/elixir && make && sudo make install
@fernyb
fernyb / gist:77522620ee4dbdbca5b5d192c98d4a99
Created December 7, 2017 18:30
nerd commenter toggle
vim bundle/nerdcommenter/plugin/NERD_commenter.vim
934 "let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine)
935 let theLine = s:AddLeftDelimAligned(s:Left({'space': 1}), theLine, 0)
Then Add to vimrc
let g:NERDDefaultAlign = 'left'
@fernyb
fernyb / gist:09b0c51cc118ae119f35b92a68f11995
Last active September 7, 2017 22:37
EarlGrey GREYElementInteraction
[[CustomAction sharedInstance] setRootProvider:cellView];
GREYElementInteraction *elementInteraction = [[GREYElementInteraction alloc] initWithElementMatcher:matcher];
[elementInteraction inRoot:nil];
[elementInteraction setDataSource:[CustomAction sharedInstance]];
[elementInteraction assertWithMatcher:grey_sufficientlyVisible() error:&error];
if (error) {
} else {
dispatch_queue_t concurrent_queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_sync(concurrent_queue, ^{