Pages

Thursday, November 22, 2012

A list of Mime Types

Following is a list of mime types of most used file types. I wish I had found this earlier
ExtensionMime TypesFile Types
Audio formats
.sndaudio/basicSun/NeXT audio format
.auaudio/basicSun/NeXT audio format
.aiffaudio/x-aiffApple audio format
.aifcaudio/x-aiffApple audio format
.aifaudio/x-aiffApple audio format
.wavaudio/x-wavWindows WAV format
.midaudio/midWindows MIDI format
.rmiaudio/midWindows MIDI format
Image formats
.bmpimage/bmpWindows bitmap format
.gifimage/gifGIF
.iefimage/iefImage Exchange format
.jpgimage/jpegJPEG
.jpeimage/jpegJPEG
.jpegimage/jpegJPEG
.tifimage/tiffTIFF
.tiffimage/tiffTIFF
.rasimage/cmu-rasterCMU raster format
.pngimage/pngPNG
.pnmimage/x-portable-anymapPBM Anymap format
.pbmimage/x-portable-bitmapPBM Pixmap format
.pgmimage/x-portable-graymapPBM Graymap format
.ppmimage/x-portable-pixmapPBM Pixmap format
.rgbimage/x-rgbRGB format
.xbmimage/x-xbitmap7bit-X bitmap
.xpmimage/x-xpixmapX pixmap format
.xwdimage/x-xwindowdumpX window dump (xwd)
.cmximage/x-cmxCorel CMX format
.icoimage/x-iconX-Icon format
Video formats
.mpgvideo/mpegMPEG
.mpevideo/mpegMPEG
.mpegvideo/mpegMPEG
.qtvideo/quicktimeQuickTime
.movvideo/quicktimeQuickTime
.avivideo/aviMS Video for Windows
.movievideo/x-sgi-movieSGImovieplayer
.asfvideo/x-ms-asfMS Active streaming format
.asxvideo/x-ms-asfMS Active streaming format
.vdovideo/x-vdoliveVDOLive script
Message formats
.emlmessage/rfc822Outlook Mail Message
.mhtmessage/rfc822Mail Message
.mhtmlmessage/rfc822Mail Message
Text formats
.htmltext/html8bit-HTML
.htmtext/html8bit-HTML variant
.htmlstext/html8bit-HTML w/ Server-side includes
.shtmltext/html8bit-HTML w/ Server-side includes
.csstext/css8bit-Cascading Style Sheet
.xmltext/xml8bit-XML
.htctext/x-component8bit-HTML component
.ctext/plain7bit-C source
.htext/plain7bit-C headers
.cctext/plain7bit-C++ source
.cpptext/plain7bit-C++ source
.cxxtext/plain7bit-C++ source
.hhtext/plain7bit-C++ headers
.hxxtext/plain7bit-C++ headers
.mtext/plain7bit-Objective-C source
.f90text/plain7bit-Fortran 90 source
.txttext/plain7bit-Plain text
.rtxtext/richtext7bit-MIME Richtext format
.tsvtext/tab-separated-values7bit-Tab-separated values
.etxtext/x-setext7bit-Structure Enhanced Text
.fortext/plain7bit-Fortran
.martext/plain7bit-MACRO
.logtext/plain7bit-logfiles9
.comtext/plain7bit-scripts
.sdmltext/plain7bit-SDML
.listtext/plain7bit-listfiles
.lsttext/plain7bit-listfiles
.deftext/plain7bit-definition files
.conftext/plain7bit-definition files
.cnftext/plain7bit-definition files
.vcftext/x-vcard7bit-VCard
.manifesttext/cache-manifest7bit-manifest file
Compressed file formats
.gz application/x-gzipGNU Zip
.zipapplication/x-zipPKZIP
.tarapplication/x-tar4.3BSD tar
.ustarapplication/x-ustarPOSIX tar
Lotus application formats
.123application/vnd.lotus-1-2-3Lotus 1-2-3 97
.wk4application/vnd.lotus-1-2-3Lotus 1-2-3 97
.wk3application/vnd.lotus-1-2-3Lotus 1-2-3 97
.wk1application/vnd.lotus-1-2-3Lotus 1-2-3 97
.wksapplication/vnd.lotus-1-2-3Lotus 1-2-3 97
.scmapplication/vnd.lotus-screencamLotus ScreenCam Movie
.lwpapplication/vnd.lotus-wordproLotus Freelance 97
.samapplication/vnd.lotus-wordproLotus Freelance 97
.przapplication/vnd.lotus-freelanceLotus Freelance 97
.preapplication/vnd.lotus-freelanceLotus Freelance 97
.impapplication/vnd.lotus-improvLotus Improv
.odtapplication/vnd.oasis.opendocument.textLotus Symphony OpenDocument Text
.odpapplication/vnd.oasis.opendocument.presentationLotus Symphony OpenDocument Presentation
.odsapplication/vnd.oasis.opendocument.spreadsheetLotus Symphony Opendocument Spreadsheet
Microsoft application formats
.docapplication/mswordMicrosoft Word
.dotapplication/mswordMicrosoft Word
.docxapplication/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotxapplication/vnd.openxmlformats-officedocument.wordprocessingml.template
.docmapplication/vnd.ms-word.document.macroEnabled.12
.dotmapplication/vnd.ms-word.template.macroEnabled.12
.pubapplication/x-mspublisherMicrosoft Publisher
.mppapplication/vnd.ms-projectMicrosoft Project
.potapplication/vnd.ms-powerpointMicrosoft Powerpoint
.pptapplication/vnd.ms-powerpointMicrosoft Powerpoint
.ppsapplication/vnd.ms-powerpointMicrosoft Powerpoint
.ppaapplication/vnd.ms-powerpoint
.pptxapplication/vnd.openxmlformats-officedocument.presentationml.presentation
.potxapplication/vnd.openxmlformats-officedocument.presentationml.template
.ppsxapplication/vnd.openxmlformats-officedocument.presentationml.slideshow
.ppamapplication/vnd.ms-powerpoint.addin.macroEnabled.12
.pptmapplication/vnd.ms-powerpoint.presentation.macroEnabled.12
.potmapplication/vnd.ms-powerpoint.presentation.macroEnabled.12
.ppsmapplication/vnd.ms-powerpoint.slideshow.macroEnabled.12
.scdapplication/vnd.ms-scheduleMicrosoft Schedule
.wcmapplication/vnd.ms-worksMicrosoft Works
.wdbapplication/vnd.ms-worksMicrosoft Works
.wpsapplication/vnd.ms-worksMicrosoft Works
.wriapplication/x-mswriteMicrosoft Write
.xlaapplication/vnd.ms-excelMicrosoft Excel
.xlcapplication/vnd.ms-excelMicrosoft Excel
.xlmapplication/vnd.ms-excelMicrosoft Excel
.xlsapplication/vnd.ms-excelMicrosoft Excel
.xltapplication/vnd.ms-excelMicrosoft Excel
.xlwapplication/vnd.ms-excelMicrosoft Excel
.xlsxapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xltxapplication/vnd.openxmlformats-officedocument.spreadsheetml.template
.xlsmapplication/vnd.ms-excel.sheet.macroEnabled.12
.xltmapplication/vnd.ms-excel.template.macroEnabled.12
.xlamapplication/vnd.ms-excel.addin.macroEnabled.12
.xlsbapplication/vnd.ms-excel.sheet.binary.macroEnabled.12
Macromedia formats
.dcrapplication/x-directorShockwave for Director
.dirapplication/x-directorShockwave for Director
.dxrapplication/x-directorShockwave for Director
.swfapplication/x-shockwave-flashShockwave Flash
.splapplication/futuresplashFuture Splash Animator
RealAudio formats
.rmapplication/vnd.rn-realmediaRealPlayer
.rpmaudio/x-pn-realaudio-pluginRealAudio plug-in
.raaudio/x-pn-realaudioRealPlayer
.ramaudio/x-pn-realaudioRealPlayer
.rvvideo/vnd.rn-realvideoRealPlayer
VRML formats
.wrlx-world/x-vrmlVRML
.wrzx-world/x-vrmlVRML
.xafx-world/x-vrmlVRML
.xofx-world/x-vrmlVRML
Other application formats
.cdfapplication/x-cdfChannel file
.323application/h323H.323 Internet Telephony
.jsapplication/x-javascriptJavaScript
.classapplication/octet-streamJava class file
.binapplication/octet-streamUninterpreted binary
.wp5application/wordperfect5.1WordPerfect
.odaapplication/odaOpen Document Architecture
.pdfapplication/pdfAdobe Acrobat
.aiapplication/postscript8bit-Adobe Illustrator
.epsapplication/postscript8bit-Encapulated PostScript
.psapplication/postscript8bit-PostScript
.rtfapplication/x-rtf7bit-RTF
.cshapplication/x-csh7bit-C-shell script
.dviapplication/x-dviTeX DVI
.hdfapplication/x-hdfNCSA HDF data file
.latexapplication/x-latex8bit-LaTeX source
.ncapplication/x-netcdfUnidata netCDF data
.shapplication/x-sh7bit-Shell-script
.tclapplication/x-tcl7bit-TCL-script
.texapplication/x-tex8bit-TeX source
.texiapplication/x-texinfo7bit-Texinfo
.texinfoapplication/x-texinfo7bit-Texinfo
.tapplication/x-troff7bit-Troff
.roffapplication/x-troff7bit-Troff
.trapplication/x-troff7bit-Troff
.manapplication/x-troff-man7bit-Troff with man macros
.meapplication/x-troff-me7bit-Troff with me macros
.msapplication/x-troff-ms7bit-Troff with ms macros
.srcapplication/x-wais-source7bitWAIS source
.bcpioapplication/x-bcpioOld binary CPIO
.cpioapplication/x-cpioPOSIX CPIO
.gtarapplication/x-gtarGnu tar
.sharapplication/x-shar8bit-Shell archive
.sv4cpioapplication/x-sv4cpioSVR4 CPIO
.sv4crcapplication/x-sv4crcSVR4 CPIO with CRC
.icex-conference/x-cooltalkCooltalk
.rrfapplication/x-InstallFromWebInstallFromTheWeb
.wisapplication/x-InstallFromWebInstallFromTheWeb plug-in
.jnlpapplication/x-java-jnlp-fileJava Web Start
.crlapplication/pkix-crlCertificate Revocation List
Hope this helps :)


