« first day (960 days earlier)      last day (2295 days later) » 

12:35 AM
Howdy! I know I'm talking to myself right now, but hopefully, y'all will read this when you get up, a lively discussion will ensue, so that when it is time for me to get up in my timezone, I will have something fun to read :-D
I had this question in my mind for the past several hours that was spawned by this question, although it doesn't really have anything substantial to do with it:
2
Q: Is there a performance difference between `select` and `select!` when called on a Ruby hash?

dsp_099hash = { 'mark' => 1, 'jane' => 1, 'peter' => 35 }.select {|k,v| v > 1} #=> { 'peter' => 35 } What if I have millions of keys - is there a difference between hash = hash.select vs hash.select! ?

 
What's your question?
 
How do you benchmark mutating data structure operations in a statistically significant, sensible, reliable, repeatable manner? We learn that you should run the benchmark many times, throw the first few iterations away until the implementation has warmed up and settled into a steady state, then run a couple of more iterations to get around clock resolution issues, get rid of outliers and so on.
There are even libraries to help us do that automatically like @Marc-Andre's Fruity or Evan's benchmark/ips.
But! It's a mutating operation on a mutable datastructure! We just destroyed it during our first iteration!
We would have to re-create it for every iteration, but then the creation would become part of the benchmark, which is not what we want. How do we get out of that? My only idea was to create enough deep copies of the datastructure beforehand in order to be able to run all iterations on a fresh, but identical, instance. But now we have artificially increased memory pressure. I haven't come up with a sensible idea yet.
 
12:53 AM
@JörgWMittag When I can, I will instrument the operation itself so that it is timed separately from everything else, then run the whole thing--setup and operation--"enough" times, saving the time of each operation. Then setup is not included in the benchmark results.
 
@JörgWMittag I would really like to be that guy but I'm not :P I'm github.com/marcandregirard
 
Haha, well, we all have to start somewhere.
@WayneConrad Yes, something like that. Unfortunately, this mode of operation is not built into any of the existing Ruby benchmarking tools I know of. Maybe it is possible to build something like that using benchmark-ips's concept of custom Suites.
 
1:07 AM
Just checked: no, it's not possible.
 
1:35 AM
@JörgWMittag I ad-hoc tests like that. It doesn't usually take much code to do it.
$time ||= 0; start_time = Time.now; .... do stuff .... ; $time += Time.now - start_time ; p $time. is one stupid way to report cumulative time through the section being benchmarked. This doesn't get you any of the nifty things that benchmark tools do, but sometimes it's enough.
 
1:57 AM
Anyone have any suggestions as to if I should use class << self or a combination of module_function and public (extend self doesn't work because it's for two methods in a larger module)
 
user4710450
2:36 AM
Hi
 
user4710450
I want to work with this gem :
https://github.com/stympy/faker
 
user4710450
Is there anyway possible to call methods generically, not writing all the stuff shown in the examples?
 
Like using function references?
 
user4710450
2:53 AM
@JudahMeek I am newbie, how can I do that?
 
@Ehsan What do you mean by calling methods generically? Do you have an example of how you'd like it to work?
@thesecretmaster I don't know without seeing code.
 
user4710450
No, but I was looking for a way to call all those methods with not writing all of them
 
user4710450
Possibly with send
 
@Ehsan In Ruby, you can certainly discover what methods exist on an object. Is that what you want to do?
 
user4710450
Ah, yes, how!? :)
 
3:07 AM
require "faker"

method_names = Faker::Address.public_methods - Object.methods
method_names.each do |method_name|
  if Faker::Address.method(method_name).arity == 0
    p [method_name, Faker::Address.send(method_name)]
  end
end
# => [:state, "Arkansas"]
# => [:city, "Helgaside"]
# => [:street_name, "Shanna Land"]
# => ...
 
user4710450
@WayneConrad Thank you very much! This is exactly what I was looking for! Thanks for your time
 
#public methods return an object's public methods. We subtract out the methods defined by Object because we don't care about them. Then we find out which ones take no arguments, and call them.
@Ehsan You are welcome. Do you mind saying why you want to do this? I'm curious.
 
user4710450
I am creating a hobby website to generate all fake stuff.
 
Clever! I will bet you are the first to use the faker gem that way.
 
user4710450
So, what is its main use? I guessed many people use it for generating fake stuff
 
3:11 AM
Its main use that I know of is to generate data for tests.
 
user4710450
@WayneConrad Yeah as noted in Michael Hartl's book
 
user4710450
Thank you mate, I may go work on this hobby website,
I bet it will be soon available at : https://fake.heroku.com
 
