Skip to content

Murmur Hash 2 for Arduino

I made modification from the official murmur2 code because the official code assumes 32 bit math whereas Arduino’s math is 16 bit.

// Same as MurmurHash2, but endian- and alignment-neutral.
// Half the speed though, alas.
uint32_t MurmurHashNeutral2 ( const void * key, uint32_t len, uint32_t seed )
{
 const uint32_t m = 0x5bd1e995;
 const uint32_t r = 24;
uint32_t h = seed ^ len;
const unsigned char * data = (const unsigned char *)key;
while(len >= 4)
 {
 uint32_t k;
k = (uint32_t)data[0];
 k |= (uint32_t)data[1] << 8;
 k |= (uint32_t)data[2] << 16;
 k |= (uint32_t)data[3] << 24;
k *= m; 
 k ^= k >> r; 
 k *= m;
h *= m;
 h ^= k;
data += 4;
 len -= 4;
 }

 switch(len)
 {
 case 3: h ^= (uint32_t)data[2] << 16;
 case 2: h ^= (uint32_t)data[1] << 8;
 case 1: h ^= (uint32_t)data[0];
 h *= m;
 };
h ^= h >> 13;
 h *= m;
 h ^= h >> 15;
return h;
}

set timezone on Heroku servers

Set timezone on Heroku dynos. Tested on cedar stack.

heroku config:add TZ=America/Whitehorse

Set timezone on dedicated PostgreSQL server

  1. get list of timezones from wikipedia
  2. get user id
    heroku pg:info
  3. change time zone
    heroku pg:psql
    ALTER ROLE youruserid SET timezone = 'America/Los_Angeles';
    \q

Update from heroku:

The user id will stay the same across forks and follows.

It will change if you request it to be randomly re-generated or if you get a new database and use PGBackups.

Also, there is an important caveat: the ALTER ROLE SET TIMEZONE setting does not persist in PGBackups or pg_dump or pg_restore at this time.

I would suggest having your software automatically run SET TIMEZONE at connection start-up to be the most robust approach because of that problem, but if you must, ALTER ROLE does work.

Jquery Mobile – how to change hash without triggering page change event

I needed to handle the beforepagechange event in order to customize the hash value for bookmarking purpose. But the problem is the page change event chain gets triggered when I update the hash.

windows.location.hash = newHash;

The reason is jquery listens on the hash value. hashListeningEnabled disables hash listening all together, but I just want to disable hash listening specifically in just one function.

I dug into the jquery source code and found an undocumented variable that does the trick. (It’s not documented as far as I know. I’ve been looking for a while). I’m not sure if this is good practice in jquery, but it works.

 $.mobile.urlHistory.ignoreNextHashChange = true; 
 window.location.hash = newHash;

This variable gets reverted to false in jquery built-in _handleHashChange function.

rently.com is under DDOS attack

http://www.dreamhoststatus.com/2011/11/09/server-ras-alhague-is-suffering-from-a-ddos-attack/

This is the first time Rently is under any type of cyber attack. Attacker could be targeting us or another site hosted under the shared server. There is nothing we could do with our limited access to the server. We are just waiting for the issue to be resolved by DreamHost.

If this problem doesn’t get resolved in another hour, we are switching the hosting service.

 

Update: 10:49 server is back. Thanks for your patience.

Day two of launch – we got two real users!

Looking at Google analytics has been a obsession of ours in the past two days. We’ve been monitoring through out the day like it’s the stock market. At least for me, looking at the stats is a outlet to calm my nerves.

Today’s stats

  • 41 unique visitors
  • 18 people went to the sign up page
  • 5 new users signed up
  • 2 of the names belongs to people we don’t know
  • we started experimenting with variations of the resume pitch and compare the bounce rate. 61% for variation 2 and 51% for variation 1. Not enough difference to tell us anything.
Tomorrow – we will start experimenting with pitching undeveloped features, and see which one the users respond most favorably.
Something interesting – Today we heard of a company called livelovely.com. They are about 6 month ahead of us in terms of features. They have 75% of the same features we’ve planned for. It makes me think maybe it’s not about the features, but how we market it.

just launched with a Minimum Viable Product

My startup is launched today with a rental resume feature. As you can see, it’s more like a feature than a product. Nonetheless, Merrick and I emailed, tweeted, commented, blogged – all the social network marketing work. The result for the first day is we have 30 unique visitors, and one account sign up. (Thanks Jin. You are the best.)

