mindstalk: (CrashMouse)
My new work laptop has Windows 7 Pro at base, which we need at some point, so for Linux we've been trying to put Linux into a VMware Workstation. Since I use Arch, I tried for Arch, even though it's not listed as supported. It's been a fun couple of days. Some of that my own fault: though I did wonder about boot information, I missed the "choose and install bootloader" instructions three times running. Some, well, while Arch does tell you to enable dhcp, you have to click through and read everything; it's easy to think it's up by default.

Then there's VM Tools. Supposedly even VMWare tells you to use "open-vm-tools" rather than what they provide, but a couple webpages said certain features would work with the official tools. But its installation script failed straight out of the ISO, on a clean install. That's never good...

There's a site OSBoxes.org, which provides VMWare and VirtualBox images of various OSes. No idea who they are, and I'd be paranoid about trusting some unknown OS image. OTOH, I did end up downloading a few to see if things would work at all -- Arch CLI, Arch KDE, Ubuntu.

Discovery: don't think I like KDE or Ubuntu's UI, but the latter did have full screen and cut-and-paste between Linux and Windows. The Arch ones didn't seem to, so it didn't seem worth trying to track down a difference in configuration.

One cool thing about VMs is that you get to treat 'machines' as documents. I'd started making copies and snapshots, and when messing around with official VM Tools failed and broke things, I was able to pop back to an instance before that. Woo.

And with that, trying open-vm-tools again *very carefully* and avoiding conflicting paths, I got shared folders working -- even without the auxiliary tool the docs said I would need. Sweet! But fullscreen and pasting still didn't work.

OTOH, by default I use startx and the ancient environment of twm. xfwm4 didn't 'work' either. Finally I tried Cinnamon... the window manager of which promptly crashes. But the session hangs around, and voila! fullscreen and paste! So I guess I'm going to need some sort of full session for this thing, not just a WM.

Also twm was able to take over the apps, and then the Failsafe Desktop or something becomes a window managed by twm. That's just surreal.

LXDE was happier starting from startx, and that's what I've got now.

Still missing: touchpad scrolling, which is a big loss. Hope I can get it...
mindstalk: (Default)
When I was a kid, I learned -- probably in The Gentle Art of Mathematics or some such book -- how to convert numerals from one base to another. Divide n by newbase, record the remainder, replace n by the quotient, repeat until quotient = 0, then write the remainders in reverse order.

This manifestly worked, if you did it, but always felt backwards to me, doubly so -- once for the reverse order thing, and once for the fact that you're only using remainders, not quotients, or so it seemed. Plus, though it gave the right answer, I didn't have much sense of why it worked.

Well, I was thinking about it early this morning in lieu of sleeping again, as I do, and came up with a method[1] that's slow but does both use quotients and yield the digits in MSB (most significant 'bit' first, descending significance). And then I thought about the old remainder method again, and it made more sense[2], and I also realized a key mismatch: the whole cycle of dividing by newbase calls up long division, may even involve long division if newbase is multiple digits in oldbase, and long division gives its answer in MSB. The remainder method chews up the number LSB, and gives the newbase numeral's digits LSB, so it's not backwards at all by its own lights, but it is LSB instead of MSB. Works fine if you write the units first and work to the left.

[1] Trial and error: multiply by increasing powers of newbase until the quotient is zero; backoff to the preceding power, and the resulting quotient is the first digit (MSB) of your answer. Repeat for the remainder. So (base 10 to base 10, for simplicity), n=742: find that 742//1000 = 0, 742//100 = 7, so 7, then repeat for 42. A subtlety is that numeral-based long division may not work, e.g. if you're converting a binary numeral to base ten and dividing by '1010': binary quotients are only 0 or 1. You'd have to go back to basics, division as "how many times can I subtract b from a?"

[2] 10 to 10 again: n=742, divide by 10 and get 2, that's your units; now shift right (or use the quotient) to get 74, divide by 10, get 4, which is your tens digit, and so on. Thinking about the relation between dividing by 2, and shifting the binary representation of a number to the right, made it all clear.

Dunno if I'm making it clear. I think the core insight for me is simply "base conversion felt backwards because you felt it should go in the same order as long division, but it doesn't and is doing something else. Also "put the remainders aside and write in reverse order" is less clear than "write the remainders as you find them, but right to left."
mindstalk: (Default)
After a couple of visits, I wasn't expecting surprises from Glendale, but that was foolish of me. On Monday I went on one of my walks, soaking up sunlight and enjoying a close hill to walk up, heading toward streets I knew climbed up while still have sidewalks. After a while having done so without water bottle seemed foolish, but I found myself close enough to push on to the Brand Library -- "currently open" on Google Maps -- where at least there'd be water, and supposedly some park.