@Ehsan Good luck!
 
 
3 hours later…
user4710450
6:37 AM
Hi
 
user4710450
What does the parameter to paginate method do?
 
user4710450
In rails console I entered the following :

>> Micropost.paginate(page:nil) == Micropost.paginate(page: 1)
=> true
 
user4710450
Why on the earth page:1 and page:nil should yield the same?
 
user4710450
I am totally confused :|
 
this micropost?
 
user4710450
6:43 AM
Exactly
 
which will_paginate do they use?
 
 
4 hours later…
10:18 AM
> ok; 553 bytes written (11.44% compression ratio)
 
I have no clue what that means but it sounds impressive
 
It's a file that mostly consists of [:pop,[]],
17 hours ago, by Jan Dvorak
My idea of storing the state of my application is to log its RNG seed and the sequence of commands that has been used. The log is expected to be 1 MB uncompressed and highly compressible.
I may have been a bit pessimistic about the log size
 
user4710450
I figured about page: nil and page:1
 
user4710450
They should be the same because we don't have page:0
 
user4710450
One more question :
 
user4710450
10:32 AM
What cloud IDE do you use?
 
user4710450
Recently I can't open c9.io my browser just gets stuck in connection, so please give me the alternatives
 
user4710450
@Nima I guess you had no idea about what you were talking...
 
user4710450
I think the code formating is great
 
user4710450
Writing a code formatter and syntax highlighter is really tricky, which I wanted to add to my website but I gave up soon
 
11:52 AM
Anyone know how to simplify this?
value = value.to_s.downcase
value = case
when value.include?("test")
  0
when value.include?("dev")
  1
when value.include?("prod")
  2
when value.include?("err")
  3
else
  4
end
 
12:09 PM
@Ehsan At the moment I'm trying Visual Code and I used Atom. Not full-fledged IDE like say Eclipse for Java, but they do a good job.
Visual Code has an extension for Ruby and Rubocop which is nice.
 
user4710450
12:31 PM
@thesecretmaster What is this structure!?
 
user4710450
@Marc-Andre I use RubyMine. Perfect for students!
 
Oh my bad I didn't see cloud next to your IDE :P
 
user4710450
@Marc-Andre I meant a cloud ide, mate
 
user4710450
@Marc-Andre Your welcome!
 
Yep I gave you good old IDE alternatives, not a Cloud one!
I can't help you much with that
 
user4710450
12:36 PM
I have seen nitrous.io
 
user4710450
but the free planning is limited to 50 hours monthly
 
user4710450
OMG!
 
user4710450
This song is awesome!
 
user4710450
 
@Ehsan I'm getting numbers from words with a case statement. Rubocop hates me for this.
 
user4710450
12:39 PM
Is this a switch case?
 
user4710450
I think you could possibly store those in a array
 
I wanted to use a hash/array type thing but I couldn't figure out how to get it to work with include?
 
user4710450
 array = %w[test dev prod prod]
 
Oh, and iterate over it
 
user4710450
12:41 PM
You may use a for-loop
 
that makes sense
Thanks @Ehsan
 
user4710450
Is thery anything like for-loop in ruby?
 
user4710450
Coming from Python :|
 
user4710450
# I have seen
3.times do |i|
   puts "Hi"
 end
 
user4710450
But wonder if there is a for - loop available in ruby just like Python...
 
user4710450
12:43 PM
@thesecretmaster Hope succeed :)
 
There is, but why would you do that?
 
user4710450
I want a starting point an end point
 
As in, iterate over a range?
 
If you have something htat include Enumerable you can use each most probably
 
(min..max).each{|i| ...
 
user4710450
12:46 PM
like this :

for ( int i = 10;i < 20; i ++ ) {
System.out.println(i);
}
 
user4710450
What is the equivalent in Ruby?
 
there's also min.upto(max){|i|...
 
user4710450
Thanks, but is there any kind of loop like I the one shown in Java?
 
user4710450
Thanks for the reference :)
 
user4710450
12:49 PM
So the equivalent is :
 
user4710450
for i in 10..20
   puts "Value of local variable is #{i}"
end
 
that works, but really - do each instead
 
user4710450
OK, could you put an example with each? I am completely newbie
 