XSS - Possible measures

I understand that there are some tools like Nessus and Nikto that would help detect such attacks. I have no idea about them though. Just came across these stuffs and hence though of sharing the same.

Following is a shame less copy and paste. Again just wanted to share what I read.


How to Protect Yourself

The primary defenses against XSS are described in the OWASP XSS Prevention Cheat Sheet.
Also, it's crucial that you turn off HTTP TRACE support on all webservers. An attacker can steal cookie data via Javascript even when document.cookie is disabled or not supported on the client. This attack is mounted when a user posts a malicious script to a forum so when another user clicks the link, an asynchronous HTTP Trace call is triggered which collects the user's cookie information from the server, and then sends it over to another malicious server that collects the cookie information so the attacker can mount a session hijack attack. This is easily mitigated by removing support for HTTP TRACE on all webservers.
The OWASP ESAPI project has produced a set of reusable security components in several languages, including validation and escaping routines to prevent parameter tampering and the injection of XSS attacks. In addition, the OWASP WebGoat Project training application has lessons on Cross-Site Scripting and data encoding.

And I guess you can get more ideas on the possible ways by which you can be exploited in http://ha.ckers.org/xss.html.
Hope this helps :)

XSS Cross-site scripting makes me worry


The concept of cross site scripting rang a bell inside me a long time ago. I was kind of wary about it and I even learnt to perform it. Hey I am not a hacker, dont start getting ideas already. Its just that I am curious and feel very happy to experiment stuffs the safe way as most of us prefer to do. Recently I came across a nice post about it in https://www.owasp.org/index.php/Cross-site_Scripting_(XSS).

