Wednesday, May 25, 2016

Http proxying through an ssl tunnel

I have found useful in the past the use of a simple http proxy in one location (e.g tinyproxy), that listens on a local port (e.g localhost:8888)

And an ssl tunnel to that system that effectively maps a local port (e.g 8080) to the remote one.
Assuming the proxy on the other side is up and running, we can do the following:

ssh  -L 8080:localhost:8888 remote-server-with-proxy-service

Now we can configure one of our local browsers to use local port 8080 and access the proxy on the other side.
A useful trick if we need to access services geographically restricted (e.g tv streaming etc)

Sunday, May 22, 2016

Haskell in production

Interested in haskell in production?  Take a look at this http://www.stephendiehl.com/posts/production.html

Saturday, May 14, 2016

LiquidCrystal Displays compatible with the Hitachi HD44780 driver and arduino pin mapping

These lcds are cheap and retro and work with most arduino boards even if you do not have i2c. They are using a bunch of digital pins for the communication.
The full details about the various pins can be found here.

There is an arduino shield that can be used for fast prototyping with a weird (at least for me) pin mapping. The pin mapping the shield is using is: lcd(8, 9, 4, 5, 6, 7).

However if you buy a naked lcd, you can wire it up any way you like. Unfortunately if you are using the shield to develop your app and have a different pin mapping in your naked lcd, that means that you need to modify the code between debugging and normal mode, or wire your lcd in the same way with the shield.

Most code examples out there are using the shield mapping as well.

Anyway. The lcd has 16 pins. Some of them can be wired only one way:

  • VSS (pin 1) -> Ground
  • VDD (pin 2) -> 5Volt
  • V0 (pin 3) -> 10K resistor/pot (this pin controls the contrast)
  • R/W (pin 5) -> Ground
  • A (pin15) -> 10K resistor/pot (this pin controls the backlight)
  • K (pin 16) -> Ground

and there are another 6 data pins that can be wired any way we like. The shield mapping is the following:

  • RS (pin 4) -> Digital pin 8
  • E (pin 6) -> Digital pin 9
  • D4 (pin11) -> Digital pin 4
  • D5 (pin12) -> Digital pin 5
  • D6 (pin13) -> Digital pin 6
  • D7 (pin14) -> Digital pin 7
The pins D0 up to D4 are not being used, since we are using the screen in 4bit mode.

This mapping should allow you to have the same mapping between your development environment and your final setup.

Friday, May 13, 2016

Cleaning hazy photos

Using gimp, multiple passes of the unsharpen mask filter with a radius of 50 and an amount of 0.2 will usually do the trick. After a certain point noise is introduced, so caution is needed.

The documentation for the filter can be found here https://docs.gimp.org/en/plug-in-unsharp-mask.html

Saturday, May 7, 2016

Verifying https key and certificate match

Sometimes it is difficult to verify if your https key matches your https certificate.

In these cases you can use the following commands:

openssl x509 -noout -modulus -in /etc/yourcertificate.crt | openssl md5 
openssl rsa -noout -modulus -in /etc/private.key | openssl md5

Also keep in mind that the CN name of the certificate sign request (CSR) needs to match the CN of the certificate.

If you have more than one domain entries in the certificate, the first one is the CN. Multiple https virtualhost definitions (including the default ssl.conf) may confuse apache.