Skip to content

Instantly share code, notes, and snippets.

import requests
import pandas as pd
from sqlalchemy import create_engine
from datetime import datetime, timezone, timedelta
## Load Data from API to Dataframe
url = "https://api.openweathermap.org/data/2.5/weather?appid=<API KEY>&q=Bangkok&units=metric"
response = requests.get(url)
data = response.json()
df = pd.json_normalize(data)
# ... continue clean the dataframe [df] if needed ...
@JoeThunyathep
JoeThunyathep / cesium.js
Created April 20, 2021 12:40
Adding MapBox Based Map to Cesium Application
var viewer = new Cesium.Viewer('cesiumContainer', {
imageryProvider: new Cesium.MapboxStyleImageryProvider({
styleId: '<Style ID (e.g. light-v10, streets-v11, etc.)>',
accessToken: '<Your Mapbox Access Token (pk....)>'
}),
//other viewer option
//see full documentation: https://cesium.com/docs/cesiumjs-ref-doc/Viewer.html
});
@JoeThunyathep
JoeThunyathep / pyCountryExample.py
Created December 19, 2020 15:20
Example - How to use PyCountry
import pycountry
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/12-18-2020.csv')
def findCountryAlpha2 (country_name):
try:
return pycountry.countries.get(name=country_name).alpha_2
except:
return ("not founded!")
@JoeThunyathep
JoeThunyathep / doc2md.py
Created November 9, 2020 07:41
Convert .docx file to .md using Mammoth
import mammoth
with open("sample.docx", "rb") as docx_file:
result = mammoth.convert_to_markdown(docx_file)
with open("sample.md", "w") as markdown_file:
markdown_file.write(result.value)
@JoeThunyathep
JoeThunyathep / doc2html.py
Created November 9, 2020 07:37
Convert Docx file to HTML using Mammoth
import mammoth
with open("sample.docx", "rb") as docx_file:
result = mammoth.convert_to_html(docx_file)
with open("sample.html", "w") as html_file:
html_file.write(result.value)
<html lang="en">
<head>
<meta charset="utf-8">
<script src="https://cesium.com/downloads/cesiumjs/releases/1.80/Build/Cesium/Cesium.js"></script>
<link href="https://cesium.com/downloads/cesiumjs/releases/1.80/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
</head>
<body>
<div id="cesiumContainer" style="width: 100%; height:100%"></div>
@JoeThunyathep
JoeThunyathep / AddingTerrainToCesiumJS.js
Created October 30, 2020 16:12
Adding Terrain to the Cesium JS 3D Web Map
// Adding terrain
var terrainProvider = new Cesium.createWorldTerrain({
requestWaterMask : true, // required for water effects
requestVertexNormals : true // required for terrain lighting
});
viewer.terrainProvider = terrainProvider;
viewer.scene.globe.enableLighting = true; // set lighting to true
@JoeThunyathep
JoeThunyathep / Create3DWebMap.js
Last active October 30, 2020 16:09
Loading 3D City Models to the CesiumJS 3D Web Map
var viewer = new Cesium.Viewer('cesiumContainer');
var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url : '<Link to Tileset.json>'
}));
tileset.readyPromise.then(function() {
@JoeThunyathep
JoeThunyathep / server.js
Last active October 8, 2020 10:14
Multi-domain SSL in Node.JS Application with Certbot and Express
const fs = require('fs')
const http = require('http')
const https = require('https')
const express = require('express')
const app = express()
app.get('/', (req, res) => {
res.send('Hello World!');
});
@JoeThunyathep
JoeThunyathep / server.js
Created October 8, 2020 09:41
Static Node.js Express Application
const express = require('express');
const app = express();
app.use(express.static(__dirname, { dotfiles: 'allow' } ));
app.listen(80, () => {
console.log('HTTP server running [port - 80]');
});