It was very informative and very useful. I am getting newer ideas even when I am typing this one down. All stuffs posted in the site are basic and clean, but opens up my mind to a lot of potentially harzardous methods, if employed by some one against my sites, would be a massacre.

By my thoughts some of the stuffs that bothers me about how XSS may affect us are

1.
<html>
<body>

<? php
print "Not found: " . urldecode($_SERVER["REQUEST_URI"]);
?>

</body>
</html>

2.
http://testsite.test/<script>alert("TEST");</script>

3.<%...
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from emp where id="+eid);
if (rs != null) {
 rs.next();
 String name = rs.getString("name");
%>

Employee Name: <%= name %>
where name can be an XSS Hack

You can steal user session cookie etc.. and a lot more of such examples can be made

Most of the times when I am into serious mind wrecking program issues, all I would need was one loop hole, however small it may be, and I would fix the issues. I will just get what ever I want out of it.

All I did here was 10 minutes of thinking about what can I do with XSS. And I already got a lot of options.

Worst case, if I could understand a browser, which I definelty can if I spend a couple of months may be, I my self can do idiotic stuffs. So what can a full time hacker be capable of. Hope I dont get a cyber attack. This is scary

Saturday, November 17, 2012

Alert box issues in Sencha Touch 2

I believe there is an issue with the Ext.Msg.alert() dialog in chrome right from the first version of the Sencha Touch. However there were css hacks that have been posted in various forums to handle them.
My point is it only has issues with Chrome and not with safari and I believe mobile devices dont use chrome yet. So I just had this tought running in my head.


Just leave it and get on with your work unless u think, it will keep bothering you. :)

