By Anmol Tomar on CodeX
Nov 29, 2022
𝐀 = {'😀': 5} | |
for ℹ︎ in range(20): | |
# print(i, ℹ︎, i == ℹ︎) # NameError: name 'i' is not defined. | |
for _,__ in 𝐀.items(): | |
if __ == ℹ︎: | |
print(_, ℹ︎) | |
print(𝐀) # Prints dictionary in 𝐀 | |
print(A) # Also prints dictionary in 𝐀! | |
print(𝐀 is A) # True |
class IndexFormatter: | |
def __init__(self, volumeId: int): | |
self.itemPages = ( | |
ItemPage.objects.filter(volume__id=volumeId) | |
.order_by('item__topic__name', F('page') * 1, 'item__name')) | |
def format(self) -> str: | |
""" | |
Format the index for printing. | |
""" |
By Anmol Tomar on CodeX
Nov 29, 2022
Useful notes about using jq.
jq -c paths
Prints each path as an array and doesn't show values.jq --stream 'select(.[1]|scalars!=null) | "\(.[0]|join(".")): \(.[1]|tojson)"' example.json
.
and array indices were enclosed in square
brackets, then each one would be a valid jq query string.#!/bin/sh -- | |
# Set timestamps of files in a cloned git repository to when they were last committed. | |
# Default: All git-controlled files in current directory, recursively | |
if [ ${#} = 0 ]; then | |
files="$(git ls-files -z | xargs -0 echo)" | |
else | |
files="${@}" | |
fi |
import boto3 | |
import os | |
from contextlib import closing | |
from botocore.exceptions import ClientError | |
def object_exists(s3, bucket, key): | |
try: | |
boto3.resource('s3').Object(bucket, key).load() | |
return True |
#!/bin/sh -- | |
# Toggle macOS Background Sounds on or off. | |
# | |
# See the System Settings panel for Accessibility > Audio to change settings | |
# like the sound played, volume level, and automatic stop. | |
# `read` returns an integer, but… | |
if [ $(defaults read com.apple.ComfortSounds 'comfortSoundsEnabled') = 0 ] | |
then |