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 / objective-c-string-contains.m
Created December 7, 2009 16:50
How to discover if a string contains another string in Objective C
NSString* someString = @"FooBar";
BOOL someStringContainsFoo = ([someString rangeOfString: @"Foo"].location != NSNotFound);
@programaker
programaker / show-ubuntu-version.sh
Created December 8, 2009 23:37
what ubuntu version am i using?
cat /etc/lsb-release
@programaker
programaker / oracle-column-metadata.sql
Created December 14, 2009 13:21
how to get column metadata in oracle
select * from all_tab_columns where table_name = 'TABLE_NAME';
@programaker
programaker / oracle-get-bigger-strings-in-a-field.sql
Created December 14, 2009 13:24
get the bigger strings in a field in oracle
select
varchar_field, length(varchar_field)
from
table_name
where
length(varchar_field) in (
select max(length(varchar_field)) from table_name
)
@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