小编Hou*_*man的帖子

如何以编程方式从图像列表中创建powerpoint

我已经看到了这个问题:以编程方式创建PowerPoint演示文稿,但这个问题问"你能吗?" 答案是肯定的.

但我问"怎么样?" 特别是"从图像列表?"

这就是我打破ppt到图像的方法

var app = new PowerPoint.Application();
var pres = app.Presentations;
var file = pres.Open(input, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
file.SaveAs(output, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsJPG, MsoTriState.msoTrue);
file.Close();
app.Quit();
Run Code Online (Sandbox Code Playgroud)

我该如何反过来?

c# powerpoint office-interop

6
推荐指数
1
解决办法
8492
查看次数

分配变量时Android内存不足

所以我明白了:

'01-01 20:37:34.859: E/dalvikvm-heap(19921): Out of memory on a 6471856-byte allocation.'
Run Code Online (Sandbox Code Playgroud)

尝试将一堆变量分配给内存时.我正在分配24个这样的变量:

mElements.add(new ShopElement(getResources(),R.drawable.shop_starter, b1X , b1Y,true,1,"red",true,5,checkLocked(0)));
Run Code Online (Sandbox Code Playgroud)

其中一个:

bNumbers = new Bitmap[] {Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h0)
        , 65,65, true),
        Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h1)
        , 65,65, true),
        Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h2)
        , 65,65, true),
        Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h3)
        , 65,65, true),
        Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h4)
        ,65,65,true),
        Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h5)
        , 65,65, true),
        Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h6)
        , 65,65, true),
        Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h7)
        , 65,65, true),
        Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h8)
        , 65,65, true),
        Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h9)
        , 65,65, true),
        Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.time)
                , 50,50, true)};
Run Code Online (Sandbox Code Playgroud)

但在我能够通过我创建的24个元素中的第16个之前,它会在某些手机上崩溃.

我有一个Galaxy S2,它运行良好,但在 …

memory android bitmap

5
推荐指数
1
解决办法
1170
查看次数

Android内存之间的活动泄漏

我试图找出这个内存泄漏.

我有两个SurfaceViews,A而且B.我开始A,然后导航到B,然后按后退按钮返回A,然后我B再次导航.

我每次执行此操作时都可以看到分配的内存增加,最终我会出现内存不足错误.

以下是我BSurfaceView连接内部导航到的方式A

        Context context =  this.getContext();
        Intent i =new Intent(context, StartCareer.class);
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        context.startActivity(i);
Run Code Online (Sandbox Code Playgroud)

在这两个视图中,我都有很多位图绘制.在B,我找不到任何引用A,并且在我可以想到的上下文之外的唯一引用是对我所拥有的Global类的引用.我还在后台进行了一些分析工作.我想,这可能是一百万种不同的东西

我在Eclipse上有DDMS视图,但我不确定我在看什么,或者如何找到不断重复的确切对象.

我接受DDMS分配跟踪器上的崩溃课程/教程,或者有人指出我做错了什么.


附加信息:

我有一些位图正在绘制SurfaceView.这样的例子B是:

////At class level
Bitmap rightB,leftB;
////In the constructor
rightB = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.right), 100,75, true);
////In doDraw
canvas.drawBitmap(rightB, rbX, rbY, null);
Run Code Online (Sandbox Code Playgroud)

还有我的onDestroys

@Override
public void surfaceDestroyed(SurfaceHolder holder) {


    if (mThread.isAlive()){
        mThread.setMenuRunning(false);
    }
}
Run Code Online (Sandbox Code Playgroud)

所以我运行MAT并发现一次泄漏,至少.我的 …

android memory-leaks

5
推荐指数
2
解决办法
4575
查看次数

如何在Node.js中关闭Elasticsearch的注销?

我正在使用elasticsearchnpm模块.我收到恼人的黄色警告,因为我的弹性搜索服务器目前已关闭.

我怎样才能使它不记录任何东西?

logging node.js elasticsearch

5
推荐指数
1
解决办法
2804
查看次数

在C#中将对象转换为Json并通过POST发送它会导致损坏的对象?

