Archive

Archive for the ‘code’ Category

quran android released!

August 11th, 2010 ahmedre 2 comments

quran android qr code

ramadan kareem! just in time for ramadan, we’ve released the first version of Quran Android. download it and let us know what you think! the source code is on github.

Categories: code, islam Tags: ,

what on earth, etisalat?

July 19th, 2010 ahmedre No comments
#!/bin/sh
APP_NAME="Etisalat_3.5G_USB_Modem"
APP_PATH="/Applications/Mobile Partner.app"

sudo chmod -R a+rwx "$APP_PATH"

chmod -R a+rw "/usr/local/"

the above code snippet is from the first few lines of one of the etisalat 3g usb modem’s postinstall script on osx – seriously, why chmod -R a+rw "/usr/local/"? no one uses /usr/local except etisalat?

the modem is a huawei e1550 hsdpa usb stick.

Categories: code Tags:

setting up a blackberry dev environment under linux

June 24th, 2010 ahmedre 6 comments

i recently had to look at the blackberry sdk for something. to my disappointment, the blackberry sdk is only available for windows – no linux or mac versions in site. my first attempt was to run a windows vm under virtualbox, but that brought my system to a screeching halt.

so i started doing some research (see sources at the bottom of the post) and found an easier way.  i did this all under ubuntu linux (lucid).

1.  install wine (sudo apt-get install wine)
2.  get winetricks from here (see http://wiki.winehq.org/winetricks for details).
3.  chmod +x winetricks; ./winetricks gdiplus; ./winetricks msxml3
4.  download and install the jdk for windows from sun (oracle?) under wine.
5.  update your windows path to contain the directory of the sdk – do this by editing ~/.wine/system.reg and searching for PATH= and appending your path to it.
6.  ensure that java works under wine (ie run wine javac and see if it works – if it doesn’t, try doing a wine cmd followed by a path to see what the path is at the moment).
7.  download the 32 bit eclipse for windows – unzip it and move it to ~/.wine/drive_c.
8.   install the blackberry sdk (wine BlackBerry_JDE_PluginFull_1.1.2.201004161203-16.exe).
9.  mkdir /opt/rim; cp -r ~/.wine/drive_c/eclipse/plugins/net.rim.ejde.componentpack5.0.0_5.0.0.25/components /opt/rim/sdk
10.  download the sun java wireless toolkit for linux and install it in /opt/rim/WTK2.5.2
11.  finally, set up a /opt/rim/tools directory and add the following files in there (make sure to chmod +x them):

build.sh:

#!/bin/bash

SDK=/opt/rim/sdk
PREVERIFY=/opt/rim/WTK2.5.2/bin

PATH=$PATH:$PREVERIFY java -jar $SDK/bin/rapc.jar \
   import=$SDK/lib/net_rim_api.jar \
   codename=$1 \
   $1.rapc \
   *.java

9550.sh

#!/bin/bash
cd "`dirname $0`"
/usr/bin/wine /opt/rim/sdk/simulator/fledge.exe /app=/opt/rim/sdk/simulator/Jvm.dll /handheld=9550 /session=9550 /app-param=DisableRegistration /app-param=JvmAlxConfigFile:9550.xml /data-port=0x4d44 /data-port=0x4d4e /pin=0x2100000A

and that’s it! now let’s compile a sample app, say the helloworld sample (from /opt/rim/sdk/samples/com/rim/samples/device/helloworlddemo/). to do this, copy the helloworlddemo folder somewhere and add a HelloWorldDemo.rapc file in that folder that looks like this:

MIDlet-Name: HelloWorldDemo
MIDlet-Version: 0.9
MIDlet-Vendor: Research In Motion Ltd.
MIDlet-Jar-URL: HelloWorldDemo.jar
MIDlet-Jar-Size: 0
MicroEdition-Profile: MIDP-2.0
MicroEdition-Configuration: CLDC-1.1
MIDlet-1: Hello World Demo,img/helloworld_jde.png,
RIM-MIDlet-Flags-1: 0

now you can compile it by running /opt/rim/tools/build.sh HelloWorldDemo – if all is well, you should see a HelloWorldDemo.cod file.

then run 9550.sh, which should launch the simulator. you can choose to install the cod file from the menu.

btw, if you want to use other emulators, run wine fledge.exe /help under /opt/rim/sdk/simulator and you’ll find what valid parameters there are for the device type. then edit 9550.sh and change it to your device type.

one other note – another way to compile applications involves using the blackberry ant tools. i haven’t tried this yet, however.

sources
- Eclipse + JDE + Linux – a working environment
- How to use BlackBerry Device with Linux
- BlackBerry Development on Mac OS X

Categories: code Tags: ,

google buzz – friend or follow

February 10th, 2010 ahmedre No comments

i like the site for twitter, ‘friendorfollow,’ which tells me who i am following and isn’t following me back, who are following me and i am not following back, and so on. given that i got access to google buzz today, i decided to write a little script to help me determine the breakdown of my friends (specifically, who i am following and isn’t following me back, since the rest of the information is easy to read off of the website anyway).

this script will tell you who your friends are (lol, i wish), who your fans are, and who you are following but isn’t following you back. unfortunately, there’s a manual step involved (getting the server response with your friends and followers). there’s really no point in trying to automate this right now, because soon enough, i expect that one of the google apis will expose this functionality.

download it from github here.

Categories: code Tags: ,

salam, android!

January 22nd, 2010 ahmedre 2 comments

after the nexus one came out, i became a little more interested in android. while i had written a simple ‘salam world’ app some time ago, i figure it would be nice to delve a little deeper and try to write something remotely useful.

so without further adieu, introducing a (very simple) quran for android:

source code on github

for the most part, android is fairly fun and easy to develop for. however, one of the most frustrating parts is the extremely limited memory for apps. since apps can’t be on the sd card (due to some security issues), you are limited to the very small amount of memory on the device. consequently, in order to display the images for the quran in this app, the app must download the data to the user’s sd card.

note – try it at your own risk, i only tested it on the emulator…

Categories: code, islam Tags: , ,

quran jetpack script

November 16th, 2009 ahmedre 1 comment

so i had a little bit of time before i depart on my journey for hajj, so i wanted to play around with the firefox jetpack extension a little bit. so without further adieu, this post is here to introduce a simple quran plugin for jetpack :)

