ccooke

Activity Graph

Page 1 of 3 | Next »

2018-08-16

[16:05:34] ccooke: benzrf: it certainly wouldn't be hard to write one
[16:10:01] ccooke: Actually, you might be able to use Enumerable#flat_map
[16:10:05] ccooke: depending on your block
[16:10:25] ccooke: That effectively concatenates the outputs of all the blocks
[16:13:02] ccooke: or rather, I mean "In some cases, based on what you want, you could probably use that to do what you want"
[16:20:27] ccooke: Fine. have some horrible monkey-patch code ;-) https://gist.github.com/ccooke/d41afdf9838685d9c4d2bdd1980f77ad
[16:29:09] ccooke: That might be memory intensive if any of them are large

2018-08-14

[16:52:43] ccooke: Ameisen: yes, that will assign to the variable
[16:53:17] ccooke: Ameisen: there are two things like it: 'or' and '||'. '||' has a higher precedence so binds to the expression function(foo), so:
[16:53:50] ccooke: var = function(foo) || 'x' is the equivalent of: var = ( function(foo) || 'x')
[16:54:33] ccooke: Ameisen: wheras or binds more loosely - var = function(foo) or x is the equivalent of: (var = function(foo) or x
[16:55:06] ccooke: Ameisen: Indeed

2018-07-20

[00:07:29] ccooke: *.net *.split
[00:15:48] ccooke: has joined #ruby

2018-06-28

[14:21:41] ccooke: ponzii: require is used only to load code from files. When you want to include the functionality of one namespace inside another, you need include, prepend and extend. Here's a link: https://medium.com/@leo_hetsch/ruby-modules-include-vs-prepend-vs-extend-f09837a5b073
[14:21:59] ccooke: Ruby does. It's just different.
[14:22:22] ccooke: and in particular, ruby differentiates between *loading code* and *composing functionality(
[14:23:14] ccooke: The core idiom is that you write a file that defines a Module (or Class), and then you reference that Module or Class inside another
[14:24:07] ccooke: cdunklau: "module" is an ambiguous term across all languages; many languages have something like what python calls a module, but nothing else has *exactly the same thing*, and many of them are not called 'module'
[14:29:02] ccooke: cdunklau: yes
[14:29:12] ccooke: cdunklau: nested modules are a big thing in ruby
[14:32:21] ccooke: cdunklau: the key thing to recall is that modules are global, so if a file you require requires a module, then it's in your namespace. However, because they are generally well nested, you can access them unambiguously
[14:32:55] ccooke: but you don't have the python example of selecting only the objects that you want in your current namespace
[14:35:01] ccooke: cdunklau: the equivalent in Ruby is being able to compose sets of methods into a module or class, so you can select what is available from the context of that module
[14:36:03] ccooke: cdunklau: Oh: In Ruby, "Module" is an object that contains methods and can be included within other Modules, but cannot be instantiated into an instance. Class is a descendant of Module that *can* be instantiated into an instance object
[14:36:36] ccooke: cdunklau: So "Module" is a nice way to collect functional methods that suit a purpose. It's used for things like interfaces and common functionality.
[14:38:06] ccooke: cdunklau: A common idiom, for instance, is the Enumerable module, which provides a huge number of instance methods useful to enumerable objects - things like map, mfind, entries, count, reduce etc.
[14:38:46] ccooke: the Enumerable object can be included into any class that defines an (IIRC) each method - so you'll find it included into a number of the base classes
[14:39:30] ccooke: e.g.: Hash.ancestors => [Hash, Enumerable, Object, Kernel, BasicObject], Array.ancestors => [Array, Enumerable, Object, Kernel, BasicObject]
[14:53:54] ccooke: and for debugging
[15:02:30] ccooke: it depends what you're storing
[15:03:04] ccooke: if it's only hashes, arrays, strings, numbers etc - base objects that are implemented by default in json - then it makes little difference

2018-06-26

[12:44:23] ccooke: Technically, yes, in a sense.
[12:46:05] ccooke: >>> a = [1,2,3]; b = *a; b
[15:08:24] ccooke: Bish: $? is the exit code of the last process executed
[15:08:49] ccooke: Bish: Ah, I see
[15:10:27] ccooke: delsol: Does the script execute the ssh command, or a ruby SSH library?
[15:10:57] ccooke: Bish: it does, just wanted to check.
[15:11:31] ccooke: delsol: Right. So, after you run that command, you *absolutely will* have a return code of the ssh command, whether it worked or not.
[15:12:31] ccooke: delsol: when you say "a single scipt that has multiple commands", what do you mean? Is that a long ssh line with multiple commands or an ssh command that runs a multi-line file
[15:13:34] ccooke: delsol: so, you run "ssh user@host script_file" and the script_file contains an scp and 5 ssh commands?
[15:14:54] ccooke: delsol: how do you run multiple commands in one line? Give us an example
[15:16:24] ccooke: ... if you're scp'ing a file to the server, and then running it with "ssh user@host filename"... do you make sure the file is executable first?
[15:17:15] ccooke: so, you're trying a multiline string in system()?
[15:17:58] ccooke: The latter works?
[15:18:32] ccooke: did you actually try something like system("scp stuff server\nssh server do_thing") ?
[15:19:10] ccooke: What is the exact machine format of "the entire script"
[15:19:21] ccooke: is it a string joined with newlines? is it an array?
[15:20:32] ccooke: when you say "it's a shell script", do you mean that the thing you are running in system() is a path to a file in which there are commands?
[15:21:58] ccooke: Right, finally. So. what is the value of $? after you run the system() command that fails?
[15:25:51] ccooke: that's impossible as per the specification
[15:26:02] ccooke: $? is either nil or a Process::Status object
[15:26:41] ccooke: https://ruby-doc.org/core-2.2.0/Process/Status.html
[15:26:53] ccooke: To quote: "The built-in variable $? is either nil or a Process::Status object."

2018-06-15

[20:03:50] ccooke: Ping timeout: 260 seconds
[20:15:27] ccooke: has joined #ruby

2018-06-04

[10:05:23] ccooke: The only places Liquid is called are lines 25 and 30.

2018-05-29

[02:47:04] ccooke: *.net *.split
[02:48:05] ccooke: has joined #ruby
[08:41:58] ccooke: Answers vary from "No" to "Depends how long the line is". You probably won't go far wrong if you use https://github.com/bbatsov/ruby-style-guide

2018-05-23

[20:27:14] ccooke: Your def is syntactically valid - it defines a method with only positional arguments, several of which have defaults
[20:28:25] ccooke: When you call it, window:2 indicates that it (and the rest of the following arguments) are keyword arguments. Since you have no keyword arguments defined, you get the old-style "Just shove them in a hash" method, which gets assigned to "window" because it happens to be the next positional argument

2018-05-08

[14:53:50] ccooke: has joined #ruby

2018-05-07

[13:11:10] ccooke: *.net *.split

2018-04-25

[12:26:05] ccooke: *.net *.split
[12:27:29] ccooke: has joined #ruby
[15:01:36] ccooke: *.net *.split
[15:03:32] ccooke: has joined #ruby

2018-03-28

[13:06:49] ccooke: Quit: Lost terminal
[13:08:30] ccooke: has joined #ruby

2018-03-16

[16:03:02] ccooke: *.net *.split

2018-03-15

[11:27:21] ccooke: *.net *.split

2018-02-28

[13:41:48] ccooke: Chunkypng isn't bad. Although admittedly I've only used to to write a terminal png viewer

2017-12-05

[00:17:31] ccooke: Ping timeout: 268 seconds
[00:18:00] ccooke: has joined #ruby-offtopic
[00:18:00] ccooke: has joined #ruby

2017-12-01

[02:28:27] ccooke: has joined #ruby-offtopic
[02:28:47] ccooke: has joined #ruby

2017-11-29

[13:51:10] ccooke: Rust is... unlovely.
[13:51:15] ccooke: Maybe not as bad as Go
[13:51:37] ccooke: That's an opinion :-)
[13:52:59] ccooke: apeiros: from what I've seen, it does look like an improvement on C++ - or at least, C++ last time I had time to really use it
[13:54:09] ccooke: (and it is, in fact, a *lot* nicer to use than Go ;-)
[13:54:45] ccooke: I had to do a fair chunk of Go programming at my last job, and every time I used it I found something else to hate
[13:54:53] ccooke: however, this is a matter of taste
[13:55:46] ccooke: I know people who really like Go. To me, it takes some of the broad trends I dislike in python and cranks them up beyond my tolerance level
[13:56:01] ccooke: apeiros: That's because everything is wrong. And right :-D
[13:56:37] ccooke: There is no one true correct language. But there *are* languages that are better suited to a particular problem *with a particular author*
[13:58:19] ccooke: the best thing to do there (IMO) is to work out whatever language from the set the team agrees are fit for purpose best fits their skills, and try to hire people with skills in that language
[13:58:44] ccooke: (Sometimes the needs of the organisation the team is a part of will define what's fit for purpose, of course)
[13:58:56] ccooke: Sure. But that's a trade-off
[13:59:06] ccooke: (Like everything else)
[13:59:36] ccooke: (At this place, Ruby is the most common language, so my team (techops) writes everything in either Ruby or Shell)
[13:59:50] ccooke: (Because shell is the lingua franca of ops, still)
[14:00:20] ccooke: But all of the development team know ruby, so it's easier to get ruby code reviewed
[14:00:45] ccooke: Of course, since I *like* ruby, that was one of the reasons I chose this job :-D

2017-11-22

[10:45:08] ccooke: Quit: Lost terminal
[10:45:37] ccooke: has joined #ruby-offtopic
[10:45:37] ccooke: has joined #ruby

2017-11-17

[17:42:02] ccooke: RickHull: it's fine, just monkey-patch "puts" into Object! ;-)
[17:43:01] ccooke: RickHull: That was a deliberately bad suggestion, by the way
[17:44:35] ccooke: RickHull: ahh

2017-11-16

[16:07:38] ccooke: Bish: it's a limitation of precision, though
[16:09:51] ccooke: Bish: but you can avoid it if you actually need that precision
[16:10:22] ccooke: >> require 'bigdecimal'; BigDecimal("0.1") + BigDecimal("0.2")
[16:11:59] ccooke: Precision is an important consideration in performance. Most things don't need it arbitrary precision, but if you actually do then you have options

2017-11-10

[15:08:03] ccooke: has joined #RubyOnRails
[15:08:35] ccooke: aScottishBoat: If you type "/join #RubyOnRails" that should get you to their channel
[15:10:46] ccooke: no problem
[16:43:03] ccooke: has left #RubyOnRails: ()

2017-10-30

[14:03:05] ccooke: You're probably best off using a regex
[14:04:47] ccooke: impermanence13: when you say "best way", what are you trying to optimise for? Speed? Readability? Maintainability?
[14:09:26] ccooke: I'd use a + there

2017-09-28

[03:54:21] ccooke: Ping timeout: 240 seconds
[04:01:24] ccooke: has joined #ruby-offtopic
[04:01:24] ccooke: has joined #ruby

2017-09-07

[10:01:09] ccooke: That code is awfully formatted, and you didn't fix the syntax error we *can* see
[10:02:26] ccooke: aihwh: Serious thought - is your code indented like that? Because if so, it will make it much harder for you to see what blocks have been closed
[10:03:07] ccooke: So I see :-)
[10:04:11] ccooke: yeah, it is still a bit randomly indented
[10:05:14] ccooke: Line 17 is indented a step more than it should be (and line 15 is an indent-level short). You then just added one end more than you need, because the indent-level is wrong
[10:07:13] ccooke: vim with syntax colour on can be useful
[10:07:37] ccooke: the 'end's will be in different colours depending on what sort of block they close, which would have made this clear

2017-09-05

[10:23:06] ccooke: dminuoso: But I use those all the... wait, you mean actual *class* variables, not *class instance* variables. Carry on celebrating ;-)
[17:27:44] ccooke: dminuoso: it's a parser limitation. You can't pass a block with & because you've aready *ended* the parameter list
[17:27:53] ccooke: ... Bah. Lost in scrollback.

2017-07-27

[22:42:43] ccooke: Write error: Broken pipe

2017-06-20

[00:17:05] ccooke: *.net *.split
[00:22:50] ccooke: has joined #ruby
[22:15:39] ccooke: Write error: Broken pipe
[22:21:18] ccooke: has joined #ruby-offtopic
[22:21:18] ccooke: has joined #ruby

2017-06-08

[08:35:45] ccooke: Ping timeout: 240 seconds
[08:35:53] ccooke: has joined #ruby-offtopic
[08:35:53] ccooke: has joined #ruby
[20:33:04] ccooke: Write error: Broken pipe

2017-05-02

[16:18:38] ccooke: that could be quite bad if the set of files is big, though
[16:19:17] ccooke: The set of files

2017-04-18

[12:52:14] ccooke: (Well, no. You can always implement it without recursion as a simple loop. I meant without a named function. Bah.)

2017-04-13

[15:10:51] ccooke: *.net *.split

2017-03-20

[20:29:15] ccooke: *.net *.split

2016-07-25

[15:16:35] ccooke: Ping timeout: 244 seconds
[15:30:00] ccooke: has joined #ruby-offtopic
[15:30:00] ccooke: has joined #ruby
[16:55:55] ccooke: Ping timeout: 265 seconds
[17:11:24] ccooke: has joined #ruby-offtopic
[17:11:24] ccooke: has joined #ruby

2016-07-19

[15:29:15] ccooke: Ping timeout: 276 seconds
[15:29:29] ccooke: has joined #ruby-offtopic
[15:29:29] ccooke: has joined #ruby

2016-07-11

[13:10:28] ccooke: yes, if there's a variable it can access that nothing else uses
[13:10:55] ccooke: but a class or module would be a much better way to namespace it

2016-07-09

[09:32:42] ccooke: M4dH4TT3r: fedora is red hat.
[09:33:46] ccooke: M4dH4TT3r: Well. It's the desktop/consumer/experimental distro that is the basis for Red Hat, the more official and supportable distro that's more corporate focussed

2016-07-05

[00:04:34] ccooke: Ping timeout: 240 seconds
[10:21:35] ccooke: has joined #ruby-offtopic
[10:21:35] ccooke: has joined #ruby
[10:23:11] ccooke: Client Quit
[10:24:05] ccooke: has joined #ruby-offtopic
[10:24:05] ccooke: has joined #ruby

2016-07-01

[10:20:54] ccooke: Wildfyr: because the order of operations matters for division when it doesn't for addition or multiplication, and you have the operands the wrong way round everywhere
[10:21:09] ccooke: 5 / 2 would be 2.5, as expected. 2 / 5 is 0.4
[10:22:01] ccooke: (also, consider replacing the repeated if/end blocks with a single case/when/end
[10:27:22] ccooke: Wildfyr: you're using shifts to pull the operands off the stack. If you do those into variables before you process the operand, you can control the order
[10:27:44] ccooke: as it is, you're always using the top of the stack - the most recent number - first
[10:28:29] ccooke: so if the stack is [2 3 + 2 /], then the + will see [2 3] as the stack, pull off the 3 first, then the 2, and run 3 + 2.
[10:28:58] ccooke: the / sees a stack like [5 2], pulls off the 2 first, then pulls off the 5

2016-06-29

[13:13:00] ccooke: DeBot: bg
[13:13:15] ccooke: DeBot: bg
[13:13:25] ccooke: Oh well, someone else can do it; I have a meeting :-)

2016-06-24

[22:57:27] ccooke: DeBot: ta
[22:57:50] ccooke: DeBot: oin
[22:58:03] ccooke: DeBot: shr
[22:58:32] ccooke: DeBot: g#
[22:58:38] ccooke: DeBot: cl
[22:58:45] ccooke: DeBot: cl
[22:59:11] ccooke: ACTION tries to recall how long the rate limiting is set for
[22:59:15] ccooke: DeBot: cl

2016-06-23

[20:27:37] ccooke: *.net *.split
[20:27:45] ccooke: has joined #ruby-offtopic
[20:27:45] ccooke: has joined #ruby

2016-06-07

[13:37:41] ccooke: Finally catching up with the shell ;-)