Enable/Disable USB Ports

I had a sudden thought on doing things the hard way. So I just wanted to do something that will be done other than the ordinary way. And thats how I ended up with tampering my USB ports. I really hate simple access restrictions :P
After all its is very useful. I found the following stuff which partially worked.

“HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR”

Right Click “Start” and Click modify
  • To enable USB ports: change the value from “4″ to “3″
  • To disable USB ports: change the Value for “3″ to “4″

I got to admit. I am dumb to have expected this to save me. But atleast I learnt something :)

List of all xtypes in Sencha Touch 2

List of all xtypes
# xtype Class

1 actionsheet Ext.ActionSheet
2 audio Ext.Audio
3 button Ext.Button
4 component Ext.Component
5 container Ext.Container
6 image Ext.Img
7 label Ext.Label
8 loadmask Ext.LoadMask
9 map Ext.Map
10 mask Ext.Mask
11 media Ext.Media
12 panel Ext.Panel
13 segmentedbutton Ext.SegmentedButton
14 sheet Ext.Sheet
15 spacer Ext.Spacer
16 title Ext.Title
17 titlebar Ext.TitleBar
18 toolbar Ext.Toolbar
19 video Ext.Video
20 carousel Ext.carousel.Carousel
21 carouselindicator Ext.carousel.Indicator
22 navigationview Ext.navigation.View
23 datepicker Ext.picker.Date
24 picker Ext.picker.Picker
25 pickerslot Ext.picker.Slot
26 slider Ext.slider.Slider
27 thumb Ext.slider.Thumb
28 tabbar Ext.tab.Bar
29 tabpanel Ext.tab.Panel
30 tab Ext.tab.Tab
31 viewport Ext.viewport.Default

DataView Components
---------------------------------------------
32 dataview Ext.dataview.DataView
33 list Ext.dataview.List
34 listitemheader Ext.dataview.ListItemHeader
35 nestedlist Ext.dataview.NestedList
36 dataitem Ext.dataview.component.DataItem
37
Form Components
---------------------------------------------
38 checkboxfield Ext.field.Checkbox
39 datepickerfield Ext.field.DatePicker
40 emailfield Ext.field.Email
41 field Ext.field.Field
42 hiddenfield Ext.field.Hidden
43 input Ext.field.Input
44 numberfield Ext.field.Number
45 passwordfield Ext.field.Password
46 radiofield Ext.field.Radio
47 searchfield Ext.field.Search
48 selectfield Ext.field.Select
49 sliderfield Ext.field.Slider
50 spinnerfield Ext.field.Spinner
51 textfield Ext.field.Text
52 textareafield Ext.field.TextArea
53 textareainput Ext.field.TextAreaInput
54 togglefield Ext.field.Toggle
55 urlfield Ext.field.Url
56 fieldset Ext.form.FieldSet
57 formpanel Ext.form.Panel

Problem downloading Microsoft Powerpoint 2007 document from domino server 8.5

A while ago I was presented with a seemingly trival and strange issue. The issue stated something like, a user was able to download a .pptx file from a domino website and when opened it is always blank, were as other users were able to download the .pptx file and view its contents with out issues. I thought to my self, am I an astrologer and have I sinned enough to be tested with such an issue that if I would like to get serious about it, I might laugh my self to de***.