what is it
this is a quran script for jetpack, a plugin for firefox which allows customizing the browser just through javascript.

when you are typing in a textarea (in wordpress, gmail, google talk, etc), if you highlight any text in the format of sura:ayah (ex 1:1) and right click on it, you will be given a menu that allows you to replace that with the actual verse (in arabic, transliteration, or translation).

this is very nifty for taking notes, chatting, sending emails, etc.

how does it look like?
here is a screenshot:
quran jetpack script screenshot

known issues
- sometimes, the server appears to take long to reply so it doesn’t return and you are forced to try again.
- the plugin doesn’t work on google docs and other sites that overwrite right click functionality.
- the plugin also doesn’t seem to be working on gmail when rich formatting is on.

how to install it
- install jetpack for firefox.
- go to this page. on the top right corner of the webpage, you will find a button that says, “Install…”. click it.
- scroll to the very bottom, click the “auto-update this feature” checkbox, and then click on “i know what i am doing, install it!”

source code
the source is also available as on github in this gist.

changelog
november 16th, 2009
- fixed a bug in which the appended (sura:ayah) to the text was put at the end of the textarea rather than right after the ayah.
- added a little favicon for the menu.

quran jetpack script screenshot

Categories: code, islam Tags: , ,

subqueries make life easy

September 13th, 2009 ahmedre 1 comment

often times while working with databases, you find the need to do some simple tasks (adding a column and populating it with a value from another table, etc). rather than write a script to do this, use mysql’s native subquery (and temporary table) functionality – it makes life much easier.

consider the case where you have two tables:

mysql> describe colors;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id    | int(11)     | YES  |     | NULL    |       |
| color | varchar(10) | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

and

mysql> describe color_mapping;
+------------+---------+------+-----+---------+-------+
| Field      | Type    | Null | Key | Default | Extra |
+------------+---------+------+-----+---------+-------+
| picture_id | int(11) | YES  |     | NULL    |       |
| color_id   | int(11) | YES  |     | NULL    |       |
+------------+---------+------+-----+---------+-------+
2 rows in set (0.00 sec)

let’s say you want to update the colors table to add a frequency column such that you know how often a given color is used. it turns out this is really easy using mysql:

alter table colors add frequency int;
update colors set frequency = (select count(*) from color_mapping \
   where color_mapping.color_id = colors.id);

and that’s it. also useful are temporary tables:

create temporary table color_frequencies select color_id, count(*) as cnt \
   from color_mapping group by color_id;

if you then attempt to desc color_frequencies, you’ll see a table with two columns – a color_id and a cnt column.

hopefully this will save some people some efforts writing scripts next time some simple database updates are needed :)

Categories: code Tags:

quran plugin updated for ubiquity 0.5

August 10th, 2009 ahmedre 6 comments

i’ve done a quick port of the quran ubiquity plugin to work under the new version of ubiquity (0.5). as you may know, ubiquity 0.5 and beyond use a new parser (parser 2) that isn’t compatible with the old parser (parser 1 for 0.1.x versions of ubiquity).

you can get it here. make sure to select “automatically update this feed” so that you get any updates i may get around to making.

this version is pretty much identical to the older one, except that now, you can use “get-ayah,” “get ayah,” or “ayah” to get an ayah, and “search-quran” or “search quran” to do a search. i hope to support some of the new stuff from the pre-alpha version of the quran api soon insha’Allah (other translations, etc).

Categories: code, islam Tags: , ,

introducing waqt.org

July 10th, 2009 ahmedre 7 comments

today, i took the arabeyes php extension of itl, the yahoo geocoding api, and the geonames api and put together waqt.org.

it’s a fairly minimalistic prayertimes site. the code is available on github. note that the calculation method is currently hardcoded to use the isna method, but this is fairly easy to change.

Categories: code, islam Tags:

quran ubiquity plugin

May 19th, 2009 ahmedre No comments

updated and released the first version of the quran ubiquity plugin! you can go here to install it.

essentially, it contains two commands -
1. search-quran – takes a parameter of what to search for and will show the results that match that particular query. hitting enter will bring up the search results page.
2. get-ayah – takes a parameter of which ayah (ex 2:2) and an optional parameter of the language/translation you want the ayah in (in english – muhsin khan, for example – note that ubiquity will provide suggestions for these). hitting enter will insert the text into the selection space.

this is uber-useful for muslims imho :p perhaps i will try to provide a screencast later on that shows how to use this for those who are still afraid to try it :)

*update* – rather than make my own screencast, i’ve decided to record a set of audio instructions on how to use it.

by the way – if you haven’t used ubiquity before, i highly recommend that you watch this video first. it explains what ubiquity is and gives you an idea of what it is useful for. to put it quite simply, ubiquity is amazing. it’s an indispensable tool for your firefox. watch the video :)

and here is the audio tutorial on the quran plugin for ubiquity.

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

enjoy!

Categories: code, islam Tags: , , ,