dynamic-execution

How to dynamically execute/eval JavaScript code that contains an ES6 module / requires some dependencies?

霸气de小男生 提交于 2019-12-19 07:10:07
问题 I want my users to be able to use JavaScript as a scripting language inside my JavaScript application. In order to do so, I need to dynamically execute the source code. There seem to be two main options for dynamically executing JavaScript: a) Use eval(...) method ( or var func = new Function(...); ) . b) Add a <script> node to the DOM (for example by using $('body').append(...) ). Both methods work fine as long as I do not use any import statements in the dynamically executed source code. If

Passing operators as functions to use with Pandas data frames

≯℡__Kan透↙ 提交于 2019-12-11 04:26:07
问题 I am selecting data from series on basis of threshold . >>> s = pd.Series(np.random.randn(5)) >>> s 0 -0.308855 1 -0.031073 2 0.872700 3 -0.547615 4 0.633501 dtype: float64 >>> cfg = {'threshold' : 0 , 'op' : 'less' } >>> ops = {'less' : '<', 'more': '>' , 'equal': '==' , 'not equal' : '!='} >>> ops[cfg['op']] '<' >>> s[s < cfg['threshold']] 0 -0.308855 1 -0.031073 3 -0.547615 dtype: float64 I want to use ops[cfg['op']] in last line of code , instead of '<'. I am willing to change key ,

Dynamic C code execution: memory references

∥☆過路亽.° 提交于 2019-12-10 10:39:20
问题 tl;dr : I'm trying to execute dynamically some code from another snippet. But I am stuck with handling memory reference (e.g. mov 40200b, %rdi ): can I patch my code or the snippet running code so that 0x40200b is resolved correctly (as the offset 200b from the code)? To generate the code to be executed dynamically I start from a (kernel) object and I resolve the references using ld. #!/usr/bin/python import os, subprocess if os.geteuid() != 0: print('Run this as root') exit(-1) with open("

Dynamic C code execution: memory references

烂漫一生 提交于 2019-12-06 08:29:21
tl;dr : I'm trying to execute dynamically some code from another snippet. But I am stuck with handling memory reference (e.g. mov 40200b, %rdi ): can I patch my code or the snippet running code so that 0x40200b is resolved correctly (as the offset 200b from the code)? To generate the code to be executed dynamically I start from a (kernel) object and I resolve the references using ld. #!/usr/bin/python import os, subprocess if os.geteuid() != 0: print('Run this as root') exit(-1) with open("/proc/kallsyms","r") as f: out=f.read() sym= subprocess.Popen( ['nm', 'ebbchar.ko', '-u' ,'--demangle', '

How to dynamically execute/eval JavaScript code that contains an ES6 module / requires some dependencies?

时光毁灭记忆、已成空白 提交于 2019-12-01 05:14:38
I want my users to be able to use JavaScript as a scripting language inside my JavaScript application. In order to do so, I need to dynamically execute the source code. There seem to be two main options for dynamically executing JavaScript: a) Use eval(...) method ( or var func = new Function(...); ) . b) Add a <script> node to the DOM (for example by using $('body').append(...) ). Both methods work fine as long as I do not use any import statements in the dynamically executed source code. If I include import statements I get the error message Unexpected identifier . Example user source code

Compiling code containing dynamic parallelism fails

邮差的信 提交于 2019-11-27 15:14:02
I am doing dynamic parallelism programming using CUDA 5.5 and an NVDIA GeForce GTX 780 whose compute capability is 3.5. I am calling a kernel function inside a kernel function but it is giving me an error: error : calling a __global__ function("kernel_6") from a __global__ function("kernel_5") is only allowed on the compute_35 architecture or above What am I doing wrong? You can do something like this nvcc -arch=sm_35 -rdc=true simple1.cu -o simple1 -lcudadevrt or If you have 2 files simple1.cu and test.c then you can do something as below. This is called seperate compilation. nvcc -arch=sm_35

Out-of-order instruction execution: is commit order preserved?

点点圈 提交于 2019-11-27 02:27:00
问题 On the one hand, Wikipedia writes about the steps of the out-of-order execution: Instruction fetch. Instruction dispatch to an instruction queue (also called instruction buffer or reservation stations). The instruction waits in the queue until its input operands are available. The instruction is then allowed to leave the queue before earlier, older instructions. The instruction is issued to the appropriate functional unit and executed by that unit. The results are queued. Only after all older

Compiling code containing dynamic parallelism fails

安稳与你 提交于 2019-11-26 17:07:26
问题 I am doing dynamic parallelism programming using CUDA 5.5 and an NVDIA GeForce GTX 780 whose compute capability is 3.5. I am calling a kernel function inside a kernel function but it is giving me an error: error : calling a __global__ function("kernel_6") from a __global__ function("kernel_5") is only allowed on the compute_35 architecture or above What am I doing wrong? 回答1: You can do something like this nvcc -arch=sm_35 -rdc=true simple1.cu -o simple1 -lcudadevrt or If you have 2 files