posts - 88, comments - 3, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

直接上C的实现
typedef struct Foo {
    
int len;
    
char name[100];
} Foo_t;

JNIEXPORT jint JNICALL
Java_TestJNI_foo(JNIEnv 
*env, jobject obj, jobject fooObj) {

    Foo_t 
* bar = malloc(sizeof(Foo_t));
    jclass clazz;
    jfieldID fid;

    
//init the bar data of C
    strcpy(bar->name, "Yachun Miao");
    bar
->len = strlen(bar->name);

    
// mapping bar of C to foo
    clazz = (*env)->GetObjectClass(env, fooObj);
    
if (0 == clazz) {
        printf(
"GetObjectClass returned 0\n");
        
return (-1);
    }
    fid 
= (*env)->GetFieldID(env, clazz, "len""I");
    (
*env)->SetLongField(env, fooObj, fid, bar->len);

    fid 
= (*env)->GetFieldID(env, clazz, "name""Ljava/lang/String;");
    jstring name 
= (*env)->NewStringUTF(env, bar->name);
    (
*env)->SetObjectField(env, fooObj, fid, name);

    free(bar);
    
return 0;
}

对应的Java调用
public class Foo {
    
protected int len;
    
protected String name;
}


    
private static native int foo(Foo fooObj);

    
public static void main(String args[]) {
        System.loadLibrary(
"mylib");

        Foo foo 
= new Foo();
        foo(foo);
        System.out.println(foo.name);
        System.out.println(foo.len);

    }

参考链接
http://www.steveolyo.com/JNI/JNI.html#CSTRCJ
http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/types.html

posted @ 2012-10-12 16:40 Milo的海域 阅读(3818) | 评论 (0)编辑 收藏

平时要用恶心的citrix Xenapp & citrix receiver 工作环境,装完后发现client端不能复制内容到server端,这样会对工作造成很大的困扰。
偶然发现citrix receiver的进程上有个-file的选项,会指定个临时配置文件,里面提及
ClipboardAllowed=off
于是grep下这个关键字,发现~/ICAClient/linuxx86/config/All_Regions.ini 也有个类似的
ClipboardAllowed=*
改为
ClipboardAllowed=true
然后重新开Xenapp session之后发现已经可以黏贴了。

按照这个思路,使用windows的同事使用如下的方式打通两端clipboard
1. 打开系统注册表编辑器
2. 定位HKEY_CURRENT_USER\Software\Citrix\ICA Client\Engine\Lockdown Profiles\All Regions\Lockdown\Virtual Channels\Clipboard
3. 修改ClipboardAllowed为1
4. 注销当前用户(或许需要)

如果Xenapp server上使用vnc viewer之类的Xclient,如果想打通到vnc server的clipboard,还需要在vnc server所在linux主机开启以下进程
vncconfig -nowin &
这个有点不理解,但确实可行。待真相。。

posted @ 2012-09-10 15:55 Milo的海域 阅读(3371) | 评论 (1)编辑 收藏


miaoyachun@ymiao:~$ /usr/lib/i386-linux-gnu/ibus/ibus-x11 --kill-daemon
^Z
[1]+  Stopped                 /usr/lib/i386-linux-gnu/ibus/ibus-x11 --kill-daemon
miaoyachun@ymiao:~$ bg
[1]+ /usr/lib/i386-linux-gnu/ibus/ibus-x11 --kill-daemon &
miaoyachun@ymiao:~$
然后就可以了。。

posted @ 2012-09-04 17:12 Milo的海域 阅读(546) | 评论 (0)编辑 收藏

今天发现ubunto12.4没有默认的浏览器,导致所有的链接打开的时候从用gedit。google上找到了解决方法:
编辑以下内容:
[Desktop Entry]
Version
=14.0
Name
=Mozilla Firefox Web Browser
Comment
=Browse the World Wide Web
GenericName
=Web Browser
Keywords
=Internet;WWW;Browser;Web;Explorer
Exec=/opt/firefox/firefox %u
Terminal
=false
X-MultipleArgs
=false
Type
=Application
Icon
=firefox
Categories
=GNOME;GTK;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall;
StartupNotify=true
Actions
=NewWindow;
到文件~/.local/share/applications/firefox.desktop, 并保存退出。
执行:
update-desktop-database ~/.local/share/applications/

配好以后"System Settings -> Detail -> Default Applications -> Web" list里就会有firefox了。

