vim刷新firefox

September 20th, 2010

yangsong 同学分享了一篇vim保存文件时刷新firefox的文章,用到了firefox的插架监听个端口通信的。貌似window下还用不了。我这firefox已经够慢了,对插件相当的节制,所以做个了发消息的,开始刷新IE很简单,sendmessage就行,firefox比较哏,屏了,只好去模拟按键……

代码如下

/*
 * jondynet http://jondy.net/
 * gcc firefox_f5.c -DWINVER=0x0501
 */
#include "windows.h"
#include "Winuser.h"

int main (int argc, char * argv [])
{
    HWND hwnd = FindWindow ("MozillaUIWindowClass", NULL);
    if (hwnd == 0)
    {
       MessageBox (0, "Where is firefox!", "Error", MB_ICONINFORMATION);
       return 0;
    }
    //char buffer[300];
    //SendMessage(hwnd,WM_GETTEXT,sizeof(buffer),(LPARAM)buffer);
    //MessageBox(NULL,buffer,"Captured Text",MB_OK);

    SetForegroundWindow(hwnd);
    //Sleep(2000);

    // minimize
    //SendMessage(hwnd,WM_SYSCOMMAND,SC_MINIMIZE,0);

    // ctrl + f5
    //PostMessage(hwnd,WM_KEYDOWN,VK_F5,0);
    //PostMessage(hwnd,WM_KEYUP,VK_F5,0); 

    //PostMessage(hwnd,WM_KEYDOWN,VK_CONTROL,0);
    //PostMessage(hwnd,WM_KEYDOWN,'R',0);
    //PostMessage(hwnd,WM_KEYUP,'R',0);
    //PostMessage(hwnd,WM_KEYUP,VK_CONTROL,0); 

    // SendInput
    INPUT inpdd[1];
    KEYBDINPUT kbyinp; 

    kbyinp.wVk = VK_F5;
    kbyinp.wScan = 0x3F;
    kbyinp.time = 0;
    kbyinp.dwFlags = 0;
    kbyinp.dwExtraInfo = 0;
    inpdd[0].type = INPUT_KEYBOARD;
    inpdd[0].ki = kbyinp;
    SendInput(1,&inpdd[0],sizeof(inpdd[0]));

    //关闭
    //PostMessage(hwnd, WM_CLOSE, 0, 0);
    return 0;
}

vim的设置看这里
" autocmd BufWriteCmd *.html,*.css,*.tmpl :call Refresh_firefox()
" function! Refresh_firefox()
"   if &modified
"     write
"     silent !firefox_f5
"     "silent !echo  'vimYo = content.window.pageYOffset;
"     "             \ vimXo = content.window.pageXOffset;
"     "             \ BrowserReload();
"     "             \ content.window.scrollTo(vimXo,vimYo);
"     "             \ repl.quit();'  |
"     "             \ nc localhost 4242 2>&1 > /dev/null
"   endif
" endfunction
silent !firefox_f5 这个是调用俺这个的,下边注释的那个是用插件的。

apache mod_wsgi autoreload

September 2nd, 2010

各种nix下的参考mod_wsgi的wiki
win32平台的修改 _restart 方法

def _restart(path):
    _queue.put(True)
    prefix = 'monitor (pid=%d):' % os.getpid()
    print >> sys.stderr, '%s Change detected to \'%s\'.' % (prefix, path)
    print >> sys.stderr, '%s Triggering process restart.' % prefix
    if sys.platform == 'win32':
        #win32
        import ctypes
        ctypes.windll.libhttpd.ap_signal_parent(1)
    else:
        # nix
        os.kill(os.getpid(), signal.SIGINT)

apache:Could not reliably determine the server’s fully qualified domain name

September 2nd, 2010

httpd: Could not reliably determine the server’s fully qualified domain name, using ::1 for ServerName

配虚机时的小毛病,在http.conf 设置ServerName 就好了

apache no warning

