Javascript check Opera Mini

So today I got caught on the weird-side of mobile web-development, that is to create consistent javascript on major mobile browsers. The good news is Android and IPhone are using webkit so it’s kind of easy. The Bad News is Opera Mini.

Don’t get me wrong, I love opera mini. But the different java-script engine behavior could cause headache sometimes. After googling for a while I stumbled on this http://dev.opera.com/articles/view/javascript-support-in-opera-mini-4/ that mention some things to consider:

  1. Opera Mini JS has a limited DOM event
  2. No background scripting
  3. Very limited AJAX support

And the most important thing is this snippet to check whether we are inside Opera Mini (of course you can use PHP or Server Side script as a better method)

is_operamini = Object.prototype.toString.call(window.operamini) === "[object OperaMini]";

So to avoid more headache, I just treat opera-mini as a non-javascript-capable browser *smirk*

Create Dwoo plugin that is reusing another plugin

I am using Dwoo template http://dwoo.org/ for my PHP project, and Dwoo allow me to create custom plugins. each plugin is stored inside php file, and Dwoo will be the one that handle the plugin lazy-loads.

But how one plugin can reuse another plugin? I can’t find anything on google about that, so I take a look at how
the compiled-code call plugin.

    if (function_exists('Dwoo_Plugin_input')===false) {
        $dwoo->getLoader()->loadPlugin('input');
    }

Ah, simple! so my plugin can also use the same way to call another plugin. Here is the code for my ‘password’ plugin that is reusing ‘input’ plugin to generate HTML field

function Dwoo_Plugin_password(Dwoo $dwoo, array $rest = array()) {
    if (function_exists('Dwoo_Plugin_input')===false) {
        $dwoo->getLoader()->loadPlugin('input');
    }
    $rest['type'] = 'password';
    $rest['autocomplete'] = 'off';
    return Dwoo_Plugin_input($dwoo,$rest);
}

Dwoo FTW!

CodeIgniter router config for dynamic url (url shortener or seo friendly url)

Here’s the scenario, I want my CodeIgniter to be able to works similar to url shortener services (e.g. http://bit.ly) so I can access content by using this kind of format http://blood4lifeid.org/uac1

There’s so many tricks to this. We can use mod_rewrite on some specific pattern, or force our CI to use one Master-Controller, or rewrite CI router mechanism.

But I am going to use the easiest one, only changing CI router.php config
At first I use this on CI routes.php

$route['(:any)'] = "incidents/detail_shortened/$1";

As expected, It’s kind of working, but it makes all of my controller inaccessible, that is because any ‘/controllername/parameter/’ format will match with ‘(:any)’ and will be redirected to our ‘incidents/detail_shortened/’.

To stop controllers redirected by the CI router, I have to explicitly define all of my controllers on the routes.php first (since it’s handled in sequence)

This is the code for that:

$route['default_controller'] = "welcome";
$route['404_override'] = 'help/show404';

// define all 'normal' possible routing path
$route['callbacks'] = 'callbacks';
$route['callbacks/(:any)'] = 'callbacks/$1';

$route['faqs'] = 'faqs';
$route['faqs/(:any)'] = 'faqs/$1';

$route['help'] = 'help';
$route['help/(:any)'] = 'help/$1';

$route['welcome'] = 'welcome';

$route['welcome/(:any)'] = 'welcome/$1';

// the last resort (dynamic)
$route['(:any)'] = "incidents/detail_shortened/$1";

And now it works :) all controller will he handled normally, and my shortened dynamic url will be properly
handled by my `incidents` controller.

P.S:
This applies to CodeIgniter 2.0 (i am not sure whether it works for CI < 2.0)

