February 01, 2010

Reading JQuery Sources

JQuery has become the stdlib of Javascript. After reading the jQuery docs, the next level of understanding comes from reading the code.

Here is an excellent new tool for reading the jQuery source, thanks to James Padolsey.

Food for Thought: International jQuery Use

On going back and looking at the top regions in which 'jquery' is a topic of Google searches, I find it interesting - and maybe worrying for U.S. internet innovators - that none of the top 6 jQuery cities of the world are in the U.S...

Continue reading "Reading JQuery Sources"
Posted by David at 07:23 AM | Comments (0)

January 30, 2010

Random Seeds, Coded Hints, and Quintillions

Here is a seedable random number generator in Javascript that you can set up to produce a determinstic sequence of pseudorandom numbers. Browsers do not provide a built-in way to seed Math.random(), so this solution is handy both when you need a repeatable pseudorandom sequence that is completely predictable, and when you need a robust seed that is much more unpredictable than your browser's built-in random number generator.

Many games that use weak random number generators have been cracked by exploiting their lack of randomness, and recently it has even been shown that it is possible to guess your 'random' Social Security Number given information about the time and location of your birth. To resist this type of attack, you want do better than a linear congruential PRNG seeded with the current time. Explanations below.

A Math.seedrandom Function

This script defines a function Math.seedrandom() that replaces Math.random with a seeded sequence of your choice. You use it by including seedrandom.js and then calling

Math.seedrandom('any string you like');

Next time you call Math.random(), you will get a deterministic sequence of results that can be reproduced at any time on any browser by calling seedrandom with the same string (with the example seed above, you will always get 0.4514661562021821, 0.06749172707294096, 0.8683962295094814, etc).

Seed:

The code uses RC4 as the pseudorandom number generator, so the randomness is a bit better than what you get from most browsers' built-in Math.random. But since it does all the computation in javascript, it is also is 3-10x slower.

A minified version of seedrandom.js (using the Google Closure Compiler) is less than 1K.

The code also supports automatic seeding...

Continue reading "Random Seeds, Coded Hints, and Quintillions"
Posted by David at 08:06 PM | Comments (0)

January 24, 2010

Xinhua: We Report, You Decide

Does reading the Chinese press remind you of watching Fox News?

There is a whole world outside China and outside Fox News that is starkly different and a bit closer to reality.

But when you realize that Fox is actually the most trusted news brand in the U.S. today, you can get an appreciation for the success that a censored Chinese media can have inside the world's largest society. The effects of squashing dissent in the name of nationalism are not "very limited"...


Posted by David at 09:49 AM | Comments (1)

January 19, 2010

My God, What Have We Done?

Fellow Massachusetts voters! What was the point in electing Brown?

Continue reading "My God, What Have We Done?"
Posted by David at 09:57 PM | Comments (3)

January 18, 2010

Campaign Calls

We've gotten three calls from the Scott Brown campaign in the last 24 hours, two of them late at night. The GOP smells blood in the water.

But everybody around here is a Democrat!


Posted by David at 12:10 PM | Comments (1)

January 17, 2010

Vote

My wife was originally not going to bother voting in Tuesday's special election for Senate, since we live in deepest of the deep blue states.

But it's turning out to be a nailbiter, so she's going to vote after all.

Go vote.


Posted by David at 07:38 AM | Comments (0)

January 16, 2010

Ballmer Favors Torture for Lawyers

After a series of Chinese lawyers have been imprisoned and tortured and "gone missing" for speaking up for their clients in China, our friend Steve Ballmer still "doesn't understand" why Google is upset about break-ins into Chinese lawyers email accounts. "I don’t think there was anything unusual," he says.

Perhaps torture of lawyers is routine at Microsoft; it is a bit unusual at Google.


Posted by David at 12:18 PM | Comments (0)

January 15, 2010

Anagram

A puzzle!

Rearrange the letters SEARCH ENGINE to make a phrase representing the displeasure of a nation.

h/t Rachel Grey


Posted by David at 11:38 AM | Comments (6)

January 14, 2010

Flawed Security

As awareness of the seriousness of the Chinese intrusion into Google expands, I would like to highlight what the Chinese "People's Daily" is saying about Google today:

As the world's most famous search engine company, supposedly its defense capabilities should also be very strong. If the defense system is really flawed, it is necessary to strengthen preventive measures, while passive withdrawal only shows incompetence, but also contributes to the arrogance of hackers, which is very inconsistent with Google's prominent identity.

Think about that for a moment.

Google caught the electronic equivalent of a Chinese drone attack, using sophisticated weapons and circumnavigating layers of defenses. Imagine if the Chinese People's daily had issued a similar statement about the lack of antiaircraft missiles atop the World Trade Center or lax security of United Airlines.

The Google attack was not merely a picked lock.

As some details come out, it is clear that the attacker must have had access to many resources: the ability to make a custom virus on a previously unknown bug in IE; a familiarity with the architecture of Google's highly protected internal systems; and the knowledge of Chinese dissident private email addresses. An expert has called the attack on gmail "incredibly sophisticated, the kind only seen in the government and defense industrial sector."

What seems increasingly flawed is the premise that it is possible to operate an honest business under the thumb of Chinese authorities.


Posted by David at 09:15 AM | Comments (0)

January 13, 2010

November 10, 2009

Pointless Arbitrage

Banks are special: the Fed pumps them with money because they are supposed to be the smartest lenders. The decisions of the local bank loan officer drive the engine of capitalism.

