Skip to content

Instantly share code, notes, and snippets.

View Majkl578's full-sized avatar
💥
breaking builds

Michael Moravec Majkl578

💥
breaking builds
View GitHub Profile
@Majkl578
Majkl578 / gist:947036
Created April 28, 2011 18:57
webalizing string in JS
<head>
<script type="text/javascript">
var webalize = function (str) {
var charlist;
charlist = [
['Á','A'], ['Ä','A'], ['Č','C'], ['Ç','C'], ['Ď','D'], ['É','E'], ['Ě','E'],
['Ë','E'], ['Í','I'], ['Ň','N'], ['Ó','O'], ['Ö','O'], ['Ř','R'], ['Š','S'],
['Ť','T'], ['Ú','U'], ['Ů','U'], ['Ü','U'], ['Ý','Y'], ['Ž','Z'], ['á','a'],
['ä','a'], ['č','c'], ['ç','c'], ['ď','d'], ['é','e'], ['ě','e'], ['ë','e'],
['í','i'], ['ň','n'], ['ó','o'], ['ö','o'], ['ř','r'], ['š','s'], ['ť','t'],
@Majkl578
Majkl578 / Dockerfile
Last active November 8, 2019 17:41
Dockerized example for article at Pehapkari.cz about running multiple PHP versions: https://pehapkari.cz/blog/2017/03/27/multiple-php-versions-the-easy-way/
FROM debian:stretch
ENV DEBIAN_FRONTEND noninteractive
# install NGINX
RUN apt-get update && \
apt-get install -y nginx --no-install-recommends && \
rm -rf /var/lib/apt/lists/*
@Majkl578
Majkl578 / typed-property.php
Last active June 5, 2019 12:31
model example for typed properties
<?php
declare(strict_types=1);
final class Foo
{
var DateTimeImmutable $createdAt {
get;
private set(DateTimeImmutable $value) : void {
assert($this->createdAt === null, "Can't change time of creation.");

Keybase proof

I hereby claim:

  • I am majkl578 on github.
  • I am majkl (https://keybase.io/majkl) on keybase.
  • I have a public key ASBoeRpsENPXRp5PvnaxBaoeKzodCPdO3Q5JA5WA1hfT7wo

To claim this, I am signing this object:

@Majkl578
Majkl578 / Comparable.php
Last active October 30, 2018 13:25
Equatable + Comparable
<?php
declare(strict_types=1);
namespace Comparison;
/**
* This interface imposes a total ordering on the objects of each class that implements it.
* This ordering is referred to as the class's natural ordering, and the class's compareTo method
* is referred to as its natural comparison method.
@Majkl578
Majkl578 / ArbitraryRun.php
Last active September 10, 2018 12:26
typed factory
<?php
declare(strict_Types=1);
namespace Example;
(function () : void {
$requestFactory = new class implements ServerRequestFactory {
public function __invoke() : ServerRequest
{
<?php
$hello = 'Hello';
$world = 'World';
$speaker = new class use ($hello as public, $world as private $who) {
public function say() : void
{
echo $this->hello . ' ' $this->who, PHP_EOL;
}
$ vendor/bin/roave-backward-compatibility-check r:a --from=v1.7.2 --to=master -- lib
Comparing from 3e7656c5adfd9b7d0d8757aa1e9e8daf43a6f200 to bba2123d7d8ab43927ff2370a4785892b7c181d5...
Loading composer repositories with package information
Updating dependencies
Package operations: 13 installs, 0 updates, 0 removals
- Installing ocramius/package-versions (1.3.0): Loading from cache
- Installing zendframework/zend-eventmanager (3.2.1): Loading from cache
- Installing zendframework/zend-code (3.3.0): Loading from cache
- Installing ocramius/proxy-manager (2.2.0): Loading from cache
- Installing symfony/polyfill-mbstring (v1.8.0): Loading from cache
> Annotations
> > Annotation
> > > Reference {"identifier":"Annot","fully_qualified":false}
> > > Parameters
> > > > Parameter\NamedParameter
> > > > > Scalar\Identifier {"value":"v1"}
> > > > > Collection\ListCollection
> > > > > > Scalar\IntegerScalar {"value":1}
> > > > > > Scalar\IntegerScalar {"value":2}
> > > > > > Scalar\IntegerScalar {"value":3}
@Majkl578
Majkl578 / 100
Created April 27, 2018 18:15
Doctrine logo ASCII
+----------------------------------------------------------------------------------------------------+
|oooooooooooooooooooooooooo:: ...:ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooo.. .::oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooo:. .:oooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|ooooooooooooooooooooo: .:oooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|ooooooooooooooooooooo ..oooooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooo: .:oooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooo. ..oooooooooooooooooooooooooooooooooooooooooooooooo|
|ooooooooooooooooooooo :oooooooooooooooooooooooooooooooooooooooooooooo|
|ooooooooooooooooooooo: .oooooooooooooooooooooooooooooooooooooooo