Saturday, December 12, 2015

Javascript - 1


Javascript nuances for beginners who are seasoned in another programming language
These notes are for me who have worked with C/C++, Java, Python, Matlab in the past.


- its an interpreted dynamic programming language run by your web browsers
- HTML -> content; CSS -> style; javascript -> interactivity

- variable name follows similar rules except that a dollar sign($) is also allowed in a variable name
- there are certain reserved keywords you cannot use as variable name 
- there are also certain future reserved keywords which you should not use for future portability reasons




Tuesday, November 24, 2015

Memory Leak on server side

To avoid crash due to memory leak issues, we should let the worker process die after serving certain number of max requests.

More details -
https://rayed.com/wordpress/?p=1669

Monday, October 19, 2015

Why desktop apps are making a comeback


Source: Why desktop apps are making a comeback?

  1. Standalone, desktop applications have benefits that are almost impossible to replicate within a browser:
  2. Once they find their place in the Windows Start menu or the Mac OS Dock, they are always visible. In the mobile world, an app that isn't on the home screen is easily forgotten and eventually never opened anymore.If you want your app to become a daily habit in the life of your users, then you cannot take the risk of them not opening it because they don't see it. A web app that isn't pinned to the browser is easily closed and forever forgotten. A desktop app has the power to be always visible, and even always open. Don't miss out on this!
  3. Desktop apps are "alt-tab accessible". Alt-tab is probably the most used keyboard shortcut in the entire desktop universe. For every time someone with your app open hits alt-tab, you get a free impression of your logo and brand name on their screen! How is that for cheap marketing? In all likelihood, your logo will sit between a very popular browser and a cool music streaming service, so the brand association is not bad either. The goal is always the same: your app must become part of the daily routine of your user. Even if they open it by accident, as they're trying to skip a track in their playlist, it's still one more chance for you to convince them that you have what they need. Take that chance.
  4. also, desktop apps can support download and preview much better than web apps can. Another small but critical thing is the ability to copy things to the clipboard.
  5. Another great capability of desktop apps is their easy access to the notification system. Few things get more attention than the bouncing motion of a notified app on the Mac OSX dock.





By urgent usage, I mean that your users need to react fast to things happening, either inside your app — for instance, an incoming chat message — or outside your app, like when you need to quickly mute a Spotify track to hear the people talking to you. In both cases, you get a significant benefit from having an easily accessible app, that notifies you when an action is required.

By frequent activity, I mean that your users are going to spend a sizable amount of time in your app every day. Anything that helps them do their regular work falls within this category. For programmers, it's going to be IDEs. For designers, it's going to be Photoshop & Sketch. Transversal tools like e-mail clients or Evernote also come to mind: you probably don't use them for the most part of your work, but you still need to open them several times a day and spend some time typing in it. You want them to be always open and not have to sift through twelve tabs to get to them.

If your product cannot really be used in an urgent or preponderant way, don't burden yourself with a desktop app. The advantages of web apps cannot be overstated, and many great software companies are better off offering web interfaces. APIs like Stripe's, analytics like Kissmetrics', infrastructure like Heroku's, all provide enormous value, but don't justify the development of desktop applications.

Tuesday, October 13, 2015

Buy vs Build your own Trail Manager


  • New Relic provides a crazy amount of data about the running of both your servers and your applications. This includes application performance data, errors, low level metrics and even rolled up method or database query performance. $149 per host per month for our 200 hosts gives us $29,800 per month.

  • Librato Metrics provides a fantastic way of storing arbitrary time series data. We're already storing lots of data in New Relic but Metrics provides us with less opinionated software so we can use it for anything, for instance number of logins or searches or other business level metrics. We'll go for a plan with 200 data sources, 100 metrics each and at 10 second resolution for a cost of $3,860per month.

  • Pagerduty is all about the alerts side of monitoring. Most of the other SaaS tools we've chosen integrate with it so we can make sure we get actionable emails and SMS messages to the right people at the right time. Our plan costs $18 per person per month, so lets say we have 30 people at a cost of $540 per month.

  • Papertrail is all about logs. Simple setup your servers with syslog and Papertrail will collect, analyze and store all your log messages. You get a browser based interface, search tools and the ability to setup alerts. We like lots of logs so we'll have a plan for 2 weeks of search, 1 year archive and 100GB month of log traffic. That all costs $575 per month.

  • Sentry is all about exceptions. We could be simply logging these and sending them to Papertrail but Sentry provides tools for tracking and rolling up occurences. We'll go for a plan with 90 days of history and 200 events per minute at a cost of $199 a month.

  • Pingdom used to provide a very simple external check service, but now they have added more complex multistage checks as well as real user monitoring to the basic ping. We'll choose the plan with 250 checks, 20 Real User Monitoring sites and 500 SMS alerts for $107 a month.

