Activity Graph

Page 1 of 10 | Next »


[17:25:54] catphish: has joined #ruby
[17:26:32] catphish: i'd like to represent some integers in a base-26 alpha format, is there a trivial approach to this?
[17:28:54] catphish: ellcs: that's clever, thanks!
[17:33:05] catphish: Quit: Leaving


[12:31:00] catphish: has joined #RubyOnRails
[14:11:03] catphish: has left #RubyOnRails: ("Leaving")


[00:23:02] catphish: has joined #ruby
[00:48:15] catphish:
[00:48:18] catphish: no it doesn't
[00:48:49] catphish: hm, actually it's an array, so i guess it does
[02:02:21] catphish: has left #ruby: ("Leaving")


[10:58:00] catphish: has joined #ruby
[11:02:57] catphish: i have a strange bug whereby i have a gem that uses readline to ask a user for some input, if i run the gem's bin directly, all is well, but if i run it via rubygems's wrapper, readline randomly prints "\r" to my screen when i've entered a line of text
[11:04:40] catphish: short demonstration:
[11:27:07] catphish: found my problem, caused by loading rb-readline
[11:27:32] catphish: so it's using a totally different implementation of readline
[11:28:44] catphish: Dwarf: your paste is gone
[11:29:31] catphish: you certainly need both
[20:47:57] catphish: has left #ruby: ("Leaving")


[00:59:47] catphish: Quit: Leaving
[10:58:13] catphish: has joined #RubyOnRails
[17:49:28] catphish: Quit: Leaving


[16:01:26] catphish: has joined #ruby
[16:02:08] catphish: i have an odd requirement, i'd like my ruby process to re-exec itself, is there a good way to get the full command line to do so?
[17:30:01] catphish: Quit: Leaving
[20:04:28] catphish: has joined #RubyOnRails
[20:05:55] catphish: is there an api call to reload rails in development between invocations?
[20:08:53] catphish: ah Rails.application.reloader.reload!


[15:54:24] catphish: has joined #ruby
[15:56:19] catphish: ruby has some really weird behaviours with class finding :(
[16:18:15] catphish: 2.5.3 on OSX i'm told
[16:18:58] catphish: ruby's always had behaviour i didn't understand with regard to finding classes within parent classes
[17:39:30] catphish: Quit: Leaving


[12:56:29] catphish: has joined #ruby
[12:56:39] catphish: does ruby have a while loop with no block?
[13:00:33] catphish: def process_one; something_that_returns_true_or_false; end; while(process_one);
[13:01:31] catphish: i've been writing C for a couple of weeks and i'm in the habit of writing: while(something_that_processes_and_tests);
[13:02:42] catphish: the use base being to have one method that processes something once, and a separate method that runs it repeatedly, but allows the loop to be broken
[13:03:37] catphish: canton7: so the loop doesn't do nothing, it's just that the work is done as part of the test
[13:07:33] catphish: i suppose in C it's just an empty statement (the semi-colon at the end is actually a complete statement hat does nothing)
[13:08:01] catphish: this is ok, just not that pretty: while process_once; end
[13:10:29] catphish: canton7: i think "while" implies "begin"
[13:11:04] catphish: phaul: makes sense
[13:11:27] catphish: i didn't know that, explains why it's loop *do*
[17:42:13] catphish: Quit: Leaving


[12:54:31] catphish: has joined #ruby
[12:54:57] catphish: i have a requirement to run http requests though an ssh connection (in ruby) - is there an obvious approach to this?
[12:56:26] catphish: if net::ssh can do port forwarding channels, and i can get net::http to use one, that would be the best
[13:03:14] catphish: it's nonsense
[13:04:29] catphish: i can see how that works, but it's functionally no different to: if ("A".."M").include?(char) == true; puts "hoho"; end
[13:05:12] catphish: i believe the correct approach: case char; when ("A".."M"); puts "hoho"; end
[13:05:34] catphish: the point of case is that it compares each "when" item to the "case" item
[13:07:20] catphish:
[13:08:09] catphish: you can puts within the case statement, or it can return a value as in my link example
[13:08:49] catphish: am0123_: good luck :)
[13:13:21] catphish: `when ("A".."M").include? char` should work... it evaluates to true when the char is in that range
[13:13:34] catphish: then the case statement compares true with true
[13:14:13] catphish: it's just a horrible way to use "case", you might as well just use if and elsif
[13:16:22] catphish: try using parenthesis
[13:16:32] catphish: ("A".."M").include?(char)
[13:16:51] catphish: ruby allows method calls without them, but sometimes it's ambiguous and hence not valid
[13:17:00] catphish: i prefer to always use them
[13:19:47] catphish: don't do "case true" though
[13:20:01] catphish: if you find yourself doing that, just use "if"
[13:21:34] catphish: phaul: interesting
[13:21:54] catphish: i'd always prefer elsif, but i geuss boolean case has a place
[13:22:07] catphish: they're functionally identical
[17:55:37] catphish: Quit: Leaving


