#ruby - 11 July 2018
« Back 1 day Forward 1 day »
[01:30:48]
arfy:
hi all... I'm having a bit of trouble finding an answer for ruby 2.5.1, I want to install ruby using the ruby installer in windows, but noted it doesn't come with any ri documentation for core ruby. is there a way to install this?
[03:53:07]
digimer:
hi all, I know very little about ruby, but I am trying to repackage an ruby RPM and hitting an error. I was wondering if anyone could help me understand it. - https://paste.fedoraproject.org/paste/U9x5ZhxIJEqLdkIb5BusWQ
[05:05:42]
digimer:
I'm learning packaging, and know basically nil about ruby. sorry if it's a 101 question
[05:06:14]
havenwood:
digimer: I just glanced over the logs, but that stood out. Everywhere else it's minitest 5. This one line it's minitest 4.
[05:06:48]
digimer:
odd, I grabbed the src.rpm from epel7, so it must have compiled in the past. odd
[05:30:40]
mikhael_k33hl:
regarding this file? https://gist.github.com/marzdgzmn/9d8173a0db527e54b5d2a9ec899c253c Is this wrapper gem something that wraps the export that will only be usable for ruby? I can't seem to see the exported variables in linux
[05:33:48]
havenwood:
mikhael_k33hl: You can only see env vars in the process they were created or a child process. A parent process can't get env vars from its child.
[05:34:47]
havenwood:
mikhael_k33hl: If you haven't already, take a look at exactly what the wrapper does: cat /usr/local/rvm/gems/ruby-1.9.3-p547/wrappers/ruby
[05:36:14]
mikhael_k33hl:
havenwood: isn't exporting making the variables an environment variables for linux itself?
[05:37:27]
mikhael_k33hl:
havenwood: Oh I see now, the variables were exported in the ruby environment
[05:38:35]
havenwood:
mikhael_k33hl: Exporting means child processes will inherit the variable. There's no way to have the child assign a variable on the parent.
[05:40:01]
mikhael_k33hl:
havenwood: I see. I'm still a little bit confused about it though as I've been used to export environment variables in linux just running the export command, hehe
[05:40:13]
havenwood:
mikhael_k33hl: If you check in the Ruby process, you'll see the env vars are all there. If you exec or fork from the Ruby process you'll still see them.
[05:46:11]
mikhael_k33hl:
and you will see it when you run `printenv` right? Though I'm slowly getting it. So the wrapper/ruby has exec ruby "$@" which I've read pertaing to backtraces, is that correct?
[05:46:46]
mikhael_k33hl:
Cause what I'm looking for perhaps is how those exports were sent to the ruby environments? cause they are used in a rails application
[05:47:44]
havenwood:
mikhael_k33hl: well, this `file` shim you've shown sets a few env vars, then execs a child process that's an RVM wrapper that adds a few more env vars and runs Ruby with the arguments to the file
[05:48:50]
mikhael_k33hl:
havenwood: yep, I did it has the lines source "/usr/local/rvm/gems/ruby-1.9.3-p547/environment" ; exec ruby "$@"
[05:51:39]
smrtrnx:
I am new to ruby. Using git i tried to install bootstrap using gem but it seems that I cannot locate or don't know how to install the gem file that I have downloaded
[05:53:16]
havenwood:
mikhael_k33hl: Basically the file shim and RVM wrappers do the same thing, set some env vars then pass the args on to Ruby.
[05:53:53]
havenwood:
smrtrnx: Are you wanting to use this gem in an app? Does the app have a Gemfile?
[05:54:18]
havenwood:
smrtrnx: When you say "using git", do you mean you put it in your Gemfile and ran?: bundle
[05:56:00]
havenwood:
smrtrnx: Happy to help, but we need context. Just sanity checking that you have an app, it has a Gemfile, you've bundled and are having trouble requiring the gem?
[05:56:52]
smrtrnx:
basically i have succesfully downloaded the bootstrap gem file but i don't really know how to do the bundle install
[05:57:32]
havenwood:
smrtrnx: If you don't have a Rails or Hanami app, you shouldn't be using this gem.
[05:58:10]
havenwood:
smrtrnx: Ruby is the programming language. Rails is a popular web framework library in Ruby.
[05:58:18]
ruby[bot]:
Please join #RubyOnRails for Rails questions. You need to be identified with NickServ, see /msg NickServ HELP
[05:59:01]
havenwood:
smrtrnx: I wonder if you really have a Rails app? It seems like you'd know if you did.
[06:00:08]
havenwood:
smrtrnx: If you just want to install the bootstrap gem, outside an app, for whatever reason: gem install bootstrap
[06:02:26]
smrtrnx:
i tried following the instructions here https://github.com/twbs/bootstrap-rubygem
[06:02:39]
havenwood:
smrtrnx: Wordpress is a PHP library. I don't get where a gem comes into play at all.
[06:02:54]
smrtrnx:
using this command gem 'bootstrap', '~> 4.1.1' but i am stuck installing using the bundle install
[06:03:41]
smrtrnx:
basically using some sort of this command gem 'bootstrap', '~> 4.1.1' will download the gem file
[06:04:01]
havenwood:
smrtrnx: What in the world are you doing with that line? Where are you puttin git?
[06:04:57]
havenwood:
smrtrnx: So there's Bootstrap. Then there are various Bootstrap-related gems. These are the latter.
[06:05:56]
havenwood:
smrtrnx: If you have a Ruby project, you haven't mentioned it. You seem to be using Wordpress and somehow got on a Ruby gem rather than the Bootstrap library you're searching for.
[06:06:01]
smrtrnx:
hhmmm i don't really have a clue I was trying to figure out how it works to download bootstrap on git cmd
[06:06:26]
havenwood:
smrtrnx: Since you don't have a Ruby app, or anything Ruby-related here, stay away from Ruby gems.
[06:06:42]
smrtrnx:
and from https://github.com/twbs/bootstrap-rubygem i just followed the instructions. that says gem 'bootstrap', '~> 4.1.1'
[06:07:24]
havenwood:
smrtrnx: So there are bootstrap libraries in dozens of languages, that are specific to facilitating use in that language.
[06:07:56]
havenwood:
smrtrnx: This is the actual Bootstrap library: https://github.com/twbs/bootstrap
[06:08:45]
havenwood:
smrtrnx: A Rails gem isn't relevant to what you're doing any more than a Rust Cargo package or whatever else. If it says gem, it's not what you're looking for. Stop messing with Ruby gems.
[06:12:17]
havenwood:
smrtrnx: Wordpress doesn't use gems. Gems are Ruby packages. Wordpress is not Ruby. Gems have nothing at all to do with what you're doing. Nothing.
[06:14:23]
havenwood:
smrtrnx: These gems are packaging bootstrap specifically for Ruby apps. You don't have a Ruby app so they're not what you're looking for.
[06:15:12]
havenwood:
smrtrnx: Try that ^ repo above. It seems you're trying to find a nice Wordpress theme with Bootstrap support. I don't know how you got on Ruby gems, but abort. This is not what you're looking for.
[07:21:08]
havenwood:
smrtrnx: Try the noahbass/sass-wordpress-bootstrap repo I linked above. It seems you're trying to find a nice Wordpress theme with Bootstrap support (not a Ruby gem).
[07:21:12]
smrtrnx:
I am not trolling anyway just trying to look for some help with regards to my query
[09:59:03]
ohcibi:
when `bundle install --path foo` in a new directory with just a Gemfile in it, bundler will persist the path setting in .bundle/config in that directory. I was doing the same thing in a ruby:2.5 docker container (i.e. executing `bundle install --path foo` inside the container with just the Gemfile and Gemfile.lock in it) but the config is missing... i'm running as root inside the container but the config is not persisted. also /root/.bundle contains only the
[09:59:35]
ohcibi:
the readme even tells that --path is not persisted and one must do so by using bundle config but why is the config persisted on my local machine thern?
[13:08:06]
tbuehlmann:
I'm dealing with a CSV file I want to read and the first line is "sep=;\n", which doesn't really play nice with headers: true. is there something in ruby's CSV library to use that first line for col_sep and kind of ignoring it for headers?
[13:11:53]
Bish:
oh wait what, your first line dfines the col seperator? no you will enver get CSV to do that
[13:13:47]
Bish:
col_sep,parsed = [file_data.lines[1][/sep=(.*)/,1],CSV.new(file_data.lines[1..-1],col_sep:col_sep)]
[15:41:29]
ineb:
wasnt there a quick way to create a subclass which was basically just a parameterized version of the superclass?
[15:43:13]
apeiros_:
but since SomeClass.new usually does not return a class, the way it works differs a bit from what you imagine/remember
[15:43:46]
apeiros:
and the way it was done by _why which served as a template to many was: `class Foo < Bar(a,b,c…)`
[15:45:46]
ineb:
how is Struct doing it? MyStruct = Struct.new(:foo) { def whatever; end }; MyStruct.new("baz") ?
[15:46:36]
apeiros:
Struct is one of those nice classes which fail to uphold SomeClass.new.is_a?(SomeClass) :)
[15:58:30]
ineb:
apeiros: how would Kernel#Bar(a,b,c…) look like? tmp = Class.new(Object) {}; const_set("MyClass", tmp)?
[15:59:39]
apeiros:
but the other part looks about right, yes. Class.new is the way. and then you do whatever to parametrize the created class.
[16:03:23]
apeiros:
_why was quite famous a while back. sadly quit the community. camping.rb was his project where you can see this pattern.
[16:29:57]
ineb:
apeiros: interesting story around _why. looks like he disappeared and deleted all his repo one day. i always wonder why people do this.
[16:31:05]
ineb:
i understand it when hackers remove their stuff once they receive a friendly legal note adressed at their real names ;)
[16:33:56]
WA9ACE:
Just speculating but, they could have died. Not everyone is Jim. My wife and a friend have dead man switch access to my password manager to start shutting off accounts in my case
[16:42:00]
apeiros:
WA9ACE: as far as I know _why is not dead. somebody close to him in RL said as much. but it's still only hearsay.
[16:50:32]
raggi:
Not using it for anything atm, but was considering using it for some repl stuff for introspection / exploration tools
[16:52:08]
apeiros:
feb-april I took 3 months of unpaid vacation to follow through on some projects of mine
[16:53:21]
apeiros:
yeah, though I still think I should have been more greedy and asked for 6 months :-/
[16:55:52]
raggi:
Working on an OS basically doubled my to-do list instantly, but I at least can get a bunch done by teams now
[16:55:58]
apeiros:
while I'm not sure I'll have enough time for it, I want to also learn some rust during that time. aim is to write a smallish database server from scratch.
[16:57:35]
mgraf:
obligtory https://medium.com/@terrycrowley/never-write-your-own-database-736f704c780
[17:02:13]
mgraf:
maybe I'm under estimating your resources; but it seems silly to write a database and implement it in something that people are going to use
[17:03:20]
apeiros:
IMO if you're serious about understanding something, you have to implement it yourself.
[17:06:14]
mgraf:
I wouldn't feel comfortable having users (consumers?) use / rely on a database I wrote by myself
[17:06:55]
apeiros:
given that I feel comfortable to have users/customers use other software I wrote myself, why'd that be different with a DB?
[17:07:09]
apeiros:
(it's not what I intend to do with this, though - it's intended to be a learning project)
[17:10:08]
raggi:
Accidentally because I wrote the ruby version as an experiment to get a rough minimum baseline for latency and write throughput while we were evaluating other storage solutions
[17:10:29]
raggi:
And for various reasons it was about an order of magnitude faster at the primary taks
[17:11:01]
raggi:
So, fast forward a few months and it had a journal and read repair and a few other such bits
[17:43:33]
raggi:
https://viewsourcecode.org/why/redhanded/bits/theHeartOfTryRuby.html ah time travel
[18:36:19]
Zarthus:
man, a recruiter just hit me up for a rails position at SUSE, sounded kinda interesting, but nuremberg is like the middle of nowhere.
[18:40:35]
Zarthus:
it wouldn't surprise me if comparing two large strings is faster than sha2ing both
[18:42:23]
catbusters:
What's the best datetime library for Ruby? I'm looking for something like moment.js or arrow (python)
[18:42:47]
Zarthus:
catbusters: I've managed just fine with the normal time/date libraries, what functionality do you need?
[18:44:24]
Zarthus:
masterasia: unless you store it in the db rather, checksumming both values is equal to a normal string comparison
[21:22:17]
elomatreb:
You'd probably have to restrict it to literals (i.e. no variables/expressions) in order to keep it at least a little unambigous
[21:27:32]
MasterAsia:
if I have a url like https://google.ca/api/users, how can I strip out the https://google.ca/api
[21:44:00]
MasterAsia:
I'm letting user-input sneak define which API endpoint I call, they only have limited access but could it be malicious?
[21:44:48]
MasterAsia:
link = "/users/#{params[:id]}" which is fed into http.get('https://google.ca/api/#{link}")
[21:50:54]
ruby[bot]:
al2o3-cr: # => /tmp/execpad-062b8a760887/source-062b8a760887:3: syntax error, unexpected keyword_rescue, expecting ...check link for more (https://eval.in/1035186)
[21:51:01]
ruby[bot]:
al2o3-cr: # => undefined method `relative_path' for File:Class (NoMethodError) ...check link for more (https://eval.in/1035187)
[21:51:20]
ruby[bot]:
al2o3-cr: # => undefined method `relative_paths' for File:Class (NoMethodError) ...check link for more (https://eval.in/1035188)
[21:56:35]
ruby[bot]:
al2o3-cr: # => undefined method `relative_path' for File:Class (NoMethodError) ...check link for more (https://eval.in/1035189)
[22:06:13]
ruby[bot]:
al2o3-cr: # => "/execpad/interpreters/ruby-2.3.0/lib/ruby/vendor_ruby/gems/2.3.0" (https://eval.in/1035190)