ruby

Does Python do variable interpolation similar to "string #{var}" in Ruby?

Does Python do variable interpolation similar to "string #{var}" in Ruby? Question: In Python, it is tedious to write: print “foo is” + bar + ‘.’ Can I do something like this in Python? print “foo is #{bar}.” Asked By: mko || Source Answers: Yes, absolutely. Python, in my opinion, has great support for string …

Total answers: 9

Interpreting a benchmark in C, Clojure, Python, Ruby, Scala and others

Interpreting a benchmark in C, Clojure, Python, Ruby, Scala and others Question: Disclaimer I know that artificial benchmarks are evil. They can show results only for very specific narrow situation. I don’t assume that one language is better than the other because of the some stupid bench. However I wonder why results is so different. …

Total answers: 13

Sublime Text 2 console input

Sublime Text 2 console input Question: I use Sublime Text 2 but it won’t let me enter any value when my code asks for user input. (In other words: input() in Python and gets in Ruby fail to correctly prompt me for input). Python throws an EOFError error (what you get when user doesn’t enter …

Total answers: 2

How to open (read-write) or create a file with truncation allowed?

How to open (read-write) or create a file with truncation allowed? Question: I want to: open a file in read-write mode if it exists; create it if it doesn’t exist; be able to truncate it anytime-anywhere. EDIT: with truncate I mean write until a position and discard the remaining part of the file, if present …

Total answers: 4

twitter/social data mining – Ruby or Django?

twitter/social data mining – Ruby or Django? Question: I am a decent c/c++ programmer, but don’t know much about web dev. I am interested in twitter/social data mining. So which is a better tool – RoR or Django? I am on level zero in both ruby and python. But python’s syntax seemed easier to understand/learn. …

Total answers: 3

What OCR options exist beyond Tesseract?

What OCR options exist beyond Tesseract? Question: I’ve used Tesseract a bit and it’s results leave much to be desired. I’m currently detecting very small images (35×15, without border, but have tried adding one with imagemagick with no ocr advantage); they range from 2 chars to 5 and are a pretty reliable font, however the …

Total answers: 2

Regexp finding longest common prefix of two strings

Regexp finding longest common prefix of two strings Question: Is there a regexp which would find longest common prefix of two strings? And if this is not solvable by one regexp, what would be the most elegant piece of code or oneliner using regexp (perl, ruby, python, anything). PS: I can do this easily programatically, …

Total answers: 15

python: what's the difference between pythonbrew and virtualenv?

python: what's the difference between pythonbrew and virtualenv? Question: I am new to python and I am planning to learn django. I had a bit of experience with ruby (not rails) and I am familiar with RVM however I don’t understand the difference between pythonbrew and virtualenv. I know pythonbrew is a mimic of RVM …

Total answers: 5

Can Mustache Templates do template extension?

Can Mustache Templates do template extension? Question: I’m new to Mustache. Many templating languages (e.g., Django / Jinja) will let you extend a “parent” template like so… base.html <html><head></head> <body> {% block content %}{% endblock %} </body> </html> frontpage.html {% extends “base.html” %} {% block content %}<h1>Foobar!</h1>{% endblock %} rendered frontpage.html <html><head></head> <body> <h1>Foobar!</h1> </body> …

Total answers: 9

Should one minify server code when it's in production?

Should one minify server code when it's in production? Question: When it comes to the frontend code you always minify it (remove white spaces, comments etc) in production. Should one do the same with server code? I usually have a lot of comments in my server files. But I have never heard about people doing …

Total answers: 4