word count

This commit is contained in:
vitrinekast
2025-04-13 09:03:57 +02:00
parent f6d44f88ca
commit 9b8474efb9
6 changed files with 106 additions and 31 deletions

61
app.py
View File

@ -28,6 +28,8 @@ now = datetime.now()
word_count = 0
# Utils
def getParam(params, index):
return params[index] if len(params) > index else False
@ -41,10 +43,14 @@ def listDocuments(params):
return html
# jinja filter to make a slug out of a stirng
def slugify_filter(value):
return slugify(value)
# Source: https://github.com/gandreadis/markdown-word-count
def count_words_in_markdown(text):
# Comments
@ -75,6 +81,8 @@ def count_words_in_markdown(text):
return len(text.split())
# jinja filter for date formatting
def prettydate(value, format='%d/%m/%Y'):
return datetime.fromtimestamp(int(value)).strftime(format)
@ -105,6 +113,8 @@ env.filters["slugify"] = slugify_filter
env.filters["prettydate"] = prettydate
# translate a single file into HTML
def render_single_file(page, path, dist, name=False):
name = Path(path).stem
template = env.select_template([f"{name}.jinja", "post.jinja"])
@ -139,6 +149,8 @@ def get_existing_page(path, slug):
return False
# build a slug including the folder
def get_slug(path, folder, filename):
if folder == "content":
return slugify(filename)
@ -146,6 +158,8 @@ def get_slug(path, folder, filename):
return slugify(f"{folder}/{filename}")
# compile markdown into cited HTML
def get_page_data(path):
global word_count
@ -163,7 +177,8 @@ def get_page_data(path):
page["folder"] = folder
if "start_datetime" in page:
page["has_passed"] = datetime.fromtimestamp(page["start_datetime"]) < now
page["has_passed"] = datetime.fromtimestamp(
page["start_datetime"]) < now
content = page.content
@ -186,11 +201,11 @@ def get_page_data(path):
"--csl=harvard-cite-them-right.csl",
])
word_count += count_words_in_markdown(page.body)
return page
# Do stuff to the circuit's pcb
def save_circuit_svg(filepath, outpath, name):
tree = ET.parse(filepath)
@ -217,7 +232,8 @@ def render_posts(path, output_path=OUTPUT_D):
file_path = Path(path) / filename
if file_path.suffix == ".md":
render_single_file(get_page_data(file_path), file_path, f"{output_path}/{name}")
render_single_file(get_page_data(file_path),
file_path, f"{output_path}/{name}")
elif file_path.is_dir():
render_posts(file_path, f"{output_path}/{name}")
elif file_path.suffix == ".svg":
@ -227,11 +243,13 @@ def render_posts(path, output_path=OUTPUT_D):
shutil.copyfile(file_path, f"{output_path}/{name}/{filename}")
# Pre-load before compiling
def preload_documents():
global documents
version = subprocess.check_output(["git", "rev-list", "--count", "HEAD"]).decode("utf-8").strip()
version = subprocess.check_output(
["git", "rev-list", "--count", "HEAD"]).decode("utf-8").strip()
documents["meta"] = {"now": now.strftime("%d %B %Y"), "version": version}
@ -247,7 +265,8 @@ def preload_documents():
if filename.endswith(".md"):
documents[name].append(get_page_data(cpath))
elif os.path.isdir(cpath):
documents[name].append(get_page_data(os.path.join(cpath, "index.md")))
documents[name].append(get_page_data(
os.path.join(cpath, "index.md")))
elif Path(path).suffix == '.md':
documents[Path(path).stem] = get_page_data(path)
@ -270,10 +289,37 @@ def get_inventory():
documents['inventory'].append(line)
def get_wordcount():
global word_count
word_count += count_words_in_markdown(documents['thesis'].body)
for c in documents['chapters']:
if c['filename'] != 'index':
count = count_words_in_markdown(c.body)
print(f"{c['filename']}: has {count} words")
word_count += count
for c in documents['components']:
if c['filename'] != 'index':
count = count_words_in_markdown(c.body)
print(f"{c['filename']}: has {count} words")
word_count += count
for c in documents['recipes']:
print(c['filename'])
count = count_words_in_markdown(c.body)
print(f"{c['filename']}: has {count} words")
word_count += count
print(f"word count: { word_count} ")
documents['meta']["count"] = word_count
def main():
print("....Start putting together a new document....")
get_inventory()
preload_documents()
get_wordcount()
for subdir in os.listdir(CONTENT_D):
path = os.path.join(CONTENT_D, subdir)
@ -291,4 +337,5 @@ def main():
print(f"total words: {word_count}")
main()