My feelings about the launch is mixed – filled with doubts and sense of clarity at the same time. From the start I knew building a start-up was going to be hard, but today I felt like my face hit the pavement. Doubts about the features, the ecosystem, the industry attractiveness overall started bubbling up my head. Back when we were in stealth mode, it’s so much easier to convince ourselves we are right. We dreamed about being the XX of rental. (Insert big comany names in XX) But when there is no one using our product, it is the most painful feeling. In in mist of the doubts, there is also a sense of clarity. Our feet are finally on the ground. By launching the site, we essentially cut the ability for us to day dream about how successful we could be. It clears our mind and helps me focus on whatever situation that comes up from this point.

We agonized over the past weekend on the launch / no launch decision. If we wait for the delayed rental request, review, credit report, and endorsement features, the site would look much more professional, but it would push the launch back another month or more. I was feeling anxious. Working on coding but not getting any feedback from any users feels like walking in the dark – I never know if I’m going to trip over the next moment. I wanted to hear from users, even bad feedbacks. Then, we talked about the scenarios for launching today. Although we thought it is a weak value proposition, it wouldn’t hurt for us to confirm it anyway. Sure, we will both be embarrassed knowing that what we have is not strong, but what do we got to lose? We can’t lose much from having nothing.

The upside of launching is we get in the rhythm of test-measure-learn. Plus it will jump start the marketing and customer engagement side of the business. If the users tell us there is a crucial feature missing, we can learn a great deal, even if it was something we already planned. Psychologically, we are upping the ante if we show a public face.

In the spirit of being agile and lean, we launched the site. I can’t say I’m proud of the product the way it is now, but I felt we are at the right place.

Auto zooming browser for better accessibility

Now days, it is common for a computer user with large monitors to set the resolution higher than 1024 pixels in width. However, a lot of web pages are still designed with a fixed 980 or 960 width layout.  It creates waste of space on left and right margins. I’m using Yahoo as an example.

Most of the time when I visit a site, I use browser’s zoom function (ctrl + +++) so that the page fits my screen. But not every user knows this option, and it is a hassle to zoom in the every time I visit a site. Taking care of site display should be part of website design, not a user’s task. Why doesn’t a website just auto zoom for the user? Zooming is supported in IE, Firefox, and Chrome through style.zoom and style.MozTransform. I wonder how yahoo would look if it had an auto zoom feature. I prototyped the code with jquery to test it.

     function loadjsfile(filename, filetype){
      if (filetype=="js"){ //if filename is a external JavaScript file
      var fileref=document.createElement('script')
      fileref.setAttribute("type","text/javascript")
      fileref.setAttribute("src", filename)
      }
      }
      if (typeof fileref!="undefined")
      document.getElementsByTagName("head")[0].appendChild(fileref)
    }
    // load
    loadjscssfile("http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js", "js")
    var currentWidth = $(document.body).width();
    var targetWidth = 1050; // experiment for your self
    var scrollWidth = 10; // need to make it dynamic
    // if the screen is not bigger than the target, then don't mess with zooming
    if (currentWidth > targetWidth) {
      if (typeof document.body.style.zoom != "undefined")
        document.body.style.zoom = currentWidth / targetWidth;
      else if (typeof document.body.style.MozTransform != "undefined") {
        document.body.style.MozTransformOrigin = "left top";
        document.body.style.MozTransform = 'scale(' + currentWidth / targetWidth + ')';
      }
      else if (typeof document.body.style.WebkitTransform != "undefined")
        document.body.style.WebkitTransform = 'scale(' + currentWidth / targetWidth + ')';

      $(document.body).width(targetWidth - scrollWidth);
   }

Then, I inserted it through developer tools in IE, Firefox, and chrome. (Chrome and FF require running the code twice.) Here is how they looked.

Chrome

Firefox

IE 9

With auto zooming, the font is bigger and no space wasted on left and right. The down side is there is less content displayed at a time and more vertical scrolling. In a portal site like yahoo, where it is important to optimize user experience on content selection, it may be beneficial to display as much content as possible. So I can see why they don’t auto zoom in for users.

On the other hand, auto zooming would make sense in a blog type of site, where it is important to optimize on content consumption. Bigger font means easier on the eyes for readers. (Readability point is along the lines of this article – http://www.smashingmagazine.com/2011/10/07/16-pixels-body-copy-anything-less-costly-mistake/) Wouldn’t it be great if everyone’s viewing experience is consistent? The site could also place the auto-zoom command on window resize event so that the site fills the width.

Try auto zooming for your favorite site. Please share thoughts on the result. Here is what reading this blog looks like with auto-zoom. I like it better when it’s auto-zoomed.

Hacker’s News Original

Hacker’s News Zoomed