« first day (1172 days earlier)      last day (2083 days later) » 

12:06 AM
Oh no. Now I'm halfway through the update to mint 18, I just removed all the packages it asked me to, and now I have no internet (wired or wireless) and the mintupgrade app is gone.
 
 
1 hour later…
1:28 AM
I'm trying out Linux&Unix.se for the first time. Lets see if I get answers...
 
2:22 AM
No good answers besides "restore from a backup" which only what logical (not me) people do, but I reccommend reading the comments. The answerer has me figured out. unix.stackexchange.com/q/354028/157776
I fully understand your attitude, but this method is not efficient. However if it raises your amusement levels, then it fullfills other purposes too and not only the educational which aren't too efficiently gained through this type of process. Which makes what you are doing understandable. — Akito 9 mins ago
 
 
3 hours later…
5:18 AM
Fixing something the hard way even though you don't have to can be a good way to learn useful skills. I work with a sysadmin who has occasionally fixed things the hard way for just this purpose; the skills he's learned make him one of the better sysadmins under pressure that I've ever seen. When the site is down, the owner is calling every half hour, and the backups are no good, the hard way may be all that you have left, but that's a very bad time to try it the hard way for the first time. — Wayne Conrad 30 secs ago
@thesecretmaster ^ my comment.
 
 
3 hours later…
8:02 AM
ruby on rails community is dead
It was my mistake to opt ruby on rails
 
8:17 AM
?
 
 
3 hours later…
11:23 AM
@AniketShivamTiwari ?
 
12:36 PM
Man if you think the rails community is dead, you'd hate sinatra
2
 
12:56 PM
I like sinatra. I like to think that it's simple enough that the website docs are fine.
 
I agree
 
1:23 PM
I don't know if anyone else likes teaching comp-sci/ruby things, but if you do here is an interesting area 51 proposal: area51.stackexchange.com/proposals/92460/…
 
1:41 PM
I like Sinatra too. I've only done one project using it so far, but I found it refreshlingly unmagical.
 
 
1 hour later…
3:13 PM
I don't know if anyone can help with this
But if you do a query
Some query that groups by a foreign key, and then join that with said foreign table
It should come out to the same number of records.. right?
I'm doing an assignemnt, question is "For each department, show the name of the department and the TOTAL salary earned by ALL employees in that department"

Problem is we're using something called calcite in java, so nothing makes sense.

The original group_by call returns

1 205000
50 150000
20 340000
40 585000
10 230000
30 165000

Which is great, but when I join it with DEPT to get the name...

Management 205000
Sales 205000
Marketing 205000
Accounts 205000
R&D 205000
HR 205000
Management 150000
 
Activerecord?
 
It's something called calcite
It's .. something
		 builder
				 .scan("EMPLOYEE")
				 .aggregate(builder.groupKey("DEPTNO"),
						 builder.sum(false, "C", builder.field("SALARY") )
                 )
                 .scan("DEPT")
                 .join(JoinRelType.INNER)
                 .project(builder.field("NAME"), builder.field("C"));
 
@Cereal The join happens before the group by.
@Cereal select department.name as name, sum(salary) as total_salary from departments join employees on (department.id = department_id) group by department.name
 
3:32 PM
The calcite engine is supposedly supposed to generate the SQL based on the code, but I did figure it out thanks to you. Had to throw in some aliases and .filter(builder.equals(builder.field("d", "DEPTNO"), builder.field("c","DEPTNO"))) after the join.
 
Sometimes Always it's annoying to have something between me and the SQL.
I'm glad you got it figured out, though.
 
@WayneConrad I actually find AR better because I can treat the records as actual ruby objects rather then have to parse the output of the sql command myself. Also, I don't really know sql that well, so that's part of the reason, but doesn't AR also follow security best practices to (try to) prevent SQL injection?
 
Yes, AR does escape things for you when you let it make the SQL.
Unfortunately, makes it somewhat difficult to access the escaping mechanisms yourself for when you want to hand-craft a query. That's a fault in AR.
 
I guess I've never had a use case where I've had to hand craft the SQL because I don't work in an environment where performance is very important.
 
It's not so much about performance as it is about being able to figure out how to make AR do the query that's in my head. I usually know what SQL I want generated. Sometimes I can't figure out the magic spell to make AR issue that query (danged magic again).
 
3:43 PM
And in the second question, I've come up with a final table containing 3 columns all named "name".

This would be a lot easier if we learned what this engine is exactly
 
The different database drivers do different things with same-named columns. With the pg gem used for Postgres, the ambiguous columns automatically get the table names added in the result set: foo.a, bar.a, etc. With the mysql2 adapter (and I think the TinyTDS adapter used for SqlServer), the result set contains just one of the columns, and throws away the others with the same name. This is very annoying.
 
I printed out the fields available in calcite, and they're actually still all called NAME as far as I can tell
 
You may have to do an "as" in the SQL (however you make calcite do that).
 
field [DEPT.NAME] not found; input fields are: [NAME, NAME, NAME]
 
select table1.name as name1, table2.name as name2, table3.name as name3 ...
 
3:50 PM
I think I might be able to wrangle something like that up
Hm, guess not
 
Stupid layers between us and reality.
 
I mean, SQL isn't reality either...
 
Oh, I think I found a way
 
@thesecretmaster That doesn't mean that adding more layers between it and us is always good.
 
builder.scan(..).project(builder.alias(builder.field(..), ..))
Needs more layers
  builder
          .scan("EMPLOYEE").project(builder.alias(builder.field("NAME"), "EMPNAME"), builder.field("DEPTNO"), builder.field("MGRID"))
          .scan("DEPT").project(builder.alias(builder.field("NAME"), "DEPTNAME"), builder.field("DEPTNO"))
          .join(JoinRelType.INNER, "DEPTNO")
          .scan("EMPLOYEE").project(builder.alias(builder.field("NAME"), "MGRNAME"), builder.field("EMPID"))
          .join(JoinRelType.INNER)
          .filter(builder.equals(builder.field("EMPID"), builder.field("MGRID")))
Just because it's verbose, does not mean it's easier to read, that's for sure
 
3:56 PM
It's like an onion. You keep peeling back layers and eventually the onion is gone and you have nothing and you just cry quietly to yourself and feel onion-regret.
 
Maybe it's just because I don't know it, but that API seems opaque. What all those calls to builder.find(...) doing?
 
There's no builder.find. Do you mean builder.field?
 
4:29 PM
Oh, yes. Sorry.
 
Thoughts on Object.const_set str, Class.new{...} as opposed to c = Class.new do ... end; Object.const_set str, c ?
 
It looks fine to me without the temporary.
 
Thanks
I remember that you disagreed with alias_method :foo, def bar ... end
 
If so (I think I did disagree), then I'm not very consistent.
 
5:02 PM
@JanDvorak That's exactly my solution I did yesterday. It signed me out when I clicked on the kata, so I did it without knowing I've done it before.

My original solution was... poor
Except I did const_set("whatever", Class.new ...
 
Hi guys, what's the best way to write a do until loop with a timeout in Ruby. I.e Do x until y. If y doesn't happen after 2 minutes, return nil.
 
Can you check the time after each iteration?
 
Hy @JanDvorak What do you mean?
 
time_start = Date.now; bar until foo || Date.now - time_start > 120
 
That makes sense actually.
Thanks Jan.
 
5:17 PM
What's the use case?
 
    require "timeout"

    begin
      Timeout::timeout(120) do
        ...
      end
    rescue Timeout::Error
      nil
    end
 
I guess that uses a watchdog thread?
 
@JanDvorak A bot waiting for a response.
 
I don't know the implementation.
 
Ah! Nice @WayneConrad
Is timeout a built in library?
 
5:29 PM
Yes, Timeout is built-in.
 
That's Amazing!!!!
 
@TommyAdey can you use proper threading instead? As in, block on the response socket
 
@WayneConrad Thanks.
 
@TommyAdey How are you getting the response? Many network libraries support timeouts already.
 
@JanDvorak Haven't worked with sockets per say, so I've been avoiding it haha. Even in js, I still use timeout.
 
5:31 PM
yuck
 
Hahahahahahah!
@WayneConrad it differs. Some methods wait for web page responses, some wait for XML, some wait for JSON.
 
But all HTTP?
 
Yup.
 
I think the HTTP module blocks by default
 
Search for the word "timeout" here to see what I mean about built-in timeouts. See especially open_timeout and read_timeout.
If you are not using Ruby's HTTP library directly, the library you are using may still be using Ruby's HTTP library. A little digging in the source will probably reveal if the built-in timeouts are an option for you.
 
5:38 PM
even if not, Timout with a blocking call should still be possible
 
Sage advice @WayneConrad
read_timeout looks like exactly what I need.
And yes, I'm using Ruby's HTTP library :).
@JanDvorak What do you mean by "I think the HTTP module blocks by default"?
 
in that case there really is no excuse for spinlocking ;-)
@TommyAdey as in, it doesn't return until it has the data
or rather it returns an input stream that blocks on read
 
@JanDvorak Ah! I see.
 
