Posts

My Side Project: RouteCard Maker for Safer Hiking

I've been working on this side project about route cards. It's an important thing because route cards are complicated but necessary for any hike. Given their use for planning and safety, I wanted to make it easier for outdoor enthusiasts to create them. Being out in the hills or mountains, poor planning can lead to risks and even fatalities. My hope is that more use of route cards can reduce these risks. RouteCard Maker is a free web app I built to help hikers create detailed route cards with waypoints, distances, timings, elevation profiles, and weather forecasts . No downloads required - it works in your browser. Key Features Route Cards : Grid-based planning with distances and timings Elevation Charts : See terrain challenges ahead Weather Integration : Real-time forecasts from yr.no Sharing & Export : Save routes and download as CSV Technically, it leverages Cloudflare extensively for global CDN, edge computing, and security. The app runs serverless with...

vector configuration for pfsense

decoding base64 signed urls in varnish

Fronting imgproxy with varnish, to honor old url base64 signed urls the javascript file

nginx decode base64 url for use with imgproxy

 i've been testing imgproxy, to handle our image serving needs, and it looks good. our existing servers are php based, and we sign and encode our urls for images.  To test out imgproxy , I wanted to simply drop it in as a replacement for our servers by sending a % of traffic.  There are many ways to do this, varnish was one, with custom code, but nginx is our go-to web server, so I had to find a way to have nginx sit in front of imgproxy and rewrite the decoded url. I settled on using njs, the cut down version of javascript that plugs into nginx as a loadable module.  Then use proxy_pass to pass the uri to javascript that will return the imgproxy compatable url, and proxy to it. a sample url would be http://foo.bar/images/c2lnbmF0dXJlZm9vaHR0cDovL3MzLWV1LXdlc3QtMS5hbWF6b25hd3MuY29tL215YnVja2V0b2ZwaG90b3MvcGhvdG9fb2ZfYV9jYXQ1fHx8MTIwMHgxMjAwfHx8fHx8fHw==.jpeg it has a sig, a bucket url, and parameters like image size. Getting nginx setup nginx.conf load_module modu...

running a victoriametrics cluster

