Sunday, May 22, 2011

Running Classic ASP on IIS 7

As if I'm not discussing enough different unrelated technologies in this blog, today's topic is Microsoft's IIS.

In the past couple of months I suddenly found myself having to write Classic ASP.  I had done such a project in the past, using IIS 5.   However this was IIS 7, and my old sample scripts were not working.

Here were the problems, and their solutions.

1) Classic ASP is not on by default.
You have to enable it yourself:
Control Panel -> Programs and Features -> Turn Windows Features on or off -> IIS -> WWW Services -> App Dev Services -> ASP : check

2) Set to send errors to browser
Problem: Was receiving in my browser window the following (the error itself was probably the one described in number 3 below).
An error occurred on the server when processing the URL. Please contact the system administrator
Solution:
IIS Manager -> ASP -> Debugging Properties -> Send Errors to Browser -> True

3) Must enable parent path expression ".."
Problem: Was receiving in my browser window the following.
Active Server Pages error 'ASP 0131'
Disallowed Parent Path
/NPCS/Transformer/Android/Restaurant/Transform.asp, line 6
The Include file '../../Common/Util.js' cannot contain '..' to indicate the parent directory.
Solution:
IIS Manager -> ASP -> Debugging Properties -> Enable Parent Paths -> True

Hope this helps anyone suffering through the same.

Sunday, May 8, 2011

Excel on Mac: Goodbye VBA, Hello AppleScript

Among my myriad headaches in switching back to the Mac as my primary machine, here is another doozy.

So, I have this cool social media news research job I do in the mornings for a client.  It involves collecting a lot of buzz from various corners of the web, putting them into an Excel file, and having to spit out a report in the form of a text file.  The formatting has to be a certain way so I put together a VBA script (macro) to do this. 

I grab soundbites from from all over the world, so needless to say the text file I output needs to be in UTF-8 format.  Incredibly, this doesn't come naturally to Excel.

In VBA on Windows Excel, there was the ADODB.Stream class from which we can instantiate a file object which allows us to set the encoding using the Charset property, as I do in the example VBA snippet below.

    Set fs = CreateObject("ADODB.Stream")
    fs.Type = 2
    fs.Charset = "utf-8"
    fs.Open
   
    ' Loop thru your cells
    fs.writetext myCell & Chr(10)

    fs.SaveToFile "OutputSheet.txt", 2

Anywhoo, after moving to the Mac I realized to my dismay that ADODB.Stream is not available.  Which makes sense, as it is an Active X.

I spent weeks Googling around for a VBA solution to this problem which, for the hell of it, I'll restate: The ability to output multilingual text from worksheet cells in UTF-8 format to a text file, in Excel on the Mac.  But to no avail.  Am I really the only person in the world struggling with this?  Or do I just suck as a Googler?  Could it be the martinis?

To make a long story short, I took the bold step of ditching VBA and adopted AppleScript as my language of choice on MS Office for the Mac.  When in Rome... and all that.

I have attached an AppleScript file, and a corresponding Excel test file to illustrate.  To test it out you will need to open the Excel file, open the AppleScript file with the AppleScript Editor, and hit Run from the menu (or Cmd-R).

Here is the entire AppleScript.

    tell application "Microsoft Excel"
        activate
       
        set outFile to (path of active workbook)
        set outFile to (outFile & ":OutputUTF8.txt")
        set openFile to open for access file outFile with write permission
        set eof openFile to 0
       
        set title to (name of active workbook) & return
        write title to openFile as «class utf8»
       
        set rowNum to 1
        repeat
            set rowNum to (rowNum + 1)
            set cellVal to (value of cell rowNum of column 1 of active sheet)
           
            if (cellVal = "") then
                exit repeat
            else
                set langStr to (value of cell rowNum of column 1 of active sheet)
                set textStr to (value of cell rowNum of column 2 of active sheet)
                set outStr to langStr & ":" & textStr & return
                write outStr to openFile as «class utf8»
            end if
           
        end repeat
        close access openFile
       
    end tell

Here is the salient line of code that allows me to specify the encoding.  It doesn't seem to be at the file level but at the level of each write statement.
    write outStr to openFile as «class utf8»


Download the AppleScript:
http://www.box.net/shared/rbjxybmuts 


Download the Excel file:
http://www.box.net/shared/bc047mefh2

Thursday, April 28, 2011

Mac Keyboard Operation

One of the biggest things I miss about Windows, since largely transitioning to the Mac, is the lack of emphasis on keyboard operation.  I tend to be more productive the less I need to touch the mouse.  This post is for others who feel the same way.  (We may be a minority among Mac users).

