Tuesday, April 03
On the one hand, some tweaks to the template engine have improved FizzBuzz performance to about 0.25 mips.
On the other hand, the new (dynamic) timezone support adds around 30μs per topic.
Now... User profile page.
Posted by: Pixy Misa at
06:04 PM
| No Comments
| Add Comment
| Trackbacks (Suck)
Post contains 38 words, total size 1 kb.
I've made some FizzBuzz-related enhancements to the new conditional tags. TTLWAIN* is sufficiently lacking in expressive power that even simple programs like FizzBuzz are a pain to write, so I've added some new options to [if] to smooth things out.
First, all the [if.condition] tags now work if supplied with a single variable. The missing variable is assumed to be zero, if the provided variable is a number; False, if the value is True, blank, if the value is a string, and None otherwise.
Second, some new condition codes have been added:
[if.z] and [if.nz] test whether the value is zero or non-zero. This is effectively identical to using [if.eq] and [if.ne] with a single numeric variable, but may be clearer to the user.
[if.odd] and [if.even] test whether the value is odd or even. If the variable is not numeric, the result is undefined.
[if.all] tests whether both the variables are true (non zero / non-empty) - effectively an and.
[if.any] tests whether either or both of the variables is true - an or.
[if.one] tests if one and only one of the variables is true - a xor.
[if.none] tests if neither of the variables is true - a nor.
Third, there is now a matching [ifn.condition], which does what you'd expect.
Fourth, and cause for much rejoicing, there is an [else]. Code within [else]....[/else] is evaluated if the last tried conditional block within the current template was not evaluated. In other words, it works the way you would expect, with one addition: You can have multiple [else] blocks after one [if] block, and all the [else] blocks will be evaluated if the [if] fails.
* The template language without an interesting name. The Minx API is called Mai (Minx Application Interface); the forthcoming Minx desktop app is called Miko. I haven't managed come up with a neat and appropriate name for the template language yet.
Posted by: Pixy Misa at
03:06 AM
| Comments (6)
| Add Comment
| Trackbacks (Suck)
Post contains 305 words, total size 3 kb.
Monday, April 02
If you are less adventurous in your choice of habitats [1], [2] perhaps you would care for our third alternative: The Big Ball of Ice™. The Big Ball of Ice™ works like this: You take a whacking great neodymium magnet* and encase it in about 30,000km of ice, capped with a few hundred kilometres of diamond.**
With a diameter of 60,000 to 70,000km, the structure has the area of 25 Earths, but the low density of ice gives it a surface gravity of around 1g.*** It requires no particular dynamic maintenance; just don't let it get too warm...
* For shielding from the solar wind, and so that boy scouts don't get lost.
** All of this except perhaps the neodymium being in plentiful supply at your local cosmic outfitters.
*** Pumice can have a density one-quarter that of ice, but ice is relatively incompressible; pumice less so. If you nonetheless decide on building a World of Pumice with a diameter of 250,000km, please do write and let us know how it went.
Posted by: Pixy Misa at
05:51 PM
| Comments (2)
| Add Comment
| Trackbacks (Suck)
Post contains 175 words, total size 1 kb.
One way to build a large space habitat with real-world materials is to put a large mass on the inside and live on the outside. Use the mass, instead of the rotation of the habitat, to generate gravity.
Let's try doing this with Jupiter.
Jupiter has a diameter of 143,000km, and a "surface" gravity of about 2.4g. So a habitat with a diameter of about 340,000km will experience a gravity of 1g. With a circumference of over 1,000,000km and a width of 10,000km (preserving at least 93% of Jupiter visible to Earth-bound astronomers), it would have a surface area equal to 20 Earths.
We spin the habitat once every 24 hours to give us day and night. That works out to about 0.1g of outward acceleration, so we only feel 0.9g.
The problem with this is that the habitat will be under massive compression stress. Just as an equally large habitat with 0.9g of centripetal acceleration would fly apart instantly, this habitat would instantly collapse and crash into Jupiter.
However, while there are no energy-efficient ways to dynamically reduce tension, there are ways to reduce compression. What we do is create a second structure just inside the first, and rotate it much faster, so as to balance the force of gravity on the structure itself.* Gravity still effects people and things on the outer surface of the habitat, keeping them in place, but the habitat is dynamically stable - at least structurally.
The problems with such a structure are similar to Niven's Ringworld, with one or two added thrills. First, it's not in orbit around Jupiter (though it is in orbit around the Sun), so that if it drifts off course relative to the planet it will keep right on going, or even accelerate. If it is pushed towards Jupiter vertically, it will accelerate into the planet, which would destroy the habitat and kill everyone on it.
If, on the other hand, it drifts away from Jupiter laterally, it won't collide with the planet, but the loss of gravity will cause the atmosphere, people, pets, trees and so on to drift off into space and asphyxiate. Well, it would, except that the inner ring, no longer bound by said gravity, would tear itself apart and the main structure along with it, killing the people, pets, trees etc instantly.
Oh, and I think Jupiter's radiation would be lethal. And the structure would intersect the outer ring, so you might have to remove that. And you would only get 4% of the sunlight intensity that Earth receives, so you'd either need a mirror 25x the size of the habitat to light things up, or some really warm underwear.
Apart from that, though, it's great.
* You'd need some pretty fancy bearings, but that's a mere engineering detail.
Posted by: Pixy Misa at
05:29 PM
| No Comments
| Add Comment
| Trackbacks (Suck)
Post contains 469 words, total size 3 kb.
FizzBuzz in Minx Template Language.
Admittedly it took me more than a couple of minutes, because (a) I'm at the office and keep getting interrupted, (b) MTL (need a cute name for it) doesn't have proper expressions or loops or even else, (c) there seems to be a bug when using the basic conditional statements with user variables, and (d) I forgot to link the demo folder to something with content, so it didn't actually do anything at first.
(via Coding Horror)
[topics count=100]
[inc i]
[calc.mod m3 var.i 3]
[calc.mod m5 var.i 5]
[if.eq var.m3 0]Fizz[/if.eq][if.eq var.m5 0]Buzz[/if.eq]
[if.gt var.m3 0][if.ge var.m5 1][var.i][/if.ge][/if.gt]
<br/>
[/topics]
Takes about 55ms to run. 20ms of that is the SQL queries; 28ms is the processing of the topic entries; 2ms is fixed overhead per page; 5ms is the calculation and conditional tags. It has to execute 700 of those to generate the page, so they work out to around 7μs each - about 0.14 mips.
Posted by: Pixy Misa at
12:11 PM
| Comments (1)
| Add Comment
| Trackbacks (Suck)
Post contains 141 words, total size 1 kb.
So what's new for today?
Conditions, calculations and variables!
Minx already had four conditional tags, namely [if], [ifn], [iff], and [iffn].
[if] tests a single variable. If that variable exists and has a true (non-zero / non-null / non-empty) value, the template code within the bracket of the [if] and the [/if] is evaluated.
If the variable is false (zero / null / empty), the code is not evaluated.
And if the variable does not exist, the [if] tag itself is not evaluated, and is instead included directly in the output. So if you get the name of the variable wrong, and type [if post.coments] instead of [if post.comments], you will be able to see your mistake right there in the page. In this case, the bracketed code is processed as if the [if] tag did not exist.
[ifn] works exactly the same, except that the condition is reversed. Code inside the [ifn] [/ifn] is evaluated if the variable is false.
[iff] and [iffn] are similar, with one big exception: The bracketed code is evaluated if and only if the variable evaluates to true (or false, for [iffn]). If the variable does not exist, the code is skipped, just as if the variable had been false.
Comparison Tags
[if.eq], [if.ne], [if.gt], [if.lt], [if.ge], [if.le]These extended conditional tags compare two values, to see if, respectively, they are equal or unequal, or that the first value is greater than, less than, greater than or equal, or less than or equal to the second value. They must be closed by a corresponding [/if.XX] tag such as [/if.eq], not by a [/if].
The values can be either variables or constants. The way Minx determines which is the case is somewhat simplistic: If a variable exists which has the name of the value, it assumes that's what you mean; if not, then it assumes the value is a constant. So unlike the simple [if] tag, there's never a case where the variable doesn't exist.
These tags will perform integer comparisons if both values are integers; otherwise they will perform string comparisons. So [if.gt 10 2] will evaluate as true, just as you'd expect, and [if.gt a10 a2] will evaluate as false.
[I had held off on implementing these for the sake of keeping the template language simple, but it turns out I need them to properly manage context-sensitive selection lists - such as on my new forum pages - so in they went.]
Variables and Calculations
[set]You can set a variable with the [set] tag. Like the extended conditionals, [set] can take either another variable or a constant, so [set a post.title] or [set a "Wombats in Paradise"] are valid examples. Again like the extended conditionals, [set] assumes a variable if the variable name exists, and a constant otherwise.
The variable can be accessed again with the prefix var. So [var.a] will print the value of a, and [if var.a] will test it. You can use the var.a terminology inside set as well, and it will be interpreted appropriately.
Variables can be used anywhere a normal data tag could be used.
[calc.add], [calc.sub], [calc.mul], [calc.div], [calc.mod], [calc.min], [calc.max]
The [calc] tag performs a calculation based on two values, and assigns the result to a variable. The values must be integer variables or constants; anything else will be evaluated as zero.
So [calc.add x var.y var.z] will set the variable x to be the sum of y and z.
[inc], [dec]
Just want to increment or decrement a counter? These are the tags for you! [inc a] or [dec a] and you're done.
If the variable did not exist beforehand, it is created as zero, and then incremented or decremented.
Note that none of these tags can alter the value of an existing data tag, only user variables.
Posted by: Pixy Misa at
12:37 AM
| Comments (5)
| Add Comment
| Trackbacks (Suck)
Post contains 546 words, total size 6 kb.
Sunday, April 01
Subforums work.
Also the random quotey thing.
Posted by: Pixy Misa at
04:21 PM
| Comments (2)
| Add Comment
| Trackbacks (Suck)
Post contains 9 words, total size 1 kb.
55 queries taking 0.2989 seconds, 386 records returned.
Powered by Minx 1.1.6c-pink.









