Archive for the ‘geeky’ Category

San Diego’s 1st SuperHappyDevHouse (SDSHDH1)

Sunday, July 4th, 2010

Update 7/11/2010: Coverage of the event from the Del Mar Times by Steve Perez!

San Diego’s 1st ever SuperHappyDevHouse was a blast and success! Special thanks to Erica and Richard for hosting the hackathon :) We had about 17-18 software + hardware folks (and one reporter! we have no idea how that happened). The venue was perfect, people brought snacks, drinks, lawn chairs, and we ordered pizza. Most of the attendees are not surprisingly, from the San Diego Hacker News meetup.

While the attendance was really great good for the SDSHDH1, I suspect that it would have been as much as 30% higher if the semester was in session as many of those who voiced interest are college students from the nearby UCSD. Below are some pictures and videos from the event. I’m already looking forward to the next one! :) Thanks to all who stopped by—”network effects” is key to having a fun SHDH ;)

SDSHDH1

SDSHDH1

SDSHDH1

What do a philologist and a lollipop have in common?

Wednesday, February 24th, 2010

Question: What do a philologist and a lollipop have in common?

Answer: LOL (if you don’t get it, you will LOL when you see it below)

The generalized problem statement

Given a few strings:

  ewf3hardyharharoiew
  p90weuhardyharhar
  hardyharharoie78wjf
  ahardyharhar787834

Determine the longest substring that they all have in common:

 p90weuhardyharhar
       |||||||||||
      ahardyharhar787834
       |||||||||||
   ewf3hardyharharoiew
       |||||||||||
     d1hardyharharoie78wjf

Which in this example above, is ‘hardyharhar’. The question is, how do you code this?

The solution

Today on Hug-An-Algorithm day, we’re giving the hat-tip to an algorithm called longest common substring (LCS).

The solution can be implemented using a generalized suffix tree, or by dynamic programming
(Wikipedia).

Specifically, I’ll walk you through a Python implementation—but focusing on the approach behind it, so that you can implement this in any language you want. I found a few LCS implementations on Wikibooks.org, which is where I got this simple Python implementation from (and adapted it slightly for this demo).


Technical nitty-gritty details warning! (If you’re interested in how this may be useful to you, skip to real-world applications section after it):

Select full screen + high quality plz:

Code from the video above for plugging into your python interpreter:

def LCS(S, T):
    m = len(S); n = len(T)
    L = [[0] * (n+1) for i in xrange(m+1)]
    LCS_set = set()
    longest = 0
    for i in xrange(m):
        for j in xrange(n):
            if S[i] == T[j]:
                v = L[i][j] + 1
                L[i+1][j+1] = v
                if v > longest:
                    longest = v
                    LCS_set = set()
                if v == longest:
                    LCS_set.add(S[i-v+1:i+1])
    print LCS_set

Real world application

As researchers, we often find ourselves swimming in a sea of seemingly random data, and we’re always looking for ways to make sense of this wealth of data, how we can obtain insights and the act accordingly.

Here’s how I use the LCS algorithm to find patterns in malicious links. Obviously, it can be applied to any kind of data outside the boundaries of security research. Hope you’ll find this tool handy in your problem-solving toolkit!

Security Researcher: Jay Liew

p.s. This blog post is dedicated to the folks in #python on Freenode.

This is a cross-post from my company’s blog.

Best thing since emoticons

Wednesday, September 23rd, 2009

Math and physics geeks rejoice! Instant messaging in LaTeX. Very cool. Check it out: http://www.mathim.com/

(char)lotte: my- *love –

Monday, November 24th, 2008

I almost fell off my chair reading this. Funniest thing I’ve seen in a while! :D C/C++ hackers would <3 this! Even if you’re not a hacker, you can still appreciate the English poetry. It’s just expressed, differently ;)

From the International Obfuscated C Code Contest, may I present to you this lovely poem:

char*lie;

	double time, me= !0XFACE,

	not; int rested,   get, out;

	main(ly, die) char ly, **die ;{

	    signed char lotte,

dear; (char)lotte--;

	for(get= !me;; not){

	1 -  out & out ;lie;{

	char lotte, my= dear,

	**let= !!me *!not+ ++die;

	    (char*)(lie=

"The gloves are OFF this time, I detest you, snot\n\0sed GEEK!");

	do {not= *lie++ & 0xF00L* !me;

	#define love (char*)lie -

	love 1s *!(not= atoi(let

	[get -me?

	    (char)lotte-

(char)lotte: my- *love -

	'I'  -  *love -  'U' -

	'I'  -  (long)  - 4 - 'U' ])- !!

	(time  =out=  'a'));} while( my - dear

	&& 'I'-1l  -get-  'a'); break;}}

	    (char)*lie++;

(char)*lie++, (char)*lie++; hell:0, (char)*lie;

	get *out* (short)ly   -0-'R'-  get- 'a'^rested;

	do {auto*eroticism,

	that; puts(*( out

	    - 'c'

-('P'-'S') +die+ -2 ));}while(!"you're at it");

for (*((char*)&lotte)^=

	(char)lotte; (love ly) [(char)++lotte+

	!!0xBABE];){ if ('I' -lie[ 2 +(char)lotte]){ 'I'-1l ***die; }

	else{ if ('I' * get *out* ('I'-1l **die[ 2 ])) *((char*)&lotte) -=

	'4' - ('I'-1l); not; for(get=!

get; !out; (char)*lie  &  0xD0- !not) return!!

	(char)lotte;}

(char)lotte;

	do{ not* putchar(lie [out

	*!not* !!me +(char)lotte]);

	not; for(;!'a';);}while(

	    love (char*)lie);{

register this; switch( (char)lie

	[(char)lotte] -1s *!out) {

	char*les, get= 0xFF, my; case' ':

	*((char*)&lotte) += 15; !not +(char)*lie*'s';

	this +1s+ not; default: 0xF +(char*)lie;}}}

	get - !out;

	if (not--)

	goto hell;

	    exit( (char)lotte);}

iPhone Tech Talk – Los Angeles

Monday, November 10th, 2008

(I’ve been rather caught up lately, and this is a slightly late post!)

Update 11/11/08: Correction, when I wrote below that a certain Apple product did not have a camera, I was referring to the iPod Touch, not the iPhone 2G! Tks CaArRrRny.

About 2.5 weeks ago, I took a day off from work and drove 2 hours up to LA to attend a mini iPhone developer conference. It was a free event, but seating was limited and reservation was a must. I was lucky to get a spot, a few of my developer buddies from the San Diego area were not able to secure one (the event “sold out” almost immediately!)

photo.jpg
 

Apple also announced that they have just launched a developer forum site just the night before. This forum is late in the game, also because it was only recently that Apple decided to lift the developer-community-killing NON DISCLOSURE (duh) agreement.

I got to meet some interesting dev guys, and learned a bit more about this new mobile platform (below are some pictures). Some of my thoughts:

The iPhone App Store really does provide value

As much as some folks criticise this “centralized” distribution method, it provides value like Digg.com, Reddit.com, and Slashdot.org does – in discovery. Does Digg create its own content? No. Digg’s largest value prop: The most interesting news at that point in time on the ‘net, when you visit the site (great for ADD news addicts). It’s a great discovery service. So if you’re an iPhone app developer, the App Store is a great way for people to discover your app. You are exposed to an audience world-wide. Or at least, the 50-60 some countries that iPhone is officially distributed in.

To contrast, in absence of the App Store, you can distribute your app on your own personal web site. Uhh, and how are you going to get discovered? Are you going to spend $ on a marketing SEO force? Look at Windows Mobile and Symbian. If you developed an app on these said platforms, you are free to give/sell it exclusively from on your own web site. There’s not an equivalent “App Store” for Windows Mobile and Symbian OS. (And how are apps doing on those platform again? Right..)

Apple’s seemingly arbitrary process of approving apps sucks

