Skip to content

Instantly share code, notes, and snippets.

View Curts0's full-sized avatar

Curtis Stallings Curts0

View GitHub Profile
@Curts0
Curts0 / virtualkeys.py
Created March 9, 2024 22:07 — forked from biqqles/virtualkeys.py
Cross-platform Win32 virtual-key codes
"""
Win32 virtual-key (VK) constants for Python, extracted from winuser.h with
comments.
Original copyright notice printed below:
/****************************************************************************
* *
* winuser.h -- USER procedure declarations, constant definitions and macros *
* *
* Copyright (c) Microsoft Corporation. All rights reserved. *
@avolok
avolok / DeltaTableConfig.py
Last active January 24, 2024 21:58
Medium/DeltaProperty/DeltaTableConfig.py
from delta import DeltaTable
from pyspark.sql import SparkSession
from typing import Union
import logging
def get_logger(name: str):
"""Returns an instance of the logger"""
logger = logging.getLogger(name)
@juanluisrto
juanluisrto / generate_fake_dataframe.py
Last active June 17, 2023 05:37
Function which generates dataframes with fake data in a controlled manner.
import pandas as pd
import numpy as np
from itertools import cycle
def generate_fake_dataframe(size, cols, col_names = None, intervals = None, seed = None):
categories_dict = {'animals': ['cow', 'rabbit', 'duck', 'shrimp', 'pig', 'goat', 'crab', 'deer', 'bee', 'sheep', 'fish', 'turkey', 'dove', 'chicken', 'horse'],
'names' : ['James', 'Mary', 'Robert', 'Patricia', 'John', 'Jennifer', 'Michael', 'Linda', 'William', 'Elizabeth', 'Ahmed', 'Barbara', 'Richard', 'Susan', 'Salomon', 'Juan Luis'],
'cities' : ['Stockholm', 'Denver', 'Moscow', 'Marseille', 'Palermo', 'Tokyo', 'Lisbon', 'Oslo', 'Nairobi', 'Río de Janeiro', 'Berlin', 'Bogotá', 'Manila', 'Madrid', 'Milwaukee'],
'colors' : ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'purple', 'pink', 'silver', 'gold', 'beige', 'brown', 'grey', 'black', 'white']
}
@KristoR
KristoR / databricks_all_columns.py
Created April 28, 2021 11:44
This script creates a dataframe with all databases, tables and columns in Databricks. Similar to information schema in regular SQL databases.
from pyspark.sql.types import StructType
# get field name from schema (recursive for getting nested values)
def get_schema_field_name(field, parent=None):
if type(field.dataType) == StructType:
if parent == None:
prt = field.name
else:
prt = parent+"."+field.name # using dot notation
res = []
@biqqles
biqqles / virtualkeys.py
Created November 22, 2020 19:46
Cross-platform Win32 virtual-key codes
"""
Win32 virtual-key (VK) constants for Python, extracted from winuser.h with
comments.
Original copyright notice printed below:
/****************************************************************************
* *
* winuser.h -- USER procedure declarations, constant definitions and macros *
* *
* Copyright (c) Microsoft Corporation. All rights reserved. *
@gamesbook
gamesbook / ticks.py
Last active June 24, 2024 19:06
Convert C# tick dates into a Python / readable date
# -*- coding: utf-8 -*-
"""
Purpose: Convert .NET ticks to formatted ISO8601 time
Author: D Hohls < dhohls@csir.co.za>
"""
from __future__ import print_function
import datetime
import sys
@brettp
brettp / thread-index.py
Last active November 26, 2021 10:39
Python implementation for Outlook's thread-index headers for message threading
import struct
import time
import sys
import base64
import hashlib
import datetime
def parse_thread_index(index: 'str') -> ("tuple (str, array [datetime.datetime, ...])"):
import binascii