How to measure the size of a Ruby object? [closed] - ruby

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm having Memcache problems and I was wondering what is the best way to know how big the objects I create are.
The only solution I have is to put them into Memcache which display their size in bytes (by the way, can I customize Memcache's output? I want readable kilobytes…).
Thank you,
Kevin

The excellent Eigenclass blog had an interesting article on that once:
http://web.archive.org/web/20120126022146/http://eigenclass.org/R2/writings/object-size-ruby-ocaml
There also was a good discussion on ruby-talk, which led to some code by Robert Klemme (Ruby Best Practices):
http://www.ruby-forum.com/topic/156648
http://www.pastie.org/217131
Plugging the values from the first article into the script might get you started and is probably quite educational.
You could also check out memprof, though it's more about object references and finding memory leaks than actual sizes:
http://github.com/ice799/memprof

Related

Is it necessary to memorize the codes of data structures? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
Is it necessary to memorize the code of data structures like linked lists, dynamic arrays , circular linked list, queues , stacks , Graphs etc. Or just the basic knowledge of code is enough ? What kind of questions can be asked in a job interview regarding data structures ?
I don't know what your (future) employer may ask, but generally, I'd say no. You have to know how they work and what they're used for, expecially which data structure serves which purpose with its advantages/disadvantages. If you know that, you'll be able to write the code of such a structure without having it memorized - because you know how it will work.

Algorithm Visualization [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I wonder how it is possible to make a visual presentation of algorithm.
I found a very good visualization in Wikipedia like following:
If you know how to make a similar presentation, please let me know.
There are lots of libraries in various languages that can be used to visualize whatever you want, but according to this page:
http://en.wikipedia.org/wiki/File:Sorting_quicksort_anim.gif
The picture you're looking at was:
Created with: Ruby 1.8.4, RMagick.
Just for reference.

Algorithm reference [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
This is a trivial question - but something I always miss in the day-to-day programming.
Is there a gook lookup reference available for the common algorithms that we usually face in our everyday programming - sorting,sequences,graphs.
The emphasis is more on the applicability and pseudocode ,rather than the mathematical proofs(which I find is what books tend to stress on).
The idea is to keep a ready reference,as and when we need to resort to one of these algorithms into our respective development project and languages.
Dictionary of Algorithms and Data Structures
How about this?
List of algorithms#Wikipedia

How does the algorithm for the "report abuse" feature on a website work? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I was just wondering- is there an automated way that the "report abuse" (for profane or inappropriate posts) feature works for a large website like, say, Amazon? Is it just a simple game of numbers (e.g. 100 ppl report the link so it should be taken down) or something more sophisticated?
It is a link on a website that the website-owner implemented? I don't think there is a some sort of top-down regulated method of implementing this, everyone does it's own thing. Some will be 'just simple numbers', some will be more sophisticated.
SO does both I guess: the more flags, the more a problem (spam for instance) gets attention of people who can lock, and flags of some users way heavier then others...

diplomacy game judge algorithm [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am writing a server for playing the great diplomacy game online. Does anyone know an algorithm for the judge, that will calculate all moves/supports/convoys on the map at the end at each round?
For implementing the protocol I use twisted, for db-access django
Yes. DPjudge Adjudication Algorithm. Also see the DPJudge FAQ answer to the question about convoy paradoxes.
A check the njudge page that links to source code.
You might also want to look into the DAIDE project. They have a full comm protocol for create dip bot players against special servers. It's not open source (unfortunately) but there is a small community who use it to play real-time Dip games when 7 humans aren't available to play.

Resources