RSSAmplifier

Blog

Sandro Tosi

A blog about things I do: Debian, Linux, Python, whatever

sandrotosi.blogspot.comRSS feed ↗25 posts

Latest posts

HOWTO remove Reddit (web) "Recent" list of communities

If you go on reddit.com via browser, on the left column you can see a section called "RECENT" with the list of the last 5 communities recently visited. If you want to remove them, say for privacy reasons (shared device, etc.), there's no simple way to do so: there's not "X" button next to it, your profile page doesn't offer a way to clear that out. you could clear all the data from the website,…

TL;DR belongs at the top of an article

TL;DR if you are writing an article and plan to add a TL;DR section, then put it at the very top, right after the title. that's it, no excuses, end of discussion. It has happen to probably everyone to read an article, reach the end of it only to see a TL;DR section right at the bottom, and thinking: "eeh i wish this would have been at the top so i didnt have to read (DR) this long article (TL) to…

Mastodon hook for dput-ng

If you use dput-ng , you may be familiar with the Twitter hook that tweets a message when uploading a package. A similar hook is now available for Mastodon too; if interested, give it a try and comment on the MR

QNAP: control LCD panel and speaker

LCD Panel Most (if not all) QNAP models come with an LCD display, in my model i got a 2 lines by 16 characters each. The tool to control the panel is: /sbin/lcd_tool but sometimes it's a bit stubborn in executing the commands, so as mentioned here you may want to killall -9 lcdmond and then issue the command you want; this is the snippet i'm using: # print a msg on the panel killall -9 lcdmond…

Empire State Building Lights iCalendar

I'm very lucky to be able to see the Empire State Building from my apartment windows, and at night the lights are fantastic! But i'm also curious to know what's going to be today's lights, and tomorrow, etc. I thought I'd easily find a calendar to add to gCal to show that, but i wasn't able to find any, so I made it myself: https://sandrotosi.github.io/esb-lights-calendar/

Devils: Massimo Ruggiero's apartment building

If you enjoyed watching Devils , like me, and if you tend to obsess over tiny details that have absolutely nothing to do with the story being told, like me, and you lived in that general area, like me, then you may be curious of the location of Massimo's apartment. In several shots we can see views of both The Gherkin and the north side of Canary Wharf , so that means the building is in and around…

Gmail and tracker.debian.org: add a label to team emails

Recently the Python Team started the migration from Alioth mailing list to a tracker.debian.org team . Alioth mailing list, being a real ml, included a List-Id header, which is handled by Gmail natively and which you can use to create a filter based on it. Tracker.d.o instead uses a custom header, X-Distro-Tracker-Team , and Gmail doesn't allow to create filters on custom headers. But there's a…

Python: send emails with embedded images

to send emails with images you need to use MIMEMultipart , but the basic approach: import smtplib from email.mime.multipart import MIMEMultipart from email.mime.image import MIMEImage msg = MIMEMultipart('alternative') msg['Subject'] = "subject" msg['From'] = from_addr msg['To'] = to_addr part = MIMEImage(open('/path/to/image', 'rb').read()) s = smtplib.SMTP('localhost') s.sendmail(from_addr,…

QNAP firmware 4.5.1.1465: disable ssh management menu

as a good boy i just upgraded my QNAP NAS to the latest available firmware, 4.5.1.1465, but after the reboot there's an ugly surprise awaiting for me once i ssh'd into the box to do my stuff , instead of a familiar bash prompt i'm greeted by a management menu that allows me to perform some basic management tasks or quit it and go back to the shell. i dont really need this menu (in particular…

Multiple git configurations depending on the repository path

For my work on Debian, i want to use my debian.org email address, while for my personal projects i want to use my gmail.com address. One way to change the user.email git config value is to git config --local in every repo, but that's tedious, error-prone and doesn't scale very well with many repositories (and the chances to forget to set the right one on a new repo are ~100%). The solution is to…

Installing prometheus snmp_exporter on a QNAP nas

I've this project in the background about creating a grafana dashboard for a QNAP nas. As the summer is ramping up, i wanted to figure out the temperature of the nas throughout the day, so.. prometheus + grafana to the rescue! I wrote the instructions to install snmp_exporter on a linux-based QNAP nas. For now i'm using an already existing dashboard , but it's the first step to create my own.

It's a waiting game... but just how long we gotta wait?

While waiting for my priority date to become current, and with enough "quarantine time" on my hand, i just come up with a very simple Python tool to parse the USCIS Visa Bulletin to gather some data from that. You can find code and images in this GitHub repo . For now it only contains a single plot for the EB3 final action date; it answers a simple question: how many months ago your priority date…

What's that code: Elementary S04E09

they hacked a car and around 7:27 in the episode they are analyzing the car's computer source code, that's some sweet compression they say, but it turns out it's Perl interpreter source code, with Perl replaced with Auto (after all it's the auto code right?) https://perl5.git.perl.org/perl.git/blob/HEAD:/perl.c#l431 and following lines another interesting code copy was in The Americans (cant…

