如果我创建一个简单的项目:
ionic start MyApp
Run Code Online (Sandbox Code Playgroud)
并添加ImagePicker插件:
ionic plugin add https://github.com/wymsee/cordova-imagePicker.git -save
Run Code Online (Sandbox Code Playgroud)
只需将此示例www文件夹复制到项目中即可:
ionic platform add android
ionic build android
ionic run android
Run Code Online (Sandbox Code Playgroud)
一切都很好.我可以按预期选择多个图像而不会出现任何错误.
到现在为止还挺好.现在我尝试将其包含在我的项目中,所以我添加了ImagePicker插件.现在这是我的插件列表:
ionic plugin ls
com.synconset.imagepicker 1.0.6 "ImagePicker"
cordova-plugin-camera 1.1.0 "Camera"
cordova-plugin-device 1.0.0 "Device"
cordova-plugin-dialogs 1.1.0 "Notification"
cordova-plugin-splashscreen 2.0.0 "Splashscreen"
cordova-plugin-statusbar 1.0.0 "StatusBar"
cordova-plugin-vibration 1.1.0 "Vibration"
cordova-plugin-whitelist 1.0.0 "Whitelist"
Run Code Online (Sandbox Code Playgroud)
我创建了一个新模块:
angular.module('App.ImageSelect', [])
.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider.state('app.imageSelect', {
url: "/products/prints/pola/imageSelect",
views: {
'menuContent': {
templateUrl: "modules/products/prints/pola/imageSelect/imageSelect.html",
controller: 'ImageSelectController'
}
}
});
})
.controller('ImageSelectController', …Run Code Online (Sandbox Code Playgroud) 我对iOS编程很新,现在想要实现定期后台同步,以便将我的服务器数据与客户端数据同步.我想要实现的是与Androids相当的SyncAdapter,您可以在其中定义时间间隔(例如每30分钟),系统将在后台自动触发定义的任务.
到目前为止,我找不到Swift 3.0的这种机制,所以我需要问一下somone是否有经验或一些暗示我如何实现这一目标.
我想做的事听起来很简单:
当应用程序首次启动时,应用程序应设置同步管理器,该管理器每30分钟自动触发一次后台任务.后台任务负责同步服务器和客户端数据(使用Alamofire).
我怎样才能做到这一点?
我需要设置一个环境变量CLASSPATH。在该变量中,我需要设置命令的结果:
hadoop classpath --glob
Run Code Online (Sandbox Code Playgroud)
这将返回大量的 java 库,并且它们都需要设置到该CLASSPATH变量中。最大的问题是我只能在 docker 构建完成后运行这个命令,这意味着我必须在ENTRYPOINT. 但我就是无法让它发挥作用。我尝试了不同的方法:
ENTRYPOINT ["sh", "-c", "export CLASSPATH=$(hadoop classpath --glob) ...."
ENTRYPOINT ["sh", "-c", "set CLASSPATH=$(hadoop classpath --glob) ...."
ENTRYPOINT ["sh", "-c", "CLASSPATH=$(hadoop classpath --glob) ...."
ENTRYPOINT ["sh", "-c", "/bin/bash && export CLASSPATH=$(hadoop classpath --glob) ...."
Run Code Online (Sandbox Code Playgroud)
但这些都不起作用。该命令本身有效,我使用以下方法对其进行了测试:
ENTRYPOINT ["sh", "-c", "echo $(hadoop classpath --glob) >> /tmp/classpath.tmp ...."
Run Code Online (Sandbox Code Playgroud)
启动后该文件包含正确的内容。所以只是设置和保存环境变量有问题。我应该如何设置环境变量?通常你使用类似的东西
ENV CLASSPATH="some classpath"
Run Code Online (Sandbox Code Playgroud)
但在这里我无法使用该ENV语句,因为它不会处理命令$(hadoop classpath --glob)
我正在处理熊猫和Spark数据帧。数据帧始终很大(> 20 GB),而标准的火花功能不足以容纳这些大小。目前,我将我的熊猫数据框转换为火花数据框,如下所示:
dataframe = spark.createDataFrame(pandas_dataframe)
Run Code Online (Sandbox Code Playgroud)
我进行这种转换是因为通过火花将数据帧写入hdfs非常容易:
dataframe.write.parquet(output_uri, mode="overwrite", compression="snappy")
Run Code Online (Sandbox Code Playgroud)
但是,对于大于2 GB的数据帧,转换失败。如果将spark数据框转换为熊猫,则可以使用pyarrow:
// temporary write spark dataframe to hdfs
dataframe.write.parquet(path, mode="overwrite", compression="snappy")
// open hdfs connection using pyarrow (pa)
hdfs = pa.hdfs.connect("default", 0)
// read parquet (pyarrow.parquet (pq))
parquet = pq.ParquetDataset(path_hdfs, filesystem=hdfs)
table = parquet.read(nthreads=4)
// transform table to pandas
pandas = table.to_pandas(nthreads=4)
// delete temp files
hdfs.delete(path, recursive=True)
Run Code Online (Sandbox Code Playgroud)
这是从Spark到Pandas的快速会话,它也适用于大于2 GB的数据帧。我还找不到其他方法可以做到这一点。意思是有一个熊猫数据框,我在pyarrow的帮助下将其转换为火花。问题是我真的找不到如何将熊猫数据帧写入hdfs。
我的熊猫版本:0.19.0
我目前正在为我的 REST 端点编写一些基本的单元测试。我为此使用Mockito。这是一个例子:
@MockBean
private MyService service;
@Test
public void getItems() {
Flux<Item> result = Flux.create(sink -> {
sink.next(new Item("1"));
sink.next(new Item("2"));
sink.complete();
});
Mono<ItemParams> params = Mono.just(new ItemParams("1"));
Mockito.when(this.service.getItems(params)).thenReturn(result);
this.webClient.post().uri("/items")
.accept(MediaType.APPLICATION_STREAM_JSON)
.contentType(MediaType.APPLICATION_STREAM_JSON)
.body(BodyInserters.fromPublisher(params, ItemParams.class))
.exchange()
.expectStatus().isOk()
.expectBodyList(Item.class).isEqualTo(Objects.requireNonNull(result.collectList().block()));
}
Run Code Online (Sandbox Code Playgroud)
此实现会导致以下错误:
java.lang.AssertionError: Response body expected:<[Item(name=1), Item(name=2)]> but was:<[]>
> POST /items
> WebTestClient-Request-Id: [1]
> Accept: [application/stream+json]
> Content-Type: [application/stream+json]
Content not available yet
< 200 OK
< Content-Type: [application/stream+json;charset=UTF-8]
No content
Run Code Online (Sandbox Code Playgroud)
当我将 Mockito 语句中的参数与 Mockito.any()
Mockito.when(this.service.getItems(Mockito.any())).thenReturn(result); …Run Code Online (Sandbox Code Playgroud) 我想在DialogFragment中显示一个DatePicker:
public class DatePickerDialogFragment extends DialogFragment {
private OnDateSetListener dateSetListener = null;
private String title = null;
public DatePickerDialogFragment() {}
public DatePickerDialogFragment(OnDateSetListener dateSetListener, String title) {
this.dateSetListener = dateSetListener;
this.title = title;
}
public Dialog onCreateDialog(Bundle savedInstanceState) {
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
DatePickerDialog datePickerDialog = new DatePickerDialog(this.getActivity(), this.dateSetListener, year, month, day);
datePickerDialog.getDatePicker().setCalendarViewShown(false);
datePickerDialog.setTitle(this.title);
return datePickerDialog;
}
}
Run Code Online (Sandbox Code Playgroud)
遗憾的datePickerDialog.getDatePicker().setCalendarViewShown(false);是完全被忽略了.我讨厌日历视图,因为它很丑陋且不舒服.那我怎么能禁用它呢?
我正在使用MPAndroidChart 库。
我想用CombinedChart来创建这样的图表:

那可能吗?我试过了,但它似乎不起作用,因为条目没有按我预期的那样工作。你不能说一个条目的 x 轴值为 2,y 轴值为 300。我也不能创建两个不同的 y 轴,一个用于条形,一个用于线条。
一些奇怪的事情是 MPAndroidChart 首先添加所有 x 值,然后添加所有 y 值,您无法控制哪个 y 值属于哪个 x 值,因为它只是按照它们出现的顺序插入 y 值,将其与下一个 x 值相关联。
有什么方法可以用 MPAndroidChart.js 创建这样的图表。我实际上不想因为需要互联网连接而被迫使用 Google Charts(但创建这种图表将与 Google Charts 完美配合)。
林有工作RecyclerView,SyncAdapter并greenrobot eventbus
当我SyncAdapter完成syincing我发布一条消息到消息总线:
EventBus.getDefault().post(new EventMessagesRefreshed());
Run Code Online (Sandbox Code Playgroud)
在我的目标类中,我执行以下操作:
@Subscribe
public void onEvent(EventMessagesRefreshed event) {
this.init();
}
Run Code Online (Sandbox Code Playgroud)
在我的init()i中为recyclerview创建适配器并设置它:
public void init() {
if(this.listRowParent != null) {
this.adapter = new FragmentMessagesListAdapter(this.getActivity(), SingletonMessages.getInstance().getMessages());
this.listRowParent.setAdapter(this.adapter);
}
}
// listRowParent is my RecyclerView!
Run Code Online (Sandbox Code Playgroud)
接收事件的片段位于选项卡视图的内部.因此,当我不在正确的目标选项卡中时,有多个选项卡,有时还有消息总线中的SyncAdapter帖子,EventMessagesRefreshed但由于它已注册,它会尝试调用init()并创建适配器并将其设置为RecyclerView.如果发生这种情况,我会收到以下错误:
Could not dispatch event: class EventMessagesRefreshed to subscribing class class FragmentMessagesList
java.lang.IllegalStateException: Observer android.support.v7.widget.RecyclerView$RecyclerViewDataObserver@2c3421a7 was not registered.
at android.database.Observable.unregisterObserver(Observable.java:69)
at android.support.v7.widget.RecyclerView$Adapter.unregisterAdapterDataObserver(RecyclerView.java:5688)
at android.support.v7.widget.RecyclerView.setAdapterInternal(RecyclerView.java:873)
at android.support.v7.widget.RecyclerView.setAdapter(RecyclerView.java:857)
Run Code Online (Sandbox Code Playgroud)
所以我需要 …
我通过谷歌提供的iOS快速入门指南工作,注意它已经过时了很长时间.
因此,我研究了一整天,以了解它现在应该如何工作,但我没有找到有关如何实现它的工作解决方案/说明.
我有一个带日历的iOS应用程序.用户可以决定应该使用哪个日历来同步应用和日历之间的日历事件.应支持Google日历和Apple日历.Apple Calendar同步工作正常.对于Google日历,我还找不到任何解决方案.谷歌日历的用户应该可以将所有事件与我们的iOS应用程序同步(包括添加,删除和更改事件).
对于那些没有过时的内容是否有任何来源,并且描述了如何做到这一点?
可以说我们有以下课程:
public class NameCreator {
public String createName(String lastname) {
return lastname;
}
public String createName(String lastname, String firstName) {
return lastname + " " + firstname
}
...
}
Run Code Online (Sandbox Code Playgroud)
如果我想通过Java 8方法引用它:
NameCreator::createName
Run Code Online (Sandbox Code Playgroud)
我会得到错误:
Cannot resolve method createName
Run Code Online (Sandbox Code Playgroud)
如何定义我想要调用哪些方法?
android ×3
java ×2
angularjs ×1
apache-arrow ×1
apache-spark ×1
calendar ×1
cordova ×1
datepicker ×1
docker ×1
ios ×1
java-8 ×1
mocking ×1
mockito ×1
ngcordova ×1
pandas ×1
pyarrow ×1
python ×1
swift ×1
swift3 ×1
unit-testing ×1