2022-08-29 Emacs news

| emacs, emacs-news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Hacker News, lobste.rs, planet.emacslife.com, YouTube, the Emacs NEWS file, Emacs Calendar, emacs-devel, and lemmy/c/emacs. Thanks to Andrés Ramírez for links!

View or add comments

Recoloring my sketches with Python

| supernote, drawing

The SuperNote lets me draw with black, dark gray (0x9d), gray (0xc9), or white. I wanted to make it easy to recolor them, since a little splash of colour makes sketches more fun and also makes them easier to pick out from thumbnails. Here's the Python script I wrote:

Download recolor.py
#!/usr/bin/python3
# Recolor PNGs
#
# (c) 2022 Sacha Chua (sacha@sachachua.com) - MIT License
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:

# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import numpy as np
import sys
import os
import csv
import argparse
from PIL import Image

DARK_GRAY = 0x9d
GRAY = 0xc9
WHITE = 0xfe

parser = argparse.ArgumentParser(description='Recolor a PNG.',
                                 formatter_class=argparse.RawTextHelpFormatter,
                                 epilog="If neither --colors nor --freq are specified, display the most frequent colours in the image.")
parser.add_argument('--colors', help="""Comma-separated list of RGB hex values in the form of old,new,old,new
Examples:
9d,ffaaaa,c9,ffd2d2 - reddish
c9,ffea96 - yellow highlighter
c9,d2d2ff - light blue
""")
parser.add_argument('--freq', help="Color replacements in order of descending frequency (ex: .,ffea96). .: use original color")
parser.add_argument('--csv', help="CSV of color names to use in the form of colorname,hex")
parser.add_argument('--preview', help="Preview only", action='store_const', const=True)
parser.add_argument('input', help="Input file")
parser.add_argument('output', nargs='?', help="Output file. If not specified, overwrite input file.")

args = parser.parse_args()

def color_to_tuple(color_dict, s):
    if s in color_dict:
        s = color_dict[s]
    s = s.lstrip('#')
    if (s == '.'):
        return (None, None, None)
    elif (len(s) == 2):
        return (int(s, 16), int(s, 16), int(s, 16))
    else:
        return tuple(int(s[i:i + 2], 16) for i in (0, 2, 4))

def load_color_dict(filename):
    dict = {}
    with open(filename, newline='') as csvfile:
        reader = csv.reader(csvfile, delimiter=',', quotechar='"')
        for row in reader:
            dict[row[0]] = row[1]
    return dict

color_dict = load_color_dict(args.csv) if args.csv else {}

input = args.input
output = args.output if args.output else input
if os.path.isdir(output):
    output = os.path.join(output, os.path.basename(input))

im = Image.open(input).convert('RGB')
data = np.array(im)
red, green, blue = data[:, :, 0], data[:, :, 1], data[:, :, 2]

if args.colors:
    colors = iter(args.colors.split(','))
    for from_c in colors:
        to_c = next(colors)
        from_r, from_b, from_g = color_to_tuple(color_dict, from_c)
        to_r, to_b, to_g = color_to_tuple(color_dict, to_c)
        mask = (red == from_r) & (green == from_g) & (blue == from_b)
        data[:, :, :3][mask] = [to_r, to_b, to_g]
else:
    colors = im.getcolors()
    sorted_colors = sorted(colors, key=lambda x: x[0], reverse=True)
    if args.freq:
        freq = iter(args.freq.split(','))
        for i, f in enumerate(freq):
            if f != '.':
                to_r, to_b, to_g = color_to_tuple(color_dict, f)
                by_freq = sorted_colors[i][1]
                if isinstance(by_freq, np.uint8):
                    print(i, '%02x' % by_freq, f)
                    mask = (red == by_freq) & (green == by_freq) & (blue == by_freq)
                else:
                    print(i, ''.join(['%02x' % c for c in by_freq]), f)
                    mask = (red == by_freq[0]) & (green == by_freq[1]) & (blue == by_freq[2])
                data[:, :, :3][mask] = [to_r, to_b, to_g]
    else:
        for x in sorted_colors:
            if isinstance(x[1], np.uint8):
                print('%02x' % x[1])
            else:
                print(''.join(['%02x' % c for c in x[1]]))
        exit(0)
