Business

Never feel sorry for yourself

Here are few notes I’ve wrote down after I saw this powerful talk of Charlie Munger.

  • Never feel sorry for yourself
  • Never feel envy.
  • Good waves and Bad waves – so what?

If you don’t know who is Charlie Munger – well, he is the CEO of Berkshire Hathaway AND the one person that Buffett suggest you save if both of them are on a sinking ship!

BTW, his full talk, is very interesting but I took one thing that was above the ‘ordinary’ – “…On philanthropy: Generally speaking, I believe Costco (Nasdaq: COST) does more for civilization than the Rockefeller Foundation. I think it’s a better place. You get a bunch of very intelligent people sitting around trying to do good, and I immediately get kind of suspicious and squirm in my seat. That may be a prejudice of mine which isn’t quite fair. But I’ve seen so much good in the world by people who really created better systems, and I’ve seen so much folly and stupidity on the part of our major philanthropic groups, including the World Bank, that I really have more confidence in building up the more capitalistic ventures like Costco.”

Standard
life

Andy Irons Tribute


Great moments, photos, music and a very sad end to the story. Life.

Standard
life

How To Harness The Good Bugs To Fight For You

I wish I saw part of this TEDx which took place last April in Tel Aviv. Shimon Steinberg looks at the difference between pests and bugs and makes the case for using good bugs to fight bad bugs, avoiding chemicals in our quest for perfect produce. It’s very cool, greener, organic way to approach our battles in the fields.


TEDxTelAviv – may be next year.

Standard
php, webdev

ZendCon 2010 – Caching on the Edge

PHP Caching on the Edge

The goal is to never generate the same response twice.
This is another ‘notes post’ – nothing too organize here (for now).

Changing the HTTP headers with php:
header(‘Content-Type: text/plain’);

Caching  spec – read it on the night you feel like you can’t sleep.

1. HTTP expiration

Is the data fresh? only when the version is stale we will go to the server to get a new data.
HTTP Headers for Expiration

2. HTTP validation

Last-Modified / If-Modified-Since
ETag / If-None-Match

(!) Http cache headers only work with ‘safe’ HTTP methods (GET/HEAD) – meaning, these method won’t change the application state.

Expires – give the date/time after which the response is considered stale.
$expires – gmdate(‘D, j M Y H:i:s T’, time()+5); // expire in 5sec
header(‘Expires: ‘ . $expires);

* With expiration of less then few days you might hit problems because the clock in the web server and the clock in the client is not showing the same time.
* HTTP/1.1 spec says that you are not allowed to send expire for more then 1 year in the future. WHY?

A better way:
* Use cache-control
header (‘Cache-Control: max-age=5’);

(!) So use expire only for things you want to cache for very long time (more then 48h).
On other cases, use cache-control.

Usage of ETag

You can compute the etag on your own or use a tool that do the work for you (some good framework).
ex: http://http.trainings.sensiolabs.com/etag.php

* Expiration wins over Validation – first we checking the expiration.
* Expiration allows you to scale as less requests hit your server.
Validation saves bandwidth.

PHP and cache

http://http.trainings.sensiolabs.com/cookie.php

session_start();
$_SESSION['foo'] = 'bla';

(!) By default – when you set a cookie… php set for YOU no-cache/no-store/must-revalidate
Because if you have a cookie, you don’t want to cache the page.
It’s more a ‘safe’ default. So no one else could take this information from you.

header(‘Cache-Control: private/public, max-age=5’);
private – will prevent any proxy from cache this page.

Types of Caches

1. Browser cache – for example it’s good for images.

2. Proxy cache – inside a company/organization. It still on the ‘client side’ and it will mask all the clients that site behind it.
We can find it in big companies and lots of ISPs. It’s public.

3. Gateway cache (=reverse proxy or Http Accelerator or Surrogate Cache) – This is just like a proxy BUT it is on the server side.
Shared cache on the server side. Make your site more scalable, reliable and improve performance.

Gateway cache

In practice, most caches avoid anything with: cache-control, cookie, www-authenticate, post/Put, 302/307 status codes.
Cache-Control in php save us with a safe default of ‘private’.

A gateway cache won’t cache anything ‘private’ or carrying a cookie – so how can we use Google Analytic and still have cache?
use varnish… or any other proxy that remove+add the cookies before the request hit the server.

In cases where you want your code to run with reverse proxy like Akamai/varnish (esi tag is supported) you should use:

Surrogate-Capability: abc=”Surrogate/1.0 ESI/1.0″
Surrogate-Control: content =”ESI/1.0″ <– this will let the reverse proxy to parse the tags.

(!) You need to set these features in Varnish (they are not there by default).

Symfony2 – got a reverse proxy that is written in PHP. You might want to use it if you can’t afford to use varnish (it’s free – but let say your hosting company won’t install it)

In the end of the day, you want to hit the application as less as possible.
You can do it with HTTP headers and ESI.

Last but not least, please remember that, the one who picks his targets carefully, acts quietly, and achieves his objectives — he wins wars.

