The Linux Page

C

The C language is one of the oldest. It allows for very fast implementations, but has a huge lack of memory protection.

stream_socket_client() fails with no errors...

Today I had a weird one.

The PHP function named stream_socket_client(), used to create a socket to communicate with another computer over a network, may return $errno = 0 and $errstr = "".

The PHP reference actually mentions the problem:

On failure the errno and errstr arguments will be populated with the actual system level error that occurred in the system-level connect() call. If the value returned in errno is 0 and the function returned FALSE, it is an indication that the error occurred before the connect() call. This is most likely due to a problem initializing the socket. ...

[ODBC Driver Manager] Data source name not found and no default driver specified

As I was working on a MS-Windows installation, I ran in this weird error: Data source not found and no default driver specified...

This was output when I was running the following in a command line prompt:

osql -E

The result should have been an MSSQL prompt instead!

The problem on the computer was that I uninstalled MSSQL 2005 that was automatically installed by Visual Studio C++ and was not compatible with our application, so I first uninstalled that but that uninstallation is really not proper. It leaves a LOT of things behind.

After that I installed MSSQL 2014 which was reported as ...

The for() in C, C++, Java, PHP, JavaScript...

As I am working on my as2js compiler, I stumble on a couple of problems with the for() loop parsing because of the in keyword. That made me think and the for() statement was actually a very funny one. Yes! You can actually write something like this and it compiles:

int zero;
for(3;2;1) zero;

As you can see, all 3 entries in the for() statement are valid expressions and therefore the compiler can compile that code. This creates a loop that runs forever, similar to:

for(;;) zero;

but much less clear to read, obviously.

Now that's food for thought, isn't it?

In JavaScript, you ...

Setting tag attributes in a dynamic way in XSLT with XQuery

I wanted to dynamically manage the attributes of the HTML tag. As I'm working on the Snap! C++ system, I thought that should be done with the standard XSLT feature: <xsl:attribute-set name="...">. Unfortunately the the XQuery implementation does not currently support such, at all.

There is a way, though, to still make it work with a central template definition which can be used to decide what should be and what should not be added to the HTML tag.  Especially, in this way we can make use of one template that is a system defined template. This being said, if you use ...

Console color: dark blue on black unreadable

As I work in consoles every now and then, I run in that one problem:

Some text is written in Dark Blue over the Black background:

This is a good example of what I'm talking about.

And if you can read that text, wow! (without selecting it first.

So... how could you change the color of that blue to make it readable? There is a way by sending some escape command to the console:

echo -e "\\e]R\\e]PC6495ed"

That command changes the color of the blue to a light blue (somewhat "cyan", although not light cyan.)

The "\\e]R" part is to reset the colors to ...

Classes in JavaScript (from complex objects to proper classes)

When creating objects (commonly called JavaScript classes) in your JavaScript code, you want to use the prototype. This is the only clean way of doing it. In JavaScript, you can create objects on the fly, but those are not considered safe.

Quick and Dirty

The quick way is to create an object directly. This works, but it has potential problems with used against a powerful optimized such as the Google Closure Compiler.

All the Quick and Dirty examples can make use of this in their myFunc examples. However, the closure compiler will warning about all of them because it doesn't know for ...

Very Sleepy CPU Profiler written in C/C++

When running a process under MS-Windows, it is at times rather difficult to find a problem caused by some slowness in your code, especially when it is not expected to be slow.and you do not get any kind of feedback from your software outside of the slowness itself.

When that happens a good way to find the problem is to use a profiler. Under MS-Windows, you have quite a few choices, but in most cases I've seen rather complicated solutions. Today I was told to check in Very Sleepy which I downloaded very quickly, installed very quickly, and ran very quickly., Also it did not give me the ...

A C++ implementation of a UDP client/server

I have noticed that quite a few people were trying to create UDP communication and I thought that proposing my class could help them. This is very basic as it does not define anything such as the size of a packet or any protocol to ensure arrival of the packets. However, it can be useful if you want to send a signal from one process to another, which is exactly how I use this implementation.

This code is part of the Snap! C++ implementation. It can be found in the corresponding SourceForge.net repository.

Header file:

// UDP Client Server -- send/receive UDP packets
// Copyright (C) 2013 ...

Doxygen does not generate documentation for my C functions (or any global function)

As I write programs, mainly in C++, I document them using the Doxygen tool. This is a very powerful parser that is capable to finding functions, variables, macros, and many other things in the source code and attach the corresponding documentation to those functions, variables, macros, etc.

This is extremly practical when creating large projects or libraries that you want to share with others.

One problem though, by default it seems like global functions (and thus C functions) and variables do not make it to the documentation, when C++ classes work fine.

There are two potential issues:

...

Designing a rotating wheel to ask users to wait while working in the background

Large version of the waiting wheelAs I'm working on a new feature for our Snap! Website system I wanted to have a turning wheel that asks users to wait while the computer does work.

The graphic is very simple: a rectangle with a border and a background color that rotates. However, I do not have a tool (that I know of) which could create the graphics automatically. So I did it with quite a bit of manual labor, but it was fun to learn a few things along the way.

I use inkscape to create such graphics. First I created the rectangle on the left. With that I had to have it rotated going 360 degrees repeating the rectangle 24 ...

Syndicate content Syndicate content

SMS From Me Logo

SMS From Me

To automatically start one on one conversations with your online leads.

     

   

Terms of Site Index

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

  • .dylib
    Dynamic Library--the Mac OS/X naming convention for dynamic libraries. Not too sure why they choose that extension since FreeBSD uses .so just like most other Unices... To confuse people, maybe?
  • cmake
  • inline
  • time
  • white