Othman

on programming, Science & Mathematics

Author Archive

building jbilling from source

leave a comment »

This Guide describes the steps to setup a jbilling version 2.x development environment. This guide applies to current settings:

  • Operating System : Linux (or any  *nix OS system).
  • Java version : Java 6 or higher.
  • Database system : PostgreSQL 8 or higher.
  • JBilling version 2 (this doesn’t apply to jbilling 3 where you can find instructions to build jbilling 3  here).

1-Database System Setup :

follow the steps below to set up a postgresql database system for use with jbilling:

  • download and install PostgreSQL open source database engine from this page .
  • in most linux systems when postgresql is instqlled user postgres has no password set. you can set one using this command:
  • $passwd postgres (assign the new user a password)
    
  • Initialize postgresql cluster by running the following commands:

root# mkdir /usr/local/pgsql/data
root# chown postgres /usr/local/pgsql/data
root# su postgres
postgres$ initdb -D /usr/local/pgsql/data

Now you need to enable pg_hba  config file for permissions configuration:

  • locate file pg_hba.conf.sample (usually in /usr/share/postgresql . sometimes you could find another file in folder /var/lib/postgresql/data/ so you need to change both files).
  • activate file pg_hba.conf using this command:

 $sudo cp pg_hba.conf.sample  pg_hba.conf

  • Edit the PostgreSQL pg_hba.conf file and change the “local” and “IPv4″ localhost connection types:

# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust

  • start the database server using:

$  postgres -D /usr/local/pgsql/data

or

  $  pg_ctl -D /usr/local/pgsql/data -l logfile start

  • To prevent having to retype the full command every time we start or stop the database, create a start script and a stop script in the postgres user’s home directory named pg_start and pg_stop. Below are the contents of the pg_start file. Make sure to create these files as the postgres user in the home directory:

$ sudo su - postgres

$ vim ./pg_start

#!/bin/sh

pg_ctl -D /user/local/pgsql/data -l /user/local/pgsql/log/postgres.log start &

  • Below are the contents of the pg_stop file:

$ vim ./pg_stop

#!/bin/sh

pg_ctl -D /user/local/pgsql/data  -l /user/local/pgsql/log/postgres.log stop

  • Don’t forget to make them executable:

$ chmod +x ./pg_start

$ chmod +x ./pg_stop

  • Now use the pg_start script to start up PostgreSQL. Execute it as the postgres user (sudo su – postgres) I tend to cat the log file just to make sure it’s running correctly:

$ ./pg_start

$ server starting

$ cat ../../log/postgres.log

LOG: database system is ready to accept connections

LOG: autovacuum launcher started

  • There is a Mac OS X way of starting PostgreSQL using launchctl . for those using Mac OS X you can use either lauchctl or simply the pg_ctl method. see this page  for details on how to “Create a launchd Launch Agent” to automatically start postgres for you. The instructions look right for Tiger, Leopard, and Snow Leopard. (Beyond that, google for “postgres launchd”).
  • the next step is to use the following commands to create user “jbilling” and database “jbilling_test” :
  • change user to postgres using command :

$su -postgres

  • at postgesql shell issue the following two commands:

postgres=#CREATE ROLE jbilling WITH LOGIN SUPERUSER CREATEDB CREATEROLE PASSWORD 'jbilling';

postgres=#CREATE DATABASE jbilling_test WITH OWNER jbilling;

Now you have a Postgresql database ready to use with the jbilling system.

2-JBilling System Setup:


To build jbilling from sources follow these instructions from jbilling website.  after you complete these steps you will need some extra steps not mentioned in previous instructions to get your jbilling development envirenment setup correctly:

The extra steps you need to do :

  •   copy file   ~/jbilling/src/jars/postgresql.jdbc4.jar  to   ~/jbilling/lib/ (in case it is not already there)
  • change this line in file  ~/jbilling/conf/jbilling.properties:

# time interval for scanning cached rules bases for updates
rules_scanner_interval=5

  • rename file “~/jbilling/src/build.properties.sample”  (remove .sample )
  • set BASEDIR envirement variable :

export BASEDIR= YOUR_JBILLING_INSTALLATION_DIR
(example :
export BASEDIR=/home/othman/Development/Java/workspace/jbilling/
)

  • add  directories “src/resources” and “src/libs”  from jbilling-src.zip  (downloaded from jbilling) to your git src directory
  • If you use  eclipse  IDE  see instructions on how to use eclipse with jbilling here
  • select eclipse output directory as “jbilling/src/build/classes”.