You can also apply this scenario for your SEO friendly dynamic URL (e.g. http://yoursite.com/content-title-that-is-seo-friendly)

CodeIgniter 404 not found on freshly installed apache2

So I start this morning with freshly installed apache2 on my Ubuntu 11, pulling from bitbucket/Mercurial and suddenly it gave me 404 standard apache2 page.

404 not found

Because my CodeIgniter is a standard no index.php and use .htaccess file to activate the mod_rewrite, so this symptom of problem usually caused by non existing mod_rewrite. So I have to activate mod_rewrite first.


sudo a2enmod rewrite

And then restart apache2 to load the mod


sudo /etc/init.d/apache2 force-reload

Checking on `phpinfo()` it will show mod_rewrite is activated, still 404 error because I haven’t modify the `AllowOverride` settings.

So you have to open file in `/etc/apache2/sites-enabled/000-default` by


sudo nano /etc/apache2/sites-enabled/000-default

(you can use vim, gedit or anything :P )

And change the `AllowOverride None’ into `AllowOverride All`. This will allow `.htaccess` to kick in and override apache2 configurations on your CodeIgniter root.

Refresh the page and voila! my controllers are initalized properly.

Sharepoint Workflow – How To Pass Value To Custom Task Form Extended Properties

So I was reading Ingo’s blog to create a custom task form for my workflow, if you need to create custom ASPX form for your custom task content-type you can go check his blog.

Basically my problem was, how to fill the custom fields inside CreateTaskByContentType activity? there’s ExtendedProperties but putting the field name on ExtendedProperties seems does not pass anything to the newly created Task.

This is my previous code

createTaskProperties.Title = "New Task";
createTaskProperties.PercentComplete = 0;
createTaskProperties.ExtendedProperties["CustomField"] = "Something";

After googling for a bit, I found a solution (sorry I forgot the URL since I *accidentally* clear my history). Basically we are still using ExtendedProperties but we can’t use the custom field name, we have to use GUID of the field.

This is the fixed code

createTaskProperties.Title = "New Task";
createTaskProperties.PercentComplete = 0;
Guid custField = workflowProperties.TaskList.Fields["CustomField"].Id;
createTaskProperties.ExtendedProperties[custField] = "Something";

Voila! the custom field in our custom task will be populated on CreateTask Activity.

Happy meddling with Workflow :)

CAML query on GetItems doesn’t filter the content

So basically today I am creating a SPQuery object to filter list items. The filtering code for list goes like this

SPQuery qry = new SPQuery();
//..
//.. generate the query here
//..
SPListItemCollection listItemsCollection = list.GetItems(qry);

The code doesn’t give any error, but somehow the CAML query doesn’t work. Kind of misleading isn’t it :)

So it turns out that the CAML that I generate is wrong, I use <query> tag that makes it ignore all of my query entirely (somehow it doesn’t give me any error at all).

<Query>
<Where>
<Or>
<Geq><FieldRef Name="Expires" />
<Value IncludeTimeValue="TRUE" Type="DateTime">2011-05-06T21:00:21Z</Value></Geq>
<IsNull><FieldRef Name="Expires" /></IsNull>
</Or>
</Where>
<OrderBy><FieldRef Name="Created" Ascending="False" /></OrderBy></Query>

Just remove the query tag and the GetItems should work

<Where><Or><IsNull><FieldRef Name="Expires" /></IsNull>
<Geq><FieldRef Name="Expires" /><Value Type="DateTime">2011-05-06T14:22:09</Value></Geq></Or>
</Where>
<OrderBy><FieldRef Ascending="FALSE" Name="Created" /></OrderBy>

Add custom menu to Site Actions in Sharepoint 2010

So today’s SharePoint mission is adding a custom menu to the Site Action, this custom menu will link to a custom setting page (ordinary aspx page module).

After googling for a while I found a good solution here.

Basically it’s just creating a new SharePoint Project.  Adding an Empty Element and replace the Elements.xml into this.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="SiteActionsToolbar"
     GroupId="SiteActions"
     Location="Microsoft.SharePoint.StandardMenu"
     Sequence="1000"
                
     Title="My Settings"
     Description="My Site Settings"
     ImageUrl="_layouts/mylayout/img/widgets.png">
     <UrlAction Url="_layouts/mylayout/mypage.aspx"/>
  </CustomAction>
</Elements>

Make sure you add the element to a Feature.

And that is all .

See the detailed solution here.

Decode/Decrypt MD5 Hash

So one of the challenge in one “job employment puzzle” that i took for fun is to get the real value of one md5 hash string.

We know that md5 is an hash algorithm and it’s not reversible (it’s not an encryption), so the only way to know the real value is to do a brute force of multiple string combinations (using char combinations or dictionary attack)

It will took a while to get the results :D

Luckyly there are some people that have the same idea and they share their combination database online, so we only have to submit our MD5 hash and they will compare it with their internal database to look for the real value.

The sites are located here and here

So in my case it’s:

d8578edf8458ce06fbc5bb76a58c5ca4

and the site show me that it’s a MD5 hash of:

qwerty

Now you know why you should avoid MD5 and use better hash algorithm that have salt / modifier (e.g. SHA)

Cannot Send Email From My local test application (Blocked by McAfee)

My friend have this problem, he can’t send email from his local web application using SMTP connection, while other developers PC can.

When he tried to direct connect to port 25 of our SMTP server, it always fail. He tried using telnet to port 25, it also fail

I notice that McAfee suddenly put a red-border on the tray icon, so the action considered as malicious by McAfee.

And I found this on McAfee log file

1/11/2011 4:58:23 PM Blocked by port blocking rule C:\Windows\system32\telnet.exe Anti-virus Standard Protection:Prevent mass mailing worms from sending mail XXX.XX.XX.XX:25

So it’s clear that McAfee block the port, we need to add our test application to McAfee safe-list. right click on the McAfee tray icon, click on “Virus Scan Console… “. click on Access Protection icon.

Found the causing rule, I edit it to recognize my application

Since it’s a SharePoint based application.. let’s add w3wp.exe

Done! :)

JDK not found on Installing Android SDK

So last night I was installing Android SDK r8 on Windows 7 64bit and using JDK 6 64bit.

The installer gave me this…

But I have installed JDK, so somehow the installer cannot find my JDK path and adding JDK location to my PATH doesn’t solve it.

I’ve googled about it, and some people have this solutions:

  1. Use JDK 32bit
  2. Use Android SDK (.zip) installer

But I don’t want to do those :D I have 64bit environment, so I want to use JDK 64bit (mainly because I am too lazy to re-download those)

And then I found this discussion here that tells me to change some registry key, because the SDK installer somehow is looking for 32bit JDK path.

So I export this key

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\]

and apply some changes so it will be imported to

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\]

(basically just find-and-replace

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\

into

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\

)

Below is the new registry file, I save it to .reg extension and Import it to my registry. Voila! my Android SDK r8 now works!

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft]
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Development Kit]
"CurrentVersion"="1.6"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Development Kit\1.6]
"JavaHome"="C:\\Program Files\\Java\\jdk1.6.0_23"
"MicroVersion"="0"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Development Kit\1.6.0_23]

"JavaHome"="C:\\Program Files\\Java\\jdk1.6.0_23"

"MicroVersion"="0"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Plug-in]

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Plug-in\1.6.0_23]

"JavaHome"="C:\\Program Files\\Java\\jre6"

"UseJava2IExplorer"=dword:00000001

"UseNewJavaPlugin"=dword:00000001

"HideSystemTrayIcon"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment]

"Java6FamilyVersion"="1.6.0_23"

"CurrentVersion"="1.6"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment\1.6]

"JavaHome"="C:\\Program Files\\Java\\jre6"

"RuntimeLib"="C:\\Program Files\\Java\\jre6\\bin\\client\\jvm.dll"

"MicroVersion"="0"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment\1.6.0_23]

"JavaHome"="C:\\Program Files\\Java\\jre6"

"MicroVersion"="0"

"RuntimeLib"="C:\\Program Files\\Java\\jre6\\bin\\client\\jvm.dll"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment\1.6.0_23\MSI]

"JU"="1"

"OEMUPDATE"=""

"MODE"="C"

"JQS"=""

"FROMVERSION"="NA"

"FROMVERSIONFULL"=""

"KERNEL"=""

"PRODUCTVERSION"="6.0.230"

"INSTALLDIR"="C:\\Program Files\\Java\\jre6\\"

"SYSTRAY"="1"

"EULA"="0"

"IEXPLORER"="1"

"MOZILLA"="0"

"JAVAUPDATE"="1"

"AUTOUPDATECHECK"="1"

"AUTOUPDATEDELAY"=""

"ImageCkSum"="2272295289"

"FullVersion"="1.6.0_23-b05"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Web Start]

"CurrentVersion"="1.6.0_23"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Web Start\1.0.1]

"Home"="C:\\Program Files\\Java\\jre6\\bin"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Web Start\1.0.1_02]

"Home"="C:\\Program Files\\Java\\jre6\\bin"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Web Start\1.0.1_03]

"Home"="C:\\Program Files\\Java\\jre6\\bin"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Web Start\1.0.1_04]

"Home"="C:\\Program Files\\Java\\jre6\\bin"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Web Start\1.2]

"Home"="C:\\Program Files\\Java\\jre6\\bin"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Web Start\1.2.0_01]

"Home"="C:\\Program Files\\Java\\jre6\\bin"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Web Start\1.6.0_23]

"Home"="C:\\Program Files\\Java\\jre6\\bin"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Prefs]

Update:
Zukro notified in the comment box that you can try a faster way, I never tried this method but many notified that it works, no matter how weird it may sound :)

I quote Zukro’s comment directly

When there’s a pop up say JDK not found. just press ‘back’ button and then press again ‘next’ button.. look what happened!!!!!!!!!!!!!!

Well, there’s magic in that I presume :P

Next Page »


About The Blog

Trying to share many settings or programming problems that I find during my work-hours :)

The Writer

Erwin Maulana Saputra a Software Engineer who live in Indonesia, in love with this field since junior high-school while creating ASCII or 320x200, 256bit games :) and now somehow making money from web stuff *wink* Used to work at DotSeven and Mitrais and currently freelancing until January 2011
LinkedIn

 

January 2012
M T W T F S S
« Dec    
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Follow

Get every new post delivered to your Inbox.

Join 715 other followers