2011-08-11

Google Analytics API

To retrieve the report data:
DataQuery q = new DataQuery(new URL("https://www.google.com/analytics/feeds/data"));
q.setMaxResults(8192);
q.setStartDate("2007-01-01");
q.setEndDate("2012-12-31");
q.setDimensions("ga:pageTitle,ga:pagePath");
q.setMetrics("ga:pageviews,ga:entrances,ga:avgtimeonpage");
q.setSort("-ga:pageviews");
q.setIds("ga:" + profileId);
DataFeed dataFeed = client.getFeed(q, DataFeed.class);
for (DataEntry entry : dataFeed.getEntries()) {
  // Do something with entry
}


The profileId could be listed by:
ManagementFeed f = client.getFeed(new URL("https://www.google.com/analytics/feeds/datasources/ga/accounts/~all/webproperties/~all/profiles"), ManagementFeed.class);
for (ManagementEntry entry : f.getEntries()) {
  System.out.println(entry.getProperty("ga:profileId"));
}


A list of Dimensions and Metrics could be found at http://code.google.com/apis/analytics/docs/gdata/gdataReferenceDimensionsMetrics.html.

2011-08-10

Google Analytics API Notes

A general way to query Google Analytics API:
String feedUrl;

feedUrl = "https://www.google.com/analytics/feeds/datasources/ga/accounts";
feedUrl = "https://www.google.com/analytics/feeds/datasources/ga/accounts/~all/webproperties";
feedUrl = "https://www.google.com/analytics/feeds/datasources/ga/accounts/~all/webproperties/~all/profiles";
URL queryUrl = new URL(feedUrl);
ManagementFeed feed = client.getFeed(queryUrl, ManagementFeed.class);
for (ManagementEntry entry : feed.getEntries()) {
System.out.println("--- Account Entry ---");
for (Property property : entry.getProperties()) {
System.out.println(property.getName() + ": " + property.getValue());
}
}

2011-06-27

Install Notes Oracle Enterprise Linux 6.1

Download the ISO image from edelivery.oracle.com.

Install with "Desktop" pre-configured installation.
And remove Oracle's unbreakable enterprise kernel (uek): yum erase kernel-uek*
  • *kernel-devel (for VirtualBox driver compilation)
  • gcc-c++
  • make

2011-06-22

Apache2 PHP Ubuntu User Directory

  1. cd /etc/apache2/mods-enabled
  2. sudo ln -s ../mods-available/userdir.load .
  3. sudo ln -s ../mods-available/userdir.conf .
  4. sudo apache2ctl restart
  5. The items in ~/public_html should be accessible from http://host/~username

By default, PHP is disabled in user directories. To enable it:
  1. Edit /etc/apache2/mods-enabled/php5.conf
  2. Delete/comment out the lines related to disabling the user directory execution.

2011-06-15

CentOS 5 Configurations

    Apache httpd
  • yum install httpd
  • Append one line in /etc/sysconfig/iptables if it is not there: -A RH-Firewall-1-INPUT -m tcp -p tcp --dport 80 -j ACCEPT

    GNOME
  • yum install xorg-x11-server-Xorg gnome-desktop gdm

2011-04-21

Blender Python Study Notes

The environment has:
C: handle to Blender context
__builtins__: Built-ins of Python 3
bpy: Top level Blender Python API module

2011-04-15

Ubuntu Server 10.04 As Desktop Use

(A modified version of previous installation guide, focusing on 10.04 LTS)

Configure Medibuntu source: https://help.ubuntu.com/community/Medibuntu

To disable installing recommended packages, create /etc/apt/apt.conf and put APT::Install-Recommends "false"; in it.

Desktop - system

xserver-xorg
gnome-core
gdm
gnome-themes-selected
humanity-icon-theme
dmz-cursor-theme

Desktop - apps


alacarte (menu editor)
file-roller
evince
gnome-screensaver
gksu
gcalctool
flashplugin-installer
chromium-browser
firefox (Chrome not able to display XML files with a XSL stylesheet)
language-support-??
brasero (ISO burner)
gnome-utils (including baobab -- a disk usage analyser, gnome-dictionary, gnome-search-tool, gnome-system-log, and gnome-screenshot)
gnome-bluetooth
*jockey-gtk (the proprietary driver manager)
*network-manager
*network-manager-openconnect (for Cisco AnyConnect VPN)
*kchmviewer
*gconf-editor

Development:
g++
gdb
openjdk-6-jre
*freeglut3-dev
*dia
*mysql-server
*libmysql-java (the JDBC driver)
*mysql-admin
*python-mysqldb
*apache2
*php5
*php5-mysql
*php5-sqlite
*libqt4-dev
*libqt4-opengl-dev

*libqt4-sql-sqlite
*qt4-doc
*qt4-dev-tools
*qt4-designer

Remote access
vinagre (the client; you might want to disable the keyboard shortcuts in the preferences menu)
vino (the server)


Media
alsa-base
alsa-utils
gnome-codec-install
audacious
libdvdcss2
non-free-codecs
*vlc
*mozilla-plugin-vlc
*banshee
*banshee-extension-soundmenu (for ubuntu 11.04)
*totem

Gaming
playonlinux (front end of wine)

Printing
system-config-printer-gnome
cups
*smbclient (for Windows shared printing)
*hplip (HP printer drivers)


Configuration

  • Enable audio:
    1. alsamixer
    2. Press "M" to (un)mute channels
  • Clear screen when logout:
    1. ~/.bash_logout
    2. insert single command clear
  • Disable Ctrl-Alt-Del:
    1. /etc/init/control-alt-delete.conf
    2. comment out the actual command line
  • Let vim display line numbers:
    1. sudo echo set nu >> /usr/share/vim/vimrc (if there is no such line)
  • Secure login/out logs:
    1. sudo chmod 640 `sudo find /var -name ?tmp`
  • NetworkManager system tray icon:
    1. edit /etc/NetworkManager/nm-system-settings.conf
    2. make the line read managed=true
    3. sudo /etc/init.d/network-manager restart
  • Stop GDM from auto starting:
    1. /etc/init/gdm.conf
    2. comment out all "start on" stuff
  • Configure GRUB:
    1. /etc/default/grub
    2. update-grub
  • MySQL
    1. Add line default-storage-engine=INNODB to /etc/mysql/my.cnf
    2. to reset root password: sudo dpkg-reconfigure mysql-server-5.1
  • Remote login
    1. vino-preferences

2011-03-01

KDE on Ubuntu Server 11.04

Configure Medibuntu source: https://help.ubuntu.com/community/Medibuntu

Packages

    Desktop

  • kde-plasma-desktop (xserver-xorg and kdm included)
  • chromium-browser
  • flashplugin-installer
  • language-support-??
  • kchmviewer
  • network-manager-kde
  • jockey-kde

    Development

  • g++
  • make
  • gdb
  • openjdk-6-jre
  • qt4-dev-tools

    Media

  • amarok

Configuration

    NetworkManager

  • edit /etc/NetworkManager/NetworkManager.conf
  • make the line read managed=true
  • sudo service network-manager restart

2011-02-22

Python Notes

os.wait() will return the oldest finished jobs

2011-02-15

Vim Recording

Ref: http://www.thegeekstuff.com/2009/01/vi-and-vim-macro-tutorial-how-to-record-and-play/

Start recording by pressing q, followed by a lower case character to name the macro
Perform any typical editing, actions inside Vim editor, which will be recorded
Stop recording by pressing q
Play the recorded macro by pressing @ followed by the macro name
To repeat macros multiple times, press : NN @ macro name. NN is a number