tag:blogger.com,1999:blog-73182538091786125912024-02-06T19:19:53.404-08:00James Moore's code blogJMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.comBlogger98125tag:blogger.com,1999:blog-7318253809178612591.post-6122400078272669412020-03-12T21:45:00.000-07:002020-03-12T21:45:06.217-07:00Working remote / working from home<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">I've been working remote for most of the past fifteen years. Here's what's made it work well for me. </span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<b id="docs-internal-guid-11da3b21-7fff-f106-26f9-d4b1e4946d27" style="font-weight: normal;"><br /></b></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">These tips are from the point of view of someone who writes software, and talks to other people about writing software, all day every day. </span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<br /></div>
<ul style="margin-bottom: 0; margin-top: 0;">
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline; white-space: pre;"><div dir="ltr" role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">Have a dedicated space. Having an office that's a dedicated workspace means you can set up things the way you want and leave them set up. No taking down your physical dev environment because someone needs the space for something else.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline; white-space: pre;"><div dir="ltr" role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">High quality computer. My current setup is a very hefty desktop machine. Yours might be a good laptop. Whatever it is, make sure it's up to the job.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline; white-space: pre;"><div dir="ltr" role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">Get the keyboard you like. Get several of them. I'm partial to the </span><a href="https://www.amazon.com/Freestyle2-Wireless-Ergonomic-Keyboard-Separation/dp/B00NMVJZ1E/ref=sr_1_4?dchild=1&keywords=kinesis+keyboard&qid=1584073773&sr=8-4" style="text-decoration: none;"><span style="-webkit-text-decoration-skip: none; background-color: transparent; color: #1155cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">https://www.amazon.com/Freestyle2-Wireless-Ergonomic-Keyboard-Separation/dp/B00NMVJZ1E/ref=sr_1_4?dchild=1&keywords=kinesis+keyboard&qid=1584073773&sr=8-4</span></a><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">, but you should experiment.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline; white-space: pre;"><div dir="ltr" role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">Fast internet. The best you can find. Unfortunately, for lots of people there's exactly one choice, so make sure you live somewhere that has good service.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline; white-space: pre;"><div dir="ltr" role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">Get out of the house before you start work. For me, it's walking up to morning coffee at </span><a href="https://candpcoffee.com/" style="text-decoration: none;"><span style="-webkit-text-decoration-skip: none; background-color: transparent; color: #1155cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration-skip-ink: none; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">https://candpcoffee.com/</span></a><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">. Get up, get out of the house, come back to work. Leaving the house first thing in the morning (even though I'm coming right back) means I'm creating a boundary between my morning routine and my work day.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline; white-space: pre;"><div dir="ltr" role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">Get used to doing lots of things in writing. That might mean slack, or it might be email, doesn't matter. This is a great habit anyway; if your company gets lots of things done because random hallway conversations happen, you're in a world of hurt anyway.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline; white-space: pre;"><div dir="ltr" role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">Don't hesitate to start voice conversations, via whatever tools you use. No one has a desk phone any more, but things like slack have a call button. Use it, and use it often.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline; white-space: pre;"><div dir="ltr" role="presentation" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">Pay attention to the cat. Sometimes you need small distractions; for me it's our cats. When you're in an office, your days are mostly filled with distractions and timewasting random conversations, with occasional breaks for doing the things you're actually paid to do. At home, you'll find that's flipped, with much more time for actual work. Your brain will function better when you make sure to take small breaks.</span></div>
</li>
</ul>
James Moorehttp://www.blogger.com/profile/00881846109577158489noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-46054932395487295792017-03-30T08:50:00.002-07:002017-03-30T08:51:37.921-07:00Errors when you try to run more than one spark shellIf you have a spark shell running, and you forget it's there and start another one, you'll see errors like the ones below.<br />
<br />
If you're like me, all the useful bits that point straight at the problem have scrolled off your screen, so you'll probably waste some time on google looking for other people having problems with <b>error: not found: value spark</b>. Hopefully that google search has lead you here, and you can now go kill all your extra spark shell sessions.<br />
<br />
<script src="https://gist.github.com/banshee/51050ec2d33835ae77bd5516cfec7d0f.js"></script>JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-25877386449816439042016-10-25T19:52:00.001-07:002016-10-25T19:52:29.898-07:00Good deal tomorrow on Alaska business class flight tomorrow with miles LAX -> LHRFound this one browsing around Alaska's flights, figuring out a trip for next year - 50k miles for a business class ticket LAX -> LHR seems like a really good deal to me:<br />
<br />
<span id="goog_247297777"></span><span id="goog_247297778"></span><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxsAsDq9_lY1T8hAHikIhlAo2WpiRvanKV6Oi-UgxurY1NX5Pd8T36l-3W0ZBKvVsLMlrtd1Xnm5ddv3gvS7hv6aJZ-vfVSoHB3qDTVGBpjysH-2s0A3iVw13QDyP0Dqq_OqweYNJGlAaV/s1600/Untitled.png" imageanchor="1"><img border="0" height="304" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxsAsDq9_lY1T8hAHikIhlAo2WpiRvanKV6Oi-UgxurY1NX5Pd8T36l-3W0ZBKvVsLMlrtd1Xnm5ddv3gvS7hv6aJZ-vfVSoHB3qDTVGBpjysH-2s0A3iVw13QDyP0Dqq_OqweYNJGlAaV/s640/Untitled.png" width="640" /></a><br />
<br />
<br />JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-18799485009275386052016-06-21T19:56:00.001-07:002016-06-21T19:56:54.430-07:00Xamarin Studio + Android StudioIf you have a Xamarin Studio project for an Android application, you'll probably want to use Android Studio to edit the resource files.<br />
<ul>
<li>Create a new Android Studio project (I usually call it AndroidStudioHolder, but the name is unimportant)</li>
<li>cd AndroidStudioHolder/app/src/main</li>
<li>rm -rf res</li>
<li>ln -s ../../../../YourAndroidProject/Resources res</li>
</ul>
<div>
Unfortunately, you still have to deal with all the weird naming issues that Xamarin Studio creates. You should fix them anyway, and it's easier to do it early in the project. (Main.axml isn't a real layout file, for example, even though Xamarin Studio will create it for you by default.)</div>
JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-10724910593853729752016-05-26T10:04:00.000-07:002016-05-26T10:17:54.146-07:00Using F# modules and types from C#It's simple to use FSharp modules from C#, but for some reason I always forget exactly how the system works <br />
(maybe too much switching back and forth between Scala/C#/F#/Java...).<br />
<br />
Here's some F# snippets and a C# example of how to pull them together. The weird one is C#'s "using static", since the name seems to indicate that it's just pulling in static methods. In addition to pulling in static methods, though, it also pulls in nested types.<br />
<br />
<script src="https://gist.github.com/banshee/55b0f0516c4977d7aa44f918a3646bc6.js"></script><br />
<br />
<script src="https://gist.github.com/banshee/f9a7ea2642d37725cbfcb1432b40d135.js"></script><br />
<br />
<script src="https://gist.github.com/banshee/bbec82f52c92df98111398ed4c033cc3.js"></script><br />
<br />
Consuming from F# is slightly simpler:<br />
<br />
<script src="https://gist.github.com/banshee/2af9cf426c0697e8cd4bebcae5e01de5.js"></script><br />
<br />
Here's <a href="http://fsharp.org/specs/language-spec/">the F# specification</a> for more details.JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-31967920960328677732016-02-10T17:41:00.001-08:002016-02-10T17:42:13.005-08:00Fun with Shapeless - functions taking arguments converted to functions taking HList'sI'm starting to play with the <a href="https://github.com/milessabin/shapeless">Shapeless</a> Scala library.<br />
<br />
Here's how to take a normal function and turn it into a function that accepts an HList instead of the original arguments.<br />
<br />
<script src="https://gist.github.com/banshee/afc1d024849ddc1a0807.js"></script>JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-16574888906179386612015-12-27T19:44:00.000-08:002015-12-27T19:44:13.427-08:00Intellij not adding things to the classpath - Exception in thread "main" java.lang.NoSuchMethodError: shapeless.Witness$.mkWitness(Ljava/lang/Object;)Lshapeless/Witness;Using Intellij? Just added circe (or shapeless, I'm guessing)? Seeing these sorts of exceptions?<br />
<br />
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"></span><br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">Exception in thread "main" java.lang.NoSuchMethodError: shapeless.Witness$.mkWitness(Ljava/lang/Object;)Lshapeless/Witness;</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">at Example$fresh$macro$73$1.inst$macro$1$lzycompute(PicklingApp.scala:26)</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">at Example$fresh$macro$73$1.inst$macro$1(PicklingApp.scala:26)</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">at Example$.delayedEndpoint$Example$1(PicklingApp.scala:26)</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">at Example$delayedInit$body.apply(PicklingApp.scala:16)</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">at scala.Function0$class.apply$mcV$sp(Function0.scala:34)</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">at scala.App$$anonfun$main$1.apply(App.scala:76)</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">at scala.App$$anonfun$main$1.apply(App.scala:76)</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">at scala.collection.immutable.List.foreach(List.scala:381)</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">at scala.App$class.main(App.scala:76)</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">at Example$.main(PicklingApp.scala:16)</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">at Example.main(PicklingApp.scala)</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">at java.lang.reflect.Method.invoke(Method.java:606)</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)</span></span></div>
<span id="docs-internal-guid-58cd2178-e6ae-eeba-7065-a8d1c7ceb945"><br />
</span>Just restart Intellij. It's become confused about the classpath.<br />
<div>
<br /></div>
JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-38936374341428243882015-04-22T10:23:00.001-07:002015-04-22T10:28:30.921-07:00Xamarin Studio 5.9 + F# - Target _CreateNativeLibraryArchive failingIf you're seeing an error like this in Xamarin Studio 5.9, building an Android project:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;"> Target _CreateNativeLibraryArchive:<br />/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets:<br />error : Error executing task CreateNativeLibraryArchive: Argument cannot be<br />null.<br />Parameter name: unformatted<br />Build FAILED.</span><br />
<div>
<br /></div>
<div>
You may have mips binary files marked as EmbeddedNativeLibrary. Turn that off (mips isn't supported yet anyway), and you should be able to build.<br />
<br />
The bug has been reported to Xamarin - tech support found the solution.</div>
James Moorehttp://www.blogger.com/profile/00881846109577158489noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-5072798620910048852014-05-17T16:47:00.000-07:002014-05-17T16:54:03.342-07:00Topic from scalaz-streamI've been playing around with scalaz-stream topics, and didn't understand how they worked. My first attempt was this:<br />
<br />
<script src="https://gist.github.com/banshee/14bdade885fb11e568cb.js"></script><br />
<br />
(And note that this was supposed to be just a quick example; you certainly would end up with different threads publishing and subscribing to a topic.)<br />
<br />
That had a few problems:<br />
<br />
• Line 7-8: the type of out1 is Process[Task, String \/ Int]. Those are useful, but they're only part of the way towards what I needed. What I really wanted was to go from a process to a task to running the task.<br />
<br />
• Line 11-13: again, I'm only part of the way there. Both of these produce Task[Unit], and they needed to be run.<br />
<br />
So I asked for help on the scalaz mailing list, and <a href="https://groups.google.com/forum/#!search/scalaz$20stream$20james/scalaz/NQd-ug-Yhk0/Q9uPOyfpDBwJ">Pavel Chlupáček pointed me in the right direction</a>.<br />
The working version is:<br />
<br />
<script src="https://gist.github.com/banshee/2fa9d563991dcc9bdc5b.js"></script><br />
<br />
• Lines 6-8 produce a Task[IndexedSeq[String \/ Int]], one step further than in the first version (where the steps are process >> task >> run the task).<br />
<br />
• Lines 10-12 actually run the task - and anything published before the attemptRun won't be seen by the subscriber.<br />
<br />
• Line 19 stalls, waiting for the attemptRun to hook up the subscriber. (As the note says, I think this is only something you'd do for a demo).<br />
<br />
• Lines 21-22 actually run the tasks they create<br />
<br />James Moorehttp://www.blogger.com/profile/00881846109577158489noreply@blogger.com1tag:blogger.com,1999:blog-7318253809178612591.post-49601272425886237382014-04-27T10:46:00.001-07:002014-04-27T10:46:59.632-07:00AndroidProguardScala 51 released - supports 2.11I just released v 51 of AndroidProguardScala, the Eclipse plugin for Scala + Android development.<br />
<br />
The release adds support for Scala 2.11 (including the 3.x.x and 4.x.x branches of the Scala IDE).<br />
<br />
Install instructions are <a href="https://github.com/banshee/AndroidProguardScala">here</a>.James Moorehttp://www.blogger.com/profile/00881846109577158489noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-43564050510644634972014-01-04T12:25:00.000-08:002014-01-04T12:25:00.123-08:00Using ruby to explore scalazI've been poking around scalaz, and sometimes it's nice to just get a quick overview of the code using some simple ruby. I could write some code using asm to look at the bytecode, but it's usually faster for me to just use ruby on the source. I'm not looking for 100%-complete tested code here, it's more like a very fancy grep.<br />
<br />
For example, I was curious about all the places that define functions starting with lift:<br />
<br />
<script src="https://gist.github.com/anonymous/8260165.js"></script><br />
<br />
And then to read the output, I use a google spreadsheet:<br />
<br />
<iframe frameborder="0" height="300" src="https://docs.google.com/spreadsheet/pub?key=0AmxC0dwhhLGIdFZQYWxMc2xhTFpkYlJOWXBZT2RuM1E&output=html&widget=true" width="500"></iframe><br />
<br />
Run with:<br />
<br />
<div class="p1">
<span style="font-family: Courier New, Courier, monospace;">find * -name *.scala -type f -print0 | xargs -0 ruby lift.rb | pbcopy</span></div>
<div class="p1">
<span style="font-family: Courier New, Courier, monospace;"><br />
</span></div>
<div class="p1">
<span style="font-family: inherit;">pbcopy is the mac utility that copies stdout to the clipboard, so it's fast to run this from the command line, switch to the spreadsheet, and hit paste.</span></div>
JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-17237118358513154582013-09-01T10:50:00.002-07:002013-09-01T10:50:34.948-07:00Combine reference.conf files from a bunch of akka jars<div style="background-color: rgba(255, 255, 255, 0.952941); border: 0px; box-sizing: border-box; color: #3f4549; font-size: 14.399999618530273px; line-height: 15.199999809265137px; padding: 0px;">
<span style="font-family: Helvetica Neue, helvetica, arial, sans-serif;">Need to build a reference.conf from a bunch of different Akka jars? Here's a simple way to do it from the command line:</span><br style="box-sizing: border-box;" /><br style="box-sizing: border-box;" /><span style="font-family: Courier New, Courier, monospace;">for i in /Users/james/nexus/sonatype-work/nexus/storage/central/com/typesafe/akka/*/2.2.1/*jar ; do unzip -q -c $i reference.conf ; done > /tmp/reference.conf</span></div>
<div style="background-color: rgba(255, 255, 255, 0.952941); border: 0px; box-sizing: border-box; color: #3f4549; font-family: 'Helvetica Neue', helvetica, arial, sans-serif; font-size: 14.399999618530273px; line-height: 15.199999809265137px; padding: 0px;">
<br style="box-sizing: border-box;" /></div>
<div style="background-color: rgba(255, 255, 255, 0.952941); border: 0px; box-sizing: border-box; color: #3f4549; font-family: 'Helvetica Neue', helvetica, arial, sans-serif; font-size: 14.399999618530273px; line-height: 15.199999809265137px; padding: 0px;">
That just cats together the contents of all the reference.conf files and puts it in /tmp/reference.conf.</div>
<div style="background-color: rgba(255, 255, 255, 0.952941); border: 0px; box-sizing: border-box; color: #3f4549; font-family: 'Helvetica Neue', helvetica, arial, sans-serif; font-size: 14.399999618530273px; line-height: 15.199999809265137px; padding: 0px;">
<br style="box-sizing: border-box;" /></div>
<div style="background-color: rgba(255, 255, 255, 0.952941); border: 0px; box-sizing: border-box; color: #3f4549; font-family: 'Helvetica Neue', helvetica, arial, sans-serif; font-size: 14.399999618530273px; line-height: 15.199999809265137px; padding: 0px;">
Adjust the paths to fit your version and file locations, of course.</div>
JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-81633315693765224152013-08-19T09:27:00.001-07:002013-08-19T09:27:10.098-07:00Using F# on iOS - need to build from source for monodevelopIf you're starting to use F# on iOS using Xamarin.iOS, you'll need to build some parts from source. I submitted a patch to the instructions that should eventually end up <a href="http://fsharp.org/use/ios/" target="_blank">on the F# foundation website</a>. In the meantime, you can see the instructions <a href="https://github.com/banshee/fsfoundation/blob/gh-pages/use/ios/index.md" target="_blank">here</a> in my github fork.JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-25997024798488577222013-08-10T17:56:00.002-07:002013-08-10T17:56:39.409-07:00v50 of AndroidProguardScala releasedJust released v50 of the AndroidProguardScala Eclipse plugin. Installation instructions are <a href="https://github.com/banshee/AndroidProguardScala">here</a>, and if you're a current user you can pick it up by asking Eclipse to check for updates.<br />
<br />
Changes:<br />
<br />
<ul>
<li>Update to latest version of dependencies (Scala 2.10.2, Scalaz 7.0.2)</li>
<li>Better checking for Proguard errors</li>
</ul>
JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-17106774844544558132013-08-01T22:21:00.000-07:002013-08-01T22:21:07.874-07:00Glassware in Scala and ScalazI've been working on a Scala port of one of the Glassware samples. You'll find the code <a href="https://github.com/banshee/mirror-quickstart-java">here on Github</a>.<br />
<br />
It has examples of a few really useful Scalaz features. In particular, it has a bunch of examples of using EitherT in for-comprehensions.JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-87038154460793827312013-05-12T19:12:00.001-07:002013-05-12T19:12:48.613-07:00F# Parsing XML, aiming to get to Type ProvidersFor a new project, I've started using some F# again. Type providers are brand new since last I used the language, so I thought I'd start out by writing my own type provider to deal with some xml apis I'll be using.<br />
<br />
One of things I missed from F# was sequence generators. Here's a sequence generator that turns XML into a slightly different form, hopefully easier to consume from a type provider:<br />
<script src="https://gist.github.com/anonymous/5565747.js"></script><br />
Here's the output:<br />
<script src="https://gist.github.com/banshee/5565772.js"></script>JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-83593302428298289962013-04-22T10:24:00.000-07:002013-04-22T10:24:25.945-07:00tinyxml issue with ctype.hCompiling tinyxml for iOS? Seeing this kind of error?<br />
<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">tinyxml.cpp:25:10: fatal error: 'ctype.h' file not found</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
You probably just upgraded Xcode, or just installed it. You don't have the right simulator installed. Go to Xcode preferences -> Downloads tab and install the right simulator.<br />
James Moorehttp://www.blogger.com/profile/00881846109577158489noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-63544022059000509312013-04-11T09:51:00.000-07:002013-11-26T09:30:05.731-08:00Very simple Google Spreadsheet codeFYI - this blog post is from a long time ago, and I think things have changed quite a bit. I'm leaving it here because some parts my still be useful, but definitely read the comments and don't expect it to work out of the box. <i>- James, 26 Nov 2013</i><br />
<br />
(Update - see comment from Sean about this no longer working due to auth changes from Google)<br />
<br />
I wanted to use data from a google docs spreadsheet in a project, and the sample code all talks about how to authenticate and get lists of documents for a user.<br />
In my case, I already had a public document that I wanted to read. <br />
You’ll want to read the doc <a href="http://code.google.com/apis/spreadsheets/data/3.0/developers_guide.html" target="_blank">here</a> first, but there were two gaps. <br />
<ol>
<li>It wasn’t straightforward (at least for me) to figure out exactly what the URL for a public spreadsheet should be (the doc concentrates on private documents, and assumes you’re going to be iterating through a list of available spreadsheets, not going straight to a specific one). </li>
<li>It wasn’t clear which Java classes mapped to the URLs I had. </li>
</ol>
So here’s a very simple sample, reading data from <a href="https://spreadsheets.google.com/spreadsheet/ccc?key=0AsaDhyyXNaFSdDJ2VUxtVGVWN1Yza1loU1RPVVU3OFE&hl=en_US&authkey=CLXm3-ML" target="_blank">this public spreadsheet</a>:<br />
<br />
<iframe frameborder="0" height="140" src="https://spreadsheets0.google.com/spreadsheet/pub?hl=en_US&hl=en_US&key=0AsaDhyyXNaFSdDJ2VUxtVGVWN1Yza1loU1RPVVU3OFE&single=true&gid=0&output=html&widget=true" style="height: 174px; width: 500px;" width="500"></iframe>
The output:<br />
<pre>One
1
Two
2
Three
3</pre>
The code:<br />
<div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:b9f9b760-806d-421e-8961-1dd2d6554616" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
<pre class="brush: java; gutter: true; first-line: 1; tab-size: 4; toolbar: false; width: 829px; height: 450px;" style="height: 450px; overflow: auto; width: 829px;">package com.banshee;
import java.io.IOException;
import java.net.URL;
import com.google.gdata.client.spreadsheet.SpreadsheetService;
import com.google.gdata.data.spreadsheet.CustomElementCollection;
import com.google.gdata.data.spreadsheet.ListEntry;
import com.google.gdata.data.spreadsheet.ListFeed;
import com.google.gdata.util.ServiceException;
public class SpreadsheetSucker {
public static void main(String[] args) {
SpreadsheetService service = new SpreadsheetService("com.banshee");
try {
// Notice that the url ends
// with default/public/values.
// That wasn't obvious (at least to me)
// from the documentation.
String urlString = "https://spreadsheets.google.com/feeds/list/0AsaDhyyXNaFSdDJ2VUxtVGVWN1Yza1loU1RPVVU3OFE/default/public/values";
// turn the string into a URL
URL url = new URL(urlString);
// You could substitute a cell feed here in place of
// the list feed
ListFeed feed = service.getFeed(url, ListFeed.class);
for (ListEntry entry : feed.getEntries()) {
CustomElementCollection elements = entry.getCustomElements();
String name = elements.getValue("name");
System.out.println(name);
String number = elements.getValue("Number");
System.out.println(number);
}
} catch (IOException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
}
}
}
</pre>
<!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div>
JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com7tag:blogger.com,1999:blog-7318253809178612591.post-18981584903545317842012-10-16T09:46:00.000-07:002012-10-16T09:46:00.773-07:00sbt: pushing and pulling from a local Nexus installationHere's a simple build.sbt for pushing and pulling from a local Nexus repository. The Nexus repository has almost no configuration changes; I've added a password for the deployment user (here given as "deploy"), but other than that it's running with the settings that came out of the box. Note that the hostname in my case is "git", and Nexus uses the default port of 8081.<br />
<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">name := "fnord"</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">organization := "com.restphone"</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">version := "0.1-SNAPSHOT"</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">scalaVersion := "2.10.0-RC1"</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">// Compile for these Scala versions</span><br />
<span style="font-family: Courier New, Courier, monospace;">crossScalaVersions := Seq("2.9.1", "2.9.2", "2.10.0-RC1")</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">publishMavenStyle := true</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">scalaSource in Compile <<= baseDirectory(_ / "src")</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">resolvers += "Sonatype OSS Snapshots" at "http://git:8081/nexus/content/repositories/snapshots"</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">resolvers += "Sonatype OSS Snapshots" at "http://git:8081/nexus/content/repositories/releases"</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">libraryDependencies ++= Seq(</span><br />
<span style="font-family: Courier New, Courier, monospace;"> "com.restphone" % "artifactname" % "1.0"</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;">publishTo <<= version { (v: String) =></span><br />
<span style="font-family: Courier New, Courier, monospace;"> val nexus = "http://git:8081/nexus/content/repositories/"</span><br />
<span style="font-family: Courier New, Courier, monospace;"> if (v.trim.endsWith("SNAPSHOT"))</span><br />
<span style="font-family: Courier New, Courier, monospace;"> Some("snapshots" at nexus + "snapshots")</span><br />
<span style="font-family: Courier New, Courier, monospace;"> else</span><br />
<span style="font-family: Courier New, Courier, monospace;"> Some("releases" at nexus + "releases")</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;">credentials += Credentials("Sonatype Nexus Repository Manager", </span><br />
<span style="font-family: Courier New, Courier, monospace;"> "git", </span><br />
<span style="font-family: Courier New, Courier, monospace;"> "deployment",</span><br />
<span style="font-family: Courier New, Courier, monospace;"> "deploy")</span><br />
<div>
<br /></div>
James Moorehttp://www.blogger.com/profile/00881846109577158489noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-16217277353655611442012-08-19T11:49:00.002-07:002012-08-19T11:49:30.599-07:00Looks like switching to zfs was worth doing:<br />
<br />
<br />
<pre>pool: jamespool
state: ONLINE
status: One or more devices has experienced an unrecoverable error. An
attempt was made to correct the error. Applications are unaffected.
action: Determine if the device needs to be replaced, and clear the errors
using 'zpool clear' or replace the device with 'zpool replace'.
see: http://zfsonlinux.org/msg/ZFS-8000-9P
scan: scrub repaired 0 in 29h13m with 0 errors on Fri Aug 17 13:12:16 2012
config:
NAME STATE READ WRITE CKSUM
jamespool ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
scsi-SATA_WDC_WD7500AACS-_WD-WCAU47125177 ONLINE 0 0 0
scsi-SATA_WDC_WD7500AACS-_WD-WCAU47162708 ONLINE 0 0 0
mirror-1 ONLINE 0 0 0
scsi-SATA_WDC_WD7500AAKS-_WD-WCAPT0622481 ONLINE 0 0 0
scsi-SATA_ST3000DM001-9YN_S1F01R75-part1 ONLINE 0 0 0
mirror-2 ONLINE 0 0 0
scsi-SATA_WDC_WD7500AAKS-_WD-WCAPT0622515 ONLINE 0 0 0
scsi-SATA_ST3000DM001-9YN_S1F01R75-part2 ONLINE 0 0 0
mirror-3 ONLINE 0 0 0
scsi-SATA_WDC_WD15EARS-00_WD-WMAVU2129350-part1 ONLINE 0 0 3.50K
scsi-SATA_ST3000DM001-9YN_S1F01R75-part3 ONLINE 0 0 0
mirror-4 ONLINE 0 0 0
scsi-SATA_WDC_WD15EARS-00_WD-WMAVU2129350-part2 ONLINE 0 0 429
scsi-SATA_ST3000DM001-9YN_S1F01R75-part4 ONLINE 0 0 0
</pre>
SMART isn't seeing a problem with scsi-SATA_WDC_WD15EARS-00_WD-WMAVU2129350 yet though.JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-31287742407542567072012-08-10T17:20:00.000-07:002012-08-10T17:20:00.137-07:00OpenSL ES for Android - SL_RESULT_CONTENT_UNSUPPORTEDIf you're getting a SL_RESULT_CONTENT_UNSUPPORTED result from OpenSL like this:<br />
<br />
<pre>E/AudioRecord( 2108): AudioFlinger could not create record track, status: -1
E/libOpenSLES( 2108): android_audioRecorder_realize(0x1cde560) error creating AudioRecord object
W/libOpenSLES( 2108): Leaving Object::Realize (SL_RESULT_CONTENT_UNSUPPORTED)
</pre>
<br />
look a bit higher in the log. The solution might be staring you in the face:<br />
<br />
<pre>W/ServiceManager( 81): Permission failure: android.permission.RECORD_AUDIO from uid=10078 pid=2108
E/AudioFlinger( 81): Request requires android.permission.RECORD_AUDIO
</pre>
JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-65688947971830242562012-07-24T09:11:00.001-07:002012-07-24T09:11:38.396-07:00scalaz for the Eclipse Scala IDE pluginThere's a brand new build of scalaz 6.0.4 for M5 that seems to work well with the Eclipse plugin. If you were having issues before with scalaz + Eclipse, give this one a shot:<br />
<br />
<pre><div class="p1">
<span class="s1"> </span><span class="s2"><</span>dependency<span class="s2">></span></div>
<div class="p2">
<span class="s3"><groupId>org.scalaz</groupId></span></div>
<div class="p2">
<span class="s3"> <artifactId>scalaz-core_2.10.0-M5</artifactId></span></div>
<div class="p2">
<span class="s3"> <version>6.0.4</version></span></div>
<div class="p2">
<span class="s3"> <dependency></span></div>
</pre>JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com0tag:blogger.com,1999:blog-7318253809178612591.post-9597700451743805822012-07-14T12:30:00.002-07:002012-07-14T12:35:45.943-07:00Scala on Android: what you need to know (some of this applies to any large Android codebase)Here's a collection of all of the interesting links talking about issues with Scala running on Android. (And note that it's not specific to Scala; it's large codebases generally.)<br />
<h3>
<b>Summary</b></h3>
Android tools limit you to 65535 methods referenced, which includes both methods defined and methods called. If you hit this limit (and you will with anything past hello-world when you're using the Scala library), you need to run an external tool.<br />
<div>
<br /></div>
<div>
If you use Eclipse, try my <a href="https://github.com/banshee/AndroidProguardScala" target="_blank">AndroidProguardScala plugin</a>.</div>
<div>
<br /></div>
<div>
If you use sbt, use the <a href="https://github.com/jberkel/android-plugin/" target="_blank">sbt Android plugin</a>.</div>
<div>
<br /></div>
<div>
Keep up with the <a href="https://groups.google.com/forum/?fromgroups#!forum/scala-on-android" target="_blank">scala-on-android mailing list (google group)</a>.</div>
<h3>
Useful links</h3>
<div>
<a href="http://code.google.com/p/android/issues/detail?id=7147" target="_blank">http://code.google.com/p/android/issues/detail?id=7147 Issue 7147: dx fails on scala-library.jar and scala-compiler.jar</a><br />
The Android bug. Important quote:<br />
<blockquote class="tr_bq">
<pre style="font-size: 12px; max-width: 80em; padding-left: 0.7em; white-space: pre-wrap;">It turns out that you have made the first report we've seen of anyone running into Dalvik's existing limit of
65536 method references per dex file</pre>
</blockquote>
<a href="https://issues.scala-lang.org/browse/SI-5278" target="_blank">https://issues.scala-lang.org/browse/SI-5278 Scala outputs redundant interface declarations in bytecode</a><br />
<span style="background-color: white;">This is the bug + fix that should solve LinnearAlloc issues.</span><br />
<br />
<a href="http://code.google.com/p/android/issues/detail?id=22586" target="_blank">http://code.google.com/p/android/issues/detail?id=22586 Issue 22586: Dexopt fails with "LinearAlloc exceeded" for deep interface hierarchies</a><br />
Earlier Scala versions hit this, but the problem has been solved by SI-5278.<br />
<br />
<a href="https://issues.scala-lang.org/browse/SI-4620" target="_blank">https://issues.scala-lang.org/browse/SI-4620 Android install of scala 2.9.0 built binary fails (worked with scala 2.8.1)</a><br />
Here's the Scala issue covering the Scala patch that reduced the<br />
<br />
<a href="https://github.com/scala/scala/commit/7a99c03da1d31ac5950eecb30f422f43c5e3d04e" target="_blank">https://github.com/scala/scala/commit/7a99c03da1d31ac5950eecb30f422f43c5e3d04e Don't generate redundant interfaces</a><br />
Here's the Scala patch itself. It includes this comment:<br />
<blockquote class="tr_bq">
Drop redundant interfaces (ones which are implemented by some<br />
other parent) from the immediate parents. This is important on<br />
android because there is otherwise an interface explosion.</blockquote>
<a href="http://code.google.com/p/android/issues/detail?id=20814" style="background-color: white;" target="_blank">http://code.google.com/p/android/issues/detail?id=20814 dx crashes on projects with > 65,535 methods</a><br />
Note that the title is misleading (it's not just number of methods). From the bug:<br />
<blockquote class="tr_bq">
As I understand it, the limit is the number of methods referenced, which includes both methods defined and methods called, which is why you might see this even if your app only contains 56,484 method definitions.</blockquote>
<a href="http://www.scala-lang.org/node/10929" style="background-color: white;">http://www.scala-lang.org/node/10929</a><br />
A conversation about using Scala with Android</div>JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com2tag:blogger.com,1999:blog-7318253809178612591.post-19637439155674365742012-07-12T11:45:00.000-07:002012-09-27T20:14:31.019-07:00Getting this? E/dalvikvm( 6037): JNI ERROR (app bug): attempt to use stale weak global reference 0xbSeeing this in your Android code?<br />
<br />
<pre>E/dalvikvm( 6037): JNI ERROR (app bug): attempt to use stale weak global reference 0xb
</pre>
<div>
<br /></div>
<div>
Make sure you're not:</div>
<div>
<br /></div>
<div>
a) Calling back into java from javascript in a WebView, and then b) Dereferencing a null pointer in Java.</div>
<div>
<br />
Notice that this problem has nothing to do with any of your JNI code.</div>
JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com2tag:blogger.com,1999:blog-7318253809178612591.post-69749418792350955102012-07-05T09:12:00.000-07:002012-07-05T09:12:33.294-07:00Parsing Java signatures with Scala's parser combinatorsI need to parse some Java signatures for a new version of <a href="https://github.com/banshee/AndroidProguardScala" target="_blank">the AndroidProguardScala plugin</a>. I had read about #Scala parser combinators, but never used them. Here's what I came up with for parsing Java signatures (the things like Ljava/util/List<[Ljava/util/List<Ljava/lang/String;>;>; that you see when you're using asm and other tools).<br />
<br />
<script src="https://gist.github.com/3054552.js?file=gistfile1.scala">
</script><br />
<br />
<br />
And here's the test file:<br />
<br />
<script src="https://gist.github.com/3054567.js?file=gistfile1.scala">
</script>JMhttp://www.blogger.com/profile/07317484043295391400noreply@blogger.com0