Posts

Showing posts from May, 2014

Hack the SelectDateWidget of Django's form

Remember how we can fetch data from an external database to a Django's form? If not, you can check out this blog post: http://iambusychangingtheworld.blogspot.com/2013/07/django-make-use-of-django-forms.html Code block (1): ... def __init__(self, *args, **kwargs):     db = my_db_utils.MyDBUtil()     self.fields['mydate'].initial = my_db_utils.get_data(db, 'my_date') ... Today, I found out an issue with the SelectDateWidget for django.forms.extra.widgets module. It could not display the correct year fetched from the database if the year is in the past. It will render the current year instead. The only correct parts are the day and the month of the intial date data fetched from db. As I invested source code of the django/forms/extra/widgets.py, I saw: Code block (2): ...     def __init__(self, attrs=None, years=None , required=True):         # years is an optional list/tuple of years to use in the "year" select box. ...

Socrates on Ignorance

Image
“I examined the poets, and I look on them as people whose talent overawes both themselves and others, people who present themselves as wise men and are taken as such, when they are nothing of the sort. From poets, I moved to artists. No one was more ignorant about the arts than I; no one was more convinced that artists possessed really beautiful secrets. However, I noticed that their condition was no better than that of the poets and that both of them have the same misconceptions. Because the most skillful among them excel in their specialty, they look upon themselves as the wisest of men. In my eyes, this presumption completely tarnished their knowledge. As a result, putting myself in the place of the oracle and asking myself what I would prefer to be — what I was or what they were, to know what they have learned or to know that I know nothing — I replied to myself and to the god: I wish to remain who I am. We do not know — neither the sophists, nor the orators, nor the artists, n...

Wish me a happy birthday

Image

edx-platform - A first look at paver in Open edX

Yesterday, I noted that the edx team has moved the edx-platform build system away from rake and use paver instead: https://groups.google.com/d/msg/edx-code/0duQswYtjqg/A6HOFR_npjcJ And when I was trying to create a script to update my custom theme from the git repo, I got some feedback and advice to use the paver tool of edx-platform instead for the sake of simplicity : https://groups.google.com/d/msg/edx-code/ozqkmW3ll10/dsr4TbG3fAUJ So, I took a while to look into the /edx-platfrom/paverlib/ to see how to use paver , what are the available options of paver in Open edX? Here they are: edxapp@demo:/edx/app/edxapp/edx-platform$ paver help ---> paver.tasks.help Usage: paver [global options] taskname [task options] [taskname [taskoptions]] Options:   --version             show program's version number and exit   -n, --dry-run         don't actually do anything   -v, --verbose        ...

edx-platform - Activation link when registering account from CMS after 05/16/2014 update

This morning, after I ran an update for our Open edX instance, the activation link when registering from CMS was 'localhost' even though the EDXAPP_SITE_NAME variable was set to 'our.domain.com'. After a while looking around the ansible playbooks of the configuration repo, I figured out why. There were some changes with the main configuration file which caused the issue: https://github.com/edx/configuration/blob/master/playbooks/roles/edxapp/defaults/main.yml They are: EDXAPP_SITE_NAME : 'localhost' EDXAPP_LMS_SITE_NAME : "{{ EDXAPP_SITE_NAME }}" EDXAPP_CMS_SITE_NAME : 'localhost' So, I had to add EDXAPP_CMS_SITE_NAME variable in /edx/app/edx_ansible/server-vars.yml and ran the update script again: EDXAPP_SITE_NAME : 'our.domain.com' EDXAPP_CMS_SITE_NAME : 'our.domain.com' For now, the  EDXAPP_CMS_SITE_NAME  have to be the same with  EDXAPP_SITE_NAME  or the activation link will not work.

edx-platform - Error when accessing Course Creator link in the django admin interface of CMS

