Skip to content

Instantly share code, notes, and snippets.

View Charmatzis's full-sized avatar
🎯
Focusing

Christos Charmatzis

🎯
Focusing
View GitHub Profile
@Charmatzis
Charmatzis / SpatialKeyComparition.scala
Last active July 17, 2017 04:30
SpatialKeyComparition.scala
object IngestImage extends App{
val _spark = SparkSession
.builder()
.config("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
.config("spark.kryo.registrator", "geotrellis.spark.io.kryo.KryoRegistrator")
import geotrellis.proj4.{LatLng, WebMercator}
import geotrellis.raster.{ArrayTile, DoubleCellType, IntConstantNoDataCellType, MutableArrayTile, RasterExtent, Tile}
import geotrellis.raster.render.ColorRamps
import geotrellis.raster.resample.Max
import geotrellis.spark._
import geotrellis.spark.io._
import geotrellis.spark.io.index._
import geotrellis.spark.io.s3._
import geotrellis.spark.pyramid._
import geotrellis.spark.tiling._
@Charmatzis
Charmatzis / Zeppelin.md
Last active February 5, 2018 11:06
use Zeppelin in EMR with geotrellis and geotrellis-spark-sql

Introduction

This is a help page for settinh up Zeppelin with geotrellis and geotrellis-spark-sql and continue with analysis.

Steps

Prestep

Set properties for EMR cluster

@Charmatzis
Charmatzis / SQLServerGetVersion.sql
Created February 22, 2018 07:16
Get MS SQL Server edition details
SELECT
CASE
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '8%' THEN 'SQL2000'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '9%' THEN 'SQL2005'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '10.0%' THEN 'SQL2008'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '10.5%' THEN 'SQL2008 R2'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '11%' THEN 'SQL2012'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '12%' THEN 'SQL2014'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '13%' THEN 'SQL2016'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '14%' THEN 'SQL2017'
@Charmatzis
Charmatzis / getsize.sql
Last active March 23, 2018 14:49
Get Table size in SQL Server
USE MyDatabase
GO
EXEC sp_spaceused N'User.ContactInfo'
GO
@Charmatzis
Charmatzis / allocated_page_page_id.sql
Created March 23, 2018 15:09
getallocated_page_page_id of a table MS SQL Server
WITH dataCTE
AS
(
SELECT allocated_page_page_id, next_page_page_id, previous_page_page_id
FROM sys.dm_db_database_page_allocations(DB_ID(), OBJECT_ID('dbo.TEMP_POS_TERR'),1, NULL, 'DETAILED')
WHERE is_allocated = 1
AND page_type_desc = 'DATA_PAGE'
)
,pageCTE
AS
@Charmatzis
Charmatzis / index_physical_stats.sql
Created April 16, 2018 04:35
Get index_physical_stats from table in SQL Server
select index_id
, index_type_desc
, index_depth
, index_level
, page_count
, record_count
from sys.dm_db_index_physical_stats (DB_ID(),
OBJECT_ID('Table_Name'), DEFAULT, DEFAULT, 'DETAILED')
go

Reading tiles using RIO

<GDAL_WMS>
    <Service name="TMS">
	<ServerUrl>https://api.mapbox.com/v4/mapbox.satellite/${z}/${x}/${y}.jpg?access_token=******</ServerUrl> <!-- Map -->
    </Service>
    <DataWindow>
        <UpperLeftX>-20037508.34</UpperLeftX>
 20037508.34
SELECT c.conrelid::regclass AS "table",
/* list of key column names in order */
string_agg(a.attname, ',' ORDER BY x.n) AS columns,
pg_catalog.pg_size_pretty(
pg_catalog.pg_relation_size(c.conrelid)
) AS size,
c.conname AS constraint,
c.confrelid::regclass AS referenced_table
FROM pg_catalog.pg_constraint c
/* enumerated key column numbers per foreign key */
@Charmatzis
Charmatzis / psql_useful_stat_queries.psql
Last active May 26, 2021 08:40
List of some useful Stat Queries for PSQL
-- Unused Indexes
select
indexrelname as index_name,
idx_scan,
idx_tup_read,
idx_tup_fetch
from
pg_stat_all_indexes
where
idx_scan = 0