问题:我有两个来自外部系统的固定宽度字符串.第一个包含基本字符(如az),第二个(MAY)包含要附加到第一个字符串以创建实际字符的变音符号.
string asciibase = "Dutch has funny chars: a,e,u";
string diacrits = " ' \" \"";
//no clue what to do
string result = "Dutch has funny chars: á,ë,ü";
Run Code Online (Sandbox Code Playgroud)
我可以写一个大规模的搜索并替换所有字符+不同的变音符号,但希望更优雅的东西.
有人知道如何解决这个问题吗?尝试计算小数值,使用string.Normalize(c#),但没有结果.谷歌也没有真正想出办法.
给出了下载管理器的示例.可以有任意数量的活动下载.
可以调度操作以启动,停止,标记完成并标记任何特定下载的下载进度.
const START_DOWNLOAD = "START_DOWNLOAD";
const startDownload = payload => ({ type: START_DOWNLOAD, payload });
const DOWNLOAD_PROGRESS = "DOWNLOAD_PROGRESS";
const downloadProgress = payload => ({ type: DOWNLOAD_PROGRESS, payload });
const STOP_DOWNLOAD = "STOP_DOWNLOAD";
const stopDownload = payload => ({ type: STOP_DOWNLOAD, payload });
const COMPLETE_DOWNLOAD = "COMPLETE_DOWNLOAD";
const completeDownload = payload => ({ type: COMPLETE_DOWNLOAD payload });
Run Code Online (Sandbox Code Playgroud)
这些操作将包含用于标识下载的ID,并可使用以下reducer修改redux状态:
const downloadReducer = (state = initialState, action) => {
switch (action.type) {
case STOP_DOWNLOAD:
return {
...state,
[action.payload.id]: {
state: "IDLE", …Run Code Online (Sandbox Code Playgroud)
我在SO上阅读了几个类似的问题并建议解决方案不起作用..
我想找到单词短于8的所有字段
我的数据库屏幕:
我尝试使用此查询执行此操作
{
"query": {
"match_all": {}
},
"filter": {
"script": {
"script": "doc['word'].length < 5"
}
}
}
Run Code Online (Sandbox Code Playgroud)
我做错了什么?我想念什么?
我Rx.Observable从一系列事件中创建了一个:
Rx.Observable.fromEvent(recognizeStream, 'data')
Run Code Online (Sandbox Code Playgroud)
其中每个数据事件如下所示:
{ error: null, alternatives: [result1, result2, result3] }
Run Code Online (Sandbox Code Playgroud)
我想在数组中获取每个值alternatives并将它们合并到流中.我需要看哪些操作员?
据我所知,flatMap并且concatMap可以完成这项工作,但我从他们的例子中得不到这个想法.
有人可以解释我应该使用哪个运算符并向我提供一个示例吗?
我正在构建一个Angular2应用程序,并且有两个BehaviourSubjects我想在逻辑上组合成一个订阅.我正在制作两个http请求,并希望在两个人都回来时发起一个事件.我期待在forkJoinVS combineLatest.似乎当更新behvaviorSubjects时,combineLatest将会触发,而forkJoin只会在所有behavoirSubjects更新后触发.它是否正确?必须有一个普遍接受的模式,这不是吗?
编辑
这是我的angular2组件订阅的一个behaviorSubjects的示例:
export class CpmService {
public cpmSubject: BehaviorSubject<Cpm[]>;
constructor(private _http: Http) {
this.cpmSubject = new BehaviorSubject<Cpm[]>(new Array<Cpm>());
}
getCpm(id: number): void {
let params: URLSearchParams = new URLSearchParams();
params.set('Id', id.toString());
this._http.get('a/Url/Here', { search: params })
.map(response => <Cpm>response.json())
.subscribe(_cpm => {
this.cpmSubject.subscribe(cpmList => {
//double check we dont already have the cpm in the observable, if we dont have it, push it and call next to propigate new cpmlist everywheres
if (! …Run Code Online (Sandbox Code Playgroud) 我想创建一个发出文件添加/删除(通过chokidar)的 observable 。我可以通过这样的方式做到这一点:
Rx.Observable.create((subscriber) => {
this.watcher = chokidar.watch(
this.contentPath
);
this.watcher.on('addDir', () => { subscriber.next(); });
this.watcher.on('unlinkDir', () => { subscriber.next(); });
});
Run Code Online (Sandbox Code Playgroud)
我想要做的是,如果没有订阅者,我想停止观看文件,并在订阅时重新开始。像这样的东西,但使用 RxJs:
class Notifier {
constructor() {
this.subscriberCount = 0;
}
subscribe(onNext, onError, complete) {
this.subscriberCount++;
if (this.subscriberCount === 1) {
this.startInternalWatcher();
}
return () => {
this.subscriberCount--;
if (this.subscriberCount === 0) {
this.stopInternalWatcher();
}
}
}
}
// files are not watched
const n = new Notifier(); …Run Code Online (Sandbox Code Playgroud) 目前我的web.config看起来像这样:
<configuration>
<connectionStrings configSource="connectionstrings.config"/>
</configuration>
Run Code Online (Sandbox Code Playgroud)
在生成部署包(Msbuild.exe + target = Package)时,它不会"神奇地"将我的连接字符串参数化到parameters.xml文件以进行部署时的替换.
当我内联我的连接线时,一切都很好,并为我的连接线生成参数..
所以:
如何通过web.config转换复制connectionstrings.config的内容作为部署<... configsource ="xxx"/>的替换?
编辑: 我接受了Sayed Ibrahim的答案,因为'默认'行为非常好(web.config中连接字符串的自动参数化)但最后更好地指定需要参数化的确切内容(通过{projectname} .wpp.targets或parameters.xml文件).
msbuild web-config msdeploy web-config-transform config-transformation
我想在flatMap中有一个条件来检查第一个observable返回的内容.如果条件不满足,我想打破并导航到不同的页面.
this.service.getData(id)
.flatMap((data) => {
if (!data) {
return Observable.throw(new NoDataFoundError());
}
return Observable.forkJoin(
this.service.getData2(id2),
this.service.getData3(id3),
);
})
.subscribe(
([data2, data3]) => {
this.data2= data2;
this.data3= data3;
},
(err) => {
if (err instanceof NoDataFoundError) {
this.router.navigate(...);
}
}
);
Run Code Online (Sandbox Code Playgroud)
目前我正在抛出特定错误并捕获它但是我不喜欢这个解决方案,因为它不是唯一可能引发错误的代码片段而if不是缩放.
我考虑过filter或takeWhile操作符,但我无法执行重定向.
我还考虑过返回Observable.of而不是扔(第4行),但后来我必须在订阅中做if也闻起来.
我正试图检测我所有的观察结果何时完成.我有以下Observables:
let observables:any[] = [];
if(valid){
observables.push(new Observable((observer:any) => {
async(()=>{
observer.next();
observer.complete();
})
}))
}
if(confirmed){
observables.push(new Observable((observer:any) => {
async(()=>{
observer.next();
observer.complete();
})
}))
}
Observable.forkJoin(observables).subscribe(
data => {
console.log('all completed');
},
error => {
console.log(error);
}
);
Run Code Online (Sandbox Code Playgroud)
每当我的所有功能都完成时,我需要做一些事情.当observables数组不为空时,Forkjoin似乎有效.但是当数组为空时,它永远不会被调用.我怎么解决这个问题?
我正在尝试查看删除选项是否适用于 webhdfs :
http://ec2-ab-cd-ef-hi.compute-1.amazonaws.com:14000/webhdfs/v1/user/barak/barakFile.csv?op=DELETE&user.name=hadoop
Run Code Online (Sandbox Code Playgroud)
但我收到一个错误:
{"RemoteException":{"message":"Invalid HTTP GET operation [DELETE]",
"exception":"IOException","javaClassName":"java.io.IOException"}}
Run Code Online (Sandbox Code Playgroud)
此文件拥有所有权限 (777)。
[hadoop@ip-172-99-9-99 ~]$ hadoop fs -ls hdfs:///user/someUser
Found 2 items
-rwxrwxrwx 1 hadoop hadoop 344 2015-12-10 08:33 hdfs:///user/someUser/someUser.csv
Run Code Online (Sandbox Code Playgroud)
我还应该检查什么以允许通过 Amazon EMR WEBHDFS 删除选项