Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I'm at the point in learning Ruby where I'd like to look at some small-ish libraries' source code to see how they were built. I do not know what is considered a small library but was hoping SO could recommend some easy-to-understand libraries to study.
So if anyone knows a very tiny library or two that's a good example for novice Rubyists to study, please recommend!
I wanted to use Manveru's Innate lib because it tries to stay under 2000 LOC but I'm not yet familiar with the Ruby shorthand that is used so much within it.
Maybe some ~100 - ~500 LOC libs would be better for me? Thank you.
Ryan "ZenSpider" Davis's stuff is always interesting. It is however, not entirely suited for beginners. On the one hand, Ryan is absolutely fanatical about keeping things, simple, short and clean, which helps understandability quite a bit. On the other hand, he does use pretty much all of Ruby's power to achieve that.
One of the most amazing examples of his work, is MiniTest, the new testing framework which replaces Test::Unit in the Ruby 1.9 standard library. It contains a full xUnit style testing framework in 419 lines, an RSpec style BDD framework in 87 lines and a full mocking framework in a whopping 28 lines.
But, for example, the way that the BDD framework is so small, is that it uses reflective metaprogramming to dynamically loop over the assertion methods from the testing framework and rename them to BDD style must_ methods.
Another nice example is also a BDD framework by Christian Neukirchen: Bacon has 291 lines. Also check out his other stuff, for example his mocking framework in 131 lines, forum software in 488 lines and blog engine in 146 lines.
Last but not least, there is Gregory Brown's Prawn PDF Generation library. The interesting thing about Prawn is actually that it was deliberately written not only as a PDF Generation library but also as an example of well-written, well-designed Ruby code. Again, his other stuff is also interesting, like his blogging engine in 184 lines.
Speaking of Greg Brown and well-written code: Greg is the author of the book Ruby Best Practices, which uses real-life code examples from real-life Ruby projects to show what good, well-written, well-designed Ruby code looks like. (Plus, it also has a chapter called Ruby Worst Practices with anti-examples.) And, you don't even have to buy the book (although you really should), because all the code samples are on GitHub!
Some picks from github.com:
http://github.com/mislav/anemone (web spidering)
http://github.com/adamwiggins/rest-client/ (rest client...)
http://github.com/mojombo/chronic/ (natural language date parser)
You could check out Github. There are many Ruby projects from "very small" up to "way too much".
sinatra is an about 1.5K library is quite readable
the first version of rake had 78 lines of code, according to the author - maybe there is some older version around ..
much more on github.com ...
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
Is there something that can render Lilypond content to an image, such as mathjax?
Also, in my mind it would be nice to open a Stack Exchange forum about music. Such a thing would bring nice functionality to it, like LaTeX in http://math.stackexchange.com and so on.
Why Lilypond and what else is there?
Musically educated people hate ABC notation, but apparently it is ideal for forums just as TeX for math fomulas (e.g. via MathJax). Lilypond is very advanced in its integration (TeX, HTML) and platform support (Windows, Linux, Mac). It is also recommended by pedants who are crazy about producing beautiful note sheets (see http://lilypond.org/web/switch/advantages).
Here is a nice review of note editors, so Lilypond is not limited to TeX integration only - it also produces nice .PS and .SVG files.
Vexflow is a nice javascript engine based on Raphael for programmatic drawing of music notation, but it is really for programmers. It has also a web-based SaaS http://static.vexflow.com/ as described by the 0xfe blog.
Other javascript rendering libraries supporting ABC notation are abcjs and abcnode. IMO abcjs is the closest to MathJax in the sense of HTML5 js rendering.
MusicXML implements a non-ABC approach. This XML notation has become really well-supported since 2012, but essentially it is very cumbersome (just like MathML vs. TeX). There are also a number of JS renderers supporting MusicXML such as score-library.
Is there a stack exchange forum with music typesetting?
It seems there is proposal for typesetting, but it has been proposed to merge all computer music notation related questions into https://music.stackexchange.com/
Coupling with playing music
http://0xfe.blogspot.ch/2010/05/music-notation-with-html5-canvas.html
This is another interesting task, i.e. to render the notation into MIDI or HTML5 audio element, but it is a topic for a different question.
There is a WordPress plugin called ScoreRender. Also there are several cloud services like LilyBin or WebLily but it is not really possible to embed their outputs in web pages.
There is an Area51 proposal for Music Typesetting (it is proposed to be LilyPond-specific but despite typesetting music with nothing but LilyPond for years myself, I suggest it being more generic). If you like the idea, follow it and spread the word!
Closest thing that I can think of is Vexflow which is a Javascript/HTML5 layout engine. It won't render Lilypond notation files directly (since Lilypond files are basically Scheme macros, it's difficult to get anything but Scheme to parse more complex Lilypond). If you absolutely need Lilypond parsed, you could hack Abjad, a Python package that can parse Lilypond, and maybe link it up with the Vexflow outputting mechanisms of my Python package music21. But you'd probably be better off making a pure Javascript converter to the Vexflow intermediate representation. It's hard stuff, but know that others are working on such things, so you're not alone.
I have been C/C++/VBNET programmer for a long time. Now Ruby advanced concept is attracting me. So I decided to learn how to use it.But the "Behavior" of Ruby used to confused me. I usually feel like can't completely control my Ruby program.
Can you help me get clearly about this ?
(Maybe some of your favorite guide about "Ideas" and "Styles" in Ruby may help >:D< . Thank)
Ruby is quite an unusual programming language if you are more used to static/declarative style languages like C/C++.
I suspect it's the highly dynamic nature of the language which is causing you a problem, it can be difficult to get your head around this when you encounter it for the first time after having used only the more static languages. Ideas like Duck Typing can seem weird if you are used to declaring variables as strict types before use.
I would thoroughly recommend working your way through one of the excellent books about ruby that are out there. Don't just mess around writing code without really understanding the concepts.
Personally I really liked "The Ruby Programming Language" from O'Reilly, but I have experiance of a lot of different languages so I'm used to some of the more dynamic features in Ruby.
However you may prefer to start with something less terse such as Dave Thomas' "Programming Ruby" (make sure you get the 1.9 version).
Work through one of these books, do the examples, play around with the code. That way you will get a thorough understanding of the language.
Best of luck. Once you get your head around it, Ruby can be a very powerful language.
I think that the book Design Patterns in Ruby might help you. The first chapter describes the syntax of Ruby (which I guess that you won't need), but the rest of the book goes through the classic design patterns and shows you a Ruby way of approaching them. It's very clearly written and I learned a lot about Ruby idioms from it.
If you can talk to a Rubyist then that will probably help a lot - from experience, a code review or pairing session with someone else can get you over mental blocks better than anything else. If you don't know anyone, try writing some code then post a link to it to the Ruby Talk mailing list with questions. This is a very friendly community, and people are happy to help.
I recommend reading Why's Poignant Guide to Ruby. It will open your mind to the wonders of working in a dynamic language. Or it will piss you off with its cartoons of talking foxes. Either way it will change your thinking about Ruby :)
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 3 years ago.
Improve this question
If you are given a large n-tier project (.NET) with 15,000 lines of code written in "Spanish" (variables, tables, classes names etc) that requires feature addition and bug fixing, what would be your strategy to work on it?
Converting the whole project to English(Google Translation or other tools) names does not seem to be a good options as it will be time consuming
Hire a developer who knows "Spanish" or a translator
EDIT: The developers who wrote the original software does not understand English so they are not useful in this case.
Attempt to work on it as it is without translating anything. If it doesn't work, start translating it on-demand, only pieces that are relevant to you.
A dictionary can get you quite far already. You can translate code elements on your own. Naturally, don't add any more pieces to the puzzle. What you add should be in English.
I would also notify the customer that due to the code being written against common sense and best practices in non-English (and even unfamiliar to you language) there will be a delivery delay. Blame on the original creator of the novel.
Unless this is The Project From Hell, there should be far fewer than 15000 variables and methods in your code. My on-the-cheap suggestion would be for you to extract a cross-reference list of variable names as found in your program, hire a quick cheap Spanophone to translate those names for you, and then keep the translation list handy as you and your teammates code.
It's handy to have an idea of what is meant by a variable name, but it's not essential. I spent 20 years writing programs with only 4 significant characters in the variable name.
It's subjective, but my personal opinion is Option B) Hire a developer who can speak spanish - primarily because all the commenting will likely to be in spanish and if the commenting has been done well - it will have valuable information within that should not be ignored / lost.
A translator might not be able to understand the terms within the comments / code and a translation by a non programmer could go bad.
Best option would be to get in touch with the guys who wrote the darn thing...if possible at all. Second best, a developer who knows Spanish.
Translate your classes first. Then you should be able to keep track of instances by their type.
Sorry mostly questions.....
Is the customer a Spanish speaker? If so the software should be written by a Spanish programmer. As the cost of communicating with the customer is a lot less if the programmer understands the customer.
If the customers is not Spanish, why was a Spanish programmer used at all?
Was the Spanish programmer chosen to save money?
If so, is the software worth keeping at all?
How can you tell how good the code is if you can’t read Spanish?
I think the translation should be done as needed on demand, e.g
All new code should be in “English”.
All methods that are changed should be in “English”
All class/methods the new code uses should have English names and summary comments.
The names and comments on all unit tests for class/methods with English names should be in English
Missing unit tests should be written for any class/method when it is not clear what the spec is. (So as to check the translation of the comments into English.)
I think a willing English programmer will be able to use Google translate to do the above, however as with any new source code base, the programme will have to spend a long timer really understanding what each class/method does before using it.
An English programmer that knows some Spanish would be able to do it quicker. However don’t use a Spanish programmer, as you always want a translator translating into their native language.
First step, and this is true when you inherit a legacy code base whether it's in your native tongue or not, is to set up regression tests based on "known good" output, and begin writing more tests as you go, for the changes you make.
Quite possibly, given the relatively small size of the code base, you will fairly shortly start to understand what various routines are doing, and may be capable of beginning the translation effort yourself, maybe supplemented by automated translation.
This assumes you understand the problem domain, and that the original code was written professionally.. although if it were, you'd already have tests, wouldn't you? You don't mention whether that's the case.
Doing anything here without regression tests is foolhardy. Doing it with tests, you may find the whole task relatively manageable and don't need a serious translation effort. Definitely respect the other suggestions to do this incrementally too.
I can get all of methods, fields, annotations and etc. with reflection methods and etc. to export excel or etc. Then I can send this excel file to spanish translator. After translated, i can convert all of project codes by reference which is translated excel file by text processor applications (find / change etc.)
I need a good reference for how to use standard Libraries in Ruby. Current libraries do not describe or give examples like say Java's. Yet this is where examples are much more needed (in Ruby), because I am not familiar with what the called method will yield! I am left with having to look at the source files every time, which seems inefficient. What is a good standard library reference... or am I just not understanding blocks yet?
I find myself bouncing around between the ruby core API on ruby-doc.org, googling for answers on random blogs, and spending time testing ideas in the interactive interpreter (irb). I haven't seen any other core reference documentation that I liked, but I do have a copy of The Ruby Way and its pretty decent.
Betweeen these four sources I can almost always find out how to solve the problem I'm working on.
Best of luck - ruby is fun, frustrating, and powerful.
There is the Ruby Standard Library documentation and sites like apidock. The Pickaxe book has a great reference towards the end. There's even a free version online, but it's quite out of date; to find the reference there, click Standard Library in the top-left frame.
Try GotAPI You'll be able to find the Ruby standard documentation and a whole lot of api docs there
Understanding blocks is pretty important, especially if you want to understand the Enumerable module. ruby-doc.org is usually all I need, but if I need a little more explanation I grab the PickAxe. You need the PickAxe, no question.
I am sorry , but again, i have to recommend ruby cookbook. (Already two times today)
What are coding conventions and guidelines you suggest for writing Bison (.y) and flex (.lex) files?
Please address the length of the code sections and their style.
Thanks,
Asaf
P.S.,
There's an old thread about it here, but I'm looking for a more detailed answer (and to have it on SO!).
For questions like this in general I would typically see what other people have done. Good resources for this are Google Code Search and Koders. Both support searching by a specific programming language; however it appears that only Google has lex as a listed language.
Other than that, I generally try to keep to either 79 or 96 columns in source code, to make sure I can view at least 2 windows-worth of code side by side.