First off, work sent me to Chicago to learn how to code for iOS (iPhone, iPod, iPad, etc). Training was awesome. The small problem with it though was it was the day after my final exam for my business class. The business class is now over and I scored an A in that class. Just 4 more classes left!
I’m on vacation for the next week and a half and I’m going to take a break from studying. Maybe I will code up some iPhone apps…
I haven’t posted in a while! Let’s see…
Our house side was replaced in February. The roof was replaced in May. I small plumbing problem cropped up and I fixed that. That’s about it for the house…
Olessia graduated with her MBA (from BW) in May. Her mom came to see the commencement. She stayed for 3 weeks and we took her to several concerts and to New York.
Computer news: My main XP box suffered a hard drive failure. I replaced the drives with 2 1tb drives and installed Windows 7 Pro. This setup has been working out great. I also got a MacBook Pro for iOS development. This has been a bit of a live saver as well.
Phone news: Olessia finally has a smart phone – an iPhone 3G. She didn’t think she would need it and discovered how handy it is to be able to keep up with your personal email and to be able to play your favorite games. Like in good fashion, I waited for my friend to pick a phone and seeing if he liked it before getting a new phone. I went with the Atrix (Android). I’m already working on an app for it.
School news: Olessia is done. I’m still going. I started back at U. Akron last year (summer 2010) and I’m at the half way mark. When I started back, I had 10 classes left. Now it is 5 (4 in two weeks). I finished with A’s in Computer Security and Software Engineering. I’m in a business class right now. Next semester I have Linux Programming and after that, I will have just 3 classes left!
So some time in early November, after 50mph gusts, the siding blew off. I found it two houses over at the corner. The house looked like this until mid January until it could get fixed.
Now we have new siding! It looks a bit like this now:
New gutters and new siding all within a year. Not bad! Insulation and the roof is next.
Finally! I started fiddling with OpenVPN two years ago and put it aside until last week.
Real quick, OpenVPN is an open source virtual private network (VPN) solution. It uses SSL technology to encrypt a tunnel from one internet location to another internet location. DD-WRT is an alternative firmware available for a bunch of routers. With DD-WRT, the router runs a watered down flavor of Linux. Apps meant for full size Linux have been ported to run on the router, like OpenVPN.
I gave up on OpenVPN two years ago because I wasn’t a routing expert. I’m still not a routing expert. But I know how to google and I guess maybe I’m a better problem solver, since I passed calculus 1 and 2 (and heck, stats too). Two years ago I figured I’d use PPTP. It’s not an ideal solution since it can be easily hacked. The setup time for PPTP was insanely low – turn on the option, add some users, and you’re done!
This time, I was HIGHLY motivated to get OpenVPN working. Now and then I visit a network location which provides wireless but has a lot of stuff locked down. For example, I can’t send email out over their network unless I use their SMTP server (makes sense, limits spammers). I also want to be able to access the network at our house, get to file shares, etc. PPTP worked, but it was blocked at this one particular network. I tried to find out if the ports could be switched. It didn’t seem possible using the Windows PPTP client. OpenVPN was now an option again.
First, pick a port. I like 443. It’s the browser’s SSL port. I’m not running SSL on my web server so I don’t mind using 443 for vpn. You will need to install OpenVPN on the “server” (for me, it was my Linksys WRTSL54GS router). You will also need to install an OpenVPN client on your client machine(s). I went with the GUI option. You will need to setup the keys and certificates. I ended up using the easy-rsa utilities provided in the Windows OpenVPN client. I setup the keys and copied them to the proper spots (both server and client get certain files). Follow the easy-rsa key tutorial on openvpn.net.
Things get rather tricky from here on out. OpenVPN allows you to setup a routed tunnel or a bridged tunnel. The bridge is a bit chatty since it sends back and forth ALL data, while the routed version just sends targeted TCP/IP traffic. I went with bridged and my config files reflect it. You will need to setup config files for both the client and server. They have to be in tune with each other. You can’t mix and match with what you find out on the internet. Here’s what I used for my client:
remote [Your external IP address or domain name] 443
# Set log file verbosity.
The server config file looks like this:
server-bridge a.b.c.d a2.b2.c2.d2 a3.b3.c3.d3 a4.b4.c4.d4
push “dhcp-option DNS a.b.c.d”
keepalive 10 120
You will need to update some the a.b.c.d’s with your IP addresses. Here’s what you will need:
a.b.c.d = The IP address of the vpn server
a2.b2.c2.d2 = The netmask for the a.b.c.d IP address. If you are using 192.168.1.1, then 255.255.255.0 would go here.
a3.b3.c3.d3 and a4.b4.c4.d4 = An IP range that OpenVPN can use to give to the client. So a client connects to your VPN, they will get an IP from this range. Note, this IP should NOT be in conflict with any of your DHCP servers (if you are not using DHCP, you don’t need to worry then).
You may need to tweak the paths for the keys in both the client and server files.
Just when you think its almost over, there’s more! You have to setup routing on the server. Here’s the script I used to setup my routing on my Linksys router:
/opt/sbin/openvpn –mktun –dev tap0
brctl addif br0 tap0
ifconfig tap0 0.0.0.0 promisc up
iptables -A INPUT -i tap0 -j ACCEPT
iptables -I INPUT -p udp –dport 443 -j ACCEPT
iptables -A POSTROUTING –table nat -o eth1 -j MASQUERADE
openvpn [path to your server.config file]
The only thing you have to change in the above script is the path to openvpn, the server config file, and the port number if you are not using 443. I use this above script to launch OpenVPN. There was one catch to this script: I launch it from the startup script in the DD-WRT menu. For some reason, if you have the firewall enabled, the firewall takes a bit of time to start up and will overwrite these settings. So I added the sleep command (went with 60 which should work) followed by the command to run this script.
If you are going to do this with your router, make a backup! Heck, print out all the config screens (or the ones you know you modified), BEFORE you make any changes. I finished getting everything working and started fiddling with the firewall and something went terribly wrong and wouldn’t route traffic to the internet. Everything I tried wouldn’t fix it so I ended up having to reset the router.
With this setup, I can connect from just about any network to my home network. Plus, my internet gets routed through my home machine, which yes, isn’t fast, but it is secure. I can be on a hostile network and know my banking and browsing is safe. Plus, a lot of networks block ports and now I can wiggle around those restrictions.
I had an interesting application requirement: Take an integer (or long) and convert it into a text representation of a number. For example, the method accepts the number 1 and returns “One” and so on. The goal is to convert any positive integer (including zero) into its text representation. In C#, as of this writing, an int maxes out at 2,147,483,647.
Test Driven Development (TDD) applies very nicely to this problem. The solution to this problem may not be obvious at first glance (and in some cases, a bit overwhelming). Might I recommend a “divide and conquer” approach and we can leverage TDD to ensure our re-factoring didn’t break anything.
If you are comfy coding and with TDD, stop here and hammer out some code. If you are new to TDD, let me try to walk you through the process.
- Create a class which will handle the integer two text magic, let’s say “Int2Text.” Add a method string Convert(int number). Convert will take one number and return the text representation of the number.
- Start simple. Create a test case for a single digit number. Then write code to pass that test case.
- Add another test for another single digit number. Write some code and get that case to work. Did you break the previous test case? If so, refactor your code until both test cases are working.
- Create a couple more test cases that are below 20.
- Are all the tests passing? If so, look at your code. Do you see any code segments that are repeated or very similar to other sections? Can you refactor it? After refactoring, do your tests still pass?
- Do not continue on until you are confident your code can display text for 0 to 19 and all your tests are passing (note, this doesn’t mean you need 19 test cases and they all pass).
- Do you have 19 if statements? Or did you use 19 case statements in a switch? If so, think about refactoring.
- With all your tests passing, let’s think about the next step: Notice a pattern with numbers 20 and above (up to 99)? No? Do you notice a pattern when counting by 10, starting from 20? (such as 20, 30, 40, 50…) Don’t think about the numbers between the tens, like 21, 22, 23 – just ignore those and think about the tens – 20, 30, 40, 50.
- Add a test case for 20. Then write only the bare minimum to get this test to pass.
- Did it pass? Try 30. Create a test for 30 first. Then add code. Run your tests. Did any tests fail? If so, go back and fix your code so all tests pass.
- Can your code count from 20 to 90 by counting by tens? If so, can you refactor your code to simplify it? If you used switch or if statements for each tens number, you might think about refactoring.
- To count to 100, we need to be able to print the numbers between the tens, like 21, 22, 23, … 28, 29 and so on. Is there a pattern here? Your code knows how to display 1-9 and it knows how to display 20. Isn’t 21 just a combination of the word “twenty” and “one”? Your code knows how to display these. Can you use recursion to display 21? First create a test for 21 and then try writing some code. If the test passes, remember to try refactoring and testing your changes. Then add more test cases to try out different numbers. Think about some additional test cases to try out. Does 99 work?
- By this point, your code should be able to count from 0 to 99. How about 100? Make a test case for 100 and add code to get this to work.
- Notice that 100 to 119 look a bit like 0 to 19? Add some tests to try these number and add enough code to make these new tests pass without failing your old tests.
- How about counting to 200? 500? 999?
- If you made it this far, try 1000. 10,000. 100,000. 999,000. Can you simplify your code and use recursion?
- How about 1,000,000? 999,999,999? Have you tried 0?
I just got done wrapping up “Call Block Drop” Windows Mobile application. I’ve been getting tired of not being able to block calls. There are apps out there that do do this, but they cost money. So I wrote my own. You can block a call and have it go directly to voicemail, or you can have the call dropped.
I enjoy photography. I’m not good at it, but the hobby is fun. I’ve been reading some rather disturbing stories of citizens being arrested for photographing or video recording the police. Apparently, wiretapping laws are being used to arrest and hold citizens. Of course, if the footage is favorable, then no arrests. But if the footage shows cops in a bad light, then arrest is what you get.
Making matters worse, is these charges are being upheld in court!
Interestingly, anyone can photograph or video record anyone else when out in public. If you go out in public, you automatically assume a lack of a certain amount of privacy, including having your picture taken.
Cops are out in public. They are public servants. By not being able to photograph or record them, why do they get additional rights than the public? Who will be there to speak up when it is a cop’s word against a citizen in court? If a cop is doing nothing wrong, why can’t they be recorded in public? Why can they record us?
So far, it sucks to be you in Illinois, Maryland, and Massachusetts.