Skip to main content

a silhouette of a person's head and shoulders, used as a default avatar

Что можно почитать?

Часто возникает вопрос: А где найти информацию по языку, стандарту и т.д. В принципе, таких мест много в сети. Но если удобно работать с печатными изданиями, которые всегда под рукой, "приятно шелестят страницами", не требуют наличия соединения с сетью, да и вообще ноутбука, то я могу порекомендовать следующее:
Язык программирования C
Сэмюел П. Харбисон, Гай Л. Стил
Язык программирования C

Книга, а мой взгляд, написана очень хорошо. Полностью раскрыты возможности использования языка, приведены примеры.
Так что, эта книга заслуживает Вашего прочтения.
the avatar of Flavio Castelli

QJson: a Qt-based library for mapping JSON data to QVariant objects

In order to realize a project of mine I started looking for a Qt library for mapping JSON data to Qt objects.

I came over a couple of solutions but none of them made me happy. So in the last weekend I wrote my own library : QJson The library is based on Qt toolkit and converts JSON data to QVariant instances. JSON arrays will be mapped to QVariantList instances, while JSON’s objects will be mapped to QVariantMap. The JSON parser is generated with Bison, while the scanner has been coded by me.

Usage

Converting JSON’s data to QVariant instance is really simple:

{% codeblock [] [lang:cpp ] %} // create a JSonDriver instance JSonDriver driver; bool ok; // json is a QString containing the data to convert QVariant result = driver.parse (json, &ok); {% endcodeblock %}

Suppose you’re going to convert this JSON data:

{% codeblock [JSON data] [lang:json ] %} { “encoding” : “UTF-8”, “plug-ins” : [ “python”, “c++”, “ruby” ], “indent” : { “length” : 3, “use_space” : true } } {% endcodeblock %}

The following code would convert the JSON data and parse it:

{% codeblock [] [lang:cpp ] %} JSonDriver driver; bool ok; QVariantMap result = driver.parse (json, &ok).toMap(); if (!ok) { qFatal(“An error occured during parsing”); exit (1); } qDebug() << “encoding:” << result[“encoding”].toString(); qDebug() << “plugins:“; foreach (QVariant plugin, result[“plug-ins”].toList()) { qDebug() << “\t-” << plugin.toString(); } QVariantMap nestedMap = result[“indent”].toMap(); qDebug() << “length:” << nestedMap[“length”].toInt(); qDebug() << “use_space:” << nestedMap[“use_space”].toBool(); {% endcodeblock %}

The output would be:

encoding: "UTF-8" plugins: - "python" - "c++" - "ruby" length: 3 use_space: true

Requirements

QJson requires:

  • cmake
  • Qt

Obtain the source

Actually QJson code is hosted on KDE subversion repository. You can download it using a svn client:

svn co svn://anonsvn.kde.org/home/kde/trunk/playground/libs/qjson

For more informations visit QJson site

a silhouette of a person's head and shoulders, used as a default avatar

Использование atexit

Использование функции atexit... Функция позволяет назначать обработчики выхода из программы. Зарегистрированные с помощью нее обработчики будут вызваны при нормальном завершении программы, а также в некоторых случаях прерывания ее работы. Это позволяет провести некоторые операции, например, сохранение данных программы, при ее завершении.
Функция atexit определена в стандартом заголовочном файле stdlib.h. Функция выглядит следующим образом:

int atexit(void (*)(void)).


Таким образом, функция, которая может использоваться в качестве обработчика выхода из программы, не должна возвращать результатов и, кроме того, она не имеет параметров.


Пример использования:


#include

#include


void exit1(){

printf("At function exit1\n");

}


void exit2(){

printf("At function exit2\n");

}


void exit3(){

printf("At function exit3\n");

}


void exit4(){

printf("At function exit4\n");

}


int main (int argc, const char * argv[]) {

    // insert code here...

    printf("Hello, World!\n");

atexit(exit1);

atexit(exit2);

atexit(exit3);

atexit(exit4);

int i=0;

for(i=0;i<100;++i)

printf(".");

    return 0;

}

В результате получается следующее:

[Session started at 2008-11-03 22:45:28 +0300.]

Hello, World!

....................................................................................................At function exit4

At function exit3

At function exit2

At function exit1


Можно зарегистрировать до 32 обработчиков. При этом они будут вызываться в обратном порядке, т.е. последний зарегистрированный обработчик будет вызываться первым.

a silhouette of a person's head and shoulders, used as a default avatar

О блоге...