Ref: http://askubuntu.com/questions/166455/how-do-i-make-luakit-my-default-browser

posted @ 2012-08-20 11:28 Milo的海域 阅读(1012) | 评论 (0)编辑 收藏

When play with eclim (eclipse style vim), i found its "LocateFile" command not work well when "invpaste" enabled in vim.
Solution is disable it by
" set invpaste

posted @ 2012-08-06 14:56 Milo的海域 阅读(249) | 评论 (0)编辑 收藏

发现用curl从jetty服务器上download文件的速度比较慢大概只有4M/s, 开始以为curl有默认的limit-rate,设置为1G以后发现还是慢。
然后开始怀疑是jetty server的问题。看SslSelectChannelConnector的responseBufferSize比较像,反复实验发现原来是由于headerBufferSize太小。
改为32K以后:
        SslSelectChannelConnector connector = new SslSelectChannelConnector();
        
        connector.setRequestBufferSize(
32768);

效果:
curl -k https://USER:PASSWD@HOST:PORT/api/internal/file?filename=/path/to/file > /dest/to/file
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                             Dload     Upload   Total   Spent     Left   Speed
100  723M  100  723M    0     0   29.3M      0       0:00:24  0:00:24 --:--:-- 29.4M

ref: http://wiki.eclipse.org/Jetty/Howto/Configure_Connectors

posted @ 2012-07-18 18:22 Milo的海域 阅读(599) | 评论 (0)编辑 收藏

PHP curl option "CURLOPT_SSL_VERIFYPEER=false"  is same thing of '-k or --insecure' option of curl command.

ref: http://curl.haxx.se/docs/sslcerts.html

posted @ 2012-07-17 17:39 Milo的海域 阅读(796) | 评论 (0)编辑 收藏

assume gprof and gprof2dot.py, graphviz be installed.


1. checkout memcached src code from git server
2. sh autogen.sh & ./configure
3. modify Makefile about CFLAGS, append option '-pg', after that do make
4. run memcached & do some actions by telnet
5. terminate memcached process, a gmon.out file will be generated.
6. gprof memcached gmon.out | /usr/bin/gprof2dot.py -n0 -e0 -c bw | dot -Tpng -o memcached_callgraph.png

posted @ 2012-07-16 18:03 Milo的海域 阅读(321) | 评论 (0)编辑 收藏

The scriptlets also take an argument, passed into them by the controlling rpmbuild process. This argument, accessed via $1 is the number of packages of this name which will be left on the system when the action completes, except for %pretrans and %posttrans which are always run with $1 as 0 (%pretrans and %posttrans are available in rpm 4.4 and later). So for the common case of install, upgrade, and uninstall we have:


install upgrade uninstall
 %pretrans $1 == 0 $1 == 0 (N/A)
 %pre $1 == 1 $1 == 2 (N/A)
 %post $1 == 1 $1 == 2 (N/A)
 %preun (N/A) $1 == 1 $1 == 0
 %postun (N/A) $1 == 1 $1 == 0
 %posttrans $1 == 0 $1 == 0 (N/A)

Scriptlets ordering

The scriptlets in %pre and %post are respectively run before and after a package is installed.
The scriptlets %preun and %postun are run before and after a package is uninstalled. The
scriptlets %pretrans and %posttrans are run at start and end of a transaction.

On upgrade
, the scripts are run in the following order:

     %pretrans of new package
     %pre of new package
    (package install)
     %post of new package
     %triggerin of other packages (set off by installing new package)
     %triggerin of new package (if any are true)
     %triggerun of old package (if it's set off by uninstalling the old package)
     %triggerun of other packages (set off by uninstalling old package)
     %preun of old package
    (removal of old package)
     %postun of old package
     %triggerpostun of old package (if it's set off by uninstalling the old package)
     %triggerpostun of other packages (if they're setu off by uninstalling the old package)
     %posttrans of new package

For detail, will ref:
http://fedoraproject.org/wiki/Packaging:ScriptletSnippets

posted @ 2012-07-06 13:41 Milo的海域 阅读(388) | 评论 (0)编辑 收藏

关于SQL连接查询的图形表示SQL连接查询

posted @ 2012-07-04 09:35 Milo的海域 阅读(259) | 评论 (0)编辑 收藏

仅列出标题
共9页: 上一页 1 2 3 4 5 6 7 8 9 下一页