Google voice comedy

August 18th, 2010

Yea for Google Voice transcription:

“”"
Hey Matt, I was gonna miss you get a real i guess it up. Maybe tomorrow. This letter tiny bit on hold because al bridge. Uncle in law, so awful ever while helping him do some work at the house yesterday and apparently, so I signed my resume but he said he’s totally OK, and the valve Richard worry about it anymore. But I’ll put shows what’s up, so short, we’re probably still gonna go and officially you’re You’re welcome. And because this is. That’s my fault for we’ll see you bye.
“”"

Shell trick: track new tcp connections per second in Linux

February 11th, 2010

This little snippet is for when you want to see new active connections per second, not concurrent established, as most tools show you:


C=0; while true; do echo "new connections: $C"; c1=`netstat -s -t|grep "active connections openings"|awk '{print $1;}'`; sleep 1; c2=`netstat -s -t|grep "active connections openings"|awk '{print $1;}'`; C=`expr $c2 - $c1` ; done

Enjoy!

Introducing: Business Engineering, the evolution of Business Intelligence

February 11th, 2010

Define intelligence:

Intelligence is a characteristic of thinking, but it is also a thing to be acquired. This substance is different than information. Intelligence is information that has been discovered, processed, and presented in a way that encourages its other definition: disciplined, insightful thinking.

Define engineering:

Engineering is the deliberate, analytical, scientific application of intelligence to the design or modification of a system.

Most data floated as Business Intelligence is more accurately labeled business information. It becomes the substance Business Intelligence when superior tools expose patterns and trends that are actionable.

Business Engineering is the practice of managing decisions based on critical analysis of intelligence about internal and external factors influencing the business.

RescueTime allows businesses to tweak the previously hidden algorithms that drive productivity of workforces. Data is scientifically gathered, and innovatively processed and presented in real time.

Businesses can re-balance work loads, uncover inefficiencies, and identify stalled or unusually successful projects while they are happening. Smart managers can introduce a measure of science into management itself: easily visualized historical information exposes trends one week to the next. Try several workflow processes, prove which one works best for each team.

Ruby for are these chars in this string…

February 11th, 2010

I find myself wanting to know if the characters in one string are in another.
For example, if you have a key space for a string key name, making sure the provided key is valid.


require 'set'
def chars_subset_of? checkme, inme
checkme.split(//).to_set.subset? inme.split(//).to_set
end

You could also toss this inside class String to dynamically add the method


require 'set'
def chars_subset_of? other_string
if other_string.class == String
self.split(//).to_set.subset? other_string.split(//).to_set
else # just try
self.split(//).to_set.subset? other_string.to_set
end
end

Appengine: Auccumulate and Rejoin Fragmented Data or Buffer Small Object Floods in Memcache

February 11th, 2010

I put this together to solve a problem where contiguous data generated in JavaScript on the browser side needed to be broken into pieces and sent to the server and reconstructed there. The same tool could be used to buffer rapidly incoming small objects to queue for batch inserts for higher performance / less contention on the Appengine datastore.

Jump to the code. I apologize for the CSS failfailfail.

For the “large object out of many small fragments” use case:

The principle is the sender provides some kind of identifier that uniquely identifies the batch. I use a cookie that is generated on page load combined with a counter in the JS that is incremented once for each batch from that client. The cookie was conveniently already there for another purpose.

On the server, the library takes this identifier and uses it as the memcache root key or “groupkey” in the code. Each fragment sent should include the total expected, and the index in the array of fragments of the current fragment. On the server an atomic global counter keeps track of when all pieces are sent. The api allows you to use the library to preserve the array order, or you can just stick order info in the stored value and figure it out yourself when the server gives you the completed array of accumulated fragments. Very simply, the server uses the unique identifier both to store the fragments in memcache and to keep track of the fragment count, which when equal to the expected count raises a Complete exception, allowing you to fetch back an array of all the fragments. Typically this would be done inline with the request that’s sending the last missing fragment.

For the case of queueing up small objects for batch insert into BigTable:

This use case is obvious, and analysis is left to the reader as exercise (smile). Basically, the above concern about order is removed, and the reconstruction is unneeded.