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
function trimNewlinesAndSpaces(inputString: string | number) {
// Remove newlines and replace multiple spaces with a single space
if (typeof inputString === "string") {
return inputString.replace(/\n/g, '').replace(/ +/g, ' ').replace(/\,/g, '');
} else {
return "" + inputString
}
}
function trimNewlinesAndSpaces(inputString) {
// Remove newlines and replace multiple spaces with a single space
if (typeof inputString === "string") {
return inputString.replace(/\n/g, '').replace(/ +/g, ' ').replace(/\,/g, '');
} else {
return "" + inputString
}
}
const flattenObj = (results, parentKey, obj) => {
setopt localoptions rmstarsilent
esto
es
una
prueba
@guerrerocarlos
guerrerocarlos / htpasswd.py
Created July 27, 2012 23:55
Python script for generating htaccess passwords
#!/usr/bin/python
"""Replacement for htpasswd"""
# Original author: Eli Carter
import os
import sys
import random
from optparse import OptionParser
# We need a crypt module, but Windows doesn't have one by default. Try to find
@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 / chromecast_with_subtitles.html
Created January 21, 2017 12:45
The chromecast documentation for Chrome is terrible, so to save other's some time, here is the straigt-forward way to stream something quickly and with subtitles
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js"></script>
</head>
<body>
@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