5 mins ago, by Jan Dvorak
(min..max).each{|i| ...
 
user4710450
Sorry for the typos :(
 
12:52 PM
(10...20).each{|i| puts i.to_s}
 
user4710450
Thanks
 
better yet, puts (10...20).map(&:to_s).join("\n")
 
user4710450
@JanDvorak Hm... a bit hard to understand :|
 
where foo(&:bar) is a shortcut for foo{|i|i.bar}
 
user4710450
Similar to Java references, though
 
12:54 PM
?
 
user4710450
Excuse me , just ignore that
 
user4710450
Jan , is this your profile in UC Davis?
http://biosci3.ucdavis.edu/Faculty/Profile/View/14135
 
user4710450
Is this your facebook profile?
https://www.facebook.com/public/Jan-Dvorak
 
user4710450
1:00 PM
Anyway, do you have any profile on twitter, Linkedin, Instagram and etc. ?
 
I don't use Linkedin, never were to Instagram, and my twitter account only receives very little.
Have you tried making Fizzbuzz in Ruby yet?
 
user4710450
 
Yes
 
user4710450
Not yet, in fact I started learning Rails and yet have no complete understanding of Ruby :(
 
First things first, shall we?
 
1:03 PM
You probably know more rails than me already :/
 
Could you read someone else's Ruby code?
def fizzBuzz i
  (1..i).each do
    puts case
      when i % 15 == 0 then "FizzBuzz"
      when i %  5 == 0 then "Buzz"
      when i %  3 == 0 then "Fizz"
      else i.to_s
    end
  end
end
 
user4710450
@thesecretmaster No, I'm the dumbest Rails developer ever :(
 
user4710450
@JanDvorak Hmmm. It looks interesting
 
You'll quickly learn by looking at the SO front page you are not ;-)
 
user4710450
1:05 PM
@JanDvorak lol
 
user4710450
By the way in what UTC time zone are you living?
 
user4710450
Is it evening/morning/midnight?
 
Actually, my fizzBuzz implementation has a bug. Can you fix it?
 
user4710450
@JanDvorak I suppose it doesn't show a user friendly error message xD
 
It doesn't.
 
user4710450
1:08 PM
so we change else i.to_s to an error message
 
Why would we?
 
user4710450
What kind of error are you talking about?
 
user4710450
Logical/Runtime error?
 
user4710450
I guess it might be related to i
 
Yeah, it doesn't output what it should
 
1:09 PM
Did you run the code ?
 
user4710450
Since if it is negetive we would bump into a problem
 
user4710450
@thesecretmaster How did you run it?
 
@JanDvorak Took me a bit to catch what was going on :P Nice one
 
Copy it into an editor, save it as whatever.rb, go into a command line, cdto the parent directory and run ruby whatever.rb
 
user4710450
It shows nothing
 
1:12 PM
Or you can use IRB too if you have one
 
IRB is a worthy skill
 
user4710450
@Marc-Andre That way I should type all that stuff :|
 
@Ehsan I can copy-paste in mine
 
user4710450
@Marc-Andre This seems more approachable
 
user4710450
Is there any codegolfs written in Ruby?
 
1:17 PM
I'd recommend starting with readable ruby ;-)
 
user4710450
$><<"string"
 
user4710450
What does this code suppose to mean?
 
Let's start with breaking it into parts. $> is an alias for STDOUT, and << is an operator with that STDOUT as its receiver
 
user4710450
# This is the result in `irb` :
>> $><<"string"
string=> #<IO:<STDOUT>>
 
user4710450
Hmmm. seems interesting
 
user4710450
1:21 PM
Does it have any performance benefit?
 
one less character
sometimes
It might save a little time, I guesss
 
@Ehsan did you figure out the fizzbuzz program?
 
user4710450
Not yet. What was the problem?
 
Well, in a case statement the first condition takes precedance
 
That's intended
 
1:31 PM
What the program should do is print out all the numbers 1 to i and for every multiple of 3 print fuzz, for multiples of 5 buzz, and for multiples of 3*5 print fizzbuzz
@JanDvorak wow nevermind I misread the code
 
user4710450
We're sorry, but something went wrong.

Could not retrieve database information at this time.
 
user4710450
Why is heroku giving this to me?
 
@JanDvorak I just got it
Seems weird that it doesn't throw an error
 
user4710450
I am just trying to create a PostgreSQL db
 
user4710450
Hobby plan
 
user4710450
2:06 PM
Hi, I'm back
 
user4710450
Is there any tool to convert .css to .scss?
 
user4710450
And simplifies it?
 
user4710450
like use mixins and blocks
 
user4710450
No, not simply renaming
 
user4710450
2:07 PM
doing some refactoring also
 
user4710450
I have a static layout
 
user4710450
Now I want to use in Rails
 
user4710450
Is there any css selector to chose all <a> tags except the one with class active?
 
:not
 
49
Q: How to create a css rule for all elements except one class?

NickI have created a CSS stylesheet for my project. Is there any way I can create a css rule that applies to all table elements EXCEPT table elements belonging to the class "dojoxGrid"? Something like: .not(dojoxGrid) table{ width:100%; border-top:1px solid #dddddd; border-left:1px solid...

 
user4710450
2:13 PM
Well I am looking to something like this :
 
user4710450
ul.navbar-nav li a {
  color: black !important;
}
 
user4710450
But not including .active one
 
yuck
 
user4710450
Bootstrap :|
 
user4710450
w8, I am creating a fiddle
 
2:15 PM
Bootstrap doesn't force you to use !important
 
user4710450
try your best to make it work, plz
 
MAP = %w[test dev prod err]

def map_value(value)
  value = value.to_s.downcase
  MAP.each_with_index do |key, i|
    return i if value.include?(key)
  end
  nil
end
 
user4710450
Hi Wayne!
 
@thesecretmaster ^ In cases like that, I prefer to use a data structure to represent the mapping, and then a little code to implement it.
@Ehsan Hello, good morning.
 
user4710450
good evening here, mate!
 
2:17 PM
Good evening, then :) Where is "here?"
 
user4710450
Duabi, UAE
 
Hey @WayneConrad!
 
That is indeed a long way from here (Phoenix, Arizona). But also a desert and very hot in the summer, right?
@Marc-Andre Good morning!
 
user4710450
Ya, but a beautiful city :)
 
@Ehsan I think you had the idea for the code I just posted--use a data structure and some code--but just didn't know how to implement it in Ruby.
 
user4710450
2:21 PM
People are very rich here
 
user4710450
I think police cars are famous in the world!
 
user4710450
Yup :)
 
I did not know about Dubai police cars until just now. I found that image on google.
 
user4710450
As I said people here are very rich
 
user4710450
2:23 PM
I guess I'm the poorest here
 
user4710450
Could you please take a look at it?
 
user4710450
The problem is the first menu item is black
 
user4710450
How can I solve it?
 
user4710450
And also the hover action isn't working ... :(
 
user4710450
2:33 PM
Wayne its the project I talked about morning ( evening for you )
 
@WayneConrad thats what I ended up implimenting
 
I'm looking at the fiddle. I don't now CSS well, so I'm learning things just looking at it. Like, I didn't know an HTML element could have more than one class. Cool.
 
user4710450
You should consider learning them, mate :)
 
