Fail of the day #004

Todays fail of the day:

Do NEVER update the apache-server! If the new feature doesn’t work, just delete the feature!

But why?

It uses some … functions that are not only deprecated, but won’t work anymore, if you aren’t careful. Trust me. Either you stay with the old version, or just recode the hole system.

Tagged , ,

“Why does my computer need an anti-virus software?”

Why does my computer need an anti-virus software? I only use it for E-Mail and facebook, nothing like online-banking. Why should someone hack my PC? There’s nothing interesting here!

Shut up and look at this.

Chart of uses for a hacked pc

This is a very good chart by Brian Krebs, the author of Krebs on Security, which shows the different ways a hacked PC can be used by hackers. If someone ever asks why he should install an anti-virus software, just show him that chart (and explain it. Maybe not everybody will understand it).

Tagged , , , , , , , ,

Todays fail of the day:

result = ((IIdentifiable) this).getId();

Looks stupid, but works. And it’s needed, which angers me a little bit. Maybe I should scrap the design.

 

Fail of the day #003

Tagged , , , , ,

Todays fail of the day:

“Ah, can you tell me where room 21 is?”

“Yes, you go left, two floors up, turn right, left, second right, get a ticket in the waiting room, go through the green hallway – the green one, not the red – enter the next waiting room, turn left, go over the bridge, go one floor down, turn left twice, follow the floor and enter the waiting room for questions concerning driving-licenses. There you ask, whether the room 21 is used. If it’s not, you need to get a ticket for vehicle registrations. Then you need to go to the first floor in sector two, where you can wait for your number being called. If the room 21 is used, you may wait in the first waiting room you entered.”

“Err … Thanks for the info.”

Why must agencies always be so complicated? I mean, they have bridges inside their buildings. Bridges! Or sectors! Who the fuck needs this?

Fail of the day #002

Tagged , , , , ,

Loading an error-image instead of missing image in Ren’Py

This is a little snippet that can be used if you want to load an error-image if an image that should be loaded wasn’t found.

def missing_image_callback(s):
    return im.Image("error.png")

config.missing_image_callback = missing_image_callback

This automatically loads the error.png if an image isn’t found. You can extend the function by logging or whatever you want, to do more in that case.

Tagged , , ,

Git behind a proxy & large commits.

Today I finally tried to pull a git repo with my new PC. It’s not the first time, but again the same problem came into my way: Git over a proxy.

If you sit behind a proxy, just open your bash and type the following:

git config --global http.proxy http://your.proxy.server

You can also specify a port or your authentication-data for digest-authentication:

git config --global http.proxy http://name:password@your.proxy.server:port

To add a SSL-Proxy, you need to use the setting https.proxy.

Another problem that occurred to me, was that I had a reeeeeeaaaaal big commit. It was several megabyte large, so git had a problem with it. It just said

error: RPC failed; result=22, HTTP code = 411
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

All I needed to do, is setting the post-buffer higher:

git config http.postBuffer 524288000

That means that I can now push up to 500 MB. More than I will ever need.

… And I hope that I never need to pull 500 MB.

 

Tagged , , ,

Enable ELAN touchpad while typing

So that new shiny lenovo N581 is nice and everything … but wait. I can’t play any game. What the …

The touchpad is disabled by default.

That’s nice if you type texts and stuff, but playing is impossible. Duck, aim, strafe and shoot – Not possible by default. So how do you enable the touchpad while typing? Some googling helped me to find the obvious: Try the driver-settings! (Not like I haven’t done it. Why should I?) The problem is the following: The setting isn’t there.

Here’s the solution: To see all the settings, you must open regedit and navigate to HKEY_CURRENT_USER/Software/Elantech/SmartPadDisplay, there you can modify what you want to see. Setting the value of TouchPadRejection to 1 shows you one more option in the driver-settings. Play with it and see your result :D ! (Don’t worry, you can’t destroy anything.)

 

Tagged , , , , , , , ,

For the next time, I’ll post some funny or not so funny fails I encountered the day.

Todays fail of the day: Install the anti-virus-software in Sandboxie, to make it more secure.

Fail of the day #001

Tagged , , ,

JUnit: How to not test exceptions

If you’re using JUnit to test your code (and I hope, that you test your code), maybe you want to test a method like the following:

public void someMethod(Object param) {
    if (param == null) throw new IllegalArgumentException("param was null!");
}

JUnit offers a nice way for testing exception, using the expected parameter in the @Test-annotation.

@Test(expected = IllegalArgumentException.class)
public void someTest() {
    someObject.someMethod(null);
}

That’s okay here. But what if …

public void someMethod(Object param) {
    if (param == null) throw new IllegalArgumentException("param was null!");
    throw new IllegalArgumentException("Ooops");
}

Why would someone do this? Don’t ask me. But hey, it’s only an example, you understand what I mean.

The test still runs perfectly. But what if …

… we delete the if (param == null) line? Let’s do this and look … The test still runs. Which is bad. Actually, the test isn’t complete; it tests whether an exception is thrown, but not which.

To do it better, we need a Junit ruleExpectedException. Therefore, we introduce a new field in our testclass:

@Rule public ExpectedException exception = ExpectedException.none();

With that, we can modify our test-case:

@Test
public void someTest() {
    exception.expect(IllegalArgumentException.class);
    exception.expectMessage("param was null!");

    someObject.someMethod(null);
}

That’s much better. It not only checks whether the type of the exception is correct, but it also asserts that the message is correct. That helps us more.

To conclude some very hurting code I’ve seen, not long ago:

@Test(expected = Exception.class)
public void someTest() {
    // Much crazy shit here
    someObject.someMethod(null);
    // More crazy shit here
}

What could possibly go wrong? Everything.

Imagine the first crazy shit is wrong. IOException => Bamm => Test succeeds.

Or: someObject isn’t initialized. NullPointerException => Bamm => Test succeeds.

What happens if your someMethod doesn’t work, but the second crazy shit is broken? AssertionError => Bamm => Test succeeds.

So keep one thing in mind: Never use @Test(expected if you don’t have a good reason to do so.

And test your fucking code.

 

Tagged , , , , , , , ,
Follow

Get every new post delivered to your Inbox.

Join 30 other followers

%d bloggers like this: