KBD

Keith Devens .com

Friday, November 21, 2008 Flag waving
The reason to do animation is caricature. Good caricature picks out the essense of the statement and removes everything else.... – Brad Bird, writer and director, The Incredibles (The Incredibles DVD, behind the scenes, character design)

Archive: May 13, 2002

← May 12, 2002May 14, 2002 →

Daily link icon Monday, May 13, 2002

Beyond Compare

Beyond Compare version 2.0 was just relased today. Beyond Compare is the best diff program for Windows for the money - it's the best value. Araxis Merge is probably better, but not worth the money to me.

CSS question

So in CSS, how do I say "a paragraph of class 'markup' not preceded by anything else immediately before it of class 'markup'"?

Ok, did it:

p.markup{display: inline}
*.markup + p.markup{display: block; margin-top: 0; margin-bottom: 1em}

Explanation:
What I needed was adjacent sibling selectors.

Basically, I wanted to say: If a paragraph is the first thing in some marked up text (output by my markup parser), then make it inline (I don't want any blank space before it). Otherwise, I want it to be a block level element, and have a bottom margin, but not a top margin.

"*.markup + p.markup" means a paragraph with class "markup" preceded by any element with class "markup". This goes second because it is more specific than the "p.markup" selector. So basically, these lines say "make a paragraph inline, but if it's preceded by another markup element, then make it block level (and have a margin, etc.)" Pretty cool, huh?

Now if their box model wasn't broken...

Update: while what I did above worked, it turned out to not be what I wanted. But thanks to collapsing margins, I was able to do what I wanted.

A New Kind of Science

Chris Langreiter reminds me that Stephen Woldfram's A New Kind of Science (which I pre-ordered a while ago) is being released tomorrow. Check out this article from the NY Times about it: A Man Who Would Shake Up Science

Mr. Wolfram, who was born in Britain, published his first paper on particle physics in 1975 at age 15, and obtained a doctorate at Caltech at 20 (where Richard Feynman called him "astonishing"). He won a MacArthur Foundation Fellowship at 21, reshaped the ways in which complex phenomena (like the movements of fluids) were analyzed before he was 26, founded an institute for the study of complexity at the University of Illinois, and then left academic life and research science, starting a software company, Wolfram Research Inc., in 1987. His main commercial product, a program called Mathematica, has become an international standard, used as a mathematical tool by over a million scientists and students and engineers in areas ranging from medical research to the analysis of weather.

Now Mr. Wolfram is finally publishing his work, and his claims surpass the most extravagant speculation. He has, he argues, discovered underlying principles that affect the development of everything from the human brain to the workings of the universe, requiring a revolutionary rethinking of physics, mathematics, biology and other sciences. He believes he has shown how the most complex processes in nature can arise out of elemental rules, how a wealth of diverse phenomena — the infinite variety of snowflakes and the patterns on sea shells — are generated from seemingly trivial origins.

Base64 decoding

I just needed to decode a base64 encoded file. First I tried writing a small script with REBOL's debase function, but that didn't work. REBOL's save function kept saving it in a REBOL-readable form, not in a binary form (I was decoding a PNG), even when I used the /png refinement.

So I went looking for something already written and the first hit on Google was this very useful utility for encoding and decoding base64. Worked right away, no hitch Smiley Thanks John Walker (not that John Walker). He also has a similar utility for encoding and decoding quoted-printable encoding.

No cents for you

Via BlahBlahBlog, The Demise of the $.01 Sign. Fun read.

Anti-idioms

Really cool post from Adam on programming anti-idioms.

Knowing a programming language's idioms is the key to being fluent in that language.
It is also important to know what not to do. Just because a language allows a certain coding style doesn't mean that style is a good one.

The anti-idiom he uses as an example is one where you can butcher C++'s exception handling to be able to "return" a value of any type. Read the post for specifics... however, I say that this type of thing is actually an anti-pattern, not an anti-idiom. In fact, I don't think you can even have "anti-idioms". An idiom doesn't really carry a value judgement along with it; an idiom is just a thing people commonly do. [Design] Patterns on the other hand, do carry a value judgement.

I like the way wiki says it, "an AntiPattern is a pattern that tells how to go from a problem to a bad solution", whereas a pattern tells us how to go from a problem to a good solution.

Seen on LtU.

Another reason this is an anti-pattern instead of an anti-idiom which I didn't mention before is that this is a large-scale design rather than a small scale bit of code that would be called an idiom.

Ehud brings up a good possible use for the term anti-idiom:

Perhaps the term anti-idiom should be reserved for incorrect code people repeatedly produce, esp. if related to well known idioms.

Maybe something like for(n=0;n<=count;n++){...} would be an anti-idiom? Or to use Adam's example, something like while(*++n = *++m);?

← May 12, 2002May 14, 2002 →
November 2008
SunMonTueWedThuFriSat
 1
2345678
9101112131415
16171819202122
23242526272829
30 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 5 posts

Recent comments XML

new⇒Calif. Supreme Court to take up gay marriage ban

I would argue the point is not​definitional.  While the word​marriage is su...

Justin: Nov 20, 4:37pm

Java join function

Meh, don't have null strings in​your string arrays imo, but you're​welcome ...

Keith: Nov 19, 7:51pm

Girls, please don't get breast implants

sorry but another thing i have to​make a comment on about you​men...the men...

happynow: Nov 17, 11:36pm

Books by Vincent Cheung

to all Cheung​fans:

read:

http://www.progin​osko.com/aquascum/cheung.h...

Zamir: Nov 16, 9:07am

Spider solitaire

To undo or not to undo that is the​question.
I'm an undoer. 
My dad​was n...

Can Turk: Nov 15, 2:50pm

Generated in about 0.078s.

(Used 7 db queries)

mobile phone