user4710450
w3schools.com is an awesome place for learning them
 
user4710450
@WayneConrad the CSS is Bootstrap
 
2:41 PM
Oh, Bootstrap. How does that fiddle reference Bootstrap? I don't see it.
 
@Ehsan no
 
user4710450
There is a left sidebar which contains External Resources.
 
user4710450
There you can find it, I have reference 3 things
 
Ah, now it makes sense. Thanks.
 
user4710450
@WayneConrad Most welcome
 
user4710450
2:43 PM
Now if you take a look at it I have added a JS which makes it a bit nicer
 
Does this css work?ul.navbar-nav li a {
background-color: darkseagreen !important;
}
 
user4710450
Yeah
 
My bad on the disgusting formatting
 
user4710450
Guys , can you edit my code or is it freezed for iyou?
 
user4710450
$(item).css('color','white');
 
2:47 PM
@Ehsan I see no JS there
 
user4710450
Isn't working :(
 
user4710450
    $("ul.navbar-nav li a").on('mouseover',function(event){
   $this.css('color','white');
});

$("ul.navbar-nav li").each(function(item) {
	$(item).css('color','white');
});
 
user4710450
This is the JS
 
user4710450
I think Bootstrap has used !important somewhere
 
Yeah, I dunno. My frontend is almost mediocre
 
user4710450
2:52 PM
And yup I found the problem :
 
user4710450
.navbar-inverse .navbar-nav > li > a {
    color: #9d9d9d;
}
 