[10:45:22] catphish: has joined #ruby
[10:47:21] catphish: it would be really nice if ruby offered direct access to pipe2() with flags
[10:53:17] catphish: may need to write a gem for it, though i've never written a C gem before
[14:43:50] catphish: al2o3-cr: oh that's beautiful, thanks! i had no idea it was that easy to do on the fly
[15:00:29] catphish: well they're different types of request
[15:00:55] catphish: it's sometimes a mild annoyance, but i wouldn't call it weird
[15:02:50] catphish: you can say the same about any such setup i guess, like the response classes
[15:04:01] catphish: i don't understand
[15:04:52] catphish: i don't follow that logic, nor do i agree with the facts
[15:05:01] catphish: responses have a return code, the class it just an added niceness, it's redundant in terms of data
[15:05:54] catphish: requests have no such redundancy, the only place the request method is specified in in the class name
[15:06:10] catphish: but again, it's purely a matter of taste, someone had to make a decision, they did
[15:06:26] catphish: it would be perfectly functional either way
[15:07:02] catphish: "head and body" is a gross oversimplification
[15:07:40] catphish: anyway, both are fairly simple containers
[15:07:52] catphish: and it was just a style decision to subclass them
[15:08:59] catphish: personally i find the subclassing of http requests to be an annoyance, but not enough to warrant a complaint
[15:09:56] catphish: i always end up with case statements in order to create instances of Net::HTTP::Request
[15:23:49] catphish: depends on the input data
[15:24:12] catphish: sometimes it's much more convenient being able to instantize a get request directly, other times it's annoying :)
[16:40:39] catphish: Quit: Leaving


[13:30:26] catphish: has joined #ruby
[13:31:10] catphish: is it practical to use a SIGCHLD handler to reap terminated child processes? i was thinking of doing so, but i have a million concerns about race conditions
[13:32:02] catphish: specifically, what happens if a signal arrives during a signal handler execution? will it queue another one?
[13:33:16] catphish: someone writes "pending signals of the same type are not queued", so i'm not sure how this could be used :(
[17:08:54] catphish: ruby 2.6 is cowardly >> RangeError (cannot convert endless range to an array)
[17:28:44] catphish: havenwood: that works :D
[17:45:27] catphish: Quit: Leaving


[03:41:18] catphish: has left #RubyOnRails: ("Leaving")


[00:19:24] catphish: is the behaviour of modifying an array while iterating over it defined?
[00:19:57] catphish: has left #RubyOnRails: ("Leaving")
[00:22:06] catphish: looks like i should probably use Array#delete_if to iterate and allow me to delete items at the same time
[11:45:18] catphish: has joined #RubyOnRails
[13:25:56] catphish: i have a rails process that i'd like to fork to run tasks, is there any way to avoid needing to close database conneections prior to forking? i assume not, but i can see it being a bit messy having to shut down the database connections and reconnect for every fork :( thought i'd ask if there is any standard solution to this
[13:26:52] catphish: it seems to me that one can't reliably close the connection post-fork without risking interruption to the connection in the parent
[13:47:30] catphish: has left #ruby: ("Leaving")
[13:47:31] catphish: has left #RubyOnRails: ("Leaving")
[13:47:35] catphish: has joined #RubyOnRails
[18:46:09] catphish: we weren't able to find a sane way to use it in our environment
[19:15:25] catphish: nickjj: yeah i don't remember the details, but i recall it related to the interaction between development, test, and production environments


