小编mac*_*osh的帖子

在使用mod_wsgi的Apache上使用Django时必须重新启动Apache

我正在用Django创建一个Web应用程序.由于我非常熟悉Apache,因此我设置了我的开发环境,让Django使用mod_wsgi运行Apache.我唯一的烦恼就是每次更改代码时都必须重新启动Apache.有没有解决的办法?

python apache django mod-wsgi restart

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

在ASP.NET页面上重复使用多次变量

问这么简单的问题我觉得有些愚蠢,但我似乎无法找到答案.我是ASP.NET(C#)的新手,但我正在学习构建一组显示报告的简单网页.我有一个代表公司名称的变量.我需要在网页上的多个位置输出此变量.我发现输出变量的唯一方法是:

company_name.Text = "Acme Windows";
Run Code Online (Sandbox Code Playgroud)

然后

<asp:literal id="company_name" runat="server" />
Run Code Online (Sandbox Code Playgroud)

我的问题是我想在页面的多个地方使用company_name.我是否真的必须创建一个单独的变量,每次在页面上放置相同的值?如果我只是将上面的XML代码复制到我想要显示变量的所有位置,那么它显然会产生编译错误,因为已经定义了该ID.

我觉得我错过了一些非常明显的东西.

asp.net templates reusability

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

在截断行的末尾删除字形

在启用截断线的终端中使用Emacs 23时,Emacs会在每行末尾添加一个美元符号,表示文本继续超出屏幕边缘.这困扰我,我想禁用此功能或以某种方式隐藏美元符号.这可能吗?如果是这样,怎么办呢?

截断线末端的字形.

emacs terminal

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

手动创建的UIWindow是错误的大小

我正在学习如何在没有Interface Builder(即故事板,xib等)的情况下创建iOS应用程序.下面是我正在使用的基本应用程序委托类.问题是,显示时UIWindow不会耗尽设备的全屏(参见附件截图).这发生在我测试的所有设备和模拟器上.为什么不使用全屏?

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
  lazy var window: UIWindow? = {
    debugPrint("AppDelegate: Creating Window")

    let screen: UIScreen = UIScreen.mainScreen()
    let window: UIWindow = UIWindow.init(frame: screen.bounds)

    window.backgroundColor = UIColor.whiteColor()

    return window
  }()

  lazy var rootViewController: ShapesViewController = {
    debugPrint("AppDelegate: Creating Root View Controller")

    let rootViewController = ShapesViewController.init(nibName: nil, bundle: nil)

    return rootViewController
  }()

  func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
    debugPrint("AppDelegate: applicationWillEnterForeground")

    window?.rootViewController = rootViewController
    window?.makeKeyAndVisible()

    return true
  }
}
Run Code Online (Sandbox Code Playgroud)

为什么窗口不使用整个屏幕?

uikit uiwindow ios uiscreen swift

8
推荐指数
2
解决办法
1108
查看次数

确定核心音频AudioBuffer中的帧数

我试图在iPhone/iPad上访问音频文件的原始数据.我有以下代码,这是我需要的路径的基本开始.但是,一旦我有了一个AudioBuffer,我就会感到难过.

AVAssetReader *assetReader = [AVAssetReader assetReaderWithAsset:urlAsset error:nil];
AVAssetReaderTrackOutput *assetReaderOutput = [AVAssetReaderTrackOutput assetReaderTrackOutputWithTrack:[[urlAsset tracks] objectAtIndex:0] outputSettings:nil];
[assetReader addOutput:assetReaderOutput];
[assetReader startReading];

