[#408616] How to get the User_logged in windows with Sinatra — Mario Ruiz <lists@...>
I need to know the user that is accessing the intranet i created with
[#408620] including FileUtils::Verbose crashes Marshal.dump — Bryan Lockwood <lockwood.bryan@...>
This is a bug I ran into today. I'm not sure who's responsible for =
[#408622] Error with JSON#parse — Love U Ruby <lists@...>
require 'json'
The same with `YAML#load`
[#408624] Why the use of a pound (#) sign with Enumerable — Ruby Student <ruby.student@...>
Team,
[#408634] How do I make lots of classes aware of each other? — "Andrew S." <lists@...>
I'm apparently missing something fundamental in my knowledge of classes
You can use send which as you would expect sends messages to an object. You
Thanks.
[#408654] Backtick probleme — xcoder Blue_fox <lists@...>
Hey guys i got a probleme with this code :
[#408662] How can I add minutes,seconds and hours to a DateTime object? — Love U Ruby <lists@...>
require 'date'
[#408668] Implementing sort/sort! — Kyle Hunter <lists@...>
Hello,
On Wed, Jul 3, 2013 at 4:39 AM, Kyle Hunter <lists@ruby-forum.com> wrote:
[#408680] Difference between Kernel#__callee__ and Kernel#__method__ — Love U Ruby <lists@...>
Is there any Difference between Kernel#__callee__
[#408684] rake drake or ? — Marc Weber <marco-oweber@...>
Is there yet another alternative to drake vs rake?
[#408701] Loading csv giving error — Nithi anand <lists@...>
hi guys I am trying to compare some data so I create one file name
[#408712] Ruby web service with REST support — "Shubhada S." <lists@...>
Hi All,
I would suggest you install the Sinatra gem, and read the
On Fri, Jul 5, 2013 at 12:03 PM, Matthew Kerwin <matthew@kerwin.net.au>wrote:
Robert Klemme wrote in post #1114499:
On Mon, Jul 8, 2013 at 7:42 AM, Shubhada S. <lists@ruby-forum.com> wrote:
I am still confused when to use phusion passenger and when to use rails?
[#408713] Ruby link grabber — xcoder Blue_fox <lists@...>
Hey guys i wanted to write a ruby code to grab all links from html code
[#408724] How do I rescue a program exception in an at_exit block? — Josh Cheek <josh.cheek@...>
I was thinking about how bad I am at reading error messages, and realized
On Fri, Jul 5, 2013 at 4:08 PM, Josh Cheek <josh.cheek@gmail.com> wrote:
[#408734] what is Vector#map2 ? — Love U Ruby <lists@...>
Hi,
[#408745] How can I make ruby read a string of characters per three characters? — Sam Thorpe <lists@...>
I want to input a string of characters, and have it be read by every
[#408757] Parslet: subtrees merged without warning? — Axel Friedrich <lists@...>
Hi,
> Or, in which cases results are lost/merged silently?
Hallo Kaspar,
> Could I easily add some extension code to get a message in this case,
> Probably
> I think, I haven't understood the "philosophy" of Parslet yet. There are
[#408778] Price lookup from sketchup to csv — Nithi anand <lists@...>
I need to perform a lookup on a CSV file.
[#408787] execute_script - selenium-webdriver — Love U Ruby <lists@...>
HTML:
[#408788] A very half-baked idea: setting local variables — Hal Fulton <rubyhacker@...>
I'm sure this nonexistent feature is not in great demand, but there have
[#408795] Well-Grounded Rubyist -- Person class implementation in chapter 4 question — Arslan Farooq <lists@...>
Hi,
[#408801] Help me to understand a Ruby file — Salvo Foru <lists@...>
Hello everyone, I'm a new to the site and I'm just starting to learn
[#408808] how to compile .so on windows — Dimmak SDI <lists@...>
Plese help me!
[#408812] create variables depending on counter — stefan heinrich <lists@...>
Hi community,
Hi Robert and Marcus,
Ok i got it. Thank you so much.
[#408819] search a string with ruby then read what comes after the string in the same line — dJD col <lists@...>
I am trying to look for a a given string in a text and once i find the
[#408842] Why can't I just subtract in a loop without restating the variable? — Wayne Brisette <wbrisett@...>
I have some code that uses a counter. In certain circumstances, I have to s=
[#408854] execute commands within SMTP email code: send content in variables and not actual variables — dJD col <lists@...>
I am trying to send an email using the code below. I am able to send the
I was able to print the values of the variables t and s
[#408894] phusion passenger + uninitialised constant+ NameError — "Shubhada S." <lists@...>
Hi,
[#408906] how to upgrade to the latest version of ruby ? — Love U Ruby <lists@...>
I am using RVM with Ubuntu13.04. Installed version of Ruby is :
[#408911] Module Confusion — "Michael W." <lists@...>
The below code works. Question though. How does add_to_stack acess the
[#408925] closing a socket while another thread is in an IO.select() call on it — Graham Menhennitt <graham@...>
Hello Rubyists,
[#408927] Ticket for eurucamp 2013 — Jens Hausherr <jabbrwcky@...>
Hi Rubyists,
[#408937] Get part of matrix — "Diego N." <lists@...>
Hi!
[#408944] Kernel.caller Performance Across Different Ruby Versions — Peter Giacomo Lombardo <lists@...>
I wrote a quick Ruby script to benchmark Kernel.caller using ruby-prof.
[#408955] Iteration anomalu — "Andrew D." <lists@...>
Surely this is a FAQ but I can't figure out how I would search for an
[#408963] Allowing a character through Addressable::URI unescaped — Joel Pearson <lists@...>
I have some code which used to work a few months ago but appears to have
[#408970] Install RVM on Solaris — "Chamila W." <lists@...>
I tried installing RVM on Solaris using command
[#408976] TryRuby Popup Problems — "Jayant S." <lists@...>
Hello there, my name is Jay. I wanted to introduce myself because I
[#408990] Hash#update - need tweaks — Love U Ruby <lists@...>
I am in a situation,where I have to the below kind of operations.
[#408994] Ruby Debugger — Alphonse 23 <lists@...>
Could anybody recommend me a good Ruby Debugger. Preferably one that
[#408995] ActiveSupport undercore behaviour — Serguei Cambour <lists@...>
I tried to use ActiveSupport 'underscore' method to convert some
tamouse m. wrote in post #1116149:
I am on the phone, but my guess is that the quotes and backslashes are
I changed as follows and it works for the first nest level for the
On Sun, Jul 21, 2013 at 7:03 AM, Serguei Cambour <lists@ruby-forum.com>wrote:
[#409008] Unsubscribe? — James Murphy <jamurphy84@...>
Hi all,
[#409031] tap { break } idiom deserves its own Kernel method? — Andy Lowry <lists@...>
I use this idiom from time to time:
On Mon, Jul 22, 2013 at 7:37 PM, Andy Lowry <lists@ruby-forum.com> wrote:
On Mon, Jul 22, 2013 at 10:37 AM, Andy Lowry <lists@ruby-forum.com> wrote:
I just used the pattern again, and this time it's a much simpler example
[#409046] Question on while loop to script — "Talal B." <lists@...>
Hi guys,
[#409047] using qsub from Ruby script produces "command not found" — Thomas Luedeke <lists@...>
I am running a script that runs multiple cases on an engineering code.
[#409052] How can we create instance method and class methods at runtime in ruby? — Love U Ruby <lists@...>
How can we create instance method and class methods at runtime in ruby?
Sorry for creating the confusions:-
[#409064] how to create structure like bellow — Expert Alart <lists@...>
Hi...
[#409072] Link To Masses Of External Data In Openoffice? — "Austin J." <lists@...>
This is what I want to do.
tamouse m. wrote in post #1116598:
tamouse m. wrote in post #1116750:
tamouse m. wrote in post #1116838:
On Sat, Jul 27, 2013 at 5:55 AM, Austin J. <lists@ruby-forum.com> wrote:
"Jes=C3=BAs Gabriel y Gal=C3=A1n" <jgabrielygalan@gmail.com> wrote in pos=
Am 27.07.2013 21:04, schrieb Austin J.:
unknown wrote in post #1116906:
Am 27.07.2013 22:12, schrieb Austin J.:
unknown wrote in post #1116910:
[#409073] class <=> module — Bráulio Bhavamitra <lists@...>
Hello all,
Am 24.07.2013 01:04, schrieb Br叩ulio Bhavamitra:
On Wed, Jul 24, 2013 at 1:10 AM, <sto.mar@web.de> wrote:
Am 24.07.2013 14:35, schrieb Josh Cheek:
[#409104] Ruby newbie question on Methods (NoMethoderror) — "Crispian A." <lists@...>
I have recently started learning ruby and so I am writing a small little
Am 25.07.2013 12:22, schrieb Crispian A.:
unknown wrote in post #1116651:
[#409119] replace words using gsub — noterrain mee <lists@...>
New to ruby! Body is a string, i am using the code directly below. I am
The k is an iterator. Let's use another example here to demonstrate:
[#409134] Learning how to create and save .rbs — Joseph Bershas <lists@...>
So I am trying to create and run an .rb, a basic stepping stone.
[#409139] How to install Ruby 2.0.0 locally - stuck — Thomas Luedeke <lists@...>
I previously installed Ruby 1.8.7 locally on my HP-UX Unix system,
[#409152] Calculate input - numbers — Marc Heiler <lists@...>
Hi
[#409161] Difference between Kernel#caller and Kernel#caller_locations — Love U Ruby <lists@...>
Hi,
[#409169] Love U Ruby — Dave Aronson <rubytalk2dave@...>
On Sat, Jul 27, 2013 at 5:13 PM, Ryan Davis <ryand-ruby@zenspider.com>
On Sun, Jul 28, 2013 at 2:26 AM, Dave Aronson <rubytalk2dave@davearonson.com
[#409170] Working through Ch.10 for learning to program 2.0 (Chris Pine) — JD JD <lists@...>
So, I have been working through this book, and have been doing ok up
I tried this and came up with a one-liner that seems to do it. It sorts the
Am 29.07.2013 16:43, schrieb Harry Kakueki:
On Tue, Jul 30, 2013 at 2:34 AM, <sto.mar@web.de> wrote:
[#409207] Losing values upon converting object to Array — Rochit Sen <lists@...>
Hi All,
[#409221] How to check an input IS an integer ? — Captain Ishido <ishido7@...>
Hi everyone !
[#409225] Question about arrays/hash — Jenn Fo <lists@...>
Hi All:
[#409234] Parsing Data from Row using Regexp — Joel Dezenzio <lists@...>
Hi All,
[#409266] Is there a good port of Ruby for Solaris 10? — Rick Carrick <lists@...>
Does anyone know of a place to DL Ruby for Solaris 10?
[#409267] Method tracker - Need assistance — Kenny Meyer <kenny@...>
I would like to write an includable method tracker, which logs about added
Re: Working through Ch.10 for learning to program 2.0 (Chris Pine)
Am 31.07.2013 05:02, schrieb JD JD:
> So, I am just taking a detour away from the book for a bit and trying
> something else and will go back to it. I glanced at the solution for
> one you all wrote out. The book didn't really go over a lot of what you
> all are doing.
Please do not take these one-liners as examples on how you should
write your code. I consider them more as riddles or katas than
as good solutions for a beginning programmer (or maybe even for
an expert programmer). They are cryptic and not too easy to
understand, and good "real" code should be neither.
Considering your pseudo code (I do not know how your real code looks
like, but just to make sure): beware of using one letter variable
names! The additional time for typing is only spent once, but
cryptic code causes extra time spent every time you need to re-read
through it when searching for bugs, etc.
> Marcus, it sounds like you read the same book. Could you maybe give me
> a hint based off what I should know from the book? It looks like many
> people here are using things that weren't taught in the book. Not
> saying they are wrong, but it not something I probably know from what I
> read in the book. I might be wrong though. I'm still learning either
> way.
Matthew gave very good advice. Think in small steps, write them down,
break them up even more. I would like to add that IMO the selection
sort algorithm I described earlier is even a bit simpler than
insertion sort (of course, it's partially a matter of taste).
The biggest subtask there is to find the smallest element of the
array and its index.
I'll give an example implementation below, you can ignore it for
the time being, or have a peak and then try on your own, whatever.
It uses only the most basic array operations (like accessing,
pushing or deleting elements).
There is another versions that uses Array#min (which could be
considered cheating, but it's an exercise and you make the rules).
It might help further in understanding how the algorithm works.
BTW. Don't be discouraged by chapter 10. Not without reason
Chris Pine calls it a "rite of passage". And: you know that
the appendix has suggestions for possible solutions, often
more than one?
Regards,
Marcus
Without Array#min (the biggest block is only for finding
of the smallest value):
unsorted = [8, 4, 0, 9, 2, 6, 5, 9, 2, 7]
sorted = []
while unsorted.size > 0 do # more rubyish: until unsorted.empty? do
smallest = unsorted[0]
index_of_smallest = 0
1.upto(unsorted.size - 1) do |index| # more rubyish: each_with_index
if unsorted[index] < smallest
smallest = unsorted[index]
index_of_smallest = index
end
end
sorted << smallest
unsorted.delete_at(index_of_smallest)
end
p sorted # => [0, 2, 2, 4, 5, 6, 7, 8, 9, 9]
The same using Array#min:
unsorted = [8, 4, 0, 9, 2, 6, 5, 9, 2, 7]
sorted = []
while unsorted.size > 0 do
smallest = unsorted.min
index_of_smallest = unsorted.index(smallest)
sorted << smallest
unsorted.delete_at(index_of_smallest)
end
p sorted
--
GitHub: https://github.com/stomar/
PGP: 0x6B3A101A