Thursday, November 29, 2012

On (not) mixing static methods in stateful classes

Pure_function sometimes are modeled as static methods in Java should not be present in classes which also have state. Static methods are appropriate for things that don't have associated state. Some factory methods, "purely functional" methods like Math.min, etc are all perfectly acceptable static methods. Purely functional methods have no need for dependency injection, or to interact with the enclosing object and hence should be refactored into their own utility classes.
At the meager cost of a few more files and some more code we will have simpler objects and a better set of interfaces. Such a version might only be a couple of lines shorter than the other implementation but it knows much less about its constituent parts. This ensures, the functionality of helper functions is no longer locked in the context of another object. The Unix philosophy illustrates that small components that work together through an interface can be extraordinarily powerful. Nesting an aspect of your domain as an implementation detail of a specific model conflates responsibilities, bloats code, makes tests less isolated and slower, and hides concepts that should be first-class in your system. In "The Art of Unix Programming" Eric Raymond states Rule of Modularity as “write simple parts connected by clean interfaces.” This philosophy is a powerful strategy to manage complexity. Like Unix, systems/libraries should consist of many small classes each of which are focused on a specific task and work with each other to accomplish a larger task. Finally to quote Kent Beck from the Smalltalk Best Practice Patterns "Good code invariably has small methods and small objects. I get lots of resistance to this idea, especially from experienced developers, but no one thing I do to systems provides as much help as breaking it into more pieces.

Thursday, January 26, 2012

TED talk: Algorithms that shape our world

Kevin Slavin talks about how people will one day terraform the earth just to make algorithms get access to data faster. Talks about how algorithms
 i. on Amazon.com caused the price of the book "The Making of a Fly" to become 23 million USD
ii. caused 9% of wealth of US stock markets to disappear in the Flash Crash of 2:45



Monday, January 23, 2012

Summarize large amounts of frequency data in sublinear space

Count Min Sketch is a sublinear space datastructure which can be used for approximate answers to data streams for points, ranges and etc. It can be used for finding the most frequent items (approximately) and also extended to find anomalies or differences in streams for monitoring.
Original paper: http://www.eecs.harvard.edu/~michaelm/CS222/countmin.pdf
Related paper: Finding significant differences in Network Data Streams


Sunday, January 22, 2012

Discussion on Spatial indexing algorithms

For people interested in Spatial Databases there is an interesting list of algos used for indexing (Quadtrees, Geohashes and Hilbert curves) at http://blog.notdot.net/2009/11/Damn-Cool-Algorithms-Spatial-indexing-with-Quadtrees-and-Hilbert-Curves

LZMA algo and XZ Utils

XZ Utils is a data compression software with pretty high compression ratio. It uses the LZMA algorithm and has much better compression ratios than bzip2


Tuesday, December 14, 2010

What winter in Pacific Northwest does to you

winter up north
Is it the same in every part of the high northern hemisphere? Does it always feel like you just woke up from a fever breaking, at noon, except it’s dark.Something about cloud cover, and axial tilt, and the moon, and magnets.

Wednesday, September 29, 2010

Frequency with which various adjectives are intensified with obscenities

'Fucking ineffable' sounds like someone remembering how to do self-censorship halfway through a phrase."

Tuesday, March 16, 2010

AdSense now serving multiple ad networks

Here is the mail from Adsense announcing this.


Hi,

We have launched a new capability in AdSense allowing Google-certified ad networks compete directly within AdSense, which means that advertisers from these third-party networks will be able to compete with AdWords advertisers to show on the Google Content Network.

These new capabilities will automatically be enabled for your account, and you'll see a new section in your Ad Review Center where you can allow or block specific ad networks or all networks except AdWords. Please note that we'll gradually be adding new ad networks to AdSense accounts over the next few months, so you won't see any immediate impact on your ads or your earnings.

To ensure the quality of the ads that appear on AdSense publisher websites, Google will certify all participating ad networks for adherence to our standards for user privacy, ad quality, and speed. Some participating ad networks use targeting methods similar to Google's interest-based advertising to show more relevant ads to users on the sites they visit. These ad networks won't be permitted to collect data from your site for the purpose of subsequent interest-based advertising, but we'll allow networks that comply with user privacy guidelines to show ads using these tools. Publishers can opt out of user interest targeting from these ad networks, and Google has changed our requirements for third-party ad serving to reflect this.