Данный блог посвящен программированию на языке С. В нем я буду приводить примеры использования стандартного С (с99), а также рассматривать некоторые интересные моменты...

a silhouette of a person's head and shoulders, used as a default avatar

Zu welchem Paket gehörte die Datei nochmal

Will man unter openSUSE wissen zu welchem Paket eine Datei gehört lässt sich dies ganz leicht herausfinden. Leider gibt es in RPM oder Zypper keine expliziete Funktion um dies Abzufragen, aber sie lässt sich ganz leicht bauen aus vorhandenen Komponenten zusammenbauen.

RPM zeigt im Abfrage-Modus (-q) mit -l alle Dateien einem Pakets an. Mit -a arbeitet der Abfrage-Modus auf allen Paketen. Es liegt also nahe alle Dateien aller Pakete anzuzeigen und alle unbenötigten Informationen mit grep auszufiltern. In meinem Beispiel suche ich das Paket glibc-devel welches die Datei /usr/include/gnu/stubs.h enthält.

marix@eddie:~> rpm -qal | grep "/usr/include/gnu/stubs.h"
/usr/include/gnu/stubs.h

Leider funktioniert dies wie im Beispiel zu sehen ist nicht so richtig. Zwar wird die Datei gefunden, das Paket aber noch nicht mit angezeigt. RPM zeigt mit -l ja nur die Dateien an, aber nicht die Paketnamen. Zum Glück lässt sich RPM aber über die Option --queryformat genau sagen, welche Informationen es zu einem Paket wie anzeigen soll. Unter http://rpm.org/max-rpm-snapshot/s1-rpm-query-parts.html#S3-RPM-QUERY-QUERYFORMAT-OPTION ist auch der passende Formatierungstext zu finden.

marix@eddie:~> rpm -qa --queryformat '[%{=NAME}: %{FILENAMES}\n]' | grep /usr/include/gnu/stubs.h
glibc-devel: /usr/include/gnu/stubs.h

a silhouette of a person's head and shoulders, used as a default avatar

Followup “10 Things …”

I put the post “10 Things …” into the wiki. I rearranged the order a little bit, but basicly it’s the same page. If you have suggestions how to expand it, feel free to do it. The main intention was to write down things that users always ask me on events, of course it could be extended to a general “Tips and Tricks for openSUSE users”. But keep in mind that we already have the Users FAQ. Thanks for the comments, i will start writing an article or chapter how to buy new hardware for Linux soon.

the avatar of Sandy Armstrong

Got a G1, Yay Linux!

So I caved and got a G1. I may write an in-depth review after I've had it longer, or I may not, but here are the highlights:

Rock
  • I can has source!
  • No need to print from Google Maps when I leave the house.
  • Better reception in my house with T-Mobile than I had with AT&T.
  • ConnectBot SSH client works great with my screen+irssi setup.
  • Used ShopSavvy at Sports Authority yesterday to convince Ellery it was worth getting her a shiny new pair of rollerblades. Hold phone up to barcode, see local and online price comparisons.
  • Used Shazam to find out what's playing on the radio. Hold phone up to speaker, wait a few seconds, prompted with all the info you could desire, including a link to download via phone at Amazon MP3 store.
  • Unlock screen shows when my alarm is set to go off.
  • Keyboard surprisingly comfortable to use.
  • Camera image quality decent.
  • Easier than I thought to patch HAL (or just edit .is_audio_player) so that G1 Just Works in Banshee:

G1 in Banshee
Click for larger view, obligatory F-Spot Awesomeness

Suck
  • My thumbs are a bit fat to use on the touch screen (I have somewhat-deformed wide thumbs). So, no one-handed use.
  • No visual voice mail.
  • When interacting with a phone service, like voicemail, and you are prompted to enter digits, I go into freak-out mode, because I look at the screen and it is blank, so I have to unlock, then find the dialer so I can hit a number, which can be kind of tricky depending on how the call started. I can probably flip out the keyboard and use that, but as I said, I'm in a panic.
  • Not sure how to carry this thing. It comes with a sleeve/pouch/thingy, and for now I put it in there and then in my pocket, but now it takes two hands and an extra few seconds to answer my phone. What do people do? I'm used to having a crappy phone that can live in the same pocket as keys and other dangerous items!
  • Camera slow, worthless in low-light situations.

Really looking forward to Tomdroid!

a silhouette of a person's head and shoulders, used as a default avatar

the avatar of Sandy Armstrong

Tomboy Planning Meeting Tomorrow

In case anybody's interested, we're having our planning meeting for this development cycle in #tomboy tomorrow...

