Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
afilini committed Jun 4, 2021
0 parents commit 7d93e5c
Show file tree
Hide file tree
Showing 23 changed files with 435 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .githooks/pre-commit
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -eo pipefail

./scripts/check-exif-jpg.sh
5 changes: 5 additions & 0 deletions .gitignore
@@ -0,0 +1,5 @@
venv/
public/

*.swp
geckodriver.log
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "themes/hugo-bearblog"]
path = themes/hugo-bearblog
url = https://github.com/janraasch/hugo-bearblog.git
17 changes: 17 additions & 0 deletions README.md
@@ -0,0 +1,17 @@
# afilini.com

Source code of my personal website, hosted at <https://afilini.com>.

The website is built with [hugo](https://gohugo.io/), to run it locally you can use:

```
hugo serve
```

which will start listening on <http://localhost:1313>.

Note that in order to correctly pull the theme you should either clone `recursively` or initialize the submodules after you've cloned the repo.

## License

The content of the website is licensed under [CC BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/).
53 changes: 53 additions & 0 deletions config.toml
@@ -0,0 +1,53 @@
baseURL = "https://afilini.com"

# The name of this wonderful theme ;-).
theme = 'hugo-bearblog'

# Basic metadata configuration for your blog.
title = "Alekos Filini"
author = "Alekos Filini"
copyright = "CC BY-SA 4.0"
languageCode = "en-US"

# Generate a nice robots.txt for SEO
enableRobotsTXT = true
# Enable git integration
enableGitInfo = true

[permalinks]
blog = "/blog/:slug/"
tags = "/blog/tag/:slug"

# Allow raw HTML in .md files
[markup.goldmark.renderer]
unsafe = true

[params]
# The "description" of your website. This is used in the meta data of your generated html.
# description = "Hugo + Bear = :heart:"

# The path to your "favicon". This should be a square (at least 32px x 32px) png-file.
# Hint: It's good practise to also put a "favicon.ico"-file into your "static"-folder.
# favicon = "images/favicon.png"

# These "images" are used for the structured data templates. This will show up, when
# services like Twitter or Slack want to generate a preview of a link to your site.
# See https://gohugo.io/templates/internal#twitter-cards and
# https://gohugo.io/templates/internal#open-graph.
images = ["images/share.png"]

# Another "title" :-). This one is used as the site_name on the Hugo's internal
# opengraph structured data template.
# See https://ogp.me/ and https://gohugo.io/templates/internal#open-graph.
title = "Alekos Filini"

# This theme will, by default, inject a made-with-line at the bottom of the page.
# You can turn it off, but we would really appreciate if you don’t :-).
hideMadeWithLine = true

# By default, this theme displays dates with a format like "02 Jan, 2006", but
# you can customize it by setting the `dateFormat` param in your site's config
# file. See [Hugo's Format function docs](https://gohugo.io/functions/format/)
# for details. An example TOML config that uses [ISO
# 8601](https://en.wikipedia.org/wiki/ISO_8601) format:
dateFormat = "Jan 02, 2006"
12 changes: 12 additions & 0 deletions content/_index.md
@@ -0,0 +1,12 @@
### About

Welcome to my website! [Here](/about) you can find some more info about myself and what I do.

### Contact

If you'd like to contact me in some way, there's a [dedicated page](/contact) with my all my email/social accounts and my PGP key.

### Blog
From time to time I also like to publish blog posts about random *weekend projects* I start or other interesting thing I hack on: check out the [blog section](/blog) if you wanna know more about that.

Enjoy!
16 changes: 16 additions & 0 deletions content/about.md
@@ -0,0 +1,16 @@
+++
title = "About"
menu = "main"
+++

### About

I'm a {{< age >}} year old developer working full time on open-source Bitcoin projects like [Bitcoin Dev Kit (BDK)](https://bitcoindevkit.org) and [Magical Bitcoin](https://github.com/MagicalBitcoin) thanks to a generous grant from [Brink](https://brink.dev).

Previously, I've worked at [Blockstream](https://blockstream.com) and [BHB Network](https://twitter.com/BHBnetwork).

I'm currently based in Milan, Italy.

---

<small><em>This website is made with [Hugo ʕ•ᴥ•ʔ Bear](https://github.com/janraasch/hugo-bearblog/) and hosted on [NixOS](https://nixos.org)</em></small>
4 changes: 4 additions & 0 deletions content/blog/_index.md
@@ -0,0 +1,4 @@
+++
title = "Blog"
aliases = [ "/blog/tag" ]
+++
71 changes: 71 additions & 0 deletions content/blog/hacking-sennheiser-pxc550.md
@@ -0,0 +1,71 @@
+++
title = "Hacking my Sennheiser PXC 550"
date = "2021-05-25"
description = "Fixing the annoying issue that makes them turn off and on constantly"
tags = [
"hardware",
"hacking",
"pxc550"
]
+++

### aka "Why the fuck are they constantly turning off by themselves??"

Once upon a time, when lockdowns and closed borders weren't really a thing, I used to spend a decent amount of time travelling, most of the time on an airplane. Since they tend to be rather noisy environments, I started to
look around for a pair of noise-cancelling headphones that would allow me to enjoy music while I wait to get from point *A* to point *B* at 35000 ft.

In the end I settled for a pair of [Sennheiser PXC 550][msAFRq_link][^msAFRq] because of... <abbr title="tbh I don't remember why I picked those instead of the Sony MX-whatever. They were probably just cheaper.">reasons</abbr>.

As an absolutely average music listener who listens to (high bitrate) MP3s over Bluetooth, they sounded great to me and the noise-cancelling effect was also pretty decent.

Fast forward almost a year and one day they just randomly reboot while I'm using them. I didn't think too much of it, "maybe it's just the low battery". But the more time went on, the more they started doing it,
up to the point where they would reboot at least once every time I would use them. Eventually I also noticed that this issue seemed somewhat related to the movements I made with my head: it would happen more
frequently if I was walking rather than sitting still at my desk.

At this point I should probably explain how's that even possible: is there a loose connection somewhere inside? Why the hell would they turn off if I just move my head without touching them?

Well, Sennheiser apparently thought it was a good idea to make the headphones turn on automatically when they are unfolded out of their case and worn.

And how do they do that? With a little magnet in the frame and an [Hall effect sensor][AnOuAO_link][^AnOuAO] in the right earcup. The sensor should pick up the magnetic field when the earcup is aligned with the frame, and make the headphones turn on. The
magnetic field should then disappear when the headphones are folded away, so they would turn off automatically.

Clearly this doesn't work so well considering the amount of Reddit posts[^uIbDkh]<sup>,</sup>[^JkXGPd]<sup>,</sup>[^PCRsLl] I managed to find describing headphones that turn off and on by themselves.

I tried replacing the magnet with a [different one][PNpqCE_link][^PNpqCE], hoping that it would be stronger and lead to a more stable signal for the sensor, but that didn't help.

In the end I just accepted that I would have to live with this issue: it was too late to get an RMA, and the issue seemed like a design flaw of that specific model rathern than just a defective unit, so even getting
a new pair wouldn't have fixed the problem permanently.

The people I work with must have heard me say "sorry my headphones disconnected, can you repeat that?" at least a dozen times, but as bad as it sounds, it wasn't a complete dealbreaker for me. Sure, it was annoying,
but in the end I could still get to the end of hour-long calls with one or maybe two disconnections. It was still *good enough* that I would just live with it instead of trying to fix the problem.

That is, until one day I started randomly looking for more workarounds and I found [this other][OXOImz_link][^OXOImz] Reddit post that described how the physical Bluetooth on/off switch could be re-routed and used as a power switch. A brilliant idea!

The post didn't have any pictures though, so I would have to figure things out by myself. I was kinda worried I would find a super crammed PCB, but I decided to give it a shot and opened the right earcup (the ones that
houses all the interesting circuitry) to get to work.

In the end it turned out to be pretty easy, even for somebody with crappy soldering skills like myself. I unfortunately didn't document the whole process, but I took this picture before closing them up:

{{< my-figure url="/images/blog/hacking-my-sennheiser-pxc-550/pxc550-annotated.jpg" caption="Annotated shot of the right earcup after the mod" >}}

Highlighted you can see:
* In purple the disconnected Hall effect sensor. To unplug it you can push forward (away from the white piece) the little black part of the connector, and then lift it up slightly to pull the flat cable out.
* In blue the first wire soldered to a test point right above the sensor connector. From a quick experiment it looks like the two inner pins of the connector are both GND while the two outer pins (and the test pad) are the "signal" pins.
When pulled to GND they will make the headphones turn on.
* In yellow the second wire soldered to a relatively large ground pad.
* In red the two wires that were originally soldered to the switch, joined toghether to force Bluetooth to be always on and then moved out of the way.

And that was it! I've been using them with this mod for almost a month now and they've been working great. The new power switch is not super easy to access, but I'll take that over having them randomly turning off.

[OXOImz_link]: https://www.reddit.com/r/sennheiser/comments/gmcmzs/pxc_550_power_switch_fix/
[msAFRq_link]: https://en-us.sennheiser.com/wireless-headphone-headset-bluetooth-noise-cancelling-pxc-550-travel
[AnOuAO_link]: https://en.wikipedia.org/wiki/Hall_effect_sensor
[PNpqCE_link]: https://www.amazon.it/dp/B00TACKU36/ref=cm_sw_r_u_apa_glt_i_2TW0DERF91YB3P80X749

[^uIbDkh]: *PXC 550&#x27;s turning on and off randomly, any ideas hot to fix? : sennheiser* [[original]](https://www.reddit.com/r/sennheiser/comments/bxx0dx/pxc_550s_turning_on_and_off_randomly_any_ideas/) [[archived]](https://archive.md/31yE3)
[^JkXGPd]: *Problems with PXC 550. Turning off randomly at very small angles and slight head movement. : sennheiser* [[original]](https://www.reddit.com/r/sennheiser/comments/ggoott/problems_with_pxc_550_turning_off_randomly_at/) [[archived]](https://archive.md/8J7Ul)
[^PCRsLl]: *PXC 550 will auto shut off : headphones* [[original]](https://www.reddit.com/r/headphones/comments/aqtbf8/pxc_550_will_auto_shut_off/) [[archived]](https://archive.md/7YquU)
[^OXOImz]: *PXC 550 Power Switch Fix : sennheiser* [[original]](https://www.reddit.com/r/sennheiser/comments/gmcmzs/pxc_550_power_switch_fix/) [[archived]](https://archive.md/D8GzG)
[^msAFRq]: *Sennheiser PXC 550 TRAVEL - Wireless Headphone Headset Bluetooth® - Active Noise cancelling* [[original]](https://en-us.sennheiser.com/wireless-headphone-headset-bluetooth-noise-cancelling-pxc-550-travel) [[archived]](https://archive.md/KYljs)
[^AnOuAO]: *Hall effect sensor - Wikipedia* [[original]](https://en.wikipedia.org/wiki/Hall_effect_sensor) [[archived]](https://archive.md/gyUIC)
[^PNpqCE]: *first1magnets F331-N35-50 - Magnete al neodimio N35, diametro 3 mm x spessore 1 mm, forza magnetica 0,13 Kg (50 pezzi): Amazon.it: Fai da te* [[original]](https://www.amazon.it/dp/B00TACKU36/ref=cm_sw_r_u_apa_glt_i_2TW0DERF91YB3P80X749) [[archived]](https://archive.md/PyqK7)
12 changes: 12 additions & 0 deletions content/contact.md
@@ -0,0 +1,12 @@
+++
title = "Contact"
menu = "main"
+++

### Contact

You can contact me at my main email, `alekos.filini[at]gmail.com`.

I'm also active on Twitter with the handle [`@afilini`](https://twitter.com/afilini), on [Libera](https://libera.chat) again as `afilini` and on Signal (contact me privately for my phone number).

If you'd like to send me an encrypted email or just verify my git commits, [here](/pgp.txt) you can find my full PGP key (ID `34FDFA4F`, fingerprint `9222 07BA 3642 BE16 0216 73D2 5E8A FC30 34FD FA4F`).
6 changes: 6 additions & 0 deletions layouts/partials/footer.html
@@ -0,0 +1,6 @@
<small class="gray">
{{ if .IsPage }}
<em>Updated: {{ .Lastmod.Format .Site.Params.dateFormat }} - Version: <a href="https://github.com/afilini/afilini.com/commit/{{ .GitInfo.Hash }}">{{ .GitInfo.AbbreviatedHash }}</a></em> -
{{ end }}
&copy; <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>
</small>
4 changes: 4 additions & 0 deletions layouts/partials/header.html
@@ -0,0 +1,4 @@
<a href="{{ "/" | relURL }}" class="title">
<h1>{{ .Site.Title }}</h1>
</a>
<nav>{{- partial "nav.html" . -}}</nav>
1 change: 1 addition & 0 deletions layouts/shortcodes/age.html
@@ -0,0 +1 @@
{{ dateFormat "06" (now.AddDate -1998 -8 -24) }}
6 changes: 6 additions & 0 deletions layouts/shortcodes/my-figure.html
@@ -0,0 +1,6 @@
<figure class="image">
<a href="{{ .Get "url" }}">
<img src="{{ .Get "url" }}" alt="{{ .Get "caption" }}">
</a>
<figcaption><center><small><em>{{ .Get "caption" }}</em></small></center></figcaption>
</figure>
3 changes: 3 additions & 0 deletions scripts/apply-git-hooks.sh
@@ -0,0 +1,3 @@
#!/usr/bin/env sh

git config --local core.hooksPath .githooks/
14 changes: 14 additions & 0 deletions scripts/check-exif-jpg.sh
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -eo pipefail

function err() {
echo "FOUND EXIF METADATA IN: ${1}"
exit 1
}

for f in $(find . \( -iname \*.jpg -o -iname \*.jpeg \) ); do
identify -format '%[EXIF:*]' $f | grep -q -i 'exif' && err $f
done

exit 0
45 changes: 45 additions & 0 deletions scripts/fetch-url-archive.py
@@ -0,0 +1,45 @@
#!/usr/bin/env python3

import re
import sys
import random
import string

import urllib.parse
import urllib.request

import archiveis

def get_title(url):
req = urllib.request.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0')
f = urllib.request.urlopen(req)

content = f.read().decode('utf-8')

pattern = '<title.*?>(.+?)</title>'
result = re.findall('<title.*?>(.+?)</title>', content)
return result[0]

if len(sys.argv) < 2:
print('usage: {} URL [TEXT]'.format(sys.argv[0]), file=sys.stderr)
sys.exit(1)

url = sys.argv[1]

title = get_title(url)
archive_url = archiveis.capture(url).replace('/wip/', '/')

note_id = ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase, k=6))

if len(sys.argv) > 2:
# Print inline link + note
print('[{}][{}_link][^{}]'.format(sys.argv[2], note_id, note_id))
else:
# Print just the note reference
print('[^{}]'.format(note_id))

print('-------------------')
if len(sys.argv) > 2:
print('[{}_link]: {}'.format(note_id, url))
print('[^{}]: *{}* [[original]]({}) [[archived]]({})'.format(note_id, title, url, archive_url))
8 changes: 8 additions & 0 deletions scripts/requirements.txt
@@ -0,0 +1,8 @@
archiveis==0.0.9
certifi==2020.12.5
chardet==4.0.0
click==8.0.1
idna==2.10
requests==2.25.1
selenium==3.141.0
urllib3==1.26.5
15 changes: 15 additions & 0 deletions scripts/update-share-screenshot.py
@@ -0,0 +1,15 @@
#!/usr/bin/env python3

from selenium import webdriver

driver = webdriver.Firefox()
driver.get('http://localhost:1313')

driver.execute_script("let e = document.getElementsByTagName('html')[0]; e.style.width = '900px'; e.style.height = '600px'; ")

element = driver.find_element_by_tag_name('html')
element_png = element.screenshot_as_png
with open("./static/images/share.png", "wb") as file:
file.write(element_png)

driver.quit()
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/share.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7d93e5c

Please sign in to comment.