Automates reloading a website during development; served using vanilla Deno server using a websocket.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! ./python | |
import json | |
import sys | |
from pathlib import Path | |
import subprocess | |
def get_staged_files(): | |
"""Get list of files that are staged for commit.""" | |
try: | |
result = subprocess.run( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
import subprocess | |
from pathlib import Path | |
from typing import Optional | |
import os | |
from dataclasses import dataclass | |
from deprecated import deprecated | |
from pandas import Timestamp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This works... but cant read the output array in the final step! :( | |
# Experimental! | |
UserLib ← &ffi ⊂□"User32.dll" | |
GdiLib ← &ffi ⊂□"Gdi32.dll" | |
KernelLib ← &ffi ⊂□"Kernel32.dll" | |
MessageBoxA ← UserLib {"int" "MessageBoxA" "long" "const char*" "const char*" "unsigned int"} | |
# MessageBoxA {0 "Yes Please" "About to Take A Screenshot" 0} | |
GetSystemMetrics ← UserLib {"int" "GetSystemMetrics" "int"} | |
GetDeviceContext ← UserLib {"long long" "GetDC" "long"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import asyncio | |
from aiohttp import ClientSession, TCPConnector | |
@pd.api.extensions.register_series_accessor("aiohttp") | |
class AiohttpAccessor: | |
def __init__(self, pandas_obj): | |
self._obj = pandas_obj | |
async def _fetch_text(self, url: str, session): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pairwise coefficient of interpolation | |
Interp ← ÷:⊃(-≡⊢|≡/-)◫2 | |
MarchingSquares ← ( | |
: | |
⊃( | |
≡(◫2)Interp | |
| ◫2⍜⍉Interp | |
| ≡≡(°⋯♭)◫2_2> # types | |
| ≡°⍉⍉⊞⊟∩(⇡-1)⊃(⊢⇌|⊢)△ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
def split_dataframe_by_weighted_sequence( | |
df:pd.DataFrame, | |
split_column:str, | |
weight_column:str, | |
skew:float=0.5 | |
): | |
""" | |
Split a dataframe into two parts by a sequence of values and a sequence of weights. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import keyring | |
import pandas as pd | |
import os | |
import sys | |
# You need access to the compiled .NET AdomdClient .dll | |
# You can get it using nuget | |
# ```powershell | |
# nuget.exe install Microsoft.AnalysisServices.AdomdClient.retail.amd64 | |
# nuget.exe install Microsoft.AnalysisServices.Tabular |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function prompt { | |
$currentPath = (Get-Location).Path | |
$driveLetter = $currentPath.Substring(0,1) | |
$folderName = Split-Path $currentPath -Leaf | |
"$driveLetter:/.../$folderName> " | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
from http.server import BaseHTTPRequestHandler, HTTPServer | |
def serve_once(data:str, port=8000, host="127.0.0.1"): | |
""" | |
Serves the given data on the given port and host, then returns after | |
responding to one request. | |
This is a helpful way to send HTML to a browser being controled using Selenium. | |
""" |
NewerOlder