How to get UTC offset in javascript (analog of TimeZoneInfo.GetUtcOffset in C#)

Vadim’s answer might get you some decimal points after the division by 60; not all offsets are perfect multiples of 60 minutes. Here’s what I’m using to format values for ISO 8601 strings: function pad(value) { return value < 10 ? ‘0’ + value : value; } function createOffset(date) { var sign = (date.getTimezoneOffset() > … Read more

Image brightness detection in client side script

This function will convert each color to gray scale and return average of all pixels, so final value will be between 0 (darkest) and 255 (brightest) function getImageLightness(imageSrc,callback) { var img = document.createElement(“img”); img.src = imageSrc; img.style.display = “none”; document.body.appendChild(img); var colorSum = 0; img.onload = function() { // create canvas var canvas = document.createElement(“canvas”); … Read more

How to get client MAC address by a access on a website?

The MAC address, by TCP/IP standards, is never communicated outside of the local-area network to which it pertains — routers beyond that LAN don’t even get the information you’re trying to record. There are many other ways to try and identify unique visitors, including matching the user-agent’s details in addition to the IP, serving cookies … Read more

Can you get a public Facebook page’s feed using Graph API without asking a user to allow?

If you’re anything like me your clients won’t want a standard Facebook likebox plugin, they’ll want it all styled and customised their own way. You don’t need to spend all day going round the official documentation wondering if any of it applies to you for something simple like this, it’s quite easy. The confusion arises … Read more

A step-up from TiddlyWiki that is still 100% portable?

After some time and serious consideration, I will post my own answer. There is nothing that matches TiddlyWiki. As for voluminous information, TW can pretty much handle it. (My early discouragements were due to malformed code.) Difficulty accessing information through the interface becomes an issue before any speed problems. This isn’t to fault the interface … Read more

In IndexedDB, is there a way to make a sorted compound query?

The term compound query as used in this answer refers to an SQL SELECT statement involving more than one condition in its WHERE clause. Although such queries are not mentioned in the indexedDB specification, you can approximate the behavior of a compound query by creating an index with a keypath that consists of an array … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)