Wednesday, November 28, 2012

Cleaning Keyboard

Hot tap water. Light scrubbing with some tissues and some detergent. Wiped it down using dry tissue. This is not an expensive keyboard.

Plugged the USB back in; felt no fear doing so, since I believe it is only indirectly connected to the laptop, driver circuits and whatever. Works, despite some amount of water remaining inside of the keyboard. No keys malfunctioning yet.

Has a slightly different feel though; perhaps due to the remaining liquid.

Maybe I'll have to keep tapping on it so that the keys don't become stuck after drying out.

EDIT: don't do as I did. After a while, the up and left arrow keys stopped working. So I unscrewed a gazillon (11 plus five) screws to open the case to wipe the internals. Now all arrow keys work, but the numerals five and six don't work, also two more keys (equals and plus, I think) don't work. Weird thing is that if I hit, say, five key and six key in rapid succession, I get: u6 u6 u6. But not in the reverse order, six key and then five key. Hard to tell which malfunctioning part of the keyboard makes this happen.

Thursday, November 22, 2012

Simple S3 Solution for Maven Repository

Quick post, just the outline for this part-manual solution to publish a repo in the AWS S3 cloud.

# Set up a bucket (or find one to reuse).
# Enable Java for the AWS console (to be able to upload filesystem trees to your cloud bucket).

Each deploy:

# Use Maven's deploy command, specify a file:///tmp/my-repo/ folder as target.
# Upload using the file tree upload.
# Run the 'Make Public' command on the folder uploaded.

That's the skinny of it. Will be good enough for weekly or even daily publishing; but perhaps not for hourly updates.

Details TBD-M.

Wednesday, November 21, 2012

Contrafactual Java Package Name

I know of at least two limitations to package names. One, I've stumbled upon a few times until I learned to avoid it 'by heart': Java keywords.

Just found out about another one: can't start with a (decimal :) numeral. Which is a bummer. For instance, stuff having to do with 3-dimensional maths and graphics would be most easily recognized under the name '3d'.

Workarounds.... for '3d', let's see: Ugly "_3d"? Cryptic "ddd"? Associative "xyz"? Silly "three_d"?

With the keywords, you can at least have a name that starts with the word you'd rather have, helping with matching and alphabetical ordering and such things.

---

I wonder why he/they didn't go for a separate package syntax. I mean, the '.' can never be used as the other form of qualification operator anyway. Maybe there was plans for namespaces-as-objects or something.

(Interesting digression...it could actually be implemented (except being able to use regular dot syntax, of course); take (ClassLoader, InitialPackage) --> PackageNamespaceObject or something.)

Slash syntax would've worked. Contrafactual Java:
package com/mylib/somepackage;