im = Image.fromarray(data)
if args.preview:
    im.thumbnail((700, 700), Image.ANTIALIAS)
    im.show()
else:
    im.save(output)

I don't think in hex colours, so I added a way to refer to colours by names. I converted this list of Copic CSS colours to a CSV by copying the text, pasting it into a file, and doing a little replacement. It's not complete, but I can copy selected colours from this longer list. I can also add my own. The CSV looks a little like this:

darkgray,9d
gray,c9
lightgreen,cfe8d3
lightyellow,f6f396
lightblue,b3e3f1
y02,f6f396
w2,ddddd5
b02,b3e3f1
...

It doesn't do any fuzzing or clustering of similar colours, so it won't work well on antialiased images. For the simple sketches I make with the SuperNote, though, it seems to work well enough.

I can preview my changes with something like ./recolor.py ~/sketches/"2022-08-02-01 Playing with my drawing workflow #supernote #drawing #workflow #sketching #kaizen.png" --csv colors.csv --freq .,lightyellow --preview , and then I can take the --preview flag off to overwrite the PNG.

Here's what the output looks like after recoloring grayscale images:

View or add comments

One month with the SuperNote A5X

| supernote, drawing, tech

I've had my SuperNote A5X for a month now, and I really like it.

Text from my sketch

I use it for:

  • untangling thoughts
  • sketchnoting books
  • planning
  • drafting blog posts
  • drawing