Yeah it sucks. Apple provided lunch at the Grand Wilshire hotel, so we didn’t have to go out and spend money. Nice move, because developers can discuss and get to know each other over a meal (aligned with AAPL’s motive of cultivating a developer community – and oh, I like free food too). One thing that appears to be the consensus is Apple’s no-guidance on what apps they will approve or not approve to be on the App Store.

For an app developer, after you have done building your app, you then have to wait for Apple’s final thumbs up/down on whether your app will be accepted for distribution. While some checks and balances are necessary for various reasons (quality assurance, no malware apps, etc.) – this current process is one big black box and the trouble is that if you were a real corporation who had to justify engineering resources to allocate, complete with revenue projection plans, you have this one step where it looks like it’s a dealbreaker: the review process.

The trouble is, you don’t know before hand if Apple would say “hell no” to distributing your app after you have already spent the time/money/effort toiling away learning the platform, and then painstakingly building an app. Your resources spent would be effectively be written off as a sunk lost, if they just rejected the app. This is arbitrary outcome is hard to accept, if you’re the I-allocate-my-engineering-resources-wisely-with-planning kind. If you’re a {one, two, three}-man “side project” startup guy app developer, then whatever .. because you’ll just likely chalk it up to fun. But if you’re doing this solely to put food on the table, this process sucks.

One developer over lunch mentioned how his app was submitted, and Apple did not deliver a decision within the time they said they would (IIRC, 90 days), and told him to resubmit (essentially beginning the whole submission process from beginning again). He did call once in a while to check the status, and he said the operator’s sole job was to basically just remind callers that the 90 days have not been reached, and they should just wait by the mailbox for an answer.

Fragmentation is veeeery minimal in the iPhone

Minimal, yes, not zero. Why? Because the older iPhone iPod Touch does not have a camera. So if you’re developing an app using a camera, you had to include in your code an “if no camera, do this, else do that” statement. Think about the Android. It’s made to run on a bazillion type of different hardware from different manufacturers. If you were developing an app using the a camera, you have to do a “if no camera, break, if else, camera supports X resolution, do this, else if, camera has this special feature, do this, else … ” nesting an unnecessarily long if/else conditional (or a conditional equivalent type check).

The art of symbiotic co-creation

Back “in the day”, one has to negotiate with carriers and stuff (no one man dev shop is going to do that) – clearly the barrier-to-entry has been lowered significantly for mobile app developers. Also, Apple takes care of billing, local taxation stuff (recall that the iPhone is distributed globally in 50-60 some countries), and the hosting of your app. I think the 30% cut is reasonable, as they are creating real value for mobile developers.

It’s really nice how Apple has removed a lot of friction in developing a mobile app. The success of the iPhone hinges just as much on the app developers as do the success of the mobile developers, on the success of the iPhone. The more attractive applications exist out there, the more that would drive iPhone sales globally, further strengthening the buyer-seller network-effect (like eBay, they are un-toppable at this point). As an app developer, you’d want to develop for the platform with the widest audience possible.

Anyone can engineer an app for any niche they choose, so even obscure verticals may have their needs met. Apple knows there’s no way it can possibly meet *everyones* app tastes, so it’s smart to just farm out that piece to the free capitalistic market.

On the flip side, not providing an open market for developers would mean not being able to feasibly meet a certain need by a certain category of consumers (some will be left out, by definition!), and those folks would be ripe for poaching by iPhone-competitors. Thus, AAPL is really covering themselves from a potential attack from the low-end of the market there (which if were to occur, would force Apple to keep moving higher in the market – classic b-school case study stuff). This reminds me of an article on innovation by McKinsey Quarterly that I had just previous blogged about (good read about innovation, do check it out. Warning: soul-sucking registration required).

In all, this was a nice event to get to know other iPhone devs around the Socal area (one guy actually flew in from Phoenix!). I learned a lot of best practices type stuff, e.g. excessive and unnecessary polling of the GPS quickly drains the battery life, and most apps don’t need that kind of geo-location precision (so don’t be a hog!)

Hooking up an iPhone to a Macbook for real-time live debugging:

photo.jpg
 

Real-time performance benchmark stats:

photo.jpg
 

Hey, does that spell an “A” for .. Aquaduct?

photo.jpg