Toggling web ad-blocking via a Squid proxy

Squid is a popular open-source proxy that can be configured to block adverts. I run it on a Raspberry Pi & have my iPad Air and Samsung Galaxy S21 Ultra configured to use the proxy when connected to my Wifi at home. There are good articles on the web which show you how to set all this up, so I won’t go over it in this post.

One thing I needed was a way to easily turn the ad-blocking off & back on, since blocking ads sometimes breaks sites or links to sites (especially affiliate tracking links).

You can of course go into the network settings & remove the proxy configuration, then put it all back after you’re done, but this is a pain & I really wanted a 1-tap solution which would work on iOS & Android.

First, I wrote a bash script which would toggle the ads on/off.. this works by emptying/populating the adblock.txt file that Squid consumes & telling Squid to re-read it. Here’s the script I came up with;

/etc/squid/squid_ads_toggle.sh

if [ -s "/etc/squid/adblock.txt" ]; then
        : > /etc/squid/adblock.txt
        /usr/sbin/squid -k reconfigure
        echo "Adverts ENABLED" > /var/www/html/proxyadstoggle.out
else
        curl -sS -L --compressed "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=squid-dstdom-regex&showintro=0&mimetype=plaintext" > /etc/squid/adblock.txt
        /usr/sbin/squid -k reconfigure
        echo "Adverts DISABLED" > /var/www/html/proxyadstoggle.out
fi

Testing this from a command prompt worked, so the next thing I needed to do was be able to trigger it from a web server call. My Raspberry Pi already has Apache & PHP running, so that was the natural place to create a quick PHP page that executes the bash script;

/var/www/html/proxyadstoggle.php

<?php
        print ("Toggling ads on Squid proxy [");
        $exec = "sudo /etc/squid/squid_ads_toggle.sh";
        exec($exec, $output, $retval);
        print($retval."] - ");

        $file = file_get_contents('/var/www/html/proxyadstoggle.out', true);
        print($file);
?>

The last thing I needed to give permission for the web service to run the bash script, which uses visudo to allow the ‘www-data’ user to run it. Now, I realise this isn’t ideal, but I couldn’t find a better solution; please understand the security risks of doing this if you’re going to follow this guide.

sudo visudo

www-data ALL=(ALL) NOPASSWD: /etc/squid/squid_ads_toggle.sh

Testing this in a web browser worked, so next I could move on to triggering it from my iPad and Android phone.. I could just go to the page in a browser, but that felt a bit clunky & there are nicer ways to do this! :)

Shortcuts on iOS

‘Shortcuts’ is a really nice automation app that’s built into iOS; with just 2 steps, I can call the PHP page & output the result into a native popup notification. Here’s how it looks;

The shortcuts can be added to the slide-out widget panel in iOS, which make it really convenient to access!

Running the shortcut will display a notification like this;

Automate on Android

There isn’t a built-in equivalent of ‘Shortcuts’ on Android, but I do have Automate, which I’ve previously used in projects I’ve blogged about on here.

Here’s how the ‘Flow’ looks;

The HTTP Request block needs to save the output to a variable, like this;

And the Toast notification can then display what’s in the variable like this;

You can add the Flow to your home screen as a shortcut (via Automate, or through Widgets), and when you tap it you’ll see a notification like this;

And there you have it! An easy way to toggle ad-blocking on your phone or tablet. Those apps on iOS and Android open up a world of opportunities to integrate with other systems & do some really neat stuff.

Sync Photos from a Camera SD Card to your Phone

As I get used to owning a Fujifilm X-E3 compact mirrorless APS-C camera, one thing I’ve just figured out is how I can transfer photos and videos off it to my Android phone.

The Fuji app is supposed to do a lot of this automatically, but I’ve found it unreliable (often not connecting to the camera), doesn’t sync video, and needs to use its own WiFi hotspot for the transfer.

What I’ve figured out is I can use a USB on-the-go (OTG) adaptor, USB SD card reader, and a couple of apps to do everything I need. Here’s how you can set up the same workflow:

Get a USB OTG adaptor and USB SD Card Reader. Make sure your phone can read the SD card when it’s attached.

You’ll need to use a file-browsing app to look for the attached USB device; phone manufacturers usually pre-install one for you.

If you can see the files on your SD card, you can move onto the next step!

Next download FolderSync. This will allow you to sync the files from your SD card to your phones’ internal memory. Set up a ‘folder pair’ to sync the files where you want them (even to the Cloud).

Now you’ve got the files syncing from your SD card to your phone, you may need to perfect things depending on the camera you have. Fujifilm cameras  save videos as .MOV files which don’t show up in Google Photos or the gallery app (not on Samsung phones anyway).

To fix this, I’ve used an app called Automate to rename the copied files to .MOV.mp4. That (weirdly) sorts it out!

If you haven’t seen Automate before, it’s a bit like Tasker, but you build the automation (flow) using blocks.

The MOV renamer process I built looks like this;

This can be added to my homescreen as a shortcut which runs the flow when I tap it.

I’ve published the final version of the flow to the Automate community so that you can download and adapt it however you see fit.

To help show you exactly how this works I’ve created a short video. I go into more detail on the flow I used, and you can see the whole thing in action.

Samsung Galaxy S9 Super Slow-Mo Videos

The Samsung Galaxy S9 is a bit of a bargain if you look at the International versions. When it retailed for about £700 in the UK, you could import it from Italy for about £500! It’s available now on Amazon for £480.

When I bought the S9 I didn’t realise it had a special video mode called Super Slow-Mo. I’ve had slow mo on a Canon Ixus camera before, but it was poor resolution and needed a lot of light to work.

The S9 shoots super slow-mo at 960 frames per second, and captures 0.2 seconds of motion, stretching it to 6 seconds when you play it back.

One big difference with the S9 is how you trigger super slow-mo. When its set to automatic, a yellow square appears over the video preview.. when you start recording, the S9 looks for motion within the square, and when it sees movement it’ll trigger super slow-mo.

For me, the automatic mode makes it more than a gimmick .. you can get some great videos out of it without much effort. Here are a few (non-professional) examples that I’ve taken over the past few months;

 

 

 

 

 

 

These were quite simple to capture.. just practice a bit to see how it triggers and you can get good results.

How to get Speed Camera Alerts with Google Maps

After looking a Waze (which has speed camera alerts) I still wanted to carry on using Google Maps, but wanted to get speed/safety camera alerts. I’d also been looking at TomTom Go for Android, which looks like a good app for road warriors, but also does 50 miles for free each month & has offline maps.. handy for getting out of a tight spot when there’s no data signal!

There’s actually another app from TomTom specifically for Speed Camera alerts.. it has an overlay mode that puts a floating widget over the top of *anything* .. so that might just be your homescreen, but can also be Google Maps.. neat!

Google Play Store link

Here’s a video showing how it works (please help me out by subscribing to my channel so that I can get to 1,000 subs this year!)

youtube

 

 

‘Take Me Home’ shortcut for Google Maps

In the older version of Android I used to have a shortcut on my home sceen which would start up Google Maps in navigation mode & take me home. In the newer versions of Android, the ‘Shortcut’ feature seemed to disappear. I’ve tracked down this feature and this is where to find it;

  • Long-press on a free space on your home screen.. this allows you to add Apps | Widgets | Wallpapers
  • Choose ‘Widgets’
  • Scroll along and find ‘Directions’, then fill out the route information.. and that’s it!

Find the ‘Directions’ widget:

nav3

Enter the route info:

nav2

Done!

nav1

My Android App Essentials

