Skip to content

Instantly share code, notes, and snippets.

View donquixote's full-sized avatar

Andreas Hennings donquixote

View GitHub Profile
@donquixote
donquixote / README.md
Last active June 10, 2025 22:29
Browser search

Usage

Save the search.html in your local filesystem somewhere.

In a chromium-like browser.

Manage search engines. Create search ending with nickname 'eji'.

Add this as search url (remove line breaks): (This example is for Jira search in a specific project)

@donquixote
donquixote / test.js
Last active May 15, 2025 10:57
test.js
alert('hello this is a test');
#!/usr/bin/php
<?php
if (!is_file('composer.lock')) {
print "File 'composer.lock' not found.\n";
exit(1);
}
$orig = file_get_contents('composer.lock');
$cleaned = preg_replace(
@donquixote
donquixote / callable-performance-statistics-result.md
Last active June 13, 2023 02:05
Performance comparison for php callables
Horse Implementations Med./ns Avg/ns Dev/%
convert-only-firstclass class.closure.traditional.array 33.10 33.28 0.315
convert-only-firstclass class.closure.firstclass.array 33.12 33.17 0.272
convert-only-firstclass class.closure.traditional.string 33.13 33.22 0.260
convert-only-firstclass class.closure.firstclass.1 33.15 33.31 0.340
convert-only-firstclass function.closure.traditional 33.18 33.33 0.303
convert-only-firstclass class.closure.firstclass.0 33.23 33.31 0.273
convert-only-firstclass function.closure.firstclass 33.39 33.69 0.404
convert-only-traditional class.closure.traditional.array 36.07 36.30 0.242
<!DOCTYPE html>
<html>
<head>
<style>
div {
--varname: '5';
unknown_property: '5';
content: 'hello';
float: left;
}
<?php
// A "stream" represents a CSV file or another data source.
// "streams" exist on different levels. And a higher-level stream can use a lower-level stream as a data source.
// Problem: Find better nomenclature.
// Currently: RowStream, (AssocRowStream), AssocStream, ObjectStream.
assert($rowStream instanceof RowStreamInterface);
$rows = [];
while (false !== $row = $rowStream->fetchRow()) {
<?php
// See http://stackoverflow.com/questions/4465046/whats-faster-ifreturnelse-return-or-ifreturn-return
function else1($x) {
if ($x === true) {
return true;
}
else {
return false;
}
<?php
function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
[..]
if ($options['nomask'] === NULL
&& $options['recurse']
// Detect patterns like '/\.tpl\.php$/' or '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\.module$/'.
// The first part is
<?php
/**
* Recursively scans a directory and its subdirectories, to collect all files
* that end with the specified extension.
*
* The result is keyed by file basename.
*
* @param string $dir
* E.g. 'sites/all/modules'
<?php
/**
* @return string[][]
* Format: $[$suffix][$prefix] = $function
* Example: $['menu_alter']['system'] = 'system_menu_alter'
*/
function _drupal_get_structured_function_list() {
static $functions_by_suffix_and_prefix = array();