We are currently only accepting ads from Google-certified ad networks in North America and Europe, but we will make this feature available to ad networks in additional parts of the world in the future.

To learn more and manage the ad networks appearing on your pages, visit the AdSense Help Center at https://www.google.com/adsense/support/bin/topic.py?hl=en&topic=13522 and visit our blog post at http://adsense.blogspot.com/2010/03/google-certified-ad-networks-now.html.

Sincerely,
The Google AdSense Team

Wednesday, February 3, 2010

[Online Dating Advice] Exactly What To Say In A First Message

From: http://blog.okcupid.com/index.php/2009/09/14/online-dating-advice-exactly-what-to-say-in-a-first-message/
Ok, here’s the experiment. We analyzed over 500,000 first contacts on our dating site, OkCupid. Our program looked at keywords and phrases, how they affected reply rates, and what trends were statistically significant. The result: a set of rules for what you should and shouldn’t say when introducing yourself online. Let’s go:
Rule 1
Be literate
Netspeak, bad grammar, and bad spelling are huge turn-offs. Our negative correlation list is a fool’s lexicon: ur, u, wat, wont, and so on. These all make a terrible first impression. In fact, if you count hit (and we do!) the worst 6 words you can use in a first message are all stupid slang.
Language like this is such a strong deal-breaker that correctly written but otherwise workaday words like don’t and won’t have nicely above average response rates (36% and 37%, respectively).
Interesting exceptions to the “no netspeak” rule are expressions of amusement. haha (45% reply rate) and lol (41%) both turned out to be quite good for the sender. This makes a certain sense: people like a sense of humor, and you need to be casual to convey genuine laughter. hehe was also a successful word, but much less so (33%). Scientifically, this is because it’s a little evil sounding.
So, in short, it’s okay to laugh, but keep the rest of your message grammatical and punctuated.
Rule 2
Avoid physical compliments
Although the data shows this advice holds true for both sexes, it’s mostly directed at guys, because they are way more likely to talk about looks. You might think that words like gorgeous, beautiful, and sexy are nice things to say to someone, but no one wants to hear them. As we all know, people normally like compliments, but when they’re used as pick-up lines, before you’ve even met in person, they inevitably feel…ew. Besides, when you tell a woman she’s beautiful, chances are you’re not.
On the other hand, more general compliments seem to work well:
The word pretty is a perfect case study for our point. As an adjective, it’s a physical compliment, but as an adverb (as in, “I’m pretty good at sports.”) it’s is just another word.
When used as an adverb it actually does very well (a phenomenon we’ll examine in detail below), but as pretty’s uses become more clearly about looks, reply rates decline sharply. You’re pretty and your pretty are phrases that could go either way (physical or non-). But very pretty is almost always used to describe the way something or someone looks, and you can see how that works out.
Rule 3
Use an unusual greeting
We took a close look at salutations. After all, the way you choose to start your initial message to someone is the “first impression of your first impression.” The results surprised us:
The top three most popular ways to say “hello” were all actually bad beginnings. Even the slangy holla and yo perform better, bucking the general “be literate” rule. In fact, it’s smarter to use no traditional salutation at all (which earns you the reply rate of 27%) and just dive into whatever you have to say than to start with hi. I’m not sure why this is: maybe the ubiquity of the most popular openings means people are more likely to just stop reading when they see them.
The more informal standard greetings: how’s it going, what’s up, and howdy all did very well. Maybe they set a more casual tone that people prefer, though I have to say, You had me at ‘what’s up’ doesn’t quite have the same ring to it.
Rule 4
Don’t take it outside
Obviously, all successful OkCupid relationships outgrow our in-site messaging feature. But an offer to chat or of an email address right off the bat is a sure turn off. One of the things online dating has going for it is its relative anonymity, and if you start chipping away at that too early, you’ll scare the other person off.
Also, don’t ask for or give away a cell number (10%). I thought that was a no-brainer.
Rule 4
Bring up specific interests
There are many words on the effective end of our list like zombie, band, tattoo, literature, studying, vegetarian (yes!), and metal (double yes!) that are all clearly referencing something important to the sender, the recipient, or, ideally, both. Talking about specific things that interest you or that you might have in common with someone is a time-honored way to make a connection, and we have proof here that it works. We’re presenting just a smattering: in fact every “niche” word that we have significant data on has a positive effect on messaging.
Even more effective are phrases that engage the reader’s own interests, or show you’ve read their profile:
Rule 5
If you’re a guy, be self-effacing
Awkward, sorry, apologize, kinda, and probably all made male messages more successful, yet none of them except sorry affects female messages. As we mentioned before, pretty, no doubt because of its adverbial meaning of “to a fair degree; moderately” also helps male messages. A lot of real-world dating advice tells men to be more confident, but apparently hemming and hawing a little works well online.
It could be that appearing unsure makes the writer seem more vulnerable and less threatening. It could be that women like guys who write mumbly. But either way: men should be careful not to let the appearance of vulnerability become the appearance of sweaty desperation: please is on the negative list (22% reply rate), and in fact it is the only word that is actually worse for you than its netspeak equivalent (pls, 23%)!
Rule 6
Consider becoming an atheist
Mentioning your religion helps you, but, paradoxically, it helps you most if you have no religion. We know that’s going to piss a lot of people off, and we’re more or less tongue-in-cheek with this advice, but it’s what the numbers say.
These are the religious terms that appeared a statistically significant number of times. Atheist actually showed up surprisingly often (342 times per 10,000 messages, second only to 552 mentions of christian and ahead of 278 for jewish and 142 for muslim).
Though very few people actually do it, invoking the sky-breaking thunderbolts of zeus does help a person get noticed (reply rate 56%), but maybe that shouldn’t be a surprise on a site that is itself named for a member of the Classical pantheon. So if you can’t bring yourself to deny the deity, consider opening yourself up to a whole wacky bunch of them. But ideally you should just disbelieve the whole thing. It can help your love life, and, besides, if there really was a god, wouldn’t first messages always get a reply?