After recently moving from an old Samsung Galaxy S3 to LG G3 (which I thought was a bargain at £189), I reviewed the list of apps I had previously installed & made sure they were still relevant to my new phone. I thought it’d be useful to list out the best ones so here’s what I installed (beyond the usual apps like Twitter, iPlayer);

  • ASTRO – For managing files
  • Avast Mobile Security – I use this on all my PCs so adding it to the phone makes sense
  • Barcode Scanner – Primarily for scanning QR Codes
  • BT SmartTalk – Make VoIP calls using my landline pricing structure
  • BT Wi-fi – Connect free to any BT wifi access points
  • Chrome – Better than the stock browser
  • Evernote – We have this on our family phones for keeping notes.. often taking pictures of letters before binning them
  • FreeOTP – An alternative to Google Authenticator
  • MightyText – Receive and send texts from my desktop PC
  • MX Player – Plays any media you can think of
  • National Rail – Train info
  • Network Scanner – Handy for tracking down the IP of devices on my home network
  • Nights Keeper – Set sound profiles based on day/time.. basically turns the sound off at night UPDATE: Replaced by Timerific
  • Photos – Google photos.. enabling easy backup to the cloud
  • Pixlr – Quick and easy image editing on the move
  • Podkicker – Download and listen to podcasts
  • Rewards – Take short surveys to get small amounts of cash to spend in the Google Play Store
  • SwiftKey Keyboard – Better than most stock keyboards
  • System Tuner – Handy for debugging apps
  • Timeriffic – When I was having variable success with Wifi Timer on my LG G3, I found this worked perfectly and could also replace Nights Keeper
  • tinyCam Monitor – Connect to various IP cameras
  • Twilight – Adjust the blue light emissions on the phone’s screen after it’s dark outside
  • Unified Remote – Helps control my HTPC if I need to use a mouse/keyboard
  • Wifi Analyser – Looks at what wifi access points are in range
  • Wifi Timer – Switch of wifi based on time of day.. i.e. switch it off at night + when I’m at work UPDATE: Replaced by Timerific due to problems getting it to work all the time on the LG G3
  • World Clock – Handy when I’m travelling; has a widget to put on my homescreen

Increasing battery life on a Galaxy S3 with Android 4.3

The latest software update to the Samsung Galaxy S3 upped it to use Android 4.3, but included a whole bunch of Samsung bloatware. From a full charge, it was only taking 20 hours to run down flat, with it feeling slightly warm all the time. There was also a really annoying app that was requesting I sign into Facebook after each restart.

From what I can see, there are a bunch of things that you can disable to improve the battery life & get things back to normal. Here’s what I did;

Go to.. Settings > More > Application Manager > All

Open & disable each of these.. (obviously if you use a particular service, like Dropbox, leave it alone);

Amazon MP3
Backup
Dropbox
DropboxOOBE
Face Unlock
Game Hub
Music (the official Top 40 app)
Music Hub
O2 Space
PageBuddyNotiSvc
S Suggest
S Voice
Samsung Account
Samsung Apps
Samsung Backup Provider
Samsung Browser SyncAdapter
Samsung Calendar SyncAdapter
Samsung Cloud Data Relay
Samsung Cloud Quota
Samsung Contact SyncAdapter
Samsung Link
Samsung Push Service
Samsung SMemo SyncAdapter
Samsung Syncadapters
SamsungAppsUNA2
SNS
Video Hub

Bluetooth audio A2DP receiver BTR006 review

We have a tablet that we put in a headrest mount for the kids to watch on longer journeys. In the past I attached an FM transmitter so that audio could be fed through the car stereo, and I could control the volume from the dash. The only problem with that was local radio stations in other regions stomping over the FM signal I’d pre-set earlier in the journey.

I bought the Bluetooth audio receiver from Justop. It’s the BTR006 model which apparently has some updated chipset. It’s about £15 on Amazon.

This tiny unit draws power from its built in li-on battery (or any USB port) and when fully charged will allow for 8-10 hours of use, and something like 250 hours of standby.

It was easy to pair up with my Samsung Galaxy S3, and Blackberry Playbook.. both of which will be using A2DP. The signal travels 5-10m without problems, but at extremes, the signal gets scrambled by walls/people. For my use, which is for in the car (tablet with the kids in the back) it works a treat.

The only thing I don’t particularly like is the tiny power socket which uses some non-standard plug instead of micro or mini USB. That’s a real pain when I have loads of micro USB-ended adapters kicking around.

Streaming video from the Humax HDR-Fox T2 to Android and Blackberry Playbook

One of the nice features of the Humax HDR-Fox T2 is that it’ll stream your standard definition recordings over your network to DLNA clients. I’ve had a it streaming video onto a PC running XBMC, but wanted something more portable for catching up with some TV whilst I’m getting ready in the morning.

