Skip to content

Instantly share code, notes, and snippets.

View Swop's full-sized avatar
👨‍💻

Sylvain MAUDUIT Swop

👨‍💻
View GitHub Profile
@Swop
Swop / jail.local
Created July 21, 2013 17:53
Adds Nginx DOS detection to Fail2ban
# /etc/fail2ban/jail.local
# [...]
[nginx-dos]
# Based on apache-badbots but a simple IP check (any IP requesting more than
# 240 pages in 60 seconds, or 4p/s average, is suspicious)
# Block for two full days.
# @author Yannick Warnier
enabled = true
@Swop
Swop / AnnotatedDescription.php
Last active May 10, 2020 21:19
Annotation reader in Symfony
<?php
namespace Foo\Annotations;
/**
*@Annotation
*/
class AnnotatedDescription
{
public $value;
@Swop
Swop / push-to-new-repo.sh
Last active June 4, 2019 11:19
Push an entire local Git repository to a new remote repository
#!/bin/bash
# The command must be called inside the Git repository to send to the new repository
# Usage: push-to-new-repo.sh TARGET_REPO_URL
remote=origin;
target_repo=$1;
nb_branches=`git branch -r | grep $remote | grep -v master | grep -v HEAD | awk '{gsub(/[^\/]+\//,"",$1); print $1}' | wc -l | sed 's/ //g'`;
echo "${nb_branches} branch(es) to push";
@Swop
Swop / UrlEncodeType.php
Created August 2, 2014 11:33
UrlEncodeType (credits: Benjamin Marquant)
<?php
/**
* @author Benjamin Marquant
* @website http://www.bxnxg.com
* @example http://website.com/My Fân Page !/ > http://website.com/my-fan-page/ and become a simple url rewriting
*/
class UrlEncodeType {
private $url;
@Swop
Swop / gist:6a5f1999e1a04227e382
Created December 11, 2014 10:17
Git merge test command (to detect potential conflicts)
#!/bin/bash
git config --global alias.mergetest '!f(){ git merge --no-commit --no-ff "$1"; git merge --abort; echo "Merge aborted"; };f '
@Swop
Swop / gist:9588180
Created March 16, 2014 19:04
Composer with GitHub Two Factor Authentication
Composer doesn't work with GitHub Two Factor Authentication.
You have to generate a token (with "repo" scope at least) at https://github.com/settings/applications
Copy the token and keep it somewhere safe.
Run: composer config -g github-oauth.github.com paste-your-token-here
@Swop
Swop / Hooks.php
Last active July 15, 2016 06:16
Console app to check quality of a project (for a pre-commit hook) (source: http://carlosbuenosvinos.com/write-your-git-hooks-in-php-and-keep-them-under-git-control/)
<?php
namespace Swop\Composer\Script;
use Composer\Script\Event;
class Hooks
{
public static function checkHooks(Event $event)
{
@Swop
Swop / Dominos.py
Created March 14, 2016 19:56
Check Domino's pizza delivery status and push an OSX notification after each status change. Yummy
import json
import urllib2
import sys
import time
from Foundation import NSUserNotification
from Foundation import NSUserNotificationCenter
from Foundation import NSUserNotificationDefaultSoundName
orderId = sys.argv[1]
step = previousStep = None
@Swop
Swop / gist:8635526
Created January 26, 2014 16:47
FOSUserBundle YAML configuration (credits: http://2levelsabove.com/fosuserbundle-yaml-configuration/)
# app/config/config.yml
fos_user:
db_driver: ~ # Required
firewall_name: ~ # Required
user_class: ~ # Required
use_listener: true
use_username_form_type: true
model_manager_name: null # change it to the name of your entity/document manager
if you don't want to use the default one.
from_email:
brew install postgresql
initdb /usr/local/var/postgres -E utf8
gem install lunchy
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/9.3.1/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents
lunchy start postgres
lunchy stop postgres
# TIPS PostgreSQL
# initdb /usr/local/var/postgres -E utf8 # create a database cluster