在IIS 7下运行的ASP.Net 3.5似乎不允许开箱即用.
if (!EventLog.SourceExists("MyAppLog"))
EventLog.CreateEventSource("MyAppLog", "Application");
EventLog myLog = new EventLog();
myLog.Source = "MyAppLog";
myLog.WriteEntry("Message");
Run Code Online (Sandbox Code Playgroud) 我似乎在漂浮物上失去了很多精确度.
例如,我需要解决一个矩阵:
4.0x -2.0y 1.0z =11.0
1.0x +5.0y -3.0z =-6.0
2.0x +2.0y +5.0z =7.0
Run Code Online (Sandbox Code Playgroud)
这是我用来从文本文件导入矩阵的代码:
f = open('gauss.dat')
lines = f.readlines()
f.close()
j=0
for line in lines:
bits = string.split(line, ',')
s=[]
for i in range(len(bits)):
if (i!= len(bits)-1):
s.append(float(bits[i]))
#print s[i]
b.append(s)
y.append(float(bits[len(bits)-1]))
Run Code Online (Sandbox Code Playgroud)
我需要使用gauss-seidel解决,所以我需要重新排列x,y和z的方程式:
x=(11+2y-1z)/4
y=(-6-x+3z)/5
z=(7-2x-2y)/7
Run Code Online (Sandbox Code Playgroud)
这是我用来重新排列方程的代码.b是系数矩阵,y是答案向量:
def equations(b,y):
i=0
eqn=[]
row=[]
while(i<len(b)):
j=0
row=[]
while(j<len(b)):
if(i==j):
row.append(y[i]/b[i][i])
else:
row.append(-b[i][j]/b[i][i])
j=j+1
eqn.append(row)
i=i+1
return eqn
Run Code Online (Sandbox Code Playgroud)
然而,我得到的答案并不精确到小数位.
例如,在重新排列上面的第二个等式时,我应该得到:
y=-1.2-.2x+.6z
Run Code Online (Sandbox Code Playgroud)
我得到的是:
y=-1.2-0.20000000000000001x+0.59999999999999998z
Run Code Online (Sandbox Code Playgroud)
这似乎不是一个大问题,但是当你将数字提高到一个非常高的功率时,错误是非常大的.有没有解决的办法?我尝试了这个Decimal课程,但是它在功能方面效果不佳(即Decimal(x)**2 …
我的问题很像这个问题.但是我在MySQL上,我正在寻找能找到的"最低技术"解决方案.
情况是我有2个数据库应该有相同的数据,但它们主要是在它们无法相互联系时更新的.我怀疑有某种聚类或主/从的东西可以很好地同步它们.然而在我的情况下,这是一个主要的矫枉过正,因为这只是我自己使用的临时数据库.
有什么好办法呢?
我目前的方法是在其中一个上安装一个Federated表,并且经常通过插入/选择将数据通过线路填充到另一个.尝试处理主键有什么问题.(insert ignore似乎无法正常工作)
ps我可以轻松地构建一个选择要传输的行的查询.
问题实际上是关于C中的堆栈溢出.我有一个不能完成我的生活的分配,我已经查看了gdb中的所有内容,我只是无法想象它.
问题如下:
int i,n;
void confused()
{
printf("who called me");
exit(0);
}
void shell_call(char *c)
{
printf(" ***Now calling \"%s\" shell command *** \n",c);
system(c);
exit(0);
}
void victim_func()
{
int a[4];
printf("[8]:%x\n", &a[8]);
printf("Enter n: "); scanf("%d",&n);
printf("Enter %d HEX Values \n",n);
for(i=0;i<n;i++) scanf("%x",&a[i]);
printf("Done reading junk numbers\n");
}
int main()
{
printf("ls=736c --- ps = 7370 --- cal = 6c6163\n");
printf("location of confused %x \n", confused);
printf("location of shell_call %x \n", shell_call);
victim_func();
printf("Done, thank you\n");
}
Run Code Online (Sandbox Code Playgroud)
好的,所以我设法正确地得到了第一个问题,即任意调用主路径中未明确调用的两个函数之一.顺便说一下,这必须在运行程序时完成而不做任何修改.我这样做是通过运行程序,设置 …
我想断言一个方法只被调用一次.我正在使用RhinoMocks 3.5.
这是我认为会起作用的:
[Test]
public void just_once()
{
var key = "id_of_something";
var source = MockRepository.GenerateStub<ISomeDataSource>();
source.Expect(x => x.GetSomethingThatTakesALotOfResources(key))
.Return(new Something())
.Repeat.Once();
var client = new Client(soure);
// the first call I expect the client to use the source
client.GetMeMyThing(key);
// the second call the result should be cached
// and source is not used
client.GetMeMyThing(key);
}
Run Code Online (Sandbox Code Playgroud)
我想如果第二次调用测试失败GetMeMyThing()的呼叫source.GetSomethingThatTakesALotOfResources().
默认情况下,我们的Windows Forms应用程序将数据文件保存在用户的“我的文档”文件夹(在XP中)或“文档”文件夹(在Vista中)中。我们通过调用以下命令查找此位置:
Environment.GetFolderPath( Environment.SpecialFolder.Personal )
Run Code Online (Sandbox Code Playgroud)
我们肯定知道这对于个人文件夹位于本地磁盘上的用户非常有用。我们不确定的是对个人资料/个人数据文件夹具有“文件夹重定向”功能的域用户。
我的问题是:无论文件夹重定向是否处于活动状态,上述调用都能正确解决吗?
我没有测试该环境,也无法以任何一种方式找到任何确定的确认。
在任何人问之前,我没有做任何类型的屏幕抓取.
我正在尝试解析一个html字符串以找到具有特定id的div.我不能为我的生活让这个工作.以下表达式在一个实例中有效,但在另一个实例中没有.我不确定它是否与html中的额外元素有关.
<div\s*?id=(\""|"|")content(\""|"|").*?>\s*?(?>(?! <div\s*?> | </div> ) | <div\s*?>(?<DEPTH>) | </div>(?<-DEPTH>) | .?)*(?(DEPTH)(?!))</div>
Run Code Online (Sandbox Code Playgroud)
它正确地找到具有正确id的第一个div,但它然后在第一个结束div处关闭,而不是相关的div.
<div id="firstdiv">begining content<div id="content">some other stuff
<div id="otherdiv">other stuff here</div>
more stuff
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这应该带回来
<div id="content">some other stuff
<div id="otherdiv">other stuff here</div>
more stuff
</div>
Run Code Online (Sandbox Code Playgroud)
,但由于某种原因,它不是.它带回来:
<div id="content">some other stuff
<div id="otherdiv">other stuff here</div>
Run Code Online (Sandbox Code Playgroud)
有没有人有一个更容易表达来处理这个?
为了澄清,这是在.NET中,我正在使用DEPTH关键字.你可以在这里找到更多细节.
我必须读取一个txt文件,其中的行格式如下:
1: (G, 2), (F, 3) 2: (G, 2), (F, 3) 3: (F, 4), (G, 5) 4: (F, 4), (G, 5) 5: (F, 6), (c, w) 6: (p, f), (G, 7) 7: (G, 7), (G, 7) w: (c, w), (c, w)
每一行都将为结构提供数据(其中包含5个数字或字母).
阅读该行并获得我想要的字符串的最佳方法是什么?
我目前正在使用一系列条件,fgetc但这看起来很难看,也不是很聪明.
我不能使用数组,因为如果数字有两位数,行的大小可能会有所不同.
我怎么测试Controller.ViewData.ModelState?我宁愿没有任何模拟框架.
c ×2
.net ×1
.net-3.5 ×1
asp.net ×1
asp.net-mvc ×1
assertions ×1
c# ×1
database ×1
decimal ×1
event-log ×1
exploit ×1
file-io ×1
iis-7 ×1
mocking ×1
mysql ×1
oracle ×1
permissions ×1
python ×1
regex ×1
rhino-mocks ×1
sql ×1
sqlplus ×1
tdd ×1
windows-xp ×1
winforms ×1