Sunday 9 June 2013

Violin metronome

For this piece I'm working on my teacher really wants me to focus on the rit. during this one phrase since I'm not slowing down enough, I'm only really doing the decrescendo. So I decided to write a little metronome program that uses my laptop's PC beep to mark the rhythm and using sleep to create the tempo. Then once it hits the rit. in the phrase I gradually increase the amount of time that it sleeps.

 Here's the source code:

#include <cstdio>
#include <Windows.h>
int main(){
  int sleep=850; // In milliseconds
  for(int beat=0; beat<=15;beat++){
    if(beat>11){
      sleep+=500;
    }
  printf("\a");
  Sleep(sleep);
  }
  printf("\a"); // Just as a reminder to mark the end of the fourth beat
}

Saturday 8 June 2013

SSH Tunneling

Last week I managed to configure OpenSSH(1) on my Arch server at home, hostname bluebeetle, to act as a SOCKS(2) tunnel so I could do a little more secure browsing when I'm at school, I used a Bash function(3) to launch the bound proxy in chromium on my laptop, hostname WhiskeyJack. This week I got a profile set up on my W7 box, hostname The-Mage, in PuTTY to connect through the SOCKS tunnel. While I was doing that I had the idea of seeing if I could use the tunnel to not only redirect my HTTP traffic through the tunnel but also if I could use the tunnel to connect low-level to the PostgreSQL server running on bluebeetle. After much tinkering around and a little goggling, plus a couple brain farts, I got the tunnel set up properly and I got the pgsql program I was writing to connect. Hint: it took longer than I care to admit that I should have changed bluebeetle's address in the source code from it's LAN address to 'localhost' since the tunnel was doing the routing not my router.