The steps described above should get you a correctly setup jbilling 2 development environment.

Happy JBilling coding!


Recommended Links:

Written by othman

April 18, 2012 at 8:40 pm

Posted in Java, jbilling

2011/2012 A Boom Year For Online Education

with one comment

Below is one post comment to an Interesting article in wired Science Magazine:  The Stanford Education Experiment Could Change Higher Learning Forever

Yes this is a big deal. 2011/2012 is a boom year for online education, we are finally fulfilling the potential of the internet. The 2000s have been to a small extent a period where we saw the rise of “big data” (http://en.wikipedia.org/wiki/B… ) in the 2010s we will see that rise change our lives. Udacity/MITx/Coursera/KhanAcademy are building the big dataset we need to analyse and improve.

Just pause to think what say Google could do if it had detailed data and statistics about how people learn say Algebra or Quantum Mechanics, right down to the individual click.

If there is *any* fruit left on the tree of better educational theory and practice, this is how we will get it.

Very well said ; and very interesting to monitor the progress of this new trend of free online education.

Important free online education programs:

  1. Udacity
  2. MITx
  3. Coursera
  4. Khan Academy

Written by othman

March 29, 2012 at 10:14 pm

Turing’s Titanic Machine?

leave a comment »

Written by othman

February 23, 2012 at 4:00 pm

What is MITx?

leave a comment »

Written by othman

December 31, 2011 at 12:20 am

Posted in E-learning

The Most Ancient Marketing

with 2 comments

The Most Ancient Marketing | December 2011 | Communications of the ACM.

The Most Ancient Marketing

[article image] Credit: Gluekit / Photograph by AP Photo / Paul Sakuma

Before Apple, Steve Jobs famously went to India with his college friend Dan Kottke. While I never had occasion to talk to Jobs about it, I did hear many a tale from Kottke, and I have a theory I wish I had a chance to try out on Jobs.

Jobs loved the Beatles and referred to them fairly often, so I’ll use some Beatles references. When John Lennon was a boy, he once recalled seeing Elvis in a movie and suddenly thought to himself, “I want that job!” The theory is that Jobs saw gurus in India, focal points of love and respect, surrounded by devotees, and he similarly thought to himself, “I want that job!”

This observation is not meant as a criticism, and certainly not as an insult. It simply provides an explanatory framework for what made Jobs a unique figure.

For instance, he liberally used the guru’s tactic of treating certain devotees badly from time to time as a way of making them more devoted. I heard members of the original Macintosh team confess that they succumbed. They were tangibly stunned by it, repeatedly. They recognized it happening in real time, and yet they consented. Jobs would scold and humiliate people and somehow elicit an ever more intense determination to attempt to win his approval, or more precisely, his pleasure.


Jobs imported the marketing techniques of India’s gurus to the business of computation.


The process is described in an essay by Alan Watts on how to be a guru that was well known around the time Apple was first taking off. The successful guru is neither universally nor arbitrarily scornful to followers, but there should be enough randomness to keep them guessing and off guard. When praise comes, it should be utterly piercing and luminous, so as to make the recipient feel as though they’ve never known love before that moment.

Apple’s relationship with its customers often followed a similar course. There would be a pandemic of bleating about a problem, such as a phone that lost calls when touched a certain way, and somehow the strife seemed to further cement customer devotion instead of driving them away. What other tech company has experienced such a thing? Jobs imported the marketing techniques of India’s gurus to the business of computation.

Another way in which Jobs emulated the practices of gurus is in the psychology of pseudo-asceticism.

Consider the way he used physical spaces. Jobs always created personal and work spaces that were spare like an ashram, but it is the white Apple store interior that most recalls the ashram. White conveys purity, a holy place beyond reproach. At the same time, the white space must be highly structured and formal. There must be a tangible aura of discipline and adherence to the master’s plan.

The glass exteriors and staircases of elite Apple stores go further. They are temples, and I imagine they might someday be repurposed for use along those lines. (Maybe, some decades from now, our home 3D printers will just pop out the latest gadgets, leaving stores empty.)

There is yet another Beatles reference to bring up: It was Yoko Ono who first painted a New York City artist’s loft white. Conceptual avant-garde art invites people to project whatever they will project into it, and yet the artist offering a white space, or the silence of John Cage’s “4’33″” still becomes well known. This is the template followed by Apple marketing.

A dual message is conveyed. The white void is empty, awaiting you and almost anything you project into it. The exception is the surrounding institution—the business—which is not something to be projected away.

While that setup might seem to only benefit the establishment offering the white space, there is actually a benefit to the visitor who projects what they will into it. It’s like a good parent or lover who will listen endlessly without complaint but also sets boundaries. Narcissism can then be indulged without the terror of being out of touch or out of control. This formula is a magnet for human longings.

It’s all about you, iThis and iThat, but we will hold you, so you won’t screw yourself up. Of course, that’s not really a possible bargain. To the degree you buy into the ashram, you do give up a certain degree of yourself. Maybe that’s not a bad thing. It’s like how Apple customers experience culture in general through the lens of Apple curation whenever they use a tablet. Maybe it’s the right mix for some people. But one ought to be aware.

It’s tempting to ridicule this aspect of Job’s legacy, but everything people do is infused with some degree of duplicity. This is doubly true of marketing.

Putting the duplicity up front might be best. Back to the Beatles: Lennon’s “Sexy Sadie” ridiculed the guru shtick, while McCartney’s “Fool on the Hill” praised it, and they were singing about the same guru. These two songs could well be applied to the appeal of Apple under Jobs. Yes, he manipulated people and was often not a nice guy, and yet he also did either elicit or anticipate the passions of his devotees, over and over. (No one can say what the mix of eliciting versus anticipating really was.)

Jobs didn’t just use pseudo-asceticism for marketing. He wielded purist fanaticism so as to have power in the world of nerds. This is how it came to be that Jobs is so often remembered as an “inventor,” though he rarely was one. His genius was not technical, but he was a genius at manipulating technical minds.

An example is Jobs’ obsession with engineering beautiful fonts into personal computers. While plenty of people wanted this (Don Knuth comes to mind), it wasn’t easy to make such a luxury into a high-priority item in the engineering culture that drove early PC companies. But Jobs often mentioned his pride at having done it.

It is perhaps surprising that so few figures in tech companies have been able to push engineers around enough to enforce principles of elegance and simplicity, as understood by non-engineers. Apple’s commercial success has created a better atmosphere for such things in all the companies. But how did Jobs do it in the first place?

My impression, based on a number of interactions I witnessed over many years, is that Jobs traded one form of obsessive, principled nerdiness against another. It was useless for a typical designer or marketing person to plead with engineers during the early years of personal computers. Engineers had airtight criteria and data, and that trumped mere opinions and intuitions. But Jobs didn’t plead. He declared even more rigid and exacting criteria.

Jobs won the arms race of control freakery. He remains the only figure in a non-engineering role I have ever seen win this race against engineers outright.

Author

Jaron Lanier is Partner Architect, Microsoft Research, and Innovator in Residence, USC Annenberg School.


Copyright held by author.

The Digital Library is published by the Association for Computing Machinery. Copyright © 2011 ACM, Inc.

Written by othman

November 25, 2011 at 11:12 am

Posted in apple

Google’s Web Content Blocking Report

leave a comment »

Credit : Technology Review Magazine

Google reveals how often ­governments ask it to banish things from its services and how often it complies.
Full  Article : Going Offline
google.com/transparencyreport.

Written by othman

November 4, 2011 at 8:44 pm

Posted in Google

What Did Steve Jobs Do for Computer Science?

leave a comment »

Written by othman

November 3, 2011 at 10:08 pm

Posted in apple

Google ClientLogin Utility in Java

leave a comment »

Authentication and Authorization for Google APIs is a common feature in today’s applications requiring integration and information exchange with Google services. while most of this Google authentication process is tailored for web applications, it is also available for desktop and installed applications. for Desktop applications Google recommends using an authentication method called ClientLogin.

ClientLogin method Caution:
Google no more recommands using ClientLogin method for Authorization. here is a quote from google documentation:

ClientLogin is a Google proprietary authorization API, available as an alternative to OAuth for most Google APIs. You should avoid using ClientLogin if possible. If you already have applications that use ClientLogin, you should migrate to OAuth or the hybrid protocol.

Thus, ClientLogin is for use only when there is a high level of trust between the application and the owner of the protected data. It is mostly commonly recommend for cases where the application owns the protected data. If users of your application are worried about supplying their passwords for security and privacy reasons then ClientLogin authorization method is not suited for this situation.

How ClientLogin authorization works?
The ClientLogin method works mainly by sending HTTP Post requests to Google service using specific parameters as described in Google documentation. In this article we will use a different approach to implement ClientLogin authorization process. We will use Google APIs Client Library for Java, which is a powerful java library for accessing Google’s HTTP-based API’s on the web. The most important class in this library is , Obviously, the ClientLogin class.

Anatomy of the ClientLogin class:
ClientLogin class provides a single method authenticate() which handles the details of authentication process. it also provides an important internal class ErrorInfo which could be used to handle authentication errors and captcha challenge logic.
In this post we present a clean wrapper class for ClientLogin which handles the complete ClientLogin authorization process including authentication errors parsing and captcha challenge handling.

google-api-java-client Maven Dependencies:
we chose to use maven for building our project example. Maven provides dependencies for the Google APIs Client Library for Java. just add the following maven dependencies to your pom.xml file:

 <dependency>
      <groupId>com.google.api.client</groupId>
      <artifactId>google-api-client-googleapis-auth-clientlogin</artifactId>
      <version>1.2.3-alpha</version>
    </dependency>
    <dependency>
    <groupId>com.google.api.client</groupId>
    <artifactId>google-api-client-javanet</artifactId>
    <version>1.2.3-alpha</version>
  </dependency>

after that use maven:install to install the required jars to be included in our project classpath.

GoogleClientLogin wrapper class:
Our wrapper class obviously contains a reference to ClientLogin . it provides public methods implementing the important functions of the authentication process.
GoogleClientLogin has a constructor that takes a String representing the Google service you’re requesting authorization for ( for example “cl” for Google Calendar). The constructor looks like this:

/**
	 * @param service
	 */
	public GoogleClientLogin(String service) {
		super();
		this.service = service;
		authenticator = new ClientLogin();
		transport = GoogleTransport.create();
		authenticator.authTokenType = service;
	}

The main method is authenticate(username,password) that takes two arguments representing the username and password input by user:

/**
	 * @param username
	 * @param password
	 * @throws ClientLoginException
	 */
	public void authenticate(String username, String password)
			throws ClientLoginException {

		try {

			// authenticate with ClientLogin
			authenticator.username = username;
			authenticator.password = password;
			Response response = authenticator.authenticate();
			this.authToken = response.auth;

		} catch (HttpResponseException e) {
			parseError(e);

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

this method sets ClientLogin variables (username and password) then calls ClientLogin.authenticate() which returns a Response instance. if the ClientLogin.authenticate() call is successful we store the Authentication token ‘Response.auth’. The advantage of the authenticate(username,password) wrapper method is its intelligent handling of authentication errors.

Parsing Authentication errors:
We distinguish two Error categories that could be thrown during the call to Clientlogin.authenticate(): a-unrecoverable Errors for which we use a ClientLoginException class
b-a recoverable error thrown when Google service requires a captcha challenge. for this later we use a separate Exception class CaptchaRequiredException which extends the first ClientLoginException class.
Clientlogin.authenticate() throws a HttpResponseException if the authentication response has an error code. we provide a helper method for parsing this exception class as follows:

/**
	 * @param e
	 * @throws ClientLoginException
	 */
	private void parseError(HttpResponseException e)
			throws ClientLoginException {
		try {

			ClientLogin.ErrorInfo errorInfo = e.response.parseAs(ClientLogin.ErrorInfo.class);
			errorMessage = errorMsg.get(errorInfo.error);
			if (errorInfo.error.equals(CaptchaRequired)) {
				captchaToken = errorInfo.captchaToken;
				captchaUrl = errorInfo.captchaUrl;
				throw new CaptchaRequiredException(errorMessage, e);

			} else
				throw new ClientLoginException(errorMessage, e);
		} catch (IOException e1) {
			
			throw new ClientLoginException(e1);
		}
	}

we Call HttpResponseException.response.parseAs(ClientLogin.ErrorInfo.class) to parse the response. if the error code is “CaptchaRequired” we store errorInfo.captchaToken and errorInfo.captchaUrl then throw CaptchaRequiredException. for the rest of Error codes we just throw ClientLoginException.

Authentication with CAPTCHA Challenge:
in the case of a CAPTCHA challenge we provide a second authenticate() method which provides an extra argument ‘captchaAnswer’ representing the captcha key entered by user during a CAPTCHA challenge:

/**
	 * @param username
	 * @param password
	 * @param captchaAnswer
	 * @throws ClientLoginException
	 */
	public void authenticate(String username, String password,
			String captchaAnswer) throws ClientLoginException {
		authenticator.username = username;
		authenticator.password = password;
		authenticator.captchaToken = this.captchaToken;
		authenticator.captchaAnswer = captchaAnswer;
		try {
			Response response = authenticator.authenticate();			
			this.authToken = response.auth;
		} catch (HttpResponseException e) {
			parseError(e);
		} catch (IOException e) {
			throw new ClientLoginException(e);
		}
	}

before calling authenticator.authenticate() this method sets two extra fields authenticator.captchaToken and authenticator.captchaAnswer. Error handling for this method is the same as the main authenticate(username,password) method.
Finally we provide a method to retrieve the CAPTCHA image that will be displayed to user:
/**
	 * @return the captchaImage
	 */
	public BufferedImage getCaptchaImage() {

		BufferedImage image = null;
		try {
			URL url = new URL("https://www.google.com/accounts/"+ getCaptchaUrl());
			image = ImageIO.read(url);
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}

		return image;
	}

You can view the complete GoogleClientLogin class source file here.

Testing GoogleClientLogin wrapper class:
GoogleClientLoginDialog is a swing Dialog which presents an example of how to use GoogleClientLogin wrapper class. It provides a feature to force Google service to send a CAPTCHA challenge. we implement this test using a thread that keeps sending random passwords until Google responds with a CAPTCHA challenge:

 private class ForceCaptchaRunnable implements Runnable{

		public void run() {
			Random r = new Random();
			boolean isCaptcha = false;
			while (!isCaptcha) {
				try {
					client.authenticate(textField.getText().trim(),
							passwordField.getText().trim()+ r.nextInt(100));
					showMessage("Auth Token: "+client.getAuthToken());
				} catch (CaptchaRequiredException e1) {
					
					isCaptcha = true;
					showCaptcha(true);
					
				} catch (ClientLoginException e1) {
					
				}
			}
			
		}
		
	}

You can view and download the complete source code of this sample project at Google code project: google-apis-utils .


Resources:
Google code project: google-apis-utils.

Written by othman

September 2, 2011 at 9:18 am

Posted in Google, Java

Google Cloud Connect offline installer

with 3 comments

I always face problems installing plugins from Google. it seems their installers download is blocked if we are behind a firewall or because Google uses a proxy that blocks unauthenticated content ; or maybe for other internet connectivity reasons.
I recently failed to install the Google Cloud Connect for MS office plugin . The download fails without reporting any Error number.
A workaround is to directly download the plugin installer from the below link :

https://dl-ssl.google.com/dl/appsconnect/googleconnectinstallerenterprise.msi



Written by othman

July 12, 2011 at 3:34 pm

Posted in Google

Tagged with ,

OpenStudy : a Big Idea or just another Q&A system ?

leave a comment »

I Recently read a blog entry at CACM: Our Big Idea: Open Social Learning .  The article mentions a project OpenStudy.com which is a a start-up company spun off by Georgia Tech and Emory University. Its Web site is the latest effort to create a social platform for independent learners who want to help each other study the huge trove of educational materials published free online by universities like MIT. Another way to describe this Project is as a Open Social Learning aka Massively Multiplayer Online Learning

The Idea sounds Great But is it really innovative? .  as it stands now , openStudy is merely another Q&A website . There exists new modern Q&A systems like the popular Stack Exchange web sites network which is

a fast-growing network of 51 question and answer sites on diverse topics from software programming to cooking to photography and gaming.

many students , researchers and scientists use now extensively the Stack Exchange network sites to conduct open study collaboration on various scientific topics like mathematics , physics , programming and many other STEM topics.

In your opinion what makes OpenStudy really a Big Idea as their founders describe it? will it really take its promise to revolutionize the STEM learning process in the world and become the Facebook of schools? what is your evaluation of the OpenStudy project ?

Written by othman

June 5, 2011 at 5:36 am

Follow

Get every new post delivered to your Inbox.