Skip to content

Instantly share code, notes, and snippets.

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

Rodrigo S rodrisan

🏠
Working from home
View GitHub Profile
@derickr
derickr / save-code-coverage.php
Last active September 16, 2024 16:46
save-code-coverage.php
<?php
require 'vendor/autoload.php';
use SebastianBergmann\CodeCoverage\Filter;
use SebastianBergmann\CodeCoverage\Driver\Selector;
use SebastianBergmann\CodeCoverage\CodeCoverage;
use SebastianBergmann\CodeCoverage\Report\PHP as PhpReport;
use SebastianBergmann\FileIterator\Facade as FileIteratorFacade;
$filter = new Filter;
@navjotahuja92
navjotahuja92 / setup.ts
Last active September 19, 2025 10:54
Nest.js Test Setup with In Memory Postgres Database (pg-mem)
// Install npm i pg-mem --save-dev
import { DataSource, Repository } from 'typeorm';
import { newDb, DataType } from 'pg-mem';
import { v4 } from 'uuid';
const setupDataSource = async () => {
const db = newDb({
autoCreateForeignKeyIndices: true,
});
@tkambler
tkambler / linkedin-bulk-select.js
Created April 4, 2022 14:38
Script for bulk-selecting multiple messages on LinkedIn (for deletion)
/**
* Open the floating messages panel in the bottom right-hand corner of the LinkedIn screen. Click
* the three dots and select "Manage messages." Scroll down the page a few times so as to load several
* screens of messages (but not too many). The paste the following script into the developer console
* and press enter.
*
* All of the messages on your screen should now be selected. You can choose the "Delete" option to delete
* all of them in bulk.
*/
(() => {
@n1snt
n1snt / Oh my ZSH with zsh-autosuggestions zsh-syntax-highlighting zsh-fast-syntax-highlighting and zsh-autocomplete.md
Last active December 2, 2025 19:59
Oh my ZSH with zsh-autosuggestions zsh-syntax-highlighting zsh-fast-syntax-highlighting and zsh-autocomplete.md

Oh my zsh.

Oh My Zsh

Install ZSH.

sudo apt install zsh-autosuggestions zsh-syntax-highlighting zsh

Install Oh my ZSH.

@anibalardid
anibalardid / woocommerce-new-custom-payment-gateway.php
Created December 5, 2020 03:19
WooCommerce add new custom payment gateway
<?php
// CASH PAYMENT GATEWAY
/**
* Add the gateway to WC Available Gateways
*
* @since 1.0.0
* @param array $gateways all available WC gateways
* @return array $gateways all WC gateways + offline gateway
@bberak
bberak / bin.js
Last active July 17, 2024 23:36
Write a binary buffer to file using NodeJS
const fs = require("fs");
const kb = 32 * 1024;
const buf = Buffer.alloc(kb);
const ws = fs.createWriteStream("out.bin")
buf.fill(0xEA)
ws.write(buf);
ws.end();
@dahlsailrunner
dahlsailrunner / SSL-nginx-Docker.md
Last active October 2, 2025 18:24
SSL with Docker images using nginx as reverse proxy

Docker with SSL and an nginx reverse proxy

Running your ASP.NET Core (or other) application in Docker using SSL should not be an overwhelming task. These steps should do the trick.

Run the following steps from a Linux terminal (I used WSL or WSL2 on Windows from the Windows Terminal).

1. Create a conf file with information about the cert you'll be creating

It should look something like the content below; call it my-site.conf or something like that.

@luizlopescom
luizlopescom / Autoptimize hooks
Created September 12, 2020 22:03
List of WP Autoptimize plugin hooks
//Change AO folder and file prefix
//It's mandatory to have an underline
//serve files from e.g. /wp-content/resources/aggregated_12345.css
//wp_config.php
define('AUTOPTIMIZE_CACHE_CHILD_DIR','/resources/');
define('AUTOPTIMIZE_CACHEFILE_PREFIX','aggregated_');
//Enable non-ASCII characters
add_filter('autoptimize_filter_main_use_mbstring', '__return_true');
@josephrocca
josephrocca / escapeUnicode.js
Created June 18, 2020 11:18
Replace all Unicode characters with escape codes (JavaScript function)
// This function matches all non-ASCII characters after splitting the string in a "unicode-safe" way (using `[...str]`).
// It then splits each unicode character up into its code-points, and gets the escape code for each, and then joins all
// all the ASCII characters and Unicode escapes into one string.
function escapeUnicode(str) {
return [...str].map(c => /^[\x00-\x7F]$/.test(c) ? c : c.split("").map(a => "\\u" + a.charCodeAt().toString(16).padStart(4, "0")).join("")).join("");
}
// Based on discussion in this thread: https://gist.github.com/mathiasbynens/1243213
@jprivet-dev
jprivet-dev / .bash_aliases
Last active November 7, 2025 13:17
Git and Bash aliases defined and documented in a single `.bash_aliases` file, with Git auto-completion
# #########################################################################################
# GIT AND BASH ALIASES DEFINITION IN A SINGLE FILE `.BASH_ALIASES` WITH GIT AUTO-COMPLETION
# #########################################################################################
# All these git commands and bash aliases are tested on git version 2.17.1 on Linux Mint 19
# This compilation of aliases is an experiment.
# On a daily basis, I use only a few of these aliases ¯\_(ツ)_/¯
# **********