Posts

Showing posts from April, 2013

Few Modern JavaScript Inconsistencies

While the JavaScript weekly mailing list still points to 90s style articles about the old JavaScript Internet Explorer 5 was supporting too , the current world has different real problems to consider. Here a quick list of things you might not know about the current status of JavaScript possibilities. Reserved Words As Properties Number one of the list is the myth that reserved words cannot be used as properties. Here platforms that cannot: iOS 4 IE less than 9 Android less than 2.1 So, basically, 99% of mobile browsers support properties such obj.delete() , used in most recent JavaScript specifications, while those jurassic browsers need the obj['delete']() convention. // exactly same good old ES3 behavior // using ES5 capabilities Function.prototype.new = function () { var // grab the prototype p = this.prototype, // create from it o = Object.create(p), // invoke the real constructor r = this.apply(o, arguments); // if the result is not undefine

Standalone Java Webapp made easy with Maven

Introduction As you may already know, creating a war archive and deploying it on a preinstalled Servlet Container is not the only way running a Java webapp, since you can also embed the Web-Server in the application itself. Sometimes such artifacts are delivered as standalone executable programs that can be easily started and stopped in the commandline and even run as a service in the background. Maybe you should also consider producing your app this way and benefit from its huge advantages: No preinstalled Webserver/Servlet Container required that would take additional maintenance. Easy Cross-Platform. Same artifact can of course be run on any System. Complete Standalone Software Apache Sonar is a great Example of such Software. It uses an embedded Jetty Server and creates an embedded H2 Database for persistence that can be replaced in configuration. As you can see here they prepared startup scripts for any Platform that execute the actual StartServer class. Embedded Tomcat In my t

Boot To Node.js In 7 Seconds On Arch Linux

This is a long story that started with me buying a Raspberry Pi with the goal of discovering how good performance could have been in such device used as dedicated server. The story goes on with pcDuino too, and tricks you might want to know about booting up and building node on them. Why A Pi As A Server The story of computers is not actually that fair for same computers, as not fair is the Moore's law itself. Bear in mind, I am not saying that's not working, all I am saying is that if in 6 months we've got double amount of transistors in some CPU, this does not mean we've been used the previous CPU at its best for last 6 months! Gaming, immortal, consoles such PS2 can describe better than my words what I am talking about: hardware is good until what you need does not fit under that 100% of potentials! ARM Is Powerful Not only is becoming one of the most ambitious target for any Operating System, probably including Microsoft, ARM is also both powerful and power con

The __proto__ Comic

Image
© all images from ragefac.es and some from knowyourmeme Being a comic, sentences are not all real, mostly made up for this post. TC39 WTF is this shit?! es-discuss The community needs it and the de-facto library with stars on github uses that instead of [].push.call(new SimplifiedDOMShit, NodeListResult) TC39 OK, here what we can spec ... making it configurable, so that shit can be dropped at any time in any module es-discuss Community, we are going to spec __proto__ shenanigans all over so that any environment will have a special property able to cause more disasters than what eval did before: you should appreciate! community so, proto gonna be standard we don't have to change those 2 lines of code?! me plus some other what kind of horrible decision is this? es-discuss de-facto is de-facto , people use this, people want this! IE ... who cares ! just me OK, probably this is just a massive misunderstanding between what's truly needed, and what should be proposed ... l

Playing With V8 Native And JavaScript

What my Don Quixote like adventure against __proto__ gave me, if nothing, is a better understanding about how V8 engine internals work and how to bind JavaScript to native and vice-versa. Please Note Nobody told me anything I've written in this article is true. These are all assumptions after pushing a patch to V8 and learning by mistakes, compilation errors, and " code around reading ", done in a couple of hours so apologies in advance if some term or some concept is not perfectly and deeply explained. Let's start with this! JavaScript In JavaScript This was kinda surprising to me, almost the whole ECMAScript is implemented in JavaScript itself. In few words, what V8 does is not something like Rhino , reimplementing the whole language via a statically compiled one as Java is in Rhino case, V8 is rather the compiler for the specific ES syntax, following an example ... JSON In JavaScript It's funny when we compare in jsperf json2 vs native vs jQuery.js

A Journey To V8 ObjectSetProto Native Function

Image
Update ^_^ whatever story you are interested about in this post, one is that I've proposed a patch to V8 engine (please star it so it gets in faster) to accept a --expose-proto-setter flag at runtime able to expose the proper __proto__ setter so that my node JS pull request could start warning modules using __proto__ instead of Object.setPrototypeOf(target, proto) . What can I say ... open source is beautiful, you can potentially patch everything you want for anything you need ... even behind stubborn, politics, or decisions nobody agreed on :P Now back to the original post ... first thing: I write HTML manually in the textarea instead of Markdown, yeah!!! Why? 'cause nobody on the internet moves fast ... really, no-bloody-body! so ... back to manual tags writing instead of broken meaningless layout created via magic html editor ... yeeeeeeah! The Story ... I know this is getting boring and annoying, and I swear I wish I could say it's the last post but every day the