[22:19:08] catphish: has joined #ruby
[23:09:36] catphish: AndreYuhai: you want a human for that
[23:13:14] catphish: has joined #RubyOnRails


[14:57:01] catphish: has joined #ruby
[14:57:43] catphish: i'm a little confused, i found some documentation that states that Process.setproctitle will change a process name, but when i use it, it seems to instead change the cmdline
[14:57:59] catphish: which is correct? has this behaviour changed?
[14:59:00] catphish: oh, i'm quite certain it changes the cmdline on linux, the documentation was on OSX
[14:59:11] catphish: jhass: yeah you're right, thanks
[14:59:40] catphish: i'm quite happy with the cmdline behaviour, it shows up in process lists and isn't truncated as process names are
[16:36:31] catphish: has left #ruby: ("Leaving")


[13:34:20] catphish: has joined #ruby
[13:34:50] catphish: feature request (unless it already exists): the ability to defer signal handlers until the end of a block
[13:35:40] catphish: defer_signals {dont_interrupt_this; or_this};
[13:36:10] catphish: i assume one could create this manually by setting up and tearing down signal handlers as needed
[13:36:43] catphish: maybe not very thread safe :(
[14:32:22] catphish: darix: defer processing of it until after the block :)
[14:33:00] catphish: it makes sense that the signals to defer would be selectable
[14:46:46] catphish: darix: i rarely find that to be the case
[14:47:29] catphish: the most common signal my applications will see is TERM, and i don't necessarily want a process to exit until it's finished something critical
[14:48:03] catphish: other signals are just used to trigger things, and again i may not want them to happen instantly
[14:49:40] catphish: darix: that's what i usually do, yes, but it would be nice to abstract that
[16:07:10] catphish: one should definitely learn event driven coding
[16:07:20] catphish: no idea about that course :)
[16:29:20] catphish: has left #ruby: ("Leaving")


[14:23:01] catphish: has joined #ruby
[15:45:46] catphish: has left #ruby: ("Leaving")


[12:26:33] catphish: has joined #RubyOnRails
[12:26:55] catphish: what is the correct method on an AR association to check for count==0?
[12:27:29] catphish: actuall, looks like empty? is the answer
[12:39:16] catphish: TvL2386: people like their helper methods :)
[12:39:49] catphish: TvL2386: in that case you might want to consider changing to use any? and empty?
[12:40:11] catphish: counting all the entries will be slower
[12:40:49] catphish: yes, it does a select with a limit 1, so it only counts up to one entry
[12:41:16] catphish: means the database (with mysql at least) only has to pull entry instead of all of them
[12:41:24] catphish: *one entryy
[12:41:59] catphish: i always use .any? but i wasn't sure if there was an opposite method
[12:42:04] catphish: seems like .empty? does it :)
[13:28:54] catphish: has left #RubyOnRails: ("Leaving")


