b100s

Activity Graph

Page 1 of 1

2018-06-01

[06:40:36] b100s: has joined #ruby
[06:41:07] b100s: hi2all; is there reason to use return? e.g. `def foo return 'foo' end;` or `def foo 'foo' end`.
[19:10:43] b100s: Remote host closed the connection

2018-05-10

[05:35:07] b100s: Hi2all! I try to calculate sha256 on fly for file and got out of memory. How can I read ny chunks and avoid keep all file in memory? My gist is here: https://gist.github.com/b10s/3bdfee3cbf52de1c2dcec645ea2be1e3
[05:47:51] b100s: havenwood, thanks, what about Tempfile, can I avoid using it in my webserver?
[05:48:15] b100s: I would like to not rely on disk and just calculate everything on fly
[05:49:44] b100s: in gist : )
[05:50:09] b100s: havenwood, everything in the gist file; I do not know other way to upload files in ruby
[05:50:37] b100s: So, I need to create File and somehow get stream from sinatra?
[05:59:29] b100s: havenwood, heh, you can try on your local and be sure it is not : )
[05:59:43] b100s: I mean my gist
[06:01:52] b100s: havenwood, yeah, don't worry
[06:02:08] b100s: havenwood, I mean this one https://gist.github.com/b10s/3bdfee3cbf52de1c2dcec645ea2be1e3
[06:10:01] b100s: havenwood, How did you run app and how did you send request?
[06:13:04] b100s: havenwood, sorry, try 'curl -v -F "file=@/tmp/output3.dat" localhost:4567/save_image'
[06:13:10] b100s: I didn't put port
[06:14:15] b100s: then try any random existed file : )
[06:15:06] b100s: few gigs to fill how app eat mem
[06:15:21] b100s: s/fill/feel/
[06:15:30] b100s: s/eat/eats/
[06:17:34] b100s: and try to looks at out of ps during the uploading
[06:19:55] b100s: yeah, it will
[06:20:23] b100s: and last thing which I would like to avoid is saving to the disk temp file
[06:23:52] b100s: I belive you can read stream without keep it in mem
[06:24:52] b100s: havenwood, reading stream byte-by-byte or line-by-line allow us do not save it to disk and do not keep it in mem
[06:25:17] b100s: baweaver, what do you mean by lazy ?
[06:25:43] b100s: havenwood, do you know how to avoid creating ? : )
[07:53:15] b100s: havenwood, thanks, will check it
[08:52:02] b100s: Remote host closed the connection

2018-05-08

[05:31:51] b100s: has joined #ruby
[05:32:02] b100s: hi2all! what is the best way to validate URL ?
[07:14:48] b100s: I have sinatra app. Is there way to write destructor when app stops ?
[14:00:48] b100s: Remote host closed the connection
[14:01:13] b100s: has joined #ruby

2018-04-04

[10:15:59] b100s: *.net *.split

2018-03-28

