Subscribe. Follow. Stalk.

Tuesday, December 17, 2013

Why the car won't move

A man tries to start his car and finds that it wouldn't move. Some bystanders, a politician, a software engineer, a student of gender studies, and a financial analyst, walk towards the car.

They each come up with their own theories.

Politician: Clearly the car has been overburdened by heavy taxes and regulations that have forced it not to start. I propose cutting taxes for the car so that it will be able to move again.

Software engineer: It's probably a hardware issue. Have you tried turning it off and on again?

Student of gender studies: Clearly this car is protesting against the misogynistic empire run by men. Cars need equal rights.

Financial analyst: Based on the available data, I have downgraded this car to "under perform." You should sell it. I'll give you 200 bucks.

Ignoring the bystanders, the owner of the car takes out his phone and searches for possible causes. He solves the problem and drives away.

Sunday, December 1, 2013

Methods for bad situation

Flame method:
1. Stop (freaking out)
2. Drop (what you are doing)
3. Roll (with it)

Ice cream method:
1. Get ice cream
2. Eat ice cream
3. GOTO 1

Recursive method:
Handle Situation:
1. Handle Situation()

Static method:
1. print "I only have class"

Singleton method:
1. return badInstance

Thursday, November 28, 2013

What I am thankful for (a modern list)

  • Abundant supply of food, (maybe obesity should be thought of as a good thing)
  • Only having to eat turkey once a year (poultry in general is awful)
  • Black Friday. Only one more day!
  • Autotune. Imagine all of those celebrities singing without Autotune.
  • Mangoes. They are tasty
  • Internet. Where else would you watch sneezing pandas?
  • Twilight how else could we be able to make fun of vampires?
  • SSDs. Because HDDs suck. OCZ went bye bye...
  • Blogs. So I can post this
  • Computers, I would never make it as a physicist or a poet for that matter
  • Potato chips. Skinniness is overrated
  • Plastic surgery. Our world would look much worse off otherwise

Wednesday, November 27, 2013

Screaming at the choir

I have no idea what to write here. I just wanted to tell everyone that I'm not dead and that I've been crazy busy for the past few months. The title is really irrelevant.

Saturday, August 17, 2013

What is Yawn4life?

Ehh.. I have no idea. It was like 6 years ago. My blog has always been always been called this and I will stick by it (at least for now)

Monday, July 15, 2013

(sorta) Amazing keyboard shots

It's a beige keyboard! Bet you haven't seen one of those in a while.
I'm so bored

Alt

Side Alt

Blurry Ctrl

N

End



Friday, July 12, 2013

Enable tethering on AT&T LG Optimus G E970 for free

Read this: this might also work on AT&T Optimus G Pro E980. Also, there shouldn't be any damage to your phone if you follow these instructions exactly. Of course, I messed up my phone the first time I tried to do this... Proceed at your own risk