I recently had a need to work with metrics, and looking at the landscape of modern tools, went with victoriametrics. After initially using the single binary version, I went on to setup the cluster version, using two nodes for everything (free nodes in oracles free tier!) run these binaries on each node (where 10.0.2.41 and 10.0.2.40 are the addresses of the nodes) ./vmstorage-prod -retentionPeriod 5y -storageDataPath /var/lib/victoriametrics ./vminsert-prod -storageNode=10.0.2.41:8400 -storageNode=10.0.2.40:8400 -replicationFactor=2 ./vmselect-prod -storageNode=10.0.2.41:8401 -storageNode=10.0.2.40:8401 -replicationFactor=2 -dedup.minScrapeInterval=1ms front vmselect and vminsert with nginx server { listen 443 ssl; server_name metrics.foo.bar; location /insert/ { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://localhost:8480; } location /select/ { proxy_set_header Host $host; ...

using vmctl to copy data

I had a need to copy data from a standalone victoriametrics system to a cluster setup. for some reason the command line wasn't intuitive, so making a note here ./vmctl vm-native --vm-native-src-addr=https://source.to.copy.from:443 --vm-native-src-user user1 --vm-native-src-password password1 --vm-native-dst-addr=https://destination.to.copy.to:443/insert/0/prometheus/api/v1/write --vm-native-filter-match='{db="db1"}'

using vmagent to collect victoriametrics stats

 vmagent is part of victoriametrics, and is a lightweight prometheus scraper. create a basic prometheus.yml file that defines a host to scrape, in this example it's using SSL and basic auth global: scrape_interval: 15s evaluation_interval: 15s scrape_configs: - job_name: vmetrics static_configs: - targets: - host.to.scrape:443 scheme: https basic_auth: username: user1 password: password1 then run vmagent to use this and send to a victoriametrics node to store the metrics it scrapes ./vmagent-prod -httpListenAddr 127.0.0.1:8240 -remoteWrite.basicAuth.username user2 -remoteWrite.basicAuth.password 'password2' -remoteWrite.url=https://host.to.send.to:443/api/v1/write -promscrape.config=prometheus.dsch.yml if using the cluster version, the url in the command line might be -remoteWrite.url=https://host.to.send.to:443/insert/0/prometheus/api/v1/write

de-bouncing an S0 energy sensor on a pi

I hooked up a submeter to my fuseboard some time ago, and not too long ago I started to read it with a Pi Zero.  However every now and again I would get a crazy reading, and from logging I would see bouncing. I would see interrupts where wiringpi would report the input as 0, and then again as 0, with no change to 1 inbetween.  I read up on debouncing and how the Pi is meant to do this, and also how some people have handled it in code by removing large deviations.   In my case, the solution has been to simply add logic in an encompassing if statement, to ignore interrupts where the pin is the same value as the last interrupt, and only count interrupts where the pin is a different like this  if (digitalRead(PIN) == last_interrupt_pin) { printf("Bounce ! Last Pin = %d This Pin = %d\n", digitalRead(PIN), last_interrupt_pin); }

day night meter

 I recently looked at moving from a basic electricity meter to a day/night meter, and got a little caught up in the maths, so thought I write it here. Where I live, your electricity is made up of a standing monthly charge, and a usage charge.  you by default get a meter which is an all day meter and not aware of day/night.  though smart meters are coming  (smart tarriffs some other time in the future). For free you can change your meter to be a day night meter, where the day tariff is higher than the all day tariff, but the night tariff is a lot cheaper.  The standing rate is different, but lets ignore that or now. There is a magic point where your % of electrcity used during the day vs night, will be equal to the cost of the all day tariff, and expressing this lets you figure out if you will save money moving from all day to day/night.  The maths looks like this (night rate - all day rate) / (night rate - day rate) = %day  (the percent of you 24hr us...

installing windows 10 on a mac mini 2,1

Mac mini 2,1 devices are tricky, they are 64bit, but have a 32bit EFI.  booting a usb to install windows isn't going to work. my internal cdrom drive is faulty, so can't use that an external cdrom won't install either. The easiest way to install it, is to boot the mac mini into target disk mode (hold T on boot).  Then connect a firewire cable to another system.  The internal disk in the mini will now show up as a disk on this other system. create a 4GB NTFS primary partition. copy the contents of windows 10 x32 cdrom onto it make the partition active with diskpart (select disk X/select partion X/active) put a bootsector on it. from cdrom \boot\bootsect.exe /nt60 y: reboot mini, and it will install windows from the internal disk. thanks to  https://www.bleepingcomputer.com/forums/t/619313/clean-install-windows-directly-from-the-hard-disk-drive/ drivers are fun, get apple ir, bluetooth etc from bootcamp 4.0.4326 and extract the sigmatel audio drivers,...

Installing FreeBSD 13 on a mac mini 2,1

Mac mini 2,1 devices are tricky, they are 64bit, but have a 32bit EFI.  booting a usb to install Freebsd isn't going to work. my internal cdrom drive is faulty, so can't use that an external cdrom won't install either. The easiest way to install it, is to boot the mac mini into target disk mode (hold T on boot).  Then connect a fireware cable to another system.  The internal disk in the mini will now show up as a disk on this other system. install virtualbox and setup raw disk access to the firewire drive.  install freebsd in virtualbox, which is therefore writing at a raw level to the disk in the mini.  complete the install, power cycle the mini and it should boot into freebsd. everything worked for me, graphics were a problem though with freebsd, it wouldn't detect the DVI.  digging around, this fixed it installing port graphics/drm-fbsd12.0-kmod and adding        kld_list="/boot/modules/drm.ko /boot/modules/i915kms.k...

Using Oracle Autonomous database with PHP

The Oracle Cloud free tier is pretty generous, one thing that stands out is the free tier for a managed database.  Normally I would use mysql , but this is oracle and I haven't used that in a long time.  I also haven't used it with PHP These are my notes to make it work on ubuntu overview: 1. download and install oracle client and sdk 2. setup your wallet 3. setup php 4. test 1. setup and install oracle stuff mkdir /opt/oracle mkdir /opt/oracle cd /opt/oracle wget https://download.oracle.com/otn_software/linux/instantclient/193000/instantclient-basic-linux.x64-19.3.0.0.0dbru.zip wget https://download.oracle.com/otn_software/linux/instantclient/193000/instantclient-sdk-linux.x64-19.3.0.0.0dbru.zip unzip instantclient-basic-linux.x64*.zip unzip instantclient-sdk-linux.x64-*.zip echo /opt/oracle/instantclient_19_3 > /etc/ld.so.conf.d/oracle-instantclient ldconfig echo "LD_LIBRARY_PATH=/opt/oracle/instantclient_19_3:$LD_LIBRARY_PATH" >> /etc/envirome...
Making SMS work with house alarm again. Some time ago, Eir ceased the SMS center feature, so house alarms couldn't send SMS's any more.  to make things worse, they would try, and eventually time out. Asterisk can act as a service center for SMSs, so setting up a sipura ATA to take the call from the alarm panel , convert it to sip and send it to asterisks, ends up with the SMS sitting in /var/spool/asterisk/sms I used astlinux on an alix system as my asterisks setup, and added this to the extensions.conf exten => 1234/98765,1,Verbose(Receiving SMS from ${CALLERIDNUM}) exten => 1234/98765,2,Answer exten =>  1234/98765,3,Wait(1) exten =>  1234/98765,4,SMS(sms_fixedline,as) exten =>  1234/98765,5,Hangup and made sure the call was routed to this extension. you can simple cron watching the spool directory, pick the sms and forward via an sms provider with curl ...

Fire Alarms

I recently had to find someone to service and install a fire alarm and security system.  Came across https://www.nfss.ie and they were excellent

Android Auto and Google maps 'GPS not found'

I started using android Auto, and found that with my S8 , google maps would be inaccurate, and not update location, and display 'searching for gps' occasionally. This turns out to be the power saving feature enabled on the s8, it disables background location checks.  Unfortunately disabling power saving makes me need to find a charger in the middle of the day, and I pretty much get through a full day without needing a charger. So, I looked at how I can remedy this situation and settled with using Automate to create a workflow, which is triggered when car-mode is enabled.  This workflow then calls a tasker plugin called securetask , which you grant special perms to.  This plugin changes the power state , disabling power saving, so it fixes the problem.  when car mode is exited, it turns powersaving back on.

Hyundai Tuscon Radio, adding station logos

get radiologos here  and extract to an SD card then get the list of stations, and their PI from https://fmscan.org  , generate the list for you country. each station has a PI, which is in hex, convert it to decimal, and rename the png logo file to sid_<decemial>.png do this for each station, and store it in the logos directory on the SD card insert the SD, start the unit, and select install from the menu that pops up. vw let you download a zip of your countries logos, but you still need to rename them

figuring out s3 bucket size

You can calculate the size of your buckets with commandline tools, or using the analytics feature.  However, all of these incur charges. Alternatively you can run a ' usage report ', save it as a csv , and then do some math cat report.csv | awk -F, '{printf "%.2f GB %s %s \n", $7/(1024**3 )/24, $4, $2}' | sort -n
Time to talk about google app engine, flex , standard , php, and google cloud storage. I've been doing some experimenting using GAE to make a service like cloudinary.  It's pretty simple to do, using imagick, which is installed in GAE.  But here are some simple discoveries; 1)  GAE flex, sounds like GAE standard, but it's not.  if using php55 it's quite different.  with php72 now launched in standard, it's closer to flex, you need a front_controller, and your app.yaml is simpler 2) GAE standard scales really quickly, like to 10k instances in 1 to 2 mins.  Flex takes a LOT longer, think 30 mins 3) GAE can use imagick, imagick is not fast, and cpu intensive , fetching an image from a GCS bucket and rendering it cropped or resized is a 1-2 second operation. you could use appengines image api, but for php it's limited to getservingurl functions. unless you want to write protobuf interfaces . In python, it's way more useful, you can do all the usual t...

load testing

I have used apache bench, and more recently artillery.io tools, but it still wasn't ideal.  I came across this tool which will do a better job for basic testing https://github.com/wg/wrk

Sky Q tuning with a Meter

Image
Using a sky Q compatible LNB, you can still tune with a regular digital tuner.  The analogue inline tuners won't get enough voltage to work right. I use a satlink ws-6933, and set it to a vertical transponder and hooked it to the vertical output of the LNB, without doing that you will get a signal measurement with no quality measurement Below are the screen shots of sky Q signal on the meter and in the sky Q UI too.