It was particularly frustrating that I could not access the menu bar with keyboard shortcuts.  Well it turns out you can.  Control-F2 is your friend, it highlights the Apple menu at the top-left of your screen.  From there you can use arrow keys to move around the menus.  Better yet, if you can remember more shortcuts to execute the specific functions more power to you.  But at the very least just remember Control-F2.

This too did not come easily at first.  I Googled around and read about Control-F2 but it simply did not work.  I tried all kinds of things, including simultaneously pressing the fn key.

Anyway, it turned out that this (along with a bunch of other shortcuts) was disabled.  I have no idea when and how this happened, as they are default behaviour.  This was determined by taking a look in System Prefs > Keyboard > Keyboard Shortcuts.   Anywhoo, I restored the defaults by pressing (surprise surprise) the button Restore Defaults on that dialogue.

See the Apple Support site: Mac OS X keyboard shortcuts

Sunday, April 24, 2011

Staying on top of Fukushima

With the Fukushima nuclear issue, there is so much information, often conflicting, that it's easy to waste a lot of time following sources, reading articles, watching videos, and coming away none the wiser for it.

I think it may be helpful to have a mental filtering mechanism, whereby we focus on what it is we want to know, and constantly ask ourselves if those particular questions are being addressed.  In my case, at the moment these are the main things I want to know and constantly stay on top of.
  1. What is the status of the repair at this time?  In other words, where are we?
  2. What exactly are the repair crew doing right now, and to what end?  In other words, where are we heading?
  3. What are the radiation levels around the reactors, in and near the evacuation zone, and in Tokyo?
  4. Where is radioactive material and water being disposed, and what effect that is having?
  5. What are the elements in the disposed material?  (Iodine, cesium, strontium, etc.)
  6. How are food products and drinking water, anywhere in Japan, being affected?
  7. How much radiation are certain at-risk groups being exposed to (e.g. school children in Fukushima Prefecture, the repair crew at the reactors, evacuees, etc.)?
This may seem like a pretty mundane list (like, "duh, those things go without saying").  However, given the short attention spans of modern people (including myself) it may be helpful to have it written down and periodically refocused upon.

Also, I may be missing some key aspects here.  Will update if and when I recall them!

Saturday, December 4, 2010

Sync Multiple Google Calendars on iPhone/iPod Touch

I use Google Apps with a custom domain.  I have long found it frustrating that when I set up the account on my iPod Touch it only sets up the main calendar to be sync'd.


I have other calendars in that domain but the option to select or specify them never showed up.


I found that this is, in fact, doable.


On your device (iPhone or iPod Touch) go to:
http://m.google.com


Just follow the instructions from there.

Thursday, March 4, 2010

Nifty little feature in Yahoo navi

This post will only make sense to people living in Japan.

Just found a really nice feature on my cellphone using Yahoo Japan's train navigator 路線情報 (rosen jouhou = route infomation ).  It allows you to enter your stations of departure and arrival, and it suggests a few routes and upcoming train times.   The information is pretty comprehensive.

Of course, comprehensive information is a double-edged sword in that it's difficult to read.  It's enough of a pain in one's own language, let alone Japanese!  I just discovered today that there is a small text link at the top of a suggested route, 停車駅一覧 (teisha eki ichiran = list of stops).  Clicking this gives you a simple top-to-bottom list of the stations your current train will stop at, followed by a list of the stations the subsequent train in your route will stop at, followed by the next list if there is another train in your route, and so on.

One really cool thing I found was a little train icon with blinking red text that says 今ココ! (ima koko! = currently here!), beside the name of the station you're currently at, or will soon stop at.   I'm still not sure if that is given based on the current time (since the route info is specified right down to which train at what time) or on your phone's GPS information.  Next time I've got some serious time on my hands (yeah right!) I'll try an experiment whereby I will just get off at a station and wait for the next train and see if that "currently here" indicator readjusts itself based on where I am, or if it just advances on its own according to the time.  I'm pretty sure it's based on GPS, since it would be inaccurate to tell someone they are some place they are not.

Monday, February 1, 2010

Twitter client questions

TweetDeck
  • I can't find an easy way to add my profile page as a column to the main window.
  • Selecting "Open Link" from right-clicking a link in a displayed Tweet doesn't work.  In the Settings I don't think I saw a place to specify a browser.

Twitter website
Why are re-tweets no longer editable?  Perhaps the concept is more about just spreading their tweet around, than quoting them.  But why don't they provide an interface to support the quoting concept?

Monday, January 18, 2010

Official company rep with two Facebook accounts

Here's a question I just mailed to Facebook. Anyone know the answer?

