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: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:1172465
Created August 26, 2011 01:21
sf14: Release the session lock to avoid ajax queue
<?php
$this->getUser()->shutdown();
@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: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: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: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 / timeout.php
Created July 13, 2012 01:21 — forked from avalanche123/timeout.php
timeouts in php
<?php
class TimeoutException extends RuntimeException {}
class Timeout
{
private $active;
public function set($seconds)
{
@andreia
andreia / gist:3139278
Created July 18, 2012 22:14
Zebra tables with structural pseudo-classes
tr:nth-child(2n+1){ background: ‪#fff‬ }
tr:nth-child(2n+0){ background: ‪#ffffec‬ }
@andreia
andreia / gist:3166741
Created July 23, 2012 22:46
Environment variables that must be set on Windows to connect to a remote Oracle DB(client)
NLS_LANG <lang> - character set, language and territory
TNS_ADMIN <path> - path to tnsnames.ora file
PATH <path> - add location of the Oracle client
@andreia
andreia / gist:3181898
Created July 26, 2012 12:57
DOCTRINE 1.2: Returns a single value
<?php
$q = Doctrine_Query::create()
->select('a.title as title')
->from('Article a')
->where('a.id = ?', $this->getId());
->fetchOne()->title;