Skip to main content

Posts

Showing posts from 2013

Converting synced C/C++ into asynced JavaScript

Emscripten is a C/C++ -> LLVM -> JavaScript compiler. It's useful and interesting, but one of its biggest limitations is about the sync/async model: JavaScript is single-threaded event-driven languages, therefore you cannot do a sleep() in the hope of receiving and processing extra events. Demo First of all, please enjoy this demo , on which I really spent some time. tl;dr Motivation: to make `sleep` and other similar functions actually work in our Runtime, without lots of labor work porting the C/C++ code I actually made it worked  `sync->async` is doable and I think it's not too hard - there are already implementations for JS I think this is a feature that cannot be supported by merely an external library Does it fit emscripten? Or is it possible to write a plugin for emscripten? Demo explained(?) The demo is basically a stop-time animation: //draw something //wait for some while //draw something else //wait... You can verify this

杂记 2013.10.23

png优化工具:pngnq(有损)和 pngcrush(无损) ubuntu gnome 13.10的input source里找不到输入法:手动修改dconf键值 org.gnome.desktop.input-sources.sources ,在数组里添加 ('ibus','sunpinyin') 和 ('ibus', 'anthy') 。 但是mozc似乎不行,原因不明。观望。 mozc在dconf里要打('ibus', 'mozc-jp')

Ubuntu 下 mount windows 共享目录

一般来说遇到标题所述问题我马上会想到smbfs,不过好久不用,最近发现smbfs已经没有了,取而代之的是cifs,于是命令大约是 sudo mount -t cifs //hostname//folder /localfolder -o user=username 不过总是报 Input/ouput error google了一阵,有的说加上 sec=ntlm 有的说加 iocharset=utf8 ,不过都没用。其中加了后者还会出 Can not access a needed shared library 的错误。根据 http://wiki.openwrt.org/doc/howto/cifs.client    和 https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1067681 , 安装了linux-image-extra-***的包以后才可以,但是mount还是不行。(我的linux是在虚拟器,装的最小内核linux-virtual) 于是尝试了一下smbclient,也是报错: tree connect failed: NT_STATUS_INSUFF_SERVER_RESOURCES 根据 http://klebom.net/melazy/tricks/ 查到是IRPStackSize过小的问题, 我在windows也确实查到了事件: Log Name: System Source: srv Date: 2013-10-20 14:08:29 Event ID: 2011 Task Category: None Level: Error Keywords: Classic User: N/A Computer: *** Description: The server's configuration parameter "irpstacksize" is too small for the server to use a local device. Please increase the value of this parameter.

Install Ubuntu 13.10 via Grub Legacy

I need to install Ubuntu 13.10 into an old Linux machine. The BIOS has been locked such that I cannot boot from CD or USB drives. The machine has grub 0.97 and a pretty old CentOS installed on it, which I've got the root access, so I decided to try to load the ubuntu iso file with it. Based on https://help.ubuntu.com/community/Installation/FromLinux I tried to enter the grub commands there, but then it failed with error like this: stdin: error 0 /init: line 7: can't open /dev/sr0: No medium found After spending hours in searching and trying, I found this url: http://askubuntu.com/questions/47076/usb-boot-problems which solved the problem for me. The full commands I used are: root (hd1,0) kernel /casper/vmlinuz.efi boot=casper live-media-path=/casper/ ignore_uuid initrd /casper/initrd.lz This link http://manpages.ubuntu.com/manpages/karmic/man7/casper.7.html describes the parameters for casper

Screen Color Calibration

configure softwares gimp: edit->preferences->color management->try to use system monitor profile firefox: about:config ->  gfx.color_management.mode -> 1   test pages http://www.gballard.net/photoshop/srgb_wide_gamut.html http://photographylife.com/is-your-browser-color-managed I bought a spyder 4 express and would like to try dispcalGUI on my surface pro, so I have to install Argyll CMS's driver, which is not signed. For windows 8, one option to disable driver signature enforcement is through "advanced startup settings", which lists a few options after a restart, and you can press f7 or 7 to disable it. However for my surface pro, it refused to recognize my keyboard, no matter it is a bluebooth keyboard, a usb wireless keyboard or a normal usb keyboard. I guess a touch/type cover might work, but I don't have one. Another option is to enable test mode (bcdedit -set testsigning on), before which you should also disabl

杂记 20130821

一直纠结是用中文写还是英文写还是都写,随心情好了。 Windows 8 FileHistory 不能指定外置硬盘 参考: http://answers.microsoft.com/en-us/windows/forum/windows_8-hardware/windows-8-file-history-does-not-recognize-my/361a527b-d35b-4753-b4a6-3ccff738ff62?page=2 - 确定该硬盘没有被加入任何library - 删除 C:\Users\USERNAME\AppData\Local\Microsoft\Windows\File History 给我妹家里配无线路由,主要是希望用一个小路由增强一个大路由(外接adsl)的信号 一开始给小路由设的repeater模式,但是不太好使,于是用ap模式+开启wds,然后小路由自动禁用了dhcp。这时在小路由的信号内手动设置ip和dns可以上网。最后把小路由dhcp打开,然后把两个路由分配的ip段分开就可以了。 两个路由的ssid,信道和加密方式都应该相同。 按理说WDS应该可以的,但是似乎小路由不太行。 利用PuttyGen声称公钥然后让服务器信任 参考: http://www.dailyiteration.com/howto-passwordless-ssh-authentication-with-putty/ 主要是需要用sshkeygen -i -f 转一下格式 Gmail里拖拽图片附件,如果拖到正文,就会添加成inline image;如果拖到下方工具栏上,就会添加成附件 参考: http://lifehacker.com/add-images-as-attachments-via-drag-and-drop-in-gmail-561870021

