A Pen by Johanna Ruiz on CodePen.
This file contains hidden or 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 sort_array_by_attributes($array, ...$attributes) | |
{ | |
// Create arrays of values to sort by | |
$sort_keys = []; | |
foreach ($attributes as $attribute) { | |
$sort_keys[] = array_column($array, $attribute); | |
} | |
// Add the array to be sorted as the last argument | |
$sort_keys[] = &$array; |
This file contains hidden or 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 create_zip_stream($file_paths) | |
{ | |
// Create a new ZipArchive object | |
$zip = new ZipArchive(); | |
// Open a memory stream for the zip file | |
$zip_stream = fopen('php://memory', 'w+'); | |
$zip->open($zip_stream, ZipArchive::CREATE); | |
// Add the files to the zip |
This file contains hidden or 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 | |
function read_cb($ch, $fp, $length) { | |
return fread($fp, $length); | |
} | |
$fp = fopen('php://memory', 'r+'); | |
$string = "From: <[email protected]>\r\n"; | |
$string .= "To: <[email protected]>\r\n"; | |
$string .= "Date: " . date('r') . "\r\n"; | |
$string .= "Subject: Test\r\n"; |
This file contains hidden or 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
#add another domain | |
certbot --expand -d subdomain.domain.com | |
#add another domain with SSL and 307 redirect | |
certbot --webroot -w /var/www/html certonly -d subdomain.domain.com 307 -d subdomain.NEWdomain.com |
This file contains hidden or 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 | |
//php streaming proxy | |
header('Access-Control: allow <*>'); //xdomain ajax ftw | |
set_time_limit(24*3600); | |
$fp = fsockopen("192.168.1.149", 80, $errno, $errstr, 30); | |
if (!$fp) { | |
echo "$errstr ($errno)<br />\n"; | |
} else { |
This file contains hidden or 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
/*\ | |
title: $:/boot/boot.js | |
type: application/javascript | |
The main boot kernel for TiddlyWiki. This single file creates a barebones TW environment that is just sufficient to bootstrap the modules containing the main logic of the application. | |
On the server this file is executed directly to boot TiddlyWiki. In the browser, this file is packed into a single HTML file along with other elements: | |
# bootprefix.js | |
# <module definitions> |
This file contains hidden or 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 compare_by_alphabet($str1, $str2) { | |
$alphabet = "AaÀàÁáÂâÅåÃãÄ䯿BbCcÇçDdÐðEeÈèÉéÊêËëFfGgHhIiÌìÍíÎîÏïJjKkLlMmNnÑñOoÒòÓóÔôÕõÖöØøPpQqRrSsߊšTtUuÙùÚúÛûÜüVvWwXxYyŸÿÝýZzŽžÞþ0123456789"; | |
$l1 = mb_strlen($str1); | |
$l2 = mb_strlen($str2); | |
$c = min($l1, $l2); | |
for ($i = 0; $i < $c; $i++) | |
{ | |
$s1 = mb_substr($str1, $i, 1); |
This file contains hidden or 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/perl | |
use strict; | |
use Mail::IMAPClient; | |
use IO::Socket; | |
use IO::Socket::SSL; | |
use Time::ParseDate; | |
use Data::Dumper; | |
# Config stuff | |
my $mail_hostname = ''; |