Skip to content

Instantly share code, notes, and snippets.

@Overbryd
Created June 16, 2011 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Overbryd/1029706 to your computer and use it in GitHub Desktop.
Save Overbryd/1029706 to your computer and use it in GitHub Desktop.
Code Challenge #2

Code Challenge #2

A new challenge is on. This time @rtacconi had the idea:

"Idea:

Create a simple persistent key/value storage capable of SET, GET and DELETE actions.
It is forbidden to use Redis, MongoDB, or other ready made key/value solutions,
only storage to file, databases, serialization... are allowed

The UI should be the CLI, not web this time... just for a change."

To join the battle do the following:

  1. Check the briefing

  2. Accept the challenge by commenting on this gist with an upfront estimate.

  3. When working on the implementation always have an time tracker running. This is for your your own good, as the better you can estimate yourself the better it is. It only works if your honest with yourself and track the exact working time from start to finish.

  4. When you're done, send an link to the publicly available project of yours. You don't have to open the source before the deadline ends.

  5. Open source everything and look at other solutions, compare, enjoy!

The Deadline for submissions is the 23rd of July

If you have any questions, don't hesitate to ask @Overbryd. I may moderate comments on this gist so that it stays readable.

I wish you a lot of fun :)

The goal of these challenges

It is not about who's the fastest scripter on the internet. It is more about code quality, choice of weapons and estimation skills. I understand these challenges as a fun way to improving my self estimation skills.

Previous challenge

@radiospiel
Copy link

I'm dropping out, because what I would do is just take one of my gems ( https://github.com/radiospiel/cached ), add another command line script to it, which just uses the built in SQL stuff, and Voilá! That wouldn't seem fair... Well, in fact I did so; this is the commit radiospiel/cached@61ca3cc . I might add another JS based version; there is still a bit until the deadline :)

Maybe a few more words, because there is a bit coolness in it: it is built in ruby and uses the sqlite3 gem. It doesn't waste your CPU cycles on rubygems though, loads the gem directly from the gem dir (see fast_gem.rb).

I would like to hear your comments on all of that. (And use the cached gem, it is cool :))

@Overbryd
Copy link
Author

I'm in and I think I'll finish within 2 hours.

@radiospiel: I don't think that your reuse of code is unfair. Probably this is just a common path to take :) Luckily you wrote it by yourself.

@rtacconi
Copy link

I also think to finish it in two hours.

@rtacconi
Copy link

@jamesu
Copy link

jamesu commented Jun 17, 2011

Ok i am going to be crazy and do this within 30 minutes. Wish me luck!

@jamesu
Copy link

jamesu commented Jun 17, 2011

Went over my estimate and took 44 minutes, though the core of the app was done within 30.
Spent most of the rest of the time turning it into a gem.

Not sure exactly what you meant by "CLI" so i just made a commandline tool.

https://github.com/jamesu/dumbstore

@rtacconi
Copy link

I mean Command Line Interface. I made it interactive, so you do not have to run the command every time. I used YAML, you used JSON. Anyway it looks good to me and you made it in 44! Well done.

@radiospiel
Copy link

@jamesu: bonus points for OptionParser usage!

@radiospiel
Copy link

Trying to build a JS version. Starting now... shouldn't take more than 30 mins

@radiospiel
Copy link

yikes, 8 mins overtime, not too bad... Here it is: a JS implementation that stores the data in itself: https://gist.github.com/1031330. Runs on node.js

@Overbryd
Copy link
Author

It took me 1:30 to write the following. Most of the time was spent by writing a sinatra application. After I've written the sinatra app, I realized that the briefing was meant to be a CLI app.
After that I ported my inital sinatra attempt to GLI and tadaa, we have a super dumb K/V store: https://gist.github.com/1031943

Hehe, LOLz about myself not reading the briefing ;)

What do you think about my approach?

@jamesu
Copy link

jamesu commented Jun 17, 2011

I like your usage of the exception handler to create the default database. Though i noticed a slight flaw with the uuid code in the CLI version: if i set a value i won't be able to determine its uuid except by looking though the entire list to see what has been added.

Never heard of GLI before (seems a bit over-abstracted IMO).

Funny how everyone just about came up with the same underlying solution again, just dressed up differently.

@rtacconi
Copy link

