This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function calcResize(op){ | |
var ratio = Math[(op.fill)?'max':'min'](op.to.width/op.from.width,op.to.height/op.from.height); | |
var r = { | |
width: Math.round(op.from.width * ratio), | |
height: Math.round(op.from.height * ratio) | |
} | |
r.x = Math.round((op.to.width - r.width) / 2); | |
r.y = Math.round((op.to.height - r.height) / 2); | |
return r; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// nusoap-0.9.5 | |
require 'lib/nusoap.php'; | |
$client = new nusoap_client('http://www.banguat.gob.gt/variables/ws/TipoCambio.asmx?WSDL', true); | |
$error = $client->getError(); | |
if($error){ | |
echo $error; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function formatSize(bytes, si) { | |
var unit = si ? 1000 : 1024; | |
if (bytes < unit) return (bytes % 1 === 0 ? bytes : bytes.toFixed(2)) + "B"; | |
var exp = parseInt(Math.log(bytes) / Math.log(unit)); | |
console.log(exp) | |
var pre = (si ? "kMGTPE" : "KMGTPE")[exp-1] + (si ? "" : "i")+'B'; | |
var n = bytes / Math.pow(unit, exp); | |
return (n % 1 === 0 ? n : n.toFixed(2))+pre; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bandWidth(bits) { | |
var unit = 1000; | |
if (bits < unit) return (bits % 1 === 0 ? bits : bits.toFixed(2)) + "B"; | |
var exp = parseInt(Math.log(bits) / Math.log(unit)); | |
var pre = "KMGTPE"[exp-1] + 'bps'; | |
var n = bits / Math.pow(unit, exp); | |
return (n % 1 === 0 ? n : n.toFixed(2))+pre; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* These functions validate whether a string corresponds to a Guatemalan tax | |
* identification number, also known as 'Numero de Identificación | |
* Tributaria' (NIT). They employ regular expressions for this purpose, utilizing | |
* the metacharacter shorthand '\d' instead of '[0-9]' to save space. | |
* The approach is highly optimized for bandwidth reduction; readability and | |
* maintenance are not prioritized over optimization. You can observe how this | |
* regular expression works through the following links: | |
* - https://regex101.com/r/d5YFJE/1 | |
* - https://regexr.com/7ieic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# firsrun: | |
# install xcode-cli-tools | |
# xcode-select --install | |
# install homebrew | |
# ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
# install caskroom | |
# brew install caskroom/cask/brew-cask | |
# update/install: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple | |
function valCUI(cui){ | |
var nd, v, t=0, dl, dn = [17,8,16,16,13,14,19,8,24,20,9,29,32,22,8,17,12,5,10,11,7,17]; | |
if(nd = /^(\d{8})(\d{1})(\d{2})(\d{2})$/.exec(cui.replace(/\D/g,''))){ | |
v = parseInt(nd[2]); | |
for (var i = 0; i < nd[1].length; i++){ | |
t += nd[1][i] * (i + 2); | |
} | |
if((t % 11) === v){ | |
if(dl=dn[nd[3]-1]){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# originally from | |
# https://raw.githubusercontent.com/mattbrock/mattbrock/master/vCard_photo_extractor/vCard_photo_extractor.sh | |
# changes: | |
# - made to work with macOS's base64 (uses -D not -d) | |
# - does not convert to fixed resolution | |
# - uses identify to remove invalid images | |
# - handles special characters better |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Meters: 6371000, Miles: 3959000 | |
DELIMITER $$ | |
DROP FUNCTION IF EXISTS `DISTANCE_BETWEEN` $$ | |
CREATE FUNCTION DISTANCE_BETWEEN ( | |
lat1 float(10,6), lon1 float(10,6), | |
lat2 float(10,6), lon2 float(10,6) | |
) RETURNS DOUBLE DETERMINISTIC | |
BEGIN | |
return ACOS(SIN(lat1*PI()/180)*SIN(lat2*PI()/180) | |
+ COS(lat1*PI()/180)*COS(lat2*PI()/180) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Twitter/X Space Downloader Bash Script | |
# Copyright (c) 2024 Rodrigo Polo - rodrigopolo.com - The MIT License (MIT) | |
# | |
# Check if a stream URL is provided | |
if [ -z "$1" ]; then | |
echo "Usage: $0 <stream_url>" |
OlderNewer