Sunday, January 31, 2010

Moscow in slow-motion

Moscow in slow-motion - Amazing video

Cosmo's 10 Naughtiest iPad Sex Tips [Multi-touch Experience]

Cosmo's 10 Naughtiest iPad Sex Tips [Multi-touch Experience]
Apple's iPad is supposed to save print media, and Cosmo is a magazine that's just begging to be presented in a vibrating format. Here are some sex tips you can expect to see in the digital pages of the magazine:
10) Play a racing game and crash your car into a tree. When the iPad starts to vibrate, rest his balls on it.
9) Lie naked on the bed with the iPad resting on your belly. When he comes home, tell him he can surf the web on you tonight.
8) How about some role playing? While wearing a black turtleneck and jeans, say you want to introduce him to a 'magical' new product... in your pants.
7) Write him an e-mail explaining exactly what you want to do to him tonight in 64-point font. Everyone on the train knowing how sexy his girlfriend is will get him even hotter!
6) Load a children's alphabet game and hold the iPad so he can see it during oral sex. Tell him to trace whatever letter pops on the screen.

5) Keep ice water on your nightstand. Dip your fingers in it, and flick it on his chest. Then tap the end of the iPad's power cord on his nipples for a sexy shock.

4) Sit facing your man while you're both holding your iPads and tell him to IM what he wants to do to you — no touching allowed. See how long he can resist!

3) Check out the latest issue of Cosmo on the iPad... without using your hands. Seeing you pinch and click with your breasts is sure to make something bigger.

2) Wrap your dirty thong around his iPad in the morning and leave it in his bag. He'll get a big surprise when he takes it out at work!
1) Try to stick it in his butt.

Sex explained with pens

Sex explained with pens:


Monday, January 4, 2010

Amazon Holiday Season 2009 facts

    * Most remote shipments contained the EMU Australia Toddler Boot and was delivered to Atqasuk, Alaska.
    * Amazon customers purchased enough fruit cake to equal the weight of a 1967 Volkswagen Bug.
    * Amazon customers bought enough gingerbread house kits that if stacked on top of each other would be as tall as the Sears Tower.
    * If all the computers customers purchased this holiday were stacked one on top of the other, they would be more than twice as high as Mt. Everest.
    * Amazon customers bought over 50 times more Light Therapy devices this holiday season than there are sunny days in Seattle the entire year.
    * For the holiday time period alone, Amazon customers purchased enough shoot-and-share camcorders to supply 50 years' worth of non-stop YouTube watching.
    * Amazon customers bought enough Levi's jeans to clothe everyone at the opening ceremony of the 2010 Olympics in Vancouver.
    * Amazon customers purchased so many Blu-ray disc players that if you lined them up side to side, they would stretch for more than 27 miles.
    * During the 2009 holiday season, Amazon customers bought enough 8 GB iPod touches to play 442 years of continuous music.
    * In 2009, Amazon customers purchased enough heart rate monitor watches to put one on the wrist of everyone who finished the New York City marathons in 2008 and 2009.
    * Amazon customers purchased enough Frustration-Free Package items to eliminate over 32,000 pounds of frustrating plastic materials, such as plastic clamshells.
    * The last One-Day Prime order that was delivered in time for Christmas, was placed on Dec. 23 at 9:17 p.m. Pacific and shipped to Boca Raton, Florida for delivery on Dec. 24. The item was a pair of Yellow Gold 8-8.5mm Freshwater Cultured Pearl Stud Earrings.
    * The last Local Express Delivery order that was delivered in time for Christmas, was placed by a Prime member and went to Seattle. It was a Kindle that was ordered at 1:43 p.m. on Christmas Eve and delivered at 4:57 p.m. that evening.

