interactive

Hosting .fsx scripts inside larger applications

筅森魡賤 提交于 2019-12-23 10:49:34
问题 I want to expose my F# libraries as a scriptable tool for data manipulation. Optimally, I want this scripting facility to not require a full F# install with fsi and so on. Is there a way to link into the FSI libraries to execute scripts from F# code? My google-fu is failing me on this one, and the F# sources for fsi are a bit tangled. 回答1: No, there's no hosting API for F# interactive sessions. fsi.exe itself is factored into a lightweight client process that handles the interaction, and a

Can a string be returned from a Bash function without using echo or global variables?

旧街凉风 提交于 2019-12-23 10:16:49
问题 I'm returning to a lot of Bash scripting at my work, and I'm rusty. Is there a way to return a local value string from a function without making it global or using echo? I want the function to be able to interact with the user via screen, but also pass a return value to a variable without something like export return_value="return string" . The printf command seems to respond exactly like echo. For example: function myfunc() { [somecommand] "This appears only on the screen" echo "Return

Python and Interactive Zoom Plot with Matplotlib

≡放荡痞女 提交于 2019-12-23 03:53:06
问题 I am using a Matplotlib plot (with Basemap) inside of a wxPython pane. I have got the plot (US map with scatter plot of cities). I am trying to do some interactive zoom capabilities (select a box on the map and "zoom" into that area only). I have managed to get the toolbar to show, but when i click on the buttons, nothing happens. Seems like the toolbar is just there for show. Any Thoughts? Here is my code: # Set up area for plotting Basemap Plot and scatter plot self.figure = Figure(None,dpi

Regex to validate SMTP Responses

流过昼夜 提交于 2019-12-23 01:14:07
问题 I'm writing a regular expression that can interactively validate SMTP responses codes, once the SMTP dialog is completed it should pass the following regex (some parentheses added for better readability): ^(220)(250){3,}(354)(250)(221)$ Or with( out ) authentication: ^(220)(250)((334){2}(235))?(250){2,}(354)(250)(221)$ I'm trying to do rewrite the above regexes so that I can interactively check if the dialog is going as expected, otherwise politely send a QUIT command and close the connection

interact and plotting with ipywidgets events produces many graphs

孤者浪人 提交于 2019-12-22 10:16:04
问题 I am trying to use widget events to make an interactive graph. %matplotlib inline import numpy as np import matplotlib.pyplot as plt import ipywidgets as widgets def myplot(n): x = np.linspace(-5, 5, 30) y = x**n fig, ax = plt.subplots(nrows=1, ncols=1); ax.plot(x, y) ax.set_xlabel('x') ax.set_ylabel('y') plt.show() Interact works as expected (it changes the figure interactively): widgets.interact(myplot, n=(0,5)); However the following snippet creates several figures that appear below as you

Is it possible to force PowerShell script to throw if a required *pipeline* parameter is omitted?

℡╲_俬逩灬. 提交于 2019-12-22 09:46:11
问题 Interactive PowerShell sessions prompt the user when a required parameter is omitted. Shay Levy offers a workaround to this problem. The problem is that workaround does not work when you use the pipeline to bind parameters. Consider this example: function f { [CmdletBinding()] param ( [Parameter(ValueFromPipeLineByPropertyName=$true)] [ValidateNotNullOrEmpty()] [string]$a=$(throw "a is mandatory, please provide a value.") ) process{} } $o = New-Object psobject -Property @{a=1} $o | f This

How to call bash commands from tcl script?

天大地大妈咪最大 提交于 2019-12-22 08:09:40
问题 Bash commands are available from an interactive tclsh session. E.g. in a tclsh session you can have % ls instead of $ exec ls However, you cant have a tcl script which calls bash commands directly (i.e. without exec ). How can I make tclsh to recognize bash commands while interpreting tcl script files, just like it does in an interactive session? I guess there is some tcl package (or something like that), which is being loaded automatically while launching an interactive session to support

Matplotlib event_handling line picker

喜你入骨 提交于 2019-12-22 07:57:23
问题 This example makes it possible to click a legend and thereby change a plot. I want to do something similar, but then not by clicking the legend, just by clicking the line in the plot. I tried to do it like this: self.ax = self.fig.add_subplot(1,2,1) data = NP.array(2,10) #filled with numbers self.x = NP.arange(2) for line in range(len(data[0,:])): self.ax.plot(self.x, data[:,line], picker=5) In every loop, an extra line is plotted. One line consists of 2 points, so it draws a straight line.

Define an emacs command that calls another emacs command (preserving interactive stuff)

泄露秘密 提交于 2019-12-21 22:11:28
问题 How can I define an emacs command X that does something and then calls another emacs command Y and also copying the interactive interface of the command Y too? I want to define an altenative version of query-replace with temporarilly toggled value of case-fold-search: (defun alt-query-replace (a b c d e) (interactive) (let ((case-fold-search (not case-fold-search)) (query-replace a b c d e))) This doesn't work. When I call alt-query-replace, it says "wrong number of arguments". I want the

How do I push a string to stdin? Provide input via stdin on startup, then read stdin input interactively

感情迁移 提交于 2019-12-21 20:08:33
问题 Is there a way to "push" a string to the stdin stream of a program when calling it? So that we would have the effect of echo "something" | ./my_program but instead of reading EOF after "something" , my_program would read its further input from the original stdin (e.g., the keyboard). Example: Say we want to start a bash shell, but the first thing we would like to do inside it is to call date . echo date | bash would not do the job, as the shell would terminate after running date . 回答1: This