Skip to content

Instantly share code, notes, and snippets.

<VirtualHost *>
ServerName versace.dev
DocumentRoot "/Users/teito/workspace/versace/web"
DirectoryIndex index.php
Alias /sf /Users/teito/workspace/versace/lib/vendor/symfony/data/web/sf/
<Directory "/Users/teito/workspace/versace/lib/vendor/symfony/data/web/sf">
AllowOverride All
#Allow from All
@matteocaberlotto
matteocaberlotto / .htaccess
Last active October 4, 2015 13:58
an .htaccess example
AuthType Basic
AuthName "Restricted area"
AuthUserFile /path/to/httpdocs/web/.htpasswd
Require valid-user
Options +FollowSymLinks +ExecCGI
# video types
AddType video/mp4 .mp4
@matteocaberlotto
matteocaberlotto / gist:5652919
Last active December 17, 2015 18:28
Symfony cache/log folders permissions setup
# chmod
chmod +a "_www allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
# setfacl
setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX app/cache app/logs
setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs
#!/bin/bash
T="$(date +%s)"
sleep 2
T="$(($(date +%s)-T))"
echo "Time in seconds: ${T}"
@matteocaberlotto
matteocaberlotto / sf2gen.sh
Last active December 24, 2015 18:59
a bash script to automate symfony 2 project creation (composer, vhost and local dns)
#!/bin/bash
echo "Enter project name"
read PROJECT
DIRECTORY="/Users/teito/workspace/$PROJECT"
VHOST="/etc/apache2/extra/vhosts/$PROJECT.conf"
@matteocaberlotto
matteocaberlotto / deploy-symfony.sh
Last active April 20, 2022 14:51
Deploy symfony 2+ applications (multiple environment)
#!/bin/bash
# include config
# config example below:
#
#
# Example deploy_config.sh
#
# dev_env() {
@matteocaberlotto
matteocaberlotto / parallax.js
Last active June 25, 2016 04:29
Parallax js class
/**
* Simple parallax helper: calls all registered callbacks with current scroll top as parameter.
*/
var Parallax = (function () {
var windowWidth = null;
var windowHeight = null;
var y = null;
var y_norm = null;
/*
* jQuery getPathToElement plugin calculates one of the
* jquery unique path to reach an element of the DOM.
* It will use id, classname or tagname to identify
* the element itself and all the parents up to the body or
* the first element with an unique ID.
* For human readability it is prefered a tagname + id or
* tagname + class for the element. and id or class or tagname
* for parents.
* It simply returns the array of element selectors, up to you
@matteocaberlotto
matteocaberlotto / dump-db.sh
Last active May 2, 2017 10:44
Dumps a mysql database daily at midnight (with day of the week rotation)
#!/bin/bash
_dow="$(date +'%A'|cut -c 1-3)"
# dumps the database with day of the week appended
mysqldump mydb -u db-user -p'password' > "/home/ubuntu/databases/database-demo-${_dow,,}.sql"
# copies last db dumped
cp "/home/ubuntu/databases/database-demo-${_dow,,}.sql" /home/ubuntu/database-demo.sql
@matteocaberlotto
matteocaberlotto / gist:662d3b7ffa87b16570e2
Created September 14, 2014 20:48
Arduino sketch for unipolar stepper motors (to be used with uln2803)
int motorPins[] = {11, 10, 9, 8};
int count = 0;
int count2 = 0;
int delayTime = 500;
int val = 0;
int ledPin = 13;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);