blogng/blog/2015-12-01-a-random-rant.markdown
Dhananjay Balan 58b20109cf Convert from old categories to tags
import sys
import yaml

with open(sys.argv[1]) as fp:
    data = fp.read()

if not data.find("---") == 0:
    # no head
    print("NO YAML HEAD FOUND")
    sys.exit(-1)

data = data[3:]
head_end = data.find("---")

head = data[0:head_end]
data = data[head_end+3:]

metadata = yaml.safe_load(head)

cats = metadata.pop('categories', None)
if cats != None:
    if type(cats) == list:
        tags = cats
    elif type(cats) == str:
        tags = cats.split()

    tags = list(map(lambda t: t.lower(), tags))

    metadata["tags"] = ", ".join(tags)
    new_data = f"---\n{yaml.dump(metadata, default_flow_style=False)}---{data}"
    # write it
    print(f"coverted: categories to tags: {tags} - {sys.argv[1]}")
    with open(sys.argv[1], "w") as fp:
        fp.write(new_data)
    sys.exit(0)

if not metadata.get("tags", None):
    metadata["tags"] = "untagged"
    new_data = f"---\n{yaml.dump(metadata, default_flow_style=False)}---{data}"
    print(f"untagged: {sys.argv[1]}")
    # write it
    with open(sys.argv[1], "w") as fp:
        fp.write(new_data)
    sys.exit(0)

print("No changes needed")
2019-01-28 17:16:27 -05:00

35 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
comments: false
date: 2015-12-01 00:00
layout: post
tags: life, rant, filesystems
title: A Random rant
---
```
/me sets +rant
```
Yesterday, Found an old portable hard disk in the attic. Face lights up. Connect to computer, doesnt work. The connection probabaly fried. Its probabaly the connector, HDD internally uses a `SATA` bus.
I know what to do, lets oopen the server box and connect to the motherboard. Cant find any SATA cable. `find sata ~house`
Finally hard disk plugged in, `FreeBSD` boots. `dmesg` shows everything is alright, except `ext4`. #sigh
Somebody suggests `fuse`. Alright, thats it then. Compile, `kldld` and booyeah!
Okay, its full of photos from past. Wow! I need to see them, lets share it to something with a monitor. Thatd be my mac. `sshfs`? Sorry dude, you need the whole `XCode` suite and should sacrifice an extra kidney to load unsigned `kext`s.
But there are other ways of sharing files. `SMB` FTW!
Why the fuck are there three samba versions in ports. `cd /usr/ports/samba$(random_ver)`
Okay, samba is setup and mounted, tears
Nooo - I cant access the hard disk. Why? huh perms fucking perms!
I got this! gonna chmod the shit out, but except… it doesnt work. What the fuck does not implemented mean?
JFGI. JFGI POints to ext4 code - ext4 fuse is strictly read only. (facepalm)
Story still continues…