Friday, July 18, 2014

Flashback Ubuntu 14.04 to legacy desktop

To flashback Ubuntu 14.04 to use legacy desktop, to remove the 3D effect and animation, enter the command:

$ sudo apt-get install gnome-session-flashback

Log-out after installed. Click the Ubuntu button when log-in, select GNOME Flashback (Metacity).

Tuesday, March 4, 2014

Install Node.js on Ubuntu

From Ubuntu 12.04 to 13.04, an old version (0.6.x) of Node is in the standard repository. To install, just run:

$ sudo apt-get install nodejs

Obtaining a recent version of Node or installing on older Ubuntu and other apt-based distributions may require a few extra steps. Example install:

$ sudo apt-get update
$ sudo apt-get install -y python-software-properties python g++ make
$ sudo add-apt-repository ppa:chris-lea/node.js
$ sudo apt-get update
$ sudo apt-get install nodejs

source: https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager#ubuntu-mint

Wednesday, February 19, 2014

Get my Process ID and Parent Process ID in C, by calling getpid() and getppid()

Example to Get my Process ID (PID) and Parent Process ID (PPID) by calling getpid() and getppid().

#include <stdio.h>
#include <sys/types.h>

main(){
 pid_t mypid;
 pid_t myppid;
 
 mypid = getpid();
 myppid = getppid();
 printf("My PID: %ld\n", (long)mypid);
 printf("My PPID: %ld\n", (long)myppid);
}

getpid() and getppid()

Get GNU libc version at run-time using C

To get GNU libc version in C language at run-time, you can call gnu_get_libc_version() and gnu_get_libc_release().

- gnu_get_libc_version() returns string that identifies the glibc version available on the system.
- gnu_get_libc_release() returns string indicates the release status of the glibc version available on the system.

And, you can retrieve _CS_GNU_LIBC_VERSION with confstr().

Here is example, test_version.c:
#include <stdio.h>
#include <gnu/libc-version.h>
#include <stdlib.h>
#include <unistd.h>

main(){
    printf("GNU libc version: %s\n", gnu_get_libc_version());
    printf("GNU libc release: %s\n", gnu_get_libc_release());
    
    char *buf; size_t n;
    n = confstr(_CS_GNU_LIBC_VERSION, NULL, (size_t)0);
    if ((buf = malloc(n)) == NULL) 
        abort();
    confstr(_CS_GNU_LIBC_VERSION, buf, n);

    printf("_CS_GNU_LIBC_VERSION: %s\n", buf );
    free( buf );
}

Get GNU libc version at run-time using C
Get GNU libc version at run-time using C

Tuesday, January 28, 2014

cal - Linux command to display calendar

cal
cal command
cal is a Linux command run on Terminal, to display built-in calendar on Terminal in text mode.


Monday, January 27, 2014

GtkColorChooser example

GtkColorChooser
GtkColorChooser

#include <gtk/gtk.h>

static void 
chooser_color_activated(GtkColorChooser *chooser, 
 GdkRGBA *color, gpointer user_data)
{
 GtkLabel *label = user_data;
 gtk_label_set_text (label, gdk_rgba_to_string(color));
}

int main( int argc, char *argv[])
{
    GtkWidget *window;
    GtkWidget *box;
    GtkWidget *label;
    GtkWidget *chooser;

    gtk_init(&argc, &argv);
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(window), 400, 250);
    gtk_window_set_title(GTK_WINDOW(window), "Linux-buddy.blogspot.com");

    box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);

 label = gtk_label_new("label");
    gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 3);

 //Create GtkColorChooser
    chooser = gtk_color_chooser_widget_new();
    gtk_box_pack_start(GTK_BOX(box), chooser, FALSE, FALSE, 3);
    g_signal_connect (GTK_COLOR_CHOOSER(chooser),
                    "color-activated", 
                    G_CALLBACK (chooser_color_activated), 
                    label);

    g_signal_connect(G_OBJECT(window), "destroy", 
        G_CALLBACK(gtk_main_quit), NULL);

    gtk_container_add(GTK_CONTAINER(window), box);
    gtk_widget_show_all(window);
    gtk_main();

    return 0;
}


Note: double click the color buttons to activate color change.

Saturday, January 25, 2014

View hiden file start with a "."

Filenames which start with a "." (dot) are normally not shown. Use 'ls .*' or 'ls -a ...' to see them.