After logged in into the django admin interface of CMS (/admin) as superuser, click the Course Creator link, I got this error: DatabaseError: (1146, "Table 'edxapp.course_creators_coursecreator' doesn't exist") First, I tried to migrate the db of edx following the official wiki of Open edX (https://github.com/edx/configuration/wiki/edX-Managing-the-Production-Stack) sudo -u www-data /edx/bin/python.edxapp ./manage.py lms syncdb --migrate --settings aws But not thing changed. After a while, I noted the migrating command, It only migrates the lms, not the cms. So, gotcha! I just need to migrate the db of CMS and everything will be fine: sudo -u www-data /edx/bin/python.edxapp ./manage.py cms syncdb --migrate --settings aws

Accept both username and email address as login identity in simplesamlphp

By default, simplesamlphp only allow you to login by username. But, you hack the source code to make simplesamlphp accept both username and email address as login identity. The solution is pretty simple: + just take the input username and check if -- it is an email than split the string, get only the username part -- it is not an email, than use the input string # nano /path/to/simplesamlphp/modules/core/www/loginuserpass.php ... function get_username($un) {         if (strpos($un,'@') !== false) {                 $un = strstr($un, '@', true);         }         return $un; } if (array_key_exists('username', $_REQUEST)) {         $username = get_username($_REQUEST['username']); } elseif ($source->getRememberUsernameEnabled() && array_key_exists($source->getAuthId() . '-username', $_COOKIE)) {         $usernam...

Setting up SSL in Apache 2.2 in Windows

To enable SSL in Apache 2.2 in a Windows environment, you need to have these following things, certificates: + Your server certificate + The Intermediate CA certificate + The root CA certificate or + The combined certificate (of the above ones) and + The private key 1. Open the main configuration file of Apache ( C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf ) and make sure these lines look like following: ... Include conf/extra/httpd-ssl.conf ... LoadModule ssl_module modules/mod_ssl.so ... 2. Open the ssl configuration file ( C:\Program Files\Apache Software Foundation\Apache2.2\conf\extra\httpd-ssl.conf ) and modify as following: 3. Restart the Apache service: > Open Windows command prompt (> Start > type cmd) and enter: C:\ net stop apache2.2 C:\ net start apache2.2

Start/stop Apache service in Windows's command line

Image
To start/stop Apache service in Windows use these following commands: Open command prompt (Start > cmd): To stop apache: C:\ net stop apache2.2 or to start apache: C:\ net start apache2.2 Not quite convenient but at least It makes me feel like doing things in linux.

How to export Environment Variables in Windows

There is a way to export and import Environment Variables in Windows. That is export the registry keys which store those variables. For System Variables, open registry editor (cmd > regedit): HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment For User Variables: HKEY_CURRENT_USER\Environment Then you can import these registry keys into other windows machines.

edx-platform - Error when deleting users from django admin interface

I got this error when trying to delete users from the django admin interface of the edx platform: DatabaseError: (1146, "Table 'edxapp.social_auth_usersocialauth' doesn't exist") This bug can be reproduced on edx-platform master (commit: 04376e0 ) according to William Daly (will@edx.org). I reported this issue at https://github.com/edx/edx-platform/issues/3639 A quick fix is to: 1. Add 'social.apps.django_app.default' to INSTALLED_APPS in /edx/app/edxapp/edx-platform/lms/envs/common.py 2. Then run the db migration: $ cd /edx/app/edxapp/edx-platform $ sudo -u www-data /edx/bin/python.edxapp ./manage.py lms syncdb --migrate --settings aws

To import SSL certificate and key into PowerSchool's database

In order to use the PowerSchool's API(s) or to enable Single Sign-on with 3rd-party app using SAML2, we need to enable HTTPS. To enable HTTPS on this application server, import a certificate and private key into the database. If you have already imported a certificate on this or any other application node, skip this procedure. If you do not yet have a certificate you will have the option to import and enable HTTPS at a later time If you choose to import, all certificates should be standard X509 certificates in standard Privacy Enhanced Mail (PEM) format. Viewed in a text editor, PEM format certificates start with "------BEGIN CERTIFICATE-----" and end with "-----END CERTIFICATE-----". The private key file should also be in PEM format . The private key password is the password you set when you generated the private key/certificate request pair. If your certificate authority provides an intermediate certificate or certificates, include them here. My private ...

My favorite thing

Image

mysqld did not start properly and how to troubleshoot

This morning, after rebooting my server, the mysqld service did not listen for incoming connections (port 3306). But I can still see the mysql process: root@myserver:~ ps aux | grep mysql mysql     5804  3.8 17.1 2626952 869352 ?      Ssl  07:34   4:49 /usr/sbin/mysqld root     20822  0.0  0.0   9388   932 pts/4    R+   09:39   0:00 grep --color=auto mysql What happened? First, we should check the mysqld process's status: root@myserver:~# service mysql status mysql start/post-start, process 4394         post-start process 4395 Then check the syslog: root@myserver:~# tail -f /var/log/syslog May  7 07:33:37  myserver  kernel: [  146.209493] init: mysql post-start process (3786) terminated with status 1 May  7 07:33:41  myserver  kernel: [  150.125783] init: mysql main process (4057) terminated with status 7 May  7...

edx-platform - server-vars.yml variables

Remember how we used our custom theme for the Open edX? We added some custom variables in the server-vars.yml file: http://iambusychangingtheworld.blogspot.com/2014/03/edx-platform-using-standford-them-for.html Here is the full list of variables you can use to make change to your own server's configuration: Notes : you should check out this file regularly since it will be updated over time  https://github.com/edx/configuration/blob/master/playbooks/roles/edxapp/defaults/main.yml