Showing posts with label Microsoft. Show all posts
Showing posts with label Microsoft. Show all posts

28 March 2018

How to implement custom BotStorage class for Microsoft BotFramework

Since launch, the MS BotFramework has been changing very rapidly. So rapidly, in fact, that I recently gave up trying to keep up with my handrolled Python, and embraced (sigh) their NodeJS SDK. At least now I won't have to worry when they break stuff, right ?
One of the most recent BF changes is the deprecation and eventual removal of the default persistence API. You are now supposed to either use one of the pre-built Azure services (paying $$), or provide your own implementation. In pure Microsoft style, they state that rolling your own is very easy... but never actually provide a sample or even tell you which interface should be implemented.
I had to scavenge through their code to figure it out (at least they opensource their stuff these days), but I thought I'd save others a bit of aggravation, and here it is:
var MyBotStorage = (function () {
    
    // optional constructor
    function MyBotStorage(options) {
        this.options = options;
    }
    
    MyBotStorage.prototype.getData = function (iBotStorageContext, 
                                                callback){
        // IBotStorageData interface
        var data = {
            userData: {},
            conversationData: {},
            privateConversationData: {}
        };
        // the callback MUST be invoked
        // signature: callback(Error, iBotStorageData )
        callback(null, data);
    }
    
    MyBotStorage.prototype.saveData = function (iBotStorageContext, 
                                                iBotStorageData, 
                                                errorCallback){
        // the callback MUST be invoked
        errorCallback(null);
    }
    
    return MyBotStorage;
}());

var botStorage = new MyBotStorage({});

var bot = new builder.UniversalBot(connector, function (session) {
            // your bot code here
    }).set('storage', botStorage); 
As you can see, it is indeed trivial, once you know how. It's sad that MS somehow, in the haste of deprecating their older interfaces, couldn't find the time to put this sample in their otherwise-extensive documentation. I suspect the fact that Azure is not mentioned anywhere might have something to do with it, but I'm sure I'm just assuming excessive malice and there is a perfectly-plausible explanation that does not involve greed. Or is there?

26 March 2018

Appstores need a Trial Mode

I've been looking for a while for a Windows-native Twitter client that could sync with my other non-Windows devices (aka "supporting TweetMarker"). I've found one that claims to do that, Tweet It!, but there is a problem: it costs £3.5 upfront. That's a relatively high amount of money to throw down a well hoping that my wish will come true. However, because this feature is so rare, if it worked I'd be happy to pay three times as much, no questions asked. I just have no way to find out.

Appstores need a simple Trial Mode. All the current hacks (In-App-Purchases, subscriptions, refunds etc) are just that, clumsy workarounds to this glaring omission, which is why app prices are so squeezed down - to the chagrin of indie developers. Trial Mode would also bring huge collateral benefits like reducing reliance on SaaS services (something that Microsoft in particular should relish) and creating viable alternatives to the free-to-play bubble that has turned online gaming into a socially-accepted form of gambling addiction.

I doubt Apple will ever introduce Trial Mode - they are the dominant player and have little incentive to change the rules; and Android is a far west where the Play Store is almost irrelevant. But Microsoft should experiment with something like this, while the Windows Store is still young and evolving. Both developers and users would love it, they have been asking for something like this for years.

18 May 2017

How to get Ctrl-arrow shortcuts working in RDP sessions on macOS / OSX

It looks like recent versions of the official Microsoft Remote Desktop client are a bit shy when it comes to sending CTRL to the remote Windows session. I discovered this because I use Ctrl-Arrow very often to move from word to word, and it just stopped working in RDP.

The solution is to make sure you don't have any overlapping OSX shortcut - typically, CTRL is used for Mission Control actions. Just disable them from System Preferences -> Keyboard -> Shortcuts -> Mission Control and you should be good to go. Any recent Apple keyboard will have real keys dedicated to those actions anyway.

(Come on Microsoft, show some guts - have an option to bypass Mac shortcuts entirely!)

08 July 2016

How to (not) handle OneDrive/Sharepoint "Sync Now" on Mac OSX

UPDATE October 2017: This post is obsolete, the OneDrive client for Mac now handles sync correctly. If you still have issues, file a bug report.

This bugged me for a bit and finally got around (almost) fixing it yesterday, so I thought I'd record it for posterity.

