Skip to content

Instantly share code, notes, and snippets.

View alch's full-sized avatar

Aldo Chiecchia alch

  • Antai Venture Builder S.L.
  • Barcelona
View GitHub Profile
/**
* List charges form stripe.
* @link https://stripe.com/docs/api/php#list_charges
*/
\Stripe::setApiKey('stripe.private.key');
/**
* @var \Stripe_List $a
*/
$a = \Stripe_Charge::all();
@alch
alch / sed1line
Created July 31, 2014 08:18
One line sed common tasks
-------------------------------------------------------------------------
USEFUL ONE-LINE SCRIPTS FOR SED (Unix stream editor) Dec. 29, 2005
Compiled by Eric Pement - pemente[at]northpark[dot]edu version 5.5
Latest version of this file (in English) is usually at:
http://sed.sourceforge.net/sed1line.txt
http://www.pement.org/sed/sed1line.txt
This file will also available in other languages:
Chinese - http://sed.sourceforge.net/sed1line_zh-CN.html
@alch
alch / su.sh
Created July 21, 2014 07:43
Sudo preserving environment
#!/bin/bash
sudo su -p -
@alch
alch / clone-and-subtree-split.sh
Created April 4, 2014 10:41
Clone and subtree-split for Elcodi Bundles
#!/bin/bash
for i in $(ls -1 symfony.Elcodi/src/Elcodi/); do
rm -rf elcodi.$i
git clone git@github.com:elcodi/elcodi.git elcodi.$i;
cd elcodi.$i;
git filter-branch --prune-empty --subdirectory-filter src/Elcodi/$i;
git remote rm origin
git remote add origin git@github.com:elcodi/$i.git
git push origin master
git push --tags

From http://stackoverflow.com/questions/9018584/error-code-1005-cant-create-table-errno-150

Error Code: 1005. Wrong primary key reference in your code

Usually it's due to a reference FK field not exist. might be you have typo mistake,or check case it should be same, or there's a field-type mismatch. FK-linked fields must match definitions exactly.

Known causes may be:

  • The two key fields type and/or size doesn’t match exactly. For example, if one is INT(10) the key field needs to be INT(10) as well and not INT(11) or TINYINT. You may want to confirm the field size using SHOW CREATE TABLE because Query Browser will sometimes visually show just INTEGER for both INT(10) and INT(11). You should also check that one is not SIGNED and the other is UNSIGNED. They both need to be exactly the same.
  • One of the key field that you are trying to reference does not have an index and/or is not a primary key. If one of the fields in the relationship is not a primary key, you must create an index for that field.
@alch
alch / default.vcl
Created January 22, 2014 11:20
Varnish simple configuration for symfony 2
backend default {
.host = "127.0.0.1";
.port = "8081";
}
sub vcl_recv {
if (req.url ~ "\.(png|gif|jpg|swf|css|js)$") {
unset req.http.cookie;
}
}
@alch
alch / .htaccess
Last active March 19, 2024 23:38
Symfony full .htaccess file
# For a symfony application to work properly, you MUST store this .htaccess in
# the same directory as your front controller, index.php, in a standard symfony
# web application is under the "public" project subdirectory.
# Use the front controller as index file.
DirectoryIndex index.php
# Uncomment the following line if you install assets as symlinks or if you
# experience problems related to symlinks when compiling LESS/Sass/CoffeScript.
# Options +FollowSymlinks
@alch
alch / .htaccess
Last active December 29, 2015 08:49
Symfony assets cache bust
<IfModule mod_rewrite.c>
RewriteEngine On
# cache-bust assets url rewrite
# URL substitution example:
# http://example.com/v1/js/3785f80.js -> http://example.com/js/3785f80.js
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^v\d+\/(.+)$ $1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
@alch
alch / jquery-deferred.js
Last active December 26, 2015 12:39
JQuery Promise example
/*
<!doctype html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</head>
<body>
<script>
*/