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 / sqlserver_cpu_usage.sql
Created March 9, 2018 07:01
SQL Server CPU Usage by Session
--http://blogs.lobsterpot.com.au/2018/02/13/sql-server-cpu-usage-by-session/
DECLARE @sessionsCPU TABLE
(
session_id SMALLINT NOT NULL,
cpu_time INT NULL ,
initialCPUFlag BIT NOT NULL
)
INSERT INTO @sessionsCPU
SELECT
@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
@Charmatzis
Charmatzis / info.json
Created March 6, 2019 09:54
TileJSON.io - MarineTraffic Density Maps 2016-2017Ship traffic 2016-2017 map comparison
{
"baseLayer": {
"tilejson": "2.2.0",
"name": "base",
"version": "1.0.0",
"scheme": "xyz",
"tiles": [
"https://a.tile.openstreetmap.org/{z}/{x}/{y}.png"
]
},

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