Thursday, October 23, 2008 at 1930 UTC
http://www.timeanddate.com/worldclock/fixedtime.html?month=10&day=23&year=2008&hour=12&min=30&sec=0&p1=224

That's 12:30 PM PDT, 8:30 PM BST, etc etc.

Everybody is welcome! We've started a wiki page to gather ideas before
holding the meeting, so check it out here, and add your name if you're
attending, along with any ideas you might have:

http://live.gnome.org/Tomboy/DevMeetingZeroPointFourteen

Topics to dicuss:
* Features for this cycle
* Cross-platform updates
* Plans for bug/patch days to clean up bugzilla

My personal goals for this cycle:
* Solid Windows binaries with every 0.13.x release
* Experimental Mac binaries with every 0.13.x release
* Power through bugzilla, with a major focus on memory/performance
issues and other long-standing embarrassing bugs (like note renaming
problems).
* Better community management on my part, frequent bug/patch days, not
letting patches rot in bugzilla. Basically, enabling our awesome
contributors instead of frustrating them!

the avatar of Sandy Armstrong

Tomboy Preview for Windows and Mac

Please To Try

At the end of August, I told you about my little project to bring Tomboy to Windows users. Well, last week I finally merged that code into trunk. And then Friday, the excellent Mono team released a Mono 2.0 installer for OS X, and I found that my Windows build of Tomboy finally worked pretty well on the Mac, too. Of course, some platform integration there would be nice...





Click for full-screen shots. Notice that I added a menu for tracking open note windows, and attached the classic recent notes menu to the dock icon. This is not the most elegant solution, but I wanted Mac users to play around with it and share their own opinions. I'm very open to changes here. :-)

I didn't have any plans this weekend, so I present to you "preview builds" of Tomboy 0.13.0 for Windows and Mac OS X. I'm distributing them with the disclaimer that they are not widely tested, though in my own testing I have found no bugs that would make me worry about loss of data. Just consider yourself warned, and please back up your notes.

If you find any bugs, or have ideas for better platform integration, or find issues with install, please please PLEASE file bugs!

Click to file a bug for Tomboy on Windows!

Click to file a bug for Tomboy on Mac OS X!

Mac Instructions
  1. Install Mono 2.0 for Mac OS X.
  2. Download and mount the Tomboy disk image.
  3. Drag Tomboy to Applications, run!
  4. (optional) Copy your notes to ~/.config/tomboy

Mac Known Issues
  • Shortcut keys all use Control instead of Command.
  • The Bugzilla add-in doesn't work.
  • In the note window toolbar, notebook names can be ellipsized oddly.
  • Hand cursor doesn't show when hovering over links, but they're still clickable.
  • No keybindings support.
  • No i18n support.

Windows Instructions
  1. Install Medsphere's GTK# SDK installer (the runtime installer should work, but in my testing it did not install a particular registry key needed for Tomboy to recognize its presence).
  2. If you are running Windows Vista, you may need to follow additional instructions to work around an installer bug.
  3. Restart your computer.
  4. Download the Tomboy installer.
  5. Double-click to install!
  6. (optional) Copy your notes to %appdata%\tomboy

Windows Known Issues
  • Menu rendering issues.
  • Two console windows appear briefly when Tomboy starts (fixed in Mono.Addins SVN).
  • No drag and drop from other apps into Tomboy (appears to be unimplemented in GTK+ for Windows).
  • If you try to run Tomboy twice, it should show the Search window instead of launching again, but sometimes it will not show the Search window until you have interacted with Tomboy in some other way (by hovering over a window or clicking the tray icon, for example).
  • No i18n support.

Big Thanks

This was actually a pretty easy job, thanks to these folks:
  • Eoin Hennessey, who pioneered a lot of this work in his banshee-osx git branch, which he and Aaron are merging into Banshee trunk this week. Among other things, he created Mono bindings for Imendio's excellent ige-mac-integration library, and scripts for building app bundles.
  • Andrew Jorgensen, Thomas Wiest, Marc Christensen, and Geoff Norton of the Mono team. These guys have been rocking hard on Mono's Mac story, and it shows. Thanks especially for getting me a build of MonoDevelop in time for my Saturday hack fest!
  • Aaron Bockover, who keeps threatening to do a Mac release before me.
  • Brad Taylor and his old Medsphere cronies, who whipped gtk-sharp on Windows into shape.
  • All GTK+ developers and porters, especially those at Imendio!
  • The entire Tomboy community, especially Dmitry Kostenko, Doug Johnston, and Samuel Vandamme for their patches to help make Tomboy on Windows a reality. You guys are awesome!