« first day (964 days earlier)      last day (2291 days later) » 

 
3 hours later…
5:36 AM
Hope all are doing well.
Can anybody help me on this, I tried but I didn't find the solution, stackoverflow.com/questions/39191943/…
 
user4710450
Like an alarm
 
user4710450
You always say 'Hope all are doing well'
 
user4710450
You are violating DRY rules.
 
user4710450
lol
 
user4710450
5:52 AM
Sorry for posting this code here but if anyone has Java expereince please help me :
 
user4710450
import java.util.*;

public class Main
{

public static void main(String[] args)
{
final int x;
x = 12;
x = 45;
System.out.println(x);

}

}
 
user4710450
What should code above compile!?
 
9:42 AM
Is it strange that all of my declined flags are mod flags, and that I have no helpful mod flags?
 
 
3 hours later…
12:29 PM
@Ehsan I think that code will compile, and it will print a number.
@thesecretmaster Either I don't have any mod flags, or the flag page isn't showing me a count for them. So I don't know.
 
 
2 hours later…
2:13 PM
Hah!
If you want cat to print the lines of a file backwards, you use tac instead
 
Haha! I love Linux.
 
 
1 hour later…
3:44 PM
> The term “Separation of Concerns” honestly doesn’t mean anything anymore. But it used to...
> It's a catchall phrase which means "I'm trying to do the right thing", whatever that thing may be -- Rob Conery, The Imposter's Handbook.
 
3:58 PM
hello guys
and ladies..
+)
 
Hello Nima, Good to see you.
 
4:45 PM
I'm doing devops this morning. I don't think I'm angry enough for the job, but I'm willing to rise to the occasion.
It's a wordpress site where the dev has been changing some files, but the changes aren't visible on the site. It's... strange.
I can modify static content... like readme.html... and that change is visible. But modifying any php doesn't seem to have an effect.
 
5:08 PM
@WayneConrad what is devops?
 
@WayneConrad opcode cache problem?
 
It's a modern name for sysadmin. It means, "you get to be as angry as a sysadmin, but you have to write code too."
DevOps (a clipped compound of development and operations) is a culture, movement or practice that emphasizes the collaboration and communication of both software developers and other information-technology (IT) professionals while automating the process of software delivery and infrastructure changes. It aims at establishing a culture and environment where building, testing, and releasing software can happen rapidly, frequently, and more reliably. == Overview == In traditional functionally separated organizations there is rarely cross-departmental integration of these functions with IT operations...
@meagar As always, caching is my #1 suspect
 
@Ehsan That won't compile, you can't reassign a final variable
 
@Marc-Andre Good catch! I totally missed that.
Aaaaaaaand the site is picking up its changes now. I restarted apache -- again.
Ah. That means I had a rogue apache process that wasn't restarting when I asked it to, but finally did. Next time this happens, I'll stop apache, then look for rogues that need extra killing.
 
5:57 PM
irb(main):004:0> ary = [1,2,3]
=> [1, 2, 3]
irb(main):005:0> ary |= [5]
=> [1, 2, 3, 5]
irb(main):006:0> ary |= [2]
=> [1, 2, 3, 5]
irb(main):007:0>
"append unless present"
 
Nice!
 
Is there any way to access a smartphone camera from a wobsite?
Never mind, found it.
119
Q: HTML5 Camera Access Through Browser in iOS

JuliaWe are creating an html5 website for mobile and need to get camera access through the web browser without being a native app. We are having trouble making this work in iOS. Is anyone aware of a solution for this?

 
Why can't I sort booleans? :-(
Or rather, I'd like to sort an array by a predicate.
I have a devious idea: Sort booleans by to_s
 
I agree... booleans should be ordered.
It's confusing that true and false respond to <=> with nil
 
That's weird...
irb(main):007:0> [true,false,true].sort
ArgumentError: comparison of TrueClass with false failed
It kinda meshes with that they are different classes (which they shouldn't, IMO)
 
6:19 PM
Single page apps that respond to refresh by taking you back to the initial page are... irritating.
 
I hope you don't have to deal with that app too often!
 
Only every day :)
It's the web interface to Nagios, which is pretty awful.
 
From the quick google it look okay
 
Since @foo = []; def foo; @foo; end shouldn't work, why does it for Kernel?
Or rather, in the top scope?
 
2.3.1 :001 > self
 => main
2.3.1 :002 > def foo ; self ; end
 => :foo
2.3.1 :003 > foo
 => main
 
6:30 PM
As in, the top scope is its own instance?
(I do realise Class does that too)
 
The main object is an instance of Object. At the top scope, self is set to that object. When defining a method at the top scope, self is again set to that object.
This is different than when defining a method in a class. Outside the method, self is the class; inside the method, self is the instance.
 
Which means it's not really a class despite the similarities?
 
The top-level scope is an instance of a class.
 
How does Kernel fit into this?
 
Kernel is mixed into Object, therefore the top-level scope, which is an instance of Object, has access to all Kernel methods.
 
6:35 PM
Gotcha, thanks
 
I hadn't really thought deeply about the top-level scope until you asked. Thanks for asking.
 
