Wednesday, November 21, 2012
Pearl of Wisdom
"Whatever you do, is bound to be a giant, annoying and irrevocable mistake. So make the best mistake you can."
Saturday, November 10, 2012
Loop and Do, and number theory
Tuesday, September 25, 2012
Fixing Emacs and Latex on Mac OS
So I bought a shiny new macbook, and immediately set about installing emacs and latex. A few hiccups. First, emacs couldn't find the latex executables. This was remedied with
(setenv "PATH" (concat "/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/texbin:/usr/bin:" (getenv "PATH")))
(setq exec-path (append '("/opt/local/bin" "/opt/local/sbin" "/usr/local/bin" "/usr/local/sbin" "/usr/texbin" "/usr/bin") exec-path))
Next, I typically want pdf rather than dvi output, and I'd like to use Preview to view these. Emacs defaults to Evince, which is unhelpful in a gnome-less world.
(setq TeX-PDF-mode t)
This can be set in Customize, but trying to do these next two was problematic, since there were drop-down menus in customize defaulting to the builtin list.
(setq TeX-view-program-list '(("Preview" "open %o")))
(setq TeX-view-program-selection '((output-pdf "Preview")))
Now I'm a latex compiling machine!
Tuesday, September 18, 2012
Data
Here's how this came about. Rahm Emmanuel in all his wisdom opened up the city of chicago's data as much as possible. One dataset is crime 2001 to present here. Well, if you go to this, and export to csv, you get ~1.08 GB of information. Loading this into Excel was were the fun began. First, my Excel for Mac 2011 seems to have a limit on worksheet sizes of about one million. Second, the helpful dialog pops up saying that the import failed, but that I'll get as many rows as can fit, and that I should import the remainder using "start import at row: n" in the csv dialog. Which makes a lot of sense. However, the most positive integer which is allowed in the dialog box for row number is 37677, 2^15 - 1. A signed 16 bit integer is still in a modern excel running on a 64 bit host? I'm awestruck by the quality.
I will try this same experiment later on in windows using excel 2010 to see what gives.
In defense of excel, bringing up eshell in emacs 24, then typing `cat Crimes... | grep NARCOTICS` gave me three lines before it froze the program. There should have been over 511,000 lines for that.
This is going to be fun.
Saturday, September 08, 2012
A Small Experiment
Assume there were k primes, and we had them all in a list. Now consider the number one more than the product of all these primes. None of the primes in our list divides this number. Either it is prime, or it has a prime divisor not in our list. So there is no such k, that is, the primes are without number.
I started to think, which primes would we discover if this was our only method? I fiddled around for a few minutes with a piece of lisp code to generate these "euclidean" primes (Euclid included this proof long ago in the Elements).
(defun factor (n)
"return a list of factors of n"
(let ((test 3)
(limit (+ 1 (floor (sqrt n)))))
(cond
((eq n 1) nil)
((evenp n) (cons 2 (factor (/ n 2))))
(t (do()
((or (zerop (mod n test)) (> test limit)))
(incf test 2))
(if (> test limit)
(list n)
(cons test (factor (/ n test))))))))
(defun euclidean-primes (n)
"generate the n primes generated by euclids proof"
(let ((primes (list 1)))
(do ((count 0 (1+ count)))
((= count n) (remove 1 primes))
(let ((eprimorial (1+ (reduce #'* primes))))
(setf primes (union primes (factor eprimorial)))))))
Saturday, June 09, 2012
Announcements
One simple side-effect of being able to inspect the output is that I'm nearly certain I'm returning the wrong value in explicit steps, I noticed that I'm probably taking one step too many due to (initialTime to: endTime by: dt) do: [interesting parts here], which steps forward once to many times.
Is there a standard idiom to exclude the last item in a sequence? I would change to (initialTime to: endTime - dt by: dt), but I'm concerned about edge cases where delta-t isn't evenly divisible by dt, where does it stop?
Tuesday, June 05, 2012
Almost There
I seem to have resolved the issue I was having where clean images are able to inspect the github local repo (all of them could write, but reading from it was not possible), which appears to have been triggered by some 2.0 update. Reloading Dale's package manually did the trick.
I tested the loaded packages from fresh 2.0 and 1.4 images, and it looks good. Only the test I need to fail to remind me to get to work is failing, and apart from a dependency loop in DHB-Numerical I think it's a clean load.
Github page
SqueakSource3 Site
Monday, June 04, 2012
ODE part 2
an Euler Method explicit stepper and solver.
a Runge Kutte non-adaptive stepper and solver.
My obvious next step is adaptive step size control. My other big milestone is to implement an announcements based observer model to capture the data as a series and present the intermediate results.
I wish (and probably am only ignorant about it) that there was a straightforward 2d function plotter in Pharo.
Tuesday, May 22, 2012
Ordinary Differential Equations Solver
Things should ramp up as I get into the flow of things. I'm not committing any of these to public repositories until I have something looking moderately useable. I may use this as an opportunity to make a branch on github (have been working straight to master so far).
Sunday, May 20, 2012
SciSmalltalk Updates
I'm tempted to look into incorporating Nicolas Cellier's Arbitrary Precision Floating Point package (already included his Quaternion, Complex, and Number Extensions). I'm a little sad that there are no Doubles in Pharo/Squeak.
I need to start in on the ODE system solvers. I'm looking into odeint-v2 as a source of inspiration. Un-templating the C++ code into a dynamic language looks to be a fun time for me! I'm not certain I need to involve the generality of arbitrary algebras that they did, a good portion of this looks like it was built in to add support for CUDA operations.
I had a fun time this morning, as I did a pull merge in the wrong order and had to play some games to get my work from last night brought back into line. All the code from the commit was still visible, and all the packages were in the cache, so it wasn't more than a well learned lesson for the future. At least my own commits are visible in the timeline on my github person page.
Wednesday, May 16, 2012
Shared Experience
This is a great post. I completely understand the revulsion when loading Squeak for the first time (esp. if you get Squeak 3.9 from your Linux distro). Like the author here, I feel that seeing Squeak 4.3+ or any Pharo image is a huge relief after using the coloring book releases of Squeak 3, with the drag and drop scripting tools everywhere.
And like the author, I have to say a dozen nice things about the debugger. Really the power tool that separates Smalltalk from any other language. Why doesn't gdb have an editor, compiler, and on-demand dynamic linker built in as a standard feature? I can think why.
He links also to 10 reasons why I'm using smalltalk as a starting point for his investigations, and points to James Robertson's screencasts at Smalltalk for you as being a useful jumpstart into using the system. I really hate screencasts, since I want to click on the 'desktop' but only end up pausing the video! But Robertson's continuing efforts at education are a treasure, and deserve a wide audience.
Sunday, May 13, 2012
Bug Fix
In Pharo, the TestRunner tool allows for determining how much coverage your test suite has over some package. Basically, it records all the messages sent during execution of the tests, and compares this against all the messages implemented in that package. My personal goal is 100% test coverage, though that sometimes leads to a few seemingly meaningless tests.
Development on Pharo-2.0 is moving to restructure the basic tools and frameworks in the system, which has the unfortunate side effect of sometimes breaking the tools you are using. Something happened in the past week that broke the Run Coverage tool in TestRunner. I noticed that I could patch around it by undoing a few small changes that the developers made in the system dictionary (basically, the method for finding which tool handles which class of tasks). This worked for a few days, until the tool I moved it back to was removed from the system by another patch.
I spent a couple days working in Pharo-1.4 because of this, which is stable and unlikely to have more new problems. Today, I updated a clean 2.0 image and just let the debugger show me what was wrong. Four new methods later, I was able to get a coverage list running. The Smalltalk debugger is such a useful tool!
Rather than simply emitting a message, it gives you the entire call stack. Each stack frame is live, that is, you can look at all the passed arguments, change them, inspect them, send methods to them, etc. All of the errors I received were ultimately of the form X does not understand Y (trying to call a function on an object that doesn't implement it). Rewinding 2 stack frames showed me the call site in TestRunner's collectResultsFor method, and in the debugger, I could click on the does not understand error, click create, tell it which class in the hierarchy of X to implement the message in, choose a protocol, write the (very short) code to handle the method, and restart the stack frame where the call failed, and try over.
Honestly, as a very inexperienced programmer, to have a system so immediately supportive as to allow fixing a problem with the system tools in a few button clicks, test it, confirm that it's working, and move on with my life, is a huge relief. Having a system so understandable that it takes about 10 minutes and 10 lines of code to fix a problem in the IDE is exhilarating.
The next process involved feeding this back to the developer team. In Pharo, issues are tracked on google code, and if you've opened a ticket, you can automatically document your patch. In Nautilus, I clicked create a slice, which asked me for an issue number (mine was 5839), then automatically inserted the issue description in the slice. Submitting to PharoInbox was one more click away, and if what I did was useful, that's a bug fix!
Wednesday, May 09, 2012
Milestones for this week
SciSmalltalk Progress and github concerns
I added the complex class, and it looks like there are a lot of failing tests for Trigonometric/Circular functions.
Werner Kassens is interested in adding a KDTree implementation, and I'm excited to incorporate this when it materializes.
Does anyone know how to refork/synch a fork with upstream master on git/github? I've made the mistake of committing directly to upstream, and want to catch up with the changes I've made, but don't see the way to refresh a fork once upstream has gotten ahead of me. I think in the future what I want to do is push to my fork, then pull into master.
Also, has anyone had an issue with github deciding to use korean text in button images? The hover text is english, but all the graphics are now Hangul. Though I'm open to learning new powerful magics, I'm more of a Roman/Cyrillic/Hellenic reader, and Asian scripts always strike me as too foreign.
Lastly, I created a dummy-repo to test inline images in markdown. This is nowhere as easy as it should be! Dummy Repo
Tuesday, May 08, 2012
Ubuntu woes
My desktop had an issue where the soundcard module wasn't loaded into the kernel at boot. lsmod and modprobe showed tons of good things, but sound preferences was sending all my output to dummy device... well, reinstall from disk and thank heaven I partition /home far from /bin and /boot, and a fresh install is never more than a few hours of synaptic from yesterdays machine.
Since I've moved well away from Unity, I sometimes forget how little I like it, it's like a cute little jail, with a non-configurable dock, stupid invisible scrollbars, and garish colors. Gnome 2 on the laptop and WindowMaker on the desktop are the winners, still.
Only thing left is to set static ip on boot, not sure why the 'friendly' installer doesn't ask these questions anymore. Time was, installation was full of more questions than an income tax form.
Monday, April 23, 2012
Summer of Code
I am very excited to move forward on this. I expect to have the best summer ever.
Sunday, April 08, 2012
Ubuntu Tour
However, in fairness, I thought this was a rather clever test-drive page:
Ubuntu Tour
The most surprising thing (besides how attractive it looks), is that they just render off-site content in firefox if you use it. The back button doesn't work, but is this a free web page proxy?
Thursday, March 08, 2012
Smalltalk First Impressions
I started to look into squeak, and a little reading lead me to Pharo, which if you are an adult looking to write programs and learn smalltalk, offers a much cleaner UI, is compatible with the squeak vm, and has excellent development tools, and no toy like features which provide a funny first impression of Squeak.
It turns out much of what I thought I knew about smalltalk was either incomplete or just plain wrong, borrowing from things I remembered about Objective C from a furtive attempt to start using it years ago. I have been repeatedly blown away by the depth of the object metaphor in smalltalk. The inspector and explorer are leagues above the tools I had become used to (either gdb+emacs or slime+emacs). The additional scratchpads at the bottom of the inspector allowing modification of the object at runtime are well planned and very useful. The debugger at first glance looks like the slime debugger, a variety of restarts are available, a somewhat terse message regarding the offending condition, and a partial stack trace / message history are presented. But the immediate usability of the system comes in the ability to browse the offending code site, modify the code definitions, restart or proceed and fix on the spot the problem.
In two weeks, I worked through the "Pharo By Example" LightsOut program (which was Quinto in Squeak by Example), get a quick feel for SUnit and the test runner, where the tests are only a keystroke away, and can be automatically created, blindly find my way through a currency converter gui program (a la Learning Cocoa), and have created a small DFA simulator. The learning curve is a little steep, but having seen the example application, and learned the short syntax of the language (really fits on a single sheet of paper, possibly a 4x6 card), the remainder of programming seems to have been selecting the appropriate classes, browsing their sanely named selectors, putting the pieces together, and running the tests.
My DFA simulation took about 45 minutes to piece together in between classes one morning, and I am a complete novice in Smalltalk.
Things I don't understand, certainly include monticello/metacello, how to install software, which pieces are loadable but will break your system, and have certainly had my share of frozen images. I recommend to anyone starting to keep a pristine image, and if you ever start it, to immediately save your working copy as an alternate name. Monticello is very useful in packaging versioned bundles, and seems to beat fileOut handily.
The Pharo developers have a very active community, their mailing list is busy, the community is experimenting in several directions at once, and what's most important, the system is discoverable. The browsers and finders are beautiful, the debugger is amazing, the Morphic Hierarchy is easy to browse, and finding the right tool for the job is simply a matter of finding the right pieces to put together.
One thing I haven't discovered in Morphic is how to specify relative position of submorphs, so I simply give explicit locations in the bounds, and hope the user doesn't alter the initial size too much. VisualWorks' GUI Painter seems to have simple checkboxes to control this behavior (if you've used Interface Builder in XCode you will be familiar with Springies...), and perhaps it's present in Morphic as well.
I have to say a few nice things about Stephane Ducasse's well kept links to available books, and his personal efforts in pushing Pharo forward.
Sunday, February 26, 2012
Ongoing Elsevier Boycott
Several mathematicians recently started taking action to boycott all Elsevier journals, following comments by Mr Gower of Cambridge. This has been a large enough embarrassment for them, and has gained international news coverage (I read about it in the economist less than 10 days after seeing the initial statements on Gower's Weblog.)
Mr Gower adds a rebuttal to an open letter from Elsevier to the research community here.
Saturday, February 25, 2012
Inventing on Principle
Thursday, February 02, 2012
A Simple Example
Occasionally, people make far fetched claims about the flexibility offered by lisp. Here is a simple example: editing the source code of a running program.
(defun foo () t) ;; foo returns true when called (loop (when (not (foo)) (return))) ;; call foo repeatedly, until it is false.
This is of course a simple while true do nothing loop. But then we evaluate this little bit on the same system in a separate interaction session/slime buffer.
(defun foo () nil) ;; foo returns nil/false when called.
Amazingly, our loop exits, returns nil, and we are back in business. This is of course a contrived example, but not so far from the mark in expressing the simple idea that editing a program at runtime can yield a lot of power.
Saturday, January 07, 2012
A sigh of relief
Somehow I found Steve Yegge's blog, and was drawn by some of the humor.
Friday, January 06, 2012
Busy Week
While at the friends apartment delivering chairs, I picked up her copy of "The Winter of Our Discontent" by Steinbeck and have since devoured it. I look forward to returning it with positive reviews.
Lately I've been reading through some of the published ACL2 'books' for inspiration. The system looks quite readable, and after wrestling for some time with Cyc, it's a pleasure to find something so aesthically pleasant. The modifications and extensions to the main CL functions are mostly removable from the axioms file, and implementing and testing some of the methods has been a relaxing pastime. Having the full source in /usr/share is a wonderful benefit to the curious. Anyone looking for hints on how to bootstrap lisp in lisp is encouraged to read through the beautifully documented acl2.lisp file, which sets up all packages and handles masking out the existing language while preserving the system's symbols in another area.
School starts Monday. I picked up my bus pass and last book yesterday. I look forward to the interaction and stimulation that a group effort to understand some thorny subjects will bring.
I've recently started using github. Somehow, within 24 hours, a friend from school had found me and followed me. Amazing how quickly information spreads. Nothing I've put there is particularly interesting, but it's useful to think I can have an additional backup, and starting to use vc is enlightening. I think I hear sourceforge slowly collapsing.
Beth left town tonight for the weekend. That leaves me to indulge in stuffed green peppers and Sabado Gigante. I can't wait to watch el Chacal de la trompeta eliminate some more contestants.