Instantly share code, notes, and snippets.

View gist:57f5fe27945ee5ae8324
<?php
// https://bugs.php.net/bug.php?id=68485
namespace Math {
class Calculator {
public static function calculate($operator, $operand1, $operand2) {
switch ($operator) {
View gist:1375e605838e67dde10f
<?php
// https://bugs.php.net/bug.php?id=68485
namespace Math {
class Calculator {
public static function calculate($operator, $operand1, $operand2) {
switch ($operator) {
View freenas-error-while-trying-to-open-the-web-shell.md

FreeNAS-9.3-STABLE-201509282017

[date] [hostname] kernel: sonewconn: pcb 0x[hex]: Listen queue overflow: [#] already in queue awaiting acceptance ([#] occurrences)

Seen some people talk about the web shell being a bit finicky. I had opened it up many times since it rebooted last, and had the console messages in the footer enabled (System > Advanced > Show console messages in the footer). After some time, attempting to start the shell would show the "Loading" message for a few seconds before the window disappeared and the error message appeared in the footer.

Couple people said to restart FreeNAS. That wasn't an option for me.

View OQrmDNv.md

OQrmDNv http://imgur.com/gallery/OQrmDNv

The image shows some long division where {26& ÷ %2# = # with no remainder. Put another way, # × %2# = {26&.

The problem is to find the numeric values of the four symbols used: # % { &. Each is a single digit and presumably not one of 2, 6, or 0 (which were written normally), nor is a digit reused with multiple symbols.

The most obvious symbol to start with is #. # × # = & with maybe something carried into the ten's place. Of the 10 digits, 7 are available to try:

  • 1 × 1 = 1 (#=1, &=1) - no: it reuses the 1 for two symbols
  • 3 × 3 = 9 (#=3, &=9) - possible
View wired-without-the-adblock-veil.userscript.js
// ==UserScript==
// @name Wired without the adblock veil
// @namespace http://gist.github.com/requinix
// @version 0.9
// @author requinix
// @match http://www.wired.com/*
// ==/UserScript==
/* jshint -W097 */
'use strict';
View regex-email.php
<?php
// This code/file/output has no license, though attribution would be appreciated.
// Output at http://pastebin.com/2ZLehM5N
if ($_SERVER["QUERY_STRING"] == "source") {
highlight_file(__FILE__);
return;
}
View parse_date_abbr_search.c
const static timelib_tz_lookup_table* abbr_search(const char *word, timelib_long gmtoffset, int isdst)
{
int abbr_found = 0, offset_found = 0;
const timelib_tz_lookup_table *tp, *abbr_found_elem = NULL, *offset_found_elem = NULL;
if (strcasecmp("utc", word) == 0 || strcasecmp("gmt", word) == 0) {
return timelib_timezone_utc;
}
for (tp = timelib_timezone_lookup; tp->name; tp++) {
View php-bug-74077.md

https://bugs.php.net/bug.php?id=74077

Good news is that it isn't so difficult to explain this. What's happening is array_map really has two modes of operation: one array and multiple arrays.

Using one array, (a) with $callback: keep array keys, transform value using $callback(value) (b) without $callback: return a copy of the array

array_map(function($value) { return $value; }, $array)
View php-bug-74142.txt
LimitIterator_::rewind rewind at the beginning of the foreach...
> TestFilterIterator_::rewind ...and the inner iterator
> > ArrayIterator_::rewind ...and again. now testfilteriterator must look for the first accept()able value
> > ArrayIterator_::valid iterate on arrayiterator...
> > ArrayIterator_::current ...
> > ArrayIterator_::key ...
> > TestFilterIterator_::accept ...and test the first value it found
accept (call #1 on [0]=>'0')
> > ArrayIterator_::next value ('0') was not accepted
> > ArrayIterator_::valid continue iterating...
View papyrus-skyrim.tmLanguage.json
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "Papyrus (Skyrim)",
"scopeName": "source.papyrus-skyrim",
"foldingStartMarker": "(?i)\\b(event|function|property|state)\\b",
"foldingStopMarker": "(?i)\\b(endevent|endfunction|endproperty|endstate)\\b",
"patterns": [
{ "include": "#comments" },
{ "include": "#events" },
{ "include": "#flags" },