So suddenly I find this:





Inside I find a library with the expected bathrooms and water fountains, but also extensive art galleries featuring the work of various artist collectives. When I was done with that, and paid more attention to the collection, I found nothing but art and music books. Turns out it had been the mansion/ranch of Brand, who held parties you had to fly in to attend. The property was donated to Glendale on the condition of retaining an art focus, and so we find a public library branch that's devoted to the arts.

There was also a teeny tiny Japanese garden (free!) on the property, along with some doctor's Victorian house that had been transplanted there, and roads up into "wilderness area".

As a bonus, when I finally left, I took a different route, that happened to take me to the "Kenneth Village" I'd seen hinted at on directional signs. Nothing *too* special, just a little cluster of shops and restaurants, but as northern Glendale is pretty thoroughly residential, it was a nice surprise too.

recent movies

2017-Mar-05, Sunday 12:28
mindstalk: (rogue)
As usual when visiting S, I get exposed to movies.

* Moonlight. Emotionally powerful, but kind of unpleasant for me. Would probably not watch again.

* Castle in the Sky: I've seen this at least three times, 2007, 2014, and now. I keep liking the movie, but checking my notes, I keep forgetting what I observe about it, like how its a visual melange of motifs from other Ghibli movies, or the fact that the dubbed cast includes Rogue and Dawson Leery. (That it includes Luke Skywalker I do remember.) Has a good dub... I'm not 100% sure if I've actually watched it in Japanese, though I probably did in 2007.

* The Tale of Princess Kaguya: I've wanted to see this for a while, and finally did! Beautiful and sad. Different visual style from the usual Ghibli. Decent dub.

Castle notes over the years:

2007:
It's Gort! Who attacks Gort? Oh, secret heirs... visual melange of
Cagliostro and Nausicaa in one scene.
Behind the Microphone: James van der Beek (Dawson) as Pazu. Mark Hamill
(Luke) as Muska. Anna Paquin as Lucita. Now to compare Laputa and
X-Men directly and see if her voice changes.

2014:
movie: Castle in the Sky (re) big hit. scary for M.
I noted it's kind of a theme or motif mashup of Nausicaa, Cagliostro,
and Spirited Away. The princess and evil relative from Cagliostro, the
nature and God Monsters of Nausicaa, the engineer guy from Spirited Away...
her pigtails get shot off, making Sheeta look more like the standard heroine
not just Mark Hamill. Anna Paquin as Sheeta(!), James Van Der Beek as
Pazu, Mandy Patinkin (Inigo Montoya as Louis?). I don't known Cloris
Leachman as Dola, but others do, and long career

2017:
M got excited and squirmy a lot.
engineer in Castle reminds me of stoker in Spirited.
Ponzu dad's drawing looked like long haired Mushka.
crystal scene like spirits in Mononoke
pink skull pirates.
pink pants
I wondered if they wear the same clothes, she actually changes a lot. four outfits.
flooded city like Cagliostro
inscription like cuneiform
squirrel things like Nausicaa
Egyptian art style on Laputa
700 years gap
robot like god warrior.
sodom, Indra's arrow.
progress, can't stay hidden
shoots her pigtails off

life stuff

2017-Feb-25, Saturday 21:33
mindstalk: (YoukoRaku1)
I might have good news finally, but I feel reticent until things solidify more.

All the manga I follow feels in slow hiatus, with a couple exceptions. I got to read two Citrus chapters at once, by dint of discovering a new translation group that's a head of my earlier source; of course, Citrus itself seems in a slow burn of dancing around the putative relationship. And Mousou Telepathy is an odd thing that comes out with two pages every day, or maybe the translators do, kind of like a webcomic with a weird origin.

I've read six Dresden Files novels. I wouldn't call them deep, but they're fun. Necromancy + dinosaur skeleton went exactly where I thought it would.