View File

@ -9,6 +9,10 @@ front: false
<cite>(Solderpunk, 2020, Cited in de Valk, 2022)</cite>
I am a big fan of thinkering with electronics. I think it creates a creative mindset that allows you to hack, modify and own the devices. But Ive also grown a certain discomfort with the practices, first started with a ) the amount of waste I was creating just for a funky explorative session and b) the lack of “respect” there was for the material.
You're reading[^shortcut-print] *A Field Guide for Salvaging Sound Devices*. Here, we'll explore the practical side of salvage computing through the making of noise boxes: is it possible to *live off* (create with) electronic components salvaged in the wild? And what would such a practice entail?
[^shortcut-print]: <kbd>Ctrl</kbd> + <kbd>P</kbd> to print this publication to bring it outside

View File

@ -8,20 +8,50 @@ front: true
<span template-type="chapter"></span>
Once you've uncovered the PCB[^PCB] and other loose parts of the device, we can try to identify the various components. In general PCB's are made with either "trough hole" (THT) or "surface mount" (SMD) components. SMD components are _extremely_ tiny[^tiny] and soldered _on top of_ a PCB. Due to their size, they are really difficult to handle. Their size makes it difficult to read any type of value notation, and actually soldering SMD components is such a frustrating process.[^collapse-OS]. THT components are bigger and have "legs" which are pushed trough holes drilled in the PCB, making them easier to solder & desolder.
<ins>FOTO of multiple PCBs</ins>
<ins>FOTO of THT or SMD components</ins>
The inside of your device exists of multiple parts. Chances are youve uncoverd one or multiple PCBs[^PCB] and *very generally speaking* some sort of input and output components[^about-input-output], connected via a certain type of wire[^wires]. For instance, on the inside of a digital picture frame Ive found a power input, a battery, a screen, speakers, one PCB and an antenna.
[^PCB]: Printed Circuit Board, this is where most of the components are solderd on top of.
[^tiny]: <ins>how tiny, I should include an image</ins>
[^about-input-output]: The input and the output are usually the core functionality of the device. If i press the button (input) the blender blends my smoothie (output). From the outside its difficult to see what goes on in between the input and the output [@hertzZombieMediaCircuit2012], but uncovering the inner traces it can be more noticable how it works, depending on the repairability of the dvice.
Some parts can easily be identified, by recognising. Others can be more difficult. Looking up their datasheet online can provide information about what it is the thing does. A datasheet can be found by looking up a part number[^part-number]
[^part-number]: Some product manufactures are really protective of their parts, and scratch of the part numbers/
In general PCB's are populated with either "trough hole" (THT) or "surface mount" (SMD) components. SMD components are *extremely* tiny[^tiny] and soldered *on top of* a PCB. Their sizes makes their labels difficult to read. Due to their size, they are only suitable for factory made PCBs, which goes a bit against what were doing here. This unfortuantly makes a large portion of parts unusable for the kind of salvage we are doing [^tried]. This is also why i never take computers and smartphones. Too many tiny parts.
[^tried]: Ive made various attempts at using SMD components, since i have so many on PCBs laying around. I tried making circuits using conductive ink, cutting traces on the board directly, using charcoal pens, but none of the strategies have really worked so far. Only for parts that i **really really** want to use, such as some chips, ill jump trough the hoops, but for others, the amount of frustration is just not worth it.
[^wires]: Great for reuse as well!
## The blob
Have you spotted “The Blob” yet? This is every circuit benders worst nightmare[^the-blob]. The blob is meant to protect certain bare parts of a PCB, but is also known as a type of reverse engineering protection.
[^the-blob]: although it is rumoured that that circuit bending guy has a method
## Desoldering
Desoldering parts is generally more difficult then soldering, and requires patience and practice. Ironically, desoldering guns are much more expensive then soldering irons, so heres how i do it, on the cheapsees:\
In a well ventilated[^well-ventilated] room, heat up the blob of solder thas connects the part to the PCB using a soldering iron. After a couple of seconds, youll notice the solder becomes liquid[^liquid]. Then, using tweezers or a plier, i carefully pull the leg out from the backside of the board, and then do the same for the other legs. This process can take somewhere between 10 seconds and 10 minutes, and can be really frustrating.
[^liquid]: How fast this happens, is dependand on the temprature of the soldering iron, and the melting point of the solder that is on the board. If it wont melt, adding a bit of your own solder helps.
[^well-ventilated]: whilest modern device cannot contain led anymore, older solder will. Do not lick the PCB, clean your hands after and open a window.
There are an almost infinite number of parts[^interchangeable_part] that can be found in electronic devices. Ive limited the field guide to the parts that I have found, and found relevant to mention, but youre welcome to update.
<ins>I would like to include more information about how to identify parts and how to find datasheets</ins>
<ins>I would like to include info about how to desolder</ins>
[^interchangeable_part]: <ins> To research [interchangable parts](https://en.wikipedia.org/wiki/Interchangeable_parts#Late_19th_and_early_20th_centuries:_dissemination_throughout_manufacturing) n.a.v. deze [post](https://northcoastsynthesis.com/news/preferred-values-for-resistors-and-capacitors/)</ins>
## List of parts i think are interesting
| **Name** | **Category** | **Description** | **Found in** | **Symbol** | **Value** |
| ---------------------------------- | ------------------------ | --------------------------------------------------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ------------------------ |
| **555 Timer** | IC | A small chip that generates pulses | Timers, LED dimmers | |
@ -29,8 +59,7 @@ There are an almost infinite number of parts[^interchangeable_part] that can be
| **Coil** | Passive Component | These funky components can create sounds on their own | Transformers, relays, wireless charging | ![](./assets/schematics/Inductor-COM-Air.svg) |
| **Crystal Oscillator** | Passive | Generates a frequency that is often used as a clock | Devices that have processors | | Frequency (MHz) |
| **Diode** | Diode | Forces current to flow in one direction | Everywhere! | ![](./assets/schematics/Diode-COM-Standard.svg) |
| **Displays** | Display | Display information | Monitors, calculators, embedded systems | _nvt_ |
| **Fuse** | Passive | Protects circuits from overflowing | Power supplies, home appliances | _nvt_ | Current rating (A) | |
| **Displays** | Display | Display information | Monitors, calculators, embedded systems | _nvt_ | |
| **LED (Light Emitting Diode)** | Diode | Emit a small light | Everywhere! | ![](./assets/schematics/Diode-COM-LED.svg) |
| **Logic chips** | IC | Create logic and switches | Computers, microcontrollers, control circuits | |
| **MOSFET** | IC | Not sure yet | Power supplies, motor control | | Threshold voltage (V) |

View File

@ -21,3 +21,4 @@ SingleTransistorOsc/index.md
power-supply/index.md
4-reflection.md
5-bib.md

View File

@ -6,9 +6,3 @@ layout: index
description: This is the description of the about us page
---
<span template-type="intro"></span>
Dear reader,
This web page includes the WIP version of my thesis. For (limited) information about Klankschool's repair café, go to [https://unrepair.klank.school](https://unrepair.klank.school). The text you'll find below is a draft of the thesis. This thesis will be a field guide to salvaging electronics to make sound devices. This field guide is compact and is meant to be taken *"into the wild."* You can download the guide as a PDF via [this link](https://unrepair.vitrinekast.xyz/assets/thesis.pdf), or CTRL + P your own.
I'm leaving notes of things I'd like to include later. These notes can be recognized by their <ins>tags</ins>.

View File

@ -15,7 +15,7 @@
<header>
<h2>A field guide to</h2>
<h1>Salvaging Sound Devices</h1>
<p>Version {{documents['meta']['version']}}</p>
<p>Version {{documents['meta']['version']}} | {{documents['meta']['count']}} words</p>
<p>{{documents["meta"]["now"]}}</p>
</header>
</section>