Dear Facebook,

I have a question on behalf of a client, regarding Facebook Pages (with a capital P).
http://www.facebook.com/help/?ref=pf#/help.php?page=904

Their marketing representative created a Facebook Page for the company, from an initially logged-out state. This results in a business account being created. He then clicked the "Create Your Profile" button at the top of his business account. This resulted in a personal account also being created.

Problem is, he already had his own personal account. From the link below it sounds like an individual is not allowed to have more than one account, and that he should have set up the Facebook Page using the account he had.
http://www.facebook.com/help/?faq=12840

However, the account he had to begin with was his own, as an individual. The one he created next was as an employee in a company. It is not a small company, like a cafe or anything, but a Fortune 500 multinational with tens of thousands of employees.

Would the rule against multiple accounts apply here? If so, is the solution to first delete that new account, then have the company assign the job of managing that Facebook Page to an employee who doesn't have a Facebook account, and doesn't plan to? Are there any other workarounds?

N.B. I assume that the use of separate mail addresses does not legitimize multiple accounts. You explicitly say that it's a violation for a person to have multiple accounts, which is not possible using a single mail address to begin with, so your rule must be referring to cases of multiple accounts using separate mail addresses.

Thanks in advance,
Arka Roy
http://www.facebook.com/arka.roy

Thursday, June 11, 2009

Fighting to make good software

To create a usable piece of software, you have to fight for every fix, every feature, every little accommodation that will get one more person up the curve. There are no shortcuts. Luck is involved, but you don't win by being lucky, it happens because you fought for every inch.
-- Dave Winer


I like this and try to live it.

Wednesday, May 20, 2009

Sales in Japan and the West

I get the impression that in the West, sales is all about closing the deal.

A salesman thinks his job is done when the deal is closed. A lot of Americans, in particular, can be such reality-distorted optimists that in my experience some of them act as if their commission is already in the bank from the point that it merely appears that the deal is going to close. When things fall through (as is increasingly common in these times) they are honestly surprised and shocked and angry.

In Japan, always a few degrees less flaky than America in most aspects, a salesman isn't as defined by the deals he's made and closed, so much as the maintenance of existing relationships. After a deal closes, his job begins in earnest.

Japanese clients seldom start out placing any kind of large order to a supplier or vendor they are using for the first time. They start out placing a small order and carefully observe the level of quality and service they are receiving. They are particularly finicky about the kind of customer support they get from the salesman, how responsive he is, how clear his explanation is, and his approach to dealing with errors or trouble. If they are satisfied they will progressively place larger and larger orders.



Thursday, February 5, 2009

CD/DVD drive keeps disappearing

I keep "losing" my CD/DVD drive on my new Dell.

Happens almost every day but not constantly. CDs don't get mounted, and if I look in My Computer the CD drive icon is gone. In the Device Manager too, the CD ROM device category is gone. Conversely, in the Hard Drives category some mystery item shows up, with a garbage character name.

Restarting seems to fix it. But still, WTF?

Called Dell Support, spoke to a lady named Kudo-san. We did the following two steps.
  • Set the BIOS to default settings.
  • Uninstall the CD drive from the Device Manager. Restarting the PC reinstalls it.
She will call back on Monday to ask if things are OK.

This new Dell is turning out to be quite a hassle.

Internet up and down today

Checked Air Station settings page. Fails on Name Resolution step.

Called Flets helpline. Received guidance as follows.

Create an internet connection as follows:
Internet Properties -> Connections [tab] -> Setup [btn in top right]
Run wizard
[o] Connect to the Internet
[o] Set up my connection manually
[o] Connect using a broadband connection that requires a user name and password
ISP Name: [anything]
User name: guest@flets
Password: guest

If we can connect here it means that the problem is either in the router or with the provider (e.g. Nifty)
http://www.flets/
(Note there's no .com or .jp at the end)

Was able to view it fine, indicating I may need to call Nifty. He gave me the following Nifty numbers.
0120-818-275
03-5753-2373

Called Nifty and was given these new numbers.
0120-322-210
03-5860-7600

Called Nifty but was told it would be a 20 minute wait. Seems to be OK for now so I won't bother.

Monday, February 2, 2009

Excel 2007 crashing

I am running Office 2007, on Windows XP Service Pack 3, brand-new Dell Latitude E6500.

Excel was crashing without fail whenever I tried to close a document with using the close box (top right). I mean Close Window, to close the document, not the one to close Excel itself. It didn't crash when I closed my doc using the Close menu item in the Office Button.

I seem to have resolved it by disabling the COM Add-in "Send to Bluetooth":c:\windows\system32\btsendto_office.dll