Skip to content

Instantly share code, notes, and snippets.

@jpcercal
jpcercal / clear-selenium-grid-hub-sessions.js
Created February 21, 2024 12:05
Use it to clear the sessions started and left open by selenium grid hub when terminating the executing un-gracefully
async function clearSessions() {
try {
const url = 'http://127.0.0.1:4444';
// Get information about all active sessions on the Selenium Grid hub
const response = await fetch(`${url}/status`);
const data = await response.json();
// Loop through all active sessions and terminate them
for (const node of data.value.nodes) {
{
"version": "2.0.122.1",
"settings": {
"blur": 0,
"brightness": 100,
"contrast": 100,
"grayscale": 0,
"huerotate": 0,
"invert": 0,
"saturate": 100,
@jpcercal
jpcercal / add-p.md
Created May 23, 2023 13:08 — forked from mattlewissf/add-p.md
Lightning Talk: Git add -p

git add -p is your friend

git add -p is basically "git add partial (or patch)"

Patch mode allows you to stage parts of a changed file, instead of the entire file. This allows you to make concise, well-crafted commits that make for an easier to read history. This feature can improve the quality of the commits. It also makes it easy to remove parts of the changes in a file that were only there for debugging purposes - prior to the commit without having to go back to the editor.

It allows you to see the changes (delta) to the code that you are trying to add, and lets you add them (or not) separately from each other using an interactive prompt. Here's how to use it:

from the command line, either use

  • git add -p
@jpcercal
jpcercal / osx-for-hackers.sh
Created November 14, 2017 17:37 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
resume:
name: João Paulo Cercal
job:
en: Senior Software Engineer
pt_BR: Engenheiro de Software Sênior
de_DE: Softwareentwickler
location:
en: Munich, Germany
pt_BR: Munique, Alemanha
de_DE: München, Deutschland
@jpcercal
jpcercal / article.md
Created April 26, 2017 21:30
Article

How do you get your environment variables using PHP?

You probably get your environment variables using built-in PHP functions such as getenv or $_ENV, but did you know that you can do it in an elegant way getting the value of an environment variable in the properly PHP data type with the powerful library? If you are curious, just read how this energetic library can help you in your daily development workflow.

Note that in this article we'll use a famous library to load environment variables from an external file, this library is vlucas/phpdotenv.

Then, firstly, you need to install the dependencies. To do it, simply type this in your terminal:

$ composer require vlucas/phpdotenv
@jpcercal
jpcercal / download-patches.sh
Created November 7, 2016 17:23 — forked from mzeis/download-patches.sh
Download Magento CE security patches SUPEE-1533 ad SUPEE-8788 v2 using bash. Open the file for usage information.
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Author: Matthias Zeis (https://github.com/mzeis, https://twitter.com/mzeis)
# Date: 2016/10/17
# Version: 1.0
# License: MIT (https://en.wikipedia.org/wiki/MIT_License)
#
@jpcercal
jpcercal / SweetAlert.js
Last active October 21, 2016 16:57
A angular service to use the sweetalert library.
(function () {
'use strict';
angular
.module('yourApp')
.factory('SweetAlert', SweetAlert);
/* @ngInject */
function SweetAlert($http, $interpolate, $rootScope) {
@jpcercal
jpcercal / Gruntfile.js
Created August 19, 2016 20:53
Gruntfile.js
module.exports = function(grunt) {
'use strict';
grunt.initConfig({
ngAnnotate: {
options: {
singleQuotes: true
},
production: {
files: [
@jpcercal
jpcercal / .htaccess
Created June 8, 2016 13:15 — forked from thoop/.htaccess
Official prerender.io .htaccess for Apache.
# Change YOUR_TOKEN to your prerender token and uncomment that line if you want to cache urls and view crawl stats
# Change http://example.com (at the end of the last RewriteRule) to your website url
<IfModule mod_headers.c>
#RequestHeader set X-Prerender-Token "YOUR_TOKEN"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On