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
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
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
<!DOCTYPE html> | |
<html lang="en"> | |
<!-- | |
A sample framework for the ESA-NASA WebWorldWind web applications. | |
Author: Bruce Schubert | |
License: MIT | |
See: https://worldwind.arc.nasa.gov/web/ | |
--> | |
<head> | |
<meta charset="utf-8"> |
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
"/*@ sourceMappingURL=" source mapping URL declaration is deprecated, "/*# sourceMappingURL=" declaration should be used instead. | |
//@ sourceMappingURL=jquery.min.map | |
to | |
//# sourceMappingURL=jquery.min.map | |
//@ sourceURL=<url> | |
to | |
//# sourceURL=<url> |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2013 Johan Hillerström <https://github.com/hillerstorm> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
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
CREATE EXTENSION IF NOT EXISTS "unaccent"; | |
CREATE OR REPLACE FUNCTION slugify("value" TEXT) | |
RETURNS TEXT AS $$ | |
-- removes accents (diacritic signs) from a given string -- | |
WITH "unaccented" AS ( | |
SELECT unaccent("value") AS "value" | |
), | |
-- lowercases the string | |
"lowercase" AS ( |
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
WITH | |
activities AS ( | |
SELECT * FROM ( | |
VALUES | |
('D', '2018-01-09 11:00:00'::timestamp, '2018-01-09 11:10:00'::timestamp, 1), | |
('A', '2018-01-09 10:00:00'::timestamp, '2018-01-09 12:00:00'::timestamp, 1), | |
('X', '2018-01-09 10:05:00'::timestamp, '2018-01-09 10:11:00'::timestamp, 1), | |
('B', '2018-01-09 14:00:00'::timestamp, '2018-01-09 16:00:00'::timestamp, 1), | |
('C', '2018-01-09 10:10:00'::timestamp, '2018-01-09 10:30:00'::timestamp, 1) | |
) AS act ("name", "start", "end", "count") |
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 sortMultidimensionalArray($arr, $attr){ | |
// Comparison function | |
$compareTIME = function ($el1, $el2) use ($attr){ | |
$datetime1 = strtotime($el1[$attr]); | |
$datetime2 = strtotime($el2[$attr]); | |
return $datetime1 - $datetime2; | |
}; |
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 | |
$arr= array( | |
array("an"=>2, 'fac'=>5000, 'sr'=>45), | |
array("an"=>4, 'fac'=>5001, 'sr'=>40), | |
array("an"=>2, 'fac'=>5000, 'sr'=>40), | |
array("an"=>2, 'fac'=>5001, 'sr'=>45) | |
); | |
$cond=array("an"=>2, 'fac'=>5001); |