#ruby - 08 July 2018
« Back 1 day Forward 1 day »
[05:08:43] dhawan: I am new to ruby programming. According to a project specification, I have to execute Sinatra application in a background Thread in such a way that after executing Sinatra application, user can receive command line immediately
[05:08:55] dhawan: I cannot use process daemon or Process form in my project as it will isolate the process from the original running process moreover it would not be feasible to communication between forked process and the originally running process. Now the only option I am left with is Thread. So is it possible to execute the same by using thread?
[05:16:36] eam: you want to run the sinatra server on a command line and have it run in the background?
[05:19:28] jidar: his/her question on stackoverflow hahaha https://stackoverflow.com/questions/51225986/is-it-possible-to-execute-a-sinatra-application-via-thin-as-a-background-proce
[05:20:08] eam: so it sounds like this is really a question about the interaction between the shell and a program being run
[05:20:40] eam: if that's the case, the answer is that you absolutely must fork and create two processes -- but the first one will exit
[05:21:01] eam: and it *is* possible to communicate between forked processes, but we would need more specifics
[05:58:46] dhawan: @eam yes, it is a question about the interaction between the shell and browser. Actually I am trying to terminal output on browser to provide graphical user interface to the user.
[05:58:47] dhawan: ANd yes, I asked this question on stack overflow, But I did'nt get response there so here I am
[06:00:25] dhawan: Acually I am working on metasploit-framework project. As you know it is a command line penetration tool. My goal is to provide web Interface to Meterpreter shell.
[06:18:02] dhawan: You can find the abstract here : https://summerofcode.withgoogle.com/projects/#6618295331979264
[08:28:57] MagePsycho: set :branch, ENV['BRANCH'] || ??? -> I want to print "You must specify branch" and exit
[08:30:46] apeiros: MagePsycho: raise "You must specify branch" unless ENV['BRANCH'] the line before IMO.
[08:37:46] MagePsycho: raise "You must specify branch in order to deploy in staging server" unless ENV['BRANCH']
[08:59:38] konsolebox: i have it bookmarked in the "Refs" folder menu in Bookmarks Toolbar: https://imgur.com/a/rsolsUK
[09:08:45] apeiros: konsolebox: I prefer ri too. but some people seem to prefer online docs. for whatever reasons.
[09:09:00] apeiros: I mean ri has the clear advantage of being in sync with the ruby version you actually use
[09:12:21] konsolebox: apeiros: why "too"? i prefer the html documentation :) yeah i care about ri; i mean i persisted on making the documentation of my gems work for it. and i know it's more updated, especially with documentation of other libraries. but then i still like how easy it is to quickly browse from one class to another in the html docs. it's easy to skim/search for strings.
[09:12:41] livcd: apeiros: i guess people prefer online docs because they end up googling stuff on the internet anyway
[09:13:43] apeiros: livcd: yeah. and I keep telling people that googling methods of proglangs is a stupid idea. the less you know the worse your results will be.
[10:50:00] leitz: How do I 'require' my new gem? It's installed in /usr/local/lib/ruby/gems/2.6.0/gems/2D6_OGL_CharGen-0.0.5 and I can run the commands. However, I'd like to be able to use the "dice" class in 'lib' outside of the chargen stuff.
[10:50:12] nikivi: i.e. I have this code https://github.com/nikitavoloboev/karabiner-generator/blob/master/karabiner-generate.rb#L27
[10:50:26] leitz: https://github.com/makhidkarun/2d6_ogl_chargen/blob/master/2d6_ogl_chargen.gemspec
[10:52:02] leitz: nikivi, do you mean "is it possible to know what calls a method, from the method itself?"
[10:54:13] leitz: Something like https://stackoverflow.com/questions/199527/get-the-name-of-the-currently-executing-method
[11:00:11] leitz: This help? https://stackoverflow.com/questions/5100299/how-to-get-the-name-of-the-calling-method
[14:10:47] elomatreb: Making a name uppercase gives it constant-like treatment in Ruby, you can assign anything to local variables (lowercase names) too but it's kind of useless
[14:18:10] nikivi: basically I want to only assign something to 'modifiers' if to_modifiers is not nil
[14:23:13] nikivi: I don't want to evaluate this line at all if there is nil: 'modifiers' => to_modifiers
[14:23:50] elomatreb: If you want to achieve what you can assign like `h["modifiers"] = ...` in an if after the hash initialization
[14:26:38] elomatreb: In general this seems like a kind of dirty approach though, is there a good reason you can't just always have the key and just set it to the value, and ignore it later if it is nil?
[15:32:46] nikivi: def sticky(held_key, trigger_key, action, from_mandotary_modifiers=, to_modifiers=)
[15:33:56] elomatreb: You can, but in order to specify to_modifiers you also have to provide some value for from_mandatory_modifiers
[15:34:11] elomatreb: Alternatively you can use keyword arguments if you want specifying one but not the other to be convenient
[15:36:05] apeiros: anything beyond 2 arguments becomes hard to understand with implicit names on caller side. I prefer long code with kwargs there.
[15:36:34] apeiros: and if they're defaultized, I started to use kwargs even for 1 and 2 arg methods.
[19:07:11] nikivi: where each one binds a single key to another key, so say I press s key, then hold it and press g and it does something
[19:07:39] nikivi: I need a way to define that when I press some key, it pressed multiple keys after so I press s, then it will insert g, f, l and so on
[19:07:54] nikivi: so I want to create a method multiple_keys but not sure how to go from there really
[19:09:04] nikivi: what that did was made it so that if you press b, it will insert TODO: in sucession
[19:10:50] nikivi: there is held_trigger which is key being held down, then trigger_key which is the key that will be pressed when that key is held down and key_code is what will be inserted once that happens
[19:11:17] Zarthus: i understand how it works, I just have trouble understanding the purpose. Let's say you have an app and I hold down "s" and then press "i", what do you expect to happen?
[19:13:03] Zarthus: the way I've seen this being done in other applications is event-based. Where you'd send two events instead of one.
[19:15:03] nikivi: key("q", "l", "l", ["command", "shift"]).key("q", "l", "o", ["command", "shift"]),
[19:15:36] Zarthus: it looks to me (and I'll admit I've only spent a few minutes on this) that the args of key() are just wrong/limiting in general
[19:18:48] nikivi: or well it would if I call it with different arguments but the method calls would be called from original call