I never did figure out the Ruby's Eleven kata
 
link?
 
5:51 PM
Cool ruby question, example of why FGITW is sometimes not true:
11
Q: Weird syntax error with parens

ndnOther than hashes as last argument, you can drop parenthesis in Ruby on method invocations and get consistent results (you still have to mind the priority). However, I encountered an example where this is not the case: ''.split(/ ./) # => [] ''.split /./ # => [] ''.split / ./ # !> SyntaxErro...

 
Ah, thanks. I gave up early on that one.
 
Wayne's done it, and he said something to the affect of it's actually really easy
 
I should keep it open for when my brain is running
 
Oh, yeah, I did do that. If I recall, it took me a long time to figure out that it was really easy.
3
Agh, the Codewars UI and my brain don't agree.
If I log in and then refresh the link that Cereal gave, it still shows me logged out. I have to log in, then close and re-open the page.
Anyhow: My solutions is 15 lines, excluding comments (I commented the heck out of this one).
 
6:01 PM
I've been having problems with staying logged in on codewars lately
I think I just found a cheating way to do it
Nope, didn't work
 
@Cereal You've passed my score on Codewars.
 
I did that today!
 
Nice.
 
6:28 PM
Well, I managed to cahnge the password on some unknown object, so that's nice
 
6:38 PM
I solved it, but I think I cheated
I'll just call it an "alternative solution"
 
I have to admit that I don't understand what you've done.
Wait... where is the secure_login function defined?
Is that the cheat?
 
6:57 PM
It's used in the test cases, it returns SecureLogin, and calls #given_credentials on the supplied module
I saw your solution. Way too smart for me
It's the highest ranked solution for the problem, too
 
I saw that--surprised me. My kata solutions are usually kind of "fat" and don't get much love. Golfing seems to be preferred by most of the people who rate solutions.
 
I have no idea what #tap does
So your solution just kind of resembles magic
 
It just runs a block with self as the argument
 
Correct. Also, the result of o.tap is always o.
 
That sounds useful
 
7:03 PM
It is. Let's say you have a call chain a.b.c.d and you want to see what the intermediate result is after b is called. Then a.b.tap{|o|p o}.c.d
If you use the cute_print gem, you can abbreviate this to a.b.tapq.c.d
 
undisclosed affiliation detected ;-)
 
:D
I happen to know the schmuck who wrote cute_print, that's true.
 
Can I use your gem on codewars?
 
I don't know. I've never tried to use an external gem on codewars.
I'll be surprised if you can.
 
"Creates a Minus of the two most recent relational expressions."
This is the description of a method "minus" in calcite
It takes a parameter "all" which is a boolean
I cannot for the life of me figure out what it does
 
7:17 PM
Maybe an ESL speaker wrote it.
 
7:27 PM
Oh my god a question I answered is in list of HNQs.
 
What is HNQ?
 
Hot Network Question.
 
Cool. Link?
 
It's on the site, in the right sidebar with all the questions from other sites.
 
I mean, link to the question, please.
 
7:31 PM
Oh, I linked above. It's about the ruby parser, pretty interesting: stackoverflow.com/questions/43046927/…
It's about if "".scan / ./ is regex or devision.
And that it's regex with it's called with parens, it throws an error when no parens because it's treated like devision.
 
Good answer.
 
Most of the good parts are from comments by another user. Also, I lost votes even though I won FGITW.
 
If I added an answer, it would be "Stop following the fetish for leaving out all parentheses." But that wouldn't be a nice way to say it.
 
You're no fun. Sinatra would be so much less readable with parens.
 
Sinatra is an internal DSL. Those get special dispensation.
 
7:35 PM
Still, I'd say it's a bug because ruby says passed args are treated the same with and without parens.
 
There are other instances where they are not, so I don't know who someone would say that. Where does it say that?
It would be really difficult for a parser such as Ruby uses to handle this case.
 
Yeah, true, but how come when it's in parens it doesn't try and do devision too?
 
Because once it sees the left paren, it knows that the next thing cannot be a binary operator.
It could handle it, but it would be costly in terms of performance. You either have to start looking ahead, or doing backtracking.
 
 
1 hour later…
user5870134
9:33 PM
Hello, guys!
 
user5870134
@WayneConrad Quick question, when was the last time you changed your profile picture? Also have you always had that otter as your profile picture?
 
I don't recall when.
I think I have always had it here on SO, though.
I also think that one of us discovered that I need to find a different picture... I thought that was was under a CC license, but it doesn't appear to be.
 

« first day (1172 days earlier)      last day (2083 days later) »