Skip to content

Instantly share code, notes, and snippets.

@stajnert
stajnert / size.sql
Created March 18, 2013 09:46
db size
SELECT table_schema,
CONCAT(ROUND(SUM(data_length/(1024*1024)),2),'M') data,
CONCAT(ROUND(SUM(index_length/(1024*1024)),2),'M') idx,
CONCAT(ROUND((SUM(data_length+index_length)/(1024*1024)),2),'M') total_size
FROM information_schema.tables
GROUP BY table_schema
ORDER BY data_length+index_length DESC;
SHOW TABLE STATUS FROM etracker;
@stajnert
stajnert / .htaccess
Created April 2, 2013 07:15
Enable gzip compression on the fly
#Gzip
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
</ifmodule>
#End Gzip
@stajnert
stajnert / getFirst.php
Created April 2, 2013 08:33
Get records first by slug = london, then rest
<?php
$this->locations = Doctrine_Core::getTable('location')
->createQuery('l')
->orderBy("CASE url_slug WHEN :slug THEN '' ELSE name END")
->execute(array('slug' => 'london'));
>?
@stajnert
stajnert / changeConnection.php
Last active December 15, 2015 23:59
Chane connection with db - symfony 1.4
<?php
// connect with other database
// $instance - object with new database data
new sfDoctrineDatabase(array(
'name' => 'instance',
'dsn' => 'mysql:host=' . $instance->getInstanceDbHost() . ';dbname=' . $instance->getInstanceDbName(),
'username' => $instance->getInstanceDbUser(),
'password' => $instance->getInstanceDbPassword(),
));
@stajnert
stajnert / json_plus
Created May 20, 2013 13:33
how to send data with + in javascript
<script type="text/javascript">
$.ajax({
type: 'POST',
cache: false,
data: 'params=' + escape(JSON.stringify(structure)).replace(new RegExp("\\+", "g" ),"%2B"),
url: '/adm.php/sendregexp',
success: function(response) {
var result = jQuery.parseJSON(response);
if (result.code == 300) {
@stajnert
stajnert / updateForm.php
Created July 12, 2013 09:28
Change values before bind
<?php
$values = $request->getParameter($form->getName());
$values['yourdate'] = NEW MODIFIED DATE VALUE;
$form->bind($values, $request->getFiles($form->getName()));
$o = $form->getObject();
$o->save();
?>