Categories
Uncategorized

Fedora 21

Problems with it:

  • I don’t understand a thing about its manual partitioning.
  • This is the main thing why I did not install fedora in the first place. I don’t know how. 
  • It does not have a decent GUI package manager. No, the gnome software one will not do. I’m talking about synaptic or aptitude or at least like yast. I want to be able to easily see which package is available, not just software.
  • Tips: ‘yum search’ do what you expect it to do.
  • The gnome software hangs. If it hang but give progress, I’ll be a little bit less bored.
  • Slow mirror. Whats the use of having hundreds of server if most of them are really slow? User will most likely connect to the slow servers and will get 15kB/s download speed.
  • Tips: The fastmirror plugin don’t do much. This one does https://hedayatvk.wordpress.com/2011/05/11/introducing-yum-fast-downloader-plugin/.
  • You can also blacklist a mirror using the blacklist option of yum.conf
Categories
Programming Projects

Rails-Devise-Warden Token Authentication + Android’s Volley

Hi, recently I’m trying to make an android app that uses a rails server. I used to code REST server before, but that is for javascript apps. Not android. And now that I’m trying to do so, I found a problem. Whenever the devise authenticate_user! failed and it throw 401 to the android app, Volley complain that some form of challenge key is missing. It work fine with a browser and it responded with an error in json form. This is the normal Devise behavior, which seems to also have support for api server. Because of the error in Volley, I can’t get the JSON that contain the error in order to show the message.

For the impatient one, the solution is this:
[ruby]

Devise::FailureApp #Autoload it

