• Home
  • About
  • Resume

Category: Rant

Pebbles, rectangles and stack overflow

By , 04/20/2016 2:17 PM

UntitledWhile working on my Pebble watchface “Future Time” I have encountered persistent annoying problem – watchface would run for a while and then crash – and not only crash, but actually restart the watch. What made this even more frustrating – after 3 restarts in a row Pebble would revert to recovery mode and complete firmware reinstall was required (did I accidentally write a Pebble virus?).
When I dug into device logs I found out that every restart was given reason: “Dangerous Stack Overflow”. Which is kinda strange – I don’t have any recursions nor deeply nested function calls nor large local variables. I tried lots of things – including extreme ones like declaring all local function variables as global or static – nothing helped.
Finally Christian form Pebble developers forum shed a light. He pointed out that I use a lot of GRect constructs which is basic rectangle building block for pretty much anything from defining layers to graphics functions. I used GRect inline directly inside function calls, which I thought wasn’t a big deal, after all “everybody does that” – including Pebble in its examples. Well, as Christian pointed out those GRects are kind of local variables, and either memory is not reclaimed fast enough when they go out of scope or they spring memory leak.
Keeping this in mind I created a global GRect variable and when needed to use a GRect in local function, first I’d assign it’s value to the variable and then use variable in the function.
So something like this:

static void layer_update(Layer *layer, GContext *ctx) {
   graphics_draw_rect(ctx, GRect(10, 10, 30, 30));
   graphics_draw_bitmap_in_rect(ctx, bitmap, GRect(20, 20, 40, 40));

Becomes thus:

GRect temp_rect;

static void layer_update(Layer *layer, GContext *ctx) {
   temp_rect = GRect(10, 10, 30, 30);
   graphics_draw_rect(ctx, temp_rect);
   temp_rect = GRect(20, 20, 40, 40);
   graphics_draw_bitmap_in_rect(ctx, bitmap, temp_rect);

That’s it. This simple change cured the plague, no more crashes, restarts or recovery – just smooth sailing.

Trump wants to bring Pebble home

By , 04/01/2016 12:01 AM

Trump on PebbleDonald Trump’s plan to “Make America great again!” would have you spending a whole lot more dough on your next Pebble smartwatch.

Not surprisingly, that would be the logical consequence of the Republican presidential front-runner’s latest ambitious promise: Getting Pebble to start manufacturing their products in the US instead of China.

“We’re going to get Pebble to build their damn watches in this country instead of in other countries” Trump said in a speech at a rally in Supai, Arizona.

The Donald’s claims are made to appeal to a voters having difficulties finding jobs in the US. Pebble, the world’s most innovative company with cult of followers, designs its best-selling Pebble Time, Pebble Time Steel and Pebble Time Round in the US but relies on partners in China and Chinese factory workers to assemble all of them. But what would be the price to build those “damn watches” in the US? Even a rough estimate of the basic costs shows it’s an unrealistic option, leading to a Pebble smartwatch with a potentially jaw-dropping price tag.

To keep things easy, let’s just observe salaries of workers occupied with assembling a Pebble. A labourer at Chinese manufacturing factory gets paid roughly $400 a month before overtime, according to the New York Post.

Now assume Pebble goes the cheaper route and utilizes a factory in Wyoming or Georgia, which happen to have the country’s lowest minimum wage at $5.75 an hour. Working 8 hours a day, 5 days a week, a US worker will earn $824 a month, or more than double the Chinese labourer. And if Pebble were to utilize someone in its home state of California, where the minimum wage is $9 an hour, the monthly pay is $1,400, or more than triple of the chineese.

And that’s ssuming you have number of workers with enough technological skills to do the job (and you don’t) and also assuming those workers will work for minimum wage (they will not). After awhile, things don’t add up.

While there are a number of other factors that go into a Pebble, including the components, shipping, marketing and research and development, doubling the labor costs could significantly hike up the price of a Pebble. Current price of Pebble Time is $150 — will you pay for the same smartwatch $300? $400? Or more?

“Twice the price is a very modet estimate” says Clara Mileshti, an analyst at Dumas CostEff, about the price hike of a Pebble if it were manufactured in the US.

In another speech, Trump proposed a 35 percent tax on products built outside of the US. So at a minimum, that would mean your next Pebble Time’s price could start at over $200.

Pebble declined to comment on Trump’s comments and didn’t want to get into the potential math of bringing watch manufacturing back the US.

Trump’s comments ignore the fact that Pebble does buy some of its components from US companies, including LEG’s Cortex-MI5 processors. The company said earlier that it believes it affects jobs creation in the US throug encouraging developers to learn and and create software for their appstore ecosystem. And by the way, creating and submitting an app to Pebble appstore is free for developers.

Pebble couldn’t afford to build a watch in the US at a reasonable price. Making a more costly, “Made in the USA” product is not an option, especially as consumers start to wise up about how much they’re spending on their smartwatches. Today Pebble is the leader in low-cost efficient watches. But alternatives are cropping up.

So strike it up as another crazy, wild claim by Trump. Or is it?

Unblock my heart, i mean, iPhone for Pebble geocoding

By , 03/29/2016 11:15 AM

Cobblestyle I’ve recently updated code for Cobblestyle Pebble Watchface to take advantage of very cool geocoding service called Nominatim by Open Street Maps.

Nominatim is used in two places: Direct lookup is used in watchface’s config page to lookup coordinates of a place by its name for custom location setting; reverse lookup is used to lookup location name by its coordinates to display name on actual watchface.

It was working fine – on Pebble watches connected to Android phones. It was failing miserably on iOS, so iPhone Pebble users were getting neither location nor weather updates. And it was pretty puzzling for a while until I obtained logs from running watchface thanks to invaluable help from Robin.

Turned out iPhone Pebble app was plain simple blocked by Nominatim service, every attempt to retreive location resulted in message being sent back “You have violated acceptable policy”. Which was kinda surprising since I just started using the service. When I contacted Nominatim support, they told me that apparently some Pebble app running from iPhone abused the service pretty badly, running hundreds of requests per second. And since the only way they can detect requesting app is by it’s User Agent string – all apps spotting iPhone Pebble UA were blocked.

Support suggested to set UA string specific to the app so it could be easily identifiable. Standard approach to set headers on xmlHttpRequest object is .setRequestHeader(..). Unfortunately by many browsers and clients it is considered unsafe to spoof UA via request headers. Fortunately iOS allows that, so all I have to do is catch and ignore erros in other clients. Basically this line of code solved the issue:

try {xhr.setRequestHeader("User-Agent", "Cobblestyle Pebble Watchface");} catch(e){}

Thanks to this as of version 2.19 Cobblestyle watchface correctly displays weather and location information. Yay.

TSQL ISNUMERIC and “String or binary data would be truncated” error

By , 02/17/2016 12:34 PM

If you’re using TSQL ISNUMERIC function in a query, e.g.


You may receive unexpected error:

String or binary data would be truncated.

ISNUMERIC must truncate string data, and if you experienced the above error, some of your data is over the limit. But you can augment the above query:


But cutting only 8000 chars you will avoid the error, and I seriously doubt you will have number over 8000 digits long so it’s a safe bet as well

Restore natural picture look on Samsung smart TV

By , 02/02/2016 10:04 PM

I really like my new smart TV from Samsung it has tons of bells and whistles. But one thing I noticed – no matter what I watch – series or movies, streaming or broadcast – picture has a “teleplay” feeling – like the action is happening on stage in the theater. If you recall what later Twilight Zone episodes look like you’d know what I am talking about. Maybe it’s supposed to look like this, but I like “film” feeling more. So I found a setting that restores natural picture look:

Go to your TV menu, then select Picture -> Picture Options -> Auto Motion Plus and turn it off.

Fix Roku problem connecting to 802.11ac 5Ghz WiFi

By , 01/30/2016 2:15 PM

I recently got a Roku 4 – at the time of this post the latest and greatest streaming players from Roku family. It comes with many bells and whistles – including ability to connect to 5Ghz WiFi networks. But for the life of me – it could not connect to mine. Player was seeing the SSID of the network, able to connect to wireless, but chocked on joining to LAN. Extensive chat with support lead nowhere – they wanted me to change WAN DNS and many other hoops that achieved nothing. For the record – my router is a dual-band one, and Roku had no problems connecting to 2.4Ghz band. But Internet speed falls dramatically over 2.4Ghz connection and I needed 5Ghz.

Finally I found one thing that worked.
AC Network
AC connection has 3 bandwidth modes: 20Mhz, 40Mhz, and 80Mhz. My router was set to 80Mhz to take full advantage of 1300 speed. None of my devices had problem with this (including, I might add, my previous Roku 3 player). But apparently Roku 4 couldn’t handle it. But as soon as I switched bandwidth to 40Mhz – boom, instant connection.

Streaming doesn’t suffer from this change, but it does lower LAN speed, so I’d like alternative solution from Roku if possible. Is this a known issue? Would an update fix it?

UPDATE 2016-02-01: Found a better workaround with the help of this awesome device.
WUMC710 is a bridge between 4 Gigabit Ethernet connections and full 802.11ac WiFi. And it has no problem with 80Mhz channel. So I basically tell Roku it has a wired connection (and it does to the bridge) and the bridge has beautiful wireless connection to my router. You can grab the WUMC710 pretty cheap (I got mine for $10) and besides not having to slowdown your main network it makes actual Roku internet Speed much faster. Shame Roku’s own WiFi is not on par, but hopefully it will catch on

Fixing problem with Yahoo geolocation service

By , 01/25/2016 5:04 PM

Recently two Pebble watchfaces I’ve developed based on Paul Joel designes: Clean&Smart and Cobblestyle began to experience weather update issues – as in “weather was not updated at all”. Looking into the issue I found a weird thing: If you set your location manually – weather worked. But automatic weather based on phone location did not.

The way automatic location works is pretty straighforward. First this function is called to determine location:

function getLocation() {
    {timeout: 15000, maximumAge: 60000}

It uses phone location services (GPS, if its available, otherwise network-based location). In case of success it calls locationSuccess function. And in my tests it always called it, so location was determined successfully. Continue reading 'Fixing problem with Yahoo geolocation service'»

Solved: Issue with Pebble framebuffer after notification is dismissed

By , 01/08/2016 1:15 PM

Effect Layer Issue I’ve encountered a weird issue while working with EffectLayer Library (a visual effect library for Pebble smartwatch). In this particular watchface called Clean & Smart I used “invert” effect which inverts colors of the watchface should the user choose that option in settings. It was working fine when option changed when watchface was loaded/unload and behaved weirdly only in one particular scenario: when you would receive a notification (email, text etc.) and then dismiss it. Upon coming back from notification to watchface invert effect would only partially cover the watchface (as seen on the screenshot).
I don’t know exactly what was happening, but had a theory. Continue reading 'Solved: Issue with Pebble framebuffer after notification is dismissed'»

Solution: Windows 10: Unable to start Appstore apps

By , 08/05/2015 1:45 PM

Ok, I went ahead and upgraded to Windows 10. everything went smoothly, all my settings and installed apps preserved and work without a hitch. I am loving the interface and getting along with Cortana pretty good.

But after a while I encountered a weird issue: Appstore installed apps – e.g. Calendar, Mail etc. even Windows AppStore itself wouldn’t launch. I’d either get a cryptic error message, something along the lines “Application did not start, please contact system administrator” or very briefly a window would appear and immediately closed.

Looking into Event log was a bit more explanatory, but not too much: “Microsoft.WindowsStore_8wekyb3d8bbwe!App failed with error: Access is denied. See the Microsoft-Windows-TWinUI/Operational log for additional information.

If you google it – you will find many possible explanations of the problem and many possible ways to solve it offered, but none of those worked for me. Finally I figured it out (and Event Log entry gave me a clue): C:\Program Files\WindowsApps folder was missing necessary permissions:


Namely, “ALL APPLICATION PACKAGES” was missing read & execute permissions on that folder (had to to uncheck “Hide protected operating system files” in Control Panel, File Explorer options to be able to see it). Once I added correct permissions – appstore apps started launching with no problems.

Original Pebbles are getting TimeLine! (with special offers)

By , 04/01/2015 12:01 AM

Original Pebble Steel with TimeLine Pebble Corporation is very well know for its visionary ideas. Ideas that kept its incredible smartwatches Pebble and Pebble Steel relevant on the market years after their release. They key to such longevity is regular software updates that bring new features to existing hardware. Multilanguage support, actionable notifications and many other fetures delighted Pebble users to no end.

This worked amazingly well so far. But now Pebble is finally on the verge of releasing new hardware as well. Color Pebble Time is scheduled (as of this writing) to be released in May and a shinier version – Pebble Time Steel is to be shipped in July. Both are getting brand new OS with time-oriented Timeline interface that will streamline the way you interact with the watch.

But what about users of existing Pebbles? Are they doomed to use obsolete devices? Continue reading 'Original Pebbles are getting TimeLine! (with special offers)'»

Panorama Theme by Themocracy