Posts about computing

it's only fitting

Here's a quick-n-dirty Gaussian curve fitter, which I seem to reinvent about twice a year. There are a number of canned solutions that I can never remember how to use, but I also frequently find myself wanting to fit weird functions.

Below in a minimum working example. But the short-short version is

def func(x, *params): ...
x,y = read_some_data()
guess_params = [...]

from scipy import optimize
better_params, covariance = optimize.curve_fit(
    func, x, y, p0=guess_params)

Read more…

revenge of the kludge

I'm playing with termux-api, which exposes a bunch of Android API things to the termux command-line environment. I'm kind of afraid that I'm going to hack together an app using the command line. Excellent and hilarious and a terrible idea. The kind of procrastination that looks like work.

Read more…

your princess is in another window

I've been playing with tmux for making it possible to do more things from one terminal window. Today I realized that you can type tmux commands in one shell, and affect the contents of other windows. You can send keypresses. I knew from the interactive help (C-b ?) that you can send a pane within a window to a new window, but you can also capture panes from one window in another. The command language is the same that you can type at the C-b : command prompt; you can put them in a file and process (from anywhere) with tmux source.

But the cuteness for now is that I can do

make continuous 2>&1 | tmux splitw -dI &
make serve 2>&1 | tmux splitw -dI &

and have two long-running processes putting their outputs into one window, while I can control them from another.

Update: I learned a nicer way.

Read more…

apps from the shell

The incantation that I was looking for to start an Android app from within the shell is

am start --user 0 -n net.gsantner.markor/net.gsantner.markor.activity.MainActivity

The problem is identifying the name at the back.

Read more…

on the phone again

What I'd like to be able to do here is to edit the blog on the phone. But that's going to take a fair amount of automation, because doing anything on the phone is hard.

However, I think I've gotten it.

Read more…

i'm on the phone

I've been trying to get to a point where I can edit my nikola blog stuff on my phone, and I am slowly figuring out how. Android does lots of careful sandboxing, and I have to work to undo it — especially since my preferred Android text editor, Markor, is intentionally unaware of any kind of sharing. I'm going to end up doing stuff in make, I'm afraid.

Read more…

markdown made easy

The installation for Jason Blevins' markdown-mode is so easy that I thought I wouldn't bother to write it down … but then I looked in my note-taking place and I couldn't find it.

It's as simple as M-x package-install RET markdown-mode RET.

Everybody is using a package manager these days, and it's great.

long lines at the table

Working in an emacs buffer where I don't want to give up whitespace-mode but I have a line that has to be long. The magic is

(setq-local whitespace-line-column 100)

who is that character?

If I want to type $a \times b$ without spelling out \times, here in this lovely magical future, I should just be able to type ×. There are different ways to do such things. What are they? Of course there are websites. But I want command-line tools.

watching for changes

One of the differences between the kind of text-mode/compile interface that I like to use, versus the WYSIWYG-style editors that the rest of the world has been using since forever, is that you generally have to do something or other in order to see whether your changes are having any effect. I've spent some time yesterday and today trying to come up with a mechanism to ease that transition, and I think I like what I have.

the clipboard

Reminded today of Windows's clip.exe, which reads its standard input into the Windows paste buffer. That's the way to copy Linux/WSL stuff to Windows. Mousing in the terminal window works ... sometimes. But Emacs takes over the mouse, and the terminal copies my whitespace-identifying characters.

The magic is M-| clip.exe, which runs shell-command-on-region.