puts on a 36k csv for each row is really draining the performances. Next time, I'll try to use something that buffer the output to the console!
 
Writing 36k lines should be really, really fast.
 
Writing to where?
 
start_time = Time.now
36_000.times do
  puts "Something"
end
p Time.now - start_time
That, writing to stdout, takes 0.1 sec. on my box.
0.01 sec if redirected to a file.
 
6:42 PM
1.793 sec for me in IRB with JRuby
 
native FullHD has its disadvantages. Saw "game paused" in a Youtube video. Was confused.
 
@Marc-Andre Ouch!
 
@Marc-Andre What machine?
12 seconds or so. Powershell really isn't fast.
 
Intel Core i5-4210M and Windows
 
Let me try it in jruby.
 
6:54 PM
Why does Array override sort but not sort_by? It causes confusing documentation...
 
The docs are confusiong, I agree.
0.25 seconds for jruby. Linux/bash.
 
Wow not quite the time it took for me but still a good difference!
 
7:25 PM
If you're benchmarking puts, it should be noted that your terminal has a huge impact on this
Even resizing your terminal window so it's smaller can make a difference
Turning on the semi-transparent background blur in iTerm2 for example raises my benchmark from .09 to .9
Interesting, moving the same iTerm window from my external monitor to my laptop's retina display makes it almost 6x slower
Anyways, setting a background image, turning on blur effects, I'm up to 2.197423 seconds when my default black terminal window was 0.09
 
Yeah and I was doing costly operation too that I didn't optimize since it was a one-time deal
But thanks for the info, next time I do an output bench, I'll keep in mind that screen has a cost too.
 
7:53 PM
I should have known Ruby's sort is unstable...
ary.sort_by!.with_index{|x, i| [foo(x), i]} - is that the intended way?
 
It is. You can make it stable, with a little bit of extra machinery.
1
Q: Stable sort in Ruby revisited

user1934428We find here an implementation of a stable sort in Ruby, which works for the general case (i.e. I can supply my own comparision algorithm), and in this thread user tokland describes a very elegant way to do a stable sort using the <=> operator of the objects to be sorted. This algorithm goes like...

I don't know how to answer if that's the intended way... depends upon who is doing the intending. I think it's a reasonable approach, although I like the answer that monkey-patches Enumerable.
 
Hmm... I keep flipping the branches of the ternary, if requires end, and a postfix if with else would be pretty ugly even if possible.
 
8:19 PM
@JanDvorak Examples?
 
out = (old_cats == @categories) ? "" : "#{@categories}\n"
 
I wonder if you can't bypass that entire line in the special case. Rearrange the logic so you can do next if old_cats == @categories or something plainer.
 
  out = (old_cats == @categories) ? "" : "#{@categories}\n"
  out + pair.sort_by{|e| -(@categories.index e.category)}.join(" + ")
implicit return here
 
Hmm. That's pretty dense code.
I wonder if you should put it (with context) on the CR site.
 
It might end up too broad :-D
 
8:29 PM
The CR site is for exactly that kind of broad thing.
Or, at least it was--maybe it's changed.
 
Is pair a subset of @categories? if so I think you can get away with
out + (pair & @categories).reverse.join(' + ')
 
Nope.
 
Never mind then :p
Wait
I think it must be
Oh, wait, no, pair contains something that has a category that is a subset of @categories
I misread
I would be tempted to build the output as an array and wait until it's "complete" before joining it with \n:
out = [ pair.sort_by{|e| -(@categories.index e.category)}.join(" + ") ]
out.unshift(@categories) unless old_cats == @categories

out.join("\n")
It's slightly more code but the "no-op" ternary bugs me
 
Now it bugs me it's backwards :-)
 
out = []
out << @categories unless old_cats == @categories
out << pair.sort_by{|e| -(@categories.index e.category)}.join(" + ")
out.join("\n")
:p
 
8:40 PM
+1
 
nice one
 
I just finished my first pass through the Imposter's Handbook. It's very good--I'm going to read it again and take more time with it, aim for better comprehension of it's more difficult parts.
 
awesome, let us know how it goes @WayneConrad
 
If you are thinking of buying it, I pasted a discount code into this channel earlier this week. Just search back for it.
 
ah great thanks
 
 
2 hours later…
11:07 PM
Can anyone help me out querying this api with net/http? I'm getting a file into params in sinatra, but what am I trying gives me a permanent redirect which I don't know how to follow. Here is what I'm trying: Net::HTTP.post_form(URI.parse('http://api.qrserver.com/v1/read-qr-code'), params)
 
11:38 PM
@thesecretmaster I prefer higher level libraries such as webrat. Webrat will (I believe) follow redirects automatically.
24
Q: Ruby - net/http - following redirects

r3nrutI've got a URL and I'm using HTTP GET to pass a query along to a page. What happens with the most recent flavor (in net/http) is that the script doesn't go beyond the 302 response. I've tried several different solutions; HTTPClient, net/http, Rest-Client, Patron... I need a way to continue to ...

 

« first day (964 days earlier)      last day (2291 days later) »