Skip to content

Instantly share code, notes, and snippets.

View TheSkallywag's full-sized avatar

Skallywag TheSkallywag

View GitHub Profile
@TheSkallywag
TheSkallywag / partial-html-repair.php
Created November 7, 2020 17:45 — forked from eusonlito/partial-html-repair.php
This function allow to repair bad partial HTML (without DOCTYPE, html, head or body tags).
<?php
function fixHtml ($html)
{
libxml_use_internal_errors(true);
$DOM = new \DOMDocument;
$DOM->recover = true;
$DOM->preserveWhiteSpace = false;
$DOM->substituteEntities = false;
$DOM->loadHtml('<?xml encoding="UTF-8">'.$html, LIBXML_NOBLANKS | LIBXML_ERR_NONE);
@TheSkallywag
TheSkallywag / terminal-gif.md
Created September 24, 2020 05:40 — forked from protrolium/terminal-gif.md
convert images to GIF in Terminal

Install ImageMagick

brew install ImageMagick

Pull specific region of frames from video file w/ ffmpeg

ffmpeg -ss 14:55 -i video.mkv -t 5 -s 480x270 -f image2 %04d.png

  • -ss 14:55 gives the timestamp where I want FFmpeg to start, as a duration string.
  • -t 5 says how much I want FFmpeg to decode, using the same duration syntax as for -ss.
  • -s 480x270 tells FFmpeg to resize the video output to 480 by 270 pixels.
  • -f image2 selects the output format, a series of still images — make sure there are leading zeros in filename.
/**
* Based on the mysql cluster
* @link http://jonisalonen.com/2012/k-means-clustering-in-mysql/
*/
-- SELECT
-- * FROM
-- unnest(kmeans(array(SELECT
-- (
-- lat,
@TheSkallywag
TheSkallywag / my.cnf
Last active August 21, 2020 17:11 — forked from fevangelou/my.cnf
Optimized my.cnf configuration for MySQL/MariaSQL (on Ubuntu, CentOS etc. servers)
# Optimized my.cnf configuration for MySQL/MariaSQL
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated January 2020 ~
#
#
# The settings provided below are a starting point for a 2GB - 4GB RAM server with 2-4 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#
@TheSkallywag
TheSkallywag / customizer.php
Created March 17, 2020 04:40 — forked from colorful-tones/customizer.php
Child theme for Go - includes custom Customizer options
<?php
/**
* Customizer setup
*
* @package YourChildTheme
*/
namespace YourChildTheme\Customizer;
/**
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@TheSkallywag
TheSkallywag / utf8buffer.js
Created November 30, 2019 19:39 — forked from hugowetterberg/utf8buffer.js
A test of utf8-encoding in javascript
// https://github.com/beatgammit/base64-js
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
;(function (exports) {
'use strict'
var Arr = (typeof Uint8Array !== 'undefined')
? Uint8Array
: Array
@TheSkallywag
TheSkallywag / doh_test.sh
Created October 19, 2019 09:33 — forked from dtmsecurity/doh_test.sh
DNS over HTTPS (DoH) Resolver GET Test Script
#!/bin/bash
printf "===START dns.google.com===\n"
curl -k -H "accept: application/dns-json" "https://dns.google.com/resolve?name=example.com&type=AAAA"
printf "\n===END dns.google.com===\n"
printf "===START cloudflare-dns.com===\n"
curl -k -H "accept: application/dns-json" "https://cloudflare-dns.com/dns-query?name=example.com&type=AAAA"
printf "\n===END cloudflare-dns.com===\n"
printf "===START 1.1.1.1===\n"
curl -k -H "accept: application/dns-json" "https://1.1.1.1/dns-query?name=example.com&type=AAAA"
printf "\n===END 1.1.1.1===\n"
<?php
class Db
{
private $_connection;
private static $_instance; //The single instance
private $_host = DB_HOST;
private $_username = DB_USER;
private $_password = DB_PASSWORD;
private $_database = DB_DB;
@TheSkallywag
TheSkallywag / class.database.php
Created July 3, 2019 23:18 — forked from jonashansen229/class.database.php
PHP OOP Database class using MySQLI and Singleton pattern. Only one instance of the class will be made, this requires less memory.
<?php
/*
* Mysql database class - only one connection alowed
*/
class Database {
private $_connection;
private static $_instance; //The single instance
private $_host = "HOSTt";
private $_username = "USERNAME";
private $_password = "PASSWORd";