I discovered that the tethering functionality on my Optimus G was a pain to enable. After trying pretty much every free app on the Play Store that claimed to do hotspot, I discovered that AT&T must have a LOT of pull with LG. Unlike the popular samsung galaxy devices, you couldn't just download a hotspot toggle and be done with it. Also, FoxFi didn't work either (or at least the trial didn't).

Then I found a tethering app that required root. It worked after rooting my phone, but I couldn't get the WiFi back up afterwards without a restart. So in the end, I decided to get the built in tethering functionality to work. More after the jump.

Monday, June 24, 2013

Java vs Objective C

I often get the question: What is the difference between Java and Objective C? Well, I then give the same explanation I've given people over and over again... :/

They really are quite similar. Once you know one the other one comes to you quite easily. But they do have their own quirks.

  • Java is static. Objective C is dynamic. Basically, Java is a control freak bureaucracy that makes sure everything at compile time is ready to go. I won't say the same about Objective C
  • Objective C is based on C. Pretty obvious, but has some pretty annoying implications. Pointer problems, memory leaks and whatever else that you hate about C will likely apply here.
  • Objective C classes need more than one file (header + implementation). Kind of annoying at best. Really annoying at worst.
  • Objective C has categories. Remember how I said Objective C was dynamic? Well, you can even add methods to pre existing classes w/o the need to subclass
  • Java is garbage collected. Honestly, the time saved from finding annoying memory bugs is worth the overhead for GC.
  • Java can be compiled and run anywhere. I don't really care for this one, but it is a difference between the two.

Thursday, June 20, 2013

How to pronouce char

Throughout all of my life I was intent on calling 'char' as char (rhymes with bar). I few months ago a heard someone say 'care'. It was the most horrifying moment of my life. I didn't know what to make of it. How could someone say something illogical!? Anyway, I didn't really care, but I still maintain that my pronunciation is better.

Here's why...

  • Charred. That burned blackened stuff. See? Nobody said care.
  • Char star (non-C people won't get this) Care star sounds like it belongs in a pink pony book.
  • Char sounds like slang for 'character'. But characters != char. Char is a numerical value, while character is something dragged out of some (human) language.

I also know people who pronounce char like 'car'. Those people don't bother me as much as the ones who say 'care'. Anyway, I wrote this blog post mostly because I didn't know what else to write.

Wednesday, June 19, 2013

Linux is great. Linux is high maintanance

Ok. So I've used Linux on and off for roughly the past ten years now and I have to say that while Linux is a bit better than it used to be, I find that using windows is a much better experience. That being said, I prefer the bash shell to whatever that cmd crap is. Honestly, the biggest annoyance of Linux in my mind is maintenance. For some reason or another, I have never had a successful installation of Linux (except Fedora 13) where it didn't freeze up on me and I would have to restart gnome.

A few years ago I thought my solution to this was to use a mac. After all, they couldn't be as unreliable as linux and it would be nice to have a shell that behaves more like the ones in linux distros. Sadly, that didn't work out too well (hardware randomly started failing... I felt each event was like a mini heart attack)

So here I am back on windows. I now ssh into my VM whenever I want to use a linux box. To make my own physical box closer seeming to windows, I use cygwin. The installation thing is kind of strange to use but it works well and I'm happy.


Saturday, June 8, 2013

Learning Java Part 0

This is going to be part 0 of a three part series. I hope everyone learns why I chose to start with 0 rather than 1 by the end of the series.

Java. It's everywhere. In phones, robots, and toasters. Most of the challenge with learning a language when you've never programmed before is the underlying logic and the strange subtleties of the syntax. That's why I'm not going to teach general syntax first. Instead, I'm just going to go over a few language constructs that are commonly seen in nearly any language.

Variable - something that stores a piece of data. Variables often come with types that tell the computer what kind of data that you are storing. Some of the types include

int - for most intents and purposes, treat this just like you would if it were a regular integer
double - it can store values with a decimal point. 123 or 12.3
boolean - only has two values: true or false
Object - stores a object reference. We will look at objects more in depth on another day

These are the four data types that you will work with the most when programming. There are a lot more that I have not mentioned but they are not hard to learn. Generally speaking, you can do math on these operators such as + - * /. You can also find the remainder using %, which you will hear some people call mod. The order of these operations follows PEMDAS, so use parenthesis if you are unsure that your ordering is correct

Here are a few examples of variables...

int a; // The '//' tells the computer to ignore what goes after it on that particular line. This way you can comment your code.
/* both of these are commenting styles
This one can span multiple lines */
double b = 1.7; // we can also set values to these variables
boolean c;
Object d;// Notice the semi-colon at the end of each line, this tells the computer where one instruction ends and where the next one begins

Great, now that we have figured out variables, lets go on to two basic constructs: ifs and loops

Before we can start talking about ifs and loops, there are a few things we need to clear away first. Remember how we talked about boolean? Well, it turns out that boolean is actually pretty important. There are times when we want to test whether something is true or false, such as testing if int a is equal to 5.
The most important boolean operators you will need to know are these:

Equals ==, it has two equal signs because the single equal sign = is used for setting a variable.
Not equals !=
Less than a < b This returns true if a is less than b
Greater than a > b This returns true if a is greater than b
Greater than or equal to >= same idea
Less than or equal to <= you get the point.

AND &&, this returns true if both conditions are true
OR || this returns true as long as either condition is true
NOT ! changes from true to false and vice versa

Here's how if's work.
if (something here is true) {run this code}

Sometimes there might be else attached. This is optional and run when the condition is false
if (something here is true) {run this code} else {run this code instead}

Here are some examples:

 int j = 2;
 if (j == 3) {
 // this code will not get run because j is not equal to 3
 } else {
  // this code will run!
 }
 // carry on with rest of program
 ------------------------------
 int d = 5;
 if (d == 5) {
 // d is equal to 5, so this code runs!
 }
 // carry on with rest of program

Hopefully you can now see how easy this is. Lets move on to loops..

There are two kinds of loops that I want you to be familar with: for and while use them when you have code that repeats itself

I've gotten addicted to this song


Wednesday, May 29, 2013

Why Recursion is Bad (shorter version)

Recursion is where you try to attempt a problem, give up, and let it try again...

Sunday, May 19, 2013

Recursion is bad

Before crazy people start sending me threatening emails, I agree there is a time and place where recursion is probably ideal (Quicksort?) That being said, its better to use other options where possible. (Please do not do binary tree problems iteratively. Ok Carry on)

Repeat after me. I will never use recursion unless there is no better alternative. There are times when recursion is a necessary evil but it's an evil that should be avoided wherever possible.

Recursion eats up memory on the call stack. Every time a function is called there is going to be an overhead associated with saving register values into memory. This adds up fairly quickly when doing recursion. Since the compiler cannot really optimize recursion since it can't predict how many times it will recurse that also will contribute to the performance hit. Once recursion goes too far it causes Stack Overflow, and life just sucks.

There are people out there who call recursion 'beautiful'. I personally think loops make more sense since they don't seem as weird. Making recursive code requires a leap of faith assuming that your code is doing the correct thing its supposed to do even though your not done writing it yet. (What did I just say??)

Basically recursion is bad. But if you have to use it wash your hands afterwards. You can do recursive questions with your own stack, but I don't see the point.

Wednesday, May 1, 2013

How to type faster

Once of the most common questions i have ever gotten is: Ben how do you type so fast. I generally make a joke that most of what I write is full of typos (which is true) but there are a few ways that you can type faster

  1. Keep in mind that you are trying to type faster. Often I type at only 30 wpm due to the fact that I am not really in a rush or trying to type faster. If you try to type faster, generally you will be able to type faster.
  2. Type hard to reach keys properly. It wasn't until a few years ago before I realized how much faster I could type if I simply hit the period and comma keys with my fingers in the home position rather than have my hand move down to the lower part of the keyboard and hit the key that I wanted. Other keys that are commonly cheated are the z and the x at the bottom left of the keyboard. Do those in the same manner. It will take some time to get used to, but it really is worth it.
  3. Practice. For the people who are reading this blog, this shouldn't be an issue for you. You should have a lot of opportunities to practice your typing. Type in search queries as fast as you can. Write anything - emails, essays whatever using proper typing techniques.
  4. Play some games! My personal favorite is typingtest.com They have games and typing tests alike. I usually do some typing tests from time to time to make sure that my typing speeds have not gone down and then I play a few games (my favorite is the ones with the bubbles)
Over and out

Ben

Friday, April 26, 2013

When days are insanely busy

As the number of things to do each day increases faster than you can hope to get them done, the only hope is that better time organization will help you survive those days. Unfortunatly, there is only a limited amount of time organization possible. At a certain point, if there isn't any time, then there isn't any time.

Here are some things to do if organizing time does not work
  • Push it back. If it does not need to be done immediately (and there are other tasks with greater priority) then there is no point in getting it done early.
  • Use google calendar. Place every task you need to do as a calendar event. Set a time for each task and it's approximate length. To avoid a domino effect if one task takes longer than expected, give every task slightly more time than you hope to complete it with. Follow your calendar as closely as possible. Try to multitask. For example, if you have to read, do it on the bus rather than at a desk, when you could be working on something that might require a desk.
  • Delegate. There are other people out there. Don't do the work of 5 people on your own.
  • Double check. Are you sure you have to do all of this? Make sure that there was no miscommunication before wasting hours of your precious time.

Friday, April 19, 2013

April 2013

I have nothing to say.

Sunday, March 24, 2013

Java can get annoying

There are times when Java is wonderful, such as its cross platform-ness and its garbage collection. Then there are times when I feel that there could be some ways to improve Java.

Before I go about talking about all of Java's shortcommings, I just want to say that Java is pretty well done. Compared to languages that came before it, Java is a lifesaver. It's also the reason we have C# (for all the people in Microsoftland) and the reason we have all of those strange languages that decided to run in the JVM (for all of the people who put up with Scala and JRuby). Overall, it is the language that people like to ask about, since it is the one that people know about. The syntax is clear, and it doesn't have 3 trillion ways to print out a single line of text. Even so, there are times I wish Java was better.

  • Consistency. String and array use length when you want to determine their length. On the other hand, the List interface uses Size. Please choose one or the other, I don't like to have the compiler spew errors about such pointless subtleties.
  • JRE. If you make a application with Java (and you are mainly developing for windows), its a pain to make sure that the user can run your application. Hopefully, they will have the same version JRE as you did when you compiled it. If not, the application might not start. So you decide to bundle the JRE with your application, but that seems like a strange extra step for a language that you "write once, use anywhere"
  • Parsing JSON. Regardless of the parser that you choose to use, you will either get a zillion warnings or cast everything until the apocalypse. The compiler has no faith in the programmer that they got the type right, and is determined to save humanity by refusing to compile until every last 'error' is addressed. What a nightmare.
  • Generics. I understand Java's reasoning with generics, but I still wish it was done better (like in Scala) Due to the way java separates primitives and objects, some classes contain one method for all objects as a parameter, and then a zillion different methods for int, float, double, long etc. Wrapper classes are also necessary if you want to place an int into a List. While they have made substantial improvements regarding how they wrap and unwrap the primitive, it's still rather inconsistent to type List rather than just List. Sure, it tells the coder that the List is actually storing Integer wrapper objects rather than ints, but I don't think that will cause anyone to reconsider how they write their code. It would be a nice note to make in the docs, but not something that anyone really cares for.
  • Security. You've read the articles. I don't need to say anymore.
I've always been curious as to why Sun never bothered to give the option of compiling to JVM or native. In the early days, Java was turtleneck slow and it would have been a much more compelling alternative to C++ if the performance gap was smaller. That isn't such a big deal now, with better computers and a more mature JVM, but it is still something that I will never understand.

Friday, March 8, 2013

Power

In the physics world, power is simply the energy divided by the change in time. Sadly the rest of the world isn't really interested in this idea.

There's something alluring about power to people. Maybe its the shiny bars of gold that sit around in some of the world's largest gold reserves. Maybe they just like seeing other people miserable. The odd thing about power is that we all think it would make our lives better but we have neither empirical nor scientific evidence of that ever happening.

It's strange.

Sunday, March 3, 2013

Native Apps, Web Apps, and Whatever's left

Having the wonderful opportunity to create and use mobile apps has been sheer fun for me. I find it fairly amusing to see how other people make their apps and some of the pros and cons that are associated with each decision. In general, I like to categorize apps into three different categories: Native, Web, and Whatever's Left. Let's begin

Native.
These are the apps that are written in the language that the SDK is written in. Performance is generally fast and developers get access to hardware on the device such as the camera or the accelerometer. The GUI is built directly on View elements provided in the SDK. Since they are stored on the local device, much of the app is ready to go and has relatively little waiting.

Web.
These are apps that run in the browser. People have to type a web address into the URL bar and wait for the thing to load. They can be updated at any time since they are stored on a server rather than the local device. Can be extremely flexible since layout and design are done in HTML, which are easier to handle than the view objects provided by the SDKs for native apps. The browser in which these apps are run in often have optimizations which make the apps load somewhat faster.

Whatever's left
The worst of both worlds. Hybrid apps. Slow loading times and fairly rigid. Load times can be much slower than Native or even Web. Easier to bring interesting interface designs due to the broad range of things available to use for the app. Developer has no control over the web view, which may or may not adhere to standards extremely well.

Saturday, March 2, 2013

The blink tag

In my past decade or so of dealing with HTML and inconsistently applied web standards, my favorite HTML tag by far is BLINK. Even though it was never supported by IE and one of those strange things that Netscape cooked up in the 90's, I felt that the blink tag showed that the web browser should be capable of generating dynamic client side content without the need of a lot of javascript (remember, old browsers were slow at javascript)

Now, the W3C has blink as part of CSS text-decoration, the past still shows. Netscape's successor, Firefox, will happily blink text for you while Mammon still refuses to do so. It really is a shame. The only way to blink text with cross browser support is to use javascript.

Should you use the blink tag? Of course not. Unless you are trying to give your enemies (who do not use IE) seizures.

Thursday, January 3, 2013

More contradictory stuff

Facebook is too optimistic.


Tuesday, January 1, 2013

Crap

I've gone through every curly brace and I have two completely contradictory errors