##
# Patch failure app so that the WWW-Authenticate message is sent regardless if using http_authenticatable.
class Devise::FailureApp < ActionController::Metal
alias :old_http_auth :http_auth
def http_auth
old_http_auth
self.headers["WWW-Authenticate"] = %(Basic realm=#{Devise.http_authentication_realm.inspect})
end
end

[/ruby]

Put this in an initializer. Another thing is that, make sure that Volley tells Rails that it is accepting a json response, through HTTP Headers or ‘.json’ postfix.

The reason for the Volley error is that, when an HTTP server respond with HTTP 401, it is expected to respond with “WWW-Authenticate” header. The spec indicate that it MUST respond so. The problem is, the browser treat this header as an indicator to show user an HTTP Basic Authentication form, which is not always what we want. We just want to respond with 401 to indicate that the user is unauthorized for that particular resource. We can’t really use 403 because that means, Forbidden, a different meaning. Showing a 200 with an error message/json just feels too hackish for an api server. Because of this, devise did not send the header if the model did not enable http basic authentication.

By default, Devise sent out a 401 when it detect that the request is not of a ‘navigation’ format. By default that is [*,:html], which as far as I understand, every format and html. Or in another word, everything. For those of you who have problem with setting up Devise for an api server, change this to [:html] and make sure your client application properly indicate its accepted format. Using this, which basically means nothing else but the patch above, my api server seems to be working for now with no error on Volley (aside from authentication error, but that is expected). If the user manually send a request there from a browser, it will redirect to a login page.

Also, if you intend to use token authentication, checkout the devise-token_authentication gem. Devise developers for some reason (which seems to be security) removed the token authentication strategy from devise. This gem is a fork of the token authentication strategy.

Categories
Linux

Opensuse 13.2

Problem with it.

  • When installing, the expert partitioner is not very friendly. It by default already have various suggesting setting in which I don’t know how to change them, like remove the extended partition and make it primary again. Tips: There is a reset button.
  • VLC says, it can’t decode h264. Its VLC and it actually can’t do that if you install from official repository.
  • The Yast2 package manager is not very intuitive.
  • It is not obvious that Opensuse 13.2 version of packman repository exist. (13.2 is still new right now and the documentation has not been updated).
  • It is not clear how to change installed version of library that is also in packman repository to the packman repository version. Hint: change the repository priority so that packman has a higher priority (lower number) then run zypper dist-upgrade.
  • nginx is actually not in the official repository.
  • By default it does not use the usual NetworkManager. Causes confusion. And for some reason, I need to restart the network.service in order for it to work after switching the network backend in Yast. Shouldn’t it do that for me?
  • When I’m installing something, it keeps giving warning about low disk space on an unrelated ntfs partition I used to store various things. I checked the “don’t warn me again checkbox”, but it still warn me.
  • I have to update the repository on every startup of software manager.
  • I have to update the repository every time I want to install something.
  • I have to upgrade any upgradable software every time I want to install something.
  • FGLRX is not working. It just boot to terminal login.
  • The open source radon driver has a tendency to hang at some point.

Plus side.

  • systemd starts really fast.
  • One click install is literally one click install.
  • The repository has priority. Neat.
  • Delta updates.
  • Kde and Gnome desktop is more complete than in ubuntu.
  • zypper is very nice. zipper accept both package name and rpm file. Much nicer than ubuntu/debian separate dpkg and apt-get.
Categories
Programming Projects Uncategorized

Introducing, String2Regex

Assalamualaikum everyone. In this post, I’ll show you a (relatively) new project which I’ve created in about a week or two. It seems to be useful for greater good and so I’ve released the code under the MIT license. The code is available here

String2regex is basically a clone of txt2re.com but run entirely on client side and not as full featured. The concept is, given a sample string, generate a regular expression to match that string based on user’s selection of string groups. If you don’t know what is regular expression, you are probably not a programmer and this is effectively useless for you. If you are a programmer but you do not know what is regular expression, then you are missing out. If you know what is a regular expression, check it our here and you’ll understand what does it do. Screnshot

One significance of this application for me is that it is the first (I think) client side application I made that have some kind of automated testing. It is also the my first client side application that is made ground up with some nifty javascript tools such as bower and grunt. Styler and IIUMSchedule both uses grunt for concatenation purpose but not originally. In another word, String2Re is currently the most… what is the word?… decent? proper? … yes, proper web application I’ve ever made right now. 

This is largely due to some automated testing build with it. The testing is not perfect, as it does not test it entirely and it does not test the view, just the controller logic. However the controller logic is quite complicated (not really) so having some test for that reassure me that it will not crash easily. 

Categories
Article Linux

What to complain about linux’s desktop environment.

Ubuntu’s Unity:

  • I don’t like the virtual desktop.
  • When you click an icon of an application that opened in another virtual desktop, it switches to the virtual desktop.
  • I want it to open in current virtual desktop. So I have to use middle mouse button.
  • The virtual desktop does not show much separation.
  • I can’t really change much.
  • It keeps taking something from Gnome, which in the end, prevent me from installing full gnome environment.

Cinnamon:

  • It just feels unpolished.
  • For some reason it starts slowly compared to other DE.

KDE:

  • I’m not sure if it is really bloated or just feels bloated.
  • Gradients and transparency everywhere.
  • Excellent add-on downloader, but no decent opaque theme.
  • When you click to open something, you just feel than annoying 300ms delay.
  • Feels advanced, but unpolished. The margin and padding is weird. Its like a prototype. You think that I’ll be awesome, but it keep staying as a prototype.
  • Gtk applications sometime does not work very well. 

Gnome:

  • Lack of taskbar and ability to minimize.
  • Sure, it have some nifty drag and drop trick, but sometime we just want an application to hide from every virtual desktop.
  • I’m using two monitor. To switch application I have to drag my mouse to the top left of a screen. So if I’m on my right monitor, its a long way there.
  • For some reason it does not save the monitor offset vertical offset correctly.
  • Virtual desktop only work for the main monitor.
  • Right now I can’t enable any extension.
Categories
Article Programming Projects

Perbezaan antara Python, Ruby dan PHP.

Assalamualaikum semua, apa khabar, dalam post ini, saya akan mencabar diri saya untuk memperjelaskan perbezaan antara Python, Ruby dan PHP dalam kontext pengatucaraan laman sesawang. Cabaran sebenar saya dalam post ini sebenarnya adalah menggunakan bahasa melayu sebanyak yang mungkin. Sesuatu yang sukar dilakukan memandangkan ini adalah bidang perkomputeran yang mana kebanyakan dokumentasi adalah dalam bahasa Inggeris. 

Categories
Uncategorized

Student Admin Dialogue

[tweetpost postid=5649050225344512]

Categories
Personal Projects

Thank you for using SemiAutomatic IIUM Schedule Maker

Assalamualaikum everyone. How are you guys? First of all I would like to say thank you very much for using my newest application SemiAutomatic IIUM Schedule Maker. I expect it to get significant traffic, but not this much. For the record, between 19 April 2014 to today 27 April 2014, the application got 9089 visit or 16928 pageviews, 80% of that is from schedulemaker, 10% from scheduleformatter. In comparison, from january 2012 (the start of the application) to 19 April 2014, it received 9335 visits or 19128 pageviews. Within one week, schedulemaker almost surpassed the amount of traffic generated by scheduleformatter for two whole years. 

Selection_017

It is THAT significant. In fact in the first hour after my friend share it, the server’s cpu peaked at 100% for almost half hour. The traffic steadily decreases after that. One interesting fact is that for every day on prereg, the traffic peaked at 11 PM. Assuming that IIUM Student start sorting their schedule at 11 PM is one thing, but actually having the data to say so is a totally different feel.

Frankly I never though that the tools I make because I’m too lazy sort my schedule or make a timetable would get this much traffic, let alone my website with the highest reception. I mean, the number of IIUM student is approximately 20000, google analytic say that there are 5240 users. Lets assume some of them also use their phone/tablet, so the actual number of user is about 4000. So one every five student in IIUM use this application. Someone actually use this. 

One again I would like to say thank you very much for using the application. This will look brilliantly in my CV. And thank you to all my friends who share the application. Like usual,  if I’m the one who share it, it does not work, but for some reason, if someone else share it, it get hundreds of like. It happened with schedule formatter , it happened with this one and it will happen again in the future. That’s it for now, good bye and Assalamualaikum. 

Categories
Projects

SemiAutomatic IIUM Schedule Maker!

Assalamualaikum everyone, how are you? So, lets get straight to the point. The purpose of this post is to publicly kinda-announce SemiAutomatic IIUM Schedule Maker. Given that it does not have an official readme page, I cannot confidently say that I’m releasing it to the wild. However, given that prereg is next week, and I don’t feel like making an official readme page any time soon, I’m announcing it now in this post. Also, this post will act like a readme page for now. 

So what is SemiAutomatic IIUM Schedule Maker? Basically it is a single web page application that helps you plan/sort your schedule for the next semester. Given that I miss several subject already, I think this should be very useful. How does it helps you? Well…. it:

  • Show your schedule in a day-to-day table like in Automatic IIUM Schedule Formatter in a preview.
  • When you hover the add/replace section button, it show your section as highlighted in the schedule preview.  
  • When a section collide with another section of another subject, it will show that this section collide with the other section. 
  • It has a generator function in which you select all the subject that you want to enroll, then it will list down all possible section combination. Then you just select one of them, and the changes is applied. 
  • It does NOT automatically register the subject. It is just an aid to help you sort your schedule. Don’t blame me if you did not prereg the subject.

How to use it. 

To use it, first go to http://iiumschedule.asdacap.com/schedulemaker/ which is the schedule maker. The first thing you see is that it ask for the session of the schedule and student type. Just enter the session for the schedule and the student type.

plasma-desktop_008

 

Click submit, and it will enter a loading page where it will fetch the subjects for that particular semester for that particular student type. Then you will see this page. 

SemiAutomatic IIUM Schedule Maker

The page is divided into two part. The left part is the preview of current schedule, with the added section as a table. Click on the big red button to remove the section from current schedule. There is two bottom button, the Schedule Generator and the Schedule Formatter which will be explained later. The right section will show all the subject available.

Selection_011

 

Keep in mind that the subject list does not necessarily reflect the current subject available in IIUM. The server will attempt to update the list every week. However it may fail to do so. Just now I tried to update it manually. However, it seems that IIUM server is currently under heavy load and does not response to a request. 

Selection_012

The right panel has a list of kuliyyah. Click on it to filter down the subject list to subject on that particular kulyyah unly. Click on the kuliyyah again to cancel the filter. It also have a search input on top which you can use to search for subject. Click on a particular subject to fetch and show list of section for that particular subject. The section list have an add button. Hover on it to show preview on where it is in the schedule. Click on it to add the section. If the section collide with another section, the add button will not show up. 

Schedule Generator

plasma-desktop_013

Click on the schedule generator to open the schedule generator page. On the left of the generator is also a subject list. However you cannot select a section over here. You only select subject. Several of them, which is which subject you want to pick. After you select the subject, it will generate all possible section combination of the subjects. In another word, several possible schedules with no section collision.

Selection_014

Beware, the application still need to fetch the section list from the server. So wait a few second for all combination to appear. The top button list down the selected subject and the number of section fetched in the black circle. Pick the schedule that you like using the ‘Use Schedule’ button, and it will go back to previous page.

Schedule Formatter

plasma-desktop_015

After you are done with picking section, you can save your schedule through Automatic IIUM Schedule Formatter. Click on the “Schedule Formatter” button to open another page. This page will ask you to input several more information that is needed by the formatter. Just fill it up or leave empty. Click “Save Data”, then it will show notice of saving the data, then another button will appear that say ‘Go to Automatic IIUM Schedule Formatter’. Click on it to open schedule formatter.

Selection_016

That is It

So that is it. It basically does that. I probably should mention about the list limitation I put for performance reason. But its not a big deal. By the way, the whole source code is now available at github. So you can now see the source code. Which means that now, if you have a problem with this thing, or if you want a new feature to be implemented you have two choice. First, the less recommended one, you can email me at asdacap@gmail.com, then wait indefinitely. Or a (much) better alternative, fork the code repository, do the modification yourself, then send a pull request. Anyway, that’s it for now. Good bye and Assalamualaikum. 

PS: You can now share your schedule using a link right above the schedule preview. Just share the link with your friend. The link change every time you add or remove section. 

Categories
Uncategorized

Programming Interest Group Talk

[tweetpost postid=5668600916475904]