• Home
  • About
  • Resume

Copy/Paste image into an editable DOM element in Chrome

By , 09/11/2017 4:29 PM

All major browsers allow to paste image directly into a DOM element with contentEditable property set to true. They automatically convert it into IMG element with source pointing to base64 encoded DataURI of the pasted image. That is all browsers, but Chrome. Chrome needs a little help.

In my particular case I need to be able to paste image into an IFRAME with editable body of the content document (for some reason Infragistics WebHtmlEditor ASP.NET control renders itself as this contraption). But the code below applies (with small changes) to any editable DOM element.

To achieve the result we need to perform 3 tasks:

  1. Capture image from the clipboard
  2. Convert the image to DataURI format
  3. Create IMG element with the DataURI source and insert it into the DOM

Take a look at the code below: Continue reading 'Copy/Paste image into an editable DOM element in Chrome'»

April Fools has been canceled this year.

By , 04/01/2017 12:01 AM

Because we live in a farce now.

That will be all.

Tweet images with Scriptr and IFTTT

By , 02/28/2017 4:34 PM

Sev Trek

Looks like everybody is doing Twitter bots these days so I decided to try my hand on one as well. And it had to be something lighthearted – to let people’s mind off things for a while. Way back in early 2000s there was a funny parody comic of Star Trek called Sev Trek. Original site is gone now, but archive of images was saved at http://sevspace.com/stupidarchive/sevtrek.asp.htm. Images are numbered sequentially – ideal for automatic processing. My bot would tweet random images every couple hours.

To host bot’s script I decided to go with Scriptr which offers powerful JavaScript backend and multiple expansion modules. And IFTTT has a cool Twitter service, one that can tweet image from an URL. So the idea was:

  1. Code hosted at Scriptr generates URL pointing to an image at sevspace.com
  2. Code then call Maker service of IFTTT – custom service capable of accepting HTTP requests
  3. Maker service triggers Twitter service and passes URL of image it got from Scriptr code
  4. IFTTT Twitter service tweets the image

Continue reading 'Tweet images with Scriptr and IFTTT'»

Full control of your LimitlessLED/Milight – v6- bulbs from Amazon Echo

By , 02/24/2017 9:42 PM

A while ago I blogged about controlling you Milight smart bulbs from Amazon Echo. This was done by sending raw UDP packets directly to Milight bridge. Since a packet consisted only of a few bytes – this was manageable.

Then we got v6 of Milight bulbs. They’re vastly superior to previous version – besides brightness and color you can set warmth and saturation among other things. But with new features came increase complexity of commands. UDP packets now consist of huge number of bytes and you cannot simple send packet and forget it, response matters too.

HA-Bridge, which is used to emulate Phillips Hue bulbs so Echo can detect the devices, is incapable of such commands. Thankfully it can run external scripts. Continue reading 'Full control of your LimitlessLED/Milight – v6- bulbs from Amazon Echo'»

Using FusionCharts in SSRS reports

By , 01/30/2017 12:11 PM

Microsoft’s SSRS is pretty advanced reporting system with multitude of advanced features. SSRS also has charting capabilities, but it’s somewhat lacking compared to more advanced desktop or web charting suites

On the other hand FusionCharts offers very cool charting package with gazillion of chart types and very cool features. But it uses JavaScript engine and renders charts client-side only!

What if there was a way to marry the two technologies together – to render cool FusionCharts in advanced SSRS repots? Continue reading 'Using FusionCharts in SSRS reports'»

There’s new reflective LCD in town (SMA Q2 vs PTS)

By , 01/20/2017 12:23 PM

I’ve been a fan of Pebble smartwatch for a very long time, both as a user and developer, but recently, even before announcement of Pebble acquisition by FitBit I got curious – what else’s out there? Two mainstream branches of smartwatches – Android Wear and “The Watch” are of no interest to me – too boring. So I looked into Samsung Gear watches – Tizen platform is very interesting, then it was Vector Watch (which ended up being bought by FitBit as well) and now a new ePaper watch from Chinese company Shenzhen – SMA Q2 (sometimes called SMA Time).

There is no question that despite obvious visual similarities, at this point in time Pebble Time Steel is vastly superior to SMA Time. PTS is on 4th generation firmware which brought many advanced features over the years, PTS has a very popular appstore and high quality developer ecosystem. SMA Time feels like Pebble circa firmware v1.x (probably even less, e.g. it has only 3 slots for watchfaces on the watch) but it seems to have great potential.

I am posting here a few pics comparing PTS with SMA Time. Continue reading 'There’s new reflective LCD in town (SMA Q2 vs PTS)'»

Panorama Theme by Themocracy