Skip to content

Instantly share code, notes, and snippets.

@gsouf
gsouf / AdaptiveLink.jsx
Last active March 7, 2025 07:50
A React component for shopify's remix embedded app that will let opening links in a new tab
@gsouf
gsouf / check-all-repos.bash
Created October 1, 2024 01:29
list all uncommitted and unpushed changed in all repos of a given directory
#!/bin/bash
check_repo_status() {
local dir="$1"
# Check if it's a git repository
if ! git -C "$dir" rev-parse --is-inside-work-tree > /dev/null 2>&1; then
return
fi
@gsouf
gsouf / createkey.php
Last active July 10, 2017 13:24
phpcache-redis
<?php
include __DIR__ . '/vendor/autoload.php';
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$pool = new \Cache\Adapter\Redis\RedisCachePool($redis);
@gsouf
gsouf / gist:8634874aca7cf3cbd321595dc6408239
Created June 26, 2017 07:44
Aggregate apache logfile by useragent
awk -F\" '{arr[$6]++}END{for(a in arr) print arr[a], a}' access.log | sort -n
@gsouf
gsouf / mailhog.conf
Last active September 4, 2018 19:46
Mailhog upstart script to beplaced in /etc/init/mailhog.conf
description "mailhog"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec start-stop-daemon --start --make-pidfile --pidfile /var/run/mailhog.pid --exec /usr/local/bin/mailhog >> /var/log/mailhog.log 2>&1
@gsouf
gsouf / generate-codes.php
Created June 8, 2015 09:33
generate random alphanum codes
<?php
$codes = array();
function generateCode(){
global $codes;
$chars = "azertyupqsdfghjklmwxcvbn23456789";
$charsCount = strlen($chars) - 1;
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@gsouf
gsouf / docker.md
Created July 11, 2014 08:15
Docker reminder

Working with docker containers

  • Daemonizing a container

$ docker run -d

  • Leaving the container

CTRL+P -> q

<?php
class EmailTestCase extends PHPUnit_Framework_TestCase {
/**
* @var \Guzzle\Http\Client
*/
private $mailcatcher;
public function setUp()
{
@gsouf
gsouf / convert-charset.sh
Created February 14, 2014 13:38
Recursively convert encoding of all files in a project
encodeTo="UTF-8"
# CHANGE THE PATTERN IF NEEDED
for filename in ` find . -type f -name "*.php"`
do
echo $filename
enc=`file -bi $filename | awk -F"charset=" '{print $2}'`
iconv -f $enc -t $encodeTo $filename -o $filename
done