import com/mylib/somepackage/misc/*;
import com/mylib/someotherpackage/thispackage/ThisClass;
import com/mylib/someotherpackage/3d-math/SomeModule;

public class Contrafactual3dDemo { //...
}
(And why not lose those package and import semicolons...)

Learning to Deploy (Maven)

I am in the process of learning how to do public deploys with maven; for instance, to publish java library artifacts. Uploading to AWS S3 would be nice, but one step at a time.

I found no 'deploy' menu item in Eclipse's Maven menus. So I made a nice little script:
cd $(dirname $0)
ls -l

echo -----------------------------------
echo deploying...
echo -----------------------------------

mvn javadoc:jar deploy

echo -----------------------------------
echo deploy script done.
echo -----------------------------------
echo 

echo -----------------------------------
echo damage report...
echo -----------------------------------

find /tmp/maven-tmp-repo

echo -----------------------------------
echo now back to your regular shell, see you later. 
echo -----------------------------------

$SHELL
I have found it to be a nice pedagogical tool. It's of course not much different from doing it manually but it saves work. I've put it in a 'mvn-deploy.command' file next to the 'pom.xml', which also makes for quick deploys -- it's just a double-click to start from inside Eclipse (provided you set the 'executable' property/flag under Properties); no having to navigate to the right directory in the terminal.

(Btw, why doesn't Eclipse have a 'Open Folder In Shell/Terminal'. Or maybe it does, somewhere. Do tell!)

The 'ls -l' at the start is just for context. The 'find' at the end lists all files in the makeshift repository. Yeah, almost forgot: you need something like this in your pom.xml:
<distributionManagement>
    <repository>
            <id>local-tmp-repo</id>
            <name>Temp Folder</name>
            <url>file:///tmp/maven-tmp-repo</url>
        </repository>
</distributionManagement>
Pardon the formatting. (EDIT: Shit, now it looks even worse: '& gt;' and all. Damn you, blogger editor. -- No wait, it looks ok in 'print'.)

So, you can now see in your terminal, or by inspecting the /tmp/ file system tree, how maven adds files like '/1.0-SNAPSHOT/maven-metadata.xml', 'pub-lib-1.0-20121121.203440-1.jar', 'pub-lib-1.0-20121121.205813-2-javadoc.jar', etcetera, without digging in to .m2 (these files are probably simply copies out of the .m2 local repo).

That's it, readers. I just might return with a post about the maven shapshot process, in very concrete terms.

Artifactory Online: Reviewlet

Reviewlet of Artifactory Online.

Home Url: https://secure.artifactoryonline.com/

Sign-Up: easy, but a bit too much filling in of forms. And either there's a glitch, or I mistyped something: the first confirmation mail didn't get back, so I had to add a '2' to the chosen domain, as it was reported as taken. Oh well.

Clicking confirmation link brought me in to the setup process, very simple, a bit slow; but from an implementor viewpoint I can see that it may be hard to keep a pool of fired-up instances ready.

I managed to snap these screenshot during the automatic process:



Done.

Next comes the finding-your-way. I dabbled with Nexus and Artifactory a few years back, so I recognize some of the repo naming schemes. But even thinking a bit, I must confess that I don't remember really fully understanding the scheme.

I am looking to have two 'permissions' of repos, one publicly available, and one for internal libraries. Well, actually, only the public one is really needed. So how do you do such a thing? Not immediately obvious if it is part of the factory set-up or not.

----

Ok, so an unexpected item in the review: finding-your-way-back-to-the-app. Can't seem to find a link from the main page. So I guess browser history, or find the confirmation email in the email history.

----

The repository search browser is pretty nice; I like to have this comprehensive data available like this:


Here, to the left (in this partial screenshot) you can see the list of repos. None of these seem to be the one I am looking for: publicly released artifacts. All these repo names end in '-local'. I suppose the name I am looking for would along the lines of 'libs-releases-public' (and perhaps 'libs-snapshots-public'). Isn't that a common enough usage that the default setup might want to include one?

----

The search I can only presume that it works, since all the shown repos seem to be empty. Maybe the repo1-cache contains something to search for...no. Even such a general pattern as "*X*" finds nothing. I can't get a clue as to why. Possibly they are all empty. One has to click the 'Show...' link as seen in the screenshot to get that number, unfortunately. In each selected one -- not very generous.

----

[TBD-M]

Tuesday, November 20, 2012

Heisenberg Keypress

Breakpoint in JavaScript on keydown. When hit, focus shifts to debugger. The keypress never comes.

I can't observe both the keydown and the keypress event. If I observe the first one, I can't observe the second one.

Good to know. Bad to have to know.

Eclipse Is Back


That's a new one, served fresh in a modal popup close to my face: 
An internal error occurred during: "Launching TestTemplate".
java.lang.NullPointerException
Restart, clean, refresh, nothing helped so far. Is it something in the code itself? Weird. Only other symptoms: 'misplaced' breakpoint (due to quick edit somehow) can't be removed, and no new breakpoints can be added anywhere.

Getting new issues from Eclipse is getting old.

---

(Expletive deleted), this is annoying. Deleted various project files. Open/Closed project, committed all uncommitted, tried the trick "Disable-Enable Dependencies" described in earlier posts, et-f5g-cetera. No go.

---

Found a clue: after deleting the contents of target/, the classes/ and test-classes/ folders are recreated, but they don't get populated. Is it my deletion of the .settings project files, or is it the original problem?

...no, the .settings/ files are actually back (org.eclipse.jdt.core.prefs, org.maven.ide.eclipse.prefs).

---

Two more clues: the process roster has a large number of zombie-like processes in it. When they are terminated, they take a long time, then both die, and a dialog "Termination Failed" is shown.

And shifting to 'Run' instead of 'Debug As..' I get this:


Exception in thread "main" java.lang.NoClassDefFoundError: org/pub/TemplateTest
Caused by: java.lang.ClassNotFoundException: org.pub.TemplateTest
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

Yeah, if the build isn't working, that's not totally weird.

It's interesting that this causes the debugger to not be able to connect to the child process! Is it that it fails so fast, that there's no time? Or does it depend on a working classpath? Would be interesting to know...

---

Solution: rename the project. Don't ask me why it works. My guess is that some cache or setting is associated with the project name.

Repugnant shit...

Thursday, November 15, 2012

Killing Port Owners

This post is about a bunch of ways to do find and kill the process that owns a specific port.

First, some context. [TBD]

Now: the kills! In the below examples, the port number is 8181.

Here's the first way. Find or open a terminal; type:
lsof -i:8181 -t | xargs kill -9

-- TO BE EXTENDED

Wednesday, November 14, 2012

Trying WebStorm

In JavaScript Development Sucks, I detailed some things that make it so. We can consider this a tools issue; at least as far as the language makes tool-making feasible. And it's easy to imagine pretty good tools for JavaScript. Refactoring may be largely out of reach with such a language, at least without assumptions or whole-program analysis. But that's not impossible either.

Am in the process of trying out WebStorm, an IDE in the IntelliJ family. So far:
+ autocompletion seems to be good; looks into at least files in same dir (probably also whole project)
+ it's aware of JS-specific features like 'arguments' -- if 'arguments' is used, an otherwise unused argument is no longer considered to be unused.

Well that's about it. I haven't understood how IntelliJ 'works', so it's pretty slow going. Maybe I'll end up with an expired trial period, as last time when I tried IntelliJ for JEE, forgetting about the period since I have work to do.


Eclipse Drag-And-Drop Idea

Just realized that the serious usability problems with drag-and-drop in Eclipse has a surprisingly obvious solution!

If you have a large number of files and folders in your project source trees, drag-and-drop is a serious pain in the rear, because you may have to wait for scrolling, which is slow and a bit finicky to control. And if you over-scroll, you have to move the drag to the other end of the scrolled pane. Etcetera. And even remembering the target is difficult.

For moves within the same 'classpath entry' (e.g. src/main/java) there is at least the alternative of typing a new package name -- with auto-completion assisting you -- and then using the quick fix 'move', but for moves between projects, for instance, the problem remains.

However, I just got this really simple and in-hindsight-ly obvious idea: why not open a second 'Navigator' view? Turns out I don't know how to do that. But there is a an almost-as-good solution: the possibility to drag-and-drop into panes of other kinds! At least into the 'Project Explorer', just tried it.

Well, one simple trick closer to peaceful cooperation with Eclipse. Many annoyances remain to be worked around.

Monday, November 12, 2012

Fix Maven Source Version Having No Effect

In a recent article at http://impossible-is-development.blogspot.com/2012/11/basic-maven-project-build-fix-tip.html, I wrote about a trick to get the .classpath file to reflect the src/main/java etcetera build structure. This trick actually helps in another not-to-uncommon situation: unsyncronized source versions.

If you create a new pom.xml, it may happen that there is no Java versions information given. The version can be given in two ways; via some xml using a 'properties' tag, or via more xml. 

Plugin config: 
<build>
<plugins>
<plugin>
maven-compiler-plugin
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin></plugins>
Sorry about the formatting. (Doesn't the Blogger editor suck something awful for quotes and code? ...hmm...can one blog on Github?)

<project.build.source>1.6</project.build.source> <project.build.target>1.6</project.build.target>
(Again, sorry about the formatting.)

Now; if you add this to an existing pom.xml, Eclipse may fail to take note of this change automatically. Maybe it never takes note. In any case, the same solution applies here as in the earlier blog post: just disable and enable dependency management.

Slashdot Descriptors Feature For Stack Overflow

You probably already know about Stack Overflow, a mostly nice Q&A site. There are still some problems with it, in my experience.

One problem is getting down-voted without explanation. Has happened to me lots of times, so you get used to it, you even expect it (without submitting knowingly bad questions, to be clear). But it's still confusing.

There is a solution, that would help at least some: down-vote buttons should be categorized. We know and love this feature on Slashdot: moderation descriptors. The complete list seems to be: normal, offtopic, flamebait, troll, redundant, insightful, interesting, informative, funny, overrated, or underrated (from http://en.wikipedia.org/wiki/Slashdot).


The negative ones are: offtopicflamebaittrollredundantoverrated. 

The positive ones are: insightfulinterestinginformativefunnyunderrated.

I haven't thought up good descriptors for Stack Overflow, but why not reuse the canned answers used when a question is considered so bad that it gets deleted? Maybe: 'unclear', 'shopping-list', 'clearly-homework', 'submitter-should-have-tried-harder', et cetera.





Thursday, November 8, 2012

Eclipse/SVN Nice Going


Trying to add new property 'svn:ignore' with value 'target
.settings
',
but property already exists with value '.settings
target
'.

Tuesday, November 6, 2012

Missing Quick Fix In Package-Info File

Creating a package-info.java is useless without the package declaration. But strangely, in Eclipse, you get no error if you leave the file empty. And the usual Quick Fix to mend the package declaration is absent. Odd.

But the solution is simple: just add a "class X {}". It's legal syntax, and when that class declaration is present, you'll get that helpful Quick Fix. You can then remove the class if you want -- after you invoke the 'Add Package Declaration' Quick Fix.

Java Project Modularity Woes

We want to publish:
1) an API (DTOs and stuff), 20 classes or so.
2) a devkit. A simple server based on Jetty, less than ten classes.

Now, of course there are ways to do it. But no really good ways, I believe.

We may have to use Maven here.


Basic Maven Project Build Fix Tip

Sometimes, in Eclipse, a maven project will not be properly set up. For instance, when you create a maven project by creating a pom.xml file inside a folder. This can be seen by inspecting the '.classpath' file -- it will contain only these three items (or similar):


<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> 

<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> 

<classpathentry kind="output" path="target/classes"/>


Then, what you do is this: simply "Disable Dependency Management" and then "Enable Dependency Management" from the "Maven" menu in the contextual menu from the project. If you keep the ".classpath" file open, you'll be able to see the what happens.

In the 'Disable' step, the Maven entry disappears:
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
Then, in the 'Enable' step, the entries which enable the build appears:
kind="src" output="target/classes" path="src/main/java"> 
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
 along with the 'MAVEN2_CLASSPATH_CONTAINER' thing mentioned above. Done!

--

Today I discovered that the above maneuver is in fact useful to handle another problem involving mis-synchronization between ".classpath" and the "pom.xml" file. Article forthcoming.

Monday, November 5, 2012

AWS Alarm Super Easy to Set: Warning

Mea culpa: I must've not clicked the link in the confirmation email. Just tried adding my email, and now it shows up in the SNS console of 'NotifyMe'. Me bad,AWS good!

However... it would be nice if the AWS alarm GUI could warn me of such a condition as where a notification has no confirmed endpoints.

---

In a previous post, I stated that the AWS alarm feature is super-easy to use. That may be the case, but it seems to not have sent me the notification mail I expected.

So now I am trying to find out information about what happened, and that turns out to be not so easy.

Clicking the link next to the alarm status icon gets you alarm info -- good. Then you can get history data pertaining to this alarm -- fine. And even some JSON describing what happened -- might be useful.

What seems not possible to get, is information about the action connected to the event. I am pretty sure that I filled in the e-mail field correctly, but what else might cause me to not get that email? So I want to check the settings in the connected action, which happens to have the name "NotifyMe".

In the "Edit" view, there is this information: "This is an SNS Console managed topic and cannot be viewed". 

That's an unexpected complication. By the way, 'SNS' means 'Simple Notification Service'.

Entering the SNS Console, there is no trace of the email I entered back when I created the alarm. Mysterious. 

Why did I think that it'd be easy, and Just Work? It's a rare event -- like diamonds -- when something just works. I should've tried the alarm out, of course. 

Maybe there is an email sent as confirmation when the notification is set. Then you could check that email, and if you don't get that email, something is wrong.