Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View uilian's full-sized avatar
🏠
Working from home

Uilian Souza uilian

🏠
Working from home
View GitHub Profile
col "Tablespace" for a22
col "Used MB" for 99,999,999
col "Free MB" for 99,999,999
col "Total MB" for 99,999,999
select df.tablespace_name "Tablespace",
totalusedspace "Used MB",
(df.totalspace - tu.totalusedspace) "Free MB",
df.totalspace "Total MB",
round(100 * ( (df.totalspace - tu.totalusedspace)/ df.totalspace))
@uilian
uilian / tbsp-ddl-extract.sql
Created April 8, 2014 12:19
Oracle - extract DDL for all tablespaces
select dbms_metadata.get_ddl('TABLESPACE','TD_DBCLARIDATA_AUTO') from dual;
set head off echo off
select 'select dbms_metadata.get_ddl(''TABLESPACE'','''
|| tablespace_name || ''') from dual;' from dba_tablespaces;
@uilian
uilian / unzip.groovy
Last active August 29, 2015 14:01
Find and extract file in zip
import groovy.io.FileType
String targetFileName = 'someFileName'
String filter = 'someFilter'
def dir = new File(".")
dir.eachFileRecurse(FileType.FILES){ file ->
if (file.name.endsWith(filter)) {
def zipFile = new java.util.zip.ZipFile(file)
@uilian
uilian / long-queries-progress.sql
Last active August 29, 2015 14:01
Oracle - Long query progress
--
-- Mostra o andamento de operacoes longas no Oracle.
--
select target, sofar, totalwork, ROUND((sofar/totalwork)*100,5) pct_done
from v$session_longops
where (sid, serial#) in (select sid, serial#
from v$session
where logon_time > trunc(sysdate))
order by pct_done;
@uilian
uilian / scripts-uteis.sql
Created May 20, 2014 18:11
Oracle Spatial - Scripts
-- calcular centroide
select SDO_GEOM.SDO_CENTROID(tb.geom, '0.000005')
from tabela tb;
-- converter para outra projecao
EXECUTE SDO_CS.TRANSFORM_LAYER('TABLE_ORIGINAL','GEOM_COL','TABLE_DESTINATION',3857);
@uilian
uilian / call-command-line.groovy
Created May 21, 2014 17:13
Groovy - executar linha de comando
String commandLine= "java -version"
def sout = new StringBuffer(), serr = new StringBuffer()
def proc = commandLine.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForProcessOutput()
if (sout) log.info "$sout"
if (serr) log.info "$serr"
@uilian
uilian / unexpected-rude.sh
Created May 23, 2014 16:21
Linux doesn't loves you
echo '
..XXX. .XXX..
.XXXXY.TXXXX.
XXXXXYXTXXXXX
.VXXVYXTVXXX.
`.TYXTXYXTV .
` ,YVTXYYV .,
`...XXXXX`..,
.`...XXX...,.
..` V ,.' | tr '.\`, VYTX' ' ()__() '
@uilian
uilian / unlock-sheet.vb
Created July 1, 2014 13:49
Unlocking protected excel sheets
Sub PasswordBreaker()
'Breaks worksheet password protection.
Dim i As Integer, j As Integer, k As Integer
Dim l As Integer, m As Integer, n As Integer
Dim i1 As Integer, i2 As Integer, i3 As Integer
Dim i4 As Integer, i5 As Integer, i6 As Integer
On Error Resume Next
For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
@uilian
uilian / convert-load-geo-spatial-data-notes
Last active August 29, 2015 14:04
Notes on manipulating geo/gis data and load on a database
Carregar novas features no mapa.
Ferramentas: (plataforma OSGEO) QGIS, Udig, JOSM, Gimp/Inkscape, Open Street Maps.
Técnicas:
1) Inkscape + Gimp: criar um raster (DFX, TIF) da feature desejada (um rio, por exemplo), deixá-la o mais simples possível, sem ruído. Vetorizar esta imagem, e salvar como SVG. Georeferenciar a imagem vetorizada, e converter para shapefile.
Para georeferenciar pode-se utilizar o ogr2ogr, como no exemplo abaixo:
ogr2ogr -progress -f "ESRI Shapefile" SAIDA.SHP -a_srs EPSG:3785 -dsco ATTRIBUTES_SKIP=YES -order 1 -gcp 285.32538 226.59571 -5429612.461 -26028.318 [-gcp X_IMG Y_IMG X_MAP Y_MAP] ENTRADA.SHP
@uilian
uilian / ora-password-expiration.sql
Created August 25, 2014 14:35
Oracle - Dealing with locked accounts and password expiration
-- Identify and change profile life_time
select profile from DBA_USERS where username = '<username>';
alter profile <profile_name> limit password_life_time UNLIMITED;
select resource_name,limit from dba_profiles where profile='<profile_name>';
-- Identify which accounts are about to expire (or expired), change password and unlock
select username,expiry_date,account_status from dba_users ORDER BY expiry_date DESC;
alter user <username> identified by <new_password> account unlock;