Yes it was funny, and I did all sorts of checking like is the user trying to preview the file on lotus notes which I knew would fail or does the user's machine really have Microsoft office installed and many such tests came back negative. I knew I am approaching/at the verge of the dangerous scenario - "Laughing myself to de***", i.e. get serious.

Know what?, I did really found something serious. Once again I am humbly reminded that one can never know everything.

It is a kind of a well known bug which was well documented as well. A rare phenominan with IBM lol. :P
http://www-01.ibm.com/support/docview.wss?uid=swg21412063

It helped me find something that I was looking for a long time, a list of all the commonly used mime type. Wonderful:O..

The abstract of what I understood from the documentation is as follows
In some cases, the browser identifies the attachment as a zip file.

Symptom : The user may be prompted to download the file locally, even though the file type is associated with the correct application in their browser.

Cause : This issue occurs because the MIME types for Microsoft Office 2007 formats are not listed in the Web Server metabase on the Domino server (httpd.cnf).

Currently, when a HTTP request is made for an unknown file type, the server returns a Content-Type of "application/octet-stream" in the response, instead of the appropriate Office 2007 MIME type.

Resolving the problem
This issue is now fixed in Lotus Notes and Domino 8.5.1 FP4 and 8.5.2.

Fix details: SPR# JBEN7WRHM7

Refer to the Upgrade Central site for details on upgrading Notes/Domino.

To resolve the issue in a previous release, IBM recommends performing the following actions to add the Office 2007 MIME types to your current Web Server metabase (httpd.cnf):

1) Shutdown the HTTP process by issuing the following command on the Domino server console: tell http quit

2) Open the httpd.cnf file (located in the Domino Data directory) using a text editor, such as Notepad. In order to edit this type of file on most operating systems, it will be necessary to launch the editor first and then open using the file menu from within the editor.

3) Copy the Office 2007 MIME types below and paste them into the httpd.cnf file (Note: When inserted, each line below should begin with either the hash symbol "#" or "AddType")


#
# Microsoft Office 2007 formats
#
AddType .docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
AddType .dotx application/vnd.openxmlformats-officedocument.wordprocessingml.template
AddType .xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
AddType .xltx application/vnd.openxmlformats-officedocument.spreadsheetml.template
AddType .pptx application/vnd.openxmlformats-officedocument.presentationml.presentation
AddType .potx application/vnd.openxmlformats-officedocument.presentationml.template
AddType .ppsx application/vnd.openxmlformats-officedocument.presentationml.slideshow

Note: The above list only includes the most commonly used Office 2007 MIME types. For a complete list of the document types addressed by SPR # JBEN7WRHM7 (including other extensions that may be needed in your environment), please refer to the following Microsoft documentation:
http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/05/08/office-2007-open-xml-mime-types.aspx

4) Restart the HTTP task by issuing the following command on the Domino server console: load http

Friday, July 20, 2012

text-transform in css

We knew it all along and yet, we forget their existence -- it must have been quoted by some big person or else let me own the patent for it. I always have issues with this

Now I just rediscovered it with the text-transform property in CSS. oh pls, God Bless Me

This does relatively reasonable job which is very appreciable. I find many instances in which I could have used it in the past and yet, I never did.

Following is a simple illustration of how to use this and what it does

I am applying the following style on the forth comming statements which are typically html paragragh tags

p.uppercase {text-transform:uppercase;}
p.lowercase {text-transform:lowercase;}
p.capitalize {text-transform:capitalize;}



This is some text.The class of this para is "uppercase"

This is some text..The class of this para is "lowercase"

This is some text..The class of this para is "capitalize"

!important in css

It reads like not important, but it means totally the other way. I got curious when I first encountered this property in CSS. It has really took a long time for me to discover this property.

After going through the details of this property, in order to make my understanding simler, it is some what like the final keyword in Java. Dont take my word for granted, its just a persection. I am just trying to put things together to explain the stuff.

Following is a simple explanation of the same