As long as your Android phone is relatively recent, there are a bunch of DLNA clients.. the one I’ve had the best results with is Skifta. Then I’ve got MX Player installed which will handle video playback. The thing I like about MX Player is the gesture control for skipping through the program (swipe across), and adjusting volume (swipe up/down).

I’m running that on a Samsung Galaxy S3, and it works really well. It’s just slightly too small when it’s across the room. It would be better on a tablet, and I have a Blackberry Playbook (from their developer programme).. the only problem has been the lack of a DLNA client.. until just recently, when I found KalemSoft Media Player.

The app is currently being sold at £5, which was a bit more than I’m used to paying.. but the reviews were almost all really good, so I gave it a go. Here’s the app running with my Humax HDR-Fox T2;

As you can see, it’s really fast to browse the folders and start playing back video. It even manages HD if you’re running the auto-decode package, although I had buffering issues when trying to play it back over my network.

KalemSoft do a PC service which will share all your video from there too; I’ve found it works really well.. better than TVersity, and the built-in Windows media sharing stuff, both of which seemed to take ages to index my stuff, and then didn’t even work well after that. Apparently it can be configured to share stuff out over the Internet (password protected too), but I don’t need that feature. It can also stream live TV if you’ve got a TV card.

Titanium Apps and the Blackberry Playbook

In Feburary 2012, Blackberry updated the OS for their 7″ Playbook tablet to v2.0. This introduced compatailbity with Android-based applications whereby developers can simply repackage, code sign, and submit their Android apps into BlackBerry App World. It also means you can take any Android app (that hasn’t gone through this process) and sideload the app yourself.

Since I develop mobile apps for iOS and Android using the Titanium platform, I was interested in how much effort it would be to get my existing apps working on the Playbook. There are plenty of posts on how to take an APK and sign it correctly for App World, but what took me a while to figure out, was which version on Titanium was compatible with the Playbook.

After some experimentation, I’ve found that if you package your app against Titanium SDK 1.7.5, it’ll work nicely on the Playbook. Version 1.8.x won’t work (hmm, maybe it’s V8 vs Rhino.. V8 definitely doesn’t work…). Certain pieces of code may also cause the app to crash (whereas it won’t crash on a proper Android device). The one thing I hit, was passing url:null, into Titanium.UI.createWindow will crash the app, whereas that’s absoutely fine on iOS and Android.

The other small advantage of using the 1.7.5 SDK is that the resulting APK is a lot smaller, although since the current Playbook only has Wifi this is less of an issue than it is on a mobile phone.

Now we have the APK, you just have to go through the app packaging/signing process as detailed elsewhere on the web, or in Blackberry’s official documentation. This new GUI-based tool looks like a good place to start if you don’t like working from the command line.

Blackberry Playbook: Bargain 7″ Tablet

In the last few weeks the price of the Blackberry Playbook has plummeted further, to £169 in the UK from retailers such as PC World. At that price it deserved some research into what it offers & whether it’s worth a look. The tablet itself is solidly built, with a decent amount of processing power & good multi-tasking abilities. There’s an app store that offers a fair number of apps, including the obligatory Angry Birds, Plants vs Zombies, and useful stuff like free VNC clients.

The 7″ screen looks crisp & vivid, and isn’t as cramped as I’d imagined it would be. I’d viewed someone’s Samsung 7″ tablet so knew what to expect. Browsing the web on it is slick & fast, plus it’ll play Flash videos, so iPlayer, 4oD and other sites all work on it without a hitch.

The OS is soon to get v2.0, and that’s where things get even more interesting; that opens the Playbook up to the Android Market, allowing it to run a majority/proportion (not sure which yet!) of Android apps. OS2.0 will also offer MKV support, but what codecs are actually covered is unclear.

Built-in storage is limited to what you initially purchase (e.g. 16Gb), and there’s no SD card expansion. However, if you root the Playbook, there’s a method to add USB-host functionality, allowing you to attach USB flash drives.

A micro-HDMI connector allows it to mirror the display to a TV without proprietary adapters & it just works!

Here’s what you need if you want to hook it up to a TV (a few different cable lengths included):

