问题列表 - 第31736页

在两个其他字符串之间按字母顺序生成字母字符串的算法?

我试图解决的一个问题:假设你有两个由小写字母a到z组成的不同字符串,在两个字符串之间找到一个字符串,这样就可以找到更多的中间字符串.

更多细节:

鉴于'a'按字母顺序排在'b'之前,'a'和'b'之间有无数个字符串,当按字典排序时:'aa','aaa','aaaa','ab' ,'aba'等.但是,所有字符串之间没有无限数量的字符串 - "a"和"aa"之间没有任何字符串.此外,在'a'和'aaa'之间只存在一个中间的字符串'aa'.

什么算法可以找到字母顺序排列在'a'和'b'之间的字符串X,它还满足'a'和X以及X和'b'之间存在无限数量字符串的条件?

algorithm

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

python是移动应用程序的首选语言吗?

我的很多朋友都在使用Python来构建他们的移动应用程序和游戏.

python是开发人员移动应用程序的首选语言吗?如果是这样,为什么?

python mobile

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

在Python中有效地执行多个字符串替换

如果我想进行多个字符串替换,那么最有效的方法是什么呢?

我旅行中遇到的一种情况如下:

>>> strings = ['a', 'list', 'of', 'strings']
>>> [s.replace('a', '')...replace('u', '')  for s in strings if len(s) > 2]
['a', 'lst', 'of', 'strngs']
Run Code Online (Sandbox Code Playgroud)

python string immutability

8
推荐指数
1
解决办法
5184
查看次数

CakePHP中有多贵('count')?

我有,我想获得多少每一类岗位的用户的计数的CakePHP程序.我也使用paginate帮助器在他们的个人资料上显示所有用户的帖子.
我可以:
1)做一个find('all', $conditions)请求所有用户帖子然后解析,对于我需要(通过去通过后后,并检查它是否符合我要找的)计数.
2)进行乘法find('count', $conditions)请求,得到我需要的所有计数.
3)用户的表维护新列的职位创建(认沽每当一个新的职位是由将涉及编写用户帐户),当跟踪这些数字.
哪一个是最好的选择?

php mysql performance cakephp count

3
推荐指数
1
解决办法
4224
查看次数

CGBitmapContextCreateImage - vm_copy失败 - iPhone SDK

我在我的iPhone应用程序中使用CGBitmapContextCreateImage时遇到问题.

我正在使用AV Foundation Framework使用此方法抓取相机帧:

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
    CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
    CVPixelBufferLockBaseAddress(imageBuffer,0);
    uint8_t *baseAddress = (uint8_t *)CVPixelBufferGetBaseAddress(imageBuffer);
    size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer);
    size_t width = CVPixelBufferGetWidth(imageBuffer);
    size_t height = CVPixelBufferGetHeight(imageBuffer);
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGContextRef newContext = CGBitmapContextCreate(baseAddress, width, height, 8, bytesPerRow, colorSpace, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);
    CGImageRef newImage = CGBitmapContextCreateImage(newContext);
    CVPixelBufferUnlockBaseAddress(imageBuffer,0);
    CGContextRelease(newContext);
    CGColorSpaceRelease(colorSpace);

    UIImage *image= [UIImage imageWithCGImage:newImage scale:1.0 orientation:UIImageOrientationRight];
    self.imageView.image = image;

    CGImageRelease(newImage);

} 
Run Code Online (Sandbox Code Playgroud)

但是,我在调试控制台中看到一个错误:

<Error>: CGDataProviderCreateWithCopyOfData: vm_copy failed: status 2.
Run Code Online (Sandbox Code Playgroud)

有没有人见过这个?通过注释掉我的问题,我将问题排成一行:

CGImageRef newImage = CGBitmapContextCreateImage(newContext);
Run Code Online (Sandbox Code Playgroud)

但我不知道如何摆脱它.从功能上讲,它很棒.很明显,CGImage正在创建,但我需要知道是什么导致错误,所以它不会影响其他部分. …

iphone objective-c cgimage

10
推荐指数
1
解决办法
4824
查看次数

Android ==>子活动?

是否可以在当前活动之上添加活动.例如,假设我单击一个按钮,然后它向当前活动添加第二个活动.第二项活动只涵盖了我当前活动的一小部分.

android subactivity android-activity

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

JQuery JEditable - 如何在单击编辑时禁用

