Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
User Journal

Journal: Circular dependencies in three languages 1

Journal by Sloppy

Here are six files for ya, showing a problem in 3 different scripting languages. What will they do?
--------- test1.php:
<?php
require 'test2.php';

define('SOMECONSTANT','hello world');

function foo() {
                return SOMECONSTANT;
}

echo foo(); echo "\n";

--------- test2.php:
<?php
require_once 'test1.php';

echo foo(); echo "\n";
--------- test1.py:
#!/usr/bin/python
import test2

SOMECONSTANT='hello world'

def foo():
                return SOMECONSTANT

print foo()
--------- test2.py:
#!/usr/bin/python
import test1

print test1.foo()
--------- test1.rb:
#!/usr/bin/ruby
require 'test2.rb'

SOMECONSTANT='hello world'

def foo
                SOMECONSTANT
end

puts foo()
--------- test2.rb:
#!/usr/bin/ruby
require 'test1.rb'

puts foo()
---------
Ok, scriptfiends, predict the output of these three commands:
php -q -f test1.php
python test1.py
ruby test1.rb

and then do some pasting and try it out. Match your predictions?

The PHP one bit me pretty hard today.

User Journal

Journal: One Too Many 2

Journal by Sloppy

I have a password written on a post-it note underneath my keyboard. Decades went by without this ever having happened, but now I have one of these. [rationalize]And I'm keeping the post-it, because it'll probably be months or years before I ever need that password again, so there's just no chance I'll be able to remember it (it's actually a pretty well-made password).[/rationalize] OTOH, I suppose I could just throw it away and then the next time I need it, ask someone for it again. [truth]But no, it amuses me that I've entered the ranks of people with passwords on post-its at their desks, so I'm keeping it, for that reason if nothing else.[/truth]

User Journal

Journal: NY Times: being anti-tax is an act of vandalism 1

Journal by DesScorp

Robert Frank takes the NYT's standards even lower. Now it seems that if you think lower taxes are better than higher taxes, well, you're some kind of vandal.

"Anti-tax zealots denounce all taxation as theft, as depriving citizens of their right to spend their hard-earned incomes as they see fit. Yet nowhere does the Constitution grant us the right not to be taxed. Nor does it grant us the right to harm others with impunity. No one is permitted to steal our cars or vandalize our homes. Why should opponents of taxation be allowed to harm us in less direct ways?"

"Be allowed"? Nice, Ill Duce. We'll take that under advisement. BTW, here's what the law actually says about issue:

"Any one may so arrange his affairs that his taxes shall be as low as possible; he is not bound to choose that pattern which will best pay the Treasury; there is not even a patriotic duty to increase one's taxes." - Judge Learned Hand, Helvering v. Gregory, 69 F.2d 809, 810-11 (2d Cir. 1934)

Government

Journal: Lawrence Lessing, enemy of government transparency?

Journal by DesScorp

In the New Republic, copyright activist and professor Lawrence Lessig pens an essay called Against Transparency: The Perils Of Openness In Government (Warning: the essay is 11 pages of some pretty dry writing). Lessig makes the argument that while transparency in government seems like a good thing, it's not always so, and he seemingly worries that there are some things that citizens just wouldn't understand in government if given complete access to data, and that the whole process will simply make voters more cynical. That strikes me as a little lame, and more like "I don't trust voters to make decisions based on what they see".

  Sayeth Lessig:

How could anyone be against transparency? Its virtues and its utilities seem so crushingly obvious. But I have increasingly come to worry that there is an error at the core of this unquestioned goodness. We are not thinking critically enough about where and when transparency works, and where and when it may lead to confusion, or to worse. And I fear that the inevitable success of this movement--if pursued alone, without any sensitivity to the full complexity of the idea of perfect openness--will inspire not reform, but disgust. The "naked transparency movement," as I will call it here, is not going to inspire change. It will simply push any faith in our political system over the cliff.

Government

Journal: NYT Op-Ed calls for one-party rule 7

Journal by DesScorp

New York Times Op-Ed writer Thomas Friedman is showing his true colors. He's advocating "enlightened" one-party rule, as he tires of Republicans refusing to co-operate with Democratic initiatives. Friedman says that we currently have a "one party democracy" because of near-total GOP opposition to Democratic bills, and that perhaps an enlightened one-party autocracy with America's best interests at heart could be the answer. Friedman further thinks China is a good model of government to emulate. "One-party autocracy certainly has its drawbacks. But when it is led by a reasonably enlightened group of people, as China is today, it can also have great advantages. That one party can just impose the politically difficult but critically important policies needed to move a society forward in the 21st century." Friedman flatly states that "our one-party democracy is worse". Perhaps we too can look forward to things like a one-child policy and extensive Internet censorship. Friedman is the type of Liberal Jonah Goldberg was talking about when he wrote Liberal Fascism.

Further, Goldberg says that liberals like Friedman are nothing new, that we've seen this kind of liberal pining for benevolent dictatorship many times before:

"I cannot begin to tell you how this is exactly the argument that was made by American fans of Mussolini in the 1920s. It is exactly the argument that was made in defense of Stalin and Lenin before him (it's the argument that idiotic, dictator-envying leftists make in defense of Castro and Chavez today). It was the argument made by George Bernard Shaw who yearned for a strong progressive autocracy under a Mussolini, a Hitler or a Stalin (he wasn't picky in this regard). This is the argument for an "economic dictatorship" pushed by Stuart Chase and the New Dealers. It's the dream of Herbert Croly and a great many of the Progressives."

Television

Journal: multicast video: someone's finally doing it 1

Journal by Sloppy

I've long advocated that the future of video delivery should either be multicast, or old-school protocols like HTTP combined with caching at the ISP. (Why all ISPs don't run transparent Squids, I still don't understand.) Bittorrent just isn't the right way to do it.

Thanks to Freedom To Tinker I've just learned that someone is using multicast to deliver TV.

Except it's not available in my area, and still requires propriety DVRs/STBs, which I assume means that it probably uses DRM and therefore has massive interoperability problems.

But it's a start. I hadn't heard of anyone actually doing it, before now.

Programming

Journal: I can't believe this happened. I miss .. Pascal?! 1

Journal by Sloppy

I was writing a function in PHP4 and it kept getting bigger. It could use some splitting up for readability/testing/debugging purposes, although it didn't really need that to work. But then I realized I needed to reuse some sections of code, and since I hate duplicating code, those parts needed to be pulled out into their own functions.

But they needed access to the working set of local variables of the big function. Oh great.. do I pass all those vars by reference, making the argument list really long? Do I move all those variables into a struct (well, an associative array) and pass that?

These are, like, Programming 101 issues. Experienced programmers don't normally have to think about this stuff, because the right thing to do is just .. obvious.

Then I remembered that Pascal has the unusual (and rarely(*) needed) feature of nested procedures, where the sub-procedures can directly access the outer scope's local variables. It dawned on me: that would be incredibly convenient (and readable) in this case.

I wussed out and put everything into a class. It's not really oop (all this class does, is return a result) but that looked like the best way to deal, except now I have an ugly this-> in front of everything.

(*) I haven't programmed in Pascal (or anything like it) in over 20 years. Never really missed that feature until today.

User Journal

Journal: Is The New Republic infected with a Trojan?

Journal by DesScorp

I rarely go there, but on two occasions now, I've gone to TNR.com following a story link, and an attempted AntiVirus 2008 infection begins. Lucky me that I use a Mac this time of day.

National Review doesn't have this problem.

Security

Journal: The ad business REALLY sucks 2

Journal by Sloppy

It's bad enough when you're actually serving the data from your own site but it's in some form where you can't audit it. That's one of the many reasons I hate Flash.

But even Javascript sucks, when you <script src="someothersite">. The moment you do that, you know that all sorts of horrible things can go wrong. You just have to have faith. Faith is what it comes down to. And it can be justified, I guess, because you can get away with it for years.

Until this morning when our webpage was only showing for a second and then the whole thing would then redirect to someone else's site. Adios, visitors.

(What actually happened: the domain we were including from, apparently expired and now any http request goes to a Network Solutions page, instead of returning a DNS error like it should. Fuck you, Network Solutions, as if we didn't already know you're evil and dangerous. But the same risk remains even if someone's domain doesn't expire; they can always serve a different script today than they did yesterday, and that script can do anything with the DOM that it wants to. There's no way to sandbox it.)

It's "standard practices" to include external scripts. Everyone does it. The ad people aren't techies; if I were to tell them, "uh, we don't want to include any external scripts that might change from load-to-load, and we also don't want to include any Flash crap unless we've compiled it from readable, auditable source ourselves," they would think I'm crazy. You know, one of those open source fanatics. They would say, "Gee, that's a shame you don't want the money," and go on sending the same dangerous ads to our competitors while we collect nothing.

Is it really an unreasonable weirdo religious fanatic position, to just want to be able to make sure that stuff will work and not do anything crazy? I don't think so. The fucking "standard practices" need to change, but how can one person do that? *sigh* I feel so powerless.

User Journal

Journal: A poster named ScentCone...

Journal by DesScorp

... has really impressed me of late.

In the recent story McCain releases technology platform, one poster stood out in his responses against the usual left-libertarian grain here. He's ScentCone, and he consistently posts forcefully argued, well reasoned ripostes. Despite the left-libertarian slant here, he's usually modded pretty well because, frankly, he makes very good arguments. He's apparently a productive poster as well. I'm a little wary of adding friends here, but after his "performance", so to speak, in that story, I had to add him. Simply an outstanding guy, and a great read.

Encryption

Journal: The Mom Test 2

Journal by Sloppy

Out of the blue, I got an email from my mom. She's been corresponding with someone about some sensitive things, and asked how to encrypt her emails.

My writeup is 9 paragraphs long. *sigh* There's so way she's really going to be able to do all that without me eventually going over there.

This is on Mac OS X. Sheesh. A Unix that doesn't come with gpg out-of-the-box, and the preloaded mailer (mail.app) needs a hard-to-maintain 3rd-party hack just to get basic functionality: you call this "just works?"

I don't wanna turn this into a specifically-Apple flame (I know of another high-marketshare desktop OS maker that also makes some pretty shitty apps), so I'll just make this generic comment: mail encryption is a very fundamental thing and it's ridiculous for it to not be built into all desktops. That's like a web browser that can't talk https. The howto I sent to my mom should have been about key exchange issues, not installing plugins. It's a disgrace for any mailer to not have this. This kind of shit is half the reason crypto goes unused by so many people. It's a pain in the ass not just because of the complex concepts (e.g. learning how to exchange keys safely) but because the most highly-deployed apps don't even work as-is.

Programming

Journal: Remember when.. 1

Journal by Sloppy

..a character was a byte, and you always knew what that byte meant, and you didn't have to worry about what database library the script interpreter was compiled against, and in turn what character sets the database library was compiled with support for? Remember when what you saw on the screen was the same as the underlying data?

How I long for those days. *sigh*

User Journal

Journal: Safari/Slashdot problems? 3

Journal by DesScorp

Safari (on OS X Tiger, all the latest updates) seems to be dying way too much when I'm on Slashdot. It's gotten bad enough that when I report it to Apple, I put "Slashdot hates you" in the what-were-you-doing part of the crash dialogue box. I wonder if Slashdot has some funky scripts that Safari chokes on?

Spam

Journal: Go Go Greylisting! 2

Journal by Sloppy
Wow, postgrey just got rid of 99% of my spam, before it gets to spamassassin, and with no false positives (any standards-compliant mailers can get through it). I should have done this ages ago.
Unix

Journal: I hate Unix schedulers 9

Journal by Sloppy

One of the things that annoyed the hell out of me when I made the "big switch" around 2000-2002 from AmigaOS to Linux, is the dynamic scheduling. I'm pretty sure I've bitched in my /. journal about this before, but I'm too lazy to go back and look.

Hey, when I "nice" a time-consuming process, I fucking expect it to not slow my computer down, no matter how CPU-intense it is. That's how it was on AmigaOS: I could run as many tasks as I wanted, and as long as I gave them a priority lower (or was it higher, damn I don't remember the specifics) than 0, it had absolutely no impact on the responsiveness of the computer, and anything that I ran at a normal priority, ran just as fast as it would if I hadn't been running those other tasks at all. That's the joy of an absolute scheduler: it starves the low-priority tasks, and as a user that's what I want.

But all the so-called "modern" systems after the 1980s, from OS/2 to Windows to Linux (and now Mac OS as of version 10) totally fuck this up.

My Mac here at work runs a long job every morning, that I have niced. When it's running, the whole damn machine feels sluggish and -- seriously -- I can out-type the speed at which my fucking keystrokes are appearing in this fucking web browser's textarea. It is so utterly ridiculous that a 1.5GHz machine can't run as fast as 50 MHz Amiga.

Niced processes should starve if there's anything better to do. Absolutely starve. That is a good thing, not a bad thing.

But can Unix have this? Nooooo, because something (I don't know what) might deadlock (at least according to Linus, when the topic comes up in the context of Linux). Well, get your locks sorted out, Unixheads, so that maybe someday Unix can run as fast as an Amiga that has a tenth of the processing power.

Mediocrity finds safety in standardization. -- Frederick Crane

Working...