text
stringlengths
185
73.3k
repo
stringlengths
7
100
path
stringlengths
4
146
language
stringclasses
7 values
hash
stringlengths
16
16
score
float64
7
8.5
stars
int64
0
237k
#!/usr/bin/env python """ Elasticsearch CRUD operations using requests library """ import json import requests # Configuration ES_HOST = "localhost" ES_PORT = 9200 ES_URL = f"http://{ES_HOST}:{ES_PORT}" INDEX_NAME = "products" # HTTP session (security disabled: no authentication) session = requests.Session() sessio...
veltzer/demos-db-elk
exercises/developer/00_crud/16_requests_create_index.py
.py
ccb58f40512df757
7.15
1
#!/usr/bin/env python """ Elasticsearch CRUD operations using requests library """ import json import requests # Configuration ES_HOST = "localhost" ES_PORT = 9200 ES_URL = f"http://{ES_HOST}:{ES_PORT}" INDEX_NAME = "products" # HTTP session (security disabled: no authentication) session = requests.Session() sessio...
veltzer/demos-db-elk
exercises/developer/00_crud/18_requests_search_documents.py
.py
f081a4f4fe6eefc7
7.15
1
#!/usr/bin/env python """ Elasticsearch CRUD operations using requests library """ import json from datetime import UTC, datetime import requests # Configuration ES_HOST = "localhost" ES_PORT = 9200 ES_URL = f"http://{ES_HOST}:{ES_PORT}" INDEX_NAME = "products" # HTTP session (security disabled: no authentication) ...
veltzer/demos-db-elk
exercises/developer/00_crud/19_requests_update_documents.py
.py
106f0616543b0020
7.15
1
#!/usr/bin/env python """ Elasticsearch CRUD operations using requests library """ import json import requests # Configuration ES_HOST = "localhost" ES_PORT = 9200 ES_URL = f"http://{ES_HOST}:{ES_PORT}" INDEX_NAME = "products" # HTTP session (security disabled: no authentication) session = requests.Session() sessio...
veltzer/demos-db-elk
exercises/developer/00_crud/20_requests_delete_documents.py
.py
86090c94470a6230
7.15
1
#!/usr/bin/env python """ Update documents in the products index using the Elasticsearch client """ from datetime import UTC, datetime from elasticsearch import Elasticsearch # Initialize client es = Elasticsearch( ['http://localhost:9200'], ) INDEX_NAME = "products" def update_document_full(doc_id: str): ...
veltzer/demos-db-elk
exercises/developer/00_crud/25_client_update_documents.py
.py
3f8b88d600a68c96
7.15
1
#!/usr/bin/env python """ Delete documents from the products index using the Elasticsearch client """ from elastic_transport import TransportError from elasticsearch import ApiError, Elasticsearch # Initialize client es = Elasticsearch( ['http://localhost:9200'], ) INDEX_NAME = "products" def delete_document(do...
veltzer/demos-db-elk
exercises/developer/00_crud/26_client_delete_documents.py
.py
7e4f521b085d1852
7.15
1
#!/usr/bin/env python """ Advanced CRUD operations (mget, bulk, scroll, count) using the Elasticsearch client """ from elasticsearch import Elasticsearch # Initialize client es = Elasticsearch( ['http://localhost:9200'], ) INDEX_NAME = "products" def mget_documents(): """Get multiple documents in one reques...
veltzer/demos-db-elk
exercises/developer/00_crud/27_client_advanced_operations.py
.py
7cb6d178baaaf9a1
7.15
1
#!/usr/bin/env python """ Solution """ from pyspark import SparkConf, SparkContext # Initialize Spark conf = SparkConf().setAppName("Simple RDD Example").setMaster("local[*]") sc = SparkContext(conf=conf) # sc.setLogLevel("ERROR") # Create RDD from a list # numbers = [1, 2, 3, 4, 5] # this is called a python "gene...
veltzer/demos-bd-spark
exercises/pyspark/04_rdd_basics/solution.py
.py
f8942a902f6b08a5
7.15
1
#!/usr/bin/env python """ Solution """ import os from pyspark import SparkConf, SparkContext def create_spark(): """Create and configure SparkContext""" conf = SparkConf().setAppName("Text Processing").setMaster("spark://localhost:7077") return SparkContext(conf=conf) def analyze_files(sc, input_dir):...
veltzer/demos-bd-spark
exercises/pyspark/07_rdd_many_files/solution.py
.py
b725fc405b8f206f
7.15
1
#!/usr/bin/env python """ Solution """ import time from pyspark.sql import SparkSession # Create Spark session spark = SparkSession.builder.appName("ShuffleOptimization").getOrCreate() # Create sample data # Orders data with customer_id and amount orders_data = [(i, i % 100, float(i * 10)) for i in range(1000000)]...
veltzer/demos-bd-spark
exercises/pyspark/11_sql_shuffle/solution.py
.py
b68c3baf4ab66970
7.15
1
#!/usr/bin/env python """ Chaining """ from pyspark.sql import SparkSession spark = SparkSession.builder.appName("SimpleOptimization").getOrCreate() sc = spark.sparkContext # Create sample data numbers = range(1, 100000000) rdd = sc.parallelize(numbers) # Inefficient way: Multiple separate operations def inefficie...
veltzer/demos-bd-spark
exercises/pyspark/12_shuffle/chaining.py
.py
40a1489b777944cb
7.15
1
#!/usr/bin/env python """ Explain output """ import pyspark.sql.functions as F from pyspark.sql import SparkSession def show_plan(df, title): """ Function to capture and print explain plan """ print(f"{title}") print("=" * len(title)) # Get the plan explanation plan = [] # pylint: disable=pr...
veltzer/demos-bd-spark
exercises/pyspark/12_shuffle/explain-output.py
.py
e9af94c4daa93ed0
7.15
1
#!/usr/bin/env python """ Explain """ from pyspark.sql import SparkSession spark = SparkSession.builder.appName("SimpleOptimization").getOrCreate() sc = spark.sparkContext numbers = range(1, 1000) rdd = sc.parallelize(numbers) # Convert RDD operations to DataFrame operations so we can use explain() df = spark.creat...
veltzer/demos-bd-spark
exercises/pyspark/12_shuffle/explain.py
.py
9e28d7cef411991e
7.15
1
#!/usr/bin/env python """ Solution """ from pyspark.sql import SparkSession spark = SparkSession.builder.appName("OperationCounter").getOrCreate() sc = spark.sparkContext numbers = range(1, 10000) df = spark.createDataFrame([(x,) for x in numbers], ["value"]) # Create accumulators to count operations filter_ops = s...
veltzer/demos-bd-spark
exercises/pyspark/12_shuffle/ff.py
.py
a13cf2de64b6ca89
7.15
1
#!/usr/bin/env python """ Solution """ from pyspark.sql import SparkSession spark = SparkSession.builder.appName("SimpleOptimization").getOrCreate() sc = spark.sparkContext # Create sample data numbers = range(1, 100000) rdd = sc.parallelize(numbers) # Inefficient way: Multiple separate operations def inefficient_...
veltzer/demos-bd-spark
exercises/pyspark/12_shuffle/solution.py
.py
e0c0236241e9bd29
7.15
1
#!/usr/bin/env python """ optimized version """ import time from pyspark.sql import SparkSession spark = SparkSession.builder.appName("SimpleOptimization").getOrCreate() sc = spark.sparkContext # Create sample data numbers = range(1, 10000000) rdd = sc.parallelize(numbers) # Inefficient way: Multiple separate ope...
veltzer/demos-bd-spark
exercises/pyspark/13_rdd_opt/opt.py
.py
a8892ec640fdeb33
7.15
1
#!/usr/bin/env python """ Example """ import os import time from pyspark.sql import SparkSession # Create Spark session cdir = os.path.basename(os.path.dirname(os.path.abspath(__file__))) spark = SparkSession.builder.appName(cdir).getOrCreate() sc = spark.sparkContext # Create a large RDD data = range(1, 10000000)...
veltzer/demos-bd-spark
exercises/pyspark/14_rdd_cache/example.py
.py
41572dcd816568a2
7.15
1
#!/usr/bin/env python """ Solution """ import time from pyspark.sql import SparkSession # Create Spark session spark = SparkSession.builder.appName("SQLCachingDemo").getOrCreate() # Create sample data n_rows = 1000000 data = [(i, f"product_{i % 1000}", i * 10) for i in range(n_rows)] df = spark.createDataFrame(dat...
veltzer/demos-bd-spark
exercises/pyspark/15_rdd_cache/solution.py
.py
7a38e16e8ec001d3
7.15
1
#!/usr/bin/env python """ Example """ import time from pyspark.sql import SparkSession from pyspark.sql.functions import broadcast # Create Spark session spark = SparkSession.builder.appName("BroadcastJoinDemo").getOrCreate() # Create a large dataframe large_data = [(i, f"product_{i % 1000}", i * 10) for i in rang...
veltzer/demos-bd-spark
exercises/pyspark/16_broadcast_join/example.py
.py
fc47f3c25b68bbdb
7.15
1
#!/usr/bin/env python """ Example """ import random import time from pyspark.sql import SparkSession from pyspark.sql.functions import count from pyspark.sql.functions import sum as sql_sum def create_skewed_data(num_rows, num_keys, skew_factor): """ Create sample data with skewed keys """ data = [] fo...
veltzer/demos-bd-spark
exercises/pyspark/17_two_phase_aggregation/example.py
.py
73fadd40cf759824
7.15
1
#!/usr/bin/env python """ Solution from file """ from pyspark.sql import SparkSession from pyspark.sql.functions import udf from pyspark.sql.types import IntegerType def create_spark_session(): """Create and return a Spark session""" return SparkSession.builder \ .appName("IP Address Analysis") \ ...
veltzer/demos-bd-spark
exercises/pyspark/18_udf/solution_from_file.py
.py
9b7a3c980b414693
7.15
1
#!/usr/bin/env python """ Dashboard """ import os import plotly.express as px import streamlit as st from pyspark.sql import SparkSession from pyspark.sql.functions import col, date_format, desc, to_date from pyspark.sql.functions import round as my_round from pyspark.sql.functions import sum as my_sum # Initialize...
veltzer/demos-bd-spark
exercises/pyspark/19_reports/dashboard.py
.py
33ce95c181c71dd2
7.15
1
#!/usr/bin/env python """ Solution """ import logging from datetime import datetime from pyspark.sql import SparkSession from pyspark.sql.functions import ( avg, col, count, countDistinct, date_format, desc, months_between, to_date, when, ) from pyspark.sql.functions import max as...
veltzer/demos-bd-spark
exercises/pyspark/19_reports/solution.py
.py
7651e7a8b2329709
7.15
1
#!/usr/bin/env python """ Generate data """ from datetime import datetime, timedelta import numpy as np import pandas as pd def generate_sales_data(num_stores=5, days=30, seed=42): """Generate sample sales data for the window functions exercise.""" np.random.seed(seed) # Generate dates start_date...
veltzer/demos-bd-spark
exercises/pyspark/20_window/generate.py
.py
724c095a8939ca5f
7.15
1
#!/usr/bin/env python """ Exercise 1: RDD Caching and Persistence This script performs multiple operations on the same RDD without caching, causing repeated computations. Your task is to optimize it using appropriate caching/persistence strategies. """ import time from pyspark.sql import SparkSession def create_s...
veltzer/demos-bd-spark
exercises/pyspark/opt_caching/exercise.py
.py
c3a2c0b8324fadac
7.15
1
#!/usr/bin/env python """ Solution """ import time from pyspark.sql import SparkSession def create_spark_session(): return SparkSession.builder \ .appName("RDD Caching Exercise") \ .getOrCreate() def generate_large_dataset(spark, size=10000): """Generate a large dataset with repeated value...
veltzer/demos-bd-spark
exercises/pyspark/opt_caching/solution.py
.py
ec123f1373728fb0
7.15
1
#!/usr/bin/env python """ Create data """ import random from datetime import datetime, timedelta from pyspark.sql import SparkSession # Initialize Spark spark = SparkSession.builder \ .appName("Explain Examples Data Setup") \ .enableHiveSupport() \ .getOrCreate() # Create large table for meaningful exp...
veltzer/demos-bd-spark
exercises/pyspark/opt_explain/create_data.py
.py
3b4541e55aa4ea07
7.15
1
#!/usr/bin/env python """ Simplified PySpark Repartitioning Exercise - Naive Query Script This script performs a category/region aggregation on the skewed transactions dataset WITHOUT proper repartitioning, demonstrating performance challenges with skewed data. """ import os import sys import time from pyspark.sql i...
veltzer/demos-bd-spark
exercises/pyspark/opt_repartition/simplified-naive-query.py
.py
adff366ab176bc96
7.15
1
#!/usr/bin/env python """ Fixed Optimized Query Script - Excluding Repartitioning Time This script performs aggregation with repartitioning but properly handles partition information collection to avoid errors. """ import os import sys import time from pyspark.sql import SparkSession from pyspark.sql.functions impor...
veltzer/demos-bd-spark
exercises/pyspark/opt_repartition/simplified-optimized-query.py
.py
a8de1ce47436c593
7.15
1
#!/usr/bin/env python """ Sort-Merge Performance Exercise - Comparison Script This script compares the performance results from the naive and optimized solutions and generates visualization charts. """ import json import os import sys from datetime import datetime import matplotlib.pyplot as plt import numpy as np ...
veltzer/demos-bd-spark
exercises/pyspark/opt_sort_merge/comparison-script.py
.py
82e03be6ad672ffe
7.15
1
#!/usr/bin/env python """ Sort-Merge Performance Exercise - Fixed Data Generation Script This script generates two datasets (transactions and products) in both sorted and unsorted versions for performance comparison, ensuring proper global sorting of the sorted datasets. """ import os import shutil import time from ...
veltzer/demos-bd-spark
exercises/pyspark/opt_sort_merge/data-generation-script.py
.py
00daab7df804bd1f
7.15
1
#!/usr/bin/env python """ Sort-Merge Performance Exercise - Naive Solution This script demonstrates joining unsorted datasets, requiring Spark to perform sorting during the join operation. """ import json import os import sys import time from pyspark.sql import SparkSession # Initialize Spark Session spark = SparkS...
veltzer/demos-bd-spark
exercises/pyspark/opt_sort_merge/naive-solution.py
.py
ea1df842e08324da
7.15
1
#!/usr/bin/env python """ Sort-Merge Performance Exercise - Optimized Solution This script demonstrates joining pre-sorted datasets, allowing Spark to skip the sorting step during the join operation. """ import json import os import sys import time from pyspark.sql import SparkSession # Initialize Spark Session spa...
veltzer/demos-bd-spark
exercises/pyspark/opt_sort_merge/optimized-solution.py
.py
2403a0444a7b4878
7.15
1
#!/usr/bin/env python """ Exercise """ import random from datetime import datetime, timedelta from pyspark.sql import SparkSession from pyspark.sql import functions as F def create_spark_session(): return SparkSession.builder \ .appName("Partition Pruning Exercise") \ .config("spark.sql.sources...
veltzer/demos-bd-spark
exercises/pyspark/opt_sql_prunning/exercise.py
.py
6f0ad21aeaf04eaf
7.15
1
#!/usr/bin/env python """ PySpark Data Generation Script for ANALYZE TABLE Exercise This script creates two tables with skewed data distribution: 1. orders - A large fact table with order information 2. customers - A dimension table with customer details """ import random from pyspark.sql import SparkSession from py...
veltzer/demos-bd-spark
exercises/pyspark/opt_statistics/data-prep.py
.py
a84c73f6485bdb58
7.15
1
#!/usr/bin/env python """ Slow Query Script - Without ANALYZE TABLE This script executes a complex query that joins the customers and orders tables with multiple filters. Without table statistics, Spark makes suboptimal decisions about join strategies, predicate pushdown, and partition pruning. """ import sys import...
veltzer/demos-bd-spark
exercises/pyspark/opt_statistics/exercise.py
.py
8f5f8f6b71e090a0
7.15
1
#!/usr/bin/env python """ Optimized Query Script - WITH ANALYZE TABLE This script runs the exact same query as slow_query.py, but first collects statistics using ANALYZE TABLE. With these statistics, Spark can make better decisions about join strategies, predicate pushdown, and partition pruning. """ import sys impo...
veltzer/demos-bd-spark
exercises/pyspark/opt_statistics/solution.py
.py
6407b2a59137ae80
7.15
1
#!/usr/bin/env python """ Solution """ import time from pyspark.sql import SparkSession # Initialize Spark Session spark = SparkSession.builder \ .appName("Statistics Exercise - Optimized Query") \ .getOrCreate() def compute_statistics(): print("Computing table statistics...") # Compute table-leve...
veltzer/demos-bd-spark
exercises/pyspark/opt_statistics_old/solution.py
.py
18c83b39068c3d0a
7.15
1
#!/usr/bin/env python """ Exercise 2: Optimizing Count Distinct with Two-Phase Aggregation This exercise demonstrates the performance difference between regular count distinct and a two-phase approach with partition-level aggregation. """ import random import time import pyspark.sql.functions as F from pyspark.sql ...
veltzer/demos-bd-spark
exercises/pyspark/opt_two_phase/exercise.py
.py
ff4804d2b961a320
7.15
1
#!/usr/bin/env python """ Solution """ import hashlib import random import time import pyspark.sql.functions as F from pyspark.sql import SparkSession from pyspark.sql.types import StringType def create_spark_session(): return SparkSession.builder \ .appName("Count Distinct Exercise") \ .config...
veltzer/demos-bd-spark
exercises/pyspark/opt_two_phase/solution.py
.py
060de53636ab096f
7.15
1
"""Application-wide constants and filesystem paths. Data lives outside the installation directory so that shop data survives application updates and works when the app is installed to a read-only location (Program Files, /Applications). Dropping a file named ``portable.txt`` next to the executable switches the app to...
devShakib015/BusinessMonitoringApp
app/config.py
.py
08a1f7524a3a5b89
7
0
"""Timestamps. The shop's computer clock is the source of truth: a shopkeeper reading a day-end report means *their* day, and the till is not shared across timezones. Storing local time keeps date-range reports simple and keeps the stored value readable when someone opens the database directly. """ from datetime imp...
devShakib015/BusinessMonitoringApp
app/core/clock.py
.py
6155cc3dcb0352c4
7
0
"""SQLite access layer. One connection is shared for the life of the process, guarded by a re-entrant lock so a background export cannot interleave with a checkout. WAL mode keeps reads from blocking the write that commits a sale. """ import sqlite3 import threading from contextlib import contextmanager from app im...
devShakib015/BusinessMonitoringApp
app/core/db.py
.py
7413b11e43f46de9
7
0
"""Money handling. Every amount in the database is stored as an **integer number of minor units** (paisa, cents, fils...). Floating point is never used for money: 0.1 + 0.2 is not 0.3, and a till that is off by a paisa a hundred times a day is a till the shopkeeper stops trusting. The number of decimals is a shop se...
devShakib015/BusinessMonitoringApp
app/core/money.py
.py
8766a8a299fcff8d
7
0
"""Quantities are stored as integer thousandths. A shop that sells rice by the kilo needs ``1.5`` to be a real quantity, and a shop that sells bottles needs ``2`` to print as ``2`` and not ``2.000``. One integer scale covers both without floats creeping into stock arithmetic. """ from decimal import Decimal, ROUND_H...
devShakib015/BusinessMonitoringApp
app/core/quantity.py
.py
42f60503ee417c4b
7
0
"""Password hashing and session state. Passwords are stored as salted PBKDF2-HMAC-SHA256 digests. The previous version of this app kept them in plain text in the SQLite file, which meant anyone who could copy ``main.db`` had the owner's password. """ import hashlib import hmac import os import secrets from dataclass...
devShakib015/BusinessMonitoringApp
app/core/security.py
.py
c66a73ba91094215
7
0
"""Append-only audit trail for actions worth answering questions about later.""" from contextlib import contextmanager from app.core import clock, db _muted = False @contextmanager def muted(): """Stop recording — used while seeding sample data, which is not real work.""" global _muted previous, _muted...
devShakib015/BusinessMonitoringApp
app/repo/activity.py
.py
a57e596bcfc51f67
7
0
"""Customers and their outstanding balance. A sale does not need a customer -- a walk-in is the common case and attaching one is optional. Customers exist so a shop can put a sale "on the book" and collect later, which is how most neighbourhood shops actually trade. """ from app.core import clock, db _BALANCE = """...
devShakib015/BusinessMonitoringApp
app/repo/customers.py
.py
a6ef18a3cc9d15c4
7
0
"""Backups. Shop data is the shop's livelihood, so backing it up is a one-click action in the app rather than a folder the owner is expected to know about. Copies are made with SQLite's online backup API, which is safe while the database is open and in WAL mode (a plain file copy is not). """ import os import shutil...
devShakib015/BusinessMonitoringApp
app/services/backup.py
.py
1583ef5a89529a52
7
0
"""Returns and refunds. A shop that cannot take something back is not running a till, it is running a one-way door. A return re-stocks what came back, refunds in cash or credits the customer's account, and never lets more come back than went out. """ from dataclasses import dataclass from app.core import clock, db,...
devShakib015/BusinessMonitoringApp
app/services/returns.py
.py
cd533ad7242799ed
7
0
"""Common behaviour for the screens in the main window.""" from PySide6.QtWidgets import QWidget from app.core.security import Session from app.ui.widgets.common import vbox class Page(QWidget): """A screen in the sidebar. ``refresh`` runs every time the page becomes visible, so a sale made on the sell...
devShakib015/BusinessMonitoringApp
app/ui/pages/base.py
.py
0290f3dd7cb773ca
7
0
"""YAML config loading and validation for SegCraft.""" from __future__ import annotations from importlib.resources import as_file, files from pathlib import Path from typing import Any, Dict from .schema import SegCraftConfig, parse_config, validate_config def _load_yaml(path: Path) -> Dict[str, Any]: try: ...
oney-erge/SegCraft-Semantic-Segmentation
src/segcraft/config/loader.py
.py
971fd8716384985b
7.24
2
"""Build a unit from scratch in Python: a GondorFighter horde, its members, their weapon, and the command buttons that drive it. `sage_ini`'s model is parse-driven - a typed `Object`/`Weapon`/`CommandButton` is built from an AST `Block`, not from a constructor. So "creating a unit purely from Python" means assembling ...
ClementJ18/pySAGE
examples/sage_ini/build_gondor_fighter_horde.py
.py
047aeb82fbef056f
7.35
4
"""How much damage does MordorFighter do to GondorFighter per hit? Loads the base game, takes the attacker's weapon (the nuggets on its primary weapon) and applies each DamageNugget to the defender's armor: the damage dealt for a nugget is `nugget.Damage * armor.get_damage_scalar(nugget.DamageType)`. Run from the rep...
ClementJ18/pySAGE
examples/sage_ini/damage_calc.py
.py
68ca8f91ec550b40
7.35
4
"""A turn-by-turn duel: who dies first, MordorFighter or GondorFighter? Each unit's health is the `MaxHealth` of its body module (`ActiveBody`). The two units trade single blows; each blow subtracts the attacker's per-hit damage (weapon nuggets vs the defender's armor, see damage_calc.py) from the defender's remaining...
ClementJ18/pySAGE
examples/sage_ini/duel.py
.py
074bc607b4abd1b5
7.35
4
"""Shared setup for the `sage_live` examples: attach, order, and name the local player's units. Every example needs the same few things - a writable handle on the running game, the local player, and some units to order about - so they live here rather than being copied four times. The attaching itself is `sage_live.a...
ClementJ18/pySAGE
examples/sage_live/_common.py
.py
4b72a8af6c176b94
7.35
4
"""Keep the camera on wherever the fighting is, so a bot's match can be filmed unattended. The camera half of the live bridge, doing the job it exists for. Each cycle this reads the whole board, decides where the action is, and eases the camera toward it - no orders are sent and nothing about the match is touched, so ...
ClementJ18/pySAGE
examples/sage_live/follow_action.py
.py
4b26f83f94ae6168
7.35
4
"""How fast does `ParticleSystemManager` actually step, against the client frame? `[TheParticleSystemManager+0x74]` is the stamp the update gate compares. Stock writes the raw client frame there, so particle systems take one step per client frame and every effect in the game runs at the frame rate - `render-rate.md` §...
ClementJ18/pySAGE
examples/sage_live/fx_step.py
.py
86499fb1a6a8d23c
7.35
4
"""Does the GPU particle clock advance at the authored 30, or at the client rate? `Type = GPU_PARTICLE` systems never go through the gate `render-rate.md` §9.4 installs. They read the W3D millisecond clock at `0x00DD1E0C` and convert it to frames with the *live* client rate - `ms * clientRate * 0.001` - at four sites ...
ClementJ18/pySAGE
examples/sage_live/gpu_particle_clock.py
.py
4a131cfa0409e656
7.35
4
"""Order a battalion **while it is still forming**, and watch whether it comes apart. The bug this reproduces: a horde given an order before it has finished coming out of the building that made it can end up as loose units that nothing can attack - only trample or splash damage touches them. `sage_patch/docs/horde-for...
ClementJ18/pySAGE
examples/sage_live/horde_formation.py
.py
6ebfddf664cc4a6a
7.35
4
"""Flip a running game between client rates, so one match can be measured at both. `render_rate_probe.py` compares 30 fps against 60. Doing that by patching `game.dat` and relaunching gives two *different* matches - different units, different camera, different motion - and the numbers that matter (distinct interpolate...
ClementJ18/pySAGE
examples/sage_live/set_render_rate.py
.py
225abf9d9a97afe4
7.35
4
"""Read-only reconnaissance of a live match: everything a bot needs to know before it acts. Run this once at the start of a match, before writing any policy against it. It answers the four questions that decide whether a bot can play at all, and it answers them by *measuring* rather than by assuming: 1. **Do the live...
ClementJ18/pySAGE
examples/sage_live/survey.py
.py
bac2c320d85520e2
7.35
4
"""Research an upgrade and *verify it landed* - the two scopes, and the field that lies. Upgrades are the first thing in the live API where the obvious reading is wrong, so this example is built around the mistake rather than around the happy path: player.upgrades faction-wide researches, and only th...
ClementJ18/pySAGE
examples/sage_live/upgrades.py
.py
7e6bfaaf4c8e5d66
7.35
4
"""Script to blend a tile with its neighbour in a given direction. Coordinates match the world editor visual (rows top-to-bottom, columns left-to-right). Usage: python blend_tile.py <map_file_path> <row> <col> <direction> [output_map_path] Directions: right Blend towards the tile at col+1 left Blend t...
ClementJ18/pySAGE
examples/sage_map/blend_tile.py
.py
2565f94346bec0ab
7.35
4
"""Script to detect and fix unblended tile connections. For every adjacent pair of tiles with different textures that lacks a blend, the smaller texture group blends over the larger one. A blend is added on the small-group tile, pointing toward the large-group tile. Coordinates match the world editor visual (rows to...
ClementJ18/pySAGE
examples/sage_map/fix_blends.py
.py
8bb67bc00ab9055f
7.35
4
"""Script to scale a map by a numeric factor (integer or float). Usage: python scale_map.py <map_file_path> <scale> [output_map_path] [--scale-objects] Example: python scale_map.py Mission.map 3 python scale_map.py Mission.map 0.5 Mission_half.map python scale_map.py Mission.map 3 Mission_3x.map --sca...
ClementJ18/pySAGE
examples/sage_map/scale_map.py
.py
c506ecd9e338491c
7.35
4
"""Script to replace textures in a map file. Usage: 1. Run the script with a map file path 2. It will generate texture_mapping.json with all unique textures 3. Edit the JSON file to specify replacements 4. Press Enter to apply the changes Mapping file format (per texture entry): "OldName": {"name": "NewName", "cell...
ClementJ18/pySAGE
examples/sage_map/texture_replacer.py
.py
fe442a0d02217649
7.35
4
"""Batch round-trip validator for `.apt`/`.const` pairs, shared by the `sage-apt check` CLI and the corpus acceptance gate. Each pair is decompiled, recompiled, and re-decompiled in a temporary directory so the inputs are never touched. A pair is `ok` when the second XML matches the first, `unstable` when they differ,...
ClementJ18/pySAGE
sage_apt/check.py
.py
b06dbdcea3385c82
7.35
4
"""Flag bit-field conversions for PlaceObject, Button, and ButtonAction flags.""" def _split_flags(flagstr: str) -> list[str]: return [f.strip().lower() for f in flagstr.split("|") if f.strip()] # PlaceObject flags _PO_BITS = { "move": 0x01, "hascharacter": 0x02, "hasmatrix": 0x04, "hascolortran...
ClementJ18/pySAGE
sage_apt/flags.py
.py
dcaaa08787292b07
7.35
4
"""Parser for the APT image-map `.dat` file (`AptToBigc` output). The `.dat` sitting beside a `.apt`/`.const` pair maps each `image` character to the texture it samples and the sub-rectangle it crops out of that texture's atlas. Two record kinds, one per line (`;`-prefixed lines are comments): <imageId>-><texture...
ClementJ18/pySAGE
sage_apt/imagemap.py
.py
ff8bd5aa29905906
7.35
4
"""Resolve an APT `image` character to real artwork (a cropped PNG data-URI). Ties the stdlib `.dat` image map (`sage_apt.imagemap`) to the shared texture decoder (`sage_utils.textures.TextureSource`): an image samples texture `apt_<Movie>_<id>` and crops the rectangle the `.dat` records out of it. Everything here nee...
ClementJ18/pySAGE
sage_apt/textures.py
.py
83fa14e0c8643be2
7.35
4
"""Binary reader/writer for the SAGE engine's `asset.dat` file: the BFME2/RotWK asset cache index of every source art file (`.w3d`/`.tga`/...), the individual assets each one provides with their byte range inside it, and a dependency table of which assets reference which other assets. See README.md for the full on-disk...
ClementJ18/pySAGE
sage_asset/assetdat.py
.py
6beacce69b230d7b
7.35
4
# Copyright 2019-present MongoDB, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in wri...
mongodb-labs/pymongoexplain
test/test_crud_v2.py
.py
55660b145aa850c4
7.85
4
# Copyright 2009-2015 MongoDB, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
mongodb-labs/pymongoexplain
test/version.py
.py
6f9fc1463d1fa6da
7.85
4
from __future__ import annotations import logging import os from collections.abc import Iterator from itertools import chain from typing import Any from typing import Literal try: import pandas as pd except ImportError: pd = None # type: ignore import pyarrow as pa import parquery.aggregate_duckdb as aggre...
visualfabriq/parquery
parquery/aggregate.py
.py
bb6fca924c15da3c
7.15
1
from __future__ import annotations import gc import logging import os import shutil import uuid from collections.abc import Iterator from typing import Any try: import duckdb HAS_DUCKDB = True except ImportError: HAS_DUCKDB = False import pyarrow as pa from parquery.tool import DataFilter logger = log...
visualfabriq/parquery
parquery/aggregate_duckdb.py
.py
f6e6d240d6917b82
7.15
1
from __future__ import annotations import gc import logging import pyarrow as pa import pyarrow.compute as pc import pyarrow.dataset as ds # Import shared types and utilities from main aggregate module from parquery.tool import SAFE_PREAGGREGATE, DataFilter, create_empty_result logger = logging.getLogger(__name__) ...
visualfabriq/parquery
parquery/aggregate_pyarrow.py
.py
afb73aa46c6b30a3
7.15
1
from __future__ import annotations import logging from typing import TYPE_CHECKING, Any, Literal import pyarrow as pa logger = logging.getLogger(__name__) if TYPE_CHECKING: import pandas as pd import polars as pl try: import duckdb # noqa: F401 HAS_DUCKDB = True except ImportError: HAS_DUCKDB...
visualfabriq/parquery
parquery/tool.py
.py
54c6b2c11d27013d
7.15
1
from __future__ import annotations import gc import logging import os import pathlib from typing import TYPE_CHECKING import pyarrow as pa import pyarrow.parquet as pq logger = logging.getLogger(__name__) if TYPE_CHECKING: import pandas as pd import polars as pl try: import pandas as pd HAS_PANDAS...
visualfabriq/parquery
parquery/write.py
.py
91d5298a11e3a895
7.15
1
import tempfile import pyarrow.parquet as pq import pytest from parquery import aggregate_pq, df_to_parquet try: import polars as pl HAS_POLARS = True except ImportError: HAS_POLARS = False @pytest.mark.skipif(not HAS_POLARS, reason="polars not installed") def test_polars_write_and_read(): """Test...
visualfabriq/parquery
tests/test_polars.py
.py
3bba8ba2cb48b27f
7.65
1
import pyarrow as pa from parquery.transport import ( deserialize_pa_table_base64, deserialize_pa_table_bytes, open_pa_table_stream, serialize_pa_table_base64, serialize_pa_table_bytes, ) def test_pa_serialization_bytes(): """Test PyArrow table serialization to bytes.""" # Create data dir...
visualfabriq/parquery
tests/test_serialization.py
.py
e72305ad4df1783e
7.65
1
# SPDX-FileCopyrightText: 2019-present Snoonet # # SPDX-License-Identifier: MIT """CLI for static-site-deployer.""" import re import sys import tarfile from pathlib import Path from shutil import rmtree from typing import Annotated import click import requests import typer from github import Github from github.GitRe...
snoonetIRC/static-site-deployer
src/static_site_deployer/cli/__init__.py
.py
e5bbbe8afd2f5abc
7
0
import json import jwt import time import base64 import os from app.coursegrab.utils.constants import ALGORITHM, ANDROID, EMAIL, IOS, COURSEGRAB_FROM_EMAIL, COURSEGRAB_TO_EMAIL, MAX_BCC_SIZE from datetime import datetime from hyper import HTTP20Connection from firebase_admin import initialize_app, messaging import boto...
cuappdev/coursegrab-backend
src/app/coursegrab/notifications/push_notifications.py
.py
023972ca61fc82df
7.15
1
from __future__ import with_statement import logging from logging.config import fileConfig from sqlalchemy import engine_from_config from sqlalchemy import pool from alembic import context # add your model's MetaData object here # for 'autogenerate' support # from myapp import mymodel # target_metadata = mymodel.Ba...
cuappdev/coursegrab-backend
src/app/migrations/env.py
.py
9145beb53fd19295
7.15
1
"""Change user sessions Revision ID: 110f14cc6f39 Revises: 320142725e82 Create Date: 2021-01-21 13:32:16.209987 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = "110f14cc6f39" down_revision = "320142725e82" branch_labels = None depends_on = None def upgrade():...
cuappdev/coursegrab-backend
src/app/migrations/versions/110f14cc6f39_change_user_sessions.py
.py
3520759989fbf3ac
7.15
1
"""Add semesters Revision ID: 320142725e82 Revises: c8591a7abce5 Create Date: 2020-04-21 01:49:07.098188 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = "320142725e82" down_revision = "c8591a7abce5" branch_labels = None depends_on = None def upgrade(): # ...
cuappdev/coursegrab-backend
src/app/migrations/versions/320142725e82_add_semesters.py
.py
85ef910a8e60b765
7.15
1
"""Update session Revision ID: 3cfb8cf58e98 Revises: 110f14cc6f39 Create Date: 2021-04-04 01:26:03.892507 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = '3cfb8cf58e98' down_revision = '110f14cc6f39' branch_labels = None depends_on = None def upgrade(): #...
cuappdev/coursegrab-backend
src/app/migrations/versions/3cfb8cf58e98_update_session.py
.py
d30f3b1f00f4633d
7.15
1
"""Initial migration Revision ID: 6ce1a6f069ff Revises: Create Date: 2020-03-04 17:23:44.459614 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = "6ce1a6f069ff" down_revision = None branch_labels = None depends_on = None def upgrade(): # ### commands auto g...
cuappdev/coursegrab-backend
src/app/migrations/versions/6ce1a6f069ff_initial_migration.py
.py
7cf88d14b39ddeab
7.15
1
"""Add professors Revision ID: 8bee00207b63 Revises: 6ce1a6f069ff Create Date: 2020-03-08 21:48:22.794206 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = "8bee00207b63" down_revision = "6ce1a6f069ff" branch_labels = None depends_on = None def upgrade(): #...
cuappdev/coursegrab-backend
src/app/migrations/versions/8bee00207b63_add_professors.py
.py
db26dcd31e01ecb7
7.15
1
"""Add notifications Revision ID: c8591a7abce5 Revises: 8bee00207b63 Create Date: 2020-03-11 18:08:51.709412 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = "c8591a7abce5" down_revision = "8bee00207b63" branch_labels = None depends_on = None def upgrade(): ...
cuappdev/coursegrab-backend
src/app/migrations/versions/c8591a7abce5_add_notifications.py
.py
0ca2edda6c744357
7.15
1
""" Git host client factory module. The client factory uses a dispatcher pattern to ease registration of new git host APIs. To register a new git host API implementation to this factory, simply decorate the client class with @api_client(api_name). Example: # bert_e.git_host.bitbucket module from bert_e.git...
scality/bert-e
bert_e/git_host/factory.py
.py
db6b7b83784f81ed
7.15
1
# Copyright 2016-2018 Scality # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
scality/bert-e
bert_e/job.py
.py
a1ff786a1c12fa94
7.15
1
# Copyright 2016-2018 Scality # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
scality/bert-e
bert_e/jobs/delete_queues.py
.py
197b4426e7b627ed
7.15
1
# Copyright 2016-2018 Scality # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
scality/bert-e
bert_e/lib/dispatcher.py
.py
4cf39285f58765fe
7.15
1
# Copyright 2016-2018 Scality # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
scality/bert-e
bert_e/lib/lru_cache.py
.py
56a53def2d296c5c
7.15
1
# Copyright 2016-2018 Scality # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
scality/bert-e
bert_e/lib/retry.py
.py
33a6576af5082bcd
7.15
1
# Copyright 2016-2018 Scality # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
scality/bert-e
bert_e/lib/settings_dict.py
.py
4626fd8cafd9b312
7.15
1
# Copyright 2016-2018 Scality # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
scality/bert-e
bert_e/lib/simplecmd.py
.py
ae9ed08f88eda369
7.15
1
# Copyright 2016-2018 Scality # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
scality/bert-e
bert_e/server/__init__.py
.py
5ab5a8dac49df127
7.15
1
# Copyright 2016-2018 Scality # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
scality/bert-e
bert_e/server/api/__init__.py
.py
de46afc6db6e65bb
7.15
1