Debian source package name from the binary name

it looks like i forgot all the times how to do that, and apparently i'm not able to use google good enough to find it out quickly, let's write down one way to get the source package name from the binary package name: dpkg-query -W -f='${source:package}\n' <list of bin pkgs> (since it accepts a list of packages, you can xargs it). there are probably another million ways to do that, so dont be shy…

How to change your Google services location

Several services in Google depends on your location, in particular on Google Play (things like apps, devices, contents can be restricted to some countries), but what to do if you relocate and want to update your information to access those exclusive services? Lots of stories out there to make a payment on the playstore with updated credit card info etc etc, it's actually a bit different, but not…

DICOM viewer and converter in Debian

DICOM is a standard for your RX/CT/MRI scans and the format most of the times your result will be given to you, along with Win/MacOS viewers, but what about Debian? the best I could find is Ginkgo CADx (package ginkgocadx ). If you want to convert those DICOM files into images you can use convert (I dont know why I was surprised to find out imagemagik can handle it). PS: here a description of the…

CFEngine: upgrade Debian packages

say you use CFEngine to install Debian packages on your server, so it's likely you'll have a bundle looking like this: bundle agent agentname { vars: "packages" slist => { "pkg1", "pkg2", "pkg3" }; packages: "$(packages)" package_policy => "addupdate", package_method => apt_get; } this works great to guarantee those packages are installed, but if a newer version is available in the repositories,…

Attending the Codecademy

You've probably already got it, I'm surveying several sites to improve programming skills. This episode is about Codecademy . It's a very well done site, for people that want to learn a language. It has a Python track , along with several others: Ruby, JQuery, Javascript & so on. You'll be required to actually write code and run it! yes, the code you write is then executed in a web "interpreter"…

Spending a Sunday on CodingBat.com

I've played a bit with Project Euler but all of their problems are math-centric, which is nice but not exactly what I'm looking for: some real-world programming problems to get back into the coding field . So asking my friend Google, I found CodingBat : it has a Python section with several tasks to complete. I must say they are some kinda trivial to solve, once you know some idiomatic Python code,…

Project Euler - Problem 6

Here's my solution to Project Euler problem 6 : # where the numbers list ends n = 100 # handy function to square a number pow2 = lambda x: pow(x, 2) # first compute the sum of the squares sumsq = sum(map(pow2, range(1, n+1))) # then the square of the sum sqsum = pow2(sum(range(1, n+1))) print sqsum - sumsq

Project Euler - Problem 4

Here's my solution to Project Euler problem 4 : # handy function to check if a number is palindrome def is_palindrome(i): return str(i) == str(i)[::-1] # what's the max? max_p = 0 # multiply all numbers `i` between 100 and 998, with all between i+1 and 999 for i in xrange(100, 999): for j in xrange(i+1, 1000): p = i * j if is_palindrome(p) and p > max_p: max_p = p print max_p Comments are welcome.…

Start a MySQL instance to run Debian package build-time tests

I'm the maintainer of MySQL Connector/Python Debian package , and it's shipped with several unittests, but they require a MySQL instance to be run against, so up to know I wasn't able to run them at build-time. But I want to change that, so I wanted to find a way to spawn a MySQL instance just for testing purposes. I've searched a lot, and then found a package solving the same problem: php5 . The…

How to migrate your entire Google account to a new one

I've been using a Google account since years, but having a "more serious" one along. The time has come to make the switch and elect the other as main one. Google has a lot of services, and I'm using several of them, so changing the main account requires to migrate data of those services to the new account, given it's not possible to merge two accounts. To know the full list of services your…

Mercurial: what&#39;s the tag containing this changeset?

In software development, you often need to know: when was this feature released? in which releases was this changeset included? Typical example is: you're debugging a problem, you find out what's the changeset introducing it, now you want to know when that changeset was firstly released (i.e. included in a tag) - how to do that? hg log -r " cset :: and tag()" where cset is the changeset you're…

Get the lines unique on the first field(s)

uniq is a great tool, since it returns the unique (adjacent) lines of the given input. But it has a limitation: it can't check for uniqueness only the first N fields (while it allows to ignore them, weird). So, what to do if you have a long file, and lines with several fields, but you're only interested in getting the line with the different first 2 field (but all the rest of the line content? awk…