2012-09-18 04:41:35
/Linux/CUPS

Run in terminal as root

gpasswd -a <username> sys

Then in cpusd.conf, set

SystemGroup sys

By default group sys should already be set in cupsd.conf, so the second step is not needed. And of course you can add a new group, add yourself to it and finally add the group to SystemGroup in cupsd.conf.

Links:

posted by Cyker Way
2012-09-16 16:12:47
/Linux/fontconfig

Problem:

    Having multiple values in <test> isn't supported and may not works as expected

Solution:

http://ubuntuforums.org/showpost.php?p=12159762&postcount=13

posted by Cyker Way
2012-09-13 14:30:29
/Linux/Eclipse

Edit eclipse.ini and add something like

 -vm
/opt/sun-jdk-1.6.0.02/bin/java

Links:

posted by Cyker Way
2012-09-09 12:59:56
/Linux

To install:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

To remove:

sudo apt-get remove oracle-java7-installer

Links:

posted by Cyker Way
2012-09-08 11:20:15
/Linux/Vim

Nate gives a nice script to preview Markdown files in Vim:

http://blog.natesilva.com/post/5256838248/how-to-preview-a-markdown-document-in-vim

But he hasn't tested it on Linux. Minor changes will make it work on Linux.

  1. Change open to xdg-open.
  2. Add a redraw! command in the end (in case some terminals don't automatically redraw).

The modified version is shown below. I like to use <Leader> rather than comma, but you're free to change it.

"
" While editing a Markdown document in Vim, preview it in the
" default browser.
"
" Author: Nate Silva
"
" To install: Place markdown.vim in ~/.vim/ftplugin or
" %USERPROFILE%\vimfiles\ftplugin.
"
" To use: While editing a Markdown file, press '\a' (backslash a)
"
" Tested on Windows and Mac OS X. Should work on Linux if you set
" BROWSER_COMMAND properly.
"
" Requires the `markdown` command to be on the system path. If you
" do not have the `markdown` command, install one of the following:
"
" http://www.pell.portland.or.us/~orc/Code/discount/
" http://www.freewisdom.org/projects/python-markdown/
"
function!PreviewMarkdown()
    " **************************************************************
    " Configurable settings

    let MARKDOWN_COMMAND = 'markdown'

    if has('win32')
        " note important extra pair of double-quotes
        let BROWSER_COMMAND = 'cmd.exe /c start ""'
    else
        let BROWSER_COMMAND = 'xdg-open'
    endif

    " End of configurable settings
    " **************************************************************

    silent update
    let output_name = tempname() . '.html'

    " Some Markdown implementations, especially the Python one,
    " work best with UTF-8. If our buffer is not in UTF-8, convert
    " it before running Markdown, then convert it back.
    let original_encoding = &fileencoding
    let original_bomb = &bomb
    if original_encoding != 'utf-8' || original_bomb == 1
        set nobomb
        set fileencoding=utf-8
        silent update
    endif

    " Write the HTML header. Do a CSS reset, followed by setting up
    " some basic styles from YUI, so the output looks nice.
    let file_header = ['<html>', '<head>',
        \ '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">',
        \ '<title>Markdown Preview</title>',
        \ '<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.3.0/build/cssreset/reset-min.css">',
        \ '<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.3.0/build/cssbase/base-min.css">',
        \ '<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.3.0/build/cssfonts/fonts-min.css">',
        \ '<style>body{padding:20px;}div#container{background-color:#F2F2F2;padding:0 20px;margin:0px;border:solid #D0D0D0 1px;}</style>',
        \ '</head>', '<body>', '<div id="container">']
    call writefile(file_header, output_name)

    let md_command = '!' . MARKDOWN_COMMAND . ' "' . expand('%:p') . '" >> "' .
        \ output_name . '"'
    silent exec md_command

    if has('win32')
        let footer_name = tempname()
        call writefile(['</div></body></html>'], footer_name)
        silent exec '!type "' . footer_name . '" >> "' . output_name . '"'
        exec delete(footer_name)
    else
        silent exec '!echo "</div></body></html>" >> "' .
            \ output_name . '"'
    endif

    " If we changed the encoding, change it back.
    if original_encoding != 'utf-8' || original_bomb == 1
        if original_bomb == 1
            set bomb
        endif
        silent exec 'set fileencoding=' . original_encoding
        silent update
    endif

    silent exec '!' . BROWSER_COMMAND . ' "' . output_name . '"'

    exec input('Press ENTER to continue...')
    echo
    exec delete(output_name)
    redraw!

endfunction

" Map this feature to the key sequence '\a' (backslash lowercase-a)
map <Leader>a :call PreviewMarkdown()<CR>

posted by Cyker Way
2012-09-01 03:53:20
/Linux

Yesterday I managed to install a Linux system on a computer with legacy BIOS and GPT-formatted disk. However, BIOS refused to boot unless you explicitly specify the disk to boot.

The problem here is that the sole partition in the protective MBR isn't marked as 'bootable', which is, from the BIOS's point of view, there is no bootable partition. Knowing this, the solution becomes extremely simple. Just backup MBR, change byte 0x1BE from 00 to 80, and restore it. Tools dd and hexedit suffice for this task.

I dare not use fdisk/gdisk/parted because I'm not very familiar with their actions with GPT disks. The above brute method is both direct and simple. Good.

posted by Cyker Way
2012-04-29 20:23:39
/Adobe,/Linux

Linux版本的Acroread 9.5.1版本Firefox plugin会在当前目录产生名为C\:\\nppdf32Log\\debuglog.txt的垃圾日志文件,内容为若干行NPP_GetValue is called等等。

Disable它也不能解决问题。解决方法是粗暴地删除/usr/lib/mozilla/plugins/nppdf.so。虽说只是个symlink,但乱删包管理系统安装的文件还是不好的嘛……可这个bug也太2了嘛……

Links:

posted by Cyker Way
2012-01-23 01:03:56
/others

今年的CES展会上,三星秀了一块窗玻璃。从室内看是个显示屏,从室外看是个镜子。可以利用室外自然光当背光,以及利用太阳能供电。有电子百叶窗进行透光率的控制。

俺想如果里面再嵌一堆微型电机能换气就真碉堡了。

Links:

posted by Cyker Way
2012-01-20 12:54:23
/Linux

Toy上看到的这个漏洞估计是我见过的最搞的一个了。先用

X -version

看一下X的版本号,如果是1.11,启动X的锁屏程序(screensaver/slock之类),然后按Ctrl+Alt+*(是小键盘的*不是8上面的)。然后锁屏就失效了……用Ctrl+Alt+/也有同样效果。

这个帖子是讲得比较好的:http://gu1.aeroxteam.fr/2012/01/19/bypass-screensaver-locker-program-xorg-111-and-up/,看完了来龙去脉估计也清楚了。

解决方法有二:

Toy上的帖子还是热乎的,不知道还会出现啥样奇葩的评论……

posted by Cyker Way
2012-01-20 04:18:07
/others

老早以前看到Octopress这个东西一直没时间折腾,刚巧刚才开了自己的GitHub Pages,顺便鼓捣了一下Jekyll(Octopress的核心部分)。

Jekyll是一个Ruby写的静态化站点生成器,特点是blog-aware,就是说适合拿来写博客。Jekyll支持多种markup languages,包括Markdown和Textile。就是说你用Markdown写文章,然后设计HTML模板(包括CSS、图片等等),最后运行Jekyll,自动帮你生成静态页面。生成的静态页面可以直接用常见的web服务器来serve(比如Apache和nginx等等)。

这东西有一个好处在于你可以用比较简单的语言Markdown来写作,而不是HTML,也不用关心HTML是怎么生成的,符合结构和渲染分离的原则(但是结构和渲染这东西总是相对的……)。而且还有一个好处是Jekyll和Git的关系非常紧密,你可以在Git repository里写作,正常commit/checkout,甚至可以上传到GitHub。GitHub Pages提供了对Jekyll的支持,上传之后会自动生成静态页面。关于GitHub Pages可以参考http://pages.github.com/

Jekyll的主页是https://github.com/mojombo/jekyll,大体上看完README就知道咋回事了。稍微比较重要的也就是这个目录结构https://github.com/mojombo/jekyll/wiki/usage。具体说就是:

  • 在_config.yml里做总体设置;
  • 在_layouts里设计模板,里面的{{ content }}部分将会被使用该模板的文本填充;
  • 在_posts里用Markdown写文章,注意文件名的命名格式;
  • 如果愿意,可以在_includes里设计模板的一部分,在其他文件中引用;
  • 剩下的根目录里的其他文件,如果有YAML Front Matter这个东西,也会被Jekyll处理,否则就直接复制到目的地;
  • 最后生成的结果在_site目录下。

其实说白了就是这么简单,你写个Markdown,Jekyll帮你搞成HTML。

貌似全程都没有数据库的参与,所以我还是觉得很神奇,如果有复杂的查询要求怎么办呢?看上去所有东西都要用Ruby程序搞定。当初写Blade的时候也在想是用纯文本还是数据库,后来为了查询简单就用了MySQL。如果纯文本在这方面也能做的很好的话那还真可以考虑抛弃数据库。不过我看_site下面生成的都是HTML,没有任何动态页面迹象或者索引之类的(好吧人家就是为了静态页面嘛……),那么在一堆完整的静态页面中做查询我觉得还是挺有挑战性的,相当于结构化的信息都被抹去了现在要反过来做,有点别扭。不过我看Octopress也有Search box呢,过会儿看看它是怎么做的吧。

Update. 朕惊了!跳到Google去了!

有时间的话还是想把Blade再升个级。其实现在这个版本也就算是个prototype,拖了很久没有重构了。写文章的方式还很蠢,很多HTML tags要手动加,没有辅助工具的用户估计很不爽。未来的计划大致包括:

  • 支持Markdown;
  • 尝试以静态化+索引的方式替代动态页面;
  • 和Git整合。
  • 用DISQUS管理评论。

具体说就是以Markdown作为书写语言,用Git进行版本控制(其实主要是为了方便查看过去特定时刻的状态,否则Git也不是太必要),支持静态化渲染和索引建立,方便进行关键字和日期等基本查找。评论的部分交给DISQUS估计能省去很多劳力(尤其是对一个静态化的站点来说)。最终的目标是,用户只需要写Markdown而不必管其他任何事情(当然如果他们愿意也可以自己写模板)。这工程不算太大但其实也不小,不过想想能把PHP+MySQL这一坨毛都移掉,用一种轻量化的方式来写blog,还是非常值得做的。万能的上帝请给俺发工资让俺搞定这件事儿吧!

posted by Cyker Way
/images/Facebook_32x32.png
/images/Twitter_32x32.png
/images/Feed_32x32.png
Creative Commons divcense