Skip to content

Instantly share code, notes, and snippets.

@rg443a
rg443a / dbip-mmdb-update.sh
Created May 2, 2021 20:23
dbip mmdb update
#!/usr/bin/env bash
cd /usr/share/GeoIP;
curl -LRO https://download.db-ip.com/free/dbip-country-lite-$(date +%Y-%m).mmdb.gz;
curl -LRO https://download.db-ip.com/free/dbip-city-lite-$(date +%Y-%m).mmdb.gz;
curl -LRO https://download.db-ip.com/free/dbip-asn-lite-$(date +%Y-%m).mmdb.gz;
gunzip dbip-$(date +%Y-%m).mmdb.gz;
ln -sf dbip-country-lite-$(date +%Y-%m).mmdb dbip-country-lite.mmdb;
ln -sf dbip-city-lite-$(date +%Y-%m).mmdb dbip-city-lite.mmdb;
ln -sf dbip-asn-lite-$(date +%Y-%m).mmdb dbip-asn-lite.mmdb;
geoipupdate -v;
# https://help.duckduckgo.com/duckduckgo-help-pages/results/duckduckbot/
20.191.45.212
23.21.227.69
40.88.21.235
50.16.241.113
50.16.241.114
50.16.241.117
50.16.247.234
52.5.190.19
@rg443a
rg443a / Streamer.php
Created May 26, 2021 10:58 — forked from gpbmike/Streamer.php
php backend for streaming file upload with XMLHttpRequest
<?php
class File_Streamer
{
private $_fileName;
private $_contentLength;
private $_destination;
public function __construct()
{
if (!isset($_SERVER['HTTP_X_FILE_NAME'])
@rg443a
rg443a / sparklines1.js
Created June 26, 2022 13:04
svg sparklines in javascript
function getY(max, height, diff, value) {
return parseFloat((height - (value * height / max) + diff).toFixed(2));
}
function removeChildren(svg) {
[...svg.querySelectorAll("*")].forEach(element => svg.removeChild(element));
}
function defaultFetch(entry) {
return entry.value;
@rg443a
rg443a / wp_tags.js
Last active January 6, 2023 22:46
wp server sites and tags
wp_continents = {"northamerica":{"Albany":{"id":"latham","name":"albany","title":"Albany","location":"Latham","state":"New York","country":"United States","latitude":"42.7469","longitude":"-73.7589","continent_name":"North America"},"Albuquerque":{"id":"albuquerque","name":"albuquerque","title":"Albuquerque","location":"Albuquerque","state":"New Mexico","country":"United States","latitude":"35.1107","longitude":"-106.6100","continent_name":"North America"},"Asheville":{"id":"asheville","name":"asheville","title":"Asheville","location":"Asheville","state":"North Carolina","country":"United States","latitude":"35.6008","longitude":"-82.5542","continent_name":"North America"},"Atlanta":{"id":"atlanta","name":"atlanta","title":"Atlanta","location":"Atlanta","state":"Georgia","country":"United States","latitude":"33.7489","longitude":"-84.3881","continent_name":"North America"},"Austin":{"id":"austin","name":"austin","title":"Austin","location":"Austin","state":"Texas","country":"United States","latitude":"30.2500
@rg443a
rg443a / inet_aton.sql
Created June 7, 2024 20:30
duckdb inet_aton function
CREATE OR REPLACE FUNCTION inet_aton(ip) AS (
cast(
split_part(ip, '.', 1)::UINTEGER * 16777216 +
split_part(ip, '.', 2)::UTINYINT * 65536 +
split_part(ip, '.', 3)::UTINYINT * 256 +
split_part(ip, '.', 4)::UTINYINT as UINTEGER)
);
-- select inet_aton('255.255.255.252');
<?php
$data = "lazy dog";
foreach (hash_algos() as $v) {
$r = hash($v, $data, false);
printf("%-12s %3d %s\n", $v, strlen($r), $r);
}
/*