My family, books, photos, technology, language and some math משפחתי, ספרים, תמונות, טכנולוגיה, שפה, וקצת מתמטיקה
Monday, February 16, 2009
So, you want to learn about character encodings?
You might want to start with http://www.joelonsoftware.com/articles/Unicode.html and then start checking out the information at http://www.i18nguy.com/.
There's a very useful blog post on character encodings, their meaning and their representation, especially related to HTML and HTTP in the WHATWG blog. Check out the links mentioned in that blog post. They are very useful.
I found two books to be extremely useful when it comes to diving deeper into the subject, and especially whenh diving into Unicode workd of standards and specifications and their various implementations. The first is Unicode Demystified: A Practical Programmer's Guide to the Encoding Standard by Richard Gillam, which I reviewed a few years ago on Amazon. The second one is Unicode Explained by Jukka Korpela. If you're into Asian languages from the far east then a third book will be especially useful for you: CJKV Information Processing: Chinese, Japanese, Korean & Vietnamese Computing by Ken Lunde.
Happy reading!!
Thursday, January 22, 2009
F5, Tel-Aviv office employees, corporate pictures update

I took corporate pictures of some of the newer F5 employees and some updates of other employees yesterday. They are located with all the other pictures that I shot of the F5, Tel-Aviv office employees.
http://yeda.cs.technion.ac.il/~yona/f5_tlv/#21.1.2009
Thursday, January 15, 2009
JavaScript: The Good Parts by Douglas Crockford

