Anyone else having trouble with actually sitting down to write? I have a good topic but I'm finding it hard to make time for writing. After I look after my responsibilities, I don't have much impetus left.

@bradfonseca I find it really hard. Last year I tried to write one post per week, and gave myself permission to have 4 weeks off. I did OK, and now when I'm trying to get one every two weeks it feels more relaxed.

Picking one from the long list is hard. I wrote some Python to just pick one at random and I write about that for a minimum of 10 minutes. Sometimes I then discard it and pick another, sometimes I discard it and quit for the day, sometimes I keep going, and it's done.

But it's hard.

@ColinTheMathmo
I like your idea of randomly picking a topic and just writing on that for 10 minutes to see where it goes. My challenge is having a big enough list to choose from.

I'd love to see your Python code for the topic randomizer.

@bradfonseca Choose random line from given file in Python 2:

#!/usr/bin/python

import random,sys

line = 'No lines given!'
p = 1.0
n = 1
filename = sys.argv.pop(0)
while sys.argv:
filename = sys.argv.pop(0)
handle = file(filename)
this_line = handle.readline()
while this_line:
r = random.random()
if r<p:
line = this_line
n+=1
p = 1.0/n
this_line = handle.readline()

print line,

Not exemplary code, but does the trick.

@ColinTheMathmo
"Not exemplary code, but does the trick."

That's the beauty of Python. You can hack together something relatively quickly to get a computational job done.

I may borrow your code for personal use, if I have your permission.

Follow

@bradfonseca You may certainly use the code, with all the usual caveats.

· · Web · 0 · 0 · 1
Sign in to participate in the conversation
Mathstodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!