How much!

In total that all comes to $35,080 (£20,922) per month, or $420,960 (£251,062) per year.

Now the first reaction of lots of people will be that's a lot of money and it is. But remember open source isn't free either. We need to pay for:

  • The servers we run our monitoring software on
  • The people to operate those servers
  • The people to install and configure our monitoring software
  • The office space and other costs of employing people (like management and hiring)

I think people with the ability to build software tend to forget they are expensive, whether as a contractor or as a full time member of staff. And people without management experience tend to forget costs like insurance, rent, management overhead, recruitment, etc.

And probably more important than these for some people we need to consider:

  • The time taken to build a good open source monitoring system

The time needed to put together a good monitoring stack based on for instance logstash, kibana, riemann, sensu, graphite and collectd isn't small. And don't forget the number of other moving parts like redis, rabbitmq and elasticsearch that need installing configuring and maintaining. That probably means compromising in the short term or shipping later. In a small team how core is building your monitoring stack to what you do as a business?

Sourece: More Than Seven blog

Fix Command tab on Apple Macbook

On your Mac,

  • Navigate to System Preferences
  • Go to Mission Control
  • Uncheck "When switching to an application, switch to a Space with open windows for the application"

Try using the cmd+tab now.

Source: http://apple.stackexchange.com/questions/112350/cmdtab-does-not-work-on-hidden-or-minimized-windows

Sunday, September 13, 2015

Recovering a compromised DO doplet

Configure Python-mode for Python development

quick REST error codes and indempotency

Error Codes -

  • 1XX - informational
  • 2XX - success
  • 3XX - redirection
  • 4XX - client error
  • 5XX - server error

Source: https://spring.io/understanding/REST

An idempotent operation is an operation, action, or request that can be applied multiple times without changing the result, i.e. the state of the system, beyond the initial application.

EXAMPLES (WEB APP CONTEXT):

NULLIPOTENT: If an operation has no side effects, like purely displaying information on a web page without any change in a database (in other words you are only reading the database), we say the operation is NULLIPOTENT. All GETs should be nullipotent. Otherwise, use POST.

IDEMPOTENT: A message in an email messaging system is opened and marked as "opened" in the database. One can open the message many times but this repeated action will only ever result in that message being in the "opened" state. This is an idempotent operation.

NON-IDEMPOTENT: If an operation always causes a change in state, like POSTing the same message to a user over and over, resulting in a new message sent and stored in the database every time, we say that the operation is NON-IDEMPOTENT.

When talking about the state of the system we are obviously ignoring hopefully harmless and inevitable effects like logging and diagnostics

Source: http://stackoverflow.com/questions/1077412/what-is-an-idempotent-operation




development workflow should make failure cheap

Friday, August 21, 2015

Accuracy and Precision

Accuracy refers to the closeness of a measured value to a standard or known value. For example, if in lab you obtain a weight measurement of 3.2 kg for a given substance, but the actual or known weight is 10 kg, then your measurement is not accurate. In this case, your measurement is not close to the known value.

Precision refers to the closeness of two or more measurements to each other. Using the example above, if you weigh a given substance five times, and get 3.2 kg each time, then your measurement is very precise. Precision is independent of accuracy. You can be very precise but inaccurate, as described above. You can also be accurate but imprecise.

For example, if on average, your measurements for a given substance are close to the known value, but the measurements are far from each other, then you have accuracy without precision.

A good analogy for understanding accuracy and precision is to imagine a basketball player shooting baskets. If the player shoots with accuracy, his aim will always take the ball close to or into the basket. If the player shoots with precision, his aim will always take the ball to the same location which may or may not be close to the basket. A good player will be both accurate and precise by shooting the ball the same way each time and each time making it in the basket.

Source: http://www.ncsu.edu/labwrite/Experimental%20Design/accuracyprecision.htm

Startups Funding news

