Skip to content

Instantly share code, notes, and snippets.

View fracasula's full-sized avatar
🏋️‍♂️
One pomodoro after another

Francesco Casula fracasula

🏋️‍♂️
One pomodoro after another
View GitHub Profile
@fracasula
fracasula / mysql_delete_join.sql
Created February 25, 2014 12:09
Delete with Join in MySQL
DELETE `t` FROM `category_translation` AS `t`
LEFT JOIN `category` AS `c`
ON `c`.`id` = `t`.`id`
WHERE `c`.`id` IS NULL;
@fracasula
fracasula / example_ssl.conf
Last active August 29, 2015 13:57
SSL LAMP local server for test purposes (http://dannytsang.co.uk/create-and-enable-ssl-on-ubuntu-lamp-server/ for further information)
<VirtualHost *:443>
SSLEngine On
# sudo apt-get install ssl-cert
# sudo a2enmod ssl
# Generate the crt file with: sudo make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/www.example.com.crt
SSLCertificateFile /etc/apache2/ssl/www.example.com.crt
ServerName www.example.com
@fracasula
fracasula / location_match.conf
Created April 17, 2014 14:47
Protecting a specific location with Apache allowing only a range of IPs (and/or a domain) [whitelist IP]
<LocationMatch ^/(folder1|folder2|folder3\/child)/(.*)[\/]{0,1}feed>
Order deny,allow
Deny from all
Allow from mydomain.com 80.80.80.10/15
</LocationMatch>
@fracasula
fracasula / example_ssl.conf
Created April 22, 2014 10:01
Force Wordpress to HTTP on non-admin URLs
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/www.example.com.crt
ServerName example.com
ServerAlias www.example.com
<Directory "/var/www/example/">
AllowOverride All
Order allow,deny
@fracasula
fracasula / xdebug.ini
Created May 28, 2014 10:38
Xdebug sample configuration
zend_extension=xdebug.so
xdebug.default_enable = On
xdebug.profiler_enable = On
xdebug.profiler_output_dir = "/tmp/xdebug"
xdebug.profiler_append = On
xdebug.profiler_enable_trigger = On
xdebug.profiler_output_name = "%u_%p.profile.xlog"
@fracasula
fracasula / mysql_update_join.sql
Created March 12, 2015 14:48
Update with Join in MySQL
UPDATE TABLEA a
JOIN TABLEB b ON a.join_colA = b.join_colB
SET a.columnToUpdate = [something]
@fracasula
fracasula / ajaxRouter.js
Last active December 20, 2015 18:39
Ajax Router
;(function (w, $, undefined) {
"use strict";
w.ajaxRouter = function (event, url) {
if (event.ctrlKey)
return true; // CTRL+CLICK opens link in new tab -> no ajax, default behaviour
else {
var url = url || $(this).attr('href'),
matches = /^http[s]?\:\/\/([^/]+)/.exec(url);
@fracasula
fracasula / AcmeBundlenameExtension.php
Last active December 22, 2015 15:28
Symfony2 Bundle basic parameters configuration tree (config.yml)
<?php
namespace Acme\Bundle\Bundlename\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
/**
@fracasula
fracasula / site
Created September 12, 2013 09:16
Simple Apache2 Virtual Host
# /etc/apache2/sites-enabled/site
<VirtualHost *:80>
RewriteEngine On
RewriteOptions Inherit
ServerAdmin admin@example.com
ServerName example.com
@fracasula
fracasula / mysqldump.sh
Last active August 24, 2016 13:49
MySQL dump cli command (mysqldump)
# Example 1
mysqldump --databases dbname -u root -p > dbname.sql
# Example 2
mysqldump --databases dbname -u root -pPASSWORD | gzip -c > dbname.sql.gz
# Example 3 (just the schema with no data and disabling foreign keys)
mysqldump -u root -pPASSWORD --no-data --single-transaction --quick --lock-tables=false -y --disable-keys dbname | gzip -c > dbname_schema.sql.gz
# Example 4 (loading the DB back into MySQL)