Skip to content

Instantly share code, notes, and snippets.

View programaker's full-sized avatar

Marcelo da Silva Gomes programaker

View GitHub Profile
@programaker
programaker / oracle-list-all-constraints.sql
Created December 14, 2009 13:30
list all constraints of a table in oracle
select * from all_constraints where table_name = '<table_name>'
-- where constraint_type = 'P' -> primary key
-- = 'R' -> foreign keys
-- = 'C' -> constraints like not null
@programaker
programaker / oracle-list-all-sequences.sql
Created December 14, 2009 13:31
list all sequences in oracle
select * from all_sequences;
@programaker
programaker / oracle-list-table-pk-fields.sql
Created December 14, 2009 13:34
How to list the primary key fields of a table in Oracle
select
cols.table_name,
cols.column_name,
cols.position,
cons.status,
cons.owner
from
all_constraints cons inner join all_cons_columns cols on
cons.constraint_name = cols.constraint_name and
cons.owner = cols.owner
@programaker
programaker / open-url-in-safari.m
Created December 14, 2009 13:39
how to open an URL in Safari in Objective-C
NSURL* url = [[NSURL alloc] initWithString: @"http://www.cnn.com"];
[[UIApplication sharedApplication] openURL: url];
@programaker
programaker / change-swappiness.sh
Created December 14, 2009 13:44
change linux swap intensity
# swappiness controls the intensity of swap use, varying between 0 and 100
# this command modifies the swappiness in runtime, but the change won't persist after shutdown
sudo sysctl -w vm.swappiness=0
@programaker
programaker / gist:310446
Created February 21, 2010 18:21
How to change default folder locations in Ubuntu
# to change the default folder locations in ubuntu,
# just edit this file, following the instruction inside it
vi $HOME/.config/user-dirs.dirs
@programaker
programaker / gist:325577
Created March 8, 2010 20:14
How to get the stack trace of an exception as String
public String getStackTrace(Exception e) {
Writer stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
e.printStackTrace(printWriter);
return stringWriter.toString();
}
@programaker
programaker / gist:338924
Created March 20, 2010 21:35
Fixing the "ugly root theme" problem in Ubuntu
sudo ln -s /home/your_user/.themes /root/.themes
sudo ln -s /home/your_user/.icons /root/.icons
sudo ln -s /home/your_user/.fonts /root/.fonts
@programaker
programaker / gist:338961
Created March 20, 2010 22:42
How to make Adobe Air applications use the system default browser
#1 - Open the file "/opt/Adobe AIR/Versions/1.0/libCore.so".
sudo vi /opt/Adobe AIR/Versions/1.0/libCore.so
#2 - In vi, go to the line 16104 with the command ":16104".
#3 - Find the word "firefox" (if it was your previous default browser) and replace it with "browser".
# The word "browser" is not a random choice! It was chosen because it has the same size of the "firefox" word.
# The size matters because we are editing a binary file and words with different sizes will cause segmentation fault # errors!
#4 - Save the file and exit with the command ":wq".
@programaker
programaker / gist:358949
Created April 7, 2010 14:34
How to get the source code of a stored procedure in Oracle
select
text
from
user_source
where
name = '<stored-procedure-name>'