我需要将我的PDF文件中的某个部分裁剪为PNG(这将使用Ghostscript与PHP自动完成).这就是我现在所做的,基本上将PDF的第一页转为PNG:
gs -q -dNOPAUSE -dBATCH \
-sDEVICE=pngalpha -dEPSCrop \
-sOutputFile=output.png input.pdf
Run Code Online (Sandbox Code Playgroud)
具体来说,我正试图将这个左上角的卡片裁剪为PNG.我也愿意就如何实现这一目标提出更多建议.
当我没有在我的代码中调用相同的函数时,一切都运行良好,但是当函数突然从递归返回时,变量pch为NULL:
void someFunction()
{
char * pch;
char tempDependencies[100*64+100];
strcpy(tempDependencies,map[j].filesNeeded);
pch = strtok(tempDependencies,",");
while (pch != NULL)
{
someFunction(); <- if i comment this out it works fine
pch = strtok (NULL, ",");
}
}
Run Code Online (Sandbox Code Playgroud)
因此,例如当循环作用于字符串时,file2,file3,file4它正确地拆分file2并修改字符串,file2\\000file3,file4但下一次调用pch = strtok (NULL, ",");渲染pch为0x0.在调用递归时是否有我不知道的事情?
我想为包含另一个名为的结构的数组的结构分配内存table.我发现当在最后指定函数的指针时,linkedObjects数组中的变量被破坏,所以我认为我对动态内存的处理是错误的.
这就是我现在这样做的方式:
typedef struct Object {
void *key;
struct Object *top;
struct Object *next;
} Object;
typedef struct Table{
Object *linkedObjects;
size_t size, originalSize;
HashFcn hfun;
PrintFcn pfun;
ComparisonFcn fcomp;
} Table;
TableP CreateTable(size_t tableSize, HashFcn hfun, PrintFcn pfun, ComparisonFcn fcomp)
{
int i;
struct Table *table = malloc(sizeof(table));
if (table==NULL)
{
ReportError(MEM_OUT);
return NULL;
}
table->linkedObjects = NULL;
table->linkedObjects = malloc(tableSize * sizeof(Object));
for(i=0;i<tableSize;i++)
{
table->linkedObjects[i].next = malloc( MAX_IN_LIST*sizeof(Object) );
table->linkedObjects[i].top = malloc( MAX_IN_LIST*sizeof(Object) ); …Run Code Online (Sandbox Code Playgroud) 嘿伙计们,我想获得%APPDATA%文件夹的路径.
在win 2000&xp中它位于:C:\ Documents and Settings \用户名\ Application Data
在vista和win7中它位于:C:\ Users \用户名\ AppData\Roaming
我知道有SHGetSpecialFolderPath函数,但它检索BOOL,我想将路径作为字符串.
有人可以帮忙吗?
我正在使用此方法以允许最终用户邀请朋友:
FB.ui({method: 'apprequests', message: 'app message!', data:'tracking information for the user'});
Run Code Online (Sandbox Code Playgroud)
提示用户使用Facebook对话框,他可以在其中选择邀请:
或者在简短的图像中:

我不希望最终用户在这里有选择,只提示第三个选项 - 那些没有应用程序的选项.
有人能指出我正确的方向吗?我正在使用php + facebook的php sdk.
我在点击图像时使用jQuery来更改clases.在chrome&FF中一切都很好,但在ie9(可能也更早)当我点击其中一个图像时出现一些丑陋的灰色边框.
这是html代码:
<a id="PASTWINS" href="improve.php" class="PastWin_Unmarked"></a>
Run Code Online (Sandbox Code Playgroud)
这是风格:
.PastWin_Unmarked{border:0px;display: block;background-image:url('images/tomgui3_08.png');background-repeat:no-repeat;width:206px;height:43px;text-decoration:none;}
Run Code Online (Sandbox Code Playgroud)
这是一个出现丑陋边框的图像:

我使用代码从标点符号中删除一行文本:
line = line.rstrip("\n")
line = line.translate(None, string.punctuation)
Run Code Online (Sandbox Code Playgroud)
问题是,像话doesn't反过来doesnt所以现在我只想字之间去除标点符号,但似乎无法找出一种方法来做到这一点.我该怎么办呢?
编辑:我想过使用这个strip()函数,但这只会影响整个句子的左右拖尾.
例如:
Isn't ., stackoverflow the - best ?
Run Code Online (Sandbox Code Playgroud)
应该成为:
Isn't stackoverflow the best
Run Code Online (Sandbox Code Playgroud)
而不是当前的输出:
Isnt stackoverflow the best
Run Code Online (Sandbox Code Playgroud) 查看文档,没有任何关于如何发出POST请求的好例子.我需要使用auth_token参数发出POST请求并获得响应:
response = RestClient::Request.execute(method: :post,
url: 'http://api.example.com/starthere',
payload: '{"auth_token" : "my_token"}',
headers: {"Content-Type" => "text/plain"}
)
Run Code Online (Sandbox Code Playgroud)
400错误的请求错误:
RestClient::BadRequest: 400 Bad Request
from /Users/me/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rest-client-1.8.0/lib/restclient/abstract_response.rb:74:in `return!'
from /Users/me/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rest-client-1.8.0/lib/restclient/request.rb:495:in `process_result'
from /Users/me/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rest-client-1.8.0/lib/me/request.rb:421:in `block in transmit'
Run Code Online (Sandbox Code Playgroud)
如何使用RestClient发出POST请求的任何好例子?
编辑:
这是我在模型中提出请求的方式:
def start
response = RestClient::Request.execute(method: :post,
url: 'http://api.example.com/starthere',
payload: '{"auth_token" : "my_token"}',
headers: {"Content-Type" => "text/plain"}
)
puts response
end
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个脚手架但是想将has_many属性传递给generate命令,如下所示:
rails generate scaffold grade name:string {has_many :sections}
Run Code Online (Sandbox Code Playgroud)
这会生成破碎的模型:
class Grade < ActiveRecord::Base
attr_accessible :, :name, :{has_many
end
Run Code Online (Sandbox Code Playgroud)
而不是我需要的:
class Grade < ActiveRecord::Base
attr_accessible :name
has_many :sections
end
Run Code Online (Sandbox Code Playgroud)
如何将关系属性传递给generate命令?
我曾经在Ubuntu上使用Ruby版本1.9.3并进行了更新,可能搞砸了我的bash配置文件,我需要帮助才能将其转回而不是使用版本1.8.7.现在rails s用Ruby 1.8.7打开服务器,因为我在我的应用程序中使用了更新的语法,我得到了错误.
.bash_profile:
cat ~/.bash_profile
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Run Code Online (Sandbox Code Playgroud)
which rails:
/usr/local/bin/rails
Run Code Online (Sandbox Code Playgroud)
which ruby:
/usr/bin/ruby
Run Code Online (Sandbox Code Playgroud)
ruby -v:
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]
Run Code Online (Sandbox Code Playgroud)
rvm list:
rvm rubies
=* ruby-1.9.3-p194 [ i686 ]
# => - current
# =* - current && default
# * - default
Run Code Online (Sandbox Code Playgroud)
rvm use 1.9.3:
RVM …Run Code Online (Sandbox Code Playgroud)