This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Format CamelCase to text | |
## fooBar => Foo bar | |
## fooBAR => Foo bar | |
## References: | |
## https://velocity.apache.org/engine/devel/user-guide.html | |
## https://www.jetbrains.com/help/phpstorm/2016.1/template-languages-velocity-and-freemarker.html | |
#set ($formattedName = $NAME) | |
#set ($formattedName = $formattedName.replaceAll('([A-Z]+)', ' $1')) | |
#set ($formattedName = $formattedName.toLowerCase()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
ssh_address="example@domain.com"; | |
dump_filename="dump.sql"; | |
site_remote_path="/home/example"; | |
site_remote_domain="staging.example.com" | |
local_db_host=$(php -r 'include("config/settings.inc.php");echo _DB_SERVER_;'); | |
local_db_name=$(php -r 'include("config/settings.inc.php");echo _DB_NAME_;'); | |
local_db_user=$(php -r 'include("config/settings.inc.php");echo _DB_USER_;'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" | |
PHP_CS_FIXER="bin/php-cs-fixer" | |
if [ -x $PHP_CS_FIXER ]; then | |
git status --porcelain | grep -e '^ [AM] \(src\/.*\)\.php' | cut -c 4- | while read line; do | |
$PHP_CS_FIXER fix "$line" --level=symfony --verbose; | |
git add "$line"; | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# parameters | |
url="https://example.com" | |
client_id="foo" | |
client_secret="bar" | |
# request access token | |
oauth_path="/oauth2/access_token" | |
access_token=$(curl -s -H "Accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -H "Authorization: Basic $(echo "$client_id:$client_secret" | tr -d "\n" | base64)" -X POST -d "grant_type=client_credentials" "$url$oauth_path" | sed -e 's/^.*"access_token":"\([^"]*\)".*$/\1/') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @param string $path prepended with a slash | |
* @param string $data to send | |
* @param string $method default POST | |
* @param string $header to send | |
* | |
* @return string response | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
safeRun() { | |
typeset cmnd="$*" | |
typeset ret_code | |
echo cmnd=$cmnd | |
eval $cmnd | |
ret_code=$? | |
if [ $ret_code != 0 ]; then | |
printf "Error : [%d] when executing command: '$cmnd'" $ret_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Converts FormData to object. | |
* | |
* @param {FormData} data | |
* To convert. | |
* @return {string} | |
* FormData converted to object. | |
*/ | |
function formDataToObject(data) { | |
let value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################################################################## | |
# This script is meant to be run once a day. | |
# | |
# Backup files name format must be: database-%Y-%m-%dT%H:%M.bz2 | |
# | |
# It deletes backup files that does not match one of these conditions: | |
# - backup every 15 minutes during one week | |
# - backup every day during 3 months |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global window, Image */ | |
/** | |
* Class AppleTouchStartupImage. | |
* | |
* Insert a script in the html head at the 1st position containing: | |
* const startupImage = new AppleTouchStartupImage(); | |
* startupImage.install(); | |
* | |
* @prop {string} image - source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$root = './src'; | |
$find = 'foo'; | |
$replace = 'bar'; | |
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($root)); | |
$count = 0; | |
foreach ($iterator as $file) { | |
if ($file->isDir() || 'php' !== $file->getExtension() || '.' === $file->getFilename()[0]) { | |
continue; |
OlderNewer