Skip to content

Instantly share code, notes, and snippets.

# https://geopy.readthedocs.io/en/stable/#nominatim
# https://nominatim.org/release-docs/develop/api/Overview/
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="test")
place = "New York"
location = geolocator.geocode(place)
print(location)
import qrcode
from PIL import Image
data = "https://www.aggregatedIntelligence.com/"
qr = qrcode.QRCode(version=1, box_size=10, border=5) qr.add_data(data)
qr.make(fit=True)
image = qr.make_image (fill="black", back_color="white")
image.save("qr.png")
@rajrao
rajrao / SqlUtilities.GetDotnetType.cs
Last active April 23, 2023 16:59 — forked from JerryNixon/SqlUtilities.GetDotnetType.cs
Convert SQL Type to .NET Type
public static class SqlUtilities
{
readonly static SqlDataTypeOption[] unsupportedTypes = new[]
{
SqlDataTypeOption.Sql_Variant,
SqlDataTypeOption.Timestamp,
SqlDataTypeOption.Rowversion,
};
public static string GetDotnetType(this SqlDataTypeOption sqlDataType, bool isNullable = false)
#BAD
import os
class SlackLogger:
def post message(self, message):
print("I'm posting to Slack: (message)")
#in your code e.g. Celery jobs
'''
if os.getenv("APP_ENVIRONMENT") == "production":
#This code is an example of how to use text based mapper class names to query the airflow db.
import inspect
import re
from airflow.models.base import Base
from airflow import DAG, settings
from airflow.operators.python import PythonOperator
from airflow.utils.dates import days_ago
#based on: https://www.therealomar.com/articles/2019-06/Git-the-most-edited-files-in-a-project
git log --pretty=format: --name-only --since=1.years.ago |
Where-Object { ![string]::IsNullOrEmpty($_) } |
Group-Object |
Sort-Object -Property Count -Descending |
Select-Object -Property Count, Name -First 10
//validates a cloud formation template in VsCode.
//add this to a file named tasks.json in the .vscode folder.
//to run: Terminal >> Run Task...
{
"version": "2.0.0",
"tasks":[
{
"label":"aws cf validate-template",
"type":"shell",
"presentation": {
//Add the following launch configuration to launch.json. I create
//a specific launch.json in my workspace folder as this setting
//will likely be different for each workspace folder.
//change the "startupFileNameHere" to point to your startup file.
"configurations": [
{
"name": "Python: Run Startup File",
"type": "python",
"request": "launch",
@rajrao
rajrao / OdataQueryD365FinanceAndOperationsTest.cs
Last active September 14, 2020 03:43
Shows how to perform authentication and retrieval of data from D365 Finance and Operations using OData and the Service to service calls using client credentials
//more details at: https://blog.aggregatedintelligence.com/2020/09/d365-finance-and-operations-odata-query.html
var baseUrl = "https://myDomain.sandbox.operations.dynamics.com"; //a trailing slash here will cause a "No P3P Policy defined" error
var tenantId = "TENANTID AS A GUID HERE";
string applicationId = "APPLICATION GUID HERE";
string clientSecret = "CLIENT SECRET HERE";
string api = "data/";
var authorityUrl = $"https://login.windows.net/{tenantId}";