Microsoft Office365 will usually include a Sharepoint implementation of some sort. Sharepoint now integrates with OneDrive (aka "Microsoft Dropbox")... on Windows. On Mac, the current state of play is as follows:
  • You should get the free OneDrive app from Mac App Store. If you have previous beta versions or anything like that (which never worked particularly well), uninstall them before installing this.
  • Once you start and connect OneDrive to your Office365 subscription, your personal files will automatically sync to the OneDrive folder. It seems to work reasonably well.
  • However, files shared by others to you will not sync. The feature is just not implemented yet.
  • If you access Sharepoint or OneDrive from the website and click on the Sync Now button, the website will generate a link that looks like this: grvopen://http-etc-etc and pass it to the browser. By default this grvopen protocol will be associated with OneDrive and do nothing, because (guess what?) the feature is not implemented yet.
  • However, if you have a virtual machine with Windows and Office installed, there is a chance that the link will be passed to the Sharepoint client running on that machine. You probably don't want that: it will likely break things once the feature lands in OneDrive for Mac. So you can follow these instructions for VmWare Fusion to stop it from happening. Make sure to click on Clean Up Applications after deselecting Open your Mac files and web links using Windows applications. (Other virtualization products will have different ways of doing this, check your docs.)
I can see a forced approach where you configure OneDrive in your virtualized Office to use the same folder that OneDrive for Mac is using, but I expect this would bring up all sorts of issues. These sync programs do a lot of dirty tricks with file metadata and I'd rather not risk precious company files. I guess I'll just wait for MS to bring feature parity to OSX, and use the website in the meantime (which is actually slowly improving as well).

18 June 2016

Python SDK for Azure Basic Tutorial

