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 | |
/** | |
* import debounce CSV | |
*/ | |
require __DIR__ . '/../vendor/autoload.php'; | |
core\Unsafe::init(); | |
require_once __DIR__ . '/../vendor/mpdroog/core/init-cli.php'; | |
use core\Cli; | |
use core\Helper; |
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
brew install mariadb | |
$(brew --prefix mariadb)/bin/mysqladmin -u root password |
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
curl -4 -svo /dev/null --resolve www.example.com:443:1.2.3.4 https://www.example.com |
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 | |
$ch = curl_init(); | |
if ($ch === false) { | |
user_error("curl_init fail"); | |
} | |
$opt = 1; | |
$opt &= curl_setopt($ch, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify"); | |
$opt &= curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$opt &= curl_setopt($ch, CURLOPT_TIMEOUT, 3); | |
$opt &= curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); |
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 | |
const API_KEY = "a-b-c-d"; | |
const SECRET_KEY = "SuperSecretKeyFromKayako"; | |
const HTTP_AUTH = "base64user:pass"; // Leave empty if none | |
const HTTP_URL = "https://www.yourwebsite.com/kayako/api/index.php?e="; | |
function has_prefix($s, $prefix) { | |
return mb_substr($s, 0, mb_strlen($prefix)) === $prefix; | |
} |
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
// Small (vanilla) JS to make div scroll with the view | |
// Saving this code for historical purposes | |
// Note: In 2022 this is also possible with CSS through position: sticky | |
var dom = { | |
off: function ($node) { | |
var sum = $node.offsetTop; | |
if ($node.offsetParent) { | |
sum += dom.off($node.offsetParent); | |
} |
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
var global = { | |
carousels: [], | |
slide: 0, | |
}; | |
function nextSlide() { | |
console.log("nextSlide", global); | |
global.carousels[global.slide].classList.toggle("active"); | |
global.slide++; |
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 | |
# Using lock-file to ensure only one instance can be running | |
# at the same time. | |
# DevNote: The trap is used to ensure we ALWAYS remove the lock upon completion | |
set -x | |
set -e | |
if ! mkdir /tmp/MYSCRIPT.lock; then | |
printf "MYSCRIPT already running.\n" >&2 | |
exit 1 | |
fi |
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
// https://stackoverflow.com/questions/30928770/marshall-map-to-xml-in-go | |
// https://stackoverflow.com/questions/33486725/golang-xml-unmarshal-interface-types | |
package main | |
import ( | |
"fmt" | |
"encoding/xml" | |
) | |
// StringMap is a map[string]string. |
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 | |
/** | |
* PO to JSON. | |
*/ | |
$lang = "fr"; | |
$lines = explode("\n", file_get_contents(__DIR__ . "/text.po")); | |
array_shift($lines); array_shift($lines); // Ignore first two lines | |
$out = []; |
NewerOlder