我通常运行我的程序:
perl -e 'print "A"x200' | ./vuln_prog
Run Code Online (Sandbox Code Playgroud)
stdin由gets()C++中的函数使用.
如果这只是一个命令参数,我可以通过执行以下操作打开gdb:
gdb ./vuln_prog
run $(perl -e 'print "A"x200')
Run Code Online (Sandbox Code Playgroud)
但是,我的场景不是命令参数,而是输入(STDIN?).我如何在gdb中调试它?我尝试过很多选项,但似乎没什么用.
我通常只是在进程上运行gdb,当它提示用户输入时,输入它,但是我不想只键入"A".我想输入来自\ x00-\xff的所有字符,我无法输入.
我正在尝试为新的mvc3项目做一些概念类型代码的基本证明.我们正在使用Moq和RavenDB.
行动:
public ActionResult Index(string id)
{
var model = DocumentSession.Query<FinancialTransaction>()
.Where(f => f.ResponsibleBusinessId == id);
return View(model);
}
Run Code Online (Sandbox Code Playgroud)
测试:
private readonly Fixture _fixture = new Fixture();
[Test]
public void Index_Action_Returns_List_Of_FinancialTransactions_For_Business([Random(0, 50, 5)]int numberOfTransactionsToCreate)
{
// Arrange
var session = new Mock<IDocumentSession>();
var financialController = new FinancialController { DocumentSession = session.Object };
var businessId = _fixture.CreateAnonymous<string>();
var transactions = _fixture.Build<FinancialTransaction>()
.With(f => f.ResponsibleBusinessId, businessId)
.CreateMany(numberOfTransactionsToCreate);
// Mock
var ravenQueryableMock = new Mock<IRavenQueryable<FinancialTransaction>>();
ravenQueryableMock.Setup(x => x.GetEnumerator()).Returns(transactions.GetEnumerator);
ravenQueryableMock.Setup(x => x.Customize(It.IsAny<Action<Object>>()).GetEnumerator()).Returns(() => transactions.GetEnumerator()); …Run Code Online (Sandbox Code Playgroud) 我有一个抽象的"Action"类,它派生了ActionAppointment,ActionCall,ActionEmail和ActionLetter的类型.我正在尝试编写一个会干掉我们服务层的函数,所以我们不再编写5次CRUD调用了.
我在服务层中有一些更新逻辑(为简洁起见,删除了许多其他代码):
private IServiceResponse UpdateAction<T>(T action, string originalActionStatus) where T : Action
{
if (action.GetType() == typeof(Action))
{
_actionRepository.Update(action);
}
else if (action.GetType() == typeof(ActionAppointment))
{
_actionAppointmentRepository.Update(action as ActionAppointment);
}
else if (action.GetType() == typeof(ActionCall))
{
_actionCallRepository.Update(action as ActionCall);
}
else if (action.GetType() == typeof(ActionEmail))
{
_actionEmailRepository.Update(action as ActionEmail);
}
else if (action.GetType() == typeof(ActionLetter))
{
_actionLetterRepository.Update(action as ActionLetter);
}
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,我们的存储库是如何设置的,我必须使用专门命名的存储库(即,我无法通过_actionRepository更新ActionLetter,即使它派生自Action)
我一直在阅读不同的模式,它听起来像一个类似于工厂模式的东西,但我看不出如何让它工作.
我错过了一些愚蠢的东西吗?
我正在使用Entity Framework Code First和SqlCe4编写ASP.net MVC3应用程序.
我一直在设计几个模型,并发现一个变得有趣.这是我到目前为止:
public class Preference
{
public int PreferenceId { get; set; }
[Required]
public int StudentId { get; set; }
public virtual Student Student { get; set; }
[Required]
public int PresentationId { get; set; }
public virtual Presentation Presentation { get; set; }
[Required]
public int Rank { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
然而,我需要一个独特的约束或索引,因为对于特定的学生,我希望他们必须有一个偏好列表,但PresentationId需要对每个学生都是唯一的.有没有办法通过Code First或一些验证属性来做到这一点?
这听起来像是我将Preference对象作为中间人的多对多关系的分支,以添加Rank属性.但是,我似乎无法找到如何确保值是唯一的.真正的手动只是在EF之外的数据库中添加唯一索引是最好的方法吗?
我是rails的新手,并开始了一个新项目.我有rspec2和黄瓜与我的测试工作没有问题.但是,如果我尝试添加guard-rspec和guard-cucumber,则会导致我的规范和集成测试失败.虽然,即使安装了防护装置,如果我手动运行rspec和黄瓜,测试都会成功.
我添加到我的gemfile:
gem 'guard-rspec'
gem 'guard-cucumber'
gem 'growl', :require => false if RUBY_PLATFORM =~ /darwin/i
gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
Run Code Online (Sandbox Code Playgroud)
我跑了:
bundle
guard init rspec
guard init cucumber
Run Code Online (Sandbox Code Playgroud)
然后,当我跑卫,我得到rspec失败:
Failures:
1) PostsController GET index assigns all posts as @posts
Failure/Error: assigns(:posts).should eq([post])
expected [#<Post id: 14, title: "Title", body: "The body must be over 50 characters long, or else i...", created_at: "2011-08-16 09:02:26", updated_at: "2011-08-17 19:02:46">]
got [#<Post id: 1, title: "Title", body: "The body must …Run Code Online (Sandbox Code Playgroud) 我正在尝试更新数据库中的一堆记录,基于业余爱好网站的IMDB结果来学习Node和React.我对异步/等待代码和承诺相当新,所以我很挣扎.
根据我读过的内容,此代码应该:
相反,我得到以下控制台信息:
[0] Executing (default): SELECT `id`, `rank`, `name`, `IMDBId`, `rating`, `genre`, `posterUrl`, `createdAt`, `updatedAt`, `reviewerId`, `yearId` FROM `TopMovies` AS `TopMovie`;
[0] Movie count: 150
[0] All done
[0] Updated movie: Chef
[0] Executing (default): UPDATE `TopMovies` SET `rating`=3.5,`genre`='Adventure',`posterUrl`='https://images-na.ssl-images-amazon.com/images/M/MV5BMTY5NTYzNTA1M15BMl5BanBnXkFtZTgwODIwODU1MTE@._V1_UY268_CR0,0,182,268_AL_.jpg',`updatedAt`='2018-02-02 19:49:17.036 +00:00' WHERE `id` = 44
[0] Updated movie: The Champions
[0] Executing (default): UPDATE `TopMovies` SET `rating`=4.5,`genre`='10 October 2015 (USA) ',`posterUrl`='https://images-na.ssl-images-amazon.com/images/M/MV5BMTk5MjM2MjQ4MF5BMl5BanBnXkFtZTgwNjIxMDA5NzE@._V1_UX182_CR0,0,182,268_AL_.jpg',`updatedAt`='2018-02-02 19:49:17.092 +00:00' WHERE `id` = 87
[0] Updated movie: Trance
Run Code Online (Sandbox Code Playgroud)
请注意,它在输出"All done"后更新记录,并从app.get()函数返回.理想情况下,它会更像:
[0] …Run Code Online (Sandbox Code Playgroud) c# ×2
asynchronous ×1
cucumber ×1
express ×1
gdb ×1
javascript ×1
mocking ×1
moq ×1
node.js ×1
pipe ×1
ravendb ×1
rspec2 ×1
sql-server ×1
unit-testing ×1