Syndicate content

header

Bad move for PHP unpack()! So unpack() stopped working?

Today I noticed many errors on one of my websites. Looking closer into it, I noticed that the code for the mo_references Drupal module stopped working.

It took me some time, especially because the code seemed to work just fine as all the files could easily be displayed.

Actually, that was not the case. The unpack() character 'a', which I used, was transformed from a simple string that gets trimmed, to all the characters, including the NULL characters. Ouch! Now we have to use the 'Z' character instead.

I use it to unpack() a tar file by loading 512 bytes of data in a ...

HTML background that fits the screen

You can actually define an image or a background (with CSS) that fits the area in which is it shown.

For a simple image use a width of 100%, then the browser computes the height for you.

  <div class="header"><img src="images/background.png" width="100%"></div>

This code will make the image width match the width of the <div> tag. Assuming the <div> tag fits the screen width, it will show in the full width, stretching as required.

When trying to do that with a background image in CSS, you want to use the background-size parameter ...

"Your server runs WebDAV!" But how do you know?

Just got told that one of my servers was running WebDAV. I used that before so I thought it was turned on. Checking at the server, I could not find anything about DAV that was turned on in my server...

So, how could they detect WebDAV and not me??

The fact is that by default Drupal doesn't check the HTTP query method. It should! In fact, Drupal happily answers all methods with an HTML page. So I did not have WebDAV, just a flaky CMS.

How can you test methods that your server supports?

Knowing your IP address and port, use telnet like this:

telnet IP port (i.e. telnet 1.2.3.4 80)

...

not enough actual parameters for macro min() or max()

As I was porting wpkg to Windows so it would compile under Microsoft IDE version 10, I ran in a problem with variables named min and max. Windows wanted to see them as the min(a,b) and max(a,b) macros.

That started happening when I included Windows.h which I needed for handling files (CreateFileA, CloseHandle, etc.).

Since these are macros, i.e. defined with #define ..., they take priority over anything in your C++ code (since that's handled with your preprocessor.)

One way to get rid of them is to undefine those macros after the #include, something like this:

#include ...

Multi-level lists in MS-Word... The new way!?

Okay, it has been a little while now, but each time I just have to search forever to find out how to create a multi-level numbering list.

By default, a list will appear as this:

1. Chapter

    1. Section

        1. Sub-Section

Which may work for you, but in many cases you want to have all the list numbers appearing in your section and sub-sections as in:

1. Chapter

    1.1 Section

        1.1.1 Sub-Section

Okay, so that in itself it actually very easy, but it used to be that you could ...

Quickly saving an image to disk without extra library

Often, when I work with some form of graphics, I do not have a handy library to save the image buffer I'm working with in a file on disk. In most cases, when I want to do that, I make use of the Targa format. This is very easy to save since the header is very simple (18 bytes) and the data can be saved verbatim. Plus, many tools, such as the Gimp, can read the result at once.

Here is my C code to do so. It will work in C++ also. It should be easy to tweak for other languages such as C#.

{
  unsigned char hdr[18]; // the targa file header
  FILE *f;

  memset(hdr, 0, sizeof(hdr));  ...

C printf(3) for int, long and long long that works every time

Of Note: This only applies to C99, not C++.

I learned something quite interesting today and wanted to keep a note of it.

Whenever I use a printf() with a format such as %ld and try to compile my code on "many" different platforms, I often get warnings on another one.

The fact is that an int, a long, a long long, an int32_t, int64_t all use a different combination depending on your platform and whether you're running in 32 or 64 bit.

So, the answer to this problem are the #define found in the inttypes.h header file:

PRId8
PRId16
PRId32
PRId64

These entries are used after

Weird HTTP requests from Googlebot

Somehow I receive many weird requests from one of Googlebot's. These use some very strange HTTP header, if I can even call that a header! modsecurity blocks all of them at once, but it just seems very strange since it has nothing to do with HTTP.

The two requests I have seen go like this:

0x16 0x03 0x01

0x80 0x2B 0x03 0x01

As you can see I show you the hexadecimal codes because these are controls!!! (Ctrl-V, Ctrl-C, Ctrl-A in the first request, and PAD, +, Ctrl-C, Ctrl-A)

I just have no idea what that is. I'm glad that modsecurity kicks those request out, but I'm wondering why am I

Setting the action attribute of a form with Internet Explorer

After about 2 hours of search, I finally got it. All the docs were telling me do this:

	var f = document.getElementById('myform');
	f.action = url;
	f.submit;
				

And it did not work. I was getting an error. So thinking that this 'action' is an attribute I used f.setAttribute('action', url);. And that worked great with Sea Monkey, FireFox, etc. but one day we tried under Internet Explorer. That one was not working somehow. Reading some notes on the net, indeed, setAttribute('action', url)is no good under Internet Explorer. But f.action = url;generates an error?!

After ...

Force the download of any file

How to force a download of any file in a CGI script

I have been wondering for a while, now I have the answer, so I can share it with you guys.

Your script has to do the following steps:

  1. Print a header which at least includes:

    1. Content-Type: application/force-download

      (you can also use octet-stream instead of force-download)

Syndicate content Syndicate content

Diverse Realty

Diverse Realty Team

Want a New Home?
Want to Sell Your House?

Call Alex at
+1 (916)
220 6482

Alexis Wilke, Realtor
Salesperson
Lic. # 02024063

Cory Marcus, Broker
Lic. # 01079165

     

Terms of Site Index

Find the page/content you are looking for with our index.

  • Ctrl-C
  • IsNull

    The Visual Basic function to check whether a value is set to Null. The PHP equivalent is is_null().

  • disk
  • logo

    The term logo usually references a small image or icon used to represent a business or product. In computing, there is also the LOGO language, a simplified version of the lisp language, if I may.

  • nested

    In computing, nested means an item defined inside another. It is most often used for loops, a loop can be declared inside another. The one inside is called the nested loop. In particular, two loops can be defined one after another or one inside the other. There is no other way to declare a loop.