user4710450
This takes precedence over my css :(
 
user4710450
And yup solved it
 
user4710450
But things got a bit messy
 
user4710450
I will give up
 
user4710450
2:56 PM
The only thing Bootstrap sucks in is :
You can't customize it that much
 
user4710450
I found this question :
 
user4710450
36
Q: Change color of bootstrap navbar on hover link?

CallumI want to know how to change the color of the links when you hover over them in the nav bar, as currently they are an ugly color. Thanks for any suggestions? HTML: <div class="container"> <div class="navbar"> <div class="navbar-inner"> <ul class="nav"> <...

 
user4710450
But none of the answers are working :(
 
I don't think most people in this room would be able to help you out with HTML/CSS/JS/Anything frontend. From what I gather we're mostly backend people. (Please someone correct me if I'm wrong)
 
user4710450
OK. I will mention this in CSS Room also
 
3:04 PM
I can do front-end
 
user4710450
Seems noone is online there :(
 
user4710450

HTML / CSS / WebDesign

This room is now defunct. RIP.
 
user4710450
Damn the hell, I just want to change the grey links but when I use !important things get messy for the active link
 
user4710450
It seems to be working now :)
 
user4710450
But I have badly violated DRY rules
 
user4710450
3:09 PM
:|
 
user4710450
Nevermind, It's working now xD
 
user4710450
For anyone for getting inspired from my fiddle :
https://jsfiddle.net/ehsan_akbari/hva6cnen/1/
 
user4710450
3:24 PM
Found something useful which might come to use for you all
 
user4710450
Just open it!
 
@JanDvorak By the way, the fizzBuzz thing was that you forgot the |i| after .each, right?
 
yes
 
user4710450
Also there is another useful thing
 
user4710450
3:27 PM
 
user4710450
It might come to use for avatars
 
user4710450
An example to use :
https://robohash.org/test.png
 
user4710450
 
user4710450
It generates quite interesting robot faces. lol
 
user4710450
Also you could make funny games with it
 
user4710450
3:29 PM
take user's name and give him the corresponding robot image
 
Rubocop tells me Do not prefix writer method names with set_. Why not and what should I prefix them with? (I can't use standard attr_writer because the method doesn't impact instance vars)
 
user4710450
Is it useful?
 
user4710450
Rubocop
 
@thesecretmaster foo=
 
@JanDvorak Thanks. Can't believe I forgot that though :/
@Ehsan Yeah, it's fairly useful for cleaning up syntax, although I get into arguments with it sometimes.
 
user4710450
3:41 PM
 
user4710450
I will express my feelings with these robots from now on! lol
 
Let's not. They take up too much space
 
user4710450
OK. But was really funny. lol
 
user4710450
Or I will change the size
 
user4710450
 
user4710450
3:44 PM
Is this really taking space?
 
user4710450
How awesome it could be if their was some service which returned cute animes :)
 
The large images, if done often, would be annoying.
 
Any images done often would be annoying for me, but that's my opinion
 
user4710450
OK. I won't send them again
 
5:26 PM
New bike is pretty amazing
And also
 
user4710450
Yeah its really cool
 
Pretty! Did you get that fancy rear hub with sealed internal gears, or whatever that was?
 
Yeeeup
the big red rear hub
 
Really nice bike!
 
The drive train is missing the front and rear derailleur and only has one gear in the front and back
all that junk is moved inside the hub
 
5:35 PM
And disc brakes, nice! I would have killed for disc brakes when I was riding. I never got the hang of adjusting cantilever brakes.
 
Don't know much about bikes, but it looks incredibly majestic.
 
The disc brakes are weird
They'll take some getting used to
it's suddenly really easy to lock up the rear wheel
Also, I wheelied like crazy climbing up the Niagara escarpment
I'm used to a longer wheelbase on my touring bike, the short wheel base on this bike means leaning back too far while climbing and suddenly your front wheel is in the air
 
Hope you always wear a helmet. :S
 
Most of the time, especially while riding outside of my subdivision
Though I ride about 1.5km between the train station and work 3-4 times a week, and never wear a helmet
It is a very different type of riding where I really don't feel the need
 
5:59 PM
Fair enough
 
user4710450
6:54 PM
Good night
 
user4710450
I'm falling asleep on my monitor
 
8:30 PM
Why is ruby interpreted and not compiled? Isnt compilation inherently better because you can do more optimization and it doesn't live in memory? Do interpreted languages only exist because someone was bored while their program compiled?
I understand that compiled versions of ruby exist (jruby, rubinius, etc.) but I'm talking about matzs standard C ruby interpreter
 
8:53 PM
Has anyone used the Docker Integration plugin for RubyMine?
 
9:21 PM
@Ehsan Goodnight; I hope you enjoyed your visit.
27
Q: Why Is Dynamic Typing So Often Associated with Interpreted Languages?

daveslabSimple question folks: I do a lot of programming (professionally and personally) in compiled languages like C++/Java and in interpreted languages like Python/Javascript. I personally find that my code is almost always more robust when I program in statically typed languages. However, almost every...

@thesecretmaster ^
 

« first day (960 days earlier)      last day (2295 days later) »