Misc Notes 20130702

- To remove the 'new release available' message, remove the file /etc/update-motd.d/91-release-upgrade http://blog.koppi.me/2011/12/howto-disable-new-release-available-on-ubuntu-11-10/ - To remove unused language packs from Windows 8, run `lpksetup` http://answers.microsoft.com/en-us/windows/forum/windows_7-windows_programs/how-to-uninstall-extra-language-packs-from-windows/9ac2194d-1665-498d-8571-32e4cce6efa9 - If Cygwin X server crashed with `-multiwindow` on HD4000 graphics card, try updating the graphics card driver http://serverfault.com/questions/488306/cygwin-x-crashing-on-multiwindow-option/488556#488556 - halt vs poweroff: halt does not send the acpi power off signal http://unix.stackexchange.com/questions/42572/halt-and-poweroff-options-for-shutdown-command - MyPaint picker offset on windows 64bit with high dpi - Also how to set the high dpi compatibility setting for 64bit programs http://forum.intilinux.com/mypaint-help-and-tips/color-pick

Notes 20130505

'tc' and 'netem' allow you to simulate some network environments http://www.linuxfoundation.org/collaborate/workgroups/networking/netem#Delay_distribution For example, I can delay every packet for 1s, such that in some case I can cheat in games. Google Chrome complains about "profile cannot be opened correctly": remove the 'web data' folder in the config dir http://www.fourleaftechnology.com/index.php/General/google-chrome-profile-could-not-be-opened-correctly-error.html To remove PDF password with gs http://www.cyberciti.biz/faq/removing-password-from-pdf-on-linux/ gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=unencrypted.pdf -c .setpdfwrite -f encrypted.pdf IE10 would ignore the `word-spacing` CSS rule if the width for the space char is 0, in a TTF font. Is it a bug of IE?

杂记 20130505

使用tc + netem可以模拟一些网络环境 http://www.linuxfoundation.org/collaborate/workgroups/networking/netem#Delay_distribution 比如我可以让每个包都延迟1秒,某些情况下玩游戏还可以作弊 Google Chrome说Profile无法正确打开: 把配置目录里的'Web Data'目录干掉 http://www.fourleaftechnology.com/index.php/General/google-chrome-profile-could-not-be-opened-correctly-error.html 用gs去除PDF的密码: http://www.cyberciti.biz/faq/removing-password-from-pdf-on-linux/ gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=unencrypted.pdf -c .setpdfwrite -f encrypted.pdf IE10下如果TTF字体的空格宽度是0,就会无视word-spacing的css规则,不知道是不是IE的bug。

Misc 20130401

To reset all shortcut definitions in evince, run rm ~/.config/evince/accels GCC would complain if you define a variable without actually using it. To silience it, use (void)var; DNS is not working in VirtualBox: Run VBoxManage modifyvm "VM name" --natdnshostresolver1 on Ref   A useful link talking about ravlue reference in C++11 http://thbecker.net/articles/rvalue_references/section_01.html   To clear disk cache in Linux: Run sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches' Ref  "screen-256color not found": Run infocmp xterm-256color > screen-256color.ti on a machine without this error, copy the file to the target machine and then run tic screen-256color.ti Ref Just switch to fcitx from ibus. I like a theme called 'anran'. If fcitx cannot follow the cursor on Firefox, turn on preedit, as said in the official wiki. Just played with a vim plugin called youcompleteme, for C++ autocomplete, which is quite powerful. Also I installed vund

杂记 20130401

之前evince的快捷键乱套了,使用 rm ~/.config/evince/accels 复位 定义了变量var又不用的话,gcc会报warning"unused variable",解法是 (void)var; VirtualBox中DNS不工作:运行 VBoxManage modifyvm "VM name" --natdnshostresolver1 on Ref   一个讲c++11右值引用的link: http://thbecker.net/articles/rvalue_references/section_01.html   Linux清除disk cache: sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches' Ref  遇到错误screen-256color not found需要支持新的终端类型:找一台支持screen-256color的机器执行 infocmp xterm-256color > screen-256color.ti 把文件拷贝到目标机器后执行 tic screen-256color.ti Ref  最近从ibus换到了fcitx,起初是由于sogou发布了,不过后来还是卸掉了。anran主题不错。fcitx在firefox中光标跟随有点问题,按官方wiki说法打开preedit后就没事了。  最近在vim里折腾youcompleteme这个补全插件,挺好用。顺便也装了vundle来管理插件,很不错  vim更新.vimrc后想直接应用,执行 so %

杂记 20120205 | Misc Notes 20120205

1. Javascript 图表库比较 Ext JS 各种模型比较折腾,画出来还不错。 flot,配合jQuery写着比较顺手,但是功能不够多,内置符号只有圆圈,加个插件发现图例中不能显示符号。logscale还有坐标的分点都要自己实现。。。 2.gnuplot编译时报错,libpng冲突 http://harvey.nu/compiling_gnuplot_on_mac_os_x_libpng_conflict.html 3.Excel中方向键不工作 按一下ScrollLock试试 http://www-cs-students.stanford.edu/~edlee/microsoft_excep_tip_1.html 4.Linux播放白噪音 http://dirk.net/2009/07/14/white-noise-generator-for-linux/ install sox play -n synth 60:00 whitenoise 1. A few JS libraries for plotting Ext JS, with rather complicated data models, but worthy. Produced figures look good. flot, a smooth coding experience with jQuery, but also lack of features. E.g. by default the only available symbol is circle. There are plugins available for extra symbols, but only in legend...Also I have to specify all the ticks... 2. libpng confliction when compiling gnuplot. http://harvey.nu/compiling_gnuplot_on_mac_os_x_libpng_conflict.html 3. Arrow keys not working in excel Try to press t