在C#上,我正在打印我发送到控制台的JSONified字符串,它的内容为

 { "message" : "done", "numSlides" : 1, "slides" : [{ "num" : 1, "key" : "530d8aa855df0c2d269a5a5853a47a469c
52c9d83a2d71d9/1slide/Slide1_v8.PNG" }], "bucket" : "xx.xxxxxxxxxx", "error"
: null, "wedge" : false, "tenant" : null, "name" : null }
Run Code Online (Sandbox Code Playgroud)

然后我这样做将它转换为字节数组并发送它

WebRequest request = WebRequest.Create(Program.api +"/"+ route);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";

//Get the request stream
Stream dataStream = request.GetRequestStream();
byte[] byteArray = Encoding.UTF8.GetBytes(myString);
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
Run Code Online (Sandbox Code Playgroud)

在node.js方面,我在console.logging res.body时得到这个:

{ '{ "message" : "done", "numSlides" : 1, "slides" : ': { '{ "num" …
Run Code Online (Sandbox Code Playgroud)

javascript c# json bytearray node.js

5
推荐指数
1
解决办法
114
查看次数

为什么我的茉莉花测试在DEFAULT_TIMEOUT_INTERVAL之前超时?

相关:无法为茉莉花设置超时

Jasmine 2.4.1

我的测试报告由于超时而导致失败,即使超时值似乎大于报告的时间.

我这样做:

describe('tests content controller', function(){
    beforeAll(function(done) {
        jasmine.DEFAULT_TIMEOUT_INTERVAL= 120000;
        //...
    })
    fit('/content GET should return 200',function(done){
        request(app)
        .get('/content')
        .set('Authorization', "bearer " + requestor.token)
        .set('Accept', 'application/json')
        .expect(200)
        .end(function (err, res) {
            console.log('timeout',jasmine.DEFAULT_TIMEOUT_INTERVAL); //prints 120000
            if (err) done.fail(err);
            expect(res.statusCode).toBe(200);
            done();
        })
    }); 
Run Code Online (Sandbox Code Playgroud)

然后这个测试失败,有:

1) tests content controller /content GET should return 200
  Message:
    Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
  Stack:
    Error: Timeout - Async callback was not invoked within timeout …
Run Code Online (Sandbox Code Playgroud)

javascript node.js jasmine supertest

5
推荐指数
1
解决办法
4015
查看次数

带有效json的意外标记?

为什么我不能打印这个简单的json?jsonlint.com说这是有效的

JSON:

[
   {
      "token_start_offset": "0.00",
      "token_duration": "4.00",
      "token_base_start_offset": "0.00",
      "token_base_duration": "4.00",
      "token_type": "background_noise",
      "token_background_noise_type": "other",
      "session_id": "1459194633575",
      "token_base_form": "…",
      "token_print_form": "…",
      "session_boundary": "begin",
      "nonspeech_boundary": "begin",
      "token_id": "0"
   }
]
Run Code Online (Sandbox Code Playgroud)

app.js:

var testJson = require('./json');

console.log(testJson);
Run Code Online (Sandbox Code Playgroud)

但是当我运行它时,我收到以下错误:

错误:

module.js:428
    throw err;
    ^

SyntaxError: C:\Users\Owner\Desktop\format test\json.json: Unexpected token  
    at Object.parse (native)
    at Object.Module._extensions..json (module.js:425:27)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (C:\Users\Owner\Desktop\format test\app.js:1:78)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
Run Code Online (Sandbox Code Playgroud)

Windows 10节点-v …

json node.js

5
推荐指数
1
解决办法
2765
查看次数

什么"......"在Javascript(ES6)中意味着什么?

我正在学习Redux,React和ES6.我已经用JS开发了,但是这个ES6的新世界让我很惊讶,有许多新的东西,比如"=>"来声明箭头函数和其他.然而,在这个新的Redux研究中,我...在我的代码中间面对.

贝娄我有一个例子:

import { combineReducers, createStore } from 'redux'

const userReducer = (state={}, action) => {
    switch(action.type) {
        case 'CHANGE_NAME':
            state = {...state, name: action.payload};
            break;
        case 'CHANGE_AGE':
            state = {...state, age: action.payload};
            break;
    }
    return state;
};

const tweetsReducer = (state=[], action) => {
    return state;
};

const reducers = combineReducers ({
    user: userReducer,
    tweetsReducer: tweetsReducer,
});


const store = createStore(reducers);

store.subscribe(() =>
    console.log('The chage was: ', store.getState())
);

store.dispatch({type: 'CHANGE_NAME', payload: 'Will'})
store.dispatch({type: 'CHANGE_AGE', payload: 21}); …
Run Code Online (Sandbox Code Playgroud)

javascript ecmascript-6 redux

5
推荐指数
1
解决办法
4582
查看次数

从C#运行时命令行进程不起作用

我正在尝试上传文件,然后使用服务器端进程进行转换.

这是在ASP.NET开发服务器localhost:8638上运行的Visual Studio Web ASP.NET Web应用程序的一部分

string fn = System.IO.Path.GetFileNameWithoutExtension(File1.PostedFile.FileName);
Process p = new Process();
                    p.StartInfo.WorkingDirectory = Server.MapPath("/Data");
                    p.StartInfo.FileName = "cmd.exe";
                    p.StartInfo.Arguments = "soffice --headless --invisible -convert-to pdf "+fn+".ppt";
                    p.StartInfo.UseShellExecute = false;
                    p.StartInfo.RedirectStandardOutput = true;
                    p.Start();
                    p.WaitForExit();
Run Code Online (Sandbox Code Playgroud)

我可以cmd.exeData目录内手动打开,然后输入这个命令,替换文件名,它就可以了.但是,运行此代码不会产生任何结果

我错过了什么,或做错了什么?

c# cmd process path filepath

4
推荐指数
1
解决办法
2689
查看次数

我怎样才能加速我的正则表达式?

我正在编写一个脚本来将我的内容的所有网址更改为新的位置.

var regex = /.*cloudfront.net/
var pDistro = "newDistro.cloudfront.net/"

for(var i=0;i<strings.length;i++){
    strings[i] = strings[i].replace(regex,pDistro);
}
Run Code Online (Sandbox Code Playgroud)

我正在做的字符串replace平均每个约140个字符.他们是遵循以下格式的网址:https://[thing to replace].cloudfront.net/[something]/[something]/[something]

但是这个操作非常慢,大约需要4.5秒来处理一个平均大小的阵列.

为什么这么慢?我怎样才能让它更快?

如果这个问题更适合代码回放堆栈交换或其他一些网站,请告诉我,我会把它移到那里.

编辑:

我在数据库中出现的数据似乎是140个字符.在拉取过程中,发生了一些虚拟化并在字符串上添加了400多个字符,因此难怪正则表达式需要这么长时间.

正如其他人所指出的那样,140字符串循环所需的时间要少得多.

故事的寓意:"确保你拥有的数据是你所期望的"和"如果你的正则表达式花了太长时间,使用较小的字符串和更具体的正则表达式(即没有通配符)"

javascript regex node.js

4
推荐指数
2
解决办法
1327
查看次数