Skip to content

Instantly share code, notes, and snippets.

View AdSegura's full-sized avatar

Adolfo Segura AdSegura

View GitHub Profile
@AdSegura
AdSegura / xsearch.sh
Created May 28, 2021 22:16
create a keyboard shortcut to launch, firefox new tab, google search with clipboard content
#!/bin/bash
## create a keyboard shortcut [ctrl + up + q]
## to launch a search with clipboard content
QUERY=`xclip -o`
URL='https://www.google.com/search?&q='
URL+="$QUERY"
firefox --new-tab "$URL"
@AdSegura
AdSegura / wireguard_show.py
Last active April 5, 2023 21:37
wireguard show client list
#!/usr/bin/env python3
##
# Show wireguard statistics with usernames assigned to their public keys
# $> ./wg-show.py with no options will use
# wg0_file="/etc/wireguard/wg0.conf"
# wg_iface="wg0"
# sg_to_timeout=300 seconds
#
# ./wg-show.py --help
# usage: wg-show.py [-h] [--config CONFIG] [--interface INTERFACE]
// <p class="transform_date" data-date="2020-07-30 18:08:22"></p>
$(".transform_date").each(function() {
let created_at = $(this).data("date")
let ago = moment.tz(created_at, "YYYY-MM-DD HH:mm:ss", "UTC").fromNow();
$(this).html(ago)
});
@AdSegura
AdSegura / boss.js
Last active October 24, 2019 18:08
Nodejs workers as writeable stream
'use strict';
/**
* Nodejs Stream Workers example
* will cipher and return deciphered file.txt to console output
* using a worker as a writeable stream.
*
* Use:
* node boss.js < file.txt
*
* if node < 12
@AdSegura
AdSegura / makeBigFile.js
Created October 12, 2019 00:48
Backpressuring in NodeJs Streams
//Prerequisite: cli-progress ^3.0.0
const fs = require('fs');
const _cliProgress = require('cli-progress');
let script_mode = false;
/**
* Make a big file, or small...
*
* Cli:
* > node makeBigFile.js --dest '/tmp/foo.txt' --size 1gb
@AdSegura
AdSegura / AccessToken.php
Created August 3, 2019 13:53
Get AccessToken Bearer JWT Laravel Passport
// Code from https://github.com/laravel/passport/issues/779#issuecomment-429536388
<?php
namespace App;
use Laravel\Passport\Passport;
use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Signer\Key;
use Lcobucci\JWT\Signer\Rsa\Sha256;
use League\OAuth2\Server\CryptKey;