A data: URL directly contains its content; for example, data:text/plain,Hello%20World!. The main usefulness of this is that you can do things like including images inline in a document. But you can also use it to create 'anonymous' HTML documents, where any link to them or bookmark contains the entire document.
I originally did this in 2006 when I was in need of a URL-encoding tool and did not have one to hand; so I wrote out:
data:text/html,<form action="data:text/plain,"><input id=r>
Properly encoded, that's:
data:text/html,%3Cform%20action=%22data:text/plain,%22%3E%3Cinput%20name=r%3E
This produces a form with a single field which, when submitted, will generate a data URL for a plain text document containing “?r=” and then the text; the URL, then, will contain the entered text URL-encoded after the “?r=”.
Of course, that's a horrible kludge and JavaScript has an encodeURI function...
See my site for the rest of that thought and more examples. (I can't include any actual data URLs in this post because LiveJournal doesn't permit them, for necessary but unfortunate reasons — the origin, in the sense of same-origin policy, of a data URL is the origin of the page containing it.)
A remarkable feature: “Settings → About phone → Battery use” claims to give a breakdown of energy use over the last period the phone was unplugged. It distinguishes between “Display”, “Cell standby”, “Android System”, and applications. Don't know how accurate it is.
Bluetooth keyboard driver experiences:
So I still don't have a keyboard driver. Perhaps I should look into writing one.
I need to learn about how file/application associations work so I can figure out who is at fault (file browser or viewer app) in my failing to open PDF and epub documents stashed on the SD card.
USB connection is done right: plugging into a computer does not interrupt usage at all, and if you want to mount the SD card then that's an easily-reached option; neither mandatory nor buried. (Well, it didn't; since system updates it now pops up the do-you-want-to-mount screen immediately, which you have to exit to continue with your previous activity.)
The force-Google-Account-to-Gmail thing became considerably less annoying once it occurred to me to find out that it let me change the From address of mail sent from the Gmail account. So my external identity is still kpreid@switchb.org, except in Google apps.
Nice bit of polish: “A system update has been downloaded, but your battery is too low to install it. Connect to charger first.” (phrasing from memory.)
I'm considering writing up a document like the Gadget Coverage List but with an emphasis on features × how to get them on Android rather than features × gadgets — so it would be a recommended apps list, among other things.
I forget why I wrote this Haskell program, but it's cluttering up my do-something-with-this folder, so I’ll just publish it.
-- This program calculates all the ways to combine [1,2,3,4] using + - * / and ^ -- to produce *rational* numbers (i.e. no fractional exponents). (It could be so -- extended given a data type for algebraic numbers (or by using floats instead -- of exact rationals, but that would be boring).) -- -- Written September 7, 2009. -- Revised August 25, 2010 to show the expressions which produce the numbers. -- Revised August 26, 2010 to use Data.List.permutations and a fold in combine. -- -- In the unlikely event you actually wants to reuse this code, here's a license -- statement: -- Copyright 2009-2010 Kevin Reid, under the terms of the MIT X license -- found at http://www.opensource.org/licenses/mit-license.html
import Data.Ratio (Ratio, numerator, denominator)
import Data.List (nubBy, sortBy)
--------------------------------------------------------------------------------
-- We want to "show our work", tracking the expression which produces a given
-- number; this data type does that. Not to be confused with Show/show from the
-- Prelude.
data Shown a = Shown { value :: a,
expr :: String }
-- Apply a binary operator to Shown values.
-- We could be more general, and wrap functions in Shown and define a
-- Shown-application operator, but that would be overcomplicated for this job.
explain name func a b =
Shown ( value a `func` value b )
("(" ++ expr a ++ " " ++ name ++ " " ++ expr b ++ ")")
-- comparison disregarding the expression
eqShown (Shown x _) (Shown y _) = x == y
compareShown (Shown x _) (Shown y _) = compare x y
shownToString :: (a -> String) -> Shown a -> String
shownToString f (Shown v e) = e ++ " = " ++ f v
--------------------------------------------------------------------------------
-- Rational number formatting
-- Convert a rational number to Shown
shownRatio :: Integral i => Ratio i -> Shown (Ratio i)
shownRatio x = Shown x (niceRatio x)
-- Format rational numbers in a more normal way than Show Ratio does.
niceRatio :: Integral i => Ratio i -> String
niceRatio r = if denominator r == 1
then show (numerator r)
else show (numerator r) ++ "/" ++ show (denominator r)
--------------------------------------------------------------------------------
-- Tools for the problem
infixl 5 `op`, `op2`
-- Generate a list of all valid binary operations (a X b), where X is one of + - * / ^
op :: Shown (Ratio Integer) -> Shown (Ratio Integer) -> [Shown (Ratio Integer)]
op a b = concat [[explain "+" (+) a b],
[explain "-" (-) a b],
[explain "*" (*) a b],
if denominator (value b) == 1
then [explain "^" (^^) a (Shown (numerator (value b)) (expr b))]
else [],
if (value b) == 0
then []
else [explain "/" (/) a b]]
-- Same as op but with commutation, a X b and b X a
op2 :: Shown (Ratio Integer) -> Shown (Ratio Integer) -> [Shown (Ratio Integer)]
op2 a b = op a b ++ op b a
-- foldl1 + foldM = fold1M
fold1M :: Monad m => (a -> a -> m a) -> [a] -> m a
--fold1M f (x:y:xs) = do r <- f x y; fold1M f (r:xs)
fold1M f (x:y:xs) = f x y >>= (fold1M f . (:xs))
fold1M _ [x] = return x
fold1M _ [] = error "fold1M with empty list"
--------------------------------------------------------------------------------
-- The problem
-- Return the list of all possible combinations of [1,2,3,4].
combine :: [Shown (Ratio Integer)]
combine = fold1M op2 =<< permutations (map shownRatio [1,2,3,4])
-- Unique and sorted results
uniqueCombine = nubBy eqShown . sortBy compareShown $ combine
report = concatMap ((++ "\n") . shownToString niceRatio) uniqueCombine
++ "Tried " ++ show (length combine) ++ " formulas, got "
++ show (length uniqueCombine) ++ " unique results.\n"
main = putStr report
I'd include the output here, but that would spam several aggregators, so I'll just show some highlights. The results are listed in increasing numerical order, and only one of the expressions giving each distinct result is shown.
(1 - (2 ^ (3 ^ 4))) = -2417851639229258349412351 (1 - (2 ^ (4 ^ 3))) = -18446744073709551615 (1 - (3 ^ (2 ^ 4))) = -43046720 (1 - (4 ^ (3 ^ 2))) = -262143 (1 - (4 ^ (2 ^ 3))) = -65535 ...all integers... ((1 - (2 ^ 4)) * 3) = -45 (((1 / 2) - 4) ^ 3) = -343/8 ((1 - (3 ^ 4)) / 2) = -40 (1 - ((3 ^ 4) / 2)) = -79/2 (1 - ((3 ^ 2) * 4)) = -35 ...various short fractions... (1 / (2 - (3 ^ 4))) = -1/79 (((1 + 2) - 3) * 4) = 0 (1 / (2 ^ (3 ^ 4))) = 1/2417851639229258349412352 (2 ^ (1 - (3 ^ 4))) = 1/1208925819614629174706176 (1 / (2 ^ (4 ^ 3))) = 1/18446744073709551616 (2 ^ (1 - (4 ^ 3))) = 1/9223372036854775808 (2 ^ ((1 - 4) ^ 3)) = 1/134217728 ...various short fractions... (((3 ^ 2) + 1) ^ 4) = 10000 (the longest string of zeros produced) ...all integers... (2 ^ (3 ^ (1 + 4))) = 14134776518227074636666380005943348126619871175004951664972849610340958208 (2 ^ ((1 + 3) ^ 4)) = 115792089237316195423570985008687907853269984665640564039457584007913129639936 Tried 23090 formulas, got 554 unique results.
I find Dasher an interesting input method, and after getting my Android phone I thought it would be nice to try Dasher on it. However, at the time there was no Dasher port or any information on the Web about the possibility, so I looked into writing one. I found several dead projects and miscellaneous repositories and eventually found that the main Dasher repository had a Java port of Dasher. I dabbled in getting it to run on Android, but before I got anywhere I found Dasher was now in the Android Market, though there was still no discussion/announcement/public project info.
I shall now dump the links I collected while I was working on this project, so as to make the matter of Dasher and Java better-indexed. Unfortunately, I don't recall the significance of all of them.
java/ for the Java code)
The Dasher port that's currently in the Market is pretty solid. It has a variety of options for input (touch, trackball, tilt); the main thing it's missing is independent control of the X/Y sensitivity of the tilt control.
All of education and learning depends on having a frame of reference. Without a frame of reference, one can't take something knew and stitch properly into his skill or knowledge set. As a programming chrestomathy, Rosetta Code allows a visitor to find a frame of reference and learn something new. At its simplest, Rosetta Code makes building a frame of reference for learning new languages easier by providing examples of problems known to users along with solutions which use languages they're familiar with, as well as solutions which use languages they aren't familiar with. However, that's not where Rosetta Code's model ends. The building of the frame of reference also works in reverse; users can learn to understand problems by seeing solutions to those problems written using languages they understand—I use Rosetta Code myself for this purpose a great deal of the time. Finally, Rosetta Code isn't limited to enhancing only languages and problems. A language is a tool, and, by extension, the frame of reference model Rosetta Code uses can be generalized to tools, and this is how I see Rosetta Code.
So, to go back and generalize an earlier statement: At its simplest, Rosetta Code makes building a frame of reference for learning tools easier by providing examples of problems known to users along with solutions which use tools they're familiar with, as well as solutions which use tools they aren't familiar with.
I see this as useful, because documentation and existing learning materials for problems and tools are often nonexistent, difficult to find or opaque. Take mathematics articles on Wikipedia; while I don't doubt they're largely technically accurate, I largely haven't been able to read and understand them. If I look at implementations of those articles' processes in source code, I often have a better understanding of the process. I know it's not just me; I have a friend who learned how the Hough transform works via the task on Rosetta Code.
$ cat ~/bin/maken
#!/bin/sh # Make files and view the results. make "$@" && open "$@"
Did buy a Nexus One; have now had it for an hour or so. The following is not a review, but some observations:
You may recall my post about looking for a new PDA. I have lately found additional pressure to find a solution.
I've compiled some of the options and what features they have into this Google Docs spreadsheet: Gadget Coverage List. Note that “-” means “No”.
At the moment, I am strongly considering getting an Android phone, specifically the Nexus One. I have recently determined that Android meets all my requirements, at least given some third-party software.
Buying a phone (and a plan) is indeed a higher cost than a stand-alone PDA, but I think universal Internet access is worth it.
Costs and carriers
The phone, unsubsidized and unlocked, is $529.
Given that it is GSM, I understand there are basically two carriers to consider: T-Mobile and AT&T. I get the impression that T-Mobile is somewhat less evil than AT&T, and I hear complaints about AT&T's network. On the other hand, T-Mobile does not have coverage (even roaming) in Potsdam, NY, where I'm going to be spending the next two years.
T-Mobile offers a monthly plan for $60/mo, 500 minutes/mo plus fees and (as far as I've looked now) a $35 activation fee. (The option to buy a plan without a phone was buried: you have to choose "T-Mobile SIM card" from the phone list.) I get the impression that the obscure monthly 'taxes and fees' can be around $3-$20 depending on the particular situation. Total cost over 2 years (not including phone): $1475+fees.
AT&T is, er, changing tomorrow. But now it would apparently be $70/mo, 450 minutes/mo, for a two-year contract with a free locked phone (which could be tossed or resold). Plus taxes and fees. After the change in data plan pricing, it would be (assuming no other changes) $65 for 2GB or $55 for 200MB data. Total cost over 2 years (2GB option): $1560+fees, and the phone works in Potsdam.
In both of these cases I assume the cheapest voice plan option.
One option would be to go with T-Mobile for the 2.5 months before I arrive in Potsdam; this would minimize my initial obligation to $709, and assuming I found I liked having a smartphone around sufficiently, I could then switch to AT&T for service during my 2-year stay in Potsdam.
Comments?
(If anyone has already used this title, that wasn't my intent.)
“Fire Worms From Outer Space!” was a game I wrote in spring 2009 as my final project for PH115 Science of Multimedia at MVCC.
It was written in Macromedia Adobe Director, and designed as “with the structure of a shoot-em-up and the mechanics of a physics game”; you must defeat the enemies in each of a series of levels — by smashing apart their chains-of-spheresical bodies with your wrecking ball of an inexplicably orbiting asteroid.
Most of the development time was focused on getting the physics right; the graphics, sounds, and level design were all secondary.
(I'm not particularly a fan of Director; it's just what was used in the class. If I ever get around to it, I'll rewrite it in JavaScript.)
Play Fire Worms
(Please let me know if this doesn't work; I don't have the Shockwave plugin so I can't test it.)
Source
The Director file, plain-text copies of the scripts, and all of my saved development history (reconstructed; it was originally a bunch of directory copies) are available in a Git repository at git://switchb.org/fire-worms/. (No web view yet; need to do that.)
Other than the background image, credited in game and in “Title Page” to NASA, all elements of the game are Copyright 2009 Kevin Reid. I haven't gotten around to sticking a license on it; contact me and I'll get around to labeling it MIT or CC — let me know what license would be useful for what you'd like to do with it.
Edk went on a roll and added large amounts of useful information to several langauge pages. I was putting these up via Twitter, but the rate he as adding content led me to pause; I don't want to spam folks with too many twitter-esque updates, so I waited a bit.
Pages he's filled in since then:
Edk got busy and added or de-stubbed language pages for 15 languages, from A+ to Nice.
http://rosettacode.org/wiki/Category:A%2B
http://rosettacode.org/wiki/Category:AspectJ
http://rosettacode.org/wiki/Category:AspectC%2B%2B
http://rosettacode.org/wiki/Category:Cecil
http://rosettacode.org/wiki/Category:Diesel
http://rosettacode.org/wiki/Category:FeatureC%2B%2B
http://rosettacode.org/wiki/Category:Fortress
http://rosettacode.org/wiki/Category:Glee
http://rosettacode.org/wiki/Category:Goo
http://rosettacode.org/wiki/Category:K
http://rosettacode.org/wiki/Category:Lush
http://rosettacode.org/wiki/Category:Limbo
http://rosettacode.org/wiki/Category:Mythryl
I just wrote my first use of that <canvas> thing that everyone's talking about. (If you don't know, this is part of the WHATWG/HTML5 general vicinity of features: an element which creates a bitmap pixmap image that can be drawn on by JavaScript.)
Since LJ doesn't let me embed JavaScript or iframes (a restriction which I'm only just noticing...) I'll have to provide only a link (but your CPU meters will thank me for that):
(This is also part of a personal goal to learn more about Modern Web Applications technologies: “Ajax”, jQuery, web frameworks, etc. I used to (a) not have a personal server, and (b) tend to “All web content must be accessible to non-JS and pure-text users” — but I’ve come to realize that while one should still avoid unnecessary dependence on fancy stuff, there is value in using these systems to create what are not so much “web pages” as cross-platform, zero-install applications — they may not be usable by $NON-MAINSTREAM-BROWSER-TYPE but nothing else would be more compatible and still provide the same benefits.)