我对 C++ 很陌生,遇到了一个我无法解决的问题。我正在尝试将 System::String 转换为 wchar_t 指针,该指针可以保留的时间超过函数的作用域。一旦我完成了它,我想正确地清理它。这是我的代码:
static wchar_t* g_msg;
void TestConvert()
{
pin_ptr<const wchar_t> wchptr = PtrToStringChars("Test");
g_msg = (wchar_t*)realloc(g_msg, wcslen(wchptr) + 1);
wcscpy(g_msg, wchptr);
free (g_msg); // Will be called from a different method
}
Run Code Online (Sandbox Code Playgroud)
当调用 free 时,我收到“检测到堆损坏:在 0x02198F90 处的正常块(#137)之后”。
为什么我会收到这个错误?
安德鲁·L
(
function restoreURL() {
function turnLongURL(data) {
window.location = data.url;
}
var shortUrl = window.location.href;
var url = "http://json-longurl.appspot.com/?url=" + shortUrl + "&callback=turnLongURL";
var script = document.createElement('script');
script.setAttribute('src', url);
document.getElementsByTagName('head')[0].appendChild(script);
})();
Run Code Online (Sandbox Code Playgroud)
代码在上面,但是萤火虫告诉我,turnLongURL 没有定义
这是为什么?
我很确定我已经包含了qanda类,但是当我尝试声明包含它的向量或类型的类时,我得到一个错误,说qanda未定义.知道问题可能是什么?
bot_manager_item.h
#pragma once
#include "../bot_packet/bot_packet.h"
#include <vector>
class bot_manager_item;
#include "qanda.h"
#include "bot_manager.h"
class bot_manager_item
{
public:
bot_manager_item(bot_manager* mngr, const char* name, const char* work_dir);
~bot_manager_item();
bool startup();
void cleanup();
void on_push_event(bot_exchange_format f);
bool disable;
private:
void apply_changes();
bot_manager *_mngr;
std::string _name;
std::string _work_dir;
std::string _message;
std::string _message_copy;
std::vector<qanda> games;
qanda test;
char _config_full_path[2600];
};
Run Code Online (Sandbox Code Playgroud)
qanda.h
#ifndef Q_AND_A
#define Q_AND_A
#include "users.h"
#include "..\bot_packet\bot_packet.h"
#include "bot_manager.h"
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <fstream>
class qanda
{ …Run Code Online (Sandbox Code Playgroud) function upload($path){
$config['overwrite'] = TRUE;
$config['allowed_types'] = 'jpg|jpeg|gif|png';
$config['max_size'] = 2000;
if($path =='profile'){
$config['upload_path'] = '../assets/uploads/avatars';
$config['file_name'] = $this->id;
}
if($path =='company'){
$config['upload_path'] = '../assets/uploads/company';
$config['file_name'] = $this->id.'_company';
}
$this->load->library('upload', $config);
$this->upload->do_upload();
$image_data = $this->upload->data();
if($path == 'profile'){
$this->db->update('be_user_profiles',array('avatar' => $image_data['file_name']), array('user_id' => $this->id));
}
if($path == 'company'){
$this->db->update('be_user_profiles',array('company_logo' => $image_data['file_name']), array('user_id' => $this->id));
}
$config = array(
'source_image' => $image_data['full_path'],
'new_image' => $this->upload_path,
'maintain_ratio' => true,
'width' => 500,
'height' => 500
);
$this->load->library('image_lib', $config);
$this->image_lib->resize();
}
Run Code Online (Sandbox Code Playgroud)
这是我的上传功能,它可以正常工作$path …
我有一段时间在工作中获得可行的标记.我是Ruby/RoR的新手,我觉得有时候这些插件(虽然很棒)缺乏对不习惯在Rails中工作的人的基本实现指令.
我有一个简单的内容模型,我希望能够添加标签.当我保存表单时,没有任何反应.我尝试输出标签,没有任何显示(我已经进入rails控制台,没有).我的内容模型(表格)上是否需要其他属性(列)?我有一种感觉,我错过了一些非常基本的东西.
内容模型:
class Content < ActiveRecord::Base
acts_as_taggable
# I've also tried acts_as_taggable :tags
end
Run Code Online (Sandbox Code Playgroud)
在我的形式部分:
<p>
<%= f.label 'Tags' %><br />
<%= f.text_field :tag_list %>
</p>
Run Code Online (Sandbox Code Playgroud)
在我的show.html.erb中:
<p>
<strong>Tags</strong>:
<% for tag in @content.tags %>
<%= link_to tag.name, contents_path(:view =>'tag', :tag => tag.name) %>
<% end %>
</p>
Run Code Online (Sandbox Code Playgroud)
我希望有人能让我指出正确的方向.谢谢!
编辑
这是日志的链接,你可以看到它保存了tag_list.
我终于开始进入Hadley Wickham令人印象深刻的ggplot2套餐,并且正在努力完成他的书.
在我的工作中,我经常使用文本标签显示散点图.这意味着一个plot()命令,然后是text().我曾经cex很快调整到我想要的字体大小.
我使用非常快速地创建了一个文本散点图qplot.但我无法快速调整大小.这是一个愚蠢的代码示例:
data(state)
qplot(Income,Population,data=as.data.frame(state.x77),geom=c("smooth","text"),method="lm",label=state.abb)
Run Code Online (Sandbox Code Playgroud)
在过去,我会这样做:
plot(xlim=range(Income),ylim=range(Population),data=state.x77,type="n")
text(Income,Population,state.abb,data=state.x77, cex=.5)
Run Code Online (Sandbox Code Playgroud)
如果我想的文本大小从我在默认看到减半(哦,我不得不这样做手工线性回归,并添加abline()来获得回归线 - 很高兴做这一切在通过GGPLOT2一个) .
我知道我可以添加尺寸调整大小,但它不是像我以前那样的相对大小调整.哈德利在推特上说我的尺寸是用毫米来衡量的,这对我来说并不完全直观.由于我经常调整绘图的大小,无论是在R还是在LaTeX中,绝对比例对我来说都没有用.
我必须遗漏一些非常简单的东西.它是什么?
哦 - 而且我知道我还没有真正使用过强大的ggplot2命令 - 只是想先把简单的东西放下来.
我知道,这听起来很愚蠢,但改变IB中的状态栏颜色,并没有改变任何东西.它总是保持灰色.我可以将代码改为黑色(有效),但在第一次启动时我仍然有这个灰色条.XCode是4.2 beta,现在无法下载新的.
有什么想法吗?
我听过其他人在数据完整性的上下文中提到Duplicate(),我想更好地了解它是如何工作的以及何时使用它.
我经常看到这个:
<cfreturn Duplicate(local.myVariable)>
Run Code Online (Sandbox Code Playgroud)
当这也返回相同的结果:
<cfreturn local.myVariable>
Run Code Online (Sandbox Code Playgroud) 我正在从头开始构建一个新项目.我创建了一个db,我一直在应用db结构,我用一个简短的不言自明的例子来解释:
表项 - >(Id,Name) - >包含一般信息
表ItemInfo - >(Item_Id,语言,描述) - >包含语言相关信息.
Id和Item_Id与外键关系连接.
我的想法是以一种最终只使用通过实体框架填充的单个POCO对象"Item"的方式对其进行建模.此对象仅包含公共属性:Id,Name和Description.语言将使用此对象隐藏到代码中,对象本身应负责根据包含该语言的全局变量提供正确的描述.
我已经尝试了几种方法来做到这一点并且总是遇到问题,因为实体框架不允许这种情况.我总是必须检索所有语言的信息,而不仅仅是当前语言或使用2个不同的查询.
所以最后我开始使用的解决方案是让T4模板同时创建Item和ItemInfo,然后手动添加类似于此的代码:
public partial class Item
{
private ItemInfo _itemInfo = null;
private ItemInfo itemInfo
{
get
{
if (_itemInfo == null) _itemInfo = ItemInfoes.Single(p => p.Language == GlobalContext.Language);
return _itemInfo;
}
}
public Description
{
get { return itemInfo.Description; }
set { itemInfo.Description = value;}
}
}
Run Code Online (Sandbox Code Playgroud)
使用此代码,我将ItemInfo中的其他属性添加到Item,并根据我的要求选择了正确的语言.你认为这是一个很好的解决方案吗?你会如何解决这个问题呢?
但是,运行sql profiler我可以看到2个不同的sql查询用于填充Item对象,一个查询Item表,另一个查询ItemInfo.
使用单个查询在两个表之间进行连接可以实现相同的方案吗?(我担心长期性能受到影响,这也就是我如何在没有ORM的情况下做到这一点).
任何建议都会受到欢迎,我有多年的编程经验,但我是Entity Framework和ORMs的新手.
请帮忙.
c# multilingual linq-to-entities entity-framework entity-framework-4
我一直在玩monodroid(预览8980),我正在尝试创建一个可在Android,WP7和Silverlight上运行的应用程序.
我的计划是建立一个单一的核心类库,然后为每个将包含UI东西平台的一个单独的项目 - 这样一个MonoDroid的项目,一个用于WP7和SL之一,所有这些都将引用核心类库.
这个问题的主要问题是,可以在核心库中实现一些功能,这些功能在Silverlight上可以正常工作,但在WP7上却不行.我认为确保不会发生这种情况的最佳方法是将核心库作为Silverlight 3项目,因为这将是最低的共同点.
我现在面临的问题是我无法从monodroid项目中引用SL3库.我收到这个警告 - '警告2项目'TMCore'无法被引用.引用的项目针对不同的框架系列(Silverlight)
有任何想法吗?
c# ×1
c++ ×1
c++-cli ×1
codeigniter ×1
coldfusion ×1
ggplot2 ×1
iphone ×1
javascript ×1
jsonp ×1
multilingual ×1
php ×1
r ×1
statusbar ×1
uistatusbar ×1
upload ×1