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
"""Here's Mr. P's example of a simple Flask app. | |
How to use this: | |
1. Install Python | |
2. Install Flask | |
3. Download this file and make sure it's named "hello.py" | |
4. Run this file using: | |
flask --app hello run --debug | |
5. Open your browser and go to: | |
http://127.0.0.1:5000 |
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
CREATE TABLE tbl AS SELECT strptime(dt_iso, '%x %X %z %Z') AS dt, temp_min, temp, temp_max, feels_like FROM "nyc_weather.csv"; | |
CREATE TABLE averages AS SELECT date_part('month', dt) AS month, date_part('day', dt) AS day, date_part('hour', dt) AS hour, avg(temp_min), avg(temp), avg(temp_max), avg(feels_like) FROM tbl GROUP BY month, day, hour ORDER BY month, day, hour; | |
SELECT * FROM averages WHERE month = 2 AND day = 9; | |
┌───────┬───────┬───────┬────────────────────┬────────────────────┬────────────────────┬────────────────────┐ | |
│ month │ day │ hour │ avg(temp_min) │ avg("temp") │ avg(temp_max) │ avg(feels_like) │ | |
│ int64 │ int64 │ int64 │ double │ double │ double │ double │ | |
├───────┼───────┼───────┼────────────────────┼────────────────────┼────────────────────┼────────────────────┤ | |
│ 2 │ 9 │ 0 │ 28.441458333333333 │ 29.88333333333333 │ 31.296875000000004 │ 20.9225 │ | |
│ 2 │ 9 │ 1 │ 27.859555555555552 │ 29.6 |
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 argparse | |
import sqlite3 | |
import os | |
import shutil | |
import sys | |
from urllib.parse import unquote | |
QUERY = """ | |
SELECT ZGAME.ZNAME, ZIMAGE.ZRELATIVEPATH, ZIMAGE.ZSOURCE, ZROM.ZLOCATION |
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
.DEFAULT: setup | |
SHELL = /bin/bash | |
NAME := coreml_stable_diffusion | |
PYMAJOR := 3 | |
PYREV := 8 | |
PYPATCH := 10 | |
PYVERSION := ${PYMAJOR}.${PYREV}.${PYPATCH} | |
PYENV := ~/.pyenv/versions/${PYVERSION} |
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 | |
""" | |
extract_and_merge_csv_cols.py is a script to extract a target column from a set | |
of csvs and merge them into a single csv where each column name is the filename | |
of the original csv. | |
Usage: | |
extract_and_merge_csv_cols.py <target_col> <csvs>... | |
""" |
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 | |
from enum import Enum | |
from collections import defaultdict | |
SYSTEM_DICTIONARY = "/usr/share/dict/words" | |
class Hint(Enum): | |
GRAY = 0 | |
YELLOW = 1 | |
GREEN = 2 |
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
while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; fortune -s | cowsay; } | nc -l 8080; done |
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
python3 -c "while 1: print(chr(int(9585.5 + __import__('random').random())), end='')" |
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
package io.oden.laser.common.transforms; | |
import org.apache.beam.sdk.transforms.windowing.*; | |
import org.apache.beam.sdk.transforms.windowing.Window.OnTimeBehavior; | |
import org.joda.time.Duration; | |
public class Windows { | |
/* | |
* The Window described attempts to both be prompt but not needlessly retrigger. | |
* It's designed to account for the following cases... |
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
In [3]: df1 = pd.DataFrame({"start": [1,2,6], "end": [2,6,9]}) | |
...: df2 = pd.DataFrame({"foo": [1,2,3,4,5,6,7,8,9]}) | |
...: dfm = pd.merge(df1, df2, how="cross") | |
...: dfm.loc[(dfm.foo >= dfm.start) & (dfm.foo < dfm.end)] | |
Out[3]: | |
start end foo | |
0 1 2 1 | |
10 2 6 2 | |
11 2 6 3 | |
12 2 6 4 |
NewerOlder