Skip to content

Instantly share code, notes, and snippets.

View npotier's full-sized avatar
😀

Nicolas Potier npotier

😀
View GitHub Profile
@npotier
npotier / varnish.md
Created August 14, 2014 06:47
varnish

#Installation de varnish sur Debian Wheezy

  1. Vérifier que la version 3.* de varnish sera installée :
 apt-cache show varnish
  1. Installer varnish
apt-get update
@npotier
npotier / provision-sqlserver.ps1
Last active August 29, 2015 14:05
PowerShell Install SQL Server
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
choco install MsSqlServer2012ExpressAdv -force
sqlcmd -S VAGRANT-2012-R2 -E -Q "CREATE DATABASE {{YOUR_DATABASE_NAME}};"
sqlcmd -S VAGRANT-2012-R2 -E -Q "USE {{YOUR_DATABASE_NAME}};CREATE LOGIN {{YOUR_DATABASE_USER}} WITH PASSWORD = '{{YOUR_DATABASE_PASSWORD}}'"
sqlcmd -S VAGRANT-2012-R2 -E -Q "USE {{YOUR_DATABASE_NAME}};CREATE USE {{YOUR_DATABASE_USER}} FOR LOGIN {{YOUR_DATABASE_USER}};"
sqlcmd -S VAGRANT-2012-R2 -E -Q "USE {{YOUR_DATABASE_NAME}};GRANT ALTER To {{YOUR_DATABASE_NAME}};"
sqlcmd -S VAGRANT-2012-R2 -E -Q "USE {{YOUR_DATABASE_NAME}};GRANT CONTROL To {{YOUR_DATABASE_NAME}};"
sqlcmd -S VAGRANT-2012-R2 -E -Q "USE {{YOUR_DATABASE_NAME}};EXEC sp_addrolemember 'db_owner', '{{YOUR_DATABASE_USER}}'"
sqlcmd -S VAGRANT-2012-R2 -E -Q "USE {{YOUR_DATABASE_NAME}};EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode', REG_DWORD, 2"
#!/bin/bash
# include config
# config example below:
#
#
# Example deploy_config.sh
#
# dev_env() {
@npotier
npotier / frenchHTTPCodes.php
Created April 22, 2015 10:01
french HTTP Codes explaination
$frenchHTTPCodes = array (
"100" => "Attente de la suite de la requête",
"101" => "Acceptation du changement de protocole",
"102" => "WebDAV : Traitement en cours (évite que le client dépasse le temps d’attente limite).",
"118" => "Délai imparti à l'opération dépassé",
"200" => "Requête traitée avec succès",
"201" => "Requête traitée avec succès avec création d’un document",
"202" => "Requête traitée mais sans garantie de résultat",
"203" => "Information retournée mais générée par une source non certifiée",
"204" => "Requête traitée avec succès mais pas d’information à renvoyer",
@npotier
npotier / lamp.sh
Last active January 9, 2016 03:09
Debian Lamp Stack
#!/bin/sh
# Fichier "lamp.sh"
apt-get update
apt-get -y install apache2 php5 mysql-server git vim
a2enmod rewrite php5
service apache2 restart
apt-get -y install php-apc php5-gd php5-curl php5-mysql php5-xdebug php5-intl
apt-get -y install phpmyadmin
apt-get -y install curl
apt-get -y install iptables
@npotier
npotier / ProductAdmin.php
Last active July 15, 2017 02:34
Use the code below to add the "add buton" to a sonata model autocomplete form Raw
<?php
// src/ACSEO/AdminBundle/Admin/ProductAdmin.php
// ...
protected function configureFormFields(FormMapper $formMapper)
{
// ...
$formMapper
->add('codes', 'sonata_type_model_autocomplete', array(
@npotier
npotier / check_url.sh
Last active October 24, 2017 15:20
Check URL response code and notify it to slack
#!/bin/bash
# The URL you want to check
url="HTTP_MY_AWESOME_URL"
status_code=$(curl -o /dev/null --silent --head --write-out '%{http_code}\n' $url)
date=`date`
# The channel or user you want to notify
channel="MY_CHANNEL"
# The displayed bot username
@npotier
npotier / gitlab_stats.sh
Created December 10, 2014 22:05
Gitlab stats
# Dirty command line used to scan each gitlab repository and extract some stats
# in this case : foreach commit > 2014-01-01 get the number of commmits, number of line added, deleted grouped by users
rm /tmp/stats2014.csv; find /home/git/repositories -name .git -prune -o -name '*.git' -print | while read directory; do cd $directory; git log --after="2014-01-01" --format='%aN' |sort -u | while read name; do echo -en "Project\t$directory\t" >> /tmp/stats2014.csv; echo -en "Author\t$name\t" >> /tmp/stats2014.csv; git log --after="2014-01-01" --after="2014-01-01" --author="$name" --pretty=format:%ae | gawk -- '{ ++c; } END { printf "Number of commits\t%s\t",c; }' >> /tmp/stats2014.csv; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "Added lines\t%s\tRemoved lines\t%s\tTotal lines\t%s\n", add, subs, loc }' >> /tmp/stats2014.csv; done; done;
@npotier
npotier / gist:b6a04b9ed74eecceafd61da4ac972fb2
Created April 2, 2018 20:30 — forked from Nyholm/gist:317df136ded2087649d0c9c464285cb1
Show who contributed to your vendors folder
# Install git fame
gem install git_fame
# Install all vendors with source
rm -rf vendor/*
composer update --prefer-source
# Do the calculations. This might take 30 minutes to complete.
rm output.txt
find ./vendor -type d -depth 2 ! -path "./vendor/composer" -exec echo {} \; -exec git fame --sort=loc --hide-progressbar --repository={} \; >> output.txt
@npotier
npotier / iptables.sh
Last active September 30, 2018 06:16
Basic IP Tables opening port for a Webserver
#!/bin/sh
### BEGIN INIT INFO
# Provides: firewall
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Démarre les règles iptables
# Description: Charge la configuration du pare-feu iptables
### END INIT INFO