Tagged with tech

Posting Images from Android to a Static Site

posting-from-android

I didn't post this picture because it is in any way interesting in itself, but because I can! From my phone, that is!

Let me back up and tell you why I find that exciting. This site is statically generated and a new blog post is added via a markdown file, re-compiling and uploading. This means firing up the text editor and some quick command-line actions after finishing the writing. This fits me perfectly fine, most of the time.

But when it comes to images, I found always it cumbersome to first download them to my laptop for processing and inclusion in a post. Which is why I finally got around to figuring out how to post them directly from the phone that takes the image.

The centerpice for making this work is Termux which gives you a full Linux-environment on Android devices; it's really really good and can do much more than I describe here. Termux supports the "Share with..." mechanism and allows me to execute a script with the shared file as argument. So I adapted my script that prepares the markdown file and resizes the image for this purpose.

Now when I share an image from my phone with Termux, the following steps happen:

  • The image is saved in Termux.
  • My script is called with the image location.
  • It asks me to enter a title which is used as the post title, the URL-slug and the filenames.
  • The Markdown template with this information, the image link and date/time is prepared, and saved.
  • A text editor is fired up to verify and/or write an extra line in the mardown-file.
  • The image gets resized and renamed accordingly.
  • The files get added and committed to the repository, and pushed to GitHub.
  • Finally, Pelican is told to re-compile the site into HTML, make the smaller inline-version of the image, and upload everything with rsync to my RaspberryPi-server.

Done.

Tagged , ,

Comments Are Back

The possibility to leave comments on blog posts is back! Thanks to Isso which provides a stand-alone solution for self-hosted comments. Please let me know if there are technical hiccups...

I might even import the old comments from the Wordpress-site at some point, they are not lost.

Tagged ,

It's a Dell!

The question I asked myself almost three years ago, what new laptop to get, finally got resolved a few weeks ago. The old Thinkpad X230 still has not broken down, but I need to compile things at work more often nowadays, so a more modern machine made sense.

Thus, after some more agonizing, I bought a Dell Latitude 5401 with an Intel i7-9850H, 32Gb of RAM and a fast SSD. The not-tiny formfactor suits me well and I like the larger screen. Skipping the Microsoft-tax by ordering it with Ubuntu pre-installed is a plus. So far it does its job well enough and I do not regret the choice.

Tagged

Site Update

This site no longer runs on a small virtual server in some data center, but it just moved home. Literally home that is, it now runs from my old RaspberryPi3 that sits on top of my fridge. This became possible because we got fast internet into our cottage in the middle of the Swedish forest.

With government subsidies and spreading costs over the local association, getting connected cost us 1800 EUR in total, which is a steal because they had to dig an extra kilometer just to get to us. Yes, there is an acutal glass fiber running all the way into our kitchen and I could get 1GBit/s up and down, if I had the use for it.

I was shortly considering switching back to Wordpress here, but decided against it, even though there did not seem to be a performance problem on the RasPi. I might still do it eventually for the comments and easier posting from mobile, but I would have to write a script to insert the posts that I made in the meantime from the markdown files into the database, since the RSS-import of WP fails.

Caddy is no longer just a proxy for nginx to get automatic LetsEncrypt certificates, but it serves the files itself now and interfaces with fastcgi, among other things for my instance of TT-RSS that I use as my main news and blog aggregator.

Tagged , ,

Quantified Bull

quantified-bull

I admit, when I started running some eight-or-so years ago, my first smartphone with a GPS-tracker was a strong factor in keeping the motivation up. The feeling of "living the future" was fun, and measuring exactly how far and how fast I was going made progress easily visible.

In the meantime I've "logged" most of my exercise, be it runs, hikes, cycling, or skating on Swedish winter lakes. But I never got into wearing a heart-rate-monitor, or tracking my weight more than twice a year. Plus, I rarely checked the long-term statistics of my exercises - after all I had reached a level of fitness that I am satisfied with and lack the ambition to reach any lofty goals.

