我正在为wordpress开发一个插件,我想找到当前用户是否是管理员,不幸的是我无法使用current_user_can(),因为它给了我错误,所以使用全局$ current_user.但即使是管理员用户,我也无法进入if部分..如何解决这个问题?
global $current_user;
if ($current_user->role[0]=='administrator'){
function hide_post_page_options() {
//global $post;
// Set the display css property to none for add category and add tag functions
$hide_post_options = "<style type=\"text/css\"> .jaxtag { display: none; } #category-adder { display: none; } </style>";
print($hide_post_options);
}
add_action( 'admin_head', 'hide_post_page_options' );
}
Run Code Online (Sandbox Code Playgroud) 我试图在我的docker容器中运行shell脚本.问题是shell脚本生成另一个进程,它应该继续运行,除非使用另一个关闭脚本来终止由启动脚本生成的进程.
当我运行以下命令时,
docker run image:tag /bin/sh /root/my_script.sh
Run Code Online (Sandbox Code Playgroud)
然后,
docker ps -a
Run Code Online (Sandbox Code Playgroud)
我看到该命令已退出.但这不是我想要的.我的问题是如何让命令在后台运行而不退出?
我正在尝试从debian:latest. 构建后,docker images命令中报告的映像虚拟大小为 1.917 GB。我登录查看大小 ( du -sh /),它是 573 MB。我很确定这种巨大的尺寸通常是不可能的。这里发生了什么?如何获得正确的图像大小?更重要的是,当我推送这个存储库时,大小是 1.9 GB 而不是 573 MB。
输出 du -sh /*
8.9M /bin
4.0K /boot
0 /dev
1.1M /etc
4.0K /home
30M /lib
4.0K /lib64
4.0K /media
4.0K /mnt
4.0K /opt
du: cannot access '/proc/11/task/11/fd/4': No such file or directory
du: cannot access '/proc/11/task/11/fdinfo/4': No such file or directory
du: cannot access '/proc/11/fd/4': No such file or directory
du: cannot access '/proc/11/fdinfo/4': No such file or …Run Code Online (Sandbox Code Playgroud) 这是我计划存储在磁盘中的对象,
public class SObject {
/**
*
*/
private String value;
private int occurences;
private String key;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public int getOccurences() {
return occurences;
}
public void setOccurences(int occurences) {
this.occurences = occurences;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
}
Run Code Online (Sandbox Code Playgroud)
我正在考虑创建一个对象列表并将该列表存储到一个新类中,如下所示,
public class ToDisk implements Serializable{
List<SObject> sobj;
public List<SObject> getSobj() {
return sobj; …Run Code Online (Sandbox Code Playgroud) 考虑一个像下面这样的html,
<div id="test">
{{ sometext }}
</div>
<span class="testing">
{{ asdknfsdf }}
</span>
Run Code Online (Sandbox Code Playgroud)
我想获取其内部文本{{ <sometext> }}在 jquery 中匹配的所有元素。我尝试了以下代码,但无法正确获取元素。我在这里缺少什么?
var elements = [];
$('*:contains("{{ .* }}")').each(function(){
elements.push(this);
});
Run Code Online (Sandbox Code Playgroud) 是否可以将VMware映像上传到Google Compute Engine?我知道它可能在亚马逊EC2中,但不幸的是我没有找到任何办法对GCE做同样的事情.
我无法让所有的传说出现在matplotlib中.
我的标签数组是:
lab = ['Google', 'MSFT', 'APPL', 'EXXON', 'WMRT']
Run Code Online (Sandbox Code Playgroud)
我使用下面的代码添加图例:
ax.legend(lab,loc="best")
Run Code Online (Sandbox Code Playgroud)
我只看到右上角的"谷歌".如何显示所有标签?

完整代码:
import numpy as np
import matplotlib.pyplot as plt
from itertools import cycle, islice
menMeans = (8092, 812, 2221, 1000, 562)
N = len(menMeans)
lab = ['Google', 'MSFT', 'APPL', 'EXXON', 'WMRT']
ind = np.arange(N) # the x locations for the groups
width = 0.35 # the width of the bars
fig, ax = plt.subplots()
my_colors = list(islice(cycle(['b', 'r', 'g', 'y', 'k']), None, N))
rects1 = ax.bar(ind, menMeans, width, …Run Code Online (Sandbox Code Playgroud) 我正在使用 cloudera 的 VM 来运行 hadoop。99% 的 dfs 空间已用完。所以我需要删除文件,但要删除文件,需要关闭安全模式。
我尝试使用以下命令关闭安全模式,
sudo -u hdfs hdfs dfsadmin -safemode leave
Run Code Online (Sandbox Code Playgroud)
它说它已关闭,但由于空间不足,它会自动打开它。当我尝试删除文件时,它说由于安全模式已打开,您无法删除文件。
SafeModeException: Cannot create directory /user/cloudera/.Trash/Current. Name node is in safe mode. Resources are low on NN. Please add or free up more resources then turn off safe mode manually. NOTE: If you turn off safe mode before adding resources, the NN will immediately return to safe mode.. (error 403)
Run Code Online (Sandbox Code Playgroud)
要删除文件,需要关闭安全模式。要关闭安全模式,我需要释放空间!那么如何清理文件以提供更多空间呢?
据我所知,AppEngine 项目仅定义为一个区域,Google 会自动为您处理负载平衡。但是,如果我在世界各地的不同地区有应用程序(在不同的项目中,因为这似乎是一个要求),那么我如何使用 Google Cloud 中的 HTTPS 负载均衡器根据请求来自的位置自动路由流量?(同时考虑标准和灵活)
我正在尝试在这里做一些简单的事情。从 pyodbc 获取行并将其用作创建数据帧的输入
import pyodbc
import sys
import csv
connection = pyodbc.connect("DSN=MySQL")
cursor = connection.cursor()
cursor.execute("SELECT * FROM customers")
rows = cursor.fetchall()
column_names = [x[0] for x in cursor.description]
print(rows)
print(column_names)
df = spark.createDataFrame(rows,column_names)
Run Code Online (Sandbox Code Playgroud)
但我得到以下跟踪:
raise TypeError("Can not infer schema for type: %s" % type(row))
TypeError: Can not infer schema for type: <class 'pyodbc.Row'>
Run Code Online (Sandbox Code Playgroud)
任何想法我在这里失踪?