Amazon.com's Hot Holiday Bestsellers (Nov. 15 through Dec. 19, based on units ordered):
    * Electronics: Kindle Wireless Reading Device Apple iPod touch 8 GB and Garmin nuvi 260W 4.3-inch GPS
    * Toys: Scrabble Slam Cards The Settlers of Catan and Scene It? Twilight Deluxe Edition
    * Video Games and Hardware: Wii Fit Plus with Balance Board New Super Mario Bros and Call of Duty: Modern Warfare 2
    * Sports & Outdoors: Razor A Kick Scooter Victorinox Swiss Army Champion Plus Pocket Knife and P90X Extreme Home Fitness Workout Program
    * DVD: "Harry Potter and the Half-Blood Prince" "Star Trek" and "Up"
    * Books: "Going Rogue" by Sarah Palin; "The Lost Symbol" by Dan Brown; and "The Help" by Kathryn Stockett
    * Music: "I Dreamed A Dream" by Susan Boyle; "My Christmas" by Andrea Bocelli; and "Crazy Love" by Michael BublĂ©
    * Jewelry: Sterling Silver Marcasite & Garnet Glass Heart Pendant 10k White Gold Diamond 3-Stone Heart Pendant and 18k White Gold Round Diamond 4-Prong Stud Earrings
    * Watches: Casio Men's Waveceptor Atomic Dual-Time Watch Invicta Men's II Collection Chronograph Stainless Steel Blue Dial Watch and Timex Kids' Camouflage Stretch Band Watch
    * Beauty: Sephora Brand Color Play Palette II Santa's Lump of Coal Christmas Soap and Sephora Brand Ultimate Blockbuster
    * Home & Garden: Keurig My K-Cup Reusable Coffee Filter Vinturi Essential Wine Aerator and Oster Electric Wine-Bottle Opener
    * Clothing & Accessories: The Mountain Three Wolf Moon Short Sleeve Tee Levi's Men's 550 Relaxed Fit Jean and Levi's Men's 501 Jean
    * Shoes and Handbags: Steve Madden Women's Bonanza Tall Shafted Flat Boot Hunter Original Tall Welly Boot and EMU Australia Women's Hip Boot
    * Health & Personal Care: Omron HJ-112 Digital Pocket Pedometer Philips Sonicare Essence 5300 Power Toothbrush and Farouk CHI 1 Inch Ceramic Flat Hairstyling Iron
    * Gourmet Food: Bon Appetit Gift Basket Grand Ghirardelli Chocolate Gift Basket and 50's Decade Box Gift Basket
    * Home Improvement: Black & Decker MSW100 Ready Wrench Bosch Laser Distance Measuring Device and Joby Gorillatorch Adjustable and Flexible Tripod Flashlight
    * Automotive Parts & Accessories: Wagan 12V Heated Seat Cushion 3M Headlight Lens Restoration System and Autel MaxiScan MS300 CAN OBD-II Scan Tool
    * Baby: Baby Einstein Takealong Tunes Vulli Sophie the Giraffe Teether and Baby Einstein Bendy Ball
    * Software: Microsoft Office Home and Student 2007 Adobe Photoshop Elements 8 and Microsoft Office 2008 for Mac Home & Student Edition
    * Grocery: Coffee People Donut Shop K-Cups for Keurig Brewers Coffee People K-Cup Santa's Buzz and Vita Coco 100% Pure Coconut Water
    * Wireless: Nokia 5800 XpressMusic Unlocked Phone Plantronics 510 Bluetooth Headset and BlackBerry Bold 9700 Phone (AT & T)

