Skip to content

Instantly share code, notes, and snippets.

@fabriciocolombo
fabriciocolombo / gist:2142817
Created March 21, 2012 00:07
Kill Oracle sessions
/* List all session, except background processes*/
SELECT s.username,
     s.osuser,
     s.sid,
     s.serial#,
     p.spid,
     s.status,
     s.machine,
     s.program,
     TO_CHAR(s.logon_Time,'DD-MON-YYYY HH24:MI:SS') AS logon_time
@fabriciocolombo
fabriciocolombo / Kill PostgreSQL sessions
Created March 21, 2012 00:10
Kill PostgreSQL sessions
/* List active sessions */
select datname,
       procpid,
       usename,
       application_name,
       client_addr,
       client_hostname,
       backend_start
  from pg_stat_activity;
@fabriciocolombo
fabriciocolombo / JSF redirect url
Created March 29, 2012 20:49
JSF redirect url
public void redirect(String path) throws Exception {
FacesContext ctx = FacesContext.getCurrentInstance();
ExternalContext extContext = ctx.getExternalContext();
String url = extContext.encodeActionURL(ctx.getApplication().getViewHandler().getActionURL(ctx, path));
extContext.redirect(url);
}
@fabriciocolombo
fabriciocolombo / gist:2473244
Created April 23, 2012 19:27
Contributing on github
Contributing
1. Fork it
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Added some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create new Pull Request
@fabriciocolombo
fabriciocolombo / PostgreSQL read-only user
Created April 24, 2012 20:57
PostgreSQL read-only user
GRANT CONNECT ON DATABASE $dbName TO $user;
GRANT USAGE ON SCHEMA $schema TO $user;
GRANT SELECT ON ALL TABLES IN SCHEMA $schema TO $user;
Default privileges
ALTER DEFAULT PRIVILEGES IN SCHEMA $schema
GRANT SELECT ON TABLES TO $user;
see more at http://www.postgresql.org/docs/9.0/static/sql-alterdefaultprivileges.html
@fabriciocolombo
fabriciocolombo / Delphi Version Compiler Directives
Last active May 9, 2023 12:53
Delphi Version Compiler Directives
{$IFDEF VER80} ShowMessage('Delphi 1');{$ENDIF}
{$IFDEF VER90} ShowMessage('Delphi 2');{$ENDIF}
{$IFDEF VER100} ShowMessage('Delphi 3');{$ENDIF}
{$IFDEF VER120} ShowMessage('Delphi 4');{$ENDIF}
{$IFDEF VER130} ShowMessage('Delphi 5');{$ENDIF}
{$IFDEF VER140} ShowMessage('Delphi 6');{$ENDIF}
{$IFDEF VER150} ShowMessage('Delphi 7');{$ENDIF}
{$IFDEF VER160} ShowMessage('Delphi 8');{$ENDIF}
{$IFDEF VER170} ShowMessage('Delphi 2005');{$ENDIF}
{$IFDEF VER180} ShowMessage('Delphi 2006');{$ENDIF}
@fabriciocolombo
fabriciocolombo / gist:2495415
Created April 26, 2012 03:12
Bubble Sort Delphi
procedure BubbleSort(var Vetor: Array of Integer);
var
i, temp: Integer;
changed: Boolean;
begin
changed := True;
while changed do
begin
changed := False;
@fabriciocolombo
fabriciocolombo / Delphi Compiler Messages
Created June 15, 2012 01:35
Delphi Compiler Messages
{$Message Hint 'Feed the cats'} //emits a hint
{$MessaGe Warn 'Looks like rain.'} //emits a warning
{$Message Error 'Not implemented'} //emits an error, continues compiling
{$Message Fatal 'Bang. Yer dead.'} //emits an error, terminates compiler
@fabriciocolombo
fabriciocolombo / Agregação x Composição
Created June 29, 2012 16:23
Agregação x Composição
Agregação
Os objetos contidos podem existir sem serem parte do objeto que os contém. Exemplo: Carro -> Rodas. Você pode tirar as rodas do carro antes de destruí-lo e elas podem ser colocadas em outro carro.
Composição
Os objetos contidos não fazem sentido fora do contexto do objeto que os contém.
Exemplo: Pedido -> Itens. Se você destruir o pedido, os itens são destruidos junto, eles não tem sentido fora do pedido.
@fabriciocolombo
fabriciocolombo / gist:3375118
Created August 17, 2012 01:23
JDBC Connection URLs

JDBC Connection URLs for 22 Databases

Source

PostgresSQL JDBC connection URL

jdbc:postgresql:template1
org.postgresql.Driver

MySQL JDBC connection URL