RedNifre

Activity Graph

Page 1 of 4 | Next »

2018-12-16

[09:03:04] RedNifre: Ping timeout: 264 seconds
[09:05:05] RedNifre: has joined #RubyOnRails
[09:05:05] RedNifre: has joined #ruby
[16:10:46] RedNifre: Ping timeout: 260 seconds

2018-12-15

[01:21:31] RedNifre: Ping timeout: 250 seconds
[09:04:00] RedNifre: has joined #RubyOnRails
[09:04:00] RedNifre: has joined #ruby

2018-12-14

[16:07:42] RedNifre: has joined #ruby
[16:07:50] RedNifre: has joined #RubyOnRails
[16:08:57] RedNifre: hey there, I'm new to rails. When I run `rails test` in the Cloud9 IDE it first runs the tests as expected but follows it with a lot of output, something about tmux (which isn't even installed) and many .rb files. Why is that?
[16:09:42] RedNifre: so it outputs the expected statistics of how many tests worked or failed, followed by /usr/local/rvm/gems/ruby-2.4.1/gems/notiffany-0.1.1/lib/notiffany/notifier/tmux/client.rb:12:in `version': undefined method `[]' for nil:NilClass (NoMethodError)
[16:10:38] RedNifre: I guess it wants to notify in tmux but fails because there is no tmux? Can I tell it to run the tests without a notification when they are done?
[16:39:39] RedNifre: never mind, just installing tmux fixes it.

2018-12-07

[11:10:05] RedNifre: has joined #ruby
[11:10:06] RedNifre: has joined #RubyOnRails
[11:28:39] RedNifre: Ping timeout: 252 seconds
[11:29:46] RedNifre: has joined #RubyOnRails
[11:29:46] RedNifre: has joined #ruby
[11:43:06] RedNifre: Ping timeout: 260 seconds
[12:11:27] RedNifre: has joined #RubyOnRails
[12:11:27] RedNifre: has joined #ruby
[12:28:01] RedNifre: Ping timeout: 260 seconds
[13:57:30] RedNifre: has joined #RubyOnRails
[13:57:30] RedNifre: has joined #ruby
[14:55:01] RedNifre: Ping timeout: 260 seconds
[15:21:16] RedNifre: has joined #RubyOnRails
[15:21:16] RedNifre: has joined #ruby
[15:28:52] RedNifre: Ping timeout: 264 seconds
[16:56:08] RedNifre: has joined #ruby
[16:56:09] RedNifre: has joined #RubyOnRails
[20:56:15] RedNifre: Ping timeout: 252 seconds
[21:25:47] RedNifre: has joined #RubyOnRails
[21:25:47] RedNifre: has joined #ruby
[21:32:05] RedNifre: Ping timeout: 250 seconds

2018-12-06

[19:32:05] RedNifre: has joined #ruby
[19:32:37] RedNifre: has joined #RubyOnRails
[19:33:24] RedNifre: What's a good way to learn Rails if you have medium knowledge of web frameworks and ruby?
[19:55:30] RedNifre: I learned ruby because I needed to do some simple things.
[19:55:40] RedNifre: So far I only used it for small to medium sized things.
[19:56:06] RedNifre: E.g. a Jira automation, some raspberry Pi LED blinking stuff, some media ingest etc.
[19:58:31] RedNifre: Yeah, I noticed that even though I never learned Ruby properly it's still my go to language for getting something simple done quickly. So I wondered if I should give it a closer look regarding doing large things with it, hence Rails.
[19:59:10] RedNifre: (Usually I use heavy weight statically typed languages for larger things)
[20:09:31] RedNifre: it basically replaced bash for me completely, especially since you can write `inline bash like that`
[21:23:51] RedNifre: Ping timeout: 252 seconds

2018-10-30

[01:16:34] RedNifre: Ping timeout: 272 seconds
[01:19:05] RedNifre: has joined #ruby
[01:19:51] RedNifre: Client Quit
[14:40:37] RedNifre: has joined #ruby
[18:33:49] RedNifre: Quit: everything is great

2018-10-29

[23:49:43] RedNifre: What happens when you launch ruby files with the interpreter? Does it parse individual files lazily when it encounters a require? I have a version of my script running and it's currently crawling something, but I'd like to continue working on it... I gues the interpreter doesn't mind if I edit the file since it only reads it once on startup, right?
[23:51:13] RedNifre: oh, never mind, the crawling just finished :o)
[23:51:20] RedNifre: But thanks :)

2018-10-28

