在闭包之外调用函数时会出现奇怪的行为:
任务不可序列化:java.io.NotSerializableException:testing
问题是我需要在类中的代码而不是对象.知道为什么会这样吗?Scala对象是否已序列化(默认?)?
这是一个有效的代码示例:
object working extends App {
val list = List(1,2,3)
val rddList = Spark.ctx.parallelize(list)
//calling function outside closure
val after = rddList.map(someFunc(_))
def someFunc(a:Int) = a+1
after.collect().map(println(_))
}
Run Code Online (Sandbox Code Playgroud)
这是一个非工作的例子:
object NOTworking extends App {
new testing().doIT
}
//adding extends Serializable wont help
class testing {
val list = List(1,2,3)
val rddList = Spark.ctx.parallelize(list)
def doIT = {
//again calling the fucntion someFunc
val after = rddList.map(someFunc(_))
//this will crash (spark lazy)
after.collect().map(println(_))
}
def someFunc(a:Int) …Run Code Online (Sandbox Code Playgroud) 看来,当我使用Angular cli创建一个Angular 2应用程序时.我的默认组件前缀是AppComponent的app-root.现在,当我将选择器更改为其他名称为"abc-root"时
@Component({
selector: 'abc-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
Run Code Online (Sandbox Code Playgroud)
vscode警告我,
[tslint] The selector of the component "AppComponent" should have prefix "app"
Run Code Online (Sandbox Code Playgroud) Google Chrome开发者窗口的" 网络 "标签中的状态列下的" 待处理 "是什么意思?
当我的页面脚本发出GET请求时,会发生这种情况,该请求的响应包含用于下载CSV文件的内容标题:
Content-type: text/csv;
Content-Disposition: attachment; filename=myfile.csv
Run Code Online (Sandbox Code Playgroud)
这在FF和IE7中工作正常,按预期下载CSV文件并打开文件选择器以保存文件,但Chrome不执行任何操作.我确认服务器会响应请求,因此Chrome似乎无法处理响应.
奇怪的是,如果我在Chromes地址栏中键入URL并点击,则所有工作都按预期工作.
仅供参考:Win-XP上的Chrome 10.0.648.204
我正在尝试通过USB将我的python应用程序接口与NFC设备连接.最好的选择似乎是pyusb,但我不能让它连接到libusb后端.我一直在
ValueError:没有可用的后端
我查看了堆栈跟踪,发现usb/backend/libusb10.py(这是pyusb的一部分)正在尝试加载libusb-1.0.dll以用作后端,但它无法找到它.这不是它不在我的道路上,它根本不在我的电脑上!
我安装了libusb-win32(http://libusb.org/wiki/libusb-win32),但生成的目录似乎只包含libusb0.dll.libusb-1.0.dll在哪里???
我很想知道在哪里获得该DLL,或者甚至不同的建议让pyusb在Windows 7上运行.
在一个textview中,我试图在不同的单词上分隔文本样式.
到目前为止,我有:
textview.setText(Html.fromHtml("<i><small><font color=\"c5c5c5\">" + "Competitor ID: " + "</font></small></i>" + "<font color=\"47a842\">" + compID + "</font>"));
Run Code Online (Sandbox Code Playgroud)
基本上,我说我想要"Competitor ID:"斜体,小巧,灰色.
我希望这个字符串compID是正常大小,而不是斜体和绿色.
代码的斜体和小部分完美地工作,但由于某种原因,整个文本视图具有灰色文本,而不仅仅是"Competitor ID:".
有任何想法吗?
假设我按照http://gunicorn.org/deploy.html#runit在gunicorn下启动Flask应用程序,有没有办法让我包含/解析/访问其他命令行参数?
例如,我可以foo以某种方式在Flask应用程序中包含和解析选项吗?
gunicorn mypackage:app --foo=bar
Run Code Online (Sandbox Code Playgroud)
谢谢,
我正在尝试使用arrayadapter过滤listview.arraydapter参数是String [] [].问题是任何事情都会发生.我必须覆盖Filter接口?在那种情况下,有人可以提供一些提示吗?
我试图过滤的数组的每个位置都是这样的
galleryValues[0][0] -> "tiulo"
[0][1] -> "desc"
[0][2] -> "etc"
Run Code Online (Sandbox Code Playgroud)
我试图过滤它:
lstContinente = (ListView)findViewById(R.id.list);
lstContinente.setTextFilterEnabled(true);
adapter = new PortaitArrayAdapter(cx,galleryValues);
lstContinente.setAdapter(adapter);
ed_busqueda.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
adapter.getFilter().filter(s.toString());
adapter.notifyDataSetChanged();
}
});
Run Code Online (Sandbox Code Playgroud)
适配器代码:
public class PortaitArrayAdapter extends ArrayAdapter<String> {
private final Context context;
private final String[][] values;
private List<Imagen> …Run Code Online (Sandbox Code Playgroud) 我想在图像查看器意图中显示我从下一个下载的png或jpg,但无法使其工作.
Bitmap bmp = getImageBitmap(jpg);
String path = getFilesDir().getAbsolutePath() + "/test.png";
File file = new File(path);
FileOutputStream fos = new FileOutputStream(file);
bmp.compress( CompressFormat.PNG, 100, fos );
fos.close();
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(path)), "image/png");
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
我知道位图已下载好了(使用相同的例程为我的应用程序中的其他地方提供我的ImageView实例) - 我认为它写入文件确定,我可以在磁盘上看到它并且文件大小正确.意图启动但抛出异常:
ERROR/ImageManager(1345):异常解码位图java.lang.NullPointerException
然后新活动就在那里,空白.这是如何运作的?
我有一个简单的程序,它查找目录中的所有压缩文件夹,定位一个压缩文件,获取位于压缩文件内的excel文件并将其移动到另一个位置(它为每个excel文件执行此操作,对于有多少压缩文件文件夹):
path = 'C:\Users\me\Documents\Extract'
new_path = 'C:\Users\me\Documents\Test'
i = 0
for folder in os.listdir(path):
path_to_folder = os.path.join(path, folder)
zfile = zipfile.ZipFile(os.path.join(path, folder))
for name in zfile.namelist():
if name.endswith('.xls'):
new_name = str(i)+'_'+name
new_path = os.path.join(new_path, new_name)
zfile.close()
#os.rename(path_to_folde, new_path) -- ERROR HERE
shutil.move(path_to_folde, new_path) -- AND ERROR HERE
i += 1
Run Code Online (Sandbox Code Playgroud)
我试过两种方法来移动excel文件os.rename和shutil.move.我一直在收到错误:
WindowsError:[错误32]由于另一个进程正在使用该进程,该进程无法访问该文件.
我不明白为什么这个错误仍然存在,因为我关闭了每个文件夹.
我正在尝试安装oh-my-zsh作为Docker构建的一部分(使用Dockerfile).这是有问题的dockerfile行:
RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh`
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
命令[/ bin/sh -c wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh]返回非零代码:1
要进行调试,我手动运行该命令并且它可以工作.有没有人有运气安装oh-my-zsh作为docker build的一部分?知道为什么如果以这种方式运行会有什么不同的行为?