[ rails ] web servers + application hosting

Web Servers 

Full-featured

  • Apache
  • Nginx
  • Lighttpd

Light-weight

  • Passenger/mod_rails
  • Unicorn
  • Mongrel
  • Thin

Application hosting

http://bluebox.net

http://brightbox.co.uk

http://engineyard.com

http://heroku.com

http://joyent.com

http://linode.com

http://rackspace.com

http://railsmachine.com

http://railsplayground.com

 

ref : Ruby on Rails 4 Essential Training on Lynda

Advertisements

[ Google Analytics ] wrong landing page

Due to GA’s 30 minute timeout for a session visit, any page can be a landing page. For example a user can be on a page, walk away for an hour, come back and have the page now look like a landing page.

ref : https://webmasters.stackexchange.com/questions/31193/why-google-analytics-is-displaying-wrong-landing-pages

[ jasmine ] compare/matcher function

expect(array).toContain(member);
expect(fn).toThrow(string);
expect(fn).toThrowError(string);
expect(instance).toBe(instance);
expect(mixed).toBeDefined();
expect(mixed).toBeFalsy();
expect(mixed).toBeNull();
expect(mixed).toBeTruthy();
expect(mixed).toBeUndefined();
expect(mixed).toEqual(mixed);
expect(mixed).toMatch(pattern);
expect(number).toBeCloseTo(number, decimalPlaces);
expect(number).toBeGreaterThan(number);
expect(number).toBeLessThan(number);
expect(number).toBeNaN();
expect(spy).toHaveBeenCalled();
expect(spy).toHaveBeenCalledTimes(number);
expect(spy).toHaveBeenCalledWith(...arguments);

assert not to contain

expect(array).not.toContain(member);

ref : https://jasmine.github.io/api/edge/matchers.html, https://codecraft.tv/courses/angular/unit-testing/jasmine-and-karma/,

https://stackoverflow.com/questions/37483566/is-there-something-like-a-jasmine-tonotcontain-acceptance-criteria-for-tests

 

 

[ python ] lambda

>>> foo = [2, 18, 9, 22, 17, 24, 8, 12, 27]
>>>
>>> print filter(lambda x: x % 3 == 0, foo)
[18, 9, 24, 12, 27]
>>>
>>> print map(lambda x: x * 2 + 10, foo)
[14, 46, 28, 54, 44, 58, 26, 34, 64]
>>>
>>> print reduce(lambda x, y: x + y, foo)
139

ref : http://www.secnetix.de/olli/Python/lambda_functions.hawk

[ AngularJS ] inherit factory

// Base service
app.factory('Shape', function() {

var Shape = function(colour) {
this.colour = colour;
};

Shape.prototype.getColour = function() {
return this.colour;
};

return Shape;
});

// Extended service
app.factory('Square', function(Shape) {

var Square = function(colour) {
Shape.apply(this, arguments);
};

Square.prototype = new Shape();

Square.prototype.getSides = function() {
return 4;
};

return Square;
});

ref : https://stackoverflow.com/questions/23788567/angularjs-extending-services-and-inheritance

The problem with above is

var square = new Square();

console.log(square.constructor.name); // Shape ( not Square )

So the right way to do this may be

function Food() {}
function Bread() {}
function Sushi() {}

Bread.prototype = Object.create(Food.prototype);
Bread.prototype.constructor = Bread;
Sushi.prototype = Object.create(Food.prototype);
Sushi.prototype.constructor = Sushi;

var bread = new Bread();
var sushi = new Sushi();

console.log(sushi instanceof Bread); // false
console.log(bread instanceof Sushi); // false
console.log(sushi.constructor); // [Function: Sushi]
console.log(bread.constructor); // [Function: Bread]
console.log(sushi instanceof Food); // true
console.log(bread instanceof Food); // true
console.log(sushi instanceof Sushi); // true
console.log(bread instanceof Bread); // true

ref : https://stackoverflow.com/questions/22315909/javascript-inheritance-with-prototypes-constructor-property