Skip to content

Instantly share code, notes, and snippets.

View Pierozi's full-sized avatar

Pierre Tomasina Pierozi

View GitHub Profile
@Pierozi
Pierozi / Hoa-UDP-Socket
Created February 15, 2015 16:54
Create UDP Server Socket with Hoa library
<?php
include(dirname(__DIR__) . '/vendor/autoload.php');
$server = new Hoa\Socket\Server('udp://0.0.0.0:3655');
$server->connectAndWait();
$server->considerRemoteAddress(true);
do {
$line = bin2hex($server->read(32));
@Pierozi
Pierozi / psysh.php
Last active August 29, 2015 14:22
Atoum TU with PsySh eval
<?php
namespace
{
class Foo
{
public function get()
{
$string = 'foobarbaz';
@Pierozi
Pierozi / collection_advanced.json
Created June 29, 2015 08:52
JSON API Output with relationship included
{
"links": {
"self": "/examples/collection_advanced.php"
},
"data": [
{
"type": "user",
"id": "USER-A",
"attributes": {
"firstname": "John",
@Pierozi
Pierozi / isso.sh
Created July 25, 2015 17:55
luncher script for Isso
#!/bin/sh
### BEGIN INIT INFO
# Provides: isso
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: lightweight Disqus alternative
### END INIT INFO
@Pierozi
Pierozi / dirname-recursive.php
Created January 8, 2016 11:07
dirname-recursive
<?php
$dir = __DIR__;
do {
echo $dir, "\n";
$dirParent = dirname($dir);
@Pierozi
Pierozi / docker-compose.yml
Created January 11, 2016 17:23
docker-compose
app:
image: nginx
ports:
- "8084:443"
volumes:
- .:/app
- ./config/nginx.conf:/etc/nginx/nginx.conf
links:
- php
<?php
/**
* Like class is single, specify DIRECTIVE seems not be mandatory
*/
class Single extends ObjectivePHP\Config\SingleValueDirective {}
$config->import(new Single('x'))
->import(new Single('y'));
$config->get(Single::class) == "y";
@Pierozi
Pierozi / zafrira.php
Last active March 24, 2016 08:45
Zafrira_Storepickup | Magento workarround licence key because Zafrira no longer exist !
<?php class Zafrira_Storepickup_Helper_Data extends Mage_Core_Helper_Abstract
{
public function isFreeMethod($method, $storeId = null)
{
$arr = explode('_', $method, 2);
if (!isset($arr[1])) {
return false;
}
$freeMethod = Mage::getStoreConfig('carriers/' . $arr[0] . '/free_method', $storeId);
@Pierozi
Pierozi / wifi.sh
Created May 1, 2016 14:15
Wifi Strength
#!/usr/bin/env bash
for (( ; ; ))
do
iwconfig wlan0 | grep -i --color quality
ping free.fr -c 4 | tail -1 | awk '{print $4}' | cut -d '/' -f 2
ping fritz.box -c 4 | tail -1 | awk '{print $4}' | cut -d '/' -f 2
sleep 1
done
@Pierozi
Pierozi / myWifiPassword.sh
Created September 12, 2016 10:35
Show the current password of wifi ssid connected | under Ubuntu / Debian based system
#!/bin/sh
myWifiPassword() {
SSID=`iwgetid -r`
FILE=/etc/NetworkManager/system-connections/$SSID
if [ ! -f "$FILE" ];
then
FILE="/etc/NetworkManager/system-connections/Auto $SSID"
fi