[22:27:21] RedNifre: Is there a neater way to do BigDecimal.new("123.45") ?
[22:41:53] RedNifre: Ping timeout: 250 seconds
[22:42:19] RedNifre: has joined #ruby

2018-10-22

[00:05:53] RedNifre: Ping timeout: 245 seconds
[08:06:08] RedNifre: has joined #ruby

2018-10-21

[19:28:21] RedNifre: has joined #ruby
[19:29:02] RedNifre: Hey there. What's the idiomatic ruby way for tail -f somefile | ruby somescript.rb?
[19:37:46] RedNifre: Basically I want to only read new lines as they are added to a log file.
[19:40:48] RedNifre: hmmm, looks somewhat complicated.
[19:41:39] RedNifre: I wonder if there's a simpler `tail -f bla | ruby bla.rb` solution.
[20:45:47] RedNifre: Ping timeout: 240 seconds
[20:48:02] RedNifre: has joined #ruby
[21:40:31] RedNifre: Well, given that I'm rewriting my big ball of mud code to clean it up I guess I should do the proper 'select' solution
[21:41:36] RedNifre: You see, historically I used ruby to write tiny ugly prototypes and when it got too messy I rewrote it in a different language, but now I'm trying to do it properly in ruby (because I couldn't find a better scripting language)
[21:58:48] RedNifre: Read error: Connection reset by peer
[22:04:50] RedNifre: has joined #ruby

2018-10-18

[08:26:31] RedNifre: has joined #ruby
[10:25:27] RedNifre: Ping timeout: 268 seconds
[11:45:59] RedNifre: has joined #ruby
[15:25:25] RedNifre: Ping timeout: 250 seconds
[15:34:32] RedNifre: has joined #ruby
[16:58:53] RedNifre: Ping timeout: 268 seconds
[17:41:43] RedNifre: has joined #ruby
[19:05:51] RedNifre: Ping timeout: 252 seconds

2018-09-17

[17:11:12] RedNifre: has joined #ruby
[17:12:49] RedNifre: Hey, I'm doing "Quit script with ctrl+c" wrong and I don't know how to do it properly :(
[17:13:39] RedNifre: See, I have this script that is continually processing a log file. When I quit it with ctrl+c it should write its state to a yaml file. This worked on linux, but on cygwin it seems to be killed too quickly sometimes so the file ends up empty.
[17:13:58] RedNifre: What I did was begin ... ensure write_to_file end
[17:14:14] RedNifre: ...and the ensure part seems to get killed sometimes before the file gets written.
[17:14:54] RedNifre: So I guess I'm doing "quitting the script" the wrong way... what's the proper way to quit a script and let the script save its state to a file?
[17:15:01] RedNifre: I... might be I guess? Hang on...
[17:15:46] RedNifre: The code is really begin (process log file by reading from STDIN) ensure (Save to yaml file) end
[17:16:26] RedNifre: It often works, but often doesn't and I either end up with an empty file or the file doesn't get updated at all... let me look up SIGINT...
[17:17:12] RedNifre: What was the semantic of pressing ctrl+c again? Was it "quit immediately!" or was it "take your time"?
[17:18:02] RedNifre: Okay, but conceptually speaking, what's the propper way to shut down a script that is continually processing lines from STDIN?
[17:18:43] RedNifre: Okay, it does say Interrupt when I quit it.
[17:19:41] RedNifre: Is there a key combination for "shut down, take all the time you need"?
[17:20:17] RedNifre: I mean, am I wrong to stop the script with ctrl+c or should the script signal "got you, give me a moment" to the OS?
[17:20:34] RedNifre: Well, I'm running the script in Cygwin so I was hoping I wouldn't have to deal with Windows specifics.
[17:20:50] RedNifre: So ctrl+\ is a more relaxed "quit"?
[17:21:49] RedNifre: I'm not sure it's even the right approach... I mean, how do you implement scripts that process a stream but can also be interrupted and save their state?
[17:22:43] RedNifre: Well, it handles stdio throug tail -f somefile.log | ruby thescript.rb
[17:22:53] RedNifre: ...so I can't tell it q I think.
[17:25:09] RedNifre: Well, it sounds like SIGINT is "terminate gracefully" so I'm surprised that it gets killed so quickly that it sometimes can't even write a small yaml file.
[17:26:51] RedNifre: I'm not sure if I'm correctly trapping SIGINT, it's really just `begin ... ensure (write to file) end`
[17:27:26] RedNifre: ACTION looks up how to correctly trap SIGINT int ruby...
[17:29:19] RedNifre: Well, what exactly does "ensure" do in this case? does it first tell the OS "I don't care, do what you must!" and then tries to run the following code whereas `rescue Interrupt` would tell the OS "I'm hearing you, give me a sec here!"?
[17:32:47] RedNifre: Well, it feel like "ensure" kinda sees the "exception" but does not "catch" it so the OS doesn't know that the script is trying to do something... if I understand it correctly then `begin ... rescue SystemExit, Interrupt ... end` should work instead.
[17:37:53] RedNifre: Well... It's just that I have the script running locally on my machine, I want to quit it easily and I want it to continue where it left off when I start it again, so it should save its state when I quit it.
[17:38:24] RedNifre: I'll see if it works now...
[20:28:52] RedNifre: Ping timeout: 272 seconds
[21:31:40] RedNifre: has joined #ruby
[21:45:42] RedNifre: Ping timeout: 252 seconds
[21:50:52] RedNifre: has joined #ruby
[22:06:30] RedNifre: Ping timeout: 252 seconds
[22:19:13] RedNifre: has joined #ruby
[22:26:02] RedNifre: Ping timeout: 272 seconds

2018-08-22

[00:41:18] RedNifre: Ping timeout: 264 seconds
[08:48:49] RedNifre: has joined #ruby
[08:58:42] RedNifre: Ping timeout: 264 seconds

2018-08-21

[19:56:28] RedNifre: has joined #ruby
[19:56:39] RedNifre: Good evening.
[19:56:56] RedNifre: What's the simplest way to send a tweet from a script?
[19:57:43] RedNifre: darix I looked at those, they look pretty heavy weight... I just want to send tweets, nothing more... so there is no simpler way than to get one of those huge libraries?
[19:58:00] RedNifre: oh well, heavy twitter gem it is then.
[19:58:44] RedNifre: hm, I guess once you handled oauth and all that, just doing a "you can send tweets" library with that feels like wasted work :)
[20:35:40] RedNifre: Ping timeout: 252 seconds
[20:46:31] RedNifre: has joined #ruby