Guess that I'm using the following code to style my paragraphs in my document
p {color:#0000ff}  --> should apply blue color to my paragraphs
p {color:#000000}--> should apply black color to my paragraphs and will override my previous blue style for para tags

Eventually all my paragraphs will be black in color

To ensure that certain things dont get overrided, let me say i do the following (!important atlast),
p {color:#0000ff !important;}
p {color:#000000;}


This is my target paragraph. Note that I am blue in color

This is an unexpected property that I least expected to find in CSS :).
But be warned, this is not java, so let me say the following, as far as I have tested, the !important tag is a bit tricky and is jerking around a bit as well. Its because, say I do the following

p {color:#ff0000;}
  some paras
p {color:#0000ff !important;}
  some paras
p {color:#000000;}
  some paras

Now all the "some paras" that I am refering to will be in blue color. So no matter where you declare !important property for styles, it gets applied to entire document. Thats ridiculous and will definetely be useful some times. But I am scared of it.

Again Diamond cuts Diamond and !important overrides !important - Wow howz my moral of the story (cool down plz)

p {color:#0000ff !important;}
p {color:#00ff00 !important;}

This will ensure that all your para tags are green in color. Hope you get the picutre, if not dont expect me to explain further, try it out :).

Friday, May 11, 2012

Forcing browser compatibility in IE

I happened to stumble upon this concept long back and due to some reason which I don't remember, I lost interest in it. After a long time when I checked my archives, I came across this concept again and thought its time I put it to good use. I as most developers do, believe, IE is the browser that is a gift for the developers. Its so buggy that you can forget why your wife threw a stick at you the same morning :).

And to add to the recipe we have different versions of IE which again are different from each other in behavior. Or at least that what I believe as far as I have worked with it. Stories apart, I will come to the point,

I just found some one talking about how to force IE8 to work like IE7 when working with XPages.That article was exhaustive, and I have lost track of it. But I do have parts of it documented there and there for my understanding.

All you got to do is put the following code in beforeRenderResponse event: 
// first option uses compatibility mode, second option too but stronger
// X-UA-Compatible: IE=7
// X-UA-Compatible: IE=EmulateIE7
if (context.getUserAgent().isIE(8, 8)) {
  var exCon = facesContext.getExternalContext();
  var response = exCon.getResponse();
  response.setHeader("X-UA-Compatible", "IE=EmulateIE7");
}

Understanding Compatibility View

Before displaying a standards-mode Web page, Internet Explorer 8 checks to see if the domain name of the Web site appears in the Compatibility View List. If so, the site is displayed using Compatibility View. If not, and the page contains no other direction, Internet Explorer 8 displays the page in Internet Explorer 8 Standards mode.
When a standards-based Web page is displayed in Compatibility View, the following changes occur.
Pages are displayed in IE7 mode rather than IE8 mode.
In the user-agent string, the browser identifies itself as MSIE 7.0 instead of MSIE 8.0.
Conditional comments and version vectors recognize the browser as Internet Explorer 7, rather than Internet Explorer 8.
These changes help ensure that users can still use Web sites that do not fully support the features of Internet Explorer 8.
Please note that the X-UA-COMPATIBLE header has greater precedence than Compatibility View. If a Web site is on the Compatibility View List and a page on that site includes an X-UA-COMPATIBLE header telling Internet Explorer 8 to display a page in IE8 mode, the page is displayed in Internet Explorer 8 Standards mode. This allows Web developers to support Internet Explorer 8 Standards mode on an incremental basis

Javascript to identify the compatibility mode


engine = null;
if (window.navigator.appName == "Microsoft Internet Explorer")
{
   // This is an IE browser. What mode is the engine in?
   if (document.documentMode) // IE8
      engine = document.documentMode;
   else // IE 5-7
   {
      engine = 5; // Assume quirks mode unless proven otherwise.
      if (document.compatMode)
      {
         if (document.compatMode == "CSS1Compat")
            engine = 7; // standards mode
      }
   }
   // The engine variable now contains the document compatibility mode.
}


To specify a document mode for your Web pages, use the META element to include an X-UA-Compatible http-eqiv
header in your Web page. The following example specifies EmulateIE7 mode compatibility.
    
   
      My Web Page</< span>title></div><div>      <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /></div><div>   </< span>head></div><div>   <body></div><div>      <p>Content goes here.</< span>p></div><div>   </< span>body></div><div></< span>html></div><div><br></div><div>    </div><div><br></div><div>The content attribute specifies the mode for the page; for example, to mimic Internet Explorer 7 beha vior, specify IE=EmulateIE7.</div><div>Likewise, specify IE=5, IE=7, or IE=8 to select one of those compatibility modes. You can also specify IE=edge to tell Internet Explorer 8 to use the</div><div>highest mode available. </div><div><br></div></div>

Saturday, May 5, 2012

Google Search - Context Menu Addin For Internet Explorer



Create a html filed named say “GoogleSearch.htm” in a location say “D:\Lotus Notes\tools\MyIEPlugins”
Now code the html file with the following code and save it
<script language="JavaScript">
  var parentwin = external.menuArguments;
  var doc = parentwin.document;
  var sel = doc.selection;
  var rng = sel.createRange();
  var str = new String(rng.text);

  if(0 < str.length)
  {
    window.open("https://www.google.co.in/#hl=en&q="
      + str, "_blank");
  }
</script>
Now open your registry editor and traverse to the following key “HKCU\software\microsoft\Internet Explorer\MenuExt”
Now create a key named “&Google Search”
  
Now on the right side change the (Default) attribute’s value to the location of your html file that we created in the beginning
Now create a new DWord named “Contexts” and specify its value as 0x10.
Now start or restart your internet explorer.
Open a web page or your choice. Select some text and right click on it. Voila you will find some thing like the following

This will bring up a new window with the google search for the selected text as illustrated by the following screen shot


Likewise you can do it for Live Search as well. All you got to do is tweak your url a bit
"http://search.live.com/results.aspx?q="      + str
Hope this helps J

Friday, April 20, 2012

Overloading functions in Lotusscript

At times I find it difficult with out the ability to over load functions in lotusscript. The following way just helped me do it. Since I dont do this often its like new to me every time I do this :)

Sub new(key As Variant)
     Select Case Typename(key)
     Case "STRING":
           your code for this type
     Case "INTEGER"

          your code for this type
     Case "NOTESDOCUMENT"
          your code for this type
     Case Else
         your code for this
End Select
We have to be wary about the usage of such functions though. One stuff that I found was Typename(Nothing) is object. I least expected that.

I dont think using overloaded functions in lotusscript is a time saver. As a matter of fact I found this and just dropped the idea of using it after trying to use it :P. Cos man..., it was a head ache to me. I couldn't have a dynamic parameter list like how we can do in javascript and definetly can't match the way we do it in java or C or C++ anyway.

So I felt crippled when using this idea. However, this must help in some scenarios. Hope you find this in one such case :)

Thursday, April 12, 2012

Issues adding document items dynamically through lotusscript - "Field is too large (32k) or View's column & selection formulas are too large"

I had a very tough time completing a particular job which involved huge amount of document data through lotusscript. I had to debug through thousands of lines of code which were scattered across multiple agents and script libraries. Honestly I got screwed. Not because of the volume of code I was going through but because of the limitation of the notes documents that wont accept summary data beyond a certain limit - roughly around 60000+ bytes, may be 64 K.

I encountered this because, I wanted to print debug statements to understand the flow and was going though a lot of problems in getting them accumulated in a single document. I tried splitting the data between sever different fields, appendItemValue, richtext etc.. But none seemed to help me as desired. It was then that I identified the forgotten concept of the summary and non summary items. My Research towards this concept gave me an answer with in seconds. I found the following in the ibm site.(lost track of the url :< )

The idea is to save the data to the document and make the items as non summary items. That was the simple answer to what I thought was a so very complicated problem
"Field is too large (32k) or View's column & selection formulas are too large"

Or, in a LotusScript agent the following error message corresponding to error code 4000 occurs:

"Notes error: Field is too large (32k) or View's column & selection formulas are too large"



description of this fix:

Notes/Domino 6.x and later have the following limits regarding Summary fields: 32k per field, 64k per document. Relative to memos: The limit for sending to individual names and locally expanded groups is 15k. In addition, the above restrictions still apply as regards other fields in the memo.

Except for rich text fields, fields are typically flagged as "summary" by default; you can change this with the NotesItem.IsSummary property, but it will be reset to the default if the document is edited using a form that contains that field. Non-text fields (numbers, date-times) are also summary fields, so these limits apply to them also.

Hope this helps :)

Tuesday, February 21, 2012

Microsoft Outlook Collection of Constants

Ever seen a vb code which says something like

"Set MyItem = MyOlApp.CreateItem(olAppointmentItem)" or "MyRequiredAttendee.Type = olRequired"

and had a tough time figuring out what those constants starting with ol stand for when implementing them in your technology. I had my share of head ache to find the nice simple solution for it

http://msdn.microsoft.com/en-us/library/aa210886(v=office.11).aspx

Go through the site and you may find it useful. Microsoft guys can atleast give a flow chart showing the relations between the various objects in the Object Model documentation. Atleast more developers can understand em and support microsoft.

Thanks to the awesome work by John Coolidge. You would definitely be impressed. Take a look at the his work

A sample Calendar file

Following is a content of a fully functional calendar file


BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
PRODID:-//ORG//LN//LS
BEGIN:VEVENT
SUMMARY:My Subject!
DESCRIPTION:My Description content
UID:D70C88D5-E5A1-48EC-84A4-D05DBD5CD8F6-99
DTSTART:20120218T160000
DTEND:20120218T163000
LOCATION:My Location
END:VEVENT
END:VCALENDAR

This is a really nice concept that I liked very much. If you search for info on "ical" files you will get to browse nice sweet pages including the wikepedia which has nice demonstrations/explations on what this does.

I had a scenario where I had to tinker people's outlook calendar from lotus notes. Using ical files were a really nice option. Atleast I did not find another nicer solution. Once these files are sent to users with the necessary values in it, you can have users open them and save them to their calendars.

A nice way like how xml shall mediate between different platforms. ical - I believe this will work with all major calendars. I know it works for Lotus Notes and Outlook. Yet to test on other web-based stuffs like Google Calendars. Let me know if you test them.

:)

Friday, February 17, 2012

Creating simple downloadable text file using lotusscript

Create an agent with the following Lotusscript code in it.

Print "Content-Type:application/octet-stream"

Print "Content-Disposition: Attachment;filename=""sampleDownloadAbleFile.txt"""
Print "this text is from the server"
Print "this has not been saved any where in the server"

Save the agent preview it on the web. You will be able to download a text file



Hope this helps :)

Tuesday, January 3, 2012

Bugs: "Element or Navigator is invalid" error when using NotesRichTextNavigator


-->
Let me dive straight into the point.  Assume that I have few document say five documents with a rich text item in each one of it and all of them are created using same form. So don’t bother about minor variations like missing document items etc… To make things simple let me say that these five documents are design equivalent.

Now let me say that I don’t put any values inside the richtext field in 3 document alone. So on the contrary I have values on all the 4 remaining documents.


Now assume that I have the following sort of code in an agent


On Error Goto errhandler
                …….’some code               
                Set dc=db.UnprocessedDocuments
                Set doc=dc.GetFirstDocument
                Set richStyle = session.CreateRichTextStyle
                richStyle.PassThruHTML = true
                                
                While Not doc Is Nothing
                                itr=itr+1
                               
                                Set richText=doc.GetFirstItem("myRtField")
                                Set rtnav=richText.CreateNavigator
                                                               
                                Call rtnav.FindFirstElement(RTELEM_TYPE_TEXTRUN)
                                Call richText.BeginInsert(rtNav)                   ---------------------à>> when itr=3 this line will error out with error number 4506
                                Call richText.AppendStyle(richStyle)
                                'Call rtnav.GetLastElement(RTELEM_TYPE_TEXTRUN )
                                Call richText.EndInsert
                                Call richText.Update
                                'Call doc.Save(True, False)
                                Set richText=Nothing
                                Set rtnav=Nothing
                                Set doc=dc.GetNextDocument(doc)
                                Print Cstr(itr) & " doc processed"
                Wend
                Exit Sub
errHandler:
                If Err=4506 Then Goto skiploop
                Print Error & " *** occured on line *** " & Cstr(Erl) &"*** with error number *** " & Cstr(Err)
                Exit Sub




As you may understand the since the rich text field in the third document is empty an error with number 4506 will occur.


You can say that one can handle this scenario by using some thing like “IF rtnav Is Nothing Then goto SkipLoop” etc… but it did not work so I managed to loop the control back in my error handler section.


And guess what, the object rtnav becomes unusable. I simply does not set any right values the next time the loop executes and does not accept any values. And so the following error occurs




And alas… the code breaks. Complier does not even make it to the error handler.


So sad L


I think I know a work around for that. So stay tuned