Facts about WordPress – My first plugin

<?php
/**
* @package WordPress_Facts
* @version 1.0
*/
/*
Plugin Name: Facts about WordPress
Plugin URI: http://anirudhspider.wordpress.com/wordpressfacts
Description: This is a plugin which you can use to display random wordpress facts in your admin panel.
Version: 1.0
Author: Anirudh S
Author URI: http://anirudh24seven.wordpress.com
License: GPL2
*/
/*  Copyright 2011  Anirudh S  (email : anirudh24seven@gmail.com)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

function random_fact_line() {
/** These are the random facts */
$line = “WordPress is an open source Content Management System.
Wordpress is powered by PHP and MySQL.
Wordpress was first released on May 27, 2003, by Matt Mullenweg.
Native WordPress applications exist for Android, iPhone/iPod Touch, iPad, Windows Phone 7 and BlackBerry.
In 2009 WordPress won the best Open Source CMS Award.
Wordpress version 1.2 was codenamed Mingus and was released on 22 May 2004.
Wordpress version 1.5 was codenamed Strayhorn and was released on 17 February 2005.
Wordpress version 2.0 was codenamed Duke and was released on 31 December 2005.
Wordpress version 2.1 was codenamed Ella and was released on 22 January 2007.
Wordpress version 2.2 was codenamed Getz and was released on 16 May 2007.
Wordpress version 2.3 was codenamed Dexter and was released on 24 September 2007.
Wordpress version 2.5 was codenamed Brecker and was released on 29 March 2008.
Wordpress version 2.6 was codenamed Tyner and was released on 15 July 2008.
Wordpress version 2.7 was codenamed Coltrane and was released on 11 December 2008.
Wordpress version 2.8 was codenamed Baker and was released on 10 June 2009.
Wordpress version 2.9 was codenamed Carmen and was released on 19 December 2009.
Wordpress version 3.0 was codenamed Thelonius and was released on 17 June 2010.
Wordpress version 3.1 was codenamed Reinhardt and was released on 23 February 2011.”;

// Here I split the $line query into separate lines based on the newline character (\n)
$line = explode( “\n”, $line );

// From the lines that have been generated, I generate a random line out of them for Random Facts
return wptexturize( $line[ mt_rand( 0, count( $line ) - 1 ) ] );
}

// This just echoes the chosen line, we’ll position it later
function random_fact() {
$chosen = random_fact_line();
echo “<p id=’fact’><b>Random Fact:</b> $chosen</p>”;
}

// Now we set that function up to execute when the admin_notices action is called
add_action( ‘admin_notices’, ‘random_fact’ );

// We need some CSS to position the paragraph
function fact_css() {
// If this is not present, the fact would not be at the top right, but at the top left. From Hello Dolly plugin documentation- “This makes sure that the positioning is also good for right-to-left languages”

$x = is_rtl() ? ‘left’ : ‘right’;

echo “
<style type=’text/css’>
#fact {
float: $x;
padding-$x: 15px;
padding-top: 5px;
margin: 0;
font-size: 11px;
}
</style>
“;
}

add_action( ‘admin_head’, ‘fact_css’ );

?>


Version 2 – WordPress Android App UI

Thanks for the comments and feedback on my first version of the WordPress Android App UI mock-up. I have made some modifications according to the feedback given.

Here is my 2nd version.

2nd version

This front page represents the Dashboard and clicking on the Dashboard button while reading some WordPress blog, will redirect it back to this page.

I have also added icons and tweaked the layout arrangement a bit, for this 2.1 version.

With Icons

Comments/suggestions welcome.


Suggestion for new WordPress Android App UI

As part of my GSoC application for the project “Refresh the Android App UI”, I would like to post a mock-up of what I have in my mind.

Suggestions welcome.

Explaining the header, clicking on the wordpress logo should take the user to wordpress.com, the next button upon clicking would take the user to the Stats page and the final button would implement the Search feature through the mobile app.

My WordPress Android App UI suggestion

My suggestion for the new WordPress Android App UI

Note: Suitable icons for the buttons haven’t been put up yet, as it would be difficult to find out what the buttons are for.


GSoC 2011 Projects Classification

For anyone trying to participate for the first time in Google Summer of Code, it takes quite some time for them to decide what projects they might want to get involved in.

Being interested in projects related to Android and PHP, I decided to compile the list of projects which have the specified keyword, so that it becomes easier to filter through those projects and choose the project that you like. Hope it helps.

Note.I compiled this list from the actual list of GSoC 2011 projects from the Google Melange site. You can look at the main list for more details over here: http://www.google-melange.com/gsoc/homepage/google/gsoc2011

The following links redirect to their respective GSoC 2011 page. The list is in no particular order.

Android related (keyword: android) :

Rockbox
Sakai
Processing
openSUSE
Natural User Interface Group
Catroid Project
Hedgewars Project
GNU Project
Helsinki Institute of Information Technology
K-9 Mail
The Java Pathfinder Team
Komodo OpenLab Inc.

Web Development (keyword: php) :

