Skip to content

Instantly share code, notes, and snippets.

View marcioAlmada's full-sized avatar
🚀

Márcio Almada marcioAlmada

🚀
View GitHub Profile
// FileSystem custom file system handler
type FileSystem struct {
fs http.FileSystem
}
// Open opens file
func (fs FileSystem) Open(path string) (http.File, error) {
f, err := fs.fs.Open(path)
if err != nil {
return nil, err
#/etc/X11/xorg.conf
Section "Device"
Identifier "nvidia"
Driver "nvidia"
Option "NoLogo" "true"
Option "DPI" "96 x 96"
# Specify Nvidia PCI device
BusID "PCI:1:0:0"
# Make sure X starts also when no outputs are connected to the Nvidia chip
Option "AllowEmptyInitialConfiguration"
@marcioAlmada
marcioAlmada / fail.txt
Last active June 1, 2017 19:58
😭 The most well tested PHP feature...
=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
func_get_arg test [tests/lang/func_get_arg_variation.phpt]
Test wrong number of arguments for flush() (no impact) [tests/output/flush_error_001.phpt]
output buffering - failure [tests/output/ob_014.phpt]
output buffering - failure [tests/output/ob_015.phpt]
Test ob_clean() function : error conditions [tests/output/ob_clean_error_001.phpt]
Test wrong number of arguments for ob_end_clean() [tests/output/ob_end_clean_error_001.phpt]
Test ob_end_flush() function : error conditions [tests/output/ob_end_flush_error_001.phpt]
@marcioAlmada
marcioAlmada / opaque_types.php
Created November 17, 2015 01:44
second order macros FTR
--TEST--
Opaque types with macros that generate other macros :>
--FILE--
<?php
macro {
type T_STRING·newtype = T_STRING·basetype;
} >> {
macro { T_STRING·newtype } >> { T_STRING·basetype }
}
<?php
use Foo\Bar\{ Foo, Bar, Baz, }; // group use
$array = [1, 2, 3,]; // array
fooCall($arg1, $arg2, $arg3,); // function call arglist
class Foo { // class member lists
const
callable_arg_type_list:
/* empty */ { $$ = NULL; }
| '(' ')' { $$ = zend_ast_create_list(0, ZEND_AST_PARAM_LIST); }
| T_INT_CAST {
zval zv;
ZVAL_STRINGL(&zv, "int", sizeof("int")-1);
zend_ast *type = zend_ast_create_zval_ex(&zv, ZEND_NAME_NOT_FQ);
zend_ast *arg = zend_ast_create_ex(ZEND_AST_PARAM, 0, type, NULL, NULL);
zend_ast *args = zend_ast_create_list(0, ZEND_AST_PARAM_LIST);
zend_ast_list_add(args, arg);
<?php declare(strict_types=1);
function crunch_data(array $data, callable(int $left, int $right): int $callback): array {
$result = [];
foreach($data as $left => $right) $result[] = $callback($left, $right);
return $result;
}
$crunched = crunch_data([1 => 2, 3 => 4], function(int $left, int $right): int {
@marcioAlmada
marcioAlmada / room11-sidebar.css
Created September 21, 2015 16:22
Use with stylish browser extension.
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document url("http://chat.stackoverflow.com/rooms/11/php") {
#sidebar {
bottom: 88px;
height: auto;
overflow: auto;
padding-left:34px;
}
@marcioAlmada
marcioAlmada / semi_reserved-php7.1.txt
Created August 31, 2015 22:19
List of tokens that can be used as class member identifiers on PHP7
T_INCLUDE
T_INCLUDE_ONCE
T_EVAL
T_REQUIRE
T_REQUIRE_ONCE
T_LOGICAL_OR
T_LOGICAL_XOR
T_LOGICAL_AND
T_INSTANCEOF
T_NEW
--TEST--
Non delimited layer matching
--FILE--
<?php
macro {
(T_STRING·A ···rest) // matches a lisp form
} >> {
T_STRING·A(···rest)
}