Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
if [ "$1" == "" ]; then
echo "Usage: switch_php.sh <target_version>"
echo "Versions available: 5.6 7.0 7.1 7.2"
exit 1
fi
case "$1" in
"5.6")
@matteocaberlotto
matteocaberlotto / search.sh
Last active June 9, 2017 23:18
Search inside all your symfony projects
#!/bin/bash
if [ "$1" == "" ]; then
echo "Error: search key required."
echo "Use: search.sh <key> [<vendors>]"
echo "- key: any string to be found"
echo "- vendors: v"
echo "Example: ./search.sh httphelper v"
exit 1
fi
@matteocaberlotto
matteocaberlotto / pin.sh
Last active January 23, 2017 23:54
how to use raspberry pins via shell
#!/bin/bash
ERROR_MESSAGE="Error - usage: pin <number> <on|off>"
# some checks...
if [ "$1" == "" ]; then
echo "$ERROR_MESSAGE"
exit 1
fi
@matteocaberlotto
matteocaberlotto / Entity.php
Last active November 25, 2016 13:44
php trait for symfony 2.x file upload
<?php
use Symfony\Component\DependencyInjection\Container;
class Entity {
const IMAGES_FOLDER = '/uploads/images/contents';
protected $image; // mapped prop
#!/bin/bash
if [ -f "./bin/console" ]; then
php bin/console $1 $2 $3 $4 $5 $6 $7 $8 $9
else
if [ -f "./app/console" ]; then
php app/console $1 $2 $3 $4 $5 $6 $7 $8 $9
else
echo "Symfony console script not found."
exit 1
@matteocaberlotto
matteocaberlotto / user-alert.css
Created May 6, 2016 13:55
Handy in-page user messaging
#alert-container {
position: absolute;
right: 10px;
top: 10px;
z-index: 2000;
}
#alert-container .alert-message {
display: block;
<ul {% if level != 0 %} class="collapse" id="collapsable-{{ unique }}-{{ parent_index }}-{{ level }}"{% else %}{% endif %}>
{% if value is empty %}
<li>(empty)</li>
{% else %}
{% for index, val in value %}
{% if val is iterable %}
<li>
<a role="button" aria-expanded="false" aria-controls="collapsable-{{ unique }}-{{ parent_index ~ '-' ~ index }}-{{ level + 1 }}" data-toggle="collapse" href="#collapsable-{{ unique }}-{{ parent_index ~ '-' ~ index }}-{{ level + 1 }}">
[{{ index }}] =>
</a>
@matteocaberlotto
matteocaberlotto / uglify.sh
Created April 9, 2016 02:52
uglify css bash script
#!/bin/bash
echo "Uglify all css files in web/css folder"
cd web/css
pwd
for i in $( find . -type f -name '*\.css' ); do
echo "uglifycss $i"
uglifycss $i > temp.css
@matteocaberlotto
matteocaberlotto / create-database.sh
Created February 26, 2016 14:13
bash script to create user and database
#!/bin/bash
if [ "$1" == "" ]; then
echo "Error: database required: use create-database <db_name> <username> <password>"
exit 1
fi
if [ "$2" == "" ]; then
@matteocaberlotto
matteocaberlotto / sync_database.sh
Last active December 28, 2016 03:45
A simple bash script to sync a local database with a remote one (for development purpose)
#!/bin/bash
# configure script parameters here
USERNAME=username # username for ssh/scp connection
SERVER=123.123.123.123 # server ip for ssh/scp connection
PORT=22 # ssh port
ADDITIONAL_SSH_PARAMS="-i mykeys.pem" # additional ssh parameters to append to ssh and scp commands
REMOTE_DATABASE_NAME=exampledb # name of the database on the remote server (used with dump script and as sql remote filename)