tag:blogger.com,1999:blog-302786912024-03-13T19:43:44.980+02:00Emilian Bold's blogBroadcasting from the Romanian trenchesEmilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.comBlogger139125tag:blogger.com,1999:blog-30278691.post-79919355768602782362022-06-14T11:46:00.003+03:002022-06-14T11:46:39.423+03:00The Trouble with Harry time loop<p>I saw The Trouble with Harry (1955) a while back and it didn't have a big impression on me. But recently I rewatched it and was amazed at how odd time seems to flow, how somewhat confused people are, as if they have memory problems.</p><p>This <a href="https://www.filmfreakcentral.net/ffc/2022/06/the-trouble-with-harry.html">review</a> goes into detail about the movie, but I wanted to focus on a single riddle in the movie. It's this exchange with the kid:</p><div><blockquote>Arnie: Why haven't you visited before?<br />Sam: Perhaps I'll come back tomorrow<br />Arnie: When's that?<br />Sam: Day after today.<br />Arnie: That's yesterday, today is tomorrow.<br />Sam: It was.<br />Arnie: When was tomorrow yesterday, Mr. Marlowe?<br />Sam: Today.<br />Arnie: Oh, sure. Yesterday.</blockquote></div><p>Arnie seems to be the only one that remembers reliving days. Every adult just has slight confusion at times; forgetting things or having unexplained familiarity with each other.</p><p>We learn from this exchange the loop is not identical (Sam never visited before). But time does not flow properly since Arnie has learned not to expect that tomorrow will just come the next day ("When's that?").</p><p>Actually, Arnie knows that the day after the present day is... "yesterday"; the loop restarts. If anything it looks like the present day is something entirely new to Arnie. It's finally a "tomorrow".</p><p>My impression is that the loop had a single day until now. It was "yesterday" on a loop. The present day is finally a "tomorrow".</p><p>Sam and Arnie obviously talk about things from different perspectives. Maybe Sam has a slight intuition about things (being an artist) but only Arnie knows about the loop. So, it's not clear what Sam means when he says "It was".</p><p>Anyway, this puzzles Arnie which asks "When was tomorrow yesterday, Mr. Marlowe?"</p><p>Now, Sam answers "Today". This may just be related to the talk they had: Arnie mentioned that the day after today is yesterday so, today is the day when yesterday will come tomorrow.</p><p>But then Arnie thinks about the question he just asked and finds his own answer: in the previous loop of yesterday tomorrow was always yesterday.</p><p>It almost looks like the timeline was: Yesterday1, Yesterday2, ..., Yesterday N, Today (brand new).</p><p>Based on the ending we know the adults intently do a time loop: leave Harry in the forest for Arnie to find again.</p><p>So, the timeline is: Yesterday 1, Yesterday2, ..., Yesterday N, Today1, Today 2 (new loop).</p><p>It does not look to me that time is going in reverse. It looks to me like there's a daily loop that doesn't progress until things are settled.</p><p>Going back to the missing piece: Sam says "it was" suggesting today was tomorrow. Assuming this is the 1st day in the new loop, it does make sense indeed: today was yesterday's tomorrow, but since they are entering another loop there will not be another new day, just today on repeat.</p><p>The riddle is interesting because of there's no language to express time loops properly. "Tomorrow" may mean the day following the present day which may be a re-run or loop or "tomorrow" may be the day naturally following current events. A more proper (but dry) phrasing would be:</p><p></p><blockquote>Arnie: Why haven't you visited <b>in any of the (repeated) days I remember</b>?<br />Sam: Perhaps I'll come back <b>tomorrow.</b><br />Arnie: When <b>will we get to live tomorrow</b>?<br />Sam: Day after today.<br />Arnie: <b>After today we will relive</b> yesterday, today is <b>a new day following the yesterday loop</b>.<br />Sam: <b>But the next day won't be new.</b><br />Arnie: When <b>did we live the day before yesterday</b>, Mr. Marlowe?<br />Sam: [<i>Nonsensical response</i>.]<br />Arnie: <b>[Gets confused.] </b>Oh, sure. <b>We continuously relived</b> yesterday.</blockquote><p></p>Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-35158084180516209672020-08-03T22:19:00.001+03:002020-08-03T22:19:02.677+03:00Global ecosystem report 2020: Java text editors and IDEs<div dir="ltr" style="text-align: left;" trbidi="on">
The<a href="http://www.jchoice.eu/global-ecosystem-report-2020.html"> JChoice Global Ecosystem Report 2020</a> is looking good: Apache NetBeans at <b>50%</b> of the free Java tools, Eclipse at 45% and vi / Emacs and Notepad++ at 5%.<br />
<br /></div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-14433204975869842632020-07-04T14:51:00.002+03:002020-07-04T14:54:51.328+03:00The Geek and the pseudo inclusive peer pressure<div dir="ltr" style="text-align: left;" trbidi="on">
Discrimination based on social skills and social groups exists and geeks experience it a lot.<br />
<br />
One facet of it is the pseudo inclusive peer pressure.<br />
<br />
The desire to belong to a group is strong in anyone so people would accept many things just to fit in.<br />
<br />
At the same time, a few understand this game quite well, can get meta about it and specifically target geeks to mock them by appearing to be inclusive.<br />
<br />
Nothing causes more pleasure to such dark 'master minds' than tricking a geek into ridiculing itself!<br />
<br />
Not only for the ridicule but for the mere fact that the geek believed they would thus become part of the in-group: this was never on the table! They will never be part of the in-group!<br />
<br />
After a few such experiences some geeks develop a good sense for this situation.<br />
<br />
There is no surprise then that some react quite hard in the grown up world. Their senses are screaming: it's a trap!<br />
<br />
But the master minds are also grown ups now, and they want small things, all in the name of being inclusive.<br />
<br />
<br /></div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-20571896284665381262020-06-30T11:35:00.001+03:002020-06-30T11:35:32.641+03:00Open Source sustainability is not about the individual<div dir="ltr" style="text-align: left;" trbidi="on">
There was a lot of buzz a while back about Open Source sustainability. Small and large companies as well as individuals discovered it's near impossible to survive financially doing Open Source.<br />
<br />
It occurred to me that this might be an emergent property of Open Source and a reason why many foundations (like Apache) as well as users intuitively look at the "community" first.<br />
<br />
The community is like a swarm, a Redundant Array of Individual Contributors (RAIC) that carries on regardless if a particular individual drops out. So, a "good" Open Source project is one where the community achieved this chain reaction while the others are at a stage where individual contributors make or break the project.<br />
<br />
This conclusion is quite ruthless about a specific company or individual though: the better your Open Source project is, the more precarious your position.<br />
<br />
The role of BDFL (Benevolent dictator for life) might be the only one guaranteeing some stability for an individual, but this means the swarm can only sustain one queen (I mean, dictator). Conceptually this role might be required to provide some coherence to the swarm.</div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-79930793573805047722020-06-04T13:24:00.002+03:002020-06-04T13:51:59.193+03:00Instant Thought: another open source supply chain attack<div dir="ltr" style="text-align: left;" trbidi="on">
It seems not a day goes by without another open source supply chain attack.<br />
<br />
The latest, uncovered by the security researcher "JK" is called "Instant Thought" and was noticed in the most popular Java IDE, combined the the very popular build system Gradle.<br />
<br />
One might assume that just opening a Gradle project to read the source code is a safe operation, but Instant Thought shows this is not the case.<br />
<br />
Gradle projects might have an unassuming <span style="font-family: "courier new" , "courier" , monospace;">settings.gradle</span> file with a tiny block which gets executed by the IDE as soon as the project is loaded.<br />
<br />
Root cause analysis showed the problem is the <span style="font-family: "courier new" , "courier" , monospace;">gradle.projectsLoaded</span> hook which is able to run code with the full permissions of the user account:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">gradle.projectsLoaded { g -></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> // do bad things</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">}</span><br />
<br />
<i>"This is not unlike the Word macro viruses seen in late '90s"</i> said another analyst. <i>"Which just shows how behind the times the IDEs are with security"</i>.<br />
<br />
It is not clear how widespread Instant Thought is but suffice to say developers have to think long and hard before executing or even <i>opening</i> unknown projects.<br />
<br />
According to the vendor, this is a low priority issue: <i>"[Our IDE] automatically configures the project during the import (which is quite similar to executing gradle command) and it causes the code execution. The current behaviour seems not to be a high severity security problem thus it won't be fixed in the near future."</i></div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-87576229165887247072020-01-23T23:08:00.001+02:002020-01-24T01:42:45.424+02:00Roam Like at Home is a regression for Romania<div dir="ltr" style="text-align: left;" trbidi="on">
On June 15th 2017 the EU launched "Roam Like at Home", a set of rules that removed roaming charges. It was a great idea to harmonise telecom infrastructure and remove another invisible border separating people within the EU.<br />
<br />
Romania was hit particularly bad by these rules. They introduced new borders where before there were none.<br />
<br />
Previously, roaming was available to any telecom user either on a subscription plan or on a pre-paid card in Romania. The only limitation was that, rarely, the operator might ask for a warranty (say, 100 euro) so you don't rack up too many fees while abroad.<br />
<br />
Internet and mobile services are particularly cheap in Romania and fast. We used to be ranked on the 5th place world wide based on internet speed alone.<br />
<br />
So, by having such cheap prices a problem for Romanian telecom operators was that this might encourage abuse from Romanians going abroad and downloading too much, or by other EU people buying Romanian SIM cards to use instead of their expensive national SIM cards.<br />
<br />
In order to contain this potential problem the EU was flexible with the "Roam Like at Home" rules and allowed a "fair use policy".<br />
<br />
But the biggest blow was that the EU allowed contracts without roaming services. Guess what all Romanian telecom operators started rolling out immediately? They removed roaming from all the subscription plans under a price they considered acceptable!<br />
<br />
A reasonable, entry-level, subscription plan that would have had roaming before 2017 suddenly became useless when crossing the border.<br />
<br />
Note that without roaming nothing works! You have no data but no calls or SMS either. You are stranded with a non-functioning telephone in another EU country. This was an "interesting" experience for Romanian tourists early 2018. All they could call is 112.<br />
<br />
Getting roaming temporarily on a subscription plan is just not possible anymore. Either you upgrade the whole plan to a more expensive one, forever, or you have no phone abroad.<br />
<br />
A pre-paid card has more advantages. You can activate a more expensive roaming plan at any time, but you are still penalised by losing all the benefits you had until then, regardless how much the 'national' plan costed or how much you used from it.<br />
<br />
In conclusion Roam like at Home reduced the quality of the telecom offer in Romania and introduced a quite visible border separating Romanians from the rest of the EU. One cannot imagine under what scenario the concept of 'roaming services' for SIM cards sold within the EU to EU citizens should even exist.<br />
<br />
Another change that this measure did introduce in Romania is a bigger churn on SIM cards and operators. If Romanians manage to separate their identity from the SIM number and the operator is just a dumb carrier then it will not have been all for nothing.</div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-76491639385233983592019-10-09T14:18:00.005+03:002019-10-09T14:19:16.284+03:00Tarkovsky street art<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://i.redd.it/jugpy3s4q3n31.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="800" data-original-width="640" height="640" src="https://i.redd.it/jugpy3s4q3n31.jpg" width="512" /></a></div>
<br />
<a href="https://www.reddit.com/r/mildlyinteresting/comments/d5d9az/street_art_in_moscow_the_candle_is_real_people/">Source</a>.</div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-69293748733119638342019-08-16T23:47:00.001+03:002019-08-16T23:47:03.008+03:00Wayback Machine Downloader<div dir="ltr" style="text-align: left;" trbidi="on">
Internet Archive's <a href="https://archive.org/web/">Wayback Machine</a> is a gift to the world. For quick checks you just enter the URL and you get the archived version going years back.<br />
<br />
A whole little cottage industry seems to have been formed around the Wayback Machine. They offer you whole-site download and conversions for the low price of $5 or $15 or $45 or however much they can convince you their service is worth.<br />
<br />
Among these busy bees, the free Ruby based <a href="https://github.com/hartator/wayback-machine-downloader">Wayback Machine Downloader</a> is a little gem.<br />
<br />
You just install it then run<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">wayback_machine_downloader -c 10 -s http://www.example.com</span><br />
<br />
and you get everything! Total cost: $0.<br />
<br />
Installing the actual gem on macOS as a non-admin user seems to have contradicting info online. There's a `<span style="font-family: Courier New, Courier, monospace;">gem install --local`</span> command but it doesn't seem to do what one expects -- installing in the home folder of the current user.<br />
<br />
What did the trick for me was:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">gem install -i ~/.gem/ruby/2.3.0/ wayback_machine_downloader</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: inherit;">and this after I manually downloaded <a href="https://rubygems.org/gems/wayback_machine_downloader">the proper .gem file</a> from <a href="http://rubygems.org/">rubygems.org</a></span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Some were even recommending to add a <i>http</i> (versus the default <i>https</i>) source to gem but that seemed foolish and even </span><span style="font-family: Courier New, Courier, monospace;">gem</span><span style="font-family: inherit;"> itself complained about using http in 2019.</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Whatever road you pick with downloading from Wayback Machine, remember all the work the Internet Archive is doing for all this to be available to you and <a href="https://archive.org/donate?donated=1">donate to them</a>.</span></div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-90373659057315251172019-06-08T08:30:00.002+03:002019-06-08T08:30:24.453+03:00Fair Source and the Fair Source Initiative<div dir="ltr" style="text-align: left;" trbidi="on">
There's been some uproar about the MongoDB Server Side Public License which tries to prevent cloud vendors like Amazon take all the money in the MongoDB market.<br />
<br />
Many are pointing out that this new license does not respect the <a href="https://opensource.org/osd">Open Source Definition</a> published by the <a href="https://opensource.org/">Open Source Initiative</a>.<br />
<br />
In truth many users and companies would find the license acceptable. A legal advisor will clear the license, the software will be used and nobody except a vendor in a similar position like Amazon will care.<br />
<br />
What this move towards a financially sustainable open source ecosystem needs is branding.<br />
<br />
I suggest calling this new type of open source "<b>fair source</b>". Most people and companies understand that some money is necessary to keep a project alive and would find it palatable that the once you are big enough to disrupt the market for the author you should pay.<br />
<br />
In order to help smaller companies that do not have a legal advisor at hand, a <b>Fair Source Initiative foundation</b> should be created. This foundation would review such fair source licenses and define them as acceptable or not.<br />
<br />
In many ways in the same way as "open source" was introduced to make free software more acceptable to businesses, "fair source" will be about making an open source business model more sustainable.<br />
<br />
Open Source was about dethroning the Free Software Foundation. Fair Source must dethrone the Open Source Initiative.<br />
<br />
Perhaps the Open Source Initiative board will realize this and redefine the way they classify licenses. Otherwise they will find themselves irrelevant for a buzzing section of the software world.</div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-65227414215992686542019-04-27T19:11:00.001+03:002019-04-27T19:13:34.625+03:00Apache NetBeans interview<div dir="ltr" style="text-align: left;" trbidi="on">
As Apache NetBeans became a top level Apache project and finished the incubation process I was asked for an interview and my photo.<br />
<br />
Only a single quote was taken from the interview and used on a not too positive article about NetBeans. The quote was presented as coming from me as a member of the 'Project Management Committee' to give it even more weight.<br />
<br />
Bellow is my full interview for historical reference:<br />
<br />
<span class="im">> Do you think Apache is the best place for NetBeans?<br />
</span><br />
Churchill said that 'democracy is the worst form of Government except
for all those other forms that have been tried from time to time'.<br />
<br />
In the current context, there is no better place.<br />
<br />
Maybe in some alternate universe Sun Microsystems didn't spend a full $1
billion on MySQL but took a chunk of that to create a NetBeans
Foundation that rivals the Eclipse Foundation... but I'm not entirely
certain it would have been better for the project.<span class="im"><br /> </span><br />
<span class="im">> What kind of future do you anticipate for NetBeans under Apache?<br />
</span><br />
This depends on how Apache and the other Apache projects value NetBeans.
There is a lot of integration that would help both the projects and the
end users.<br />
<br />
The ASF is a large Java house now so having a programming language
(Groovy), an IDE (NetBeans), build systems (Ant, Maven) and application
runtimes (Tomcat, TomEE) means you can do some interesting things in
sync.<br />
<br />
If you think about it, the IDE is the last major piece of the puzzle
missing from Apache. So now, you can push a new feature all the way to
developers using the IDE really easy.<br />
<br />
Imagine you want to introduce, say, reproducible builds to the Java
developer world. Well, you change the build systems, have the runtimes
also reproducible then push this to the default project types in the IDE
and suddenly all new Java projects created by developers using the IDE
are reproducible. You can really change and educate the world really
fast.<br />
<br />
And education is not to be understated. An IDE suggestion that the
developer sees *while editing code* is educational. Want people to use
libraries better? A blog post might help, but people have to find it and
read it. But if a suggestion about how to use the library better is
part of NetBeans, all developers will see it!<br />
<br />
It's not clear to me yet if the ASF takes such a holistic approach, but there's a big opportunity here. Everything fits.<span class="im"><br /> </span><br />
<span class="im">> What will your project management committee do to advance NetBeans?<br />
</span><br />
This is a hard question for me since I'm not the 'manager' of NetBeans.
Nobody is. The whole point under Apache is to participate as
individuals, regardless of the employer (that might sometimes be
sponsoring said involvement).<br />
<br />
So, I don't necessarily see hard targets like under a strictly hierarchical corporation.<br />
<br />
Changes happens somewhat chaotically but towards betterment. Many people
submit specific bug fixes for their particular problems while other
work on more big picture changes (like a new Java version being
supported, etc).<br />
<br />
On the Java front we have a lot of community members that work on it, a
few of them full time as part of their job at Oracle. On PHP we also
have some folks, particularly Jun-ichi Yamamoto from Japan. JavaEE is
also quite popular. We had people add support for JUnit 5, etc.<br />
<br />
Basically the community will self-organize to overcome obstacles. We had
somebody fix a really hard bug in the Java profiler. I would have
thought that only a handful of core Java developers from Oracle knew how
to fix that. But the individual looked into it, worked hard and fixed
it! There's a lot of hidden talent like that.<span class="im"><br /> </span><br />
<span class="im">> Also, what is the role of the committee?<br />
</span><br />
See <a data-saferedirecturl="https://www.google.com/url?q=https://www.apache.org/foundation/governance/pmcs.html&source=gmail&ust=1556467349516000&usg=AFQjCNG_23P2nAMgFbzlknrUqywSYxI-OA" href="https://www.apache.org/foundation/governance/pmcs.html" rel="noreferrer noreferrer" target="_blank">https://www.apache.org/<wbr></wbr>foundation/governance/pmcs.<wbr></wbr>html</a><br />
<br />
The PMC decides which new committers get added (which in turn decide how
the code is changed) and then votes when a release is to be made as an
act of the Apache foundation. We also oversee how the NetBeans trademark
is used and basically take care of the NetBeans project and brand as a
whole.<br />
<br />
> Thank you very much!<br />
<br />
No problem. BTW, the individual doing the hard Profiler bugfix I mentioned is called Peter Hull. </div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com2tag:blogger.com,1999:blog-30278691.post-80624696655805379212019-04-04T10:28:00.001+03:002019-04-04T10:53:42.555+03:00The Apache Software Foundation is a record label not a rock band<div dir="ltr" style="text-align: left;" trbidi="on">
What shocked me most during my involvement with NetBeans, now an Apache Software Foundation project, is that The Apache Software Foundation is a record label not a rock band.<br />
<br />
Imagine you like a given band. You go to their concerts regardless of the location, enjoy their music, buy their records, maybe proudly wear a T-shirt. You deeply care about that band and the band cares about the music they make and their fans.<br />
<br />
Once your band joins The Apache Record Label things might seem unchanged. The band still makes good music, released obviously exclusively through their new record label.<br />
<br />
But something did change: while the band and the fans care about their future, the record label has a lot of bands to look after and only tangentially cares about a particular band. The band is also not doing much better since all their sales go towards the maintenance of the main music venue, lawyers, trademark protection, distribution fees, etc.<br />
<br />
The misunderstanding about The Apache Software Foundation must have been caused by the fact that initially the Foundation was about a big and important project: the Apache HTTP Server. At that time I believe the fate of the project was quite important. Nowadays I believe the Foundation could retire the Apache HTTP Server and survive unscathed.<br />
<br />
The other misunderstanding is caused by the fact that the technology landscape has some other software foundations like the FreeBSD Foundation, the OpenBSD Foundation, Mozilla Foundation which are all about a single project. These foundations basically live and die by that project.<br />
<br />
It's an odd situation. The Apache Software Foundation provides competent support for its projects but has no skin in the game and if a project fails they will eventually acknowledge it in a board meeting and move on.<br />
<br />
There's also no way to directly support a project via the Apache Software Foundation. The Foundation does not sponsor any kind of project software development. All the donations go to infrastructure and administrative costs. But projects rarely hurt for infrastructure while targeted development could help them and their users a whole lot.</div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-7960324226512669162018-08-26T14:09:00.001+03:002018-08-26T14:09:37.530+03:00NetBeans Web Toolkit<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
I'm exploring NetBeans Web Toolkit with the articles <a href="http://notes.emilianbold.ro/">here</a><br />
<br />
NetBeans Web Toolkit is the new name I'm trying to give to Jaroslav Tulach's HTML/Java API, a rather impressive library that deserves more use.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtuj8zw5a_vyqiQTs54NfoxZIrgOFqztCVXePfAtdrw47hk_9v1EXR6hVf_u48oxXjStk9W9gTkoar9lF1v_QSMtOD8e51b0YKwBm1UkFOqQybhH313MeIY9t6ybYQwNOoTJUz/s1600/timezone-clock%25402x.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="376" data-original-width="440" height="170" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtuj8zw5a_vyqiQTs54NfoxZIrgOFqztCVXePfAtdrw47hk_9v1EXR6hVf_u48oxXjStk9W9gTkoar9lF1v_QSMtOD8e51b0YKwBm1UkFOqQybhH313MeIY9t6ybYQwNOoTJUz/s200/timezone-clock%25402x.png" width="200" /></a></div>
<span id="goog_872499847"></span><span id="goog_872499848"></span><br /></div>
</div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com1tag:blogger.com,1999:blog-30278691.post-83089808161797529742018-03-02T19:41:00.004+02:002018-03-02T19:42:59.471+02:00Guards in Java<div dir="ltr" style="text-align: left;" trbidi="on">
Haskell functions have this nice concept called 'guards' which allow you to define a condition and return a value when that condition is true.<br />
<br />
For example:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">abs n</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> | n < 0 = -n</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> | otherwise = n</span><br />
<br />
<span style="font-family: inherit;">This makes the code rather readable, especially when you have more guards.</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Guards build one upon another since you know that if your guard condition is checked, all the other failed:</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">something n</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> | n < -2 = 10</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> -- bellow we know that n > =-2</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> | n < 0 = 8</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> | otherwise = n</span><br />
<br />
Back in Java land, where I get paid, I sometimes wondered if I should write a method as:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">X method(Y param) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> if (!param.isSomething()) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> return null;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> } else {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> return param.getX();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">}</span><br />
<br />
<b>or</b> if I should write it as<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">X method(Y param) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> if (!param.isSomething()) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> return null;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> return param.getX();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">}</span><br />
<br />
I generally prefer the 2nd variant and now I realised these are a form of function guards!<br />
<br />
<br />
<br /></div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-89244373874601489562017-10-04T13:48:00.000+03:002017-10-04T16:21:15.305+03:00The case of the different jsch 0.1.54 binaries<div dir="ltr" style="text-align: left;" trbidi="on">
As part of the Apache NetBeans IP clearance we are combing through all the code and dependencies.<br />
<br />
One interesting thing we bumped into was that the jsch 0.1.54 binary JAR we are using has a different hash (and size) than the binary JAR from Maven Central.<br />
<br />
The old hash is 0D7D8ABA0D11E8CD2F775F47CD3A6CFBF2837DA4, the new one is DA3584329A263616E277E15462B387ADDD1B208D.<br />
<br />
The binaries are 278,612 bytes vs 280,515 bytes in Maven Central.<br />
<br />
Our version is actually the same as the one found on <a href="http://www.jcraft.com/jsch/">http://www.jcraft.com/jsch/</a><br />
<br />
Also, the Maven JAR <i>is</i> properly signed with the author's CA7FA1F0 key.<br />
<br />
This is where it becomes clear that <a href="https://reproducible-builds.org/">reproducible builds</a> are important. You do not want to have to wonder why a binary differs, especially years later when you are doing a review. And this one is a library doing SSH!<br />
<div>
<br /></div>
So, why the different binaries?<br />
<br />
It seems the original JAR was compiled on Aug 30, 2016 with Java 1.4 (major version 48) while the Maven Central JAR was compiled Sep 3, 2016 with Java 5 (major version 49).<br />
<br />
The original JAR also concatenates strings using <span style="font-family: "courier new" , "courier" , monospace;">StringBuffer</span> while the Maven Central JAR uses the newly introduced in 1.5 <span style="font-family: "courier new" , "courier" , monospace;">StringBuilder</span>. Which should also be a bit faster since it's not synchronized.<br />
<br />
Next, most of the cypher classes use some reflection via a <span style="font-family: "courier new" , "courier" , monospace;">static static java.lang.Class class$(java.lang.String)</span> method.<br />
<br />
What is this? It's just the way class literals worked in Java 1.4. As explained <a href="https://blogs.oracle.com/sundararajan/class-literals-in-jdk-15">here</a>, in Java 5 the <span style="font-family: "courier new" , "courier" , monospace;">ldc_w</span> instruction was introduced to load a <span style="font-family: "courier new" , "courier" , monospace;">Class</span> object.<br />
<br />
In 1.4 the class literal was helped by the compiler by actually introducing the helper <span style="font-family: "courier new" , "courier" , monospace;">Class class$(java.lang.String className)</span> method and replacing the <span style="font-family: "courier new" , "courier" , monospace;">Person.class</span> with a <span style="font-family: "courier new" , "courier" , monospace;">class$("Person")</span> call.<br />
<br />
It conclusion, it seems that excluding the Java 1.4 to Java 5 compiler changes, the two JARs <i>are</i> identical. With the Maven Central JAR even a bit better due to <span style="font-family: "courier new" , "courier" , monospace;">StringBuilder</span> being used.<br />
<br />
There is no check so far that the sources <i>do</i> produce the specific JAR. This is an exercise left for the reader.<br />
<br />
Note: I have also <a href="https://blogs.apache.org/netbeans/entry/the-case-of-the-different">cross-posted</a> this blog post to the Apache NetBeans blog.</div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-64013873004378041652017-06-20T11:08:00.001+03:002017-06-20T11:08:19.746+03:00Processing a generic Data.Array matrix<div dir="ltr" style="text-align: left;" trbidi="on">
I had an interesting Haskell problem the other week: work on columns and rows of a <span style="font-family: Courier New, Courier, monospace;">Data.Array i e</span>.<br />
<br />
You only have the <span style="font-family: Courier New, Courier, monospace;">Ix i, Ord e</span> class constraints, which make sense because the index must be a <span style="font-family: Courier New, Courier, monospace;">Data.Ix</span>. The elements also must be <span style="font-family: Courier New, Courier, monospace;">Ord</span> to be able to process them.<br />
<br />
The thing about <span style="font-family: Courier New, Courier, monospace;">Data.Ix</span> is that it's very opaque. It only extends <span style="font-family: Courier New, Courier, monospace;">Ord</span>. There is nothing matrix-related in it. One could use <span style="font-family: Courier New, Courier, monospace;">Data.Array</span> for a lot of data structures!<br />
<br />
But if you do know it's a matrix, although you have no explicit class constraint, there is a nice trick to use: two neighbouring cells will have a <span style="font-family: Courier New, Courier, monospace;">Data.Ix.rangeSize</span> of 2!<br />
<br />
So, the rows may be extracted by this little function:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">byRows :: Ix i => [i] -> [[i]]</span><br />
<span style="font-family: Courier New, Courier, monospace;">byRows indices = incGroupBy isNeighbour $ indices</span><br />
<span style="font-family: Courier New, Courier, monospace;"> where isNeighbour x y = 2 == rangeSize (x, y)</span><br />
<br />
<span style="font-family: inherit;">which is called like</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">process :: (Ix i, Ord e) => Array i e -> Something</span><br />
<span style="font-family: Courier New, Courier, monospace;">process matrix =</span><br />
<br />
<span style="font-family: Courier New, Courier, monospace;"> let rows = byRows $ indices matrix</span><br />
<span style="font-family: Courier New, Courier, monospace;"> ...</span><br />
<br />
Note the unknown <span style="font-family: Courier New, Courier, monospace;">incGroupBy</span> which is a <span style="font-family: Courier New, Courier, monospace;">groupBy</span> that takes pairs incrementally.<br />
<br />
That's it! I had a lot of ideas about using <span style="font-family: Courier New, Courier, monospace;">rangeSize</span> to figure out the matrix dimensions, but pairing cells this way was really clean.</div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-42486194286265741942017-03-30T20:45:00.001+03:002017-03-30T22:52:16.046+03:00Retina work<div dir="ltr" style="text-align: left;" trbidi="on">
These past months I have done a NetBeans patch for the Apple Retina Display and also made a small Wiki-like site to help me and anyone else interested with finding matching font icons for the NetBeans icons: <a href="https://nextbeans.com/retina">https://nextbeans.com/retina</a><br />
<br />
The <a href="http://nextbeans.com/">nextbeans.com</a> stack is <a href="https://angular.io/">Angular</a>, <a href="https://www.primefaces.org/primeng/">Prime NG</a>, <a href="https://nginx.org/en/">nginx</a>, <a href="http://www.eclipse.org/jetty/">Jetty</a>, Servlets, <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/html/jdbc.html#jdbc-JdbcTemplate">Spring Framework JDBC</a>, <a href="http://hsqldb.org/">HSQLDB</a>. SSL via <a href="https://letsencrypt.org/">Let's Encrypt</a>. Hosted at <a href="https://www.scaleway.com/">Scaleway</a>.<br />
<br />
It's a fun project since I got to learn Angular, find a bug and submit a <a href="https://github.com/primefaces/primeng/pull/2031">patch</a> for Prime NG, see how Let's Encrypt does free SSL certificates, learn about the EU cookie warning and all the many tiny things that are needed for a site.<br />
<br />
Angular in particular and the whole webdev ecosystem was a lot of new information for me. I was changing project configuration as Angular progressed along! Which reminds me: @angular/cli reached 1.0 and I should probably see if I need to tweak something.<br />
<br />
Read on JAXenter <a href="https://jaxenter.com/netbeans/netbeans-retina">a longer article</a> about my work.</div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-15096464174410261092017-01-31T21:38:00.000+02:002017-01-31T21:38:34.466+02:00Machine learning everywhere!<div dir="ltr" style="text-align: left;" trbidi="on">
Samsung announced a while back that they used a "Neural Net based predictor" for their CPU branch prediction.<br />
<br />
Shortly after that an Intel person claimed it's no big deal because they have also been using a perceptron for some time.<br />
<br />
But to me this seemed a rather big discovery! Previously I would have assumed that branch prediction is a super complex algorithm.<br />
<br />
Learning that branch prediction is a basic perceptron reduces Intel's perceived strength.<br />
<br />
So companies are openly and covertly using machine learning everywhere.<br />
<br />
Machine learning is also a perfect fit for companies because there is no moral filter on a neural network and no chance of whistle blowing.<br />
<br />
Volkswagen truly missed a golden opportunity here with their diesel scandal.<br />
<br />
They should have just trained a neural network on passing the diesel criteria and then have perfect plausible deniability: "the neural network disabled the pollution filters all by itself!"</div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-50653565650853625072016-12-28T12:13:00.002+02:002016-12-31T08:26:46.826+02:00Migrating the extra large NetBeans Mercurial repository to Git<div dir="ltr" style="text-align: left;" trbidi="on">
<i><b>Note</b>: This article is a living document and will be updated as I learn new useful information (last update 31st December 2016). I will move the helper scripts to a dedicated repository and copy part of this article into the Apache NetBeans wiki.</i><br />
<br />
<span style="font-size: large;">Introduction</span><br />
<br />
The NetBeans source code has been stored in a Mercurial repository for almost a decade now.<br />
<br />
But starting October 2016 NetBeans is preparing to become an Apache project.<br />
<br />
And all incubating projects must store their source code on Apache Software Foundation infrastructure which only provides Subversion or Git hosting.<br />
<br />
So, NetBeans must migrate its Mercurial repository to Git.<br />
<br />
<span style="font-size: large;">Size concerns</span><br />
<br />
The NetBeans Mercurial repository covers 17 years of history and has grown to over 3GB.<br />
<br />
Apache projects are mirrored on GitHub and they have a limit of 2GB or so. As such, any talk of migration started with ways of reducing the size by potentially splitting up the repository or removing some of the history.<br />
<br />
Luckily, it turns out the NetBeans Mercurial server was just using a really old Mercurial version. When Gregory Szorc <a href="http://mail-archives.apache.org/mod_mbox/incubator-netbeans-dev/201611.mbox/%3cCAKQoGanXtJr6aTrxwyw2=QfMPNs6TA_GHfUsRQO_qYQXrfxShg@mail.gmail.com%3e">looked into it</a> we learned that with the <span style="font-family: "courier new" , "courier" , monospace;">format.generaldelta=true</span> and <span style="font-family: "courier new" , "courier" , monospace;">format.aggressivemergedeltas=true</span> flags, the repository drops to about <b>1GB</b>.<br />
<br />
This was great news but, of course, we still have to migrate to Git.<br />
<br />
Under Git we have to make sure some compression is applied. This is done with the <span style="font-family: "courier new" , "courier" , monospace;">git gc</span> command which reduces the repository to under 1GB too.<br />
<br />
With size out of the way, we can do a straight migration and preserve our mono repository and the whole history.<br />
<br />
<span style="font-size: large;">The case of the corrupted repository</span><br />
<br />
The most important NetBeans repository is <a href="http://hg.netbeans.org/releases">releases</a>. This repository holds the release branches such as release82 as well as the current state in the default branch. The <a href="http://hg.netbeans.org/main-silver">main-silver</a> default branch is periodically pushed into the releases/ default branch.<br />
<br />
A direct conversion of releases/ is impossible though because the repository is corrupt:<br />
<br />
<blockquote class="tr_bq">
<span style="font-family: "courier new" , "courier" , monospace;">$ hg verify<br />checking changesets<br />checking manifests <br /><br />crosschecking files in changesets and manifests <br /><br />checking files<br /> applemenu/src/org/netbeans/modules/applemenu/layer.xml@?: rev 12 points to unexpected changeset 149753 <br /> (expected 149755)<br /> defaults/src/org/netbeans/modules/defaults/Eclipse-keybindings-mac.xml@?: rev 0 points to unexpected changeset 149753 <br /> (expected 149755)<br /> defaults/src/org/netbeans/modules/defaults/Eclipse-keybindings.xml@?: rev 25 points to unexpected changeset 149753 <br /> (expected 149755)<br /> defaults/src/org/netbeans/modules/defaults/mf-layer.xml@?: rev 74 points to unexpected changeset 149753 <br /> (expected 149755)<br />192754 files, 313961 changesets, 1122263 total revisions <br /><br />4 warnings encountered!<br />4 integrity errors encountered!</span></blockquote>
<br />
Luckily, the corruption seems to be in the default branch.<br />
<br />
So, we can get a valid releases/ repository by first making a main-silver clone and then pulling the missing changesets from releases:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">mkdir releases.fixed</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">cd releases.fixed</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">hg init .</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">hg pull http://hg.netbeans.org/main-silver</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">hg pull http://hg.netbeans.org/releases</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">hg out http://hg.netbeans.org/releases</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">#nothing should be displayed here</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">hg verify</span><br />
<br />
<span style="font-size: large;">hg-fast-export all the way</span><br />
<br />
Now that we have a valid repository we just follow the steps in the official documentation about <a href="https://git-scm.com/book/en/v2/Git-and-Other-Systems-Migrating-to-Git#Mercurial">migrating from Mercurial</a>:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">git clone http://repo.or.cz/r/fast-export.git /tmp/fast-export</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">git init ~/git-releases</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">cd ~/git-releases</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">/tmp/fast-export/hg-fast-export.sh -r ~/releases.fixed</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">git gc --aggressive --prune=now</span><br />
<br />
and then wait 48 hours for it to finish!<br />
<br />
<span style="font-size: large;">.. but first: removing the unnamed heads</span><br />
<div>
<br /></div>
<div>
Once you do start hg-fast-export.sh you'll notice it fails early with</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">Error: repository has at least one unnamed head: hg rXXXX</span></div>
<div>
<br /></div>
<div>
This is caused because Git, unlike Mercurial, does not support unnamed branches.</div>
<div>
<br /></div>
<div>
It's not a big problem for the NetBeans repository because there are very few such commits and basically historical mistakes with no relevance.</div>
<div>
<br /></div>
<div>
I have just removed them altogether with <span style="font-family: "courier new" , "courier" , monospace;">hg strip</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div>
<span style="font-family: inherit; font-size: large;">Incremental push</span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
<span style="font-family: inherit;">Although we have world class internet speed in Romania, I happened to be on a slow connection when the conversion finished. And it is no fun to restart a git push after 400MB have already been uploaded and the connection dropped!</span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
<span style="font-family: inherit;">I fixed this by uploading incrementally each month:</span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">echo "Incremental git push"</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">for year in 2012 2013 2014 2015 2016; do</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> for month in 1 2 3 4 5 6 7 8 9 10 11 12; do</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>SHA=`git rev-list -1 --before="$year-$month-1 12:00" master`</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>echo "$SHA $year-$month"</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>echo git push origin "$SHA:master"</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>git push origin "$SHA:master"</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> done;</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">done;</span></div>
<div style="font-family: inherit;">
<br /></div>
</div>
<div style="font-family: inherit;">
<span style="font-size: large;">Syncing with the old Mercurial repository</span></div>
<div style="font-family: inherit;">
<br /></div>
<div style="font-family: inherit;">
Right now my GitHub <a href="https://github.com/emilianbold/releases">repositories</a> are just experimental. The real work is still done in the Mercurial repository. As such, I still have to convert the new commits from Mercurial to Git.</div>
<div style="font-family: inherit;">
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">hg-fast-export</span><span style="font-family: inherit;"> seems designed with this in mind. The </span><span style="font-family: "courier new" , "courier" , monospace;">-r</span><span style="font-family: inherit;"> parameter which specifies the source repository is only needed the 1st time. After that it may be skipped and </span><span style="font-family: "courier new" , "courier" , monospace;">hg-fast-export</span><span style="font-family: inherit;"> will incrementally convert the missing changesets.</span></div>
<div style="font-family: inherit;">
<br /></div>
<div style="font-family: inherit;">
So, it's just a matter of:</div>
<div style="font-family: inherit;">
<br /></div>
<div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">cd ~/releases.fixed</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">hg pull</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">cd ~/git-releases</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">hg-fast-export.sh</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">git push</span></div>
</div>
<div style="font-family: inherit;">
<br />
Note that a pull on releases/ will bring back the stripped commits...<br />
<br /></div>
<div style="font-family: inherit;">
<span style="font-size: large;">Saving hg-fast-export state</span></div>
<div style="font-family: inherit;">
<br /></div>
<div>
<span style="font-family: inherit;">I did run into <a href="https://github.com/frej/fast-export/issues/85">a deadlock</a> while incrementally converting with </span><span style="font-family: "courier new" , "courier" , monospace;">hg-fast-export</span><span style="font-family: inherit;">.</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">The only solution seemed to be to redo the conversion.</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">At 48 hours per full repository this doesn't seem like fun, so I recommend periodically saving these files from the </span><span style="font-family: "courier new" , "courier" , monospace;">.git</span><span style="font-family: inherit;"> folder: </span><span style="font-family: "courier new" , "courier" , monospace;">hg2git-heads</span>, <span style="font-family: "courier new" , "courier" , monospace;">hg2git-mapping</span>, <span style="font-family: "courier new" , "courier" , monospace;">hg2git-marks</span> and <span style="font-family: "courier new" , "courier" , monospace;">hg2git-state</span>.</div>
<div>
<br /></div>
<div>
<span style="font-size: large;">Make sure not to ignoreCase</span><br />
<br />
I <a href="https://github.com/frej/fast-export/issues/87">discovered</a> that on macOS <span style="font-family: Courier New, Courier, monospace;">core.ignoreCase</span> is <span style="font-family: Courier New, Courier, monospace;">true</span> which means that changesets that only change the case of a file name will produce an incorrect git changeset.<br />
<br />
So on macOS the option needs to be explicitly set to <span style="font-family: Courier New, Courier, monospace;">false</span>:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">git config core.ignorecase false</span><br />
<br />
<br /></div>
<div>
<br /></div>
</div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com2tag:blogger.com,1999:blog-30278691.post-87423700685967384732016-12-20T01:19:00.000+02:002016-12-20T01:19:01.848+02:00Minimal NetBSD for Raspberry Pi 2<div dir="ltr" style="text-align: left;" trbidi="on">
For no reason other than fiddling with the NetBSD codebase and build system plus the desire to reduce the world bandwidth waste, I've published <a href="https://github.com/emilianbold/BaseBSD/releases/tag/7.0.2.1">a minimal NetBSD image for the Raspberry Pi 2</a> containing only the base set.<br />
<br />
You only have to download this 76MB compressed image which becomes under 500MB uncompressed so it fits any recent microSD card you have in your drawer.<br />
<br />
I have successfully used such a NetBSD system as a customer proxy of sorts this whole year.<br />
<br />
Because lots of times you just need a machine with SSH and a shell.<br />
<br />
Of course, my patches are minor, it's not like I managed to fit NetBSD <a href="https://github.com/user340/fdgw2">onto a floppy disk</a> but I liked doing it none the less!</div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-76143706934713107992016-12-17T18:20:00.000+02:002016-12-17T18:20:10.583+02:00NBnotify - Native NetBeans Notifications<div dir="ltr" style="text-align: left;" trbidi="on">
<span id="goog_838498669"></span><span id="goog_838498670"></span><a href="http://nbnotify.com/">NBnotify</a> is back with a vengeance: Windows, macOS and Linux notifications from NetBeans plus the very useful build notifications!<div>
<br /></div>
<div>
NBnotify started 6 years ago as a way to integrate NetBeans with OSX and to provide me with build notifications.<br />
<br />
I have almost always used a MacBook Pro as a work laptop for my customers so it was important that NetBeans is hooked up into the Mac ecosystem.<br />
<br />
Back then Growl was the rage, providing customizable notifications for a myriad of Mac applications.<br />
<br />
NBnotify entered into a short limbo while I was busy doing NetBeans customizations, Javascript type inference, JDBC drivers, ANTLR parsers and all in all Java code for paying customers...<br />
<br />
But as soon as I had some free time this winter I had to bring it up to date!<br />
<br />
And not only that -- but I've added first Linux and then Windows support too!<br />
<br />
Actually, since NBnotify natively binds to <a href="https://developer.gnome.org/libnotify/">libnotify</a> it should work on BSD systems too.<br />
<br />
So, if you are using NetBeans, you have to use <a href="http://nbnotify.com/">NBnotify</a>!<br />
<br />
NBnotify is closed source, but only because it was an experiment in the market for NetBeans plugins and productization.<br />
<br />
As soon as the NetBeans codebase is <a href="http://incubator.apache.org/projects/netbeans.html">donated to Apache</a> and we can start work, I plan on slowly integrating these native notifications into NetBeans proper and open-source the plugin.<br />
<br />
NBnotify was always a missing core feature of NetBeans.<br />
<br /></div>
</div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-46874560526955197562016-12-05T12:47:00.000+02:002016-12-05T13:01:38.251+02:00NetBSD cross compilation is a marvel<div dir="ltr" style="text-align: left;" trbidi="on">
While trying to get a patched variant of NetBSD 7.0.2 to run on my Raspberry Pi 3 I had to <a href="https://www.netbsd.org/docs/guide/en/part-compile.html">build NetBSD</a> many times.<br />
<br />
And it was pretty amazing how this all worked.<br />
<br />
You have a single entry point: <span style="font-family: "courier new" , "courier" , monospace;">./build.sh</span> And it does everything! It builds the kernel, the userland apps up to the install image you write on the microSD card.<br />
<br />
Of course, having a top-level script that does everything is nothing new, it's basically the second question in the <a href="http://www.joelonsoftware.com/articles/fog0000000043.html">Joel Test</a>.<br />
<br />
What is amazing is the cross-compilation.<br />
<br />
You have an x64 machine and <span style="font-family: "courier new" , "courier" , monospace;">build.sh</span> will happily create the install image for <i>any</i> supported platform.<br />
<br />
The Raspberry Pi image is just:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">./build.sh -m evbarm -a earmv7hf -u -U release</span><br />
<br />
then you look into the release dir, find <span style="font-family: "courier new" , "courier" , monospace;">arm7.img.gz</span> and you are ready to go.<br />
<br />
I ran the builds on a NetBSD virtual machine, but apparently <span style="font-family: "courier new" , "courier" , monospace;">build.sh</span> will happily run with some small preparation even on Linux or macOS.</div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-86539872228764428072016-12-04T15:55:00.000+02:002016-12-04T16:31:22.445+02:00NetBSD on Raspberry Pi 3<div dir="ltr" style="text-align: left;" trbidi="on">
I have used quite successfully a Raspberry Pi 2 running NetBSD 7 as a customer proxy and I assumed 7.0.2 would run on a Raspberry Pi 3.<br />
<br />
As it turns out, the Raspberry Pi 3 ARM Cortex-A53 processor is different enough from the previous Cortex A7 processor we have on the Pi 2 that it needs some kernel changes.<br />
<br />
And while the bleeding edge NetBSD current- does work on the Raspberry Pi 3, the stable NetBSD 7.0.2 does not.<br />
<br />
I even tried to compile my own NetBSD 7.0.2 and backport <a href="http://freshbsd.org/commit/netbsd/25dd46ce5395e53d8fb8410eecde326e7dc103c8">the patch</a> that added Pi 3 support, plus <a href="https://github.com/raspberrypi/firmware/archive/a192a05bc8ca597249e5a36875ce382c572ddc97.tar.gz">up-to-date</a> firmware, but it seems it's not sufficient. There are probably more related commits that need backporting.<br />
<br />
So, if you have a Raspberry Pi 3 you can only use current- builds. Go on the <a href="http://nyftp.netbsd.org/pub/NetBSD-daily/HEAD/">nightly build server</a>, grab an .img.gz and test it out!<br />
<br />
But if you want a stable NetBSD release, you'll have to wait some more or get a Raspberry Pi 2 instead.<br />
<br />
Getting the Raspberry Pi 2 is not such a bad thing because the Raspberry Pi 3 wireless will probably not work for a while anyhow.</div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-40821690974236707212016-09-06T22:44:00.001+03:002016-09-06T22:44:50.304+03:00Time Machine eating its own tail on a FreeNAS ZFS share<div dir="ltr" style="text-align: left;" trbidi="on">
I work on a Mac and the OSX Time Machine is a very nice and simple feature to have backups.<br />
<br />
While I have some other Apple gear I didn't get an Airport Time Capsule because I already had a tiny Airport Express, the Time Capsule is pricy and I'm not certain it does RAID.<br />
<br />
So, what I use instead is the FreeBSD-based <a href="http://www.freenas.org/">FreeNAS</a> on an N54L MicroServer. FreeNAS allows you to easily create a Time Machine Apple Share and it works seamlessly.<br />
<br />
The nice thing here is that the FreeNAS share is stored on a <a href="https://en.wikipedia.org/wiki/ZFS">ZFS</a> disk! And I have periodic snapshots for those shares.<br />
<br />
So, on one side you have Time Machine storing periodic snapshots and only deleting when it needs space.<br />
<br />
And on the other side you have the ZFS snapshots that guarantee that nothing is truly deleted!<br />
<br />
This proves to be an interesting combination because Time Machine does not expect such a situation when you are low on disk space.<br />
<br />
When you are low on disk space OSX's Time Machine will try to remove some data to free some space. But if you have recent snapshots on your ZFS filesystem, deleting files will not create any free space!<br />
<br />
So Time Machine will keep on going back in history and delete more and more in order to have enough space to do a backup. I'm pretty sure eventualy it will try to delete the whole history.<br />
<br />
Once Time Machine goes free space berserk you have to stop it and fix the problem on the ZFS side.<br />
<br />
Either you delete some snapshots, you increase the filesystem quota or move it to a larger array. <br />
<br />
In order to prevent the damage Time Machine did, you have to use <span style="font-family: "Courier New",Courier,monospace;">zfs rollback</span> to go back to a good snapshot. And in order to find a good snapshot it might be worth using <span style="font-family: "Courier New",Courier,monospace;">zfs diff</span> too.<br />
<br />
The <a href="http://docs.oracle.com/cd/E36784_01/html/E36835/gavvx.html#scrolltoc">Oracle documentation for ZFS Solaris</a> is good enough for this although you might also want to look at the <a href="http://doc.freenas.org/">FreeNAS User Guide</a> for your version.<br />
<br />
Time Machine doesn't seem to be bothered by a rollback and will gladly continue using the same share and finish the backup!<br />
<br />
All in all I believe it's a pretty good combination. In an alternate universe OSX and Time Machine knows ZFS natively but until then FreeNAS gets the job done.</div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-56660762054968255702016-08-23T11:38:00.000+03:002016-08-23T11:38:04.627+03:00Signing NetBeans modules with a Time Stamping Authority (TSA)<div dir="ltr" style="text-align: left;" trbidi="on">
Signing JAR files is a very good practice. And while a proper certificate is not worth the price and effort, self-signing is still a step in the right direction.<br />
<br />
Ever since Java 5 <span style="font-family: Courier New, Courier, monospace;">jarsigner</span> supported a Time Stamping Authority (TSA) with the <span style="font-family: Courier New, Courier, monospace;">--tsa</span> and <span style="font-family: Courier New, Courier, monospace;">--tsacert</span> parameters. A Time Stamping Authority is basically an online digital notary that certifies the point in time the jar was signed -- it is designed to prevent signing files after the certificate expired.<br />
<br />
It turns out that while you can sign NetBeans modules using the <a href="http://wiki.netbeans.org/DevFaqSignNbm">FAQ</a> steps, there is no support in the build harness for a TSA.<br />
<br />
I found bug #<a href="https://netbeans.org/bugzilla/show_bug.cgi?id=243213">243213</a> which also mentions NBM problems and I submitted a patch there.<br />
<br />
So, if you want to also add a timestamp to your NBMs, apply <a href="https://bugzilla-attachments-243213.netbeans.org/bugzilla/attachment.cgi?id=161749">this small patch </a>on top of your NetBeans source repository and rebuild NetBeans.<br />
<br />
Then, you just have to define in <span style="font-family: Courier New, Courier, monospace;">nbproject/project.properties</span> another key with your TSA (I'm using StartSSL's here):<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">tsaurl=http://tsa.startssl.com/rfc3161</span><br />
<br />
<br /></div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0tag:blogger.com,1999:blog-30278691.post-29556567017792504662016-08-03T13:14:00.001+03:002016-08-03T13:14:22.912+03:00Forcing export of internal API in Java 9 with -XaddExports<div dir="ltr" style="text-align: left;" trbidi="on">
I've long been a fan of NetBeans' module system and of OSGi so Java 9's modules are a big improvement to me.<br />
<br />
Except modules are really good at enforcing API boundaries and stop allowing one to freely use any public class.<br />
<br />
An error such as this is no fun:<br />
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;"><br />Error: A JNI error has occurred, please check your installation and try again<br />Exception in thread "main" java.lang.IllegalAccessError: superclass access check failed: class A$1 (in unnamed module @0x3fb6a447) cannot access class jdk.nashorn.internal.ir.visitor.NodeVisitor (in module jdk.scripting.nashorn) because module jdk.scripting.nashorn does not export jdk.nashorn.internal.ir.visitor to unnamed module @0x3fb6a447</span></blockquote>
<br />
I've assumed that this has to be tweaked at SecurityManager level and played with <span style="font-family: Courier New, Courier, monospace;">-Djava.security.manager</span> and <span style="font-family: Courier New, Courier, monospace;">-Djava.security.policy</span> and the very handy <span style="font-family: Courier New, Courier, monospace;">-Djava.security.debug</span>.<br />
<br />
Alas, that doesn't help. (Although I'm still convinced it should, unless there is a bug somewhere).<br />
<br />
What one needs to use is the magical <b><span style="font-family: Courier New, Courier, monospace;">-XaddExports</span></b> flag. This forces an export and allows the code to run:<br />
<br />
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">java -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.ir=ALL-UNNAMED -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.parser=ALL-UNNAMED -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.runtime.options=ALL-UNNAMED -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.runtime=ALL-UNNAMED -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.ir.visitor=ALL-UNNAMED A</span></blockquote>
<br />
<br /></div>
Emilian Boldhttp://www.blogger.com/profile/10960978131273810766noreply@blogger.com0