Skip to content

Instantly share code, notes, and snippets.

<Response>
<Say voice="woman">Your consultation will start at 2:30 PM. You can either chat with the astrologer or start a call with him. Thank you</Say>
<Play>http://demo.twilio.com/docs/classic.mp3</Play>
</Response>
@kuwapa
kuwapa / script.py
Created July 18, 2024 15:56
A script to take the sqlite db from postico1 and convert it to .sql files for postico2 query history
"""
This script is to convert a SQLite DB file from postico1 which contains the SQL query
history to .sql files for each query for Postico2.
"""
import sqlite3
import zlib
import os
from datetime import datetime, timedelta
import random
override fun onCreate(savedInstanceState: Bundle?) {
//map init code..
val path = createDummyPath()
val lineOnMap = showPathOnMap(path)
v.clearButton.setOnClickListener {
lineManager.delete(lineOnMap)
}
}
override fun onCreate(savedInstanceState: Bundle?) {
//map init code..
val path = createDummyPath()
val lineOnMap = showPathOnMap(path)
}
private fun showPathOnMap(path: List<Radio>) : Line {
val lineOptions = LineOptions()
.withLineColor("#3949AB")
fun createDummyPath() = arrayListOf(
LatLng(35.12972888243833, 137.30017964781746),
LatLng(35.16003270167863, 137.34192854082988),
LatLng(35.175866072622306, 137.4588457531761),
LatLng(35.098973418374655, 137.55921143244922),
LatLng(35.15312262941834, 137.65852062512363),
LatLng(35.2538363762526, 137.73846100826395),
LatLng(35.199466465206655, 137.92757107763117),
LatLng(35.31736555432611, 137.92545811180227),
LatLng(35.42017123490391, 137.97405622936287),
private val mapView: MapView by lazy { v.mapView }
private lateinit var lineManager: LineManager
private lateinit var map: MapboxMap
private val v: ActivityMainBinding by lazy {
ActivityTsasBinding.inflate(layoutInflater)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
zoom = 8, leftBottomTiles = (182, 118), rightTopTiles = (183, 118), tileCount = 2
zoom = 9, leftBottomTiles = (365, 237), rightTopTiles = (367, 236), tileCount = 6
zoom = 10, leftBottomTiles = (731, 474), rightTopTiles = (734, 472), tileCount = 12
20
print(getTotalTileCount((13.18178, 77.12267), (13.88948, 78.11077), 8, 10))
def getTotalTileCount(leftBottom, rightTop, fromZoom, toZoom):
totalTileCount = 0
for zoom in range(fromZoom, toZoom + 1):
leftBottomTiles = deg2num(leftBottom, zoom)
rightTopTiles = deg2num(rightTop, zoom)
currentTileCount = (rightTopTiles[0] - leftBottomTiles[0] + 1) * (leftBottomTiles[1] - rightTopTiles[1] + 1)
print("zoom = " + str(zoom) + ", leftBottomTiles = " + str(leftBottomTiles) +
", rightTopTiles = " + str(rightTopTiles) + ", tileCount = " + str(currentTileCount))
import math
def deg2num(lat_deg, lon_deg, zoom):
lat_rad = math.radians(lat_deg)
n = 2.0 ** zoom
xtile = int((lon_deg + 180.0) / 360.0 * n)
ytile = int((1.0 - math.asinh(math.tan(lat_rad)) / math.pi) / 2.0 * n)
return (xtile, ytile)