As Spider-Man would say, from great enterprise comes great complexity. Microsoft cloud services are very, very enterprisey; which means they're also absurdly overcomplicated. One can probably spend most of his 30-day trial simply wandering around their dozens of different "portals" and "account management" screens. So here's a simple tutorial on going from zero to spinning up a VM with the Python SDK. (This is a work in progress, but hopefully it saves you the headaches I got).
  1. Sign up for an Azure free trial. You'll need a phone and a credit card, because MS requires verification like pr0n sites of yore.
  2. WAIT! DON'T DO ANYTHING! After the signup is successful and you're sent to the dashboard, chances are that your account is not actually fully formed, and you might be getting a lot of prompts about signing up for a Pay As You Go subscription. Wait 10 to 15 minutes. Grab a coffee; check Hacker News; live the enterprise life.
  3. close your browser and go back to the portal.
  4. Go to your active directory
  5. Create a Global Admin user by clicking on ADD USER (not the giant NEW, that would be too easy!). Write down the temporary password. (Note: I've no idea whether it has to be a global admin, but we're just trying to keep things simple here.)
  6. Now you have to associate the user to your Azure subscription, because you created it, it's in your AD, but obviously it's completely unrelated to your resources. Enterprise life! Go back to Azure portal, click on Subscriptions. NOTE DOWN YOUR SUBSCRIPTION ID, you'll need it later.
  7. Click on the subscription then Settings
  8. Click on Users (bottom right)
  9. Click on Add, select the Owner role, then add the new user to it. (Note: again, Owner is probably a bit too powerful, but we're trying to keep things simple.) Reference here.
  10. Now open a Private Window in your browser, or sign out of your account, because you have to log on the same portal as the new user.
  11. After logging on, you'll be forced to change the password. Done? Good; log out, close the window, the web-based ordeal is officially over.
  12. Create and activate a virtualenv (this procedure will differ depending on your platform/setup, reference here):
    mkdir azure_test && cd azure_test
    pyvenv-3.5 env
    source env/bin/activate
    pip install --upgrade pip   # this is optional but good practice
    
  13. install the Azure sdk
    pip install --pre azure
  14. Launch python and get cracking:
    sub_id = 'your-sub-id'  # you should have got this earlier, it's visible in "Subscriptions"
    # authentication reference at
    # http://azure-sdk-for-python.readthedocs.io/en/latest/resourcemanagementauthentication.html#using-ad-user-password
    from azure.common.credentials import UserPassCredentials
    credentials = UserPassCredentials('yourADuser@youraccount.onmicrosoft.com','youropassword')
    from azure.mgmt.resource.resources import ResourceManagementClient
    resource_client = ResourceManagementClient(credentials, sub_id)
    
    # one-off registrations, supposedly you won't need them next time
    resource_client.providers.register('Microsoft.Compute')
    resource_client.providers.register('Microsoft.Network')
    resource_client.providers.register('Microsoft.Storage')
    
    # create the clients
    from azure.mgmt.compute import ComputeManagementClient
    compute_client = ComputeManagementClient(credentials, sub_id)
    from azure.mgmt.network import NetworkManagementClient
    network_client = NetworkManagementClient(credentials, sub_id)
    from azure.mgmt.storage import StorageManagementClient
    storage_client = StorageManagementClient(credentials, sub_id)
    
  15. Now follow the code to create a VM here, skipping the 4 lines that define resource_client, storage_client etc, because you already have them.

18 May 2013

Fully disable User Access Control (UAC) via Group Policy (GPO)

I'm sure Windows' User Access Control is a wonderful idea and dramatically improved security levels of this once-beleaugured operating system. Unfortunately, most COM/DCOM-based software was written before 2007 and simply doesn't like it (cough*Oracle EPM Financial Management*cough); 6 years later, we're still forced to disable it in many cases.

This is usually achieved through Active Directory policies. Most documents and guides will tell you that you just need to turn off three policies in Windows 2008, under Computer Configuration -> Policies -> Windows Settings -> Security Settings -> Local Policies -> Security Options:


  • User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode (set to Elevate without prompting)
  • User Account Control: Detect application installations and prompt for elevation (set to Disabled)
  • User Account Control: Run all administrators in Admin Approval Mode (set to Disabled)

Unfortunately, this will bring that lovely UAC slider all the way down, but will still results in a weird behaviour where local administrators have most rights but not all of them. The typical test I perform is to open a regular Command Prompt and try to navigate to C:\Windows\SysWOW64\Config - if I get an Access Denied message, then UAC is still lurking in the shadows.

The extra kick we need is, from my tests, this:


  • User Account Control: Only elevate UIAccess applications that are installed in secure locations (set to Disabled)

As explained on the technet site, this policy refuses to elevate applications that don't live in "secure locations" (i.e. %windir% or Program Files). It makes sense that such a policy would affect third-party software dropping executables in their own home folders (cough*lots of Java stuff*cough), but why cmd.exe? No idea, but there you are. For all intents and purposes, UAC is completely turned off only when all these four policies are disabled; miss one of them, and things will get weird. 

I wish Microsoft had just given us a big button that said Behave like Windows 2003, but I guess it wouldn't have sold new manuals and certification lessons.

28 December 2011

The Microsoft Touch Mouse Needs Better Software

I've recently picked up a Microsoft Touch Mouse in post-Christmas sales with a huge discount, and I thought I'd describe my experience.

The mouse itself is a nice (Apple-inspired) concept: a multitouch sensor replacing good ol' mouse buttons and wheel; after enduring several mice with hardware defects, having one (almost) without any mechanical moving parts feels reassuring.

Actual usage is slightly less natural than you'd expect. Scrolling is probably the trickiest activity, since in practice it now depends on friction between your finger and the mouse surface, and you have no mechanical feedback.
Right-clicking is also a bit weird, if you're in the habit of resting your index finger while doing it: the sensor detects "rested index + clicking middle" as a different (void) activity, not as a right-click, so you'll need to actually lift the index as you click with the middle finger, or move all the way and right-click with your index finger.

I believe the two items above are to be blamed for 99% of bad reviews; they break long-standing muscle memory for power users, who are heavy on their scrolling and right-clicking, and give a feel that the mouse will randomly decide what to do rather than respond to actual gestures.

The scrolling speed can be adjusted in the driver properties, reducing awkwardness, but there is no tweak for the right-click problem. And this is where Microsoft really failed: there is no way to easily customize the device.

The driver defines a limited set of gestures that you can turn on or off, but you cannot override their assignment (i.e. what they actually do) nor create new ones. Some of these gestures are quite nice: three-finger swipes will bring up the Windows equivalent of Apple's Expose'; two-finger swipes work like Win+Arrows (probably the best feature in the Windows 7 Aero desktop), thumb swipes perform Back/Forward in a very natural way. Unfortunately there is a long list of other gestures that one would really need (open/close browser tabs, a middle-click replacement, window resizing, etc etc) and there is no way to add them; worse, there is no way to simply remap existing gestures to new commands, which should be dead easy; one can only remap left and right click, which nobody will ever do.

Apparently there is a C#/C++ SDK for the sensor (32bit and 64bit), and some students have already come up with nice improvements (like the one shown in this embedded video), but it's a shame that Microsoft, a software company first and foremost,  let down this lovely piece of hardware so badly by not shipping a proper gesture editor or mapper. I really do hope they'll release updated drivers with more features in the near future.

19 September 2009

oops I did it again

Designed a very simple website. Looks wonderful in Firefox 3, Opera 9, Chrome 4, Safari 3, Konqueror 3. Yay, ready to upload then! Wait, I think I forgot something... oh yes, Internet Explorer! I'm working on Linux after all. Let's see... IE6: looks shit but who cares, nobody uses it anymore. IE7: looks marginally less shit, but still shit. Damn. Back to the css... this is why I left webplumbing.

29 October 2007

Empowering programs

I remember being impressed, more than three years ago, by this post by Joel Spolsky on Microsoft's "Empowering" partner program. It looked like Microsoft was (for once) doing the right thing to help the little guy.

Now that I'm starting to explore the possibilities of setting up shop by myself, I'm looking around for similar programs; I don't plan to use MS stuff, so Empower is simply not for me. I intend to use mainly free open source tools at the moment, but chances are that sooner or later I'll have to pay my tribute to some Big Company, so it might be good to get some info on ways to save a few bucks or get good tech tips.

My biz plan involves J2ME apps, Python (for django, so web stuff) and the inevitable database; it might (or might not) include some very small (and collateral) piece of desktop software sometime in the future.  A proper custom-built server will probably enter the equation very soon, and sooner or later I'll need new hardware anyway. So, what's out there that might interest me?

First I checked the Sun Partner Advantage program. It seems to consist mainly in hardware discounts (fair enough, they are first of all a hardware company... aren't they?); the Mobile initiative is limited to big players, not everyday members (bad, bad move). Not sure is worth the hassle, as their gear is really uber-priced and I couldn't ever make them my preferred hardware supplier. I might be wrong though; the Sun website is a perfect reflection of the company: huge, disparate, often byzantine, full of hidden gems here and there as well as boatloads of useless marketing spiels... I might have missed the great bits, who knows.

I've also looked into the Trolltech partner program, for the (inevitable) little desktop bits. As much as I love the technology, anything technically significant comes with the $1500/yr option; overall, it feels more like a commercial relationship than technical partnership. Probably too pricey for what I need.

Uhm, what else? Where's the killer partner for new mobile/web startups?

09 September 2007

See you next year!

PyConUK is now done! Thanks to all the amazing people at Python West Midlands and Python London! Also to all the sponsors (Revolver, Microsoft, Trolltech, and all the others -- including Ravenbrook!)

The breaking news are that not only PyconUK will happen next year too, but John Pinner wants to submit a bid for EuroPython 2008/2009! woot woot! John, you are full of win.

Oh, sorry if I didn't liveblog the last few talks, they'll be posted to the pyconuk site anyway. The presenter for the (impressive) gSculpt project won the xBox (bad! it lowers productivity!) and Mr. Etienne from Belgium was the lucky N800 winner! (and btw his ideas are very worth checking out, if you are a medium-small python shop interested in public money you should check it out and consider proposing to the EU commission or something).

08 September 2007

Liveblogging Pycon UK 2007 - first notes

Lots of people, fantastic atmosphere, lots of kudos to the Birmingham user group. "Msdn magazine" in the goodie bag sounds like MS really wants to invest in Python, that's probably why Sun decided to go on Ruby instead.

First talk on SQLALchemy by Paul Johnston, very very interesting, too bad it was a bit squeezed, another 15 minutes would have helped. Must investigate the reflection vs autoupdate stuff & migrate (django doesn't manage db changes very well at the moment).

Second talk: Mr. Voidspace (Michael Foorde) on Silverlight & IronPython -- lots of possibilities there, but still very very early. 1Mb of local space is very little for serious usage, there are accessibility issues (but possibly less than Flash) and limitations (1 Canvas only). But having an embedded mini-CLR/DLR in every browser (currently IE/FF/Safari, with Opera in the works) gives me a feeling of "ActiveX done right", something Java should have done 5 years ago.

Made contact with other Manchester pythonistas, it's really true that pythons hide under rocks! Looking forward to build a community in Manc when we go back, people really wants to invest serious time on Python apparently. Oh, and Resolver is hiring, but it's London-based and they do Xtreme (pair) programming, so no telecommuting, but if you are in the area and you fancy "coding the way Guido indented it" give it a go, they seem very nice guys.

Time for Django stuff with Simon Willison!

UPDATE: Simon rocks. Fast as lightning and to the point, lots of goodies for serious django usage, I hope the session was filmed because it was really worth it.

UPDATE: I met Phil Thompson, the creator of PyQt! Jeez, I probably sounded like a fanboy (that I am). And I also met a guy not just from around Manchester -- from Stockport! Astonishing, the world is so small these days. Am now on the PyQt tutorial from Mark Summerfield (who has a book finally coming out on PyQt! fantastic), Trolltech provided some very nice freebies. I feel in geek heaven.

UPDATE: Mark was great, but 2 hours straight are a bit much, so in the end the class was clearly a bit tired. Will definitely go back to his presentation very soon. Break now, then on to the lightning talks -- the list looks endless, might not do them all. Organizers expected about 100 people, got more than 200...

UPDATE: the first lightning talks: Open Spaces (weird, not sure I got it), a lovely chap trying to convert the Hansard (which is getting XML already) in RDF, Jeff Tupholme on putting javascript inside python (crazy) within LiveConnector.

UPDATE: pydoctor statically analyses code to generate docs and then uses a pseudo-wiki interface to correct typos and generate diffs (sounds nice); a lexer parsing thing which went over my head; a freakily-dressed guy from ACCU on how to pitch Python to C(++) shops (use "high-level"!); Software Freedom Day next week (eek! I'm in Oslo)!