Skip to content

Instantly share code, notes, and snippets.

@Baptouuuu
Baptouuuu / example.php
Created October 3, 2021 09:37
Objects are parameterised functions
<?php
declare(strict_types=1);
$constructor = function(string $name) {
$properties = ['name' => $name];
return function(string $method) use (&$properties) {
return match($method) {
'say' => fn() => print('hello '.$properties['name']."\n"),
'rename' => function(string $name) use (&$properties): void {
@Baptouuuu
Baptouuuu / Info.plist
Created January 21, 2019 20:03
Sublime Handler.app
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>SysPref Handler</string>
<key>CFBundleURLSchemes</key>
<array>
<string>sublime</string>
</array>
</dict>
@Baptouuuu
Baptouuuu / bootstrap.sh
Last active September 30, 2018 12:44
Bootstrap php
#!/usr/bin/env bash
# install php 7.2
apt-get install apt-transport-https lsb-release ca-certificates -y
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
apt-get update
apt-get install git php7.2 php7.2-fpm php7.2-cli php7.2-json php7.2-xml php7.2-intl php7.2-mbstring php7.2-curl php7.2-zip php7.2-gd php7.2-bcmath -y
# install composer
@Baptouuuu
Baptouuuu / shared-worker.js
Last active August 29, 2015 13:56
small worker to share data to all tabs that opened the worker
var ports = [];
self.addEventListener('connect', function (event) {
var port = event.source;
ports.push(port);
port.addEventListener('message', function (e) {
for (var i = 0, l = ports.length; i < l; i++) {