Skip to content

Instantly share code, notes, and snippets.

View ludofleury's full-sized avatar
🐼
Yay

Ludovic Fleury ludofleury

🐼
Yay
View GitHub Profile
@ludofleury
ludofleury / compare.php
Created February 22, 2012 17:04 — forked from naholyr/compare.php
Extract namespace from a PHP file
<?php
// Works in every situations
function by_token ($src) {
$class = false;
$namespace = false;
$tokens = token_get_all($src);
for ($i = 0, $count = count($tokens); $i < $count; $i++) {
$token = $tokens[$i];
@ludofleury
ludofleury / magic.sh
Last active August 2, 2022 15:53
"automate my splitting of iterm windows and opening of docker-compose logs of my applications. You can use osascript to do that which will execute AppleScript" by Anne-Sophie (https://github.com/tanguy-a)
#!/bin/bash
osascript<<EOF
tell application "iTerm"
activate
select first window
# Create new tab
tell current window
create tab with default profile
<?php
use DateTimeImmutable;
use LogicException;
Class Marker
{
public function __construct(private string $title, private DateTimeImmutable $activatedAt = null) {}
public function activate(): void
@ludofleury
ludofleury / MysqlContext.php
Last active November 8, 2021 14:41
A Behat Context with a hook to kill the Mysql connections
<?php
use Behat\Symfony2Extension\Context\KernelAwareInterface;
use Behat\Symfony2Extension\Context\KernelDictionary;
use Behat\MinkExtension\Context\MinkContext;
class MysqlContext extends MinkContext implements KernelAwareInterface
{
use KernelDictionary;
@ludofleury
ludofleury / calculator.js
Last active March 25, 2021 01:22
Attribute & Method vs Variable & Function
//////////// Object oriented programming
console.log('Calculator:');
let calculator = {
// attribute "result" of calculator object
result: 0,
// method "add()" of calculator object
add: function (number) {
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$PATH:/Users/ludo/Library/Python/3.7/bin
# Path to your oh-my-zsh installation.
export ZSH="/Users/ludo/.oh-my-zsh"
ZSH_THEME="powerlevel9k/powerlevel9k"
# CASE_SENSITIVE="true"
# HYPHEN_INSENSITIVE="true"
@ludofleury
ludofleury / A-result.txt
Created January 31, 2012 04:21
PHP get_class vs ReflectionObject vs ReflectionClass
This was a quick & dirty benchmark (for my own needs) to compare the method to get a class name in PHP
-ReflectionObject->getName();
-get_class();
-ReflectionClass->getName();
It was performed on my local machine : MacBookPro with PHP 5.3.6
You will find the result below and the code used for the 3 tests.
ReflectionObject
Memory : 750040
#!/bin/bash
# use newline as separator
IFS=$'\n'
for author in $(git log --all --format='%cN' | sort -u); do
echo $author;
git log --all --author="$author" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "++ %s\n-- %s\n= %s\n", add, subs, loc }' -
done
@ludofleury
ludofleury / docker-compose.yml
Created October 31, 2018 17:24
Docker Compose shared host based named volume with ${PWD} variant for mac
version: "3.0"
services:
composer:
image: composer/composer
working_dir: /var/app
volumes:
- project:/var/app
- ./var/composer:/composer
volumes: