我在Windows 10 PC上安装了Ubuntu Bash.之后使用apt-get install命令安装Redis 我可以使用命令连接到redis redis-cli信息显示详细信息
# Server
redis_version:2.8.4
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:a44a05d76f06a5d9
redis_mode:standalone
Run Code Online (Sandbox Code Playgroud)
之后我创建了一个我可以连接的复制品
发布我使用从/etc/redis/文件夹安装的默认配置文件启动Sentinel .
我用来启动redis的命令是 sudo redis-server /etc/redis/sentinel1.conf --sentinel
但是,如果我尝试使用redis-cli -p 26379命令连接,我会收到此错误
laptop:~$ redis-cli -p 26379
Could not connect to Redis at 127.0.0.1:26379: Connection refused
not connected>
Run Code Online (Sandbox Code Playgroud)
我检查了sentinel.conf文件,指定的端口是26379
我甚至尝试用redis-sentinel /path/to/sentinel.conf
相同的错误开始哨兵.
相同的设置在虚拟机上运行的Ubuntu上运行正常
编辑
我在WIndows 10 Bash上运行Ubuntu所以netstat -tunlpa命令显示了这一点
vipresh@VIPRESHJH:/etc/redis$ sudo netstat -tunlpa
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name …Run Code Online (Sandbox Code Playgroud) 我正在使用 Nodejs 来构建应用程序,我需要在其中处理某些字符串,为此我使用了 JS“RegExp”对象。我只希望正则表达式中的一部分字符串不区分大小写
var key = '(?i)c(?-i)ustomParam';
var find = '\{(\\b' + key +'\\b:?.*?)\}';
var regex = new RegExp(find,"g");
Run Code Online (Sandbox Code Playgroud)
但它因以下错误而中断
语法错误:正则表达式无效:/{(\b(?i)c(?-i)ustomParam\b:?.*?)}/
我将从某些外部源(如 redis)获取密钥,并从其他外部源获取要匹配的字符串,我希望第一个字母不区分大小写,其余字母区分大小写。
当我从外部来源获取密钥时,我将在第一个字母之前附加 (?i) 并在第一个字母之后附加 (?-i)。
我什至试过这个只是为了初学者,但这也不起作用
var key ='customParam';
var find = '(?i)\{(\\b' + key +'\\b:?.*?)\}(?-i)';
var regex = new RegExp(find,"g");
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用“i”标志而不是上面的标志,但这不是我的用例。我这样做只是为了检查。
我们网站上有一个中央网页,可根据某些条件将用户重定向到某个特定页面。重定向逻辑是使用 window.location.href 在 JavaScript 中编码的,但此重定向在 Facebook 应用程序浏览器中总是失败,但它在除 Facebook 应用程序内浏览器版本 323 之外的所有其他移动浏览器中运行良好。
我已经尝试了下面列出的所有其他可能的 JavaScript 重定向选项,但它们似乎都失败了。
<html><body><script type='text/javascript'> window.open("http://conv-test.mnetads.com/client-side-second-hop/");</script></body>
<html><body><script type='text/javascript'> eval('window.location.href ="http://conv-test.mnetads.com/client-side-second-hop/"');</script></body>
<html><body><script type='text/javascript'> setTimeout(window.location.href ="http://conv-test.mnetads.com/client-side-second-hop/", 10000);</script></body>
<html><body><script type='text/javascript'> setTimeout(window.onload = function(e){ location.replace("http://conv-test.mnetads.com/client-side-second-hop/"); }, 5000);</script></body>
<html><body><script type='text/javascript'> window.location ="http://conv-test.mnetads.com/client-side-second-hop/";</script></body></html>
// Sets the new location of the current window.
<html><body><script type='text/javascript'> window.location.assign("http://conv-test.mnetads.com/client-side-second-hop/");</script></body></html>
// Assigns a new URL to the current window.
<html><body><script type='text/javascript'> window.location.replace("http://conv-test.mnetads.com/client-side-second-hop/");</script></body></html>
// Replaces the location of the current window with the new one.
<html><body><script type='text/javascript'> self.location ="http://conv-test.mnetads.com/client-side-second-hop/";</script></body></html>
// Sets …Run Code Online (Sandbox Code Playgroud) System.Linq.Enumerable.WhereListIterator和System.Linq.Enumerable.WhereSelectListIterator有什么区别?
我注意到的一个区别是Type WhereListIterator反映了对集合对象的更改,但WhereSelectListIterator没有
我会更明确地说,例如.
我有一个场景,我从存储库中获取我的域对象
var buckets = testRepository.GetBuckets(testIds);
Run Code Online (Sandbox Code Playgroud)
然后我在循环中从上面的集合中选择某些桶
var bucketsForTest = buckets.Where(bucket => bucket.TestID == test.testId);
Run Code Online (Sandbox Code Playgroud)
然后我在LooserTrafficDisributor对象的方法中更改所有Bucket对象的单个属性.
ITrafficDistributor distributor = new LooserTrafficDisributor(bucketsForTest);
IEnumerable<Bucket> updatedBuckets = distributor.Distribute(test.AutoDecision);
Run Code Online (Sandbox Code Playgroud)
LooserTrafficDisributor的构造函数
public LooserTrafficDisributor(IEnumerable<Bucket> allBuckets)
{
this.allBuckets = allBuckets;
}
Run Code Online (Sandbox Code Playgroud)
LooserTrafficDistributor中的分配方法如下所示
private IEnumerable<Bucket> DistributeTraffic(bool autoDecision)
{
// allBuckets is class variable in LooserTrafficDistributor object which is set through constructor shown above .
// Omitted other details
allBuckets.Where(bucket=> bucket.IsControl == false).ToList()
.ForEach(bucket => bucket.TrafficPercentage += 10 ));
return allBuckets
}
Run Code Online (Sandbox Code Playgroud)
在此之后,我可以看到IEnumerable updatedBuckets集合中反映的变化.
但是如果我这样做,即不是从存储库中获取Bucket集合,而是以类似的方式选择&然后更新所有Bucket对象.
var …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用“--prof”选项来分析我的 Node 应用程序,但我看到不是一个单独的 v8.log 文件,而是创建了多个文件,这些文件使用了诸如isolate-0x9582b40-v8.log、isolate-0xa1cab78-v8-6049 这样的前缀.log、isolate-0xa7ffb40-v8.log、isolate-0xb5900468-v8.log、isolate-0xb6200468-v8-6049.log。
我无法使用 Linux-tick-processor 处理这些文件,因为我不知道要使用哪个文件进行处理。
我在 Vm VirtualBox 上运行以下配置 Ubuntu 12.4 Lts。节点版本 0.12.0
uname -a 的输出
Linux ubuntu 3.8.0-44-generic #66~precise1-Ubuntu SMP Tue Jul 15 04:04:23 UTC 2014 i686 i686 i386 GNU/Linux
节点 -v 的输出
v0.12.0
我正在使用EF5和Data First方法来更新实体.我正在使用其他问题建议的方法来有条件地更新实体中的已修改属性.
Oki所以这里的场景是我的控制器用POCO对象调用Service并从Service获取POCO对象,Service层与Data层对话,Data层在内部使用EF5从DB检索实体并在DB中更新它们.
控制器从服务层检索的DTO对象加载View数据.用户更改View和Posts将JSON数据发送回控制器,控制器映射到控制器中的DTO对象(礼貌MVC).控制器使用DTO对象(POCO)对象调用Service层.服务将POCO对象映射到EF实体对象,并调用传入EF实体的数据层(即存储库)更新方法.在Repository中,我从DB获取现有实体并调用ApplyCurrentvaluesValues方法,然后检查是否修改了任何属性.如果修改了属性,那么我将自定义逻辑应用于与当前实体无关的其他实体,并更新当前实体的"UpdatedAdminId"和"UpdationDate".发布这个我在Centext上调用"SaveChanges"方法.
我提到的每一件事都很好,除非我在"SaveChanges"调用中插入一个断点并将User修改的某些字段更新为不同的值,否则EF5不会抛出"DbUpdateConcurrencyException".即当我感兴趣的属性被修改为完美运行时,我可以获得有条件的更新并触发我的自定义逻辑.但是在并发的情况下我没有收到错误,即如果在我从DB获取记录,更新记录并保存记录之间更新记录,则EF不会引发"DbUpdateConcurrencyException".
在实际场景中,有一个离线cron运行,它检查新创建的广告系列并为它们创建投资组合,并将下面的IsPortfolioCreated属性标记为true,同时用户可以编辑广告系列,并且即使cron也可以将标志设置为false创建了投资组合.
为了复制并发场景,我在SaveChanges上设置了一个断点,然后从MS-Sql企业管理器中为同一个实体更新了IsPortfolioCreated feild,但是即使已经更新了Store中的Data,也不会抛出"DbUpdateConcurrencyException".
这是我的代码供参考,
Public bool EditGeneralSettings(CampaignDefinition campaignDefinition)
{
var success = false;
//campaignDefinition.UpdatedAdminId is updated in controller by retreiving it from RquestContext, so no its not comgin from client
var updatedAdminId = campaignDefinition.UpdatedAdminId;
var updationDate = DateTime.UtcNow;
CmsContext context = null;
GlobalMasterContext globalMasterContext = null;
try
{
context = new CmsContext(SaveTimeout);
var contextCampaign = context.CampaignDefinitions.Where(x => x.CampaignId == campaignDefinition.CampaignId).First();
//Always use this fields from Server, no matter what comes from client
campaignDefinition.CreationDate = contextCampaign.CreationDate; …Run Code Online (Sandbox Code Playgroud) 我的项目完全是用 CommonJS 模块编写的,我无法更改它。我正在尝试使用一个 ESM 库。该库是 Got 库(https://github.com/sindresorhus/got)。
这是我的代码
const request = require('request');
const Promise = require('bluebird');
// require('./wrapped-got');
var wrappedgot = null;
function HTTPRequestV2(hostURL, defaultOptions) {
this.hostUrl = hostURL;
this.requestWrapper = request.defaults(defaultOptions);
}
HTTPRequestV2.prototype.init = async function(){
wrappedgot = await import('got');
/*return import('got')
.then(({default: theDefault}) => {
wrappedgot= theDefault;
console.log(theDefault);
});
console.log(wrappedgot);*/
};
Run Code Online (Sandbox Code Playgroud)
但在运行此命令时,我收到错误Not Supported on thewrappedgot = wait import('got'); 线
我尝试按照问题页面中的建议使用动态导入函数的解决方法,但由于上述错误而失败 https://github.com/sindresorhus/got/issues/1789
甚至尝试运行他们的示例代码,但也失败并出现相同的错误 https://gist.github.com/szmarczak/0f2b70b2a1ed52a56a6d391ac02d094d
- - - 更新 - - - -
我使用的是 Node 版本 12.14.1,它支持异步和等待。我读过 …
Oki所以我想通过在.Net中添加随机盐来哈希我的密码.我用于此目的的内置类是RNGCryptoServiceProvider - 生成随机盐和Rfc2898DeriveBytes - 来散列实际密码.
但是当我调用Rfc2898DeriveBytes的GetBytes()函数以获得相同的passwordString,SaltBytes和Iteration计数组合时,结果会有所不同.我粘贴我的代码以供参考
public class PBKDF2Implementation
{
int minSaltSize = 32;
int maxSaltSize = 64;
public string CreateHash(string plainText , out string salt)
{
Random random = new Random();
int saltSize = random.Next(minSaltSize, maxSaltSize);
// Allocate a byte array, which will hold the salt.
byte[] saltBytes = new byte[saltSize];
// Initialize a random number generator.
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
// Fill the salt with cryptographically strong byte values.
rng.GetNonZeroBytes(saltBytes);
string strSalt = System.Text.Encoding.ASCII.GetString(saltBytes);
//string …Run Code Online (Sandbox Code Playgroud) c# ×3
javascript ×3
node.js ×2
ubuntu ×2
asp.net-mvc ×1
commonjs ×1
concurrency ×1
cryptography ×1
database ×1
es6-modules ×1
func ×1
hash ×1
inappbrowser ×1
linq ×1
linux ×1
node.js-got ×1
pbkdf2 ×1
redirect ×1
regex ×1
where ×1
windows-10 ×1