2016-05-20

[13:32:57] ccooke: Ping timeout: 276 seconds
[14:41:27] ccooke: has joined #ruby-offtopic
[14:41:27] ccooke: has joined #ruby

2016-05-17

2016-05-06

[14:52:41] ccooke: DeBot: vd#

2016-04-17

[08:12:07] ccooke: *.net *.split
[08:21:29] ccooke: has joined #ruby-offtopic
[08:21:29] ccooke: has joined #ruby

2016-04-13

[19:48:33] ccooke: *.net *.split
[20:03:10] ccooke: has joined #ruby-offtopic
[20:03:32] ccooke: has joined #ruby
[20:04:32] ccooke: *.net *.split
[22:12:02] ccooke: has joined #ruby-offtopic
[22:12:02] ccooke: has joined #ruby

2016-03-28

[11:13:34] ccooke: Ping timeout: 248 seconds
[11:14:02] ccooke: has joined #ruby
[11:14:03] ccooke: has joined #ruby-offtopic

2016-03-23

[16:58:57] ccooke: DeBot: qu

2016-03-21

[14:43:51] ccooke: Ping timeout: 276 seconds
[16:11:59] ccooke: has joined #ruby-offtopic
[16:11:59] ccooke: has joined #ruby

2016-02-22

[20:21:06] ccooke: has joined #ruby-offtopic
[20:21:06] ccooke: has joined #ruby
[20:21:06] ccooke: *.net *.split

2016-02-03

[11:12:06] ccooke: Ping timeout: 240 seconds
[11:28:00] ccooke: has joined #ruby-offtopic
[11:28:00] ccooke: has joined #ruby
[18:40:55] ccooke: Ping timeout: 245 seconds
[18:51:50] ccooke: has joined #ruby-offtopic
[18:51:50] ccooke: has joined #ruby

2016-02-02

[00:43:03] ccooke: DeBot: db
[00:44:09] ccooke: smathy: not just perl
[00:44:23] ccooke: but yes, that direction

2016-01-31

[12:25:20] ccooke: *.net *.split
[12:29:04] ccooke: has joined #ruby-offtopic
[12:29:19] ccooke: has joined #ruby

2016-01-28

[18:00:52] ccooke: slash_nick: many irc clients support an alias or macro function