Standard
JavaScript

ZendCon 2010 – JavaScript for (real) beginners

Warning: this is not a real post…
It is more ‘some notes’ I’ve took in one of the morning sessions in ZendCon 2010

—
* In php associative array are very powerful – in Java script the keys will be integer.
You can have the same ‘associative’ if you build your own object that contain the features.

var obj1 = new Object();
obj1['foo'] = 'momo';
obj1.foo2 = 'bobo';

var obj2 = {
‘foo’ : ‘bar’,
‘confObj’ : ‘bla-bla’
}
console.log(obj1);
console.log(obj2);

* Nice way to use array {key1: “value”};
* The ‘this‘ keyword – what it point to now? A good question with more then one answer.
* ‘new‘ – create a copy from the function/obj and assign it.
* instanceOf – are X is instance from Y? (return as string)
* typeOf – lots of return options.

*

functions

both as objects and as contractor or procedural

as Procedural


function ff(str) {
console.log('ff is:' + str);
}

as an Object


var foo2 = function(str){
this.str = str;
this.say = function(){
console.log('inside say let see what is str:'+str);
}
this.say();
}

prototype – a way to let you inheritance
* jQuery (Mr. Rasig) show a nice way to do a way of ‘class’ / obj and standard inheritance.
For example:

var Robot = function(name){
this.name = name;
this.say = function(){
console.log("bla bla my name " + this.name );
}
}
myRob = new Robot("momo");
// refine say
myRob.say = function() {
console.log("Yo - my name " + this.name );
}

// lets add to the ‘class’ definition a new function – it will be in all the obj. we created from it
Robot.prototype.showDown() = function(str) {
console.log (‘bye bye ‘ + str);
}

Useful sites/resource to keep learning the core of JS (and not just some ‘cool’ animation):
** eloquentjavascript.net
** mozilla – core and ref
* nczonline.net
* wtfjs.com

Books:
* JavaScript: The Definitive Guide – David Flanagan
* JavaScript: The Good parts – Doulas crockford
* JavaScript Patterns – Stoyan Steganov
* High-Performance JavaScript – Nicholas C. Zakas

On twitter you can find more #zc10 or #zendcon

Standard
life

The All Truth About Marriage From Oscar Wilde

I’ve returned again to one of my favorite authors, Oscar Wilde.
Late last night I’ve notice this piece and wanted to share a small part of it.
“…You seem to forget that I am married, and the one charm of marriage is that it makes a life of deception absolutely necessary for both parties. I never know where my wife is, and my wife never knows what I am doing. When we meet—we do meet occasionally, when we dine out together, or go down to the Duke’s—we tell each other the most absurd stories with the most serious faces. My wife is very good at it—much better, in fact, than I am. She never gets confused over her dates, and I always do. But when she does find me out, she makes no row at all. I sometimes wish she would…” – The Picture of Dorian Gray (for the 3rd time in 20 years).

and if we are talking about this subject you can’t go home without Kramer’s (Seinfeld) take:

 

Standard
Business, webdev

How To Build Your Next Mobile App? (Cleverly)

Why the current app stores are broken? Well, Apple was the first to recognize that the real our of their wonderful hardware (=iPhone) and great software (=iOS and all its components) is outside the company. It’s in the developers (how is counting them now?) that build amazing eco system on top of their app store. It’s not only ‘Angrey Bird’ but huge amount of apps (Netflix, Evernote, Pandora, Twitter, Facebook etc’) that give you a device that can do so much more then ‘just’ mobile phone.

Quite late, lots of other big forces join the party:

  • Chrome OS & Mozilla App Store with their HTML5 concept. You can see more and more HTML5 apps that give you the look & feel of a native app. The ability to have: local storage, drag&drop, audio, video etc’ in your hands is great.
    280 North was the first company that put it as a mission to bring the web app to a level of desktop (=native) apps. Their cappuccino framework is showing the power of javascript with modern browsers and real strong web developers behind it.
    Well, their projects show that the gap is closing fast. Moreover, you can see today, web apps like Gmail that give you more and more. Even on the mobile web-kit.
  • Android (Yes – the ‘java’ the Oracle is now taking them to court on) – it’s very similar to Objective C of Apple.
    The concept is that you get great tools to build apps.
    The main problem is that you need to be locked (just like in the iPhone world) to Android with your code.
  • Palm (Now HP) with phoneGap and the ability to ‘write once’ deploy anywhere. PhoneGap is an open source development framework for building cross-platform mobile apps. Build apps in HTML and JavaScript and still take advantage of core features in iPhone/iPod touch, iPad, Google Android, Palm, Symbian and Blackberry SDKs. Their goal is to give web developers (that know JS, CSS and HTML) the tools to ‘transform’ their apps to be native on different platforms. I haven’t play with it (yet) – but I’ll do it soon.

Here is a good explanation from Mozilla lab (=Pascal Finette) on why the current app stores are broken:

