在我的Angular视图中,我有一个输入字段和一些可点击的好东西,使用ng-click.
当点击其中一个ng-click时,是否有角度方式或简单的vanilla js方式来防止输入字段从LOSING焦点(如果它处于焦点)?
<input type="text" class="form-control" ng-model="foo">
<button ng-click="someThing()">click me</button>
Run Code Online (Sandbox Code Playgroud) 我正在使用(watchOS 2)applicationContext方法将我的iPhone中的字典传递给手表.
在iPhone应用程序内:
func giveMeInfo(){
var lastStringUsed = porkee288.storyPoints.last!
do {
let resultDict = ["dict": myDict]
try WCSession.defaultSession().updateApplicationContext(resultDict)
}
catch {
print("Something wrong happened")
}
}
Run Code Online (Sandbox Code Playgroud)
在手表应用内:
func session(session: WCSession, didReceiveApplicationContext applicationContext: [String : AnyObject]) {
dispatch_async(dispatch_get_main_queue()) { () -> Void in
if let retrievedDict = applicationContext["dict"] as? [String : String] {
self.dictInsideWatch = retrievedDict
}
}
}
Run Code Online (Sandbox Code Playgroud)
该数据由提取tableview的watchKit很好,但是,每个应用程序进行到背景时,数据自动丢失,这很奇怪,因为在iPhone应用字典有一些持久性(至少直到变得悬浮).
您建议如何解决此问题并防止数据消失?
我正在尝试使用 NodeJS 在 shell 中执行一些命令。因此我使用该node:child_process模块。
我使用该spawn函数是为了能够将子进程的输出转发到主进程的控制台。为了保持子进程输出的格式,我传递了该选项stdio: "inherit"(如本问题所述:在执行 child_process.spawn 时保留颜色)。
但如果我添加此选项,子进程事件(退出、断开连接、关闭……)将不再起作用。如果我删除该选项,我会丢失格式,但事件会起作用。有没有办法在子进程关闭时保留格式并得到通知?
(相关)代码:
const { spawn } = require("node:child_process");
let child = spawn("yarn", args, {
stdio: "inherit",
shell: true,
});
child.on("close", (code) => {
console.log(`child process exited with code ${code}`);
});
Run Code Online (Sandbox Code Playgroud) 我正在运行Dancer并发现它很慢 - 页面需要很长时间才能渲染.
这是Dancer :: Introduction的示例代码:
#!/usr/bin/perl
# make this script a webapp
use Dancer;
# declare routes/actions
get '/' => sub {
"Hello World";
};
get '/hello/:name' => sub {
"Hello ".param('name');
};
# run the webserver
Dancer->dance;
Run Code Online (Sandbox Code Playgroud)
它需要我的浏览器10秒钟来获取和呈现响应(在firefox中使用firebug).
和舞者的消息:
[20734] core @0.000228> request: GET / from 192.168.1.101 in /usr/lib/perl5/site_perl/5.8.8/Dancer/Handler.pm l. 57
[20734] core @0.000809> [hit #44]trying to match `/' against /^\/$/ in /usr/lib/perl5/site_perl/5.8.8/Dancer/Route.pm l. 84
[20734] core @0.000953> [hit #44] --> got …Run Code Online (Sandbox Code Playgroud) 我需要对 12 列数据框中的两列进行缩尾处理。
假设我有“A”、“B”、“C”和“D”列,每列都有一系列值。鉴于我清理了一些 NaN 列,列数从 100 减少到 80,但它们仍然索引为 100,有间隙(例如,第 5 行丢失)。
我想通过 winsorize 方法仅转换列“A”和“B”。为此,我必须将列转换为 np.array。
import scipy.stats
df['A','B','C','D'] = #some values per each column
ab_df = df['A','B']
X = scipy.stats.mstats.winsorize(ab_df.values, limits=0.01)
new_ab_df = pd.DataFrame(X, columns = ['A','B'])
df = pd.concat([df['C','D'], new_ab_df], axis=1, join='inner', join_axes=[df.index])
Run Code Online (Sandbox Code Playgroud)
当我转换为 np.array,然后返回 pd.DataFrame 时,len() 在 80 处是正确的,但我的索引已重置为 0->80。如何确保我的转换“A”和“B”列正确索引?我不认为我可以使用 apply() ,它会保留索引顺序并简单地交换值,而不是我的方法,它创建仅包含 2 列的 df 的转换副本,然后将它们连接到我的其余部分未转换的列。