I did not know about GLI and UUID, I have to say that GLI permits to write a command line interface in a very clean way. It is interesting to see the JS version, I hope to try it very soon.

@Overbryd
Copy link
Author

@radiospiel, haha that is awesome... Self contained cli key value store xD
I guess I could do that in Ruby as well, but it already looks great in javascript!

@radiospiel
Copy link

@Overbryd I don't know about a ruby version. Js - or at last node.js - has the nice feature to dump a function's source code, a feature that is missing from ruby. I guess one could put the source into a ruby file and eval it then, though

@Overbryd
Copy link
Author

I've updated my keyvalue_cli.rb to store it's data self contained https://gist.github.com/1031943

:)

@jamesu
Copy link

jamesu commented Jun 20, 2011

I think we have a champion of crazyness here ;)

@Overbryd
Copy link
Author

Hm, talking about evaluation. How do you think should we evaluate the Code Challenges?

I thought about setting up a rating system for different topics. But maybe you guys have an easier "Hot or Not" in mind?
I'm willing to setup a website on these code challenges if the interest is there.

Please give me your opinion on this.

@radiospiel
Copy link

@Overbyrd: the keyvalue_cli.rb stuff is pretty cool :) re/a website: hmm, I don't know. I guess our submissions could help others to find some great HOWTO-examples; but this seems to be a larger project then...

@rtacconi
Copy link

rtacconi commented Jun 20, 2011 via email

@Overbryd
Copy link
Author

Thank you for the ideas.

The next challenge is knocking on the door, and we already have some great proposals for the third challenge.
I have set up a poll to see what you would like to implement on the next challenge.

Please vote for the topic of the next round

I really like radiospiel's guess that submissions may help others as HOWTOs. That is also why I think that creating a website would be a good fit. With a website, the submissions may be ordered and people can easily find stuff theyre looking for.
I have not found the time to create on yet, but my head has already started thinking about an elegant solution. I really don't want to bloat this nice little challenge up.
I just want to make it better and better every time :)

Regarding evaluation. It seems that three factors stand out pretty clearly: Estimation accuracy, simpleness and quality of code. It can be done through voting. Currently I'm evaluating voting services. Any ideas? At the moment I find polldaddy.com very appealing.

@jamesu
Copy link

jamesu commented Jun 22, 2011

I think keeping this simple is key. Also keep the challenges simple yet interesting enough so that other people can realistically complete them.

There are two things to evaluate: how well you think you did, and how well everyone else thinks you did.

To me personally this is more about self-estimation and completing an interesting challenge rather than things such as code quality. If anything i'm more interested in code awesomeness. ;)

@radiospiel
Copy link

I would have liked to add a "build a kino.to frontend that is actually usable", but then the police did this already. Not that their use is of any use to me :)

@radiospiel
Copy link

I have a real idea or two: first thing would be a crowdsourced ping service, where users of a website would get a small piece of javascript which gets fetched a URL to ping, ping the url, and report the result back to the server. Could help get you measurements from around the world, even if you don't have users in, say, chile. The other one would be a todo-list (I know, its kind of boring, but yes.)

@Overbryd
Copy link
Author

Overbryd commented Jun 24, 2011 via email

@jamesu
Copy link

jamesu commented Jun 26, 2011

Out of curiosity i decided to see how easy it would be to implement the youtube sync thing. Figured i'd get it done in an hour, ended up taking 9 to get the basic system working.

Most difficult part was getting the websocket code working correctly.

Might iron out the major bugs later and upload it somewhere ;)

@radiospiel
Copy link

@jamesu makes me curios. Especially since I didn't understand the youtube sync idea :) Just show it, man!

@jamesu
Copy link

jamesu commented Jun 26, 2011

@radiospiel basically its just a way for multiple people to watch the same youtube video in sync (a prime example of this being synchtube).

My version so far if you were wondering: http://stuff.cuppadev.co.uk/testtube.jpg

@radiospiel
Copy link

@jamesu: I see. Is this synched only on the start or during watching the video too? (I.e. one person fastforwards the video and it gets fast forwarded for all viewers?)

@jamesu
Copy link

jamesu commented Jun 27, 2011

@radiospiel its basically updated about every 2 seconds, so the video stays in sync between all currently connected clients via the power of websockets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment