tag:blogger.com,1999:blog-50902081852642961592024-03-13T19:50:21.825+01:00Liad's little blogDevelopment solutions, algorithms, Data Science & Machine Learning explorationLiad Magenhttp://www.blogger.com/profile/10730284054602956057noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-5090208185264296159.post-38437132002078845932018-07-10T12:18:00.002+02:002018-07-11T18:41:26.218+02:00Analyzing Software Development using data science and analytic toolsYesterday I had the pleasure to host <a href="https://twitter.com/feststelltaste" target="_blank">Markus Harrer</a> who gave a talk about analyzing software code using data science, which he describe in details in his <a href="https://www.feststelltaste.de/" target="_blank">blog</a>.<br />
<br />
There is often a communication gap between software developers and management. While good developers can see the big picture of the code, and timely identify a need to restructure or even rewrite the code, they often miss to see the risks of both, time and cost, of such an operation.<br />
<br />
The management on the other hand, while being able to identify risks of getting into an adventure of rewriting a legacy system, often fail to understand the outcome and the risks of lack of maintenance.<br />
<br />
The solution to overcome this 'gap of ignorance' is communicating using data science and analytics. Using <a href="http://jupyter.org/" target="_blank">Jupyter</a> notebooks, for example, to combine both textual explanations as well as analytics and diagrams can easily communicate the risks of a software to the management.<br />
<br />
For using data science on software code, one should decide what are the purpose of the analysis, and which features should be chosen to analyze this target.<br />
<br />
The main targets that <a href="https://github.com/feststelltaste/software-analytics" target="_blank">Markus </a>was discussing were:<br />
<br />
<ul>
<li>Un-maintained code (old code)<br />Code that was not maintained more than 6 months, for example, is considered old. And as such, the company may be lacking the maintenance know-how of that modules.</li>
<li>Structure<br />By analyzing the connection between different objects or function calls, one can find 'dead' parts that are not being called and can be removed from the system.</li>
<li>Performance<br />By analyzing logs and execution timestamps, the bottlenecks of the software can be identified.</li>
</ul>
<div>
To illustrate these ideas, he had demonstrated it using <a href="http://jupyter.org/" target="_blank">Jupyter</a> notebook and python.</div>
<div>
<br /></div>
<h4>
<b>Old code</b></h4>
<div>
By retrieving all the commits of a project from GitHub, in his example it was Linux, as a CSV which contains the <i>user</i>, <i>timestamp</i>, <i>filename</i> and <i>line number</i>, and by using <a href="https://pandas.pydata.org/" target="_blank">Pandas</a> to analyze it, he demonstrated with simple group_by statements, how to find the top contributers, the most and least maintained files (and with simple string manipulations also modules/folders) and using the delta between the current date and the timestamp column - also the files and modules which were not updated recently.</div>
<div>
<br /></div>
<h4>
<b>Code Structure</b></h4>
<div>
For analyzing the structure, he used an automated tool to convert Java OO code to a <a href="https://en.wikipedia.org/wiki/Graph_database" target="_blank">graph DB</a> scheme (<a href="https://neo4j.com/" target="_blank">Neo4J</a>). Every class was represented as a node, and the relation between classes as an edge.</div>
<div>
<br /></div>
<div>
The same can be also done for Function-oriented programming, by converting a function invocation as en edge between two nodes (which represent the functions).</div>
<div>
<br /></div>
<div>
When the graph is ready, it is easy to analyze it using graph-theory algorithms, such as finding isolated islands (dead code), barebones (the nodes with the most edges), etc.</div>
<div>
<br /></div>
<h4>
Performance</h4>
<div>
To analyze the performance, he analyzed execution logs by converting them into a Graph as well. </div>
<div>
A similar approach for web development can be done by extracting the Performance execution from Chrome Developer's Tools, and converting it from a Tree to a Graph.</div>
<div>
<br /></div>
<div>
Since each of the function invocation includes a timestamp, it's easy to detect not only the heaviest functions, but also the heaviest function-chains, and tackle it later by code.</div>
<div>
<br />
<h4>
Interesting?</h4>
</div>
<div>
<div style="direction: ltr;">
For more information, please visit his <a href="https://www.feststelltaste.de/" target="_blank">blog</a> and his <a href="https://github.com/feststelltaste/software-analytics" target="_blank">github</a> repository for examples, the original talk slides are <a href="https://speakerdeck.com/feststelltaste/data-analysis-in-software-development-with-software-analytics-keepcurrentmeetup-vienna" target="_blank">here</a>, and feel free to feedback this post.</div>
</div>
<div>
<br />
Keep up with our <a href="https://www.meetup.com/WeAreDevelopers" target="_blank">meetups</a>, and we're also on <a href="https://www.facebook.com/KeepCurrentNow" target="_blank">facebook</a> and <a href="https://twitter.com/_keepcurrent" target="_blank">twitter</a>.</div>
<div>
<br /></div>
Liad Magenhttp://www.blogger.com/profile/10730284054602956057noreply@blogger.com0tag:blogger.com,1999:blog-5090208185264296159.post-51450050343115898552018-02-12T15:17:00.001+01:002018-02-14T15:14:14.268+01:00Natural Language Processing :: A beginner’s (brief) guide for working on NLP problems<div style="background-color: white; box-sizing: border-box; margin-bottom: 20px;">
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">This <a href="https://www.datasciencesociety.net/datathon/2018/02/09/a-beginners-brief-guide-for-working-on-nlp-problems/" target="_blank">article</a> was written for the Data Science Society's Datathon held on February 2018, as an answer to questions from the participants who were new to NLP.</span></div>
<div>
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 20px;">
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 20px;">
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 20px;">
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">The Data Science Society's <a href="https://www.datasciencesociety.net/datathon/">Datathon 2018</a>, presented us this time <a href="https://www.datasciencesociety.net/datathon/2018/02/04/the-identrics-case-automatically-tag-news-about-companies/">many</a> <a href="https://www.datasciencesociety.net/datathon/2018/02/04/the-ontotext-case-luke-i-am-your-father/">cases </a>which are Natural Language Processing <a href="https://www.datasciencesociety.net/datathon/2018/02/04/the-zencodeo-case-uniquely-identify-companies/">related</a>.</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 20px;">
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">One of the cases, for example, involves extracting entities' activities from unstructured documents, and determining their sentiment.</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 20px;">
<em style="box-sizing: border-box;"><span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;"><br /></span></em></div>
<h4 style="background-color: white; box-sizing: border-box; margin-bottom: 20px;">
<span style="box-sizing: border-box;"><span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">So, how should one begin working on such a problem?</span></span></h4>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 20px;">
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">First, let’s break this problem down:<br style="box-sizing: border-box;" />(1) we need to to detect which entities are mentioned in an article, and then (2) we need to detect the sentiment that is related, specifically to those entities.</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 20px;">
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">Let’s think about it logically for a moment: Entities are (normally) nouns, and in order to get the sentiment we will probably need to look at the adjectives that describe them, or the verbs that are related to them.</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 20px;">
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">So a first step could be (a) parsing the document into sentences, and then into words, and (b) determine the grammatical role of each word in the sentence, and determine (c) in which way these words are related to each other.</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 20px;">
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">Let’s start giving these actions names:</span></div>
<ul>
<li><span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">In NLP, documents are often referred as <em style="background-color: white; box-sizing: border-box;">corpus</em><span style="background-color: white;">, and the parsing process is referred as </span><em style="background-color: white; box-sizing: border-box;">preprocessing;</em></span></li>
<li><span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">Breaking up a corpus, as described in (a) is called <em style="background-color: white; box-sizing: border-box;">tokenizing</em><span style="background-color: white;">, while choosing the part of speech (</span><em style="background-color: white; box-sizing: border-box;">POS</em><span style="background-color: white;">) of a word is referred as </span><em style="background-color: white; box-sizing: border-box;">POS tagging;</em></span></li>
<li><span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">In order to determine the dependency of words in each other (c), the common way to represent it is as a tree (although some prefer to use a graph), and unsurprisingly it is called D<em style="background-color: white; box-sizing: border-box;">ependency Tree;</em></span></li>
<li><span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">The secondary level, i.e. subject, object, type of verbs and other semantics, is called <em style="background-color: white; box-sizing: border-box;">Semantic Role Labeling (SRL);</em></span></li>
<li><span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">Detecting that a specific word (an entity) is a name of a company/person/product, is called Named Entity Recognition (or <em style="background-color: white; box-sizing: border-box;">NER </em><span style="background-color: white;">since as you can see, we really love abbreviations)</span></span></li>
</ul>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 20px;">
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">There are <a href="http://www.nltk.org/" target="_blank">already</a> <a href="https://github.com/keon/awesome-nlp" target="_blank">many</a> <span style="box-sizing: border-box; transition: all 0.3s ease-in-out;"><a href="https://spacy.io/" target="_blank">tools</a> and <a href="https://stanfordnlp.github.io/CoreNLP/index.html" target="_blank">frameworks </a></span>out there that can do this job, and <a href="http://allennlp.org/models" target="_blank">even </a><a href="http://allennlp.org/models" target="_blank">more</a>, for you, i.e. tokenizing, tagging and parsing, and semantically labeling. A great place to start is the <a href="http://nltk.org/" target="_blank">nltk</a> library in Python, which besides offering the basic tools, also have a <a href="http://www.nltk.org/book/" target="_blank">great guide</a> for beginners. <a href="https://spacy.io/" target="_blank">Spacy</a> would give you even more power and speed for the above mentioned tasks.</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 20px;">
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">Nevertheless, it’s always encouraged to recombine, hack, tweak and change the current models in order to create a better model. This is often done by re-training a model, and for that one needs <a href="http://universaldependencies.org/u/dep/" target="_blank">a lot of </a><a href="http://universaldependencies.org/u/dep/" target="_blank">data</a>.</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 20px;">
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;"><span style="box-sizing: border-box;">Distributed R</span></span><span style="background-color: transparent;"><span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">epresentations of words, also called</span></span><em style="box-sizing: border-box; color: #444444; font-family: Arial, Helvetica, sans-serif;"> <a href="https://en.wikipedia.org/wiki/Word_embedding" target="_blank">Word embedding</a></em><span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">, is a process where the words in the sentence are being replaced by matching vectors. In order to do that, a neural-network based algorithm is first implemented on a big corpus, and through training, converts the words into vectors.</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 20px;">
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">Known algorithms in that field are <a href="https://www.tensorflow.org/tutorials/word2vec" style="background-color: transparent; box-sizing: border-box; text-decoration-line: none; transition: all 0.3s ease-in-out;">Word2vec</a>, <a href="https://nlp.stanford.edu/projects/glove/" style="background-color: transparent; box-sizing: border-box; text-decoration-line: none; transition: all 0.3s ease-in-out;">gloVe</a> and <a href="https://github.com/facebookresearch/fastText" style="background-color: transparent; box-sizing: border-box; text-decoration-line: none; transition: all 0.3s ease-in-out;">fasttext</a>. And as before, also here there are ready tools for using it, such as <a href="https://radimrehurek.com/gensim/" style="background-color: transparent; box-sizing: border-box; text-decoration-line: none; transition: all 0.3s ease-in-out;">gensim</a>, and others.</span></div>
<div style="background-color: white; box-sizing: border-box; direction: ltr; margin-bottom: 20px;">
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">In addition, as stated before, you can also re-train your own word representation, on your given corpus, in order to gain accuracy and specificity for the task you're tackling.</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 20px;">
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;">Before using these vectors for sentiment analysis, it’s important to remember that these representations are no more than semantic-representations. I.e. adjectives such as ‘good’ and ‘bad’ are represented by similar vectors, which have close/near representation in the vector space, distance-wise.</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 20px;">
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif;"><b>Where next?</b></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 20px;">
All these are merely the basics. Among places to check next are modeling algorithms such as deep-learning based models, for example CNN and BiLSTM (bi-directional LSTM).<br />
<br />
And if you are interested to get deeper into NLP, which in my opinion is a fascinating topic(!), check out these great links:<br />
<a href="https://tryolabs.com/blog/2017/12/12/deep-learning-for-nlp-advancements-and-trends-in-2017/">https://tryolabs.com/blog/2017/12/12/deep-learning-for-nlp-advancements-and-trends-in-2017/</a><br />
<br />
A discussion regarding different approaches for semantic parsing through semantic composition:<br />
<a href="http://www.xiaodanzhu.com/publications/deep_learning_composition.pdf">http://www.xiaodanzhu.com/publications/deep_learning_composition.pdf</a><br />
<br />
<br />
<br />
<br /></div>
Liad Magenhttp://www.blogger.com/profile/10730284054602956057noreply@blogger.com0tag:blogger.com,1999:blog-5090208185264296159.post-76549454725354785662018-02-03T17:23:00.000+01:002018-02-08T22:45:42.206+01:00NLP Toolkit (Made for self use - but feel free to use it too :) )A list of tools for NLP tasks.<br />
Done mostly for self-reference... hence quite brief.<br />
<br />
Better lists can be found out there:<br />
<a href="https://github.com/keon/awesome-nlp">https://github.com/keon/awesome-nlp</a><br />
<br />
<div>
<br /></div>
<div>
<a href="http://scikit-learn.org/stable/modules/classes.html#module-sklearn.feature_extraction.text">SciPy </a>(<span style="background-color: #f7f7f7; color: blue; font-size: 14px; font-weight: bold; white-space: pre-wrap;">sklearn.feature_extraction.text</span>)</div>
<div>
<div style="background-color: #f7f7f7; border-radius: 4px; border: none; color: #333333; font-size: 14px; line-height: inherit; padding: 0px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;">
</div>
<ul>
<li><span style="font-family: "courier new" , "courier" , monospace;">CountVectorizer </span>- converting text to token-counts matrix (n-grams co-reference) which is then used by:</li>
<li><span style="font-family: "courier new" , "courier" , monospace;">TfidfTransformer </span>- transforms a count-matrix (<span style="font-family: "courier new" , "courier" , monospace;">CountVectorizer</span> output) to term-frequency or inverse document frequency (TF-IDF)</li>
</ul>
<div>
<a href="http://www.nltk.org/">NLTK</a></div>
</div>
<div>
<ul>
<li>Corpus reader - Words tokenization</li>
<li>POS</li>
<li>Chunking</li>
<li>Stemming</li>
<li>Creating parse trees out of sentences</li>
<li>Using KnowledgeBases (FrameNet, WordNet, propBank)</li>
<li>Different implementation for tagging (Senna, Stanford)</li>
</ul>
</div>
<div>
<a href="https://spacy.io/">Spacy</a></div>
<div>
<ul>
<li>Corpus reader - Tokenization</li>
<li>NER, POS</li>
<li>Semantic representation (Word Vectors)</li>
<li>Labeled dependency parsing</li>
</ul>
</div>
<div>
<a href="https://radimrehurek.com/gensim/index.html">Gensim</a>:<br />
<br />
<ul>
<li>Corpus reader / parser</li>
<li>transofrmations (TF-IDF, LSA, LDA, HDP)</li>
<li>Similarity Queries</li>
<li>Topic segmentation (LDA, LSA)</li>
</ul>
<div>
<a href="http://allennlp.org/">AllenNLP</a></div>
<div>
<ul>
<li>High-level trained models</li>
<li>Machine comprehension (QA based on given text)</li>
<li>Coreference Resolution (who/what does 'it', 'they' refers to)</li>
<li>NER</li>
<li>SRL </li>
<li>Textual Entailment (similar to topic segmentation and similarity queries combined)</li>
</ul>
<div>
<br />
<a href="https://github.com/OpenNMT/OpenNMT-tf">openNMT</a><br />
<br />
<ul>
<li>Seq2seq mapping (Encoder - Decoder for translations)</li>
<li>Tagging</li>
<li>Classification</li>
<li>Also includes built-in WordEmbedder, Tokenizer</li>
<li>Based on Tensorflow</li>
</ul>
<div>
<br /></div>
<div>
<a href="https://github.com/EdinburghNLP/nematus">Nematus</a></div>
<div>
<ul>
<li>Attention-based encoder-decoder (machine translation)</li>
<li>Based on Theano through <a href="https://github.com/nyu-dl/dl4mt-tutorial">dl4mt tutorial</a></li>
</ul>
</div>
<br />
Corpus<br />
<a href="http://universaldependencies.org/">http://universaldependencies.org</a> (github repository: <a href="https://github.com/UniversalDependencies">https://github.com/UniversalDependencies</a>)<br />
<a href="https://github.com/nlp-compromise/nlp-corpus">https://github.com/nlp-compromise/nlp-corpus</a> (different categories)<br />
<br />
<br />
GPU-based services to train and run models:<br />
<br />
<ul>
<li><a href="https://www.floydhub.com/">FloydHub</a> (2h GPU, 20h CPU, 10GB)</li>
<li><a href="https://www.paperspace.com/&R=9BA2ZG6">PaperSpace</a> (10$ credit - monthly costs start with 5$ for 50GB storage and 0.07$ per hour)</li>
<li><a href="http://kaggle.com/">Kaggle</a> (Free - Good for small, short-time training; execution are killed after ~5h; includes many cleaned datasets)</li>
</ul>
</div>
</div>
</div>
Liad Magenhttp://www.blogger.com/profile/10730284054602956057noreply@blogger.com0tag:blogger.com,1999:blog-5090208185264296159.post-70698014071566792442017-07-21T14:16:00.005+02:002017-10-17T11:45:13.307+02:00pip install pymssql fails with 'sqlfront.h': No such file or directoryI've tried to install pymssql on Windows using command line:<br />
<span style="background-color: #f3f3f3; font-family: "courier new" , "courier" , monospace;">pip install pymssql</span><br />
<br />
The operation fails with an error:<br />
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 11.9px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 11.9px; line-height: inherit; margin: 0px; overflow: visible; padding: 0px; word-break: normal; word-wrap: normal;">fatal error C1083: Cannot open include file: 'sqlfront.h': No such file or directory</code></pre>
<br />
while looking for a solution, the <a href="https://github.com/pymssql/pymssql/issues/422">first results</a> are not really helpful, until you arrive to <a href="https://github.com/pymssql/pymssql/issues/439">this helpful one</a>.<br />
<br />
In short: I was using python version 3.6, which currently isn't supported with pymssql.<br />
Using python 3.5 instead solves that issue, and the <span style="background-color: #f3f3f3;">pip install pymssql</span> runs well.<br />
<br />
If you're using <i>Anaconda Navigator</i>, it is made even simpler:<br />
In the <i>Environment </i>section, you can add a new environment with your choice of python version. When you're choosing a supported version - 3.5 for example - you will find the <b>pymssql</b> in the packages list and install it from there directly.<br />
<br />Liad Magenhttp://www.blogger.com/profile/10730284054602956057noreply@blogger.com0tag:blogger.com,1999:blog-5090208185264296159.post-40990056070312584862015-01-09T17:37:00.000+01:002017-07-21T14:02:07.075+02:00AngularJS Directive: Accessing an DOM element with a dynamic ID in an asynchronous directive Hi,<br />
<br />
This problem was really bothering me for few months. In earlier cases I tried to avoid it, but today I could not hide from it any longer. And the thing is that there was no post on any other place that could solve this matter... So here it goes.<br />
<br />
You're writing a directive in <a href="https://angularjs.org/">AngularJS</a>, and you want to access one of the DOM elements declared within its template.<br />
Usually you do it through the linking function (post section in the compile) or in the directive controller, by injecting and using '$element', as explained <a href="https://docs.angularjs.org/api/ng/service/$compile">here</a>.<br />
<br />
But, in my case, I had to access an element using its ID and this ID was dynamic.<br />
<br />
So, my template contains:<br />
<br />
<br />
<div>
</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: white; color: maroon; font-family: "consolas"; font-size: 9.5pt;">div</span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: white; font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: white; color: maroon; font-family: "consolas"; font-size: 9.5pt;">div</span><span style="background: white; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">ng-attr-id</span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">="{{ 'something_' + dynamicValue
}}"></</span><span style="background: white; color: maroon; font-family: "consolas"; font-size: 9.5pt;">div</span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: white; font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;"></</span><span style="background: white; color: maroon; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">div</span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">></span><o:p></o:p></div>
</div>
<div class="MsoNormal">
<o:p></o:p></div>
<br />
And my directive contains:<br />
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;"> templateURL: </span><span style="background: white; color: #a31515; font-family: "consolas"; font-size: 9.5pt;">'pathToTempalte'</span><span style="background: white; font-family: "consolas"; font-size: 9.5pt;">,<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;"> scope: {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;">
dynamicValue: </span><span style="background: white; color: #a31515; font-family: "consolas"; font-size: 9.5pt;">'@'</span><span style="background: white; font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;"> },<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;"> link: </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">function</span><span style="background: white; font-family: "consolas"; font-size: 9.5pt;">(scope, element, attributes) {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;">
attributes.$observe(</span><span style="background: white; color: #a31515; font-family: "consolas"; font-size: 9.5pt;">'dynamicValue'</span><span style="background: white; font-family: "consolas"; font-size: 9.5pt;">, </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">function</span><span style="background: white; font-family: "consolas"; font-size: 9.5pt;">(value) {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;"> element.find(</span><span style="background: white; color: #a31515; font-family: "consolas"; font-size: 9.5pt;">'#something_'</span><span style="background: white; font-family: "consolas"; font-size: 9.5pt;"> + value);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;"> });<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;"> }</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">}</span></div>
<div class="MsoNormal">
<o:p></o:p></div>
<br />
The element.find doesn't work, because nothing is actually compiled and rendered yet here.<!------><!------><br />
<br />
The solution, at the moment, is to use ''<span style="background: white; color: #a31515; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">$timeout</span>".<br />
<br />
<span style="background-color: white; color: #a31515; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">$timeout</span>, even with '<span style="background: white; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">1</span>' as a parameter, will only be executed after everything has been rendered, and outside of the asynchronous scope. Therefore using <span style="background-color: white; font-family: "consolas"; font-size: 12.6666669845581px;">element.find</span> inside its function, will deliver the expected result:<br />
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;"> templateURL: </span><span style="background: white; color: #a31515; font-family: "consolas"; font-size: 9.5pt;">'pathToTempalte'</span><span style="background: white; font-family: "consolas"; font-size: 9.5pt;">,<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;"> scope: {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;">
dynamicValue: </span><span style="background: white; color: #a31515; font-family: "consolas"; font-size: 9.5pt;">'@'</span><span style="background: white; font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;"> },<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;"> link: </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">function</span><span style="background: white; font-family: "consolas"; font-size: 9.5pt;">(scope, element, attributes) {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;">
attributes.$observe(</span><span style="background: white; color: #a31515; font-family: "consolas"; font-size: 9.5pt;">'dynamicValue'</span><span style="background: white; font-family: "consolas"; font-size: 9.5pt;">, </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">function</span><span style="background: white; font-family: "consolas"; font-size: 9.5pt;">(value) {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;">
$timeout(</span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">function</span><span style="background: white; font-family: "consolas"; font-size: 9.5pt;">() {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;">
element.find(</span><span style="background: white; color: #a31515; font-family: "consolas"; font-size: 9.5pt;">'#something_'</span><span style="background: white; font-family: "consolas"; font-size: 9.5pt;"> + value);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;"> }, 1);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;"> });<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<br />
<div class="MsoNormal">
<span style="background: white; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">}</span><o:p></o:p></div>
<br />
Happy codingLiad Magenhttp://www.blogger.com/profile/10730284054602956057noreply@blogger.com0tag:blogger.com,1999:blog-5090208185264296159.post-70485645871430734602013-01-18T01:19:00.001+01:002013-01-18T01:19:41.851+01:00A guide for modeling a graph database - A lunch with Neo4J chief scientist Jim Webber, LondonSince the invention of NOSQL databases, it gets more and more attention from the developer community. One of the remarkable and unique databases exists in this topic of NOSQL is the graph database of NEO4J, an open-source database which stores the data as a Graph.<br />
<br />
Modeling a graph database is quite different than modeling the regular RDBMS database, and even from other NOSQL databases such as key-value collections. We got used to identifying the molecularity of the data and save it as the columns, joining similar data together into tables. But since Neo4J is a flexible graph database, this case does not work there.<br />
<br />
In order to model the data, we need to identify first the queries that we're about to run on the database. These queries will form the basic logical sentences which are the keys of modeling the database (more about that coming up in a second).<br />
<br />
We need to identify where to store each piece of information:<br />
- as a <b>node</b><br />
- as an <b>edge</b><br />
- as a <b>property</b> of a node or of an edge<br />
<br />
Nodes should store items of information, nouns: Users, Receipts, Comment, Document.<br />
The edges should store relation-items that forms a verb: <i>Created by</i>, <i>Voted By</i>, <i>IS the son of</i>, etc.<br />
Properties are an additional description for either nodes or edges. You should put as a property the data that does not need to be related. if we look at the information as a sentence - the properties are the adjectives.<br />
<br />
So, nodes and edges (and properties) should create a logical sentence as part of the modeling:<br />
<blockquote class="tr_bq">
<i>User A</i> VOTED_YES on <i>Question Q</i></blockquote>
This sentence creates the model for us:<br />
[User (<span style="color: blue;">name=A</span>)] -- <span style="color: #38761d;">VOTED_YES</span> --> [Question (<span style="color: blue;">content=Q</span>)]<br />
<br />
Where User and Question are nodes. Each of which has properties that describe it (user name, question content/title).<br />
Pay specific attention to VOTED_YES edge.<br />
We could have chosen VOTED (vote_data = 'yes') where we have an edge of VOTED and the content is its property. Why didn't we model it so?<br />
<br />
Jim Webber, the chief scientist of NEO4J explains: Performance-wise, it's better to create granularity in the model. So that each of these votes is a unique type of an edge.<br />
And what if we want to collect all the votes for a specific question? We can create an Index for the vote, and easily find all the votes in the index that are pointing to a specific question.<br />
<br />
__ to be continued __<br />
<br />Liad Magenhttp://www.blogger.com/profile/10730284054602956057noreply@blogger.com0tag:blogger.com,1999:blog-5090208185264296159.post-26148330228505315722012-08-06T19:32:00.002+02:002012-08-06T19:32:54.935+02:00Javascript, animation and easing functionsI recently had to create an animation, which obey to the laws of physics, using javascript and HTML5.<br />
<br />
Among the gravity and free falling, one of these animations had to also apply sort of bouncing and elastic laws.<br />
<br />
After creating it first with CSS3 and HTML, we realized that most of the Android devices does not support it fully yet. Especially versions prior to Ice Cream Sandwich, such as Android 2.1, 2.2, 2.3 and lower (Froyo and its siblings).<br />
<br />
So, I had to transfer everything into HTML5 Canvas, and instead of applying the css-transitions, I had to implements everything alone.<br />
<br />
The first website I encountered and would like to highly recommend is Timothee Groleau's easing generator which can be found <a href="http://timotheegroleau.com/Flash/experiments/easing_function_generator.htm">here</a>:<br />
<a href="http://timotheegroleau.com/Flash/experiments/easing_function_generator.htm">http://timotheegroleau.com/Flash/experiments/easing_function_generator.htm</a><br />
<br />
Originally made for Flash - but can easily adopted to Javascript HTML5 too.<br />
<br />
The output of his generator is basically a function describes a certain movement of an object.<br />
Such movement may be physical movement on either X/Y/Z axis, or even the rotation degree of an object.<br />
<br />
The function takes 4 parameters:<br />
<br />
<span style="color: blue;">t</span> - the current time of the animation (starts with 0 and in every frame has to be increased in 1/num_of_frames_per_second). make sure that if you work in Milliseconds - t has to be that too.<br />
<br />
<span style="color: blue;">b</span> - the initial parameter (of the x/y/z axis, the rotation degree/radians etc.)<br />
<br />
<span style="color: blue;">c</span> - the target (of the same x/y/z axis or the rotation degrees)<br />
<br />
<span style="color: blue;">d</span> - total time for this process - again, like the t, has to be at the same time-unit, and personally - I recommend working with milliseconds.<br />
<br />
the output of the function is the current value of your object at the specific <span style="color: blue;">t</span>.<br />
<br />
as for drawing, especially for 3d objects, there are already-made frameworks that can be used for this purpose such as Three.js and k3d.<br />
<br />
one last word - nearly every physical action has a formula to describe it. use the generator to find it instead of too many if's ... :)<br />
<br />
<br />Liad Magenhttp://www.blogger.com/profile/10730284054602956057noreply@blogger.com0tag:blogger.com,1999:blog-5090208185264296159.post-59067459751123057652012-01-10T15:56:00.000+01:002012-01-10T16:10:58.379+01:00TreePanel generated from TreeStore<span >Apparently, generating a treePanel from a treeStore is not 'out-of-the-box' like generating a grid or even generating tree from static json in Ext-JS.<br /><br />In addition, at the moment there are not a many examples out there that explains how it should be done. Most of the examples are using a static JSON (memory). But what if you are using a store with an already-made JSON which you need to customize to be a tree?<br /><br /><span style="font-weight: bold; ">listeners to the rescue</span><br />The way to make it happen, is to alter the store a bit.</span><div><span >we start by defining a store as usual:</span></div><span ><br /></span><blockquote><span ><br /></span><div><span ><div>Ext.define('MyTreeStore', {</div><div> extend: 'Ext.data.TreeStore',</div><div><br /></div><div><div>config: {</div><div> someConfig: 0</div><div> },</div></div><div><br /></div><div><div>constructor: function (cfg) {</div><div> var me = this;</div><div><br /></div><div> cfg = cfg || {};</div></div><div><div> me.callParent([Ext.apply({</div><div> autoLoad: true,</div><div> storeId: 'MyTreeStoreID',</div><div> root: {</div><div> expanded: true</div><div> },</div><div> proxy: {</div><div> type: 'rest',</div><div> url: 'http://website/JsonGenerator.php'</div><div> extraParams: { </div><div> someCoolConfig: 1</div><div> },</div><div> reader: {</div><div> type: 'json'</div><div> },</div><div> // Don't want proxy to include these params in request</div><div> pageParam: undefined,</div><div> startParam: undefined</div><div> },</div><div> fields: ['JSONField_ID', 'JSONField_NAME'],</div><div><br /></div><div><span class="Apple-tab-span" style="white-space:pre"> </span> // ------------------------------------------------------------------------</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> // this is the important part:</div><div><br /></div><div> <b>listeners: {</b></div><div><b><span class="Apple-tab-span" style="white-space:pre"> </span>append: function (thisNode, newChildNode, index, eOpts) {</b></div><div><b><span class="Apple-tab-span" style="white-space:pre"> </span>if (!newChildNode.isRoot()) {</b></div><div><b><span class="Apple-tab-span" style="white-space:pre"> </span>newChildNode.set('leaf', true);</b></div><div><b><span class="Apple-tab-span" style="white-space:pre"> </span>newChildNode.set('text', <span class="Apple-tab-span" style="white-space:pre"> </span>newChildNode.get('JSONField_NAME'));</b></div><div><b><span class="Apple-tab-span" style="white-space:pre"> </span>}</b></div><div><b><span class="Apple-tab-span" style="white-space:pre"> </span>}</b></div><div><b> }</b></div><div><br /></div><div><div><span class="Apple-tab-span" style="white-space: pre; "> </span> // ------------------------------------------------------------------------ </div></div><div><br /></div><div> }, cfg)]);</div><div> }</div></div><div>});</div></span><br /></div></blockquote>Liad Magenhttp://www.blogger.com/profile/10730284054602956057noreply@blogger.com0tag:blogger.com,1999:blog-5090208185264296159.post-62149970050030831662012-01-01T17:05:00.000+01:002012-01-01T17:23:30.314+01:00C#, Entity Framework, WCF and JSON serializationEver tried to serialize Entity Framework with WCF?<br />Have you tried it with the Lazy-Initialization feature?<br />And how about the Proxy Creation Enabled?<br /><br />There's a problem of circular reference if one table is referencing another table - which referencing the first one.<br /><br />We have had a great deal of problems with it. We even tried to consult an external expert of Entity Framework who simply told us it's impossible to serialize it on WCF.<br />oh darn... :(<br /><br />We tried many solutions before we gave up:<br />like that one:<br /><a href="http://geekswithblogs.net/danemorgridge/archive/2010/05/04/entity-framework-4-wcf-amp-lazy-loading-tip.aspx">http://geekswithblogs.net/danemorgridge/archive/2010/05/04/entity-framework-4-wcf-amp-lazy-loading-tip.aspx</a><br /><br />and that:<br /><a href="http://blogs.microsoft.co.il/blogs/gilf/archive/2011/10/17/avoiding-circular-reference-for-entity-in-json-serialization.aspx">http://blogs.microsoft.co.il/blogs/gilf/archive/2011/10/17/avoiding-circular-reference-for-entity-in-json-serialization.aspx</a><br /><br />We even used t4templates to create a whole new set of flattened objects (!!!)<br />But it doesn't really make life easier as one has to load separately each and every object.<br /><br />But this was not what we were looking for. We needed a solution that finds the spanning tree of a graph and serializing it into JSON.<br /><br />Eventually the solution unexpectedly arise in the form of the open source JSON Serialization for .NET:<br /><a href="http://json.codeplex.com/">http://json.codeplex.com/</a><br /><br />One of the features of this excellent util is to keep track of the objects which were already serialized in order not to re-serialize it again.<br />I was ready to implement it myself as I found out it already exists - which saved me a lot of time and work.<br /><br />So, I would like to thank these guys who made this excellent code.Liad Magenhttp://www.blogger.com/profile/10730284054602956057noreply@blogger.com1tag:blogger.com,1999:blog-5090208185264296159.post-56039544163132433132012-01-01T16:59:00.000+01:002012-01-01T17:04:39.048+01:00ExtJS 4.0 - Class system, object inheritance and configRecently we've started using the new Ext-JS 4.0 class system.<br /><br />one of the obstacles I came across with was using the configuration while making inheritance.<br /><br />On most of the examples in the web - it works seamlessly perfect.<br />but what happens when you try to extend an existing object?<br />for example, 'Ext.panel.Panel' ?<br /><br />Suddenly - weird stuff happens and it doesn't work any longer.<br /><br />So for example:<br /><blockquote>Ext.define('ProductionMap.popup.serverExplorer', {<br /> extend: 'Ext.panel.Panel',<br /><br /> config: {<br /> ParameterConfig: '',<br /> },<br /><br /> constructor: function (cfg) {<br /> this.initConfig(config);<br /> return this;<br /> }, <br /><br /> initComponent: function () {<br />...<br /> }</blockquote><br /><br />will give an error.<br />took me an hour to figure it out - but I found the solution and it's REALLY simple.<br />It's all about the constructor:<br />instead of that code, use:<br /><br /><blockquote>constructor: function (cfg) {<br /> this.initConfig(config);<br /> <span style="font-weight:bold;">this.callParent([config]);</span><br /> return this;<br /> },</blockquote><br /><br />and kaboom - works like a charm :)<br /><br />LiadLiad Magenhttp://www.blogger.com/profile/10730284054602956057noreply@blogger.com0tag:blogger.com,1999:blog-5090208185264296159.post-61932904999515213142011-03-08T10:45:00.000+01:002011-03-08T12:07:46.140+01:00Charts, JSON and ExtJS<div><span class="Apple-style-span">A bit late, I admit, but finally I've started using Sencha's ExtJS framework.</span></div><span class="Apple-style-span"><br /></span><div><span class="Apple-style-span">The first project I was executing was involving charts with JSON data loaded from a C# ASP.NET WCF service.</span></div><span class="Apple-style-span"><br /><br /></span><div><span class="Apple-style-span">I have encountered several problems and a lack of proper documentation. Many of the solutions were finally found in another websites and forums but there was no blog post I have found that had everything together in one example.</span></div><span class="Apple-style-span"><br /><br /></span><div><span class="Apple-style-span">So I'm proud to be one of the first who does that. I will also describe the problems I've encountered and of course - the solutions.</span></div><span class="Apple-style-span"><br /><br /></span><div><span class="Apple-style-span">In ExtJS, the code is created in </span><span class="Apple-style-span">Windows</span><span class="Apple-style-span">, </span><span class="Apple-style-span">Panels</span><span class="Apple-style-span" style="font-family: georgia; "> </span><span class="Apple-style-span">or </span><span class="Apple-style-span">Forms</span><span class="Apple-style-span">. The latter, </span><span class="Apple-style-span">Form</span><span class="Apple-style-span">, can not be added to Asp.net page as it regenerates a </span><span class="Apple-style-span" style="font-family: courier;"><form></span><span class="Apple-style-span"> tag, which can not be placed under the already-generated </span><span style="font-family: courier; "><form runat="'server'"></span><span class="Apple-style-span"> of the asp.net.</span></div><span class="Apple-style-span"><br /><br /></span><div><span class="Apple-style-span">I've used the <span class="Apple-style-span">Ext.Panel</span> then, in an external JS file, like so:</span></div><span class="Apple-style-span"><br /></span><div><span style="font-family: courier;">Ext.onReady(function () {</span></div><div><span style="font-family: courier;">var myPanel = new Ext.Panel({ });</span></div><span class="Apple-style-span"><br /></span><div><span style="font-family: courier;">});</span></div><span class="Apple-style-span"><br /><br /></span><div><span class="Apple-style-span">inside the panel, among the rest of the properties we're placing the items:</span></div><span class="Apple-style-span"><br /></span><div><span style="font-family: courier;">var myPanel = new Ext.Panel({</span></div><div><span class="Apple-style-span">items: [ ... ]</span></div><span class="Apple-style-span"><br /></span><div><span style="font-family: courier;">});</span></div><span class="Apple-style-span"><br /><br /></span><div><span class="Apple-style-span">In order to render it, we create in the html page a <span style="font-family: courier;"><div> </span>with a certain ID, in which we render the panel into it:</span></div><span class="Apple-style-span"><br /></span><div><span style="font-family: courier;">myPanel.render('MainPanel');</span></div><span class="Apple-style-span"><br /><br /></span><div><span class="Apple-style-span">which renders it into:</span></div><span class="Apple-style-span"><br /></span><div><span style="font-family: courier;" ><div id="MainPanel"></div></span></div><span class="Apple-style-span"><br /></span><div><span class="Apple-style-span">In the ASP.NET page itself.</span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span">So far, so good.</span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span">But the YUI charts were the complicated part.</span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span">Regardless the type of the chart (Pie, Bars, Columns, Line etc.), and like everything in life, every chart consists of 3 parts:</span></div><div><span class="Apple-style-span" style="font-family: georgia; ">The data (</span><span class="Apple-style-span">Store</span><span class="Apple-style-span" style="font-family: georgia; ">)</span></div><div><span class="Apple-style-span" style="font-family: georgia; ">The data type (</span><span class="Apple-style-span">Record</span><span class="Apple-style-span" style="font-family: georgia; ">)</span></div><div><span class="Apple-style-span" style="font-family: georgia; ">and the style (</span><span class="Apple-style-span">Chart</span><span class="Apple-style-span" style="font-family: georgia; ">)</span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span">The Store is responsible for the data itself. It can hold array of items, of data - like EVERY example on the web...</span></div><div><span class="Apple-style-span">But it can also load it dynamically from another service, like my WCF JSON service.</span></div><div><span class="Apple-style-span"><br /></span></div><div><div><span style="font-family: courier;">var store = new Ext.data.JsonStore({</span></div><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>autoLoad: true,</span></div><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>proxy: new Ext.data.HttpProxy({</span></div><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>url: 'Services/Service.svc/GetJSONData',</span></div><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>method: 'GET',</span></div><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>restful: true</span></div><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>}),</span></div><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>sortInfo: {</span></div><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>field: 'Order',</span></div><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>direction: 'ASC' </span></div><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>or 'DESC' (case sensitive for local sorting)</span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>},</span></div><div><span class="Apple-style-span"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>storeId: 'myStore',</span><span class="Apple-style-span"> </span></span></div></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>The Store also defines the Record (type of the data itself):</span></div><div><span class="Apple-style-span"><br /></span></div><div><div><span class="Apple-tab-span" style="white-space: pre; font-family: georgia; "><span class="Apple-tab-span" style="white-space:pre"> </span> </span><span class="Apple-style-span">// reader configs</span></div><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>root: 'd',</span></div><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>idProperty: 'Id',</span></div><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>fields: [{ name: 'Id', mapping: 'Id', type: 'int' },</span></div><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>{ name: 'OrderId', mapping: 'OrderId', type: 'int' },</span></div><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>{ name: 'Field', mapping: 'Field', type: 'int'}]</span></div><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"> </span>});</span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span" style="font-family: georgia; ">What I found confusing in loading the data form an external source was actually the proxy. The correct form of using it is using the </span><span class="Apple-style-span">Ext.data.HttpProxy</span><span class="Apple-style-span" style="font-family: georgia; "> </span><span class="Apple-style-span" style="font-size: medium; font-family: georgia; ">While I have used at first the </span><span class="Apple-style-span">Ext.data.DataProxy</span><span class="Apple-style-span" style="font-family: georgia; ">, which gave as a result a JS error of '</span><span class="Apple-style-span" style="font-family: georgia; ">this.load is not a function</span><span class="Apple-style-span" style="font-family: georgia; ">'.</span></div></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span"><span class="Apple-style-span">So after the Store problem was solved and I was finally calling the service and getting back my data, I needed to create the chart itself inside the </span><span class="Apple-style-span">items</span><span class="Apple-style-span"> part of the </span><span class="Apple-style-span">Panel</span><span class="Apple-style-span">.</span></span></div><div><span class="Apple-style-span">As this part is a bit more document, I'll still emphasize one aspect.</span></div><div><span class="Apple-style-span">The basic usage is</span></div><div><div><span class="Apple-style-span">{</span></div><div><span class="Apple-style-span"> store: store,</span></div><div><span class="Apple-style-span"> height: 100,</span></div><div><span class="Apple-style-span"> xtype: 'columnchart',</span></div><div><span class="Apple-style-span"> xField: 'Id',</span></div><div><span class="Apple-style-span"> yField: 'Field'</span></div><div><span class="Apple-style-span">}</span></div></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span"><span class="Apple-style-span">But, If you want to add more bars, or graphs - omit the </span><span class="Apple-style-span">yField </span><span class="Apple-style-span">part and use instead the '</span><span class="Apple-style-span">series</span><span class="Apple-style-span">' property:</span></span></div><div><span class="Apple-style-span"><div><span class="Apple-style-span">{</span></div><div><span class="Apple-style-span"> store: store,</span></div><div><span class="Apple-style-span"> height: 100,</span></div><div><span class="Apple-style-span"> xtype: 'columnchart',</span></div><div><span class="Apple-style-span"> xField: 'Id',</span></div><div><span class="Apple-style-span"> series: [</span><span class="Apple-style-span">{</span></div><div><span class="Apple-style-span"><div><span class="Apple-tab-span" style="white-space:pre"> </span>displayName: 'name',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>yField: 'Field1',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>fillColor: '0x0000FF',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>style: {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>image: 'bar.gif',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>mode: 'stretch',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>color: '0x0000FF'</div><div> <span class="Apple-tab-span" style="white-space:pre"><span class="Apple-tab-span" style="white-space:pre"> </span> </span> }</div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-tab-span" style="white-space:pre"> </span> </span> },</div><div><span class="Apple-style-span"><div><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-tab-span" style="white-space:pre"> </span> </span> {</span></div><div><span class="Apple-style-span"><div><span class="Apple-tab-span" style="white-space:pre"> </span>displayName: 'name',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>yField: 'Field2',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>fillColor: '0x0000FF',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>style: {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>image: 'bar.gif',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>mode: 'stretch',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>color: '0x0000FF'</div><div> <span class="Apple-tab-span" style="white-space:pre"><span class="Apple-tab-span" style="white-space:pre"> </span> </span> }</div></span></div></span></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-tab-span" style="white-space:pre"> </span>]</span></span>}</div></span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span">I sure hope it was helpful, and I would be delighted to assist or answer questions if needed.</span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span">Happy coding</span></div><div><span class="Apple-style-span">Liad</span></div>Liad Magenhttp://www.blogger.com/profile/10730284054602956057noreply@blogger.com2tag:blogger.com,1999:blog-5090208185264296159.post-83998593746225010182010-12-15T16:32:00.000+01:002010-12-15T17:50:55.235+01:00Image Resizing & Cropping on the fly in .NET - high qualityWhile developing a CMS for small gallery websites, I decided to store only the original uploaded image and not to create a thumbnail upon uploading.<div>I didn't want, of course, to use the html resizing feature, especially not while uploading high res images.</div><div><br /></div><div>Instead, I created a generic handler that creates the thumbnail image on the fly.</div><div><br /></div><div>Not only this handler knows how to resize the image, but also to crop it, in case I want all the images to be on a fixed ratio of width and height.</div><div><br /></div><div>So, how is it done? </div><div>There are many blog posts of resizing images on the fly.</div><div>where you'll find a code similar to this:</div><br /><code><span><span> </span></span> public static Bitmap CreateThumbnail(Bitmap loBMP, int lnWidth, int lnHeight)<div> {</div><div><br /></div><div> System.Drawing.Bitmap bmpOut = null;</div><div> try</div><div> { </div><div> ImageFormat loFormat = loBMP.RawFormat;</div><div><br /></div><div> decimal lnRatio;</div><div> int lnNewWidth = 0;</div><div> int lnNewHeight = 0;</div><div><br /></div><div> //*** If the image is smaller than a thumbnail just return it</div></code><div><code> if (loBMP.Width <><div> return loBMP;</div><div><br /></div><div><br /></div><div> if (loBMP.Width > loBMP.Height)</div><div> {</div><div> lnRatio = (decimal)lnWidth / loBMP.Width;</div><div> lnNewWidth = lnWidth;</div><div> decimal lnTemp = loBMP.Height * lnRatio;</div><div> lnNewHeight = (int)lnTemp;</div><div> }</div><div> else</div><div> {</div><div> lnRatio = (decimal)lnHeight / loBMP.Height;</div><div> lnNewHeight = lnHeight;</div><div> decimal lnTemp = loBMP.Width * lnRatio;</div><div> lnNewWidth = (int)lnTemp;</div><div> }</div><div><br /></div><div>// *** This code creates cleaner (though bigger) thumbnails and properly</div><div> // *** and handles GIF files better by generating a white background for</div><div> // *** transparent images (as opposed to black)</div><div> bmpOut = new Bitmap(lnNewWidth, lnNewHeight);</div><div> Graphics g = Graphics.FromImage(bmpOut);</div><div> g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;</div><div>g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight);</div><div><br /></div><div> loBMP.Dispose();</div><div> }</div><div> catch</div><div> {</div><div> return null;</div><div> }</div><div><br /></div><div> return bmpOut;</div><div> }</div><br /></code></div>So, this works, and works pretty well. <div><br /></div><div>And as for the cropping?</div><div>For that there is no other way but to use twice the </div><div>g.DrawImage(bmpTemp, new Rectangle(0, 0, width, height));</div><div>once for the size, and another time for the cropping...</div><div><br /></div><div><div>And last, but not least, THE QUALITY of the jpeg is determined while outputing the image like here:</div><div><code><div><b><br /></b></div></code></div><div><div><code>context.Response.ContentType = "image/jpeg";</code></div><div><code>EncoderParameters eps = new EncoderParameters(1);</code></div><div><code>eps.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L);</code></div><div><code>ImageCodecInfo ici = GetEncoderInfo("image/jpeg");</code></div><div><code>bmp.Save(context.Response.OutputStream, ici, eps);</code></div></div></div><div><br /></div><div>so there you have it.</div><div>cropping, resizing, and good quality output, on the fly.</div><div><br /></div><div>now, when doing these actions, the server has to 'work hard' on it for every photo, so a good way will be to cache it REAL GOOD...</div><div><br /></div><div><div> context.Response.Cache.SetExpires(DateTime.Now.AddYears(1));</div><div> context.Response.CacheControl = "public";</div><div> context.Response.Expires = 20160; // two weeks</div><div> context.Response.Cache.SetCacheability(HttpCacheability.Public);</div><div> context.Response.Cache.SetMaxAge(new TimeSpan(1, 0, 0));</div><div> context.Response.Cache.SetValidUntilExpires(true);</div></div><div><br /></div><div>well, that's it.</div><div>enjoy the code...</div>Liad Magenhttp://www.blogger.com/profile/10730284054602956057noreply@blogger.com0tag:blogger.com,1999:blog-5090208185264296159.post-81895186360060014342009-09-24T17:27:00.000+02:002009-09-24T17:33:32.102+02:00SubSonic 3 with MySQLRecently I've tried to user the new version of SubSonic (3.0.0.3) with MySQL.<div>for two days i was struggling to make it work.</div><div>I've tried the new MySQL .NET connector (6.1) and every time got errors.</div><div><br /></div><div>Eventually, I've downloaded the code of both, MySQL and SubSonic and tried to understand what the heck they are doing there.</div><div><br /></div><div>I've used the MySQL t4 that was supplied with the subsonic 3, renamed it to SQLServer.ttinclude and it still didnt work.</div><div>After breaking it down and solving one part after the other i've realized that the MySQL include file is missing support of Stored Procedures.</div><div>So I've rewrote it out of the SQL Server template, and using the MySQL Schema.</div><div>Here it is:</div><div><br /></div><div><div></div><blockquote><div><span class="Apple-style-span" style="font-family:'courier new';">List</span><spparam><span class="Apple-style-span" style="font-family:'courier new';"> GetSPParams(string spName){</span></spparam></div><div><span class="Apple-style-span" style="font-family:'courier new';"> var result=new List</span><spparam><span class="Apple-style-span" style="font-family:'courier new';">();</span></spparam></div><div><span class="Apple-style-span" style="font-family:'courier new';"> string[] restrictions = new string[4] { DatabaseName, null, spName, null };</span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> using(conn=new MySqlConnection(ConnectionString)){</span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> conn.Open();</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';">var sprocs=conn.GetSchema("PROCEDURE PARAMETERS", restrictions);</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';">conn.Close();</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';"> foreach(DataRow row in sprocs.Select("", "ORDINAL_POSITION")){</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';"> SPParam p=new SPParam();</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';">p.SysType=GetSysType(row["DATA_TYPE"].ToString());</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';">p.DbType=GetDbType(row["DATA_TYPE"].ToString()).ToString();</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';">p.Name=row["PARAMETER_NAME"].ToString().Replace("@","");</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';">p.CleanName=CleanUp(p.Name);</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';">result.Add(p);</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';">}</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';">}</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';">return result;</span></div><div><span class="Apple-style-span" style="font-family:'courier new';">}</span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><br /></span></div><div><span class="Apple-style-span" style="font-family:'courier new';">List</span><sp><span class="Apple-style-span" style="font-family:'courier new';"> GetSPs(){</span></sp></div><div><span class="Apple-style-span" style="font-family:'courier new';"> var result=new List</span><sp><span class="Apple-style-span" style="font-family:'courier new';">();</span></sp></div><div><span class="Apple-style-span" style="font-family:'courier new';"> //pull the SPs</span></div><div> </div><div><span class="Apple-style-span" style="font-family:'courier new';"> DataTable sprocs=null;</span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> DataTable parameters=null;</span></div><div> </div><div><span class="Apple-style-span" style="font-family:'courier new';"> using(conn=new MySqlConnection(ConnectionString)){</span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> conn.Open();</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';">sprocs=conn.GetSchema("PROCEDURES");</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';">conn.Close();</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';">}</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';">foreach(DataRow row in sprocs.Rows){</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';"> string spType=row["ROUTINE_TYPE"].ToString();</span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> var sp=new SP();</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';"> sp.Name=row["ROUTINE_NAME"].ToString();</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';"> </span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> if(spType=="PROCEDURE" &! sp.Name.StartsWith("sp_")){</span></div><div> </div><div> <span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family:'courier new';"> </span></span><span class="Apple-style-span" style="font-family:'courier new';"> sp.CleanName=CleanUp(sp.Name);</span></div><div> </div><div><span class="Apple-style-span" style="font-family:'courier new';"> sp.Parameters=GetSPParams(sp.Name);</span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> result.Add(sp); </span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> }</span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> }</span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> return result;</span></div><div> </div><div><span class="Apple-style-span" style="font-family:'courier new';">}</span></div></blockquote><div></div><div><br /></div><div>Just add it to the ttinclude of the MySQL and all the stored will be imported like a charm.</div><div><br /></div><div>Next quest: changing the template to support localizations !</div><div><br /></div><div>C'ya</div></div>Liad Magenhttp://www.blogger.com/profile/10730284054602956057noreply@blogger.com2tag:blogger.com,1999:blog-5090208185264296159.post-74403050172708107072009-06-30T10:12:00.000+02:002009-06-30T10:29:59.114+02:00Flash focus in Firefox and chromeRecently i encountered a problem which was hard finding a solution in the internet: setting the focus to the flash object in firefox and chrome when loading the website.<br /><br />I tried using this idea:<br /><br /><div style="font-family: arial;"><body onload="window.document.FlashName.<span style="font-weight: bold;">focus</span>();"></div><br /><div style="font-family: arial;"><object name="FlashName" ... /></div><br /><div style="font-family: arial;"><embed name="FlashName" ... /></div><br /><div style="font-family: arial;"></object></div><br /><div style="font-family: arial;"></body></div><br /><br />but while this works in IE it's not working in firefox at all.<br />I also tried detecting the browser and focusing the embed instead of the object in firefox, but turns out that the embed can't take focus easily.<br /><br />Eventually i've encountered this post: <a href="http://www.asserttrue.com/articles/2006/11/17/firefox-and-flash-swf-selection-and-focus-problems">http://www.asserttrue.com/articles/2006/11/17/firefox-and-flash-swf-selection-and-focus-problems</a> which solved this issue.<br /><br />In order to focus flash in both firefox and IE, there're 2 things need to be done:<br />1. add <span style="font-style: italic; font-weight: bold;">wmode="opaque" </span>to the object and to the embed<br />2. address the flash by name and not by ID or separating the code for IE and FireFox since each of the browsers is using different HTML tags (Object, Embed) and use the <span style="font-family: arial; font-weight: bold;">focus() </span>method.<br /><br />Happy programming<br />LiadLiad Magenhttp://www.blogger.com/profile/10730284054602956057noreply@blogger.com0tag:blogger.com,1999:blog-5090208185264296159.post-86163025244404544322007-10-07T02:52:00.000+02:002007-10-07T03:10:29.024+02:00ASP.NET 2.0 with MySQL 4.1.2 - unicode problemHey guys<br />This is my first post and the reason i've actually started this blog.<br />you see, it's now 3:00 AM here but i could not get sleep until I share this with the world :)<br /><br />during the last few days i struggled connecting MySQL database, version 4.1.2, through my ASP.NET application (using SubSonic DAL btw - great project, thanks guys!), and sending unicode utf-8 format data.<br />The problem was that when I tried saving data (Insert or Update SQL Commands) i got question marks ('?????') saved instead of unicode characters, like hebrew for example.<br /><br />I've looked up at all the forums and I have tried everything. I mean really - EVERYTHING.<br /><br />For example, I've read that I should send, right after I'm establishing the connection,<br /><span style="font-style: italic; font-family: courier new; color: rgb(153, 51, 0);">SET NAMES utf8 COLLATE 'utf8_unicode_ci'; SET CHARACTER SET utf8;</span><br /><br />So I've tried that... but no good, still got the question marks.<br /><br />I've downloaded the connector code and recompiled it. tried to see what does it sends. The ASP Connector version was 5.1.3 btw, and i've also used the MySQL.WEB functionality in order to use the ASP:Login, membership and roles functionality, again - thanks guys :) works like magic.<br /><br />I must mention that when I tried these on my local MySQL 5 installed on my computer - there were no unicode problems. Only when I've tried it on the MySQL 4 that is installed on the web server I'm using, then I had these issues.<br /><br />Eventually I've tried it all. I've set every variable on the server to UTF-8. I've changed all the database, tables and fields collations to the same collation - <span style="font-style: italic; font-family: courier new; color: rgb(153, 51, 0);">utf8_unicode_ci<span style="color: rgb(0, 0, 0);">.<br /></span></span>But the problem was not corrected.<br /><br />I could not sleep. I could not eat. I had to fix that damn issue.<br />I've started looking on the ASP Connector for MySQL code. I've learn that it uses encoding for the transmision... but setting it to UTF-8 instead of Latin1 did not help either.<br /><br />Eventually I've found in some forum a suggestion. Adding <span style="color: rgb(153, 51, 0); font-family: courier new;">CharSet=utf8</span> to the connection string.<br />And that was it :)<br />That made the unicode finally work.<br /><br />So if you're reading my post right now and having the same problem... try all these, including sending the set names command of course.<br /><br />Good luck! and happy programming ;)<br /><br />LiadLiad Magenhttp://www.blogger.com/profile/10730284054602956057noreply@blogger.com8