embedding

Embedding a Python shell in a webpage [closed]

扶醉桌前 提交于 2019-12-05 20:31:43
I am working on a manuscript for introducing programming to beginners. Python is one of the two languages I cover in this book. I would like to setup up a webpage with an embedded Python shell for my readers to go and try things out. What would be the best way to go about it? I am aware of web apps like repl.it . I would personally like to set something up myself, however. jfs There is a sample google appengine project that provides Python shell e.g., http://live.sympy.org uses it. Or your JavaScript code (an Ajax shell) could communicate with a sandboxed Pypy version using something like this

How do I host an application window as a child of a window belonging to another process?

六眼飞鱼酱① 提交于 2019-12-05 18:29:48
I would like to host an application window from a process "A" into the main window of a process "B", just as if "A"'s window were a MDI child window. Is this possible in Windows? Or are there some tricks which would allow me to fake this? By the way, I'd like to remove the title bar (or better yet, all the non-client stuff) of "A"'s window when it is embedded into "B"'s window. I suppose that this must be possible by tweaking the window styles or window classes, but I am by no means an expert in these Win32 intricacies. It's possible to host the Window. Change A's parent HWND by calling the

Dividing binary image into 'blocks' of pixel data

不羁岁月 提交于 2019-12-05 12:38:18
I am using Python and PIL as part of my work on embedding data in binary images and need to analyse groups of pixels to determine appropriate pixels to manipulate in order to embed data. The image needs to be split into equal 'blocks' of pixel data ready for analysis, but I am struggling to come up with an appropriate method of doing this. I have tried techniques using Python and numPy arrays, but without success. Any suggestions would be greatly appreciated. Thanks You need to use numpy array slicing to get group of pixels. Image is just 2D array, so you can use arr = numpy.array(Image.open

First attempt at lazy loading (deferring the load of embedded YouTube videos) - how can I do this more gracefully?

寵の児 提交于 2019-12-05 11:39:51
Yesterday I decided to improve the way my website loads YouTube videos by only embedding them when a user requests them. Sometimes a page could have as many as 30 videos on, and this would take a long time to load. This is the first time I've attempted a "lazy loading" method of anything, and I figured it would be well worth asking: What can I do to improve on this? How can I make it a bit more graceful? Does this completely miss the point of deferred loading? JSFiddle . Ignore the styling as that's irrelevant here. The way this works is by first placing an anchor on the page containing the

lua_open returns null using luaJIT

风格不统一 提交于 2019-12-05 08:22:41
Using the recent luaJIT lua_open returns null . This does not happen with the regular lua library. lua_State *L = lua_open(); std::cout << L << std::endl; Output: 0x0 How can I get luaJIT to work? SSCCE: #include <iostream> #include <luajit-2.0/lua.hpp> //linked library: libluajit-5.1.a int main(int argc, const char * argv[]) { lua_State *L = luaL_newstate(); // lua_open(); std::cout << L << std::endl; // 0x0 } Additional information: Built on OSX 10.9 from source (tried both 2.0.2 and from git) with make and make install . Using compiler: $ cc --version Apple LLVM version 5.0 (clang-500.2.79)

Python embedding with threads — avoiding deadlocks?

人走茶凉 提交于 2019-12-05 04:54:15
Is there any way to embed python, allow callbacks from python to C++, allowing the Pythhon code to spawn threads, and avoiding deadlocks? The problem is this: To call into Python, I need to hold the GIL. Typically, I do this by getting the main thread state when I first create the interpreter, and then using PyEval_RestoreThread() to take the GIL and swap in the thread state before I call into Python. When called from Python, I may need to access some protected resources that are protected by a separate critical section in my host. This means that Python will hold the GIL (potentially from

Does the Python 3 interpreter leak memory when embedded?

泄露秘密 提交于 2019-12-05 01:24:09
问题 This bug report states that the Python interpreter, as of June 2007, will not clean up all allocated memory after calling Py_Finalize in a C/C++ application with an embedded Python interpreter. It was recommended to call Py_Finalize once at application termination. This bug report states that as of version 3.3 and March 2011 the interpreter still leaks memory. Does anyone know the current state of this issue? I am concerned because I have an application in which the interpreter is called

Tensorflow dynamic_rnn deprecation

。_饼干妹妹 提交于 2019-12-04 17:06:27
It seems that the tf.nn.dynamic_rnn has been deprecated: Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Please use keras.layers.RNN(cell), which is equivalent to this API I have checked out keras.layers.RNN(cell) and it says that it can use masking which I assume can act as a replacement for dynamic_rnn 's sequence_length parameter? This layer supports masking for input data with a variable number of timesteps. To introduce masks to your data, use an Embedding layer with the mask_zero parameter set to True. But there is no further

Better page load performance when loading multiple embedded Youtube videos?

帅比萌擦擦* 提交于 2019-12-04 09:08:12
问题 I have a page which displays multiple (usually 10) embedded videos. The videos use the new IFRAME embed code of youtube and apparently for every IFRAME there is a separate request when loading the page. Is there a way to defer loading the videos after the rest of the page is loaded, so they don't slow down page loading that much? 回答1: Well, I wrote a javascript thingy (called "LYTE") that will create a "dummy player" (which looks & feels like a normal YouTube embed) for every div with a

tf.contrib.layers.embedding_column from tensor flow

余生长醉 提交于 2019-12-04 08:49:45
I am going through tensorflow tutorial tensorflow . I would like to find description of the following line: tf.contrib.layers.embedding_column I wonder if it uses word2vec or anything else, or maybe I am thinking in completely wrong direction. I tried to click around on GibHub, but found nothing. I am guessing looking on GitHub is not going to be easy, since python might refer to some C++ libraries. Could anybody point me in the right direction? I've been wondering about this too. It's not really clear to me what they're doing, but this is what I found. In the paper on wide and deep learning ,