我正在尝试做一些我认为会很简单的事情,但它不是那么直接而谷歌没有帮助.
我使用iTextSharp将PDF文档(字母)合并在一起,这样它们就可以一次打印出来.如果一个字母有奇数页面我需要附加一个空白页面,所以我们可以双面打印这些字母.
这是我目前合并所有字母的基本代码:
// initiaise
MemoryStream pdfStreamOut = new MemoryStream();
Document document = null;
MemoryStream pdfStreamIn = null;
PdfReader reader = null;
int numPages = 0;
PdfWriter writer = null;
for int(i = 0;i < letterList.Count; i++)
{
byte[] myLetterData = ...;
pdfStreamIn = new MemoryStream(myLetterData);
reader = new PdfReader(pdfStreamIn);
numPages = reader.NumberOfPages;
// open the streams to use for the iteration
if (i == 0)
{
document = new Document(reader.GetPageSizeWithRotation(1));
writer = PdfWriter.GetInstance(document, pdfStreamOut);
document.Open();
}
PdfContentByte cb = …Run Code Online (Sandbox Code Playgroud) 我想创建一个条形图,使用字符串作为x轴上刻度线的标签(例如,1年级,2年级等,而不是0,1,2等).
我开始使用x轴的数值(例如,0,1,2,3等),如下所示:
1)我生成我的范围:
x = d3.scale.ordinal()
.domain(d3.range(svg.chartData[0].length)) //number of columns is a spreadsheet-like system
.rangeRoundBands([0,width], .1);
y = d3.scale.linear()
.domain(Math.min(d3.min(svg.chartData.extent),0), Math.max(d3.min(svg.chartData.extent),0)])
.range([height, 0])
.nice();
Run Code Online (Sandbox Code Playgroud)
2)制作轴:
d3.svg.axis()
.scale(x);
Run Code Online (Sandbox Code Playgroud)
3)重绘轴:
svg.select(".axis.x_axis")
.call(make_x_axis().orient("bottom").tickSubdivide(1).tickSize(6, 3, 0));
Run Code Online (Sandbox Code Playgroud)
这适用于默认数字轴标签.
如果我尝试使用像这样的x tickValues的字符串数组....
d3.svg.axis()
.scale(x).tickValues(svg.pointsNames); //svg.pointsNames = ["Year 1", "year 2", etc.]
Run Code Online (Sandbox Code Playgroud)
...当我重绘图表时(对数据/设置进行更改或不进行更改),标签会像这样交换.

注意Col 1如何取代Col 0,反之亦然.
你知道为什么会这样吗?
我需要检查一个C字符串是否是一个有效的整数.
我试过了两个
int num=atoi(str);
Run Code Online (Sandbox Code Playgroud)
和
int res=sscanf(str, "%d", &num);
Run Code Online (Sandbox Code Playgroud)
但是"8 -9 10"在两行中发送字符串只返回8,而没有指出该字符串的无效性.
有人可以建议替代方案吗?
我有一些看起来像这样的JSON数据:
{
"910719": {
"id": 910719,
"type": "asdf",
"ref_id": 7568
},
"910721": {
"id": 910721,
"type": "asdf",
"ref_id": 7568
},
"910723": {
"id": 910723,
"type": "asdf",
"ref_id": 7568
}
}
Run Code Online (Sandbox Code Playgroud)
我如何使用JSON.net解析这个?我可以先这样做:
JObject jFoo = JObject.Parse(data);
Run Code Online (Sandbox Code Playgroud)
我需要能够遍历此列表中的每个对象.我希望能够做到这样的事情:
foreach (string ref_id in (string)jFoo["ref_id"]) {...}
Run Code Online (Sandbox Code Playgroud)
要么
foreach (JToken t in jFoo.Descendants())
{
Console.WriteLine((string)t["ref_id"]);
}
Run Code Online (Sandbox Code Playgroud)
但当然这不起作用.如果您在编写代码时知道密钥,那么所有示例都能很好地工作.如果您事先不知道密钥,它会崩溃.
我有这样的文件,有翻译键和值:
locale-en.json
{
"CHANGE_PASSWORD": "Change Password",
"CONFIRM_PASSWORD": "Confirm Password",
"NEW_PASSWORD": "New Password"
}
locale-jp.json
{
"CHANGE_PASSWORD": "???????????",
"CONFIRM_PASSWORD": "???????????",
"NEW_PASSWORD": "????????"
}
Run Code Online (Sandbox Code Playgroud)
例如,当我向包含英语翻译的JSON文件添加新的翻译密钥时,我必须记住将该密钥和相关的翻译添加到所有其他JSON文件中.所有JSON文件也都单独编辑.这个过程很费力且容易出错.
有没有人找到减少错误和自动化过程的方法.
理想情况下,我希望能够从Windows PowerShell运行一个脚本,如果向locale-en.json添加了一个额外的密钥,该脚本会将文件更改为:
locale-en.json
{
"CHANGE_PASSWORD": "Change Password",
"CONFIRM_PASSWORD": "Confirm Password",
"NEW_PASSWORD": "New Password",
"NEW_KEY": "New Key"
}
locale-jp.json
{
"CHANGE_PASSWORD": "???????????",
"CONFIRM_PASSWORD": "???????????",
"NEW_PASSWORD": "????????",
>>>"NEW_KEY": "New Key"
}
Run Code Online (Sandbox Code Playgroud) 我有一个Java应用程序,它创建一个外部进程并通过InputStream读取进程'stdout.当我完成它时,我需要能够杀死进程.有没有办法向这个过程发送SIGINT信号?(好像我从控制台按下Ctrl + C).
外部进程不是我的代码,我无法修改它.
是否有可能在另一个heredoc中写一个heredoc?
ssh -T -q yxz@server1 <<-"END_TEXT"
.
.
ssh -T -q abc@server2 <<-"SUB_TEXT"
.
.
SUB_TEXT
.
.
END_TEXT
Run Code Online (Sandbox Code Playgroud) 我必须编写一个程序,其中main调用其他函数来测试一系列数字(如果有的话)是否小于一个数字,如果所有系列的数字都在两个限制之间,如果有的话是负数.我的代码返回值为1表示true,0表示false表示,但是赋值会将它们打印为"true"或"false".我不知道如何将bool答案从printf打印为字符串.我使用if(atl == false)printf("false"); 在我的at_least.c和main.c中,它只返回一个true或false的长字符串(例如:truetruetrue ....).我不确定这是不是正确的编码,我把它放在错误的位置,或者我需要使用其他一些代码.
这是我的main.c:
#include "my.h"
int main (void)
{
int x;
int count = 0;
int sum = 0;
double average = 0.0;
int largest = INT_MIN;
int smallest = INT_MAX;
bool atlst = false;
bool bet = true;
bool neg = false;
int end;
while ((end = scanf("%d",&x)) != EOF)
{
sumall(x, &sum); //calling function sumall
count++;
larger_smaller(x, &largest, &smallest); //calling function larger_smaller
if (atlst == false)
at_least(x, &atlst); //calling function at_least if x < 50 …Run Code Online (Sandbox Code Playgroud) 我突然遇到初始化Eclipse Kepler的错误:
An internal error occurred during: "Repository registry initialization".
For input string: "(pilgrim's conflicted copy 2013-10-18).gen"
Run Code Online (Sandbox Code Playgroud)