So instead of going along with the "quantified-self" movement, wearing a step-counter with unobtrusive heart-rate monitor, or tracking my diet, I recently found myself not even bothering to turn on the tracker-app when I bike 20km to work, and back. Running without a GPS-watch lets you pick up some mushrooms and look around for more, without the nagging feeling that your average speed statistic will be messed up by this. I generally prefer not being in a hurry and physical effort does not need to come with feeling rushed.

Then there is the whole data privacy aspect. Do I want everybody to exercise more and be healthier? Sure. Do I want insurance companies to punish people who are not willing to prove their exercise by sending them their "quantified self" data? I think not.

Whereever data accumulates, it creates desires from companies and governments to use it for originally unintended purposes.

Tagged , ,

Twitter

I added my twitter timeline to /twitter.

This obviously violates my principle to not embed external content, for speed and privacy reasons. But it only affects that one page and I don't want to code a more sophisticated integration right now.

Tagged

Terminal blogging

Termux, Git and Pelican

I no longer carry my laptop home most days, just an Android tablet. To be able to blog with that setup, I installed Termux which provides a nice self-contained Linux environment with Apt to install more software goodies. The "Hacker Keyboard" makes vim and the command line more usable on a tablet and now I can quite comfortably edit blog entries in Markdown, commit and push to the server where Pelican re-builds the HTML site automatically.

For blogging pictures and URLs, they can be shared to Termux from other Adroid apps, I just had to drop a small script that writes the URL from the clipboard to a text file.

Tagged ,

Spy Headphones

I remember it blew my mind a little in high-school, that loudspeakers and microphones are the same thing, in principle. A membrane with a magnet and a coil that you either use to drive or to measure.

It should therefore maybe not come as a surprise that the headphones that you plug into your computer can be used to spy on you.

Tagged ,

Deploy on Push

I disabled some of my social media accounts and want to use this blog some more instead. To that end it was about time to stream-line my pusblishing process here, lowering the mental threshold. After writing a new entry, I would up to now build the site locally and then sync the output to the server. The commit to the git-repository was optional.

Now, I commit and push with git, directly to the server which updates the repo, rebuilds and syncs locally to the place where the webserver expects its files. There are many ways people do this, the following is what I found the simplest for now.

Have a git repository on the server that you push into. Let this be a standard repo, not a bare one. Set the option git config --local receive.denyCurrentBranch updateInstead inside of it. This will update the current branch working files instead of refusing to receive the push. Since we never edit files here, the tree will always be clean, so it can be updated.

Then add a script at .git/hooks/post-receive which is a hook that gets executed after the repository received the push. Mine looks like this:

1
2
3
#!/bin/sh
cd ..
pelican -q -s publishconf.py && rsync -a output/* ../tmy.se

This builds the static html files with Pelican and then syncs them to the place where the webserver expects them.One could point the webserver directly to output/, in principle. But the built process takes half a minute for me during which the main index file is missing and the website would be offline.

Also note the cd .. in the script above, which is there because the working directory that the scripts gets run in seems to be the .git/ subdirectory. This is contrary to the git docs which claim that hooks get started in the root directory for non-bare repos.

Tagged , ,

The future is near

I've recently been reading Nick Bostrom's book Superintelligence and must admit it stuck with me. It may well seem a tad abstract to us who are new to thinking about such matters, but highly stimulating and thought-provoking.

The main point is driven home thoroughly: We should be talking more about artificial intelligence! Because its arrival might be just around the corner and it has the potential to mark a crossroads for our future, the choices being really really bad or really really fantastically good.

If you havn't read them yet, these two blog posts by Wait But Why are probably the best introdution: Part 1, Part 2.

I am currently half-way through Olle Häggström's Here Be Dragons which covers related but broader toptics of near-future technologies.

Tagged , ,