This file contains 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
#!/usr/bin/env bash | |
PATH=$HOME/bin:/opt/homebrew/bin:$PATH | |
output_vars () { | |
ph --format json | jq -r '"TITLE=\"\(.title)\"\nARTIST=\"\(.artist)\"\nDATE=\"\(.performance_time)\""' | |
} | |
eval $(output_vars) |
This file contains 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 decimal import Decimal | |
from marshmallow import Schema, ValidationError, fields, post_load | |
class SerializableDecimal(fields.Field): | |
def _serialize(self, value, attr, obj, **kwargs): | |
if value is None: | |
return None | |
if not isinstance(value, Decimal): | |
raise ValidationError("must be a Decimal value") |
This file contains 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 json | |
import flask | |
from hamcrest import assert_that, is_ | |
""" | |
json.dumps, by default, will include a bit of whitespace, using default | |
separators (', ', ': ') for item_separator and key_separator, respectively. | |
Flask defaults to a slightly more compact representation, using (',', ':') |
This file contains 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
#! /usr/bin/env bash | |
# | |
# This script downloads and installs Go from http://go.dev. If no version is | |
# provided, it will install the latest released version as shown by | |
# https://go.dev/VERSION. If there is already a Go installed, the script will | |
# replace that installation with the new one (though it will not delete the old | |
# installation). If a directory exists in BASE_DIR indicating that the | |
# requested version is already present, the download will be skipped. | |
# | |
# Requirements: curl, GNU stow |
This file contains 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 /tmp/tx.py | |
(3, 'from python, at 2023-02-10 01:11:07.107806') | |
(4, 'from python, at 2023-02-10 01:11:07.108763') | |
(5, 'from python, at 2023-02-10 01:11:07.109734') | |
(6, 'from python, at 2023-02-10 01:11:07.110544') | |
(7, 'from python, at 2023-02-10 01:11:07.111276') | |
➜ ~ mysql -P 33306 -h 127.0.0.1 -u root -e "select * from test.foo;" | |
+----+--------------------------------------------+ | |
| id | mapping | | |
+----+--------------------------------------------+ |
This file contains 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 functools import reduce | |
def window_product(input: list[int], current_pos: int, window_size: int) -> int: | |
window_bound = max(current_pos + 1 - window_size, 0) | |
window = input[window_bound : current_pos + 1] | |
product = reduce(lambda a, b: a*b, window) | |
return product | |
def window_products(input: list[int], window_size: int) -> list[int]: |
This file contains 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
#!/usr/bin/env bash | |
set -Eeuo pipefail | |
if [[ $# == 0 ]]; then | |
echo >&2 "movie filename and output filename is required" | |
exit 1 | |
fi | |
input_file="$1" |
This file contains 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
// Generate a test input for rmchar.go. | |
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
) | |
func main() { |
This file contains 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
. | |
./all-files.txt | |
./sub1 | |
./sub1/foo.toml | |
./sub1/foo.json | |
./sub1/bar.json | |
./sub1/foo.yaml | |
./sub1/sub2 | |
./sub1/sub2/foo.blarg | |
./sub1/sub2/blarg.yamllllll |
This file contains 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
#! /usr/bin/env python2 | |
# <bitbar.title>Escaped-Py2</bitbar.title> | |
# <bitbar.version>v0.0.1</bitbar.version> | |
# <bitbar.author.github>ianfoo</bitbar.author.github> | |
# <bitbar.desc>Echo escaped chars to stdout</bitbar.desc> | |
print("py2: :zzz: P\xe5 tide \xe5 logge av") |
NewerOlder