I've been doing lots of RPG theory reading, specifically most of The Alexandrian. Kind of makes me want to run an old-fashioned dungeoncrawl (or a new-fashioned reconstructed one, where the 'dungeon' is justified as some high-magic weirdness like a Madoka Witch). Beyond the "prep situations not plots" that's like the Lazy GM advice I've seen elsewhere, he's got interesting ideas about game structure, and how dungeoncrawls have natural structure to keep the players moving. (Check room, deal, check next room; seek treasure), as well as how to make interesting dungeons.

I was talking with a friend about how kids make amazing amounts of noise for their weight, by stomping around; he opined that parents wouldn't want to train their kids to be stealthy, since noise is how you can keep track of them. Another parent disagreed, he'd like his to be quieter. I just know that it took S's kids years to figure out how I was so quiet and surprising in our chase games, if they even have, yet. (I think G2 has, she's crossing the threshold into adult models of causality and manipulation, like spotting how I distract the younger kids when they're being pains, and thanking me for it.)

Weather here has been freaky warm, as high as 24 C. Boston. February. Well, the snow went away fast! Oh yeah, being buried in snow seems to have been really bad for my bike, the right brake doesn't work well and the left brake squeaks. I'd thought I might ride it to filking last night, but aborted after a few blocks and took the T.
mindstalk: (Default)
Ari told me a trick he uses as a GM for naming NPCs: pick a language to be thematic, type words into Google Translate, use. So one NPC is Hungarian or something for "Betrayer", and is intended to backstab the PCs at some point, and the players have no clue.

Neat trick, but one not relevant to most of my PCs these days, where I expy some anime heroine and don't try to hide my work. (Latest: Kyouko the Dungeon Slayer, an adaptation of Sakura Kyouko.)

But someone was recruiting for an all-evil PbP game, which isn't my usual thing, but I got tempted to try to think of something anyway, It's D&D3.5, so I figured I'd start with a druid, for maximum mechanical cheese. Evil druid? Sure, he wields the power of nature for evil. Or he wields the power of nature, and is a selfish jerk. If you want philosophy, you can talk about predator/prey, nature red in tooth and claw, social darwinism.

Race? (Meaning species). I like elves as an idea, but have been avoiding them, because a 1st level 100 year old character just hurts my head. But for the character I was forming? The guy who can feel superior because he lives 10x longer than you is a perfect fit.

And even better, there's the gray elf subrace, with +2 Int. Literally smarter than you. (D&D swaps gray and high elves from Tolkien: "high elves" are like the Sindar default, gray elves the longer-lived and smarter and more arrogant 'Noldor'.)

Great, a racist gray elf druid! What to name him? I tried thinking of 'elvish' names on my own, but wasn't getting far. (I hate coming up with names.) Time to try the language trick! What are elvish languages? Tolkien was inspired by Welsh and Finnish, Order of the Stick uses pseudo-Latinate names. I started with Welsh. What's a word? Well, 'racist'. So I type that in... and get 'hiliol'.

Hiliol the elf. I dunno about you, but I figured I was done on the first try. Feels vaguely elvish, doesn't have an obvious gender. (I was figuring I'd go for androgyny, a la Vaarsuvius in Order, though he's since become male -- trying to improve the human stock by fathering lots of half-elves. But anyway.)

That was a stroke of luck, really; I've since tried some other words, and they translate to words that are so flagrantly Welsh as to be intrusive. Like 'twyllwr' for "deceiver" or 'celwyddog' for "liar". (Hiliol's Big Crime was fraud, trying to convince foolish humans that he could give them elven lifespan.)

Finnish could have worked, its 'racist' is "rasistinen", though I just realized it sounds like an import of 'racist', so maybe not.
mindstalk: (Default)
(Definition: solving a problem or writing code in an interview, in front of people, under time pressure. Video/online counts as well.)

I'm not sure I've gotten much better at this in the past year. It's one thing if the problem is one I already know and I just have to write code; I think I regurgitate under pressure fairly well. But if I have to really think about the problem then it feels like my IQ drops 20+ points under stress and being stared at. And when I come up with one idea for a solution, it's hard to try to think of others that might be better in some sense -- after all, the clock is ticking, and I have to start writing code! Not to mention the fun of having to write correct code without backup documentation or a compiler -- my memory prioritizes the stuff that's hard to look up, like What You Shouldn't Do, or Where Information Is, over the stuff that's trivial to look up at need.

As for actually being creative, that goes a lot better when I have time to relax, or step away from the problem and not consciously think about it. A lot of my best solutions just come to me when doing something else, or musing in bed or the shower, or walking.