Wednesday, November 25, 2009

Sabina Stobrawe: Divorce lift

Sabina Stobrawe: Divorce lift

A typical wedding photo was affixed to door lift doors in a law firm. Unfortunately, every time the doors opened, the couple split up. But help was at hand for everyone in the same position as soon as they stepped into the lift: a sign showed the name of the law firm and which floor the office was on.


Tuesday, November 17, 2009

Closure Compiler

From Closure Compiler - Google Code:

"What is the Closure Compiler?

The Closure Compiler is a tool for making JavaScript download and run faster. It is a true compiler for JavaScript. Instead of compiling from a source language to machine code, it compiles from JavaScript to better JavaScript. It parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what's left. It also checks syntax, variable references, and types, and warns about common JavaScript pitfalls.

To help you work with your transformed code, you can also install the Closure Inspector, a tool that makes it easy to use the Firebug JavaScript debugger with the Compiler's output.

The Closure Compiler has also been integrated with Page Speed, which makes it easier to evaluate the performance gains you can get by using the compiler."

Monday, November 16, 2009

NoSQLs Compared

A good review of the various NoSQLs products for
1) supporting multiple datacenters,
2) the ability to add new machines to a live cluster transparently to the your applications,
3) data model,
4) Query API and
5) Persistence Design.
The systems reviewed are: Cassandra, CouchDB, HBase, MongoDB, Neo4J, Redis, Riak, Scalaris, Tokyo Cabinet and Voldemort.
Article: http://www.rackspacecloud.com/blog/2009/11/09/nosql-ecosystem/#

Friday, November 13, 2009

Funny Facebook Groups (Part 3)

When I was your age, Pluto was a planet
People Who Always Have To Spell Their Names For Other People
I Use my Cell Phone to See in the Dark
I Flip My Pillow Over to Get To The Cold Side
Enough with the Poking, Lets Just Have Sex
If this group reaches 4,294,967,296 it might cause an integer overflow
Fuck Iraq, We have to catch Voldemort
I read the group name, I laugh, I join, I never look at it again.
Honestly, I write "lol" and I’m not Even Laughing
I Will Go Out of My Way To Step On a Leaf That Looks Particularly Crunchy
It wasnt awkward until you said "well, this is awkward". now its awkward.
If I Fail My Exams, Its Facebook’s Fault

Funny Facebook Groups (Part 2)

Bollywood gave me unrealistic expectations about desi women

I Thought You Were Hot Until I Clicked on "View More Pictures"

Alcohol Improves my Foreign Language!

I Wish I Were Your Derivative So I Could Lie Tangent To Your Curves!

When I was your age, we had to blow on the video games to make them work...

Do you believe in love at first sight, or should I walk by again?

For those who have ever pushed a "pull" door

Geometry can kiss my Angle-Side-Side

If I were an enzyme i would be DNA helicase so i could unzip your genes

I Secretly Want To Punch Slow Walking People In The Back Of The Head

Funny Facebook Groups (Part 1)

Anteater-Mushroom Alliance

Writing Papers Single Spaced First Makes My Double Spaced Result Climactic

Most Replys Inner Scrotum!!!

I Paint My Nails Like a Blind Parkinson's Patient
I Dont care How Comfortable Crocs Are, You Look Like A Dumbass.

If You're OCD And You Know It Wash Your Hands!

Dora the Explorer is soo an Illegal Immigrant...

BRB... IM NOT REALLY GOING ANYWHERE, BUT NEITHER IS THIS CONVERSATION

DAMM (drunks against mad mothers)

When I Was Your Age, Shoes Didn't Have Wheels

Worst. Facebook Group. Ever.

it's obvi you're just jeal cause I speak in abrevs so whatev

Monday, November 9, 2009

Prefix Hash Tree

Distributed Hash Tables are scalable, robust, and self-organizing peer-to-peer systems that support exact match lookups. This paper describes the design and implementation of a Prefix Hash Tree - a distributed data structure that enables more sophisticated queries over a DHT. The Prefix Hash Tree uses the lookup interface of a DHT to construct a trie-based structure that is both efficient (updates are doubly logarithmic in the size of the domain being indexed), and resilient (the failure of any given node in the Prefix Hash Tree does not affect the availability of data stored at other nodes).
Paper: http://berkeley.intel-research.net/sylvia/pht.pdf