[10:52:22] catphish: has joined #ruby
[10:54:13] catphish: i'm trying to stream a large quantity of data to a command using net::ssh, struggling to find an example, does anyone happen to know how to do this?
[10:56:58] catphish: Net::SSH::Connection::Channel#send_data buffers data to be sent to the channel, which is perfect, but i don't see a callback to let me know when more data is wanted
[10:57:21] catphish: no, i want to send data to its stdin
[10:57:56] catphish: well the problem is that i don't want to buffer all the data in RAM at once
[10:58:05] catphish: so i want to send a chunk any time the buffer gets empty
[10:58:39] catphish: so i want to send a chunk, wait for it to clear, then send more
[10:59:13] catphish: i assume things like net::sftp do this somehow
[11:01:49] catphish: all the examples i find are just sending really small amounts of data all at once to Net::SSH::Connection::Channel#send_data
[11:05:40] catphish: ah got it, looks like i can monitor Net::SSH::Connection::Channel#output which is the output buffer on each invocation of #on_process
[11:51:45] catphish: yep that works fine :)
[11:52:15] catphish: ch.on_process { |ch| if ch.output.content.bytesize < n ... }
[16:17:38] catphish: Quit: Leaving


[15:13:16] catphish: has joined #ruby
[15:14:19] catphish: is there likely to be any way i can store an integer variable directly in a mmap'd file with ruby?
[15:15:11] catphish: i guess i can make a wrapper that at least makes it look like that's what's happening but uses pack/unpack behind the scenes
[15:23:42] catphish: actually even mmap itself isn't marvellously implemented, i'll go back to normal file operations, will check out msgpack
[15:24:02] catphish: all i want to do is keep a (constantly changing) number in a file
[15:26:18] catphish: everything is an array of bytes though!
[15:27:50] catphish: that's kind of the point of using a file
[15:28:17] catphish: a later question i have is when i actually want to sync the data to disk
[15:29:55] catphish: the first question was really just how to constantly synchronize a number from ruby-land into a file
[15:30:15] catphish: probably no harm in having a value=(n) method that does a pack, seek, write
[15:30:28] catphish: but i was trying to be cool
[15:31:32] catphish: the use case of this is to store a pointer to a location in another file, and i just realised it might not be necessary at all... i know where i am in the other file because i'm always at the end of it
[15:33:02] catphish: the UNHRC outlawed that
[15:41:30] catphish: havenwood: mostly incremented by 1
[15:42:52] catphish: havenwood: i was gonna go with 128 bit because why not, it's going to consume a whole disk block anyway :)
[15:43:30] catphish: but after some thought i'm worried about syncing the pointer file and the data at the same time
[15:44:17] catphish: since i always write the end of the data file, its probably better to calculate the sequence number simply by seeking to the end of the data file
[15:44:57] catphish: interesting
[15:46:03] catphish: the goal here is to collect some data, simultaneously write it to a journal file, and sent it to network clients along with a location integer, if a client connection is lost, it can reconnect and resume from the last location it received
[15:47:02] catphish: so i think i can just open the file at startup with O_APPEND, check the seek location, divide it by my block size, and that's my sequence number
[15:48:17] catphish: 64 is pretty long, but not as long as an ip address :(
[15:49:03] catphish: we need 128 bit CPUs immediately :)
[15:49:39] catphish: Alec: maybe i just don't like the state of the world, but what imply you?
[15:52:02] catphish: i had assumed that if i sync'd every write before i transmitted it i'd be good :(
[15:52:44] catphish: but in all honesty, it doesn't matter, in the case of a crash, data's being lost constantly because it's not being collected at all, so a few missed items in the journal is meh
[15:53:30] catphish: the aim is more to allow clients to come and go at will and catch up, when they come back
[15:53:50] catphish: if the server crashes, data is guarenteed lost
[15:54:40] catphish: also, seriously, what's the point in having sync if it doesn't block until the data hits the physical disk?
[15:55:01] catphish: or at least some hardware that acks the write like a BBWC
[15:55:20] catphish: ACTION cries
[15:55:33] catphish: i'm not sure D means what you think it means
[16:00:35] catphish: thanks Alec and all for being mighty fine rubber ducks <3
[16:40:27] catphish: Quit: Leaving


[14:15:06] catphish: has joined #ruby
[14:15:34] catphish: does ruby cache references to classes? in particular does it cache them inside other classes?
[14:16:16] catphish: i have an odd situation where 2 different classes are both calling "User" but are referencing different classes
[14:17:00] catphish: no, it's the same class, but a different version of it, it was releaded at some point
[14:17:16] catphish: but different parts of the code are now seeing different versions of it
[14:17:31] catphish: "because rails"
[14:18:01] catphish: rails has some magic that reloads classes between requests, but i'm trying to work out why some old versions are still being referenced
[14:18:12] catphish: i am also sorry :)
[14:19:18] catphish: so i suppose my question is why in one class, User would reference one class and on another it would reference a different class, i assime there's a leven of caching somewhere that rails isn't invalidating
[14:21:12] catphish: that would be correct
[14:22:33] catphish: except that even referencing it as SomeClass i get different results depending on where it's called
[14:22:37] catphish: it's very odd
[14:23:17] catphish: no, i suppose they're not
[14:23:41] catphish: but they should end up looking in the "root" namespace i thought
[14:24:20] catphish: i'm not sure how to tell
[14:24:32] catphish: but yes, it certainly seems like that's what's happened
[14:26:06] catphish: i'll ask the rails channel i guess
[14:26:12] catphish: has joined #RubyOnRails
[16:04:48] catphish: has left #ruby: ("Leaving")
[16:04:49] catphish: has left #RubyOnRails: ("Leaving")


[14:45:47] catphish: i don't think net/ssh itself has the agent "server"
[14:46:32] catphish: i suspect what i'll end up doing instead is just automating the configuration of private keys on each server and distribution of the public keys as needed
[14:46:59] catphish: cdunklau: that's not a bad idea actually, as long as i can spawn a unique agent for this purpose, and somehow forward to it
[14:47:51] catphish: "ssh-add -" seems to work
[14:48:09] catphish: but i don't know how to spawn an agent, and forward to the right agent
[14:48:52] catphish: nope, all automated
[14:49:47] catphish: i have an existing management system that connects to several servers and manages them in various ways, and now i want to be able to create an ssh connection *between* 2 of those servers
[14:49:57] catphish: the key isn't encrypted in memory
[14:53:31] catphish: cdunklau: you just give it a private key
[14:53:51] catphish: for a start, the private key includes the public key, or the information needed to generate it
[14:55:55] catphish: to clarify, if you run "ssh-add -" it accepts a private key from stdin
[14:58:08] catphish: i'll try that, thanks
[14:59:23] catphish: looks like that might work, just need to make sure i don't spawn lots unnecessarily
[15:00:56] catphish: this may also allow me to prevent duplicates
[15:01:02] catphish: if the socket is there i can just use it
[15:01:24] catphish: the app can just start it the first time it's needed then check the socket is available
[15:02:23] catphish: thanks! i'll get something coded
[15:05:27] catphish: i have an existing management system that connects to several servers and manages them in various ways, and now i want to be able to create an ssh connection *between* 2 of those servers
[15:05:45] catphish: the purpose is to cause one to tar/rsync/some kind of backup to another
[15:05:53] catphish: without needing to manually configure trust in advance
[15:09:08] catphish: *separate key on each backup server
[15:09:08] catphish: but there are several backup servers, and servers can be provisioned at any time, so having a separate private key on each management server and adding that to all the other servers seemed like an unwanted step, when the management server can just authorize each action
[15:09:08] catphish: in fact that's the way i've written it
[15:09:08] catphish: same number of hosts
[15:10:16] catphish: i see your point
[15:10:31] catphish: it would actually complete fine if the management server went away
[15:10:50] catphish: but the management server wouldn't know :(
[15:11:47] catphish: i don't really want to complicate it too much
[15:12:21] catphish: it would be cool to have a daemon on the backup server that is asked to do a backup, and monitors the success, then the management server could just check on progress
[15:12:35] catphish: but that's rather more complicated than just running one ssh command and watching the output
[15:13:01] catphish: and these backups are quite small, not like whole system backups, just shared hosting sites
[15:13:21] catphish: thanks for all the suggestions though, lots of things to try
[15:26:00] catphish: Quit: Leaving