Post prompted by Thursday's experience, where I was asked to construct a relative path between two directories, and I saw it as a tree problem and hared down making C++ trees with nodes and everything. At the end I asked how I'd done, and was told "well, this works, or would work with a bit more polishing of the code, but there's a simpler way with just lists." One minute after leaving the building I saw what that would be, and at home it took me 18 minutes to code and debug, which I e-mailed in, but apparently got no credit for that.

I did better Monday, with some basic linked list questions; that rejection was "you did well and seem a fine technologist, but not commercially experienced enough". Which is back to the Catch-22 of not being able to get experience because I'm not experienced enough.

On the flip side, Wednesday had a video interview where I had no idea how I did, but they want me to go to NYC for an onsite next week. So yay, progress... of course, that'll probably be more whiteboarding.
mindstalk: (angry sky)
I've started studying JavaScript a bit, as you might guess from recent posts. It's struck me as a mix of Perl, Python, and crack. It's got some neat things, especially in comparison to one language or the other. And it's got lots of... wtf things.

+: exponentiation operator; nested arrays and objects (dictionaries) (without Perl's references); first class functions and lambdas and closures, including nested functions (unlike Perl); Perl-like push/pop/shift/unshift array operators (but what's the performance?); consistent 'valueOf' and 'toString' methods; JSON; multiple kinds of for loops; Perl style labeled break and continue; some convenient conversions (but see below); nice Date methods.

-: oh boy.

* JSON stringifies nested structures nicely, but simple output doesn't: [1, [2,3]] outputs as [1, 2, 3].
* (object1 == object2) is always false, no matter the underlying values. This holds for arrays and Date objects too. Nothing like Python's structural equality, or even that of STL containers.
** But you can do *inequality* comparison: ([1,2,3] < [2,2,3]) == true.
* strings take negative indices a la Python, but arrays don't.
* there's a typeof operator, but it just says 'object' for arrays.
* "5"+2 == "52" (convert 2 to "2", concatenate), but "5"-2 == 3 (convert "5" to 5, subtract.) And no Python string multiplier like "a"*2 == "aa".
** As Avi noted, it gets even weirder given that the values could be hidden in a variable. a+2=="52", a-2==3
* [1,2]+[3,4] doesn't concatenate arrays, doesn't add by element, doesn't give a type error, but gives... "1,23,4" (turn arrays into strings, concatenate without delimiter.)

My friend Mark linked me to https://www.destroyallsoftware.com/talks/wat which gives some more:
* []+{} == [object Object]
Ok, addition is commutative, right?
{}+[] == 0
And for luck: {}+{} == NaN
As above, []+[] == ""
** Actually, on playing with typeof, I think those are actually all strings. "[object Object]", "0", "NaN". OTOH, {}+[4]+5 == 9 (but typeof string)
**
>>> 5+{}+[4]
5[object Object]4 // because of course it does
*
return
  x;

turns into
 return;
 x;



* All numbers are 64-bit floats; you can still bitshift them, but as integers, so 5.2 << 2 == 20. This makes more sense when I remembered that floats are weird, not integers+fractions, so a simple bitshift of the fraction wouldn't make sense.

Hoisting Shadows

2017-Feb-05, Sunday 11:35
mindstalk: (Default)
A bit after writing the previous post on shadowing variables in JavaScript, I came across this page on hoisting. JavaScript re-writes your code so that declarations but not initializations to the top of current scope, meaning the script or function[1]. So

console.log(a);
var a=5;


turns into

var a;
console.log(a);
a=5;


Put that way, it's clear why the problem happens, if not why the language was designed this way.

Does the same thing happen in Python? Searching did not get clear results. I saw pages contrasting JavaScript with Python, which doesn't even *have* declarations. OTOH, the same behavior occurs. So... I dunno.

[1] JavaScipt does not have block scoping the way C and Perl[2] do; scopes are delimited by curly braces, but random curly braces do nothing to isolate variables.

{ a=5; }
console.log(a);


