Wednesday, January 29, 2014

Getting Generic Types in Java

Due to some crazy inter-process communication, and serialization I needed to do I ended up with an interesting problem.  Now I will admit I was probably over complicating things, or doing something I didn't need to do, but I had a lot of fun writing this and learning about the internal workings of the JVM.

The problem, I needed to be able to check if a specific method of Class that implements my interface, if it's signature matches objects that I receive elsewhere.  Now I didn't want to just execute this method and throw an exception since it would occur at a later time.  I needed to check at the moment I get the parameters so I can give the user (probably more likely the programmer using my library) a reliable and easy to understand error message if it doesn't match.

After looking on stack overflow most posts that were looking to do the same thing the responses where you can't.  Now I'm not generally one to let things go and if someone says you can't I try to prove them wrong.  Well anyways here is some sample code that demonstraits how you can get this.  There are some catches and some special cases I actually handled in my code, but this should get the point across. It's by no means elegain and I would recommend you try to find better ways, but if you really need to do this, well here you go.


Thursday, January 23, 2014

Run Netflix on Linux round two

A post or two ago I suggested using a VM to run netflix.  Although this isn't the most ideal option it does happen to work.  Well since then I have found a more ideal option.  Some very nice people have created packages for different linux systems that put together wine, silverlight and some other packages to create an easy to install netflix application for your system.


Tuesday, January 7, 2014

Download an HTML Table With JavaScript

I needed to download a list of users for the same website I talked about in my last blog post.  For whatever reason Joomla doesn't have an export function.  We are using a very old version, I don't know much about Joomla, and I didn't have access to the database.  So, I did the only thing I knew how, loop through the table grabbing the values with JavaScript.

Here is how I did it.  I post it here in hopes that is helpful to someone else, or myself when I forget how I did it in a few days (hello future self).


Sunday, January 5, 2014

Adding Water Marks to Images: Bash Script

I got tasked with building a website for the Boy Scout Troop I am affiliated with.  With that came lots and lots of photos people wanted to view.  About 6.6GB in total.  These images also needed to be water marked.  We are using Square Space because of it's ease of use, but there is no way to have it automatically watermark the images.  So I stitched some scripts together and came up with the following.

It's not the prettiest thing I have ever written but it get's the job done.  There are a lot more options that could be added in; oh well maybe another day.

Saturday, January 4, 2014

Changing My Diet

I recently completely changed my diet. I went from eating a pound of bacon for breakfast to eating bananas and apples. From eating McDonalds for lunch to a salad, and from eating hot wings for dinner to eating, well another salad. People have asked why and rather than go into the gory details with everyone I thought could give them a little overview and tell them they can come here to check out the whole story.

I was having some strange issues, some related to food others I had no idea where related to food. One issue was my stomach hurting really bad, especially at about 6am. Another was certain foods would cause me to be running for the bathroom about a half hour after eating them. I couldn’t put my finger on what foods were causing this issue, and I thought it was more that I was eating fast food and such and though everyone had these issues.

My mother had some issues, although she never told me exactly what they were, I know one was a breathing issues. After lots and lots of tests from doctors she never received any definitive answer on what the issue was. She was pretty much expected to be taking steroids for the rest of her life. Not something to look forward too. She eventually come across something called the LEAP test/diet. She took a blood test and found out what foods she was sensitive to, cut these foods out and amazingly her breathing problems went away.

Because of my symptoms my mother suggested that I get this test as well. The test itself is very simple. You go get your blood drawn and in a week or so you receive the results by mail.

After receiving these results I went on an elimination diet, basically for two weeks I ate only things that were very low on my sensitivity results, and then after the two weeks I slowly started adding other foods back in. This is where everything changed.

The first thing I noticed while on this diet was that I was always hungry, my stomach would feel like it was going to burst, but I wanted to eat more, it was very odd. Secondly, after a day or so, and lasting for about a week and a half, I was depressed. Now I like to think of myself as an intelligent person, and I know I didn’t have a reason to be depressed, and I knew that both of these symptoms seem to be coming after I made a pretty big change in diet, so I started thinking, and my conclusion was, this was the first time in my life I had not had sugar, or a bunch of random chemicals in my diet. My diet at this point consisted mostly of potatoes, apples, and beef.

At about two weeks I started to feel a lot better. The symptoms both from changing my diet, and the symptoms that caused me to go on this diet had seem to have all gone away. Other things I had never thought were food related stopped too. Feeling extremely tired at 1pm every day, had gone away!. For the last 6 years I would get a cough in the fall and it would last most of the winter, gone! Weird eye twitch I thought was from staring at computers for about 80% of my day, gone! Back and knees being sore (not a good sign at my age, but I assumed it was from all the skateboarding and snowboard I did), gone! I was feeling amazing, but with the realization of what caused the depression made me do a lot more research.

Now, I am not going to post links or even go on about MSG, or sugar or anything else, but the research I did scared me. Where our food comes from, scared me, what is being done to it and so on, all scares me. From there I started to create rules about what I was going to eat. The first and easiest one was no white powders. No more sugar, salt, that sort of thing. But as I continued doing my research and looking at different ways of eating, I started to realize I need more fruit and veggies in my diet, I also wanted less chemicals. This lead me down the path of vegan, since milk, eggs, and meat have lots and lots of chemicals poured into them (on a side note, not eating meat is significantly more environmentally friendly too). But, as I looked at the vegan lifestyle I found that well, oreos are vegan! I needed something better something that made sense.

I finally found raw vegan. Now I don’t fully embrace it, I shoot for about 80% raw (I need my coffee). This works for me, and I feel great! Anytime I stray from the path, there are generally noticeable consequences that make me immediately go back. Some other crazy things I have noticed since I have made these changes are my hair is softer and fluffier, my finger nails grow crazy fast, I don’t get pit stains. Yeah, that last one is weird. I have been rock climbing and where I use to be super sweaty and gross, I’m not. It’s just gone! Another thing I have found, is I no longer make food an event. I don’t look forward to going out to eat. I don’t get cravings for a food. I no longer live to eat. I eat to live, which actually makes me realize a lot of strange behaviors I use to have.

In conclusion, I have decided to adopt a mostly raw vegan diet, consuming mostly non cooked foods. The foods I do consume that are not raw are still vegan. This choice was made after doing lots of research about our food, where it comes from and what’s in it. I have noticed some beneficial changes in my life, the most notable one being I don’t feel tired and groggy all the time. I feel great!