August 20th, 2010
最近开发环境apache用的多了点,就在刚刚配置完mod_wsgi的支持后用
apachectl -t 检查发现一堆waning
[Fri Aug 20 16:27:55 2010] [warn] module wsgi_module is already loaded, skipping
[Fri Aug 20 16:27:55 2010] [warn] module wsgi_module is already loaded, skipping
[Fri Aug 20 16:27:55 2010] [warn] NameVirtualHost commsen:80 has no VirtualHosts
[Fri Aug 20 16:27:55 2010] [warn] NameVirtualHost test_modwsgi:80 has no VirtualHosts
[Fri Aug 20 16:27:55 2010] [warn] NameVirtualHost ubimeeting:80 has no VirtualHosts
提示很明显了,虽然不影响使用,不过我这种对系统有洁癖的人显然受不了. 这两个提示都是因为配置项重复导致的.重新整理下配置文件的结构就好了.
  1. 删掉单个虚拟主机配置文件里的loadmodule 和namevirtualhost.
  2. 将loadmodule和namevirtualhost的设置写到httpd.conf里.
zhangdi:users$ apachectl -t
Syntax OK

mac OSX10.6安装Apache2+mod_wsgi

August 20th, 2010

系统环境: macbook pro 374

python2.6是用macports管理的,Apache2是系统自带的.

查看了一下macports里的mod_wsgi,版本是3.2,比google code上的低了点,而且依赖关系有apache2和python2.6.

我这业余时间偶尔还要做些php开发,不想用macports管理apache和php,包太多平时更新ports很烦,所以这里不打算用macports里的mod_wsgi.

google了一些安装资料, 看到configure 时的两个参数 apxs和python. 看了下系统环境,下载源码包开始编译.

zhangdi:mod_wsgi-3.3$ ./configure –with-apxs=/usr/sbin/apxs –with-python=/opt/local/bin/python

两个参数一个指定apxs的位置,我这里是/usr/sbin下, python是2.6版的macports安装的

configure完成,make 时有几个warning,没什么重要的. make install 完成.

zhangdi:mod_wsgi-3.3$ sudo make install
Password:
/usr/sbin/apxs -i -S LIBEXECDIR=/usr/libexec/apache2 -n ‘mod_wsgi’ mod_wsgi.la
/usr/share/httpd/build/instdso.sh SH_LIBTOOL=’/usr/share/apr-1/build-1/libtool’ mod_wsgi.la /usr/libexec/apache2
/usr/share/apr-1/build-1/libtool –mode=install cp mod_wsgi.la /usr/libexec/apache2/
cp .libs/mod_wsgi.so /usr/libexec/apache2/mod_wsgi.so
cp .libs/mod_wsgi.lai /usr/libexec/apache2/mod_wsgi.la
cp .libs/mod_wsgi.a /usr/libexec/apache2/mod_wsgi.a
chmod 644 /usr/libexec/apache2/mod_wsgi.a
ranlib /usr/libexec/apache2/mod_wsgi.a
———————————————————————-
Libraries have been installed in:
/usr/libexec/apache2
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR’
flag during linking and do at least one of the following:
- add LIBDIR to the `DYLD_LIBRARY_PATH’ environment variable
during execution
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
———————————————————————-
chmod 755 /usr/libexec/apache2/mod_wsgi.so

zhangdi:mod_wsgi-3.3$ sudo make installPassword:/usr/sbin/apxs -i -S LIBEXECDIR=/usr/libexec/apache2 -n ‘mod_wsgi’ mod_wsgi.la/usr/share/httpd/build/instdso.sh SH_LIBTOOL=’/usr/share/apr-1/build-1/libtool’ mod_wsgi.la /usr/libexec/apache2/usr/share/apr-1/build-1/libtool –mode=install cp mod_wsgi.la /usr/libexec/apache2/cp .libs/mod_wsgi.so /usr/libexec/apache2/mod_wsgi.socp .libs/mod_wsgi.lai /usr/libexec/apache2/mod_wsgi.lacp .libs/mod_wsgi.a /usr/libexec/apache2/mod_wsgi.achmod 644 /usr/libexec/apache2/mod_wsgi.aranlib /usr/libexec/apache2/mod_wsgi.a———————————————————————-Libraries have been installed in:   /usr/libexec/apache2
If you ever happen to want to link against installed librariesin a given directory, LIBDIR, you must either use libtool, andspecify the full pathname of the library, or use the `-LLIBDIR’flag during linking and do at least one of the following:   – add LIBDIR to the `DYLD_LIBRARY_PATH’ environment variable     during execution
See any operating system documentation about shared libraries formore information, such as the ld(1) and ld.so(8) manual pages.———————————————————————-chmod 755 /usr/libexec/apache2/mod_wsgi.so