Disclaimer: I assume someone has already suggested this and there are good reasons it hasn't happened!
Inspired by a conversation with @pronskiy after my talk "PHP Generics Today (Almost)" at IPC Munich
Examples:
class Queue #
# Based on younesbelkada/finetune_llama_v2.py | |
# Install the following libraries: | |
# pip install accelerate==0.21.0 peft==0.4.0 bitsandbytes==0.40.2 transformers==4.31.0 trl==0.4.7 scipy | |
from dataclasses import dataclass, field | |
from typing import Optional | |
import torch | |
from datasets import load_dataset | |
from transformers import ( |
Disclaimer: I assume someone has already suggested this and there are good reasons it hasn't happened!
Inspired by a conversation with @pronskiy after my talk "PHP Generics Today (Almost)" at IPC Munich
Examples:
class Queue #
<?php | |
function file_get_contents(string $pathname): string | |
{ | |
$result = ''; | |
$fp = fopen($pathname, 'rb'); | |
while (!feof($fp)) { | |
$chunk = 1024; | |
Fiber::getCurrent() && ($chunk = (Fiber::suspend() ?: 1024)); |
<?php | |
$variable = 23; | |
[$query, $params] = sql(fn() => <<<SQL | |
SELECT * FROM users WHERE id = ${yield $variable} OR id = ${yield 42} | |
SQL); | |
var_dump($query, $params); | |
// |
#!/bin/bash | |
# Find files in CVE-2020-15227 nette/application issue | |
# by @spazef0rze | |
# Run with `bash find-cve-2020-15227.sh`, works on Linux, FreeBSD, tested on Ubuntu 18.04, FreeBSD 11.4 | |
# This is a universal finder for all affected versions. | |
# Requirements: find, grep, bash (might work with your default shell but YMMV) | |
# The fixes: |
<?php declare(strict_types=1); | |
/** | |
* @param float $value | |
* | |
* @return string | |
*/ | |
function float2hex(float $value): string | |
{ | |
$pack = pack('f', $value); | |
$hex = ''; |
/* add to your userChrome.css */ | |
#TabsToolbar { | |
visibility: collapse; | |
overflow: visible; | |
} | |
#TabsToolbar > * { | |
visibility: collapse; | |
} |
<?php | |
use Phan\CodeBase; | |
use Phan\Language\Context; | |
use Phan\Language\UnionType; | |
use Phan\PluginV2\ReturnTypeOverrideCapability; | |
use Phan\Language\Element\Method; | |
use Phan\PluginV2; | |
use \Phan\Language\FQSEN\FullyQualifiedClassName; | |
use Phan\Language\Element\Clazz; |
<?php | |
/** | |
* Using WP Statuses for custom Post Types. | |
* | |
* @link http://github.com/imath/wp-statuses | |
*/ | |
// Exit if accessed directly. | |
defined( 'ABSPATH' ) || exit; |