A- uses it for: (she's 6 years old)

  • practising cursive
  • doing mazes and dot-to-dots
  • drawing
  • reading lyrics

Things I'm learning:

  • Exporting PNGs at 200% works well for my workflow. I rename them in Dropbox and upload them to sketches.sachachua.com.
  • Carefully copying & deleting pages lets me preserve page numbers. I use lassoed titles for active thoughts and maintain a manual index for other things.
  • Layouts:
    • Landscape: only easier to review on my laptop
    • Portrait columns: lots of scrolling up and down
    • Portrait rows: a little harder to plan, but easier to review
  • Many books fit into one page each.
  • Google Lens does a decent job of converting my handwriting to text (print or cursive, even with a background). Dropbox → Google Photos → Orgzly → Org
  • Draft blog posts go into new notebooks so that I can delete them once converted.
  • The Super Note helps me reclaim a lot of the time I spend waiting for A-. A digital notebook is really nice. Easy to erase, rearrange, export… It works well for me.
  • Part of my everyday carry kit

Ideas for growth:

  • Settle into monthly pages, bullet journaling techniques
  • Practise drawing; use larger graphic elements & organizers, different shades
  • Integrate into Zettelkasten

I put my visual book notes and visual library notes into a Dropbox shared folder so that you can check them out if you have a Supernote. If you don't have a Supernote, you can find my visual book notes at sketches.sachachua.com. Enjoy!

View or add comments

2022-08-22 Emacs news

| emacs, emacs-news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Hacker News, lobste.rs, planet.emacslife.com, YouTube, the Emacs NEWS file, Emacs Calendar, emacs-devel, and lemmy/c/emacs.

View or add comments

Visual book notes: Influence is Your Superpower - Zoe Chance (2022)

| visual-book-notes, parenting

It was interesting to read Zoe Chance's book Influence is Your Superpower (2022) with a focus on influencing A-, who is 6 years old and definitely more reachable via her Gator brain than her Judge brain. Shining is easier because I have to connect with just one person who really wants to connect with me. Creating space with the "No" challenge is a little tougher, since she's pretty wise to the way I try to soften nos. ("You always say later!") But I'm definitely going to try to practise doing aikido with her mind, accepting her resistance and exploring it with questions. I can work on using my relaxed voice most of the time, especially since she's sensitive to my tone. I also like the tip about using the Zeigarnik effect to invite her curiosity and get her to ask, maybe by using things like "I might know something that could help. Would you like to hear about it?" instead of jumping in with advice. Paying attention to how we frame things (monumental, manageable, mysterious?) and challenging ourselves to do bigger and better might be fun, too. She's old enough that I might even be able to ask her, "What would it take?" I'm sure she'll pick up that behaviour quickly and ask me that when she wants something, so I'd better be prepared for that!

View or add comments

Making better use of time as we grow more independent together

| parenting, time

I've been coming to terms with the idea that I might not get appreciably more focus time over the next few years, if we decide to either continue with virtual school or switch to homeschooling. It's okay. A-'s going to grow more independent and disappear for long stretches of time, so there's no need to rush or push her away just so that I can do stuff on my computer. I'll miss these days soon enough.

So I just need enough me time to keep myself sane and to make better use of interstitial time as the opportunities arise: waiting for her to wake up, waiting for her to finish reading or playing, waiting for her to go to sleep… I'm starting to be able to find 5 minutes here, 20 minutes there. Most of the time, I can't jump on my laptop. If I'm on a screen, she'll want to be on a screen. Fortunately, my SuperNote doesn't trigger that sense of unfairness, so I can draw or write as long as I'm willing to let her use it if she wants to draw too.

I get some coding time here and there, too. I've shifted to more of an advisory role for my consulting, helping a couple of other developers via text chat on my phone throughout the day and sitting down to code when A-'s watching a movie. Sometimes I work on personal projects while A- watches a movie. She's very good at insisting we both take eye breaks, and from all her questions, I get the feeling that her brain is still very busy processing the Nth time through Frozen or the LEGO Movie. Cool, cool. Might as well use that time to work on continuous improvement. There's always more tidying to do, but it's also good to play around with ideas and try to make things better.

So, what do I want to think about and work on when these opportunities come up? How can I accelerate during those little sprints of thinking time?

  • Drawing and writing: I can collect questions to reflect on or thoughts to untangle, so I can quickly pick one and add to a sketch or a handwritten draft of a blog post.
  • Book notes: I can keep a bookmark in a book and sketchnote a few more pages when I have the chance. Bonus: she sees me reading. Good time to learn more about parenting, education, psychology, and other topics that might be useful.
  • Coding: I can work on setting up my server so that I can write and publish blog posts from my phone, including referring to sketches and converting hand-written drafts.
  • House: I can get rid of more clutter so that I can find things more easily.
  • Tech: I can prepare ePubs and PDFs to read on my SuperNote so that I can learn more about things that will make coding easier or more fun.

What if I want to create more time? How can I get more focused time?

  • E-book reading time: A- quickly finishes books from the library, but the tablet can be a portal to thousands more books. Besides, sometimes she just wants to read, and that's okay.
  • More consistent bedtime: if I go to sleep at a reasonable time, I can use some time in there morning to do stuff. I just have to be ready to set it aside when she wakes up.
  • At the playground: if we're at a playdate, I like to still pay attention to the kids and the other parents. I can bring a 3x3 cube and my SuperNote to take advantage of spare time, though.
  • More books to lose herself in: I pick up lots of book recommendations from Facebook, and the library's a great source. It's a win all around: we get extra exercise walking to the library, she learns about more things and more words, and I get time to focus on something.
  • Take-out/convenience foods, preparing ahead: it takes me around an hour to make dinner. I can occasionally swap some of that time for thinking or coding time by using money. Hmm…

It'll be great. Sure, it's not the sudden jump in discretionary time that I might have had if A- was going to go to in-person school, but this way could be good too. I can grow into it just like A- will grow into her own independence. It reminds me of the way my 5-year experiment with semi-retirement started off with lots of consulting and slowly ratcheted down until I felt comfortable using most of my time for my own stuff. We can learn about time apart together.

View or add comments

2022-08-15 Emacs news

| emacs, emacs-news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Hacker News, lobste.rs, planet.emacslife.com, YouTube, the Emacs NEWS file, Emacs Calendar, emacs-devel, and lemmy/c/emacs. Thanks to Andrés Ramírez for links!

View or add comments