At Loss for Words

…of Programming, Love and Metaphors

Subscribe to RSS feed

Vosková zátoka

,

Před pár dny jsme s několika známými vzpomínali na staré dětské seriály, animované nebo loutkové, na které jsme jako děti koukali. Dost jsme se shodli na tom, že dříve teda rozhodně nebyly pohádky tak mírné jako dnes, ale právě celkem drsné a zcela určitě všemi směry nekorektní. Začínaje bitkami Toma a Jerryho a konče svéráznou Pipi Punčochatou. Byla to příjemná troška nostalgie na zpestření všedních dní, ale všechno to nabralo trochu jiný nádech, jakmile jsem si vybavil jeden takový hodně zvláštní, zřejmě britský, loutkový seriál. Jmenovalo se to Vosková zátoka, v originále Candle Cove.

Read more...

sprintf-alloca-style string building for constructors

, ,

Lets say we have a COM class whose constructor is COM::COM(unsigned int index); that derives from Device class whose constructor is Device::Device(const char * devname); How do you implement the initialization in the constructor of COM?

Ladies and gentlemen, I give you the ext::sprintfa template:

COM::COM (unsigned int index)
    : Device (ext::sprintfa <16u> ("\\\\.\\COM%u", index + 1u)) {}

Read more...

Conservative variable size memory sharing

, ,

Using shared memory through Windows API is not difficult when you get over the "file"-oriented nomenclature (CreateFileMapping, MapViewOfFile, “backed by the system paging file”, ...). Sharing block of memory of fixed size is simple. It has already been described thousand times on other places.

Instead, the following article explains how to create a mapping with potential to share hundreds of megabytes, yet still takes only as much memory as is actually necessary, which can be as low as one page of 4 kilobytes.

Read more...

GetCurrentModuleHandle

,

There is a one very common problem when writing a DLL. Getting a HINSTANCE of your module after you have missed it in DllMain (or you just don't want to use a global variable, or don't want to propagate it all the way, whatever). Retrieving resources from the module, and thus almost every UI call, is impossible without this handle. And you have already found that GetModuleHandle(NULL) is useless, because it returns handle to the EXE (usually preferred 0x00400000), not your DLL handle.

Read more...

Serving XHTML correctly with simple backward compatibility

,

I don't believe in HTML5. I believe in valid XHTML 1.1. But, maybe quite the contrary, I believe in backward compatibility too. So how does my PHP website engine (Sprocket) serves valid pages that work even in IE6, IE5 and even in IE3? It's easy.

Read more...

Obecná schémata ochrany kódu (odkaz)

,

Potenciální zájemce o úvod do problematiky ochrany programů z řad čtenářů mého blogu bych rád upozornil na vydání svého staršího (rok 2006) článku k této tématice. Původně publikován v Magazínu Českých Her, nyní v přepisu na mém webu:

Obecná schémata ochrany kódu
Článek se v obecné rovině zabývá nejdůležitějšími tématy nastíněné problematiky; především návrhem a implementací kontroly klíčů, obranou proti útokům a rozpoznáváním a reakcemi na pokusy o napadení programu. Dále zahrnuje několik tipů pro vývoj shareware programů, konkrétní techniky zatemňování kódu, možnosti obrany proti existujícím crackům, a mnoho dalších zajímavostí.

Ráno

,

Probouzení je vůbec zajímavý okamžik. V jednu chvíli je mozek zcela zaměstnán komplikovaným snem, člověk je zahlcen emocemi a v druhou chvíli se vše zamlží. V ten krátký okamžik bychom dokázali obsahem svých snů popsat desítky stran textu. Ale ten okamžik vydrží jen chvíli. Co bylo ve snu jasné najednou nedává žádný smysl. Žádné surrealistické vysvobození ani žádná jednoduchá cesta ven. Sen může být bez následků zapomenut. Jsem vzhůru.

Read more...

Displaying comments of computers in network neighborhood in Windows Vista and 7

,

In my company, we use these comments to store the name of the person to which the computer is assigned, or to describe where a particular station or server is located. It is easy in Windows XP. You just open your Network Neighborhood folder and see the comment.

In Windows Vista and Windows 7 these comments are gone and you can't get them back. But only in that folder. To see comments of all computers in your network neighborhood in Windows Vista and Windows 7, you need to open a command line window (or just Win+R / cmd / Enter) and issue command:

C:\Users\JRingos> net view

Computer naming scheme

,

First we named our computers by surname of its first user. When new people of the same second name came, we used their first names. Still the names started to clash pretty fast. So various combinations of a first letters and other names were introduced. The result was an unmaintainable mess so we soon decided to rename everything.

The second naming scheme, introduced by our chief programmer, wasn't any better, unsurprisingly. Though carefully assigned to the core employees relating its sizes to their apparent weight, the names of the planets in the solar system quickly ran out. So did all the pronounceable names of other real-life stars; moons too. Inevitably, administrators soon brought their own invention into the scheme and now we have computers named Savara, Deliani, Hebridan, Proclarush Taonas (of the primadonna programmer), Chulak (of the nitpicker developer) or Melmac (of the useless manager).

Read more...

Naming key HTML page elements

,

Earlier, when building a website, I wasn't really putting much thoughts into HTML element identifier names. Not anywhere near as much as I do when designing a C++ code. But lately, as I more and more (sometimes ad absurdum) try to separate content from presentation, I found myself sick of <div id="body-bellownav-middle-helper-div"> and I sat back for few moments to think about it all.

I have discovered one thing. The typical HTML code is great candidate to use a Human Body Metaphor. Almost any web page can be generalized into following parts.

Read more...