will work just fine. :(

[2] As I was verifying this in Perl, I ran into behavior I'd forgotten. I'd thrown in "use strict;" but wasn't getting the errors I expected. Eventually I recalled that $a and $b have special meaning in Perl (I think for comparison functions), and I guess are pre-declared, and I was using $a a la the above code, so strict didn't complain about trying to access $a before assigning to it. Sigh.
mindstalk: (Default)
Months ago, Robbie had found this scoping problem in Python, which I reduced to essentials.

I've started finally learning JavaScript, and it has nicer lambdas than Python, and proper hiding of nested functions unlike Perl. But it has the same scope problem:

g1 = 12;
function func() {
  document.getElementById("demo").innerHTML = g1;

  var g1 = 5;

}
func();


(I'm not including the HTML framework because DW/LJ would yell at me if I did.)

Output is 'undefined', rather than 12. As in Python, the local variable further down shadows the outer scope variable (doesn't matter if the "g1=12" has a 'var' before it) even for lines before the local variable.

As mentioned before, Perl has proper lexical scoping here (though not for nested functions.) I don't think I can even create similar code in Scheme/Lisp, where the scoping is explicit with parentheses. (There's 'define' but I think that makes a new global, and it didn't work.) In Ocaml I have

let g1="10";;

let func () =
  print_endline g1;
  let g1="cat" in
    g1
  ;;

func();;


Which I suspect is as explicit as Lisp parentheses, in its own way; the print line is obviously outside the following "let ... in...".

PC parents

2017-Jan-30, Monday 19:03
mindstalk: (Nanoha)
If I ever GM an RPG of my own, I think I'll ask the players to give some indication of their parentage or how they were raised. Doesn't have to be detailed, maybe not even named, but something about where they're from and who raised them. Everyone has parents, or some substitute, after all, rather than springing out of the mists. And no amnesia card allowed.

(This is partially stimulated by Nanoha A's, my biggest gripe regarding which is the total lack of explanation of how Hayate is living alone as a 9 year old. If parents died recently they're never mentioned, if they died when she was a baby... who raised her and taught her stuff?)

But then I wonder, would I be being hypocritical? Have I done this for my own PCs? Answer seems to be "I didn't, but now I do." And I'll chronologically list my PC backgrounds. If you find that boring, which is understandable, you've been warned.

Read more... )

So if you bother reading all that... the answer is yes, I do do it more, though the increase hasn't been monotonic. Kind of depends on my inspiration and the nature of the game: some inspire or require more effort than others. In particular I've gotten pretty pessimistic about the lifespan of a random play-by-post (PbP) game, and am not inclined to put too much effort into them. The Yona characters were earlier... though I also like adapting Yona to various settings. Might help that the original character is "medieval", unlike Hayate or Diane.

fast array rotation

2017-Jan-28, Saturday 13:17
mindstalk: (Default)
A simple problem I'd never had occasion to think much before, before I saw a sample coding problem.

How to rotate the elements of an N-element array by k spaces? An obvious way is to shuffle it one space, k times, but that's slow, O(N*k). Faster, which I saw about as soon as I thought about performance, is to use a second array B, where B[(i+k)%N] = A[i]. But that takes O(N) extra space. Can you do better?

Yes, as I realized at 5am. For each element A[i], move it to A[(i+k)%N]. O(N) time, O(1) extra space. Can't beat that!

Except some mildly tricky math intervenes: the natural approach only works if N and k are relatively prime. A more general solution is

let g = gcd(N,k)
for i in [0,g)
  for j in [0, N/g)
    shuffle element k spaces


Despite looking like a double loop, it's still O(N), with g*N/g iterations.

I've also learned that C++ has a gcd function now. std::experimental::gcd, in the header experimental/numeric. C++17 moves it out of experimental but even g++ isn't doing that by default.

The really annoying this is that this is the sort of solution that comes naturally to me lying in bed, with little conscious effort, but that I'd likely fail to get in a whiteboard session or timed coding test, due to stress dropping my working IQ.

Moana

2017-Jan-22, Sunday 16:54
mindstalk: (lizqueen)
Saw it this afternoon. Fairly good. Or at least it had catchy songs (if not as catchy to me as Frozen) and I teared up a few times, so it does the job of a good Disney musical-movie. I did wonder about the response of native Hawaiians or Polynesians to some of the cultural depiction. Checking Wikipedia... the main criticisms there are about the lack of a strong goddess, and Maui being an "overweight" buffoon. So "culture is okay, but the gods weren't." Also controversy about a costume.

Absolutely no romance, even less than in Brave.

Applying A*

2017-Jan-17, Tuesday 12:55
mindstalk: (Default)
I've played a lot of freeciv and freecol over recent years. Both games let you order a unit to go to some square, and hopefully it takes the fastest route there. The 'world' is a square grid, of various terrain types and associated movement costs -- e.g. plains or desert take 1 move, but mountains take 3; roads and rivers take 1/3 no matter what terrain type they're laid over.

A* is this sweet magic algorithm for finding shortest paths in some graphs efficiently, vs. doing breadth-first search in all directions, but I was having trouble applying it mentally. I was using the common Manhattan distance heuristic, h((0,0),(x,y)) = x+y, and I wasn't getting good results: the algorithm would cheerfully march down a straight plains path to the goal, while ignoring a path that might step away and into mountains, but then ride a river to the goal much faster.

So I backed off, and thought about BFS. I realized that would work better if instead of naive BFS, enqueuing grid squares as you found them, instead you ranked them by total travel time so far. This is basically A* without a heuristic. Instead of exploring all paths N squares away, you'd explore all paths N moves away; it would still be radiating in all sorts of directions, but at least you'd find the shortest path to the goal.

Then I realized I'd been using the wrong heuristic; the right one should be the shortest possible journey. Or as WP says, "it never overestimates the actual cost to get to the nearest goal node." So the heuristic in this application has to consider rivers and roads, such that h() = (x+y)/3, not (x+y). This works much better: the plains march looks less attractive as it advances, converting cheap heuristic moves into actual plains moves, and the "mountain and away" move gets a chance to be considered.

Actually, units and roads can go diagonally, though rivers are rectilinear, so the proper heuristic is h((0,0),(x,y)) = max(x,y)/3.

Actually actually, infantry units only have one move, but are still guaranteed one square of movement per turn, so can march across mountains as easily as across plains; it's mounted units, with e.g. 4 move in freecol, that really care about base terrain type. Also fractional movement can be useful, e.g. I think a unit with 2/3 move left (after moving on river) can still move onto an adjacent plains.

Headphones! 2

2017-Jan-16, Monday 19:08
mindstalk: (Default)
Ari, one of my hosts, said the other night that my (Panasonic) phones must be really good, that he'd been yelling at me from the kitchen and I didn't hear them. I don't know if he could have been yelling that loudly, but they certainly obscured something. And they're working pretty well now, there are Fanw and two kids six feet in front of me, and a bunch of gamers 10 feet away, but mostly I hear Christopher Franke.

If nothing's playing then there's some attenuation but not much blockage, not as much as earplugs, maybe. But with sounds, I mostly hear the sound.

Maybe I'm playing it too loudly. But that seems unlikely, I've never been a high volume guy. One of those people cursed with sensitivity to faint sounds, physical flinching from loud ones, but impairment in understanding speech...
mindstalk: (Enki)
As I enter Japanese words, sometimes I mess up, or am guessing at what I hear in anime. I've noticed that almost anything I enter still has a meaning according to my tools. And words with the same pronunciation seem more common than in English.

As W reminded me, Japanese doesn't have that many syllables. There are about 50 basic syllables, maybe 80 including the compounds like 'gyo'. At 50, there are 2500 pairs, and 125,000 triplets. Even a large vocabulary can fill up most of that. By contrast, I read once that English has over 1000 syllables, which means 1 million pairs, and 1 billion triplets. Mind you, many of those won't be pronounceable, or valid under English phonotactics, or distinct[1]. But still, lots of words -- even 99% discounting would mean 10 million triplets.

Headphones!

2017-Jan-13, Friday 19:27
mindstalk: (Default)
Have I talked about this before? Feels like I might have, but don't see anything in the past few months. I use earbuds a lot, to play music at home, or of course out and about. I've gone through a lot too, as they kept failing in one ear or the other, especially after being carried in my pocket for a while.

I remembered Panasonic as being a solid brand for electronics, looked up online and saw that they do make earphones -- though none sold in local stores -- and ordered three, figuring even Panasonic couldn't prevent thin wires from breaking. $10 each, supposedly good performance, certainly fine by me.

Aaaand I may have outsmarted myself, I'm still on the first set. Granted I was protecting it more, putting it in a ziploc bag before pocketing it, largely to reduce tanglement but presumably also reducing friction. But I lost the bag at some point, and it's still working.

I actually have five sets. One I'd bought earlier, the three Panasonics, and one we found on the floor of Grendel's one night and no one claimed. I also had 3 $1 sets I got from Dollar Tree, but they smelled so strongly once I opened the packets that I got paranoid about touching ultra-cheap Chinese products, and I think I threw them out.

Technically all the ones I have are in-ear, so they stay in better and there's more noise isolation, especially from the Panasonics.

Really bad typo

2017-Jan-07, Saturday 22:45
mindstalk: Tohsaka Rin (Rin)
Typos happen. Usually they don't change meaning too much. But I just caught one of my worst ever: I looked back at e-mail with W about meeting up for something, and where I meant "That works for me", I'd sent "That's work for me". I am mortified, and worried she's been feeling hurt the past couple days.

Re-reading is your friend. And your friends' friend.
mindstalk: (outhead)
Date your entries. "When did I write this?" can be a fun detective exercise but not in the aggregate.


Fully date your entries. Yes, it's annoying to write the year all the time, but much later, when paging through (paper or textfile), you'll thank yourself for not having to find the beginning of year marker, assuming you left one.

If you have multiple diary books, putting the date range on the covers is nice too.

***

I found a book split between my USSR trip in 1991 and life notes in 2001-2002. Very frugal of me but makes the diary hard to order. Thanks, me.

A bunch of my diaries actually have class notes in the front, diaries in the back; school year ends without filling the notebook, so there was spare space...

***

On the electronic front, my journal files have a format of

{{2014 Dec 3}
life stuff
here

{special event like Arisia
whole bunch of lines
}
}

Not exactly sophisticated, but allows pretty free-form entry, while delimiting entries on characters you can %-bounce on in vi, while also not competing with the parentheses one might normally use (including smiley face parentheses, which don't close). And yes, I have a script somewhere that checks for mismatched curly braces. I designed the date header with some idea of easing parsing by simple scripts, though it hasn't come up much.

As you can see, the braces recurse, so I can group logically connected paragraphs within a day's entry.

One could obviously make the format smarter, with tags, or {{event} stuff}, but even what I have has been pretty helpful. I can find a day's entry quickly, beginning and end, and see the bounds of long sub-entries. There are ad hoc tags: "book:" at the beginning of a line for books I might want to read; "movie:" at the beginning for movies I've seen (yes, not very consistent); semi-regular tags for regular social events, to enable searching for those; "me on " for links to stuff I write elsewhere. Could be better though, like having an index at the top of such tags for standardized use.

In theory I could write a script to bound searches, e.g. looking for regexes within entries of a certain date, basically primitive database functionality. (Or you could put entries in a real database, but I'd rather stick to textfiles for stuff like this.) I haven't felt the compulsion to go beyond searching in less or vim, though.

booyeah, I'm good!

2016-Dec-31, Saturday 15:01
mindstalk: (squeee)
So some months ago I worked on an AVL tree in pure C. My main goal was to get self-balancing happening at all, to demystify that process, and I did that; getting the code to be robust or even asymptotically appropriate (I'm still calculating heights every time I need to, not caching and updating them) was far down the priority list. So, while I tried to be correct in handling memory, it would not have surprised me if subtle bugs still existed.

My past work experience didn't emphasize use of static analysis tools. I think I played with lint a bit on my own, but relying on it or valgrind wasn't a thing. I finally investigated them today, ending up with cppcheck for source code check, and valgrind for what it does. And ran them on my directory of C/C++ exericses, which as small exercises, could easily have had lots of problems.

...not so much! cppcheck found a few problems, most notably a missing return value I wasn't testing properly in linked list, and a realloc bug[1] in my memoized Fibonacci table, and an unset ID variable in a threading program, but nothing else, including in the AVL tree or the new C++ hash table.

valgrind found some memory leaks in linked list and AVL tree... only because the testing main() for each was creating structures and then not freeing them before exit, because who cares at that point? With a manual destroy added, both check out clean. Which the list really should, it's pretty simple, but I'm stoked about the AVL tree doing so, since it's complex and memory correctness wasn't a top priority. Seems like I do have good habits.

There's also clang's static analyzer, supposedly deeper than cppcheck, though much slower to use. It's happy with my codes too.

Of course, valgrind can only test what's executed, so more use might uncover more bugs, but still, I feel good.


[1] ptr = realloc (ptr, ...) sets ptr to NULL if the realloc fails, which means a memory leak if nothing else is pointing to what ptr had been pointing to. Not having used realloc much, plus also not worrying about errors in a tiny program, this didn't stand out to me.

April 2017

S M T W T F S
       1
2 345678
9 10 11 1213 1415
161718192021 22
232425262728 29
30      

Expand Cut Tags

No cut tags

Style Credit