Skip to content

Instantly share code, notes, and snippets.

View guerrerocarlos's full-sized avatar
:octocat:
On shoulders of giants.

Carlos Guerrero guerrerocarlos

:octocat:
On shoulders of giants.
View GitHub Profile
@media screen and (max-width: 767px) {
table.table-magic {
border: 0;
}
table.table-magic thead {
display: none;
}
table.table-magic tr {
margin-bottom: 10px;
display: block;
@guerrerocarlos
guerrerocarlos / gist:db3e0f21c1f0a431b7cba2269a97d71f
Created March 14, 2023 15:18
MacOS Dock Autohide Animation Tweak
defaults write com.apple.dock autohide-delay -float 0 ;killall Dock
defaults write com.apple.dock autohide-time-modifier -float 0; killall Dock
@guerrerocarlos
guerrerocarlos / crypto_codec.js
Created January 30, 2023 01:43
crypto.webcrypto Encrypt and Decrypt example using native crypto module
const crypto = require("crypto");
const { subtle } = crypto.webcrypto;
const iv = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); // crypto.getRandomValues(new Uint8Array(12));
const algorithm = {
iv,
name: "AES-GCM",
};
function btoa(str) {
@guerrerocarlos
guerrerocarlos / getGoogleAuthToken.js
Created October 26, 2022 16:16 — forked from markelliot/getGoogleAuthToken.js
Converts Google service user OAuth2 credentials into an access token in Cloudflare-compatible JS
/**
* Get a Google auth token given service user credentials. This function
* is a very slightly modified version of the one found at
* https://community.cloudflare.com/t/example-google-oauth-2-0-for-service-accounts-using-cf-worker/258220
*
* @param {string} user the service user identity, typically of the
* form [user]@[project].iam.gserviceaccount.com
* @param {string} key the private key corresponding to user
* @param {string} scope the scopes to request for this token, a
* listing of available scopes is provided at
@guerrerocarlos
guerrerocarlos / wireguard.conf
Created October 13, 2022 17:47 — forked from nealfennimore/wireguard.conf
Wireguard VPN - Forward all traffic to server
# ------------------------------------------------
# Config files are located in /etc/wireguard/wg0
# ------------------------------------------------
# ---------- Server Config ----------
[Interface]
Address = 10.10.0.1/24 # IPV4 CIDR
Address = fd86:ea04:1111::1/64 # IPV6 CIDR
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE # Add forwarding when VPN is started
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE # Remove forwarding when VPN is shutdown
@guerrerocarlos
guerrerocarlos / add_peer.sh
Created June 13, 2022 18:43
Wireguard add peer script
#!/bin/bash
set -eu
client_ip=$1
psk=$(wg genpsk)
wg genkey > clientprivkey.tmp
client_privkey=$(cat clientprivkey.tmp)
client_pubkey=$(cat clientprivkey.tmp | wg pubkey)
server_pubkey=$(cat publickey)
@guerrerocarlos
guerrerocarlos / new_peer.sh
Created June 13, 2022 16:51 — forked from joneskoo/new_peer.sh
Wireguard client/server config generator
#!/bin/bash
set -eu
set -o pipefail
dns_server=172.24.100.250
client_ip=$1
psk=$(wg genpsk)
client_privkey=$(wg genkey)
client_pubkey=$(wg pubkey <<<"$client_privkey")
@guerrerocarlos
guerrerocarlos / nodejs-https-requests.js
Created April 6, 2022 14:52 — forked from rajinder-yadav/nodejs-https-requests.js
Node.js making a HTTPS request with GET and POST
const https = require('https');
async function httpsGet(hostname, path, headers) {
return new Promise(async (resolve, reject) => {
const options = {
hostname: hostname,
path: path,
port: 443,
method: 'GET',
# fast Dock
defaults write com.apple.dock autohide-time-modifier -int 0;
defaults write com.apple.dock autohide-delay -int 0;
killall Dock
# brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# terminal
brew cask install iterm2