我想知道你是否可以阻止文字在点击时被编辑?我有一个单独的编辑按钮,使文本可编辑,这是我希望用户能够编辑文本的唯一方法,所以想要关闭点击编辑?

有任何想法吗?

javascript jquery jeditable

8
推荐指数
1
解决办法
3149
查看次数

Android:将RawFile复制到SD卡(视频mp4)

这段代码有什么问题?
我在我的项目(mp4 videofile)中有一个Raw文件,
当我这样做,然后我从SDcard文件中检索文件不相同所以视频无法加载:(
你有另一种方法自动复制原始文件到SD卡?
谢谢

String FICHIER_BLOW = "blowvid4.mp4";
File f=new File(Environment.getExternalStorageDirectory(), FICHIER_BLOW);
try {
    if (f.createNewFile()){
    FileWriter ecrivain = new FileWriter(f);
    BufferedWriter bufEcrivain = new BufferedWriter(ecrivain);
    BufferedInputStream VideoReader = new BufferedInputStream(getResources().openRawResource(R.raw.blow));
    while( VideoReader.available() > 0 ){
        bufEcrivain.write(VideoReader.read());
    }
    bufEcrivain.close();

    VideoView videoView = (VideoView) findViewById(R.id.VideoView);
    MediaController mediaController = new MediaController(this);
    mediaController.setAnchorView(videoView);
    video =Uri.fromFile(f);
    videoView.setMediaController(mediaController);
    videoView.setVideoURI(video);
    videoView.start();
    }
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

java video android android-sdcard

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

.Net为什么Threading.Task.Task仍会阻止我的UI?

我目前正在编写一个控制测量设备定位的应用程序.由于涉及硬件,我需要在运行电动机时不断轮询当前位置值.我正在尝试构建对此负责的类,以便它在后台线程上进行轮询,并在达到所需位置时引发事件.这个想法是轮询不会阻止应用程序的其余部分或GUI.我想使用新的Threading.Task.Task类来处理所有后台线程管道.

我还没有硬件,但已经构建了一个测试存根来模拟这种行为.但是当我像这样运行应用程序时,GUI仍会阻塞.请参阅下面代码的简化示例(不完整,不使用单独的类进行设备控制).代码具有一系列测量步骤,应用程序必须定位然后测量每个步骤.

public partial class MeasurementForm: Form
{
    private MeasurementStepsGenerator msg = new MeasurementsStepGenerator();
    private IEnumerator<MeasurementStep> steps;

    // actually through events from device control class
    private void MeasurementStarted()
    {
        // update GUI
    }

    // actually through events from device control class
    private void MeasurementFinished()
    {
        // store measurement data
        // update GUI
        BeginNextMeasurementStep();
    }

    private void MeasurementForm_Shown(object sender, EventArgs e)
    {
        steps = msg.GenerateSteps().GetEnumerator();
        BeginNextMeasurementStep();
    }        
    ...
    ...

    private void BeginNextMeasurementStep()
    {
        steps.MoveNext();
        if (steps.Current != null)  
        { 
            MeasurementStarted();
            MeasureAtPosition(steps.Current.Position); …
Run Code Online (Sandbox Code Playgroud)

multithreading .net-4.0

16
推荐指数
2
解决办法
4843
查看次数

在Zend_HTTP_Client中跳过SSL检查

我正在使用Zend_HTTP_Client将HTTP请求发送到服务器并获得响应.我发送请求的服务器是HTTPS Web服务器.目前,一次往返请求大约需要10-12秒.我理解开销可能是因为请求所依赖的Web服务器的处理速度很慢.

是否有可能像我们在CURL中那样跳过SSL证书检查以加快性能?如果是这样,如何设置这些参数?

我有以下代码:

    try
    {
        $desturl ="https://1.2.3.4/api";

        // Instantiate our client object
        $http = new Zend_Http_Client();

        // Set the URI to a POST data processor
        $http->setUri($desturl);

        // Set the POST Data
        $http->setRawData($postdata);

        //Set Config
        $http->setConfig(array('persistent'=>true));

        // Make the HTTP POST request and save the HTTP response
        $httpResponse = $http->request('POST');
    }
    catch (Zend_Exception $e)
    {
        $httpResponse = "";
    }

    if($httpResponse!="")
    {
        $httpResponse = $httpResponse->getBody();
    }

    //Return the body of HTTTP Response
    return  $httpResponse;
Run Code Online (Sandbox Code Playgroud)

php ssl https curl zend-framework

7
推荐指数
1
解决办法
8489
查看次数