eval

#Eval if statement in repeater

♀尐吖头ヾ 提交于 2019-11-27 14:19:24
I'm trying to check a string value inside a repeater, and if it has value then write a link, but can't seem to get it to work. If there is a value in myUrl then I want to display the link. <%if( %> <%#Eval("myURL").ToString().Length > 0 %> <a title="myTitle" target="_blank" href="<%# Eval("myURL") %>">my link</a> <% } %> Can anyone please help? Madhu Beela try this code !!! <%#Eval("myURL").ToString().Length > 0 ? "<a title='myTitle' target='_blank' href='<%# Eval("myURL") %>'>my link</a>":""%> I personally hate using conditional logic like that in the page. There are two options that I think

Is there C/C++ equivalent of eval(“function(arg1, arg2)”)?

房东的猫 提交于 2019-11-27 14:19:15
it need a way to call function whose name is stored in a string similar to eval. Can you help? Hauleth C++ doesn't have reflection so you must hack it, i. e.: #include <iostream> #include <map> #include <string> #include <functional> void foo() { std::cout << "foo()"; } void boo() { std::cout << "boo()"; } void too() { std::cout << "too()"; } void goo() { std::cout << "goo()"; } int main() { std::map<std::string, std::function<void()>> functions; functions["foo"] = foo; functions["boo"] = boo; functions["too"] = too; functions["goo"] = goo; std::string func; std::cin >> func; if (functions

如何用TensorFlow实现线性回归

北城余情 提交于 2019-11-27 14:05:06
环境Anaconda 废话不多说,关键看代码 import tensorflow as tf import os os.environ['TF_CPP_MIN_LOG_LEVEL']='2' tf.app.flags.DEFINE_integer("max_step", 300, "训练模型的步数") FLAGS = tf.app.flags.FLAGS def linear_regression(): ''' 自实现线性回归 :return: ''' #1.准备100个样本 特征值X,目标值y_true with tf.variable_scope("original_data"): #mean是平均值 #stddev代表方差 X = tf.random_normal(shape=(100,1),mean=0,stddev=1) y_true = tf.matmul(X,[[0.8]])+0.7 #2.建立线性模型: with tf.variable_scope("linear_model"): weigh = tf.Variable(initial_value=tf.random_normal(shape=(1,1))) bias = tf.Variable(initial_value=tf.random_normal(shape=(1,1))) y_predict = tf

PHP eval and capturing errors (as much as possible)

夙愿已清 提交于 2019-11-27 13:33:21
Disclaimer ; I'm fully aware of the pitfalls and "evils" of eval, including but not limited to: performance issues, security, portability etc. The problem Reading the PHP manual on eval... eval() returns NULL unless return is called in the evaluated code, in which case the value passed to return is returned. If there is a parse error in the evaluated code, eval() returns FALSE and execution of the following code continues normally. It is not possible to catch a parse error in eval() using set_error_handler(). In short, no error capture except returning false which is very helpful, but I'm sur

How does jsFiddle allow and execute user-defined JavaScript without being dangerous?

好久不见. 提交于 2019-11-27 13:06:46
问题 I've been working on a JS library and would like to setup a demo page on Github that allows, for example, users to define their own callbacks and execute commands. I know " eval() is evil" and I can see how blind eval() of scripts could lead to XSS and other security issues. I'm trying to cook up some alternative schemes. I really enjoy the interactivity of jsFiddle. I've taken a look at their source but was hoping someone could lay out here how jsFiddle allows and executes user-defined

C# Eval() support [duplicate]

岁酱吖の 提交于 2019-11-27 12:49:22
This question already has an answer here: How can I evaluate C# code dynamically? 16 answers we need to evaluate a value in an object in run time while we have a textual statement of the exact member path for example: myobject.firstMember.secondMember[3].text we thought of parsing this textual statement using regex and then evaluate the text value by using reflection but before we do that i wonder if C# support some kind of eval ability? so we won't have to do the parsing ourself. How do microsoft do this in their immediate window or watch windows? thanks you very much, Adi Barda Alex Yakunin

Alternative to eval() javascript [duplicate]

感情迁移 提交于 2019-11-27 12:44:35
This question already has an answer here: What are the Alternatives to eval in JavaScript? 9 answers I work mainly with javascript, Jquery, knockout, etc The thing that attracted eval() to me is var a = 5; var b = 10; eval("a+b"); //Gives me output 15 Note: I work in cases where the value of a and b changes dynamically In my work I'm dealing with a lot of dynamic objects from json, knockout, etc. So eval solves most of my problems. But as I read I found there are so many issues with eval() like slowing down etc. I searched a lot and haven't found any substitute for eval() when i have to

Dirt-simple PHP templates… can this work without `eval`?

a 夏天 提交于 2019-11-27 12:27:55
Update- Thanks for all the responses. This Q is getting kind of messy, so I started a sequel if anyone's interested. I was throwing together a quick script for a friend and stumbled across a really simple way of doing templating in PHP. Basically, the idea is to parse the html document as a heredoc string, so variables inside of it will be expanded by PHP. A passthrough function allows for expression evaluation and function and static method calls within the string: function passthrough($s){return $s;} $_="passthrough"; The code to parse the document inside a heredoc string is ridiculously

Python: How to pass arguments to the __code__ of a function?

假装没事ソ 提交于 2019-11-27 12:06:35
The following works: def spam(): print "spam" exec(spam.__code__) spam But what if spam takes arguments? def spam(eggs): print "spam and", eggs exec(spam.__code__) TypeError: spam() takes exactly 1 argument (0 given) Given, that I don't have access to the function itself but only to a code object, how can I pass arguments to the code object when executing it? Is it possible with eval? Edit: Since most readers tend not to believe in the usefulness of this, see the following use case: I want to save small Python functions to a file so that they can be called e.g. from another computer. (Needless

I can't seem to use the Bash “-c” option with arguments after the “-c” option string

别来无恙 提交于 2019-11-27 12:04:59
The man page for Bash says, regarding the -c option: -c string If the -c option is present, then commands are read from string . If there are arguments after the string, they are assigned to the positional parameters, starting with $0 . So given that description, I would think something like this ought to work: bash -c "echo arg 0: $0, arg 1: $1" arg1 but the output just shows the following, so it looks like the arguments after the -c string are not being assigned to the positional parameters. arg 0: -bash, arg 1: I am running a fairly ancient Bash (on Fedora 4): [root@dd42 trunk]# bash -