CMSampleBufferRef ref;
NSArray *outputs = assetReader.outputs;
AVAssetReaderOutput *output = [outputs objectAtIndex:0];
int y = 0;
while (ref = [output copyNextSampleBuffer]) {
    AudioBufferList audioBufferList;
    CMBlockBufferRef blockBuffer;
    CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(ref, NULL, &audioBufferList, sizeof(audioBufferList), NULL, NULL, 0, &blockBuffer);
    for (y=0; y<audioBufferList.mNumberBuffers; y++) {
        AudioBuffer audioBuffer = audioBufferList.mBuffers[y];
        SInt16 *frames = audioBuffer.mData;
        for(int i = 0; i < 24000; i++) { // This sometimes crashes
            Float32 currentFrame …
Run Code Online (Sandbox Code Playgroud)

core-audio pcm void-pointers avfoundation ios

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

PHP:动态或程序化捕获块

我有一种情况,能够有一个catch块,在运行时确定Exception的类型会很好.它会像这样工作:

$someClassName = determineExceptionClass();

try {
  $attempt->something();
} catch ($someClassName $e) {
  echo 'Dynamic Exception';
} catch (Exception $e) {
  echo 'Default Exception';
}
Run Code Online (Sandbox Code Playgroud)

这是可能吗?

php exception dynamic try-catch

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

不调用PHP流通知回调

我一直在玩PHP Streams并且一直在尝试开始编写这里显示的类.至少可以说PHP文档在这方面有点偏差.

我在获取流上下文以调用指定的回调方法时遇到了困难.如果我使用类似file_get_contentsfopen连接到套接字的函数,则会调用回调,但如果我使用stream_socket_client它则不会.

我认为它应该是因为我正在传递上下文stream_socket_client,如果我使用stream_socket_recvfrom我从套接字返回相同的字符串,因为fgets将返回.

相关的PHP文档在帖子的末尾链接.

class IMAP {

    // Connection Parameters
    private $host;
    private $port;
    private $timeout;

    // Credentials
    private $email;
    private $password;

    private $client;
    private $transcript;

    function __construct($connection, $credentials) {

        // Set Connection Settings
        $this->host = $connection['host'];
        $this->port = $connection['port'];
        $this->timeout = $connection['timeout'];

        // Set Credentials
        $this->email = $credentials['email'];
        $this->password = $credentials['password'];

        // Connect to the IMAP server
        $params = array('notification'=>array($this, 'getLine'));
        $ctx = stream_context_create();
        stream_context_set_params($ctx, $params);
        $this->client = …
Run Code Online (Sandbox Code Playgroud)

php sockets networking callback stream

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

使用Mercurial API获取给定变更集对存储库的更改

如何使用Mercurial API确定每个变更集对存储库所做的更改?我可以获得与特定修订版相关的文件列表,但是我无法弄清楚如何知道该文件发生了什么。

我如何回答变更集中每个文件的这些问题:

  • 是否添加了?
  • 它被删除了吗?
  • 修改了吗?

文件上下文中是否有一个属性可以告诉我(如果是这样,我找不到它),或者有其他方法可以解决这个问题?

这是我的代码:

def index(request):
    u = ui.ui()
    repo = hg.repository(ui.ui(), '/path/to/repo')
    changes = repo.changelog
    changesets = []

    for change in changes:
        ctx = repo.changectx(change)
        fileCtxs = []
        for aFile in ctx.files():
            if aFile in ctx:
                for status in repo.status(None, ctx.node()):
                    # I'm hoping this could return A, M, D, ? etc
                    fileCtxs.append(status)

        changeset = {
            'files':ctx.files(),
            'rev':str(ctx.rev()),
            'desc':ctx.description(),
            'user':ctx.user(),
            'filectxs':fileCtxs,
        }
        changesets.append(changeset)

    c = Context({
        'changesets': changesets,
    })

    tmplt = loader.get_template('web/index.html')
    return HttpResponse(tmplt.render(c))
Run Code Online (Sandbox Code Playgroud)

python mercurial dvcs changeset mercurial-extension

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

构建PHP Web应用程序系统

我想开始自动化更多的Web开发过程,所以我正在寻找一个构建系统.我主要在Mac OS X上编写PHP应用程序,并通过FTP部署Linux服务器.我的很多客户都有基本的托管服务提供商,因此通常无法访问其服务器的shell访问权限,但通常会出现远程MySQL访问.这是我想用构建系统做的事情:

  • 建设时:
    • Lint JavaScript文件
    • 验证CSS文件
    • 验证HTML文件
    • 缩小和连接JS和CSS文件
    • 验证PHP语法
    • 设置调试/生产标志
  • 部署时
    • 从SVN查看最新版本
    • 运行构建过程
    • 通过FTP将文件上传到服务器
    • 在远程数据库上运行SQL脚本

我意识到自动化需要做很多工作,但我认为这是值得的.那么开始这条道路的最佳方式是什么?是否有可以处理构建和部署的系统,还是应该搜索单独的解决方案?你会推荐什么系统?

php unix deployment automation build

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

更新:PHP上的Apache Chokes ldap_connect()调用

如果我在命令行上运行以下PHP代码,我会得到预期的结果:

php -r 'var_dump(ldap_connect("ldaps://ldaps.example.com", 636));'
resource(4) of type (ldap link)
Run Code Online (Sandbox Code Playgroud)

但是,如果我把它放在PHP脚本中

<?php ldap_connect("ldaps://ldaps.example.com", 636); ?>
Run Code Online (Sandbox Code Playgroud)

Apache断开连接,例如,如果我从命令行点击脚本,这就是cURL返回的内容:

curl http://example.com/ldap_test.php
curl: (52) Empty reply from server
Run Code Online (Sandbox Code Playgroud)

Apache access_log从不显示此页面的匹配,并且error_log为空.

我知道LDAP服务器正在运行,因为我在其他两台服务器上测试过它.我正在开发运行PHP 5.2.9和Apache的Joyent加速器.有人知道为什么Apache会对此感到窒息吗?

更新:

今天我在运行问题脚本的同时使用GDB调试了Apache.当脚本命中ldap_connect()行时,我在GDB中得到以下内容:

Program received signal SIGSEGV, Segmentation fault.
0xfe94b8bb in _free_unlocked () from /lib/libc.so.1
Run Code Online (Sandbox Code Playgroud)

我不确定是什么导致了段错误,但至少我知道Apache实际上正在崩溃.

这是完整的回溯:

Breakpoint 1, 0x08094417 in ap_process_request ()
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0xfe94b8bb in _free_unlocked () from /lib/libc.so.1
(gdb) where
#0  0xfe94b8bb in _free_unlocked () from /lib/libc.so.1
#1  0xfe94b86f in free () from …
Run Code Online (Sandbox Code Playgroud)

php apache lamp gdb ldap

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