Skip to content

Instantly share code, notes, and snippets.

View andreia's full-sized avatar
❤️
coding

Andréia Bohner andreia

❤️
coding
View GitHub Profile
@andreia
andreia / gist:2400504
Created April 16, 2012 18:23
Only digits
<?php
$str = '13++56-461.79/27--14-abc';
$filter = filter_var($str,FILTER_SANITIZE_NUMBER_INT);
$onlyDigitsFilterVar = str_replace(array('+', '-'), '', $filter);
$onlyDigitsRegexp1 = preg_replace('/[^\d]/', '', $str);
$onlyDigitsRegexp2 = preg_replace('/[^[:digit:]]/', '', $str); // http://www.php.net/manual/en/regexp.reference.character-classes.php
var_dump($filter); // string(19) "13++56-4617927--14-"
@andreia
andreia / gist:2345465
Created April 9, 2012 18:53
Show all tables that have a specific column name (Oracle)
SELECT TABLE_NAME FROM USER_TAB_COLUMNS
WHERE COLUMN_NAME = 'ID'
@andreia
andreia / gist:1923576
Created February 27, 2012 13:00
ORACLE: Empty / NULL
decode(trim(col),NULL,NULL,col) is NULL
-- http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements005.htm
-- Do not use null to represent a value of zero, because they are not equivalent.
-- Note: Oracle Database currently treats a character value with a length of zero as null.
-- However, this may not continue to be true in future releases, and Oracle recommends that
-- you do not treat empty strings the same as nulls.
@andreia
andreia / gist:1172483
Created August 26, 2011 01:33
Doctrine: Avoiding circular references using the free() function
<?php
$qs = Doctrine_Query::create()
->from('MyTable1 m')
->leftJoin('m.MyTable2 p');
$res = $qs->execute();
$qs->free();
@andreia
andreia / gist:1172465
Created August 26, 2011 01:21
sf14: Release the session lock to avoid ajax queue
<?php
$this->getUser()->shutdown();
@andreia
andreia / gist:1143418
Created August 13, 2011 02:57
Using YQL to find WOEID
select woeid from geo.places where text="brasília, df, brazil"
@andreia
andreia / gist:1028356
Created June 15, 2011 23:13
Tweeting from shell
$ curl -u user:pass -d status='Hello from shell' http://twitter.com/statuses/update.xml
@andreia
andreia / gist:1028347
Created June 15, 2011 23:06
Schedule a command to execute one-time
$ echo cmd | at 5am next year
@andreia
andreia / gist:998229
Created May 29, 2011 23:13
filter_var
<?php
// http://uk.php.net/manual/en/filter.filters.php
// validate
// http://uk.php.net/manual/en/filter.filters.validate.php
$var = filter_var($email, FILTER_VALIDATE_EMAIL);
$var = filter_var($code, FILTER_VALIDATE_INT);
// sanitize
// http://uk.php.net/manual/en/filter.filters.sanitize.php
$ symfony plugin:install -r 0.9.3 sfFormI18nNumberPlugin