I read JavaScript: The Good Parts by Douglas Crockford and learned a lot from it.
I feel that he makes very good points on his commentaries on the awful and bad parts of JavaScript and his suggestions to use a "good parts" subset of the language does seem to hold ground and increase quality and development time. At least, that is the case on the project that I'm working on that involves JavaScript. I seem to have fallen to just about all the pitfalls that he points out. Reading his book was a great comfort (I'm not the only one thinking that this or that aspect of the language stinks and for a good reason...) to me and his work-around suggestions do seem to be useful and practical. Along with other two very useful books on JavaScript: Bulletproof Ajax by Jeremy Keith (see my post on the book) and AJAX Security by Billy Hoffman and Bryan Sullyvan (see my post on this book too) I think that any developer that usews JavaScript can get a clear picture on the good sides and bad sides of JavaScript and clear understanding of the "do"s and the "don't"s and the implication of doing things one way or the other.
There are some mild typos in the book, that I'm sure will be corrected in future editions (e.g., pp.60: "... 'shi' has its key changed from '4' to '3'..." should be "... 'shi' has its key changed from '3' to '3'...", I believe).
Considering the fact that the author states several times that the book will avoid the bad parts and concentrate on the good parts, it is quite stressed in the book when bad parts are discussed, and some bad parts are repeatedly being mentioned and the implications of using them along with their proposed work around is also re-iterated (e.g., arguments list which is not really an Array object, or the fact that null is being identified as an object, and there are many more examples).
I liked a lot the "functional" approach, which I enjoy and like to use in many of my Perl scripts and programs, and I also use a lot in my JavaScript scripts and programs. I do find the "functional" way of doing things to be lighter and more straightforward than the classical object oriented approach that many advocate (which I don't really find very useful most of the time). For those that want a non lisp/scheme/haskell introduction to functional programming see a very nice Perl book that introduces functional programming: Higher Order Perl by Mark Jason Dominus (see my Amazon review on the book).
I really really enjoyed reading the book. I found the advise there very useful and I learned quite a lot of things about JavaScript.
I have reviewed this book on Amazon too.
Tuesday, January 13, 2009
A starting point for those interested to understand character encodings and their importance
http://www.i18nguy.com/ is a good place to find resources related to internationalization (i18n) and as a result it contains a lot of very useful information related to character encodings, their usage and implication of using and mostly misusing them.
Monday, January 12, 2009
How to UTF-8 encode/decode using core (client side) JavaScript functionality?
Don't go and implement the UTF-8 encoding and decoding yourself, as you can still use built in functionality:
var utf8 = {
encode: function(s){return unescape(encodeURIComponent(s));},
decode: function(s){return decodeURIComponent(escape(s));}
};
FireFox base64 encode/decode
If you want to decode a base64 encoded string in JavaScript under FireFox you can use the (somewhat undocumented method) atob().
Wednesday, December 3, 2008
HTML tags and their attributes with form parameter semantics
Tuesday, June 17, 2008
Generate all combinations of letters 'a'-something of length n
Here’s something that I was just asked this morning by a colleague who needed my help. I explained the solution and then wrote the program with the employee and finally we run it together on some possible input values to make sure that it does indeed do what we want. I think that makes a very good interview question. I tried to phrase it as an interview question with a few steps and some room for discussion:
You want to test a program that receives a string as input and a Boolean value (yes/no) as output.
The input string is some combinations of the characters ‘a’-‘e’ or length 4. For example ‘aaaa’ or ‘beed’
How would you test it?
An expected answer: Exhaustive search / brute force
· How would you implement a generator of such strings?
· How would you make sure that you don’t generate the same string more than once?
· How would you make sure that you don’t skip any possible string?
· How would you generalize your solution for some natural number n and any range within ‘a’-‘z’?
· Can you explain how many combinations are expected?
· How would you test your testing program?
· Say that your strings are now over Unicode (note size of character set), what would be the problems with your implementation?
· Suggest a strategy to solve your testing problem.
Here’s a C program that demonstrates a solution and allows testing the solution via the commandline:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
void getnext(unsigned char * a,int n,unsigned char k) {
int i;
for(i=n-1;i>=0;--i) {
++a[i];
if (a[i]<=k) {
break;
} else {
a[i]='a';
}
}
return;
}
/*
* input:
* n -- number -- length of string
* k -- letter -- maximum value?
*/
int main( int argc,char*argv[] ) {
int n=0;
unsigned char k=0;
int i=0;
unsigned char *a;
int max;
if (argc!=3)
return 1;
n = atoi(argv[1]);
k = argv[2][0];
if (NULL == (a=malloc(sizeof(unsigned char)*n+1))) {
exit (1);
}
a[n]='\0';
for(i=0;i<n;++i) {
a[i]= 'a';
}
max = (int)pow(k-'a'+1,n);
printf("%s\n",a);
for (i=0; i<max-1;i++){
getnext(a,n,k);
printf("%s\n",a);
}
return 0;
}
A step further up to complicate things would be something that I was once asked in an interview myself. Here’s a link to my blog where I wrote the question and a way to solve it. My solution there is in Perl:
http://shlomoyona.blogspot.com/2007/12/interview-question-next-permutation.html
Sunday, June 15, 2008
A Computational Introduction to Number Theory and Algebra
See: http://shoup.net/ntb/?
Saturday, June 14, 2008
Saturday, May 31, 2008
Monday, May 12, 2008
A simple game with surprising mathematical properties
2. If the number is odd, then multiply by 3 and add 1.
3. If the number is even, then divide by 2.
4. Repeat from 2 with the result
You get a series of number.
Apparently, all series ever tested end up with the number 1 (you can continue from there, of course).
If you begin a series with 1 you get a loop (get back to the number you started with). Apparently, this is the only loop ever discovered.
As a result all series have a repeating pattern from a certain point on: 4, 2, 1, 4, 2, 1.....
Mathematicians cannot seem to prove that no matter which number is used as the initial number you will end up with 1. They cannot find a counter example either.
Here are some series:
- 1, 4, 2, 1,...
- 2, 1, 4, 2, 1,...
- 3, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1,...
- 4, 2, 1, 4, 2, 1,...
- 5, 16, 8, 4, 2, 1, 4, 2, 1,...
- 6, 3, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1,...
- 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1,...
- 8, 4, 2, 1, 4, 2, 1,...
- 9, 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1,...
- 10, 5, 16, 8, 4, 2, 1, 4, 2, 1,...
- If we try an infinitely large number of numbers, what will we get more, jumps up (that is a step for an odd number) or slides down (that is a step for an even number)?
- How does the series of the length of series up to the first number 1 look like? Does this series have some special or surprising property?