Unfortunately, the big money is no longer in writing the loans. The big money is in arbitrage.

And that is why our economy is in trouble today.

Reversi Arbitrage

The pointlessness of arbitrage is obvious after you play a couple short games of Reversi.

On the left, play as Black. On the right, play as White.

Either game is challenging to win on its own.

However, if you play both games at once, replaying Black's moves against White and vice-versa, then you are guaranteed to win one game with no effort and no skill.

Even if you are a terrible player, you can rack up a 50% record with this strategy.

And there is money to be made on a 50% record. You can offer to bet $100 for every game played, and you will never lose any money. If you put on a good suit and print some business cards, you could surely collect a few pennies of fees for each game and turn this two-faced game-playing technique into a profitable business. Or make a computer program that plays this way, plug it directly into the markets, and make a killing.

The problem is this: you might be rich, but you would still be a terrible player.

Arbitrage Is Not Banking

And that is the problem with arbitrage.

Banks are no longer playing the loan-officer game. They do not need to know how to recognize a bad loan. They just need to know how to package it up to be resold to a different investor. Maybe the investor is being dumb, or maybe the borrower is being dumb - the banks don't care because they just pass the game through to the other side.

That is the norm in banking today. It is a blind, stupid business and it adds nothing to the economy.

Banks have long argued that the derivatives they write increase the efficiency of the capital markets, but the more you really understand derivatives, the more you realize that they are simply a way for banks to duck out of their responsibility of actually playing the role of a bank.

We need banks to get back to the business of making real decisions and taking on real risks.

Banks Need To Take Risks

Banks should not be allowed to securitize loans, write derivatives contracts, buy insurance against defaults, or transfer risk to other investors in any way.

The role of banks should be to take risks and absorb risk. Banks are insured by the FDIC and have access to the Fed discount window. They should not be allowed to have these advantages while passing their risks on to others. Arbitrage and banking should be separated.

Banks need to have skin in the game.


Posted by David at 10:45 PM | Comments (1)

September 27, 2009

Mandelbrot

In the spirit of drawing fractals using technology that was intended to do something else, here is an interactive Mandelbrot Set webpage implemented in Javascript. It works pretty comfortably in Chrome and okay in Firefox. IE may have some trouble with it.

In the pre-XGA graphics days, you couldn't render a very good-looking Mandelbrot set on a computer screen, so I used to write programs that rendered on laser printers. The cluster of word processing PCs in the basement of my school's English building would chug away through the night, iterating polynomials.

In this Javascript Mandelbrot implementation, click on a spot in any picture to zoom in. It uses table cells to draw pixels. Each iteration is rendered as soon as it is computed, so the pictures get more refined over time. More on this well-known fractal here or here.

Javascript Mandelbrot Explorer


Posted by David at 10:16 PM | Comments (1)

Calendar
February 2010
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28
Search

Archives
Recent Entries
Reading JQuery Sources
Random Seeds, Coded Hints, and Quintillions
Xinhua: We Report, You Decide
My God, What Have We Done?
Campaign Calls
Vote
Ballmer Favors Torture for Lawyers
Anagram
Flawed Security
Google and China
Pointless Arbitrage
Mandelbrot
Bravo for Courier
What's in the Box
Coin Flips Are Biased
Javascript Reversi
Time To Build A Treehouse
Free Market Healthcare
Niagara Restaurants
Law vs Power
Weiner Goes to Washington
Where I Learned Programming
Disorderly Conduct
Dear Losers
McCain/Lieberman
Easy Math Typesetting
The Small Government Paradox
The 3.6% Accident
What is a Floppy Disk?
Two Steps Behind
Politics is Important
Your Compiler Vanishes in A Puff of Logic
Elastic Shortfalls
Poetry and Prose
Death and Taxes
Geithner's China Triumph
COP and the IMF Playbook
How To Nationalize
A Cultural Problem
Obama to the World: Join Us
What is a Stress Test?
How Big Is It?
Helicopters Arrive Under Cover Of AIG Testimony
Clever Outrage
Processing
Congressional Team Building
The Bossy R
Bulls Enter China Shop
American Majesty
No Deceit Here
Winning at Chess
Transition in Cyberspace
Elizabeth Warren
Continued Fractions
Rationals are Nonobvious
Yellowstone Swarm
RMB in the NYT
In Spending We Trust
Foreign Affairs on China
Junichiro Obama
Helicopters Take Off
Amazing Transparency
A Reflective Phobia
Trade Deficit Arithmetic
Perfect Numbers
Taxman Game
Mapping Out a Trade War
Currency Disaster
The Chinese Depression
Sudoku Help
Second Grade Spelling
Waiting For Doc
Twenty Eight Hours
What Do You Call It?
Rahm Emanuel
A Fourth Republic
Helicopters and Imports
An Historic Day
Chomp
The 144 Game
Klein on Obama
I Blame Markowitz
Time for Japan to Buy
Republican Rebels
Pictoral Subtraction
McCain and Obama at Al Smith
What After November 4?
Where Is The Excess Capital?
Quick, Get a Mortgage
World's Toughest Job
What's Scaring People
The U.S. Needs a King
Dear Nancy Pelosi
A Sensible Proposal
Do-Nothing Republicans
Letterman's Best Non-Guest
What's the Rush?
Canon to Reshape Media
An Era of Inflation Begins
How to Sweep $2m Under The Rug
Links
Older Writing
About