WordPress
Drupal
LimeSurvey
Marine Biological Laboratory – Center for Library and Informatics
Moodle
Debian Project
DokuWiki
Elgg
Genome Informatics
Gentoo Foundation
The Honeynet Project
Inclusive Design Institute
Typo3 Association
Wikimedia Foundation
National Resource for Network Biology (GenMAPP, Cytoscape and WikiPathways)
Openwall Project
OSGeo – Open Source Geospatial Foundation
phpMyAdmin
Sahana Software Foundation
StatusNet
Sunlight Labs

Of course, I love GNOME too. So here is the link.
GNOME Project

Note:
I am also interested in projects related to C++, but the projects with the keyword C++ are so diverse that I thought that it might not be worth it to list them here. Readers are advised to go through the project list on their own for this.


vim for C++ programming

Here’s how to get your vim editor ready for C++ programming.

1. Invoke vim with your to-be-created-file name.

vim foobar.cpp

2. Before beginning to write the program, set the following options in your Normal mode.

:set smartindent

smartindent is one of the most preferred indentation types for C/C++ programs.

3. After setting up indentation, the next thing you’d want to do is set up automating closing of brackets, braces and parenthesis if you’re comfortable with kate-like editors. You can set this by issuing the following commands again in the Normal mode.


:inoremap [ []<Esc>i
:inoremap { {}<Esc>i
:inoremap ( ()<Esc>i

inoremap is mapping tool which maps the keys that you type, to something that you define. It is really awesome and you can save a lot of time by the above commands.

3.You are almost ready for cpp programming but you would not to type these commands every-time you want to write a cpp program.

So, to make these changes permanent, I would suggest using mksession. That way vim would remember all your session settings and you can invoke it whenever you want.

To create a session file, use the following in your normal mode.

:mksession ~/cppsettings.vim

This creates a cppsetting.vim file in your home folder (you can use any folder, but calling this file again from the $HOME folder is easy to remember).

To use these settings again, whenever you start a cpp program, type

source ~/cppsettings.vim

and all your settings that you’ve saved will be used. You need not type all the settings commands again.

Alternatively, if you want to always invoke cpp programs WITH the settings, you can do so by starting vim with the -S option along with the settings-file name before the cpp file name. For example,

vim -S ~/cppsettings.vim foobar.cpp

will import your settings at the time of starting your program and you need not enter the normal mode to invoke the settings.

You can now start writing c++ programs happily in vim. If you have any doubts/comments/suggestions you’re free to do so in the comments section.

Happy programming !

Note: Although you might want the auto-completion feature too, after going through many such tools/plugins for vim like ctags, taglist, cppcomplete and omnicppcomplete, I realized that it is widely accepted that none of them are perfect enough.

You might want to have a look at this. http://stackoverflow.com/questions/1115876/autocompletion-in-vim


Macbuntu in 15 min

Apple’s Mac OS X is well known for its awesome looks ! Sadly, you can’t obtain it if you don’t have a Macintosh Computer.

There are a few alternatives. I chose Macbuntu. It is clean, free and can be installed upon Ubuntu ! It installs all the necessary apps, icons and other resources to make your desktop look just like OS X !

Pros:

1. You still work on your good ol’ Ubuntu machine, but with stunning looks !

2. Seamless transition between your GNOME desktop looks and the new mac look.

3. Its free and seems to be stable.

4. You get a nice dock, just like a mac !

Requirements:

1. This article is about installing Macbuntu looks on Ubuntu 10.10 (Maverick Meerkat). If you’re using a different version of Ubuntu, please modify the suitable commands.

2. GNOME desktop environment.

3. Willingness to exchange simplistic looks to flashy ones.

The Macbuntu project is hosted at http://sourceforge.net/projects/macbuntu/. To install macbuntu, follow these instructions:

wget https://downloads.sourceforge.net/project/macbuntu/macbuntu-10.10/v2.3/Macbuntu-10.10.tar.gz -O /tmp/Macbuntu-10.10.tar.gz

tar xzvf /tmp/Macbuntu-10.10.tar.gz -C /tmp
cd /tmp/Macbuntu-10.10/
./install.sh

You can select what to install/modify in the installation process.

After everything gets installed, restart your computer. You’d have a wonderful Mac OSX-looking Ubuntu. Enjoy !!

Note: If you do not have Compiz installed on your ubuntu, you won’t see the visual effects. You can always download compiz and compiz-core from the Ubuntu Software Center.

Upgrade :

If you’re upgrading from an older version of Macbuntu, replace the install.sh by upgrade.sh.


Uninstall :

If OSX looks are too flashy for you, you can always uninstall it using the uninstall script.

cd /tmp/Macbuntu-10.10/
./uninstall.sh


Network Manager problem

There is a bug in Kubuntu (lucid) which prevents knetworkmanager from loading and almost every attempt to load knetworkmanager failed. One cannot connect to both wired or wireless networks without this.

This bug is caused if you hibernate your system (lucid). Knetworkmanager simply refuses to load even after many rebooting attempts. The wireless led refuses to light up too.

This can be rectified by going to NetworkManager.state in /var/lib/NetworkManager and changing value of NetworkingEnabled from false to true. Then reboot the system. Everything will start working properly again.

Code:

sudo dolphin
Go to /var/lib/NetworkManager
Open NetworkManager.state
Change the value of NetworkingEnabled from false to true
Reboot your system

Good Luck !


Follow

Get every new post delivered to your Inbox.

Join 1,440 other followers