Micro HDMI to HDMI adapter = £3.56

0.5m standard HDMI lead = £1.18
1.0m standard HDMI lead = £1.14
5.0m standard HDMI lead = £3.19

And here’s what you’d need to connect a standard USB flash drive

Micro USB to USB adapter (270 angle means it doesn’t clash with HDMI output) = £3.17
USB Female to Female adapter = £1.14

For the back of the car, I’ve gone for a generic headset mount that can also mount an iPad:

Universal tablet mount

And to protect it from scratches and minor droppage in the house I bought the official faux leather convertible case, which beats the hell out of the horrible case it ships with.

Faux Leather Convertible Case

After a few hours of research I knew it was a good deal, bought one & haven’t been disappointed. It *is* a bargain for what you get :)

Breathing new life into a Motorola Milestone

I’ve owned a Motorola Milestone for some time now.. but it’s never been the slickest of experiences and since the 2.2 Froyo update things have been a bit laggy. I’d started to look at custom ROMs, but the problem I see with custom ROMs is the risk of bricking the device, and there are a fair number of bugs in the custom ROMs which may mean I’d need to keep on top of the latest releases.

Instead of going all the way & installing a custom ROM, I went part way & rooted the phone using SuperOneClick, carefully reading all the instructions beforehand. I still messed up & didn’t run the app as Admin.. killing the app & re-running it fortunately didn’t have any nasty side-effects :)

Once the phone was rooted, I did very little else until I spotted this nice list of apps on Lifehacker. The one that peaked my interest was SetCPU, but when I ran that it topped out at 550 Mhz, which led me to find Milestone Overclock which allows you to overclock the phone without having to install a ROM that supports higher frequencies (like the official 2.2 update from Motorola).

I’m now running the phone comfortably at 800 Mhz.. but only when it needs it.. SetCPU will scale back the performance depending on what the phone is doing, which really helps with battery life.

Building a Zotac ION-based HTPC

I’ve been looking to replace my ageing Xbox which has reliably run XBMC for over 7 years with a box that can handle HD content, as well as acting as a NAS & download server. The Zotac ION box caught my eye, since the latest media center apps now support hardware acceleration for video playback & the nVidia ION GPU is supported.

Components

I bought the kit as a bundle from Mini-ITX.com and fitted a 32Gb SSD for the operating system, and a 1TB Western Digital Essentials HDD which would be attached via USB & powers down when not in use. The shopping list looks like this;

– Zotac ION-ITX-A Motherboard with Dual Core 1.6GHz Atom N330
– 2GB or 4GB DDR2 800 RAM included
– M350 Universal Mini-ITX Enclosure
(bundle costing £233 from Mini-ITX)

– OCZ Onyx 32GB SATA II 2.5in Solid State Disk
(about £50 from Amazon)

– 1TB Western Digital Essentials
(about £45 from Amazon)

OS

For the OS I wanted to use Windows 7; that’s what I’m most comfortable writing scripts + code for. The Linux distros for XBMC Live look pretty good, but there was too much of a learning curve involved for adding in the extra features I wanted.

Installing OS From USB

Since there’s no optical drive, I opted to install Windows 7 from a USB key. I actually used a 4Gb SD card from my camera & a SD card reader, and followed these instructions to make it bootable & have the Windows 7 installation on it. Installation went without a hitch.

Media Player

After installing the OS, I updated with the latest nVidia drivers, and started installing apps like XBMC. The latest Dharma release of XBMC supports hardware acceleration using DXVA2, however I was unable to get it working with 1080p content & gave up after a couple of hours. I then tried Media Portal which worked perfectly with whatever I threw at it. There’s a brilliant guide on how to configure Windows 7 and MediaPortal by Rhys Jones, which is useful to follow if you want to optimise your HTPC setup.

Remote Control

Next up was getting the remote control working correctly. I had a cheapo CyberLink remote, plus a Harmony 600.. I used the Cyberlink IR Reciever & mapped up keys into the Harmony 600. Some of the buttons worked, some didn’t. I ended up re-mapping the numeric keys to certain MediaPortal features using one of the plugins. I also re-mapped the MCE Green Button so that it runs MediaPortal (see this guide.. scroll to the Green Button heading).