Thursday, August 6, 2015

Personal Knowledge: Web/App Design from Accessibility Perspective

LĂ©onie Watson - Design it like a Damn!
https://www.youtube.com/watch?v=vK1tlLOavvM

Personal Notes:
Motivation
Its not just for the disabled ones. Its for older version of you as a being who may loose 1 ability or the other and find the internet world suddenly difficult.

alt text is important
choose elements as per function and standard user interpretation
e.g. do not make a link if what you intended was a button

modern screen readers built in browsers provide keyboard shortcuts to navigate through website
elements like article, nav, header, footer etc are very important
take care of website semantics

alternative hierarchical model for assistive technologies.
label element foreign key hooking input type to label
<input type="checkbox" id="drink"/>
<label for="drink"> Tequila </label>

the screen reader will read Tequila and understand user's input when he says check the tequila checkbox.

semantically neutral elements like div, span must be carefully used

ARIA W3C standard - attributes that only change the semantics of a html element
<span role="button">
<span tabindex="0"> // order in which one can use tab key to browse the page





Django MVC explanation

Django follows this MVC pattern closely enough that it can be called an MVC framework. Here’s roughly how the M, V, and C break down in Django:
  • M, the data-access portion, is handled by Django’s database layer, which is described in this chapter.
  • V, the portion that selects which data to display and how to display it, is handled by views and templates.
  • C, the portion that delegates to a view depending on user input, is handled by the framework itself by following your URLconf and calling the appropriate Python function for the given URL.
Because the “C” is handled by the framework itself and most of the excitement in Django happens in models, templates and views, Django has been referred to as an MTV framework. In the MTV development pattern,
  • M stands for “Model,” the data access layer. This layer contains anything and everything about the data: how to access it, how to validate it, which behaviors it has, and the relationships between the data.
  • T stands for “Template,” the presentation layer. This layer contains presentation-related decisions: how something should be displayed on a Web page or other type of document.
  • V stands for “View,” the business logic layer. This layer contains the logic that access the model and defers to the appropriate template(s). You can think of it as the bridge between models and templates.
If you’re familiar with other MVC Web-development frameworks, such as Ruby on Rails, you may consider Django views to be the “controllers” and Django templates to be the “views.” This is an unfortunate confusion brought about by differing interpretations of MVC. In Django’s interpretation of MVC, the “view” describes the data that gets presented to the user; it’s not necessarily just how the data looks, but which data is presented. In contrast, Ruby on Rails and similar frameworks suggest that the controller’s job includes deciding which data gets presented to the user, whereas the view is strictly how the data looks, not which data is presented.
Neither interpretation is more “correct” than the other. The important thing is to understand the underlying concepts.

References
  • http://www.djangobook.com/en/2.0/chapter05.html#the-mtv-or-mvc-development-pattern
  • http://reinout.vanrees.org/weblog/2011/12/13/django-mvc-explanation.html
  • http://stackoverflow.com/questions/6621653/django-vs-model-view-controller

Tuesday, August 4, 2015

piping hot pip!

Django 1.6 - What's new!

Dev Utilities

CloudInit - Initialize your cloud instance

Some of the things it configures are:
  • setting a default locale
  • setting hostname
  • generate ssh private keys
  • adding ssh keys to user's .ssh/authorized_keys so they can log in
  • setting up ephemeral mount points
Byobu Flexible Terminal to use for development

How to scale beyond the basics?

Starters - Django vs Flask

Django aims to follow Python's "batteries included" philosophy. It ships with a variety of extra, optional tools that solve common Web-development problems. 

--

Django's power shines by concept of quick application development where you can find enormous number of full-stack extensions. Getting a boilerplate for Flask will have the same effect but you won't find flask specific applications much, instead you will be able to upgrade components easily.

I'm a Django developer for 5 years but now headed for a marketplace project and that is the only thing I want to develop. I will switch to Flask within a year. I could break Django into parts but that would break current applications, which is also bound to Django version. Yes, I could use well-maintained libraries with Django as well but that wouldn't catch our 'deadlines'. Upgrading Django version with a fresh start is also an option but I don't want to do wide migrations every year.

No regrets using Django up to this point, it really forces you to learn general best practices, and helps you get the funding. I call it a startup framework as it helps you to change your business logic quickly. If you are a starter, go with Django, switching to Flask in future won't be painful once you need it.