Skip to content

Instantly share code, notes, and snippets.

View delboy1978uk's full-sized avatar

Derek Stephen McLean delboy1978uk

View GitHub Profile
@delboy1978uk
delboy1978uk / gist:0ba9ed1562c9bd8465dcc6828997c88e
Created April 13, 2021 15:46
DOM Document appending fragments
<?php
$dom = new DOMDocument();
$html = '<head><meta garbage="what"/></head>';
$head = $dom->createDocumentFragment();
$head->appendXML($html);
$html = '<body><h1>Hello</h1></body>';
$body = $dom->createDocumentFragment();
$body->appendXML($html);
@delboy1978uk
delboy1978uk / gist:270ffc801c4d8530342e6cbe456ebe22
Created April 25, 2020 21:41
how to implement `tags` properly
22 Apr
Steam Labs Search Experiment 4.1: Query Expansion
Steam Blog - christen
Now We're Thinking with Queries
In this experiment, Query Expansion, we improve Steam Search by treating tags more like a human would: using logic! Take the three tags RTS, Real-Time, and Strategy, for instance. If a game is tagged RTS but not Real-Time and Strategy, a search for Real-Time + Strategy won’t find that game using Steam's existing Search tech. Query Expansion fixes that.
You can experience our new Search Results - including those surfaced thanks to Query Expansion - when you visit Steam Labs Experiment 004.1: Search Query Expansion. Here, many searches which leverage tags will now cast a wider net and display more titles. As always, we’d love your feedback; You can let us know what you think of your new Search Results in the discussions.
Read on to learn about how Query Expansion gives better search results.
@delboy1978uk
delboy1978uk / gist:ebb438524972bb6b64596df7e9782f6e
Created December 13, 2019 14:23
SSL encryption/decryption
class Ssl
{
private $cipher = "aes-128-gcm";
private $options = 0;
/**
* @param string $plaintext
* @return array
*/
public function encrypt($plaintext)
<?php
namespace Meta\Library\Development;
use Meta\Common\Collections\Collection;
/**
* Class Timer
*
* Inspired by javscripts console.time/console.timeEnd
ECONOMIC
1. We can pool and share British-wide resources. This means Scotland can help pay for the rest of the UK's needs, and the rest of the UK can help Scotland, when and where necessary to the tune of millions and billions.
- The UK overspends its budget EVERY YEAR leaving us with a 13 billion pound black hole
2. We can redistribute wealth, via the British-wide tax system. This helps to safeguard welfare benefits, the state pension, and protect us from fluctuating oil revenues.
- welfare and pensions are the worst in the western world
3. We can remain part of the overall UK domestic market with no internal tariffs. Firms in Scotland sell twice as much to the rest of the UK as we do to the rest of the world combined.
- We are about to go out on WTO terms. Better in the EU.
<script>
function createMap() {
$("#map").kendoMap({
center: [30.2681, -97.7448],
zoom: 3,
layers: [
{
type: "shape",
dataSource: {
type: "geojson",
{
"type": "Feature",
"id": "SEA",
"properties": {
"name": "The Sea",
"risk": 0
},
"style": {
"backgound-color": "light-blue"
},
<?php
class Singleton
{
protected static $instance;
private function __construct(){}
private function __clone(){}
public static function getInstance(): self
<?php
class PaginatorException extends Exception
{
public const NO_PAGE_COUNT = 'No total page count';
public const NO_URL = 'No URL set';
public const NO_URL_PART = 'No URL part set';
public const NO_CURRENT_PAGE = 'No current page count';
}
RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]