Scripts

The HTPC also acts as a NAS + handles any downloads, so I’ve written a bunch of scripts to handle certain situtations.

– Timed execution of certain download tasks using Windows Scheduler. Making sure that the tasks don’t bring the HTPC out of sleep.
– Execution of scripts when the HTPC is brought out of sleep (like making sure MediaPortal is running)

Keyboard + Mouse Control

For times when I need a keyboard, I’m running Unified Remote on the HTPC and the client on my Android phone. This allows me to control most aspects of the HTPC via my phone, without having to buy extra hardware like a wireless mouse/keyboard.

Google Maps Navigation – Data Usage

Google unlocked the GPS navigation feature in the UK last week & one thing I wondered is how much data it used up as you drive the route it’s suggested… this is of interest to anyone on a metered tariff from their mobile provider. In my case I’m on an O2 business tariff that lets you download 200mb a month.

Google Navigate - Image from Mashable

To see how much data it used I first installed 3G Watchdog from the Android Market. Then I planned a route from work to home and headed off. From my unscientific tests it downloaded around 1mb of data in my 8 mile journey. Whether the duration of the journey makes a difference I’m not sure.. i.e. if you’re suck in traffic does it still pull/push data at the same rate as when you’re travelling? I’m assuming it won’t transfer as much, but it’ll still transfer something.

UPDATE: The actual per-mile download rate can’t be found by the method above. When you first plan the route, it’ll download and cache the data, then download small updates as you drive along. If you therefore plan your route at home whilst on a Wifi connection, then drive away (with route updates coming over 3G), you’ll get different results to what I documented above.

Ethernet Camera Review – Edimax IC-1310

Last week I bought one of these cameras to keep an eye on the house. After initially thinking I wanted the old D-Link DCS-900 I stumbled across the Edimax range of cameras. Here’s a summary of what they have available:

  • Edimax IC-1500 – Older model
  • Edimax IC-1510 – Updated version of the IC-1500 – ~£40
  • Edimax IC-1510wg – As per IC-1510 but adds wireless – ~£65
  • Edimax IC-1310 – Same as the IC-1510 but adds audio – ~£48
  • Edimax IC-1310wg – As per IC-1310 but adds wireless – ~£78

I went for the IC-1310 because I thought the audio might be useful, even if I didn’t use it at first. I also couldn’t justify the more expensive wireless model when I’ve got a couple of Belkin wireless APs in the loft that could be hooked up to add wireless at zero cost to me.

One week on, this camera is great, especially for the price! In low light the images are pretty decent, and in daylight they’re great. Some of the features require that you use Internet Explorer; e.g. getting audio as well as video requires their ActiveX control, as does the initial setup of the motion detection. However, most other features work through other web browsers like Firefox (I don’t think some people read all the documentation!) it’s all in the ‘CGI Commands’ manual on the Edimax website. You can get straight to the MJPG video stream or individual JPG images through whatever browser you like. However, I’ve not yet been able to get the audio and video stream mixed together on other browsers. The ActiveX control also doesn’t seem to work through corporate proxies.

Network setup is relatively trivial for anyone who knows their way around port forwarding in a router. It took me about 10 minutes to set everything up & make it available using a DynDNS host name for external viewing.

It hooked up to my Android phone without any problems, streaming the video over 3G using apps like ‘Tiny DVR‘ (which I’d recommend) or ‘IP Cam Viewer Lite‘. Over 3G the frame rate was about 1-2fps.. enough for a quick check on the house. Edimax have their own app for those with iPhones.

If you don’t need audio then go for the cheaper Edimax IC-1510 (which is currently about £40). I’ve had mine wired through a ethernet cable so can’t comment on the wireless side of things; if you want wireless then you need to see whether it’s worth the extra £30 to go from the IC-3010 to the IC-3010wg.

URLs that work through most non-IE web browsers are:

Single-image, not logged in (you define the file name to use);
http://IP:web_port/loginfree.jpg

MJPG Stream
http://IP:web_port/mjpg/video.mjpg

MJPG Stream with authentication
http://admin:password@IP:web_port/mjpg/video.mjpg