How About KISS vs YAGNI ?

I know this might sound silly but I keep having fun writing stuff here since I've switched to mark down text :P ### Is This A Natural Conflict ? If you are wondering what I am talking about I have a very simple example: the Linux world! In the specific case, file system operations! ``` # copy a file cp file1.txt fle2.txt # remove a file rm file1.txt ``` ### That's A Move File ! Yes, is really that simple! When you move a file you are sure that file has been copied, it has the new name or the same, if in a different folder, and you can remove the first one. OK, OK, if you are a Windows user you might have experienced some lost file in the past due accidents during the copy such "_not enough space_" I got it, but what if that's because you've been too KISS and not YAGNI? ### The Software YAGNI Approach If you can obtain that in a quite simple way, no need to complicate things around. ### The KISS Approach If everything I need is more than an action, I am not

Can Deal With Markdown In RSS Readers ?

I've spent some time trying to solve the [tinydown](https://github.com/WebReflection/tinydown#tinydown) runtime blogspot parsing and this is the current status: 1. desktop browsers are fine 2. mobile browsers are now fine too 3. textual browsers lynx like are wonderful now! 4. browsers without CSS are just fine 5. browsers without JS are kinda fine too 6. browsers without CSS and JS are almost fine ### Your RSS Reader Most likely, what you are experiencing is something similar to point 5 or, in the worst case scenario, point 6 of above list. Being markdown easy to read as any plain text or book you are familiar with, can you cope with that for RSS readers? ### As Experiment Please give you some times to see if this work before answering. I realy don't want to piss off my followers so the last option would be to revert all my changes done in blogger (or eventually host my blog in my own space) One thing I am doing different now, is to preserve a decent amount of colu

Flight Mixins Are Awesome!

OK, OK, probably is just that I cannot wait to start writing stuff with [tinydown](https://github.com/WebReflection/tinydown#tinydown) but I tweeted about this after last #FlightNight and @angustweets demo ... so here what is behind [Flight](http://twitter.github.io/flight/) mixins choice. ### The Basics JavaScript polymorphism is probably one of the best things you can find out there. Not kidding, the flexibility that this language offers when it comes to context injection and runtime class definition is simply amazing, as simple, and amazing, is this idea: ```js // most basic example function enriched() { this.method = function () { // do stuff }; } ``` Most common books and online documents usually describe above example as a _constructor with privileged methods_. Well, that's actually what you get if you `var obj = new enriched();` but that's just one story. Flight uses a different story, offering alternative methods with better semantics but basically going down to

tinydown test

OK ladies & gentlemen, time to test [tinydown](https://github.com/WebReflection/tinydown#tinydown) for real. ### What's New Well, first of all there are [35 tests](http://webreflection.github.io/tinydown/test/) with nice and/or screwed input and an expected output to complete the library so that any improvement or change will not compromise what's already working. The second thing is ... **I am using tinydown now**! You can check the source page of this post and see that all it contains is markdown. ### What's Different There at least two things different: * it supports more inside the image markup, such youtube and gists * it supports twitter handlers, like @WebReflection * even if so damn small, like less _than 2Kb_ minzipped, it supports nested blockquotes and lists `inline code` is also available together with triple tick syntax and/or tab and spaces so that var code = 'can be be written multiline'; function alCodeIsPreserved() { with(out

Writing Markdown In Blogger

Update Added tests and support for nested blocks and lists plus youtube video and gists instead of just images. Here, have a look at tinydown , compatible with both node and web. Something I've been thinking about since last year JS1K contest ... what if I could just write mark down on internet and let crawlers and bots do the math while I just write all I need to? tinydown and CloudReflection This is basically all it took to create a markdown blogger enabled service as CloudReflection is. That's correct, if I edit that post the text I gonna deal with is this one: Isn't a tiny markdown parser lovely ? ===================================== A markdown is an _easy to read and quite easy to parse_ syntax, ideal for documents that could be understood by human, and easily converted by machines. You are reading markdown now! ----------------------------- This blogpost is generated on the fly via the proposed script. Here the code **example** used for this page: this.onloa

I18n of JPA Entities

Image
Sadly the support for i18n for Entities in JPA is actually very poor to non-existent. There's just basically no out of the box solution provided by Hibernate & Co, although i18n is a feature that could be considered mandatory for a powerful ORM Framework. If you take a look at PHP for example Doctrine supports i18n very well. So besides some really unpopular i18n extensions on forums/github you are basically on your own. So how do you do it? There isn't really a general solution to achieve i18n. There are many different ways and you have to choose which is actually best for you. If you do have a relatively small amount of data and ordering by translations is not necessary you can store "keys" in your tables that are being translated by Spring i18n for example. Spring i18n could store the translations in separate property files. Since you wont have to worry about performance, this is a very easy way to achieve i18n. But lets say you have lots of data, and you need