Skip to content

Instantly share code, notes, and snippets.

View tentacode's full-sized avatar
🐙
tentacoding

Gabriel Pillet tentacode

🐙
tentacoding
View GitHub Profile
@tentacode
tentacode / namespace-fixer.php
Created July 5, 2022 14:44
It fixes php namespaces (only namespaces, not use statements)
<?php
function usage_error(): void
{
echo 'Usage: php namespace-fixer.php <path> <prefix>' . PHP_EOL;
echo 'Example: php namespace-fixer.php src App' . PHP_EOL;
exit(1);
}
$globalPath = $argv[1] ?? usage_error();

Keybase proof

I hereby claim:

  • I am tentacode on github.
  • I am tentacode (https://keybase.io/tentacode) on keybase.
  • I have a public key ASDPX7JdgYCMNSKpFne_vztynCaXnzSvexju_8S18R-tYwo

To claim this, I am signing this object:

<?php
class Something
{
public function __construct()
{
print "J'ai été instanciée.".PHP_EOL;
}
public function __destruct()
@tentacode
tentacode / resizeWindows.scpt
Created March 1, 2017 12:46
AppleScript to reposition every app (that are not Finder or iTerm2) of one specific screen to center position and specific dimension
tell application "System Events"
repeat with p in (processes where background only is false)
tell p
if name is not in {"Finder", "iTerm2"} then
repeat with x from 1 to (count windows)
set winPos to position of window x
set xPos to item 1 of winPos
if xPos > 0 then
set position of windows to {100, 100}
set size of windows to {2340, 1240}
@tentacode
tentacode / druid_setup.sh
Created December 9, 2016 11:06
Druid & Vagrant configuration
cd /opt
# Java
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get -y -q update
DEBIAN_FRONTEND=noninteractive apt-get install -y -q oracle-java8-installer
@tentacode
tentacode / DebugContext.php
Last active May 2, 2016 08:22
Doing something with the exception message after a failing behat scenario using @afterstep.
<?php
namespace Context;
use Behat\Behat\Hook\Scope\AfterStepScope;
use Behat\Testwork\Tester\Result\ExceptionResult;
class DebugContext extends BaseContext
{
/**
@tentacode
tentacode / vg.sh
Created April 28, 2016 12:37
Script to execute a command directly in vagrant via `vg bin/somecommand --arg="some argument"`
#!/usr/bin/env php
<?php
$cmd = '';
for ($i = 1; $i < sizeof($argv); $i++) {
$arg = $argv[$i];
if (preg_match('/^(--[^\- =]+=)(.+)$/', $arg, $matches)) {
$arg = sprintf('%s\"%s\"', $matches[1], $matches[2]);
}
@tentacode
tentacode / loop.php
Last active August 29, 2015 14:19
Quick & dirty loop with pcntl_fork
<?php
// every thing before will be used in every child process
while(true) {
$pid = pcntl_fork();
if ($pid === -1) {
die('Could not fork process');
} elseif ($pid) {
@tentacode
tentacode / ScreenshotContext.php
Created February 6, 2015 13:33
After a Behat javascript scenario fails, taking a screenshot then sending it to wsend as an anonymous user. (could be improved, juste a POC really)
<?php
namespace Context;
use Behat\MinkExtension\Context\RawMinkContext;
use Behat\Testwork\Tester\Result\TestResult;
use Behat\Mink\Driver\Selenium2Driver;
class ScreenshotContext extends RawMinkContext
{
@tentacode
tentacode / 0_reuse_code.js
Last active August 29, 2015 14:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console