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的海域 閱讀(3870) | 評論 (0)編輯 收藏

          平時要用惡心的citrix Xenapp & citrix receiver 工作環(huán)境,裝完后發(fā)現client端不能復制內容到server端,這樣會對工作造成很大的困擾。
          偶然發(fā)現citrix receiver的進程上有個-file的選項,會指定個臨時配置文件,里面提及
          ClipboardAllowed=off
          于是grep下這個關鍵字,發(fā)現~/ICAClient/linuxx86/config/All_Regions.ini 也有個類似的
          ClipboardAllowed=*
          改為
          ClipboardAllowed=true
          然后重新開Xenapp session之后發(fā)現已經可以黏貼了。

          按照這個思路,使用windows的同事使用如下的方式打通兩端clipboard
          1. 打開系統(tǒng)注冊表編輯器
          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的海域 閱讀(3503) | 評論 (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的海域 閱讀(561) | 評論 (0)編輯 收藏

          今天發(fā)現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, 并保存退出。
          執(zhí)行:
          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的海域 閱讀(1031) | 評論 (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的海域 閱讀(267) | 評論 (0)編輯 收藏

          發(fā)現用curl從jetty服務器上download文件的速度比較慢大概只有4M/s, 開始以為curl有默認的limit-rate,設置為1G以后發(fā)現還是慢。
          然后開始懷疑是jetty server的問題。看SslSelectChannelConnector的responseBufferSize比較像,反復實驗發(fā)現原來是由于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的海域 閱讀(619) | 評論 (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的海域 閱讀(820) | 評論 (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的海域 閱讀(338) | 評論 (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的海域 閱讀(418) | 評論 (0)編輯 收藏

          關于SQL連接查詢的圖形表示SQL連接查詢

          posted @ 2012-07-04 09:35 Milo的海域 閱讀(281) | 評論 (0)編輯 收藏

          僅列出標題
          共9頁: 上一頁 1 2 3 4 5 6 7 8 9 下一頁 
          主站蜘蛛池模板: 呈贡县| 高密市| 开远市| 宜良县| 惠安县| 诏安县| 泊头市| 即墨市| 留坝县| 孙吴县| 呈贡县| 台南县| 奈曼旗| 黄石市| 开平市| 蓬溪县| 龙山县| 丁青县| 松潘县| 梅州市| 罗源县| 新巴尔虎右旗| 玉溪市| 临武县| 开原市| 巴林左旗| 乐东| 寿阳县| 田阳县| 土默特左旗| 外汇| 红河县| 襄垣县| 揭阳市| 巩留县| 于都县| 南木林县| 黑山县| 上虞市| 湖口县| 蓬溪县|