我正在与一家小公司探讨合作关系.该公司正在寻找一种可以提高利润的算法,我有一些原型软件可以帮助他们.我的软件的核心是非常机密的,如果公司掌握它,那么他们肯定不需要我.我肯定会和他们签订合同,我会得到法律保护,但我仍然希望尽可能多地保护他们和我的"商业秘密".
我可能必须与他们的开发人员密切合作,以自动化我的算法并将其集成到他们的系统中,但我想在DLL中提供核心功能,这样我就可以保护我的"商业秘密",但仍然有能力与他们合作开发人员.鉴于我的情况,混淆是否值得?还有其他合理的选择吗?
C# 是否有类似于 C++ 的CHAR_BIT 的东西?
更新:
基本上,我正在尝试计算无分支的abs,这里是C++版本:
// Compute the integer absolute value (abs) without branching
int v; // we want to find the absolute value of v
unsigned int r; // the result goes here
int const mask = v >> sizeof(int) * CHAR_BIT - 1;
r = (v ^ mask) - mask;
Run Code Online (Sandbox Code Playgroud)
这是我的 C# 版本:
private int Abs(int value)
{
int mask = value >> sizeof(int) * 8 - 1;
return ((value ^ mask) - mask); …Run Code Online (Sandbox Code Playgroud) 我正在创建一个神经网络,并希望使用hash_map来保持每个神经元的输出神经元的权重参考:
class Neuron; //forward declaration was there (sorry I forgot to show it earlier)
typedef double WEIGHT;
typedef stdext::hash_map<boost::shared_ptr<Neuron>,WEIGHT> NeuronWeightMap;
class Neuron
{
private:
NeuronWeightMap m_outputs;
//...
public:
Neuron();
~Neuron();
//...
WEIGHT GetWeight(const boost::shared_ptr<Neuron>& neuron) const
{
NeuronWeightMap::const_iterator itr = m_outputs.find(neuron);
if( itr != m_outputs.end() )
{
return itr->second;
}
return 0.0f;
}
};
Run Code Online (Sandbox Code Playgroud)
我意识到我不能使用boost :: shared_ptr作为stdext :: hash_map的键,那么另一个建议是什么呢?是否有任何解决方法或是使用不同密钥或切换到std :: map的唯一选择?谢谢!
这是错误:
1>c:\program files (x86)\microsoft visual studio 8\vc\include\xhash(61) : error C2440: 'type cast' : cannot convert from 'const boost::shared_ptr<T>' to …Run Code Online (Sandbox Code Playgroud) 这是进行性能分析的有效方法吗?我想获得纳秒精度并确定类型转换的性能:
class PerformanceTest
{
static double last = 0.0;
static List<object> numericGenericData = new List<object>();
static List<double> numericTypedData = new List<double>();
static void Main(string[] args)
{
double totalWithCasting = 0.0;
double totalWithoutCasting = 0.0;
for (double d = 0.0; d < 1000000.0; ++d)
{
numericGenericData.Add(d);
numericTypedData.Add(d);
}
Stopwatch stopwatch = new Stopwatch();
for (int i = 0; i < 10; ++i)
{
stopwatch.Start();
testWithTypecasting();
stopwatch.Stop();
totalWithCasting += stopwatch.ElapsedTicks;
stopwatch.Start();
testWithoutTypeCasting();
stopwatch.Stop();
totalWithoutCasting += stopwatch.ElapsedTicks;
}
Console.WriteLine("Avg with typecasting = {0}", …Run Code Online (Sandbox Code Playgroud) 我正在构建一个ASP.NET MVC应用程序,我正在尝试将它部署在一个支持ASP.NET的免费主机(0000free)上.我尝试了一些东西,但没有一个工作(即我浏览到我的网站时只看到目录结构):
通常我只是将html文件放在public_html文件夹中,但我感觉MVC应用程序的部署过程略有不同.我是否必须修改Web.config或其他文件管理器?如何通常部署MVC应用程序(在免费主机上)?
更新:
我了解到主机使用Mono并支持.NET 4.0,但我仍然无法部署.
我有Visual Studio 2010,我使用它的发布功能(即右键单击项目名称并单击发布),我尝试了几件事:
主机论坛的搜索实用程序有点弱,所以我使用谷歌搜索他们的论坛:http://www.google.com/search? q =publish + asp.net + site%3A0000free.com%2Fforum% 2F&即= UTF-8&OE = UTF-8&A Q = T&RLS = org.mozilla:EN-US:官方与客户端= firefox的-A
我一直在阅读Pro ASP.NET MVC框架,他们有一章关于发布,但它没有提供有关发布位置的任何具体信息,这就是他们所说的(这在我的案例中并不是很有帮助) ):
我应该把我的申请放在哪里?
您可以将应用程序部署到服务器上的任何文件夹.当IIS首次安装时,它会自动为c:\ Inetpub\wwwroot \创建一个名为Default Web Site的网站的文件夹,但您不应该有任何义务将应用程序文件放在那里.将应用程序托管在与操作系统不同的物理驱动器上是很常见的(例如,在e:\ websites\example.com中).这完全取决于您,并且可能会受到诸如您计划如何备份服务器等问题的影响.
这是我在尝试查看Index.aspx页面时遇到的错误:
Unrecognized attribute 'targetFramework'. (/home/devarmy/public_html/Web.config line 1)
Description: HTTP 500. Error processing request.
Stack Trace:
System.Configuration.ConfigurationErrorsException: Unrecognized attribute 'targetFramework'. (/home/devarmy/public_html/Web.config …Run Code Online (Sandbox Code Playgroud) 我试图通过LINK to SQL在我的数据库中插入一个用户,我得到一个例外:
无法将值NULL插入列'UserID',表'mydatabase.developer.Users'; 列不允许空值.INSERT失败.该语句已终止.
我已将UserID标记为Users表中的主键,并且当我尝试在表中插入新用户时,我预计SQL Server将自动生成PK.
我几乎复制并粘贴了Pro ASP.NET MVC框架第4章"设置LINQ to SQL"中的示例.一切都井然有序......我的数据库有一个Users表,其中包含UserID(PK)列和Name列(两者都是非可空的),下面是与数据库表对应的类:
public class User
{
[DisplayName("User ID")]
[Column(IsPrimaryKey=true, IsDbGenerated=true, AutoSync=AutoSync.OnInsert)]
internal int UserID { get; set; }
[DisplayName("Name")]
[Column]
public string Name{ get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我还有一个存储库类,允许我修改数据库:
public class UsersRepository : IUsersRepository
{
private DataContext database;
private Table<User> usersTable;
public UsersRepository(string connectionString)
{
database = new DataContext(connectionString);
usersTable = database.GetTable<User>();
}
public void AddUser(User user)
{
usersTable.InsertOnSubmit(user);
try
{
database.SubmitChanges();
}
catch (Exception e)
{
var msg …Run Code Online (Sandbox Code Playgroud) 我正在寻找代码缩短的想法.我正在使用boost::scoped_lock锁定boost::mutex但我希望缩短我正在编写的代码量.
目前我mutex在我的班级中定义了一个名为的成员字段_sync.当我想要锁定时,我必须写:
scoped_lock<mutex> lock(_sync);
Run Code Online (Sandbox Code Playgroud)
棘手的部分是这是一个范围锁,所以我假设如果我写一个静态函数来返回scoped_lock,那么它一旦离开静态函数的函数范围就会解锁:
static scoped_lock<mutex> lock(mutex& sync)
{
return scoped_lock<mutex>(sync);
}
Run Code Online (Sandbox Code Playgroud)
这种方法可以很容易地输入:
public void Object::modify()
{
lock(_sync); // <-- nice and short! ;)
// do something to modify the object
//..
// the mutex is unlocked when we leave the scope of modify
}
Run Code Online (Sandbox Code Playgroud)
我的假设是否正确?scoped_lock当我的静态函数返回时会立即解锁吗?
假设我有一个class MyThread,Runnable用一个方法实现dosomething():
class MyThread implements Runnable{
Object dosomething(Parameter p){ ... }
run(){...};
}
Run Code Online (Sandbox Code Playgroud)
如果我做:
main(){
MyThread my = new MyThread().run();
Object o = my.dosomething(p);
}
Run Code Online (Sandbox Code Playgroud)
将在线程dosomething上myThread或main线程中执行?
如何dosomething从主线程开始执行myThread并检索返回的对象?
我试图端口一些代码为64位,但它似乎该线程地址在标识符_beginthreadex是unsigned int其为32位,我无法通过/接收一个64位的地址从函数标识符:
uintptr_t _beginthreadex( // NATIVE CODE
void *security,
unsigned stack_size,
unsigned ( __stdcall *start_address )( void * ),
void *arglist,
unsigned initflag,
unsigned *thrdaddr // <-- 32-bit address
);
Run Code Online (Sandbox Code Playgroud)
我检查了MSDN文档,但我没有看到该函数的64位版本.我是否包括错误的标头,每处理器标志或是否有其他方法来创建具有64位地址标识符的线程?
该文档声明该thrdaddr参数是32位:
Thrdaddr
Run Code Online (Sandbox Code Playgroud)Points to a 32-bit variable that receives the thread identifier. Might be NULL, in which case it is not used.
我创建了自己的TestService,它运行在一个单独的QThread,但MainLoop终止时,QThread::finished信号不会被发出.我看到了一个类似的问题,但问题略有不同,因为OP超载QThread而我只是将我的类移到线程上.
请注意,我不超载的QThread课,我只重载QObject基于这个例子:http://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation /
这是我的TestService班级:
#include <QObject>
#include <QThread>
#include <QMutex>
#include <QWaitCondition>
#include <iostream>
using namespace std;
class TestService: public QObject
{
Q_OBJECT;
private:
volatile int _count;
QWaitCondition _monitor;
QMutex _mutex;
QThread* _thread;
public:
TestService(int numSeconds)
{
_count = numSeconds;
_thread = NULL;
cout << "TestService()" << endl;
}
virtual ~TestService()
{
cout << "~TestService()" << endl;
}
void …Run Code Online (Sandbox Code Playgroud) c++ ×5
c# ×4
asp.net-mvc ×2
boost ×2
concurrency ×2
.net ×1
64-bit ×1
casting ×1
crt ×1
database ×1
dll ×1
function ×1
hashmap ×1
java ×1
linq-to-sql ×1
obfuscation ×1
performance ×1
publish ×1
publishing ×1
qt ×1
qthread ×1
scoped-lock ×1
shared-ptr ×1
shortcut ×1
sql ×1