2018-08-20

[16:10:41] RedNifre: has joined #ruby
[16:12:26] RedNifre: It's a bit weird, but `tail -f some.log | ruby somescript.rb` where somescript.rb does `$stdin.each_line do |line|` seems to hang somehow... am I doing this right?
[16:13:25] RedNifre: ...to be precise it's actually `tail -f some.log | somesedinabashscript | ruby ...`
[16:14:28] RedNifre: so, my question is: why does it seem to hang on $stdin.each_line even though I pipe lines into it?
[16:16:13] RedNifre: some people on the internet says that it buffers 20 lines for them... hm...
[16:19:54] RedNifre: hang on, I'll make sure...
[16:26:06] RedNifre: tatsache, es haengt irgendwie am sed fest... seltsam
[16:26:36] RedNifre: oops, sorry
[16:26:53] RedNifre: indeed, it somehow hangs in sed... weird
[16:29:13] RedNifre: guess I'll trash sed and do it all in ruby
[16:32:06] RedNifre: oh, does that api allow you to drive cars in space? or what does it do?
[16:54:08] RedNifre: I'm only doing hack jobs with ruby and I use vim, but many say rubymine is a good IDE
[17:39:17] RedNifre: Hm, still having problems, I cut it down to `tail -f some.log | grep -e "this" -e "that" | ruby myscript.rb` but the $stdin.each_line still seems to hang.
[17:39:45] RedNifre: I mean, if I remove the ruby part, I see each grep output line as they happen without any delay, line by line
[17:40:17] RedNifre: tail -f sends new lines as they are added to the log. that works. The grep part also works.
[17:40:29] RedNifre: Eiam it never triggers even once, that's the problem.
[17:43:07] RedNifre: I replaced the ruby script with a simple echo like `$stdin.each_line { |line| puts line }` but I still don't see any output.
[17:49:01] RedNifre: as2o3-cr no, never heard of that.
[17:49:12] RedNifre: Eiam yes, it works with cat
[17:49:30] RedNifre: Oh, I let the rubyecho running in background and I now have output. does it do batches?
[17:49:43] RedNifre: does STDIN.sync = true turn it into line based mode?
[17:51:37] RedNifre: oh, you mean its actually reading stuff, I just don't see it? okay...
[17:51:48] RedNifre: i thought puts was always somewhat instant.
[17:51:53] RedNifre: okay, I'll try...
[17:52:14] RedNifre: wait, al2o3-cr said STDIN.sync? Or both?
[17:59:24] RedNifre: well, i want live updates and the log doesn't change that often
[17:59:38] RedNifre: anyway, it still doesn't work, neither with STDIN nor STDOUT
[18:00:57] RedNifre: it works with `echo "hey" | ruby rubyecho.rb`, but I guess that's because it notices that the stream ends?
[18:02:11] RedNifre: Hang on, I think it's the grep
[18:03:06] RedNifre: When I do either `tail -f | grep...` or `tail -f | rubyecho` it works, but not with `tail -f | grep | rubyecho` so I guess that grep is buffering it? Hm.
[18:03:23] RedNifre: yeah, I don't want individual bytes, I want lines.
[18:03:55] RedNifre: Well, I don't understand why putting a grep between tail -f and the ruby script seems to buffer it, but I guess I can get rid of the grep and do it in ruby? Hm...
[18:04:13] RedNifre: I don't really understand the problem, but I guess I can solve it by going all ruby then ._.
[18:04:31] RedNifre: So you guys are doing tail -f | grep | ruby all the time without problems?
[18:09:01] RedNifre: Alright, it works. No idea what grep had to do with it. Thanks a lot!
[18:23:43] RedNifre: ah, thanks al2o3-cr, that seems to explain it!
[18:24:01] RedNifre: ...but it's too late, it's all ruby now anyway ;)
[18:45:02] RedNifre: Eiam because I thought I should give sed and awk a chance, lost motivation, so ruby slowly ate it all away.
[18:45:28] RedNifre: oh, right, i could even move the tail -f into the ruby script...
[18:46:30] RedNifre: don't worry, it's just a toy project just for myself, I won't outsource it to you...
[18:46:56] RedNifre: In this case, the philosophical "I" is just "me"
[18:47:06] RedNifre: no, I won't be using this thing in 2 years
[18:47:57] RedNifre: It's a moot point since it's just tail -f some.log | ruby myscript.rb now, I'm sure I'll figure the tail -f out in 2 years ;)
[21:30:26] RedNifre: hmmm... is there something special in regexes with "#"? I want to match "aoeh o9uoe#8o" so I try [\w #]+ or [\w \#]+ but something weird is happening...
[21:36:48] RedNifre: yeah, hmmmm...
[21:39:23] RedNifre: Yeah, I think like I might not understand regexes enough...
[21:40:33] RedNifre: The string looks somewhat like " 234 bla bleh blu#9e for " and my regex looks like / (\d+) ([\w# ]+) for / in the middle...
[21:41:22] RedNifre: It fails for something that looks like " 1 Bla Bleh#3y for "...
[21:45:17] RedNifre: Yeah... is # something special maybe?
[21:52:58] RedNifre: Never mind, it worked with #, the next problem is that numbers aren't actually d+,dd they have dots separating the thousands...
[21:53:13] RedNifre: rubular is extremely helpful, thank you very much!

2018-08-19

[00:13:43] RedNifre: Ping timeout: 260 seconds
[00:17:43] RedNifre: has joined #ruby
[00:38:49] RedNifre: Ping timeout: 244 seconds
[08:50:21] RedNifre: has joined #ruby
[17:28:32] RedNifre: Ping timeout: 276 seconds

2018-08-18

[21:20:50] RedNifre: has joined #ruby
[21:21:20] RedNifre: schnell geblickt!
[21:21:56] RedNifre: jedenfalls, I was wondering how to sort of do a command line stream script in ruby and how to get a result from it.
[21:22:21] RedNifre: Yeah, I tend to come back here... and to other channels.
[21:22:44] RedNifre: Anyway, I thought I should try out the old unix tools sed, awk, etc. but I'm not sure it's worth it.
[21:23:48] RedNifre: What I have right now is something that preprocesses a log on the fly, but I need to do some accumulation on it... i guess with ruby I would just pipe to the ruby script which would read from stdin... but since this is sorta infinite, where should I access the accumulated results?
[21:25:19] RedNifre: Say the log looks like "Bob bought 23 green bananas for $10,00 from you." and I already trimmed it down to "Bob 23 green bananas 10.00"... I want to accumulate the money for each purchase per item...
[21:25:48] RedNifre: Oh, wait, maybe I'm just thinking to complex here...
[21:26:20] RedNifre: I guess I'll just print the whole state of the script on every purchase so I'll always see the latest state when I look at the terminal window.
[21:26:34] RedNifre: That way, there is no "end" result.
[21:27:13] RedNifre: It's just a toy project from a game.
[21:27:22] RedNifre: I thought about this, too, but a database might be overkill.
[21:27:32] RedNifre: Sure, but hear me out.
[21:28:06] RedNifre: This is the situation: There is a game, in that game you can open virtual shops and you get chat messages when people buy or sell to your shop. The game logs the chat to a txt file.
[21:28:43] RedNifre: So my idea is to count what's in my shop when I log in, tell it to the script, and the script reads the chat log to keep the inventory tally updated.
[21:29:05] RedNifre: I considered it and my plan right now is to actually do both.
[21:29:23] RedNifre: however, the nature of the game makes all this very transient.
[21:29:44] RedNifre: i.e. when i log off people will still interact with the shop, which means the inventory count will diverge
[21:30:04] RedNifre: so what really matters is the inventory count when i log in plus all following chat messages
[21:30:26] RedNifre: it's not a serious professional system, it's just a tiny game that isn't even about shops
[21:31:19] RedNifre: I want to put all the messages in a sqlitedb anyway so i can easily figure out who my most frequent customers are etc. but the immediate goal is more transient.
[21:32:15] RedNifre: ...but that might get a bit too far off topic now... I guess I'll try piping the sed output into a ruby script and have it process it... it's just `gets`, right? For one line of stdin?
[21:32:27] RedNifre: (it's been a while since i last used ruby)
[21:32:52] RedNifre: Thanks, I'll see what happens...
[21:36:12] RedNifre: well, i tried `some sed stuff | ruby myscriptrb` and `gets` seems to return empty strings.
[21:37:12] RedNifre: I'm not familiar with the "different" stdin... where in the ruby script do the 5000 lines that get emitted by the sed stuff appear?
[21:38:21] RedNifre: To keep it simple I tried to write an echo command in ruby, just while true do line = gets; puts "got #{line}"; end, nothing too fancy.
[21:59:23] RedNifre: good night!
[21:59:37] RedNifre: and thanks for the help!
[22:19:36] RedNifre: hm, is there a decimal datatype? something for two decimal places?
[22:22:13] RedNifre: I need something for decimal numbers with two places, e.g. 10.00
[22:25:37] RedNifre: well, it's just for a game and precision is not that important... if i add 7000 numbers as floats, do I still have 2 decimals precision?
[22:25:51] RedNifre: (i'm pretty much clueless about numerics and accumulated errors...)
[22:29:35] RedNifre: yeah, but if i round to 2 places it's still correct
[22:31:26] RedNifre: okay, another thing, how do I do a hash where every entry kinda already exists with value 0.00 ? so I can just do myhash[some_previously_unknown_key] += some_amount ?
[22:31:50] RedNifre: ruby sure is simple :)
[22:42:07] RedNifre: well, it seems to work... is there a simple list to turn this into an ordered high score list like [["key34", 1000.00], ["key90", 980.00]...] ?
[22:42:47] RedNifre: sleepwalking?
[22:43:08] RedNifre: never mind, I'll figure it out...
[22:49:23] RedNifre: well, I did hashmap.to_a.sort { |a, b| a[1] <=> b[1] } instead
[23:40:27] RedNifre: weaksauce I finished it, I'm just writing some simple analytics script for a silly game.
[23:40:57] RedNifre: it's a game where you can build a shop and now I have a high score list of which player bought how much.

2018-05-12

[07:09:36] RedNifre: has joined #ruby
[07:30:24] RedNifre: Ping timeout: 260 seconds
[09:46:24] RedNifre: has joined #ruby
[10:11:09] RedNifre: Ping timeout: 264 seconds
[10:26:08] RedNifre: has joined #ruby
[11:42:32] RedNifre: Ping timeout: 246 seconds
[12:08:50] RedNifre: has joined #ruby
[12:18:57] RedNifre: Ping timeout: 240 seconds
[14:07:26] RedNifre: has joined #ruby
[14:35:52] RedNifre: Read error: Connection reset by peer
[14:49:18] RedNifre: has joined #ruby
[15:31:50] RedNifre: Ping timeout: 276 seconds
[16:19:10] RedNifre: has joined #ruby
[17:45:06] RedNifre: Ping timeout: 250 seconds
[17:56:57] RedNifre: has joined #ruby

2018-05-11

[16:32:36] RedNifre: has joined #ruby
[17:21:57] RedNifre: Ping timeout: 240 seconds
[17:31:47] RedNifre: has joined #ruby
[17:54:57] RedNifre: Ping timeout: 264 seconds
[17:59:48] RedNifre: has joined #ruby
[21:25:16] RedNifre: Ping timeout: 250 seconds