Enjoy and keep building mobile apps. One main point to keep in mind is the size that today seems to be all belong to Apple. I guess that in the near future, when will see Google iPads with Chrome OS, things will be different. Any way, it should be a world where like: Pandora apps, your apps are working every where: laptop, iPad, iPhone, Mobile, TV etc’

Standard
life, Sport

How To Run A Marathon?

Running on the beach with Amir

I’ve been doing a few marathons a year in the past three years, and I wish I had such a list before my first race. 

I could use it and avoid some of the common mistakes I made.

Tips for your next marathon:

Remember that the hard part was the training period. The primary hard part is all the long runs during the weekends alone or with a friend. Now (race day), you should enjoy as much as possible. So, relax. Yes, try to relax and apply what you know from your training. Eat what you regularly eat (I hope you know what bar makes you happy… do NOT try a new energy bar gel during the race day), drink what you like to drink during the runs, and wear the best gear you used. In a nutshell, try something other than new stuff during the race.

Please keep it simple and go with what you practiced.

Choose your ‘race partner‘ – this is one of the most important aspects (for me) of a good/successful race. After the first 4-5 miles, when you get into your pace, search for the one you think will go with you to the end (of the race). If you are lucky, you can find a partner, which improves the whole race.

Think about the next mile, which is only part of the race. It’s so much better to take (every project in life) step by step. You can break the race into 2,4,6,10 segments and think only about the next segment. It is a good feeling to ‘see’ your progress during the race.

Check out #2 and #1 – start slowly. No matter what, a girl/boy passes you without a visible effort.

It’s a common mistake. You should do what you practiced and know you will run faster during the race. Moreover, after 4-5 miles, you should be at your average ‘race pace’ and ‘race heart rate,’ so make sure to pace yourself. Don’t let your ego win – it will hunt you down around the 20-22 mile.

Adjust yourself and listen to your body. You can never know what the race will bring you. Sometimes, it’s 120F temperature (Tel Aviv Marathon), and sometimes, the climbs are crazy (each San Francisco marathon after 23 miles). Show up with a flexible game plan and adjust as needed because, in the end, it’s all about enjoying (or, for the experts – performing) your best on that day.

Have fun and be strong!

Standard
Business, life

Why the Future of Business is Sharing?

New tool set for web developersI’ve read “The Mesh: Why the Future of Business is Sharing” and it’s good reading (specailly, if you have 3h flight).

It outlines how the internet is driving radical new business models for companies with products. In essence, the latest location-based and smart phone apps allow us to access (expensive) products without having to own them. Think about the fact that, on average, you only drive your car one hour per day. What about those expensive tools you have sitting in your garage or handbags sitting in the closet. Written by serial entrepreneur Lisa Gansky, she co-founded Ofoto (sold to Kodak) and GNN (sold to AOL), Gansky is the first to name this important new trend in business. She points out that Huizenga used the same principle of purchasing a product and then renting it multiple times.

Want some more examples? here are just few:

  • Netflix – let you rent a library of DVDs that will cost you few millions to own.
  • Hilton/Hyyat and other hotels. They all let you do ‘time share’ and in their most basic business – they kind of ‘renting’ their properties piece by piece.
  • ZipCar – let you share cars and use them only when you DO need it. Very cool start up that I am hoping to see in more and more places.
  • Crushpad – wine-making services. I guess there are lots of avid wine fans that want to create their owe ‘grape juice’.
  • North Portland Tool Library – Why pay for a great tool and use it only twice (on a good case)? rent them…

I’m sure there are other examples for these type of business that can run today, significantly better, due to the usage of the internet and mobile apps.

The fact that people are aware to quality and wants it make these business even more interesting because they give the crowds an option to use and enjoy something that is not in their reach in any other way. We will see in the future lots of models like this… Specially, in places like India, Brazil and China.

Standard
Business, life

Agile – Getting Things Done and How TODO Stuff

Taking the right turns in your project

Taking the right turns in your project

Some good points from the last 3 years:

  • Describe the project in:
    A. The shortest way you can.
    B. The clearer way you are able.
  • Assign accountabilities – this is critical for the success so put time and effort behind this task. Ask yourself if the people you are putting accountable could deliver what you wish them in the quality/time you want it to be.
  • Document your fears – this list is something you want to check from time to time during the sprints (or short mile stones you put yourself).
  • Find shortcuts/edges – the only way to move like a ‘speed boat’ is to find these little ‘shortcuts’ that give you good tail wind.
  • Describe where you want to be in an ideal world when the project ends.  Then you should:
    A. Quantify `good enough’ – and make it clear when to ship it in that stage (you can/should always improve it in the next versions).
    B. Make it less – in lots of cases less is more and you want to remove stuff! It’s hard – but it will make your project better.
  • Thrash early – IF it seems you are moving (fast) in the wrong direction. This one is easy to say and very hard to do… so be AWARE.
  • Put ‘fire’ in all the people that contributing to the project. This wind tail will make the difference in the end of hard coding night.
  • Try to have fun along the way. It’s very important to enjoy the ride (if you can).
Standard