[04:45:41] b100s: Hey! What could be the reason of the next error in my simple sinatra app? https://gist.github.com/b10s/c3c5351854f866376461610d1d49463d
[04:59:00] b100s: havenwood, thx, how could I check my version of puma ?
[04:59:28] b100s: because I have two environment and one of them is ok, another is not : (
[05:00:05] b100s: yeah, error message includes path to the bad puma : )
[05:00:12] b100s: let me check good one by myself
[05:03:14] b100s: hm, it was the same puma version, strange
[05:07:03] b100s: havenwood, is there something what I could use instead puma ? something interchangable
[05:08:41] b100s: havenwood, taking in mind that I didn't mention puma in my snippet, how could I start use Unicorn ? : )
[05:14:37] b100s: Sinatra (v2.0.1) has taken the stage on 4567 for development with backup from Puma== Sinatra (v2.0.1)
[05:15:09] b100s: after cahnge 'puma' to 'unicorn' in Gemfile, remove Gemfile.lock and run `bundle` ^ ^
[05:18:09] b100s: havenwood, "bundler: command not found: unicorn" even after `bundle install`
[05:18:23] b100s: I try to run exactly the same code as in snippet
[05:18:28] b100s: so, it is sinatra app
[05:23:05] b100s: Yup, Gemfile.local has unicorn but there is no puma;
[05:23:08] b100s: havenwood, https://gist.github.com/b10s/c7d1a877beffdcd5fb84b5822f863460
[05:23:18] b100s: looks like unicron still not installed : (
[05:25:42] b100s: sorry, it was a typo in `gem install unicorn'
[05:26:15] b100s: https://gist.github.com/b10s/d81807615297b8fc3d478ee82be1fd58
[05:26:34] b100s: fun story, there is also exists unicron : )

2018-03-27

[04:01:56] b100s: has joined #ruby
[04:05:16] b100s: Hello! Probably simple question: could I force Sinatra to listen on multiple IPs or/and ports ?
[04:15:31] b100s: baweaver, could I run multiple "apps" in one server like `my_app = Sinatra.new { get('/') { "hi" } } my_app.run!`, so each will listen to different IP and port ?
[04:16:33] b100s: baweaver, noted, nginx is not my current case, unfotunately
[04:17:39] b100s: baweaver, I have app which runs inside cloud like bluemix, so I'm not able to change anything aside my app
[04:18:00] b100s: I have two interfaces and have to listen to them for handle different requests

2018-03-26

[01:53:33] b100s: has left #ruby: ("Leaving")

2018-03-23

[04:22:42] b100s: has joined #ruby
[04:23:23] b100s: hi2all; is it possible to have one endpoint for one net interface and another for second net interface in one ruby sinatra app ?
[06:03:42] b100s: havenwood, thanks: ) by the way, is it possible to get source IP of request ?

2018-02-19

[05:39:58] b100s: has left #ruby: ("Leaving")

2017-12-26

[00:15:51] b100s: Quit: Leaving

2017-12-23

[09:37:18] b100s: has joined #ruby
[09:38:33] b100s: hi2all; I've got error: `Mysql2::Error - Lost connection to MySQL server during query`. My app has two threads: one sleep and do query to mysql, another one is main thread - listen for http query and do sql query; What could i do to avoid such errors?

2017-12-19

[06:58:14] b100s: has joined #ruby
[07:02:26] b100s: what is better? https://gist.github.com/b10s/766d95419ddc7820023862e89ffcbdee
[07:24:04] b100s: i mean, what is better to have as last stament of function: `return body.is_a?(Hash) ? body['foo'] : nil` or `body['foo'] rescue nil` ?
[07:31:54] b100s: @pwnd_nsfw, could you explain why?
[07:36:25] b100s: @pwnd_nsfw, thanks! @apeiros , why would you choose first?
[07:42:19] b100s: apeiros, thanks
[09:12:24] b100s: Quit: Leaving

2017-11-29

[05:22:45] b100s: has left #ruby: ("Leaving")

2017-11-27

[06:11:35] b100s: has joined #ruby
[06:13:24] b100s: hi2all; what if i want to call from class' method a function, which is decribed in the same namespace? is it possible? or everything described in the same namespace will be either class method or instance one?
[06:39:26] b100s: is it possible to share var in threads?
[06:59:57] b100s: dminuoso, i'm going to use http://ruby-doc.org/core-2.0.0/Thread.html#method-i-5B-5D for return some values from immortal thread to mortal one
[07:00:13] b100s: looks like it shouldn't be error prone
[07:00:59] b100s: dminuoso, what do you mean by that?
[07:01:19] b100s: dminuoso, i mean in my context of http://ruby-doc.org/core-2.0.0/Thread.html#method-i-5B-5D
[07:01:34] b100s: in general i understand what is 'thread safe'
[07:03:28] b100s: dminuoso, yup, it is for 2.0.0 (part of link: http://ruby-doc.org/..>>core-2.0.0<<...
[07:03:57] b100s: dminuoso, no
[07:04:50] b100s: 2.3.3 is ok?
[07:04:51] b100s: dminuoso,
[07:05:17] b100s: here you go: http://ruby-doc.org/core-2.3.3/Thread.html#method-i-5B-5D

2017-11-19

[11:59:30] b100s: has joined #ruby
[12:00:54] b100s: hi2all; i have file task and task 'foo'; i want task foo to always recreate that file using file task but it not creates file in case file already exists : ( is there way to re-create file always?
[12:10:37] b100s: Remote host closed the connection

2017-11-15

[07:48:08] b100s: Remote host closed the connection

2017-11-14

[00:31:38] b100s: has joined #ruby
[00:33:32] b100s: hi2all; i have structure like that: `h={:foo=>{:sid1=>[1, 1, 1], :sid2=>[2, 2, 2]}, :bar=>{:sid1=>[3, 3, 3], :sid2=>[4, 4, 4]}}` hash.hash.arr; i would like to get all array elements by key of first hash, e.g.: y=0; h['foo'].values.each { |x| y+=x }; y # => 9
[00:33:47] b100s: but my example is wrong
[00:34:23] b100s: this one is wotk: `y=0;h[:foo].values.each { |x| x.each {|xx| y+=xx} }; y` but i expext something more obvious and easy
[00:39:47] b100s: baweaver, RickHull, looks likes `h[:foo].values.flatten` is enough
[00:43:56] b100s: RickHull, haven't get you
[00:44:34] b100s: `y=0; h[:foo].values.flatten.each {|x| y+=x }; y` everything work good;
[00:44:51] b100s: or are there any caveates?
[00:45:49] b100s: it will be great, but actually i need just get them - all elements of arrays of hashes
[00:45:58] b100s: actual action is not sum for me : )
[00:46:51] b100s: iteration by first level hash by keys is necessary as well
[00:47:06] b100s: so, looks like everything what i want is here
[00:47:09] b100s: thanks a lot
[00:47:32] b100s: flatten - is actually was what helped me

2017-11-13

[05:40:48] b100s: has joined #ruby
[05:41:49] b100s: hi2all; is there autovivification for hashes? i want to do next: `foo={} foo['x']['y']=1 foo # => {"x"=>{"y"=>1}}
[05:50:16] b100s: baweaver, thanks
[09:57:25] b100s: Quit: Leaving

2017-11-10

[01:42:44] b100s: has joined #ruby
[01:44:04] b100s: hi2all; is it safe to use something like this http://paste.org.ru/?t231gw in web-app to do some periodic job?
[01:49:42] b100s: RickHull, it's going to execute forever, every let's say few hours; tracking errors - is good thought, i didn't think about it yet; defenetly it is not critical job and in case of fail i will just write some err message in log and let main thread to do it's main job as before
[01:50:14] b100s: RickHull, what is important, in my opinion, it's shared database object
[01:51:03] b100s: i'm not sure which way should i use it; if i do use it and in the same momen main thread will use it... some strange things may happens
[01:51:31] b100s: RickHull, i have some instance of class which do http requests to DB
[02:05:57] b100s: RickHull, yep, thanks
[10:55:06] b100s: Remote host closed the connection

2017-11-07

[01:52:09] b100s: has joined #ruby
[01:52:25] b100s: hi2all! when i do `puts 'hello'` i send message puts to self object isn't it? but when i do it explicitly `self.puts('hello')` it doesn't work. Why?
[02:03:37] b100s: elomatreb, RickHull thanks! in well-grounded rubies, second edition, said: `Here, in spite of the lack of a message-sending dot and an explicit receiver for the message, we’re sending the message puts with the argument "Hello." to an object: the default object self. There’s always a self defined when your program is running, although which object is self changes, according to specific rules.`
[07:42:16] b100s: Quit: Leaving

2017-10-17

[09:27:35] b100s: has joined #ruby
[09:28:10] b100s: what's wring with second example? why ther re only 2 elems? expected all three http://paste.org.ru/?fektyg
[09:33:25] b100s: matthewd, why? there is syntax which allow me to say left and right border of indexes like [0..2]
[09:34:02] b100s: matthewd, https://ruby-doc.org/core-2.2.0/Array.html#class-Array-label-Accessing+Elements
[09:34:14] b100s: arr[2, 3] #=> [3, 4, 5]
[09:37:56] b100s: tobiasvl, yes, [0,2] actually all array; but i've gotten only 2 elems
[09:38:06] b100s: need all using syntax [0,2]
[09:39:16] b100s: sorry, thanks; yes, my wrong
[09:39:18] b100s: pair of arguments (start and length)
[09:58:28] b100s: Quit: Leaving