Archive for the ‘Writing’ Category

Applying NVIDIA Hotfix (KB940105) for Windows Vista

Thursday, December 27th, 2007

A few friends of mine running Vista have had troubles installing the NVIDIA hotfix described in KB940105. The hotfix is downloadable as Windows6.0-KB940105-x86.msu and can be installed using the following steps:

Unpack the hotfix

expand -f:* "Windows6.0-KB940105-x86.msu" %TEMP%

Apply the hotfix (you will be prompted about whether to allow or not)

pkgmgr.exe /n:%TEMP%Windows6.0-KB940105-x86.xml

PHP: Secure Your Included Files

Tuesday, November 13th, 2007

If you’re anything like me, you heavily rely on splitting things up. Even the simplest application needs to be separated into individual files for functions, database calls and user interface. The files are usually named and placed so that they are easily accessible for the index file and inconvenient to find for the potential attacker.

If the attacker where to reveal their path it would not necessarily pose a serious threat to the application’s security, assuming executing the individual file on its own does not give away any useful debugging information. To avoid helping people exploit your applications you may consider to turn off the standard PHP behaviour of throwing out all possible information as soon as something goes wrong: Either set “error_reporting†to “0†in php.ini or through your .htaccess-file.

Additionally you might consider isolating your files from even executing on their own. The easy way to do this is to:

define a function in the main file (index.php) only allow execution of additional files if the defined function is able to execute

index.php

<?php function LoadedCorrectly() { return true; } ?>

database.php

<?php LoadedCorrectly() or die(); ?>

Interesting Photos Taken in Paris

Sunday, October 14th, 2007

A close friend of mine recently visited Paris, France equipped with his brand new Nikon D40.

[image]

[image]

Get Sound Working For Quake-based Games

Sunday, October 7th, 2007

Running games such as Quake III, Enemy Territory or Return To Castle Wolfenstein on Linux will sometimes fail to initialize sound. After modifying a generic fix for this problem I wrote this:


APP="${1}.x86"
echo "${APP} 0 0 disable" > /proc/asound/card0/pcm0c/oss
echo "${APP} 0 0 direct" > /proc/asound/card0/pcm0p/oss
echo "${APP} 0 0 disable" > /proc/asound/card0/pcm1c/oss

To use it, simply run the script with the game binary’s name as an argument:

# Fix sound for RTCW single player
sh sound-fix.sh wolfsp
# Fix sound for Enemy Territory
sh sound-fix.sh et

Possible Future Career

Sunday, September 30th, 2007

I think I’ve finally figured what I want to do for the rest of my life. My humble dream is to get a Master of Science degree in Chemical Engineering, probably at Lund university or Chalmers (Gothenburg).

Some fields I think would be very fun to research:

Bio-fuel: Creating more efficient production methods and cheaper ways to “upgrade” the gas. Nuclear waste management: How to dispose of nuclear waste as safe and reliable as possible. Chemical computing: Initial attempts of creating a computer made out of chemicals has already been done successfully. In the future computers may consist of chemicals replacing the electronic grinds used to perform calculations today. Hydrogen-fuel: Better methods of extracting hydrogen for fuel-cells and engines.

Turning Spreadsheets Into Database Tables

Thursday, June 14th, 2007

While developing database-driven applications or building a database with bogus information for testing purpose, the traditional interfaces for adding values to each table are often utterly complex or require too many mouse-clicks per entry. Wouldn’t it be nice to import a plain spreadsheet created in OpenOffice Calc or Excel straight into your database? This article will introduce a technique making it possible.

(more…)

8 Random Facts

Tuesday, June 12th, 2007

Apparently my fellow blogger Lasse has tagged me in this popular (but childish) blog game called 8 random facts. The first rule of 8 random facts is not that you do no talk about 8 random facts, instead the first rule states that you should give away the rules:

Players start with 8 random facts about themselves. Those who are tagged should post these rules and their 8 random facts. Players should tag eight other people and notify them that they have been tagged.

(more…)

What My Programming Course Taught Me

Monday, June 4th, 2007

For the past term I have been taking a specialized course in which the teacher was kind enough to combine a course called programming A and another one called database management. The idea was to use PHP together with MySQL to put together various assignments. After solving a couple of assignments I started out working on the main project, a webshop with basic features. With one week to go I think that I have learnt several things from the course so far:

(more…)

Not a Big Fan of Data Loss

Friday, June 1st, 2007

In this post I will summarize my own personal backup approach, which might give you some fresh ideas about backups, especially if you are a Linux user.

(more…)

Resume Unknown Screen

Wednesday, May 23rd, 2007

Sometimes you know that there is an instance of an application running in a screen but you are not sure about the exact screen name and

screen -x

returns a tedious list. Maybe I still have no clue about how to use screen to the fullest, but here is a function I use in a script on my shell account to resume screens:

(more…)

Generating Random Passwords

Monday, May 21st, 2007

Writing a sufficient password generator does not have to be hard nor overly complex. In this article a simple password generator technique will be presented and explained.

One of the simplest password generators could simply output the ASCII character represented by a series of random integers:

(more…)

Youtube Ripping: Reloaded

Sunday, May 13th, 2007

The initial version of the Youtube command-line ripper appeared on Digg without ever reaching any sort of maturity. There was at most an hour between the beginning of the coding process and the massive public exposure. I am grateful for all the feedback I have received and, as promised I now announce a total rewrite in PHP that is confirmed working on Linux, Windows and OS X (just about any platform with PHP actually).

Version 0.40 is available for download.

PHP5 is available for Windows as binaries from the PHP.net site Most Linux distributions have a package in their repositories There is a port of PHP5 available for OS X users

Handling Command Line Arguments in PHP

Saturday, May 12th, 2007

When working with PHP in an web environment programmers are often used to the comfort of having the associative arrays $_GET and $_POST to hold the data to be passed on as arguments. During command line runtime however, there is only a numerated array called $argv holding each argument:

(more…)

An Object Oriented Caching Approach

Tuesday, May 8th, 2007

Today I announce a minor release of my latest object oriented beauty. Inspired by the earlier mentioned caching method in PHP i decided to rewrite it as a reusable class.

SimpleCacher is a class written in PHP aimed at providing an object oriented caching method for (X)HTML-pages otherwise generated by querying a database-backend along with the execution of intense PHP applications. The idea is to provide a clean and extendable way to set up caching procedures for webpages.

GZIP compressed cache (sends the GZIP compressed cache file directly to the client, if possible) Strips down the cache file to contain only a single line of (X)HTML Redundant error checking forces the original content to be displayed in case the cache method breaks

Simple Caching Method Using PHP

Sunday, May 6th, 2007

The idea of caching is to keep a replicate of data where it is easier to reach than the original. Simply put caching could mean to keep a static copy of a web page that would otherwise be compiled together using a dynamic procedure (like PHP using a database back-end). By caching a copy to be served statically the overhead the dynamic procedure would otherwise create is eliminated.

A very simple cache procedure would consist of checking if there is already a cached copy of the requested material, if there is no already cached copy then it should create one. The second thing to take into consideration is how ‘fresh’ the currently cached copy is, all file systems today keep track of modification times on each file, comparing timestamps is sufficient enough for this. This very simple example does the previously mentioned checks and comparisons and you can try it out by accessing a cached copy of this post.

Since there is still some overhead when the client has to load the CSS and associated images the bandwidth saving is non-existent, the database load is totally eliminated however. I intend to work further on this caching code and make it object oriented and later on figure out how to make it save some bandwidth as well as database queries and execution time.



You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser