'전체 글'에 해당되는 글 216건

  1. 2012.02.12 Vim: python indenting like C indenting
  2. 2012.01.28 date commands
  3. 2012.01.28 How to list defined functions in bash.
  4. 2012.01.14 iTunes Command-F to search local musics
  5. 2011.12.13 히라사와 우이 넨도로이드 구입 2
  6. 2011.12.05 Installing Io on OS X Snow Leopard(10.6.8)
  7. 2011.10.06 스티브 잡스 사망. 향년 56세, An iconic figure of the era has gone.
  8. 2011.09.01 JLPT N1 합격 3

Vim: python indenting like C indenting

Computing/vim tips 2012. 2. 12. 18:14

I set cinoptions as "(0,W4" when I have to edit C/C++ source files.

This cinoptions setting adjusts indenting of your sourcecode as follows:

somevalue = function_foo(argument1,  /* you type Enter key here */
                         arg2, /* And the cursor is automatically located right next to below "(" letter */
                         argument3);

Yes, it automtically indents lines inside parentheses to the column where the starting parenthesis is.

Recently, I've been editing lots of python programs. The original python.vim indent file does not provide this feature. It only indents stupid shiftwidth or shiftwidth * 2. So I had to manually align my source codes every time.
Finally, I've come to think I've had enough of it, and I started to modify the default python.vim indenting scheme.

Here goes python.vim that does cinoptions=(0,W4 feature. This scripts has been modified from the original python.vim script, which can be found in the indent directory in your vim installation location.

orchistro.deltabellun:~$ diff -ub  /Applications/MacVim.app/Contents/Resources/vim/runtime/indent/python.vim .vim/indent/python.vim
--- /Applications/MacVim.app/Contents/Resources/vim/runtime/indent/python.vim    2010-08-16 05:04:06.000000000 +0900
+++ .vim/indent/python.vim    2012-02-12 18:01:29.000000000 +0900
@@ -69,34 +69,17 @@
   endif
 
 
-  " When inside parenthesis: If at the first line below the parenthesis add
-  " two 'shiftwidth', otherwise same as previous line.
-  " i = (a
-  "       + b
-  "       + c)
+    " i = (aasdfasf,
+    "      b,
+    "      c)
   call cursor(a:lnum, 1)
-  let p = searchpair('(\|{\|\[', '', ')\|}\|\]', 'bW',
+    let [l,c] = searchpairpos('(\|{\|\[', '', ')\|}\|\]', 'bW',
       \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
       \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
       \ . " =~ '\\(Comment\\|String\\)$'")
-  if p > 0
-    if p == plnum
-      " When the start is inside parenthesis, only indent one 'shiftwidth'.
-      let pp = searchpair('(\|{\|\[', '', ')\|}\|\]', 'bW',
-      \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
-      \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
-      \ . " =~ '\\(Comment\\|String\\)$'")
-      if pp > 0
-    return indent(plnum) + (exists("g:pyindent_nested_paren") ? eval(g:pyindent_nested_paren) : &sw)
-      endif
-      return indent(plnum) + (exists("g:pyindent_open_paren") ? eval(g:pyindent_open_paren) : (&sw * 2))
+    if l > 0
+        return c
     endif
-    if plnumstart == p
-      return indent(plnum)
-    endif
-    return plindent
-  endif
-
 
   " Get the line and remove a trailing comment.
   " Use syntax highlighting attributes when possible.

Let's compare indending results before applying this script in your .vim/indent/ directory and after applying it.

Original indenting (before):

    avalue = self.some_function(argument1,
            argument2,  # how stupid it is
            argument3)
    blablabla...

Modified indenting (after):

    avalue = self.some_function(argument1,
                                argument2, # it looks good!!
                                argument3)
    blablabla...

For convenience, here is the python.vim file. Put it in your .vim/indent/ directory. If the directory does not exist, create one.

python.vim


----

Edit 1, 2012-04-16
* Fixed some broken English scentences.
* The script works fine most of the time. Sometimes, however, it cannot find correct indenting especially when there's arrays in arguments. I am not going to work on the bug until it starts driving me crazy :$

:

date commands

메모 2012. 1. 28. 00:48

$ date
Sat Jan 28 00:44:24 KST 2012

Getting the unixtime of now (BSD date, GNU date):
$ date +%s

1327679054

Getting the unixtime of specific moment (with LC_TIME='C', GNU date):
$ date -d 'Sat Jan 28 00:44:24 KST 2012' +%s

1327679064
$ date -d 'Sat Jan 28 00:50:01' +%s

1327679401
$ date -d 'Sat Jan 28 00:50' +%s
1327679400
$ date -d 'Sat Jan 28' +%s
1327676400

Getting the unixtime of specific moment (with LC_TIME='C', BSD date):
$ date -j 01280050.01  # format: [[[mm]dd]HH]MM[[cc]yy][.ss]
Sat Jan 28 00:50:01 KST 2012
$ date -j 01280050.01 +%s
1327679401

Getting the human readable date from unixtime: (GNU date)
$ date -d@1327679064
Sat Jan 28 00:44:24 KST 2012

Getting the human readable date from unixtime: (BSD date)
$ date -r 1327679064
Sat Jan 28 00:44:24 KST 2012

:

How to list defined functions in bash.

메모 2012. 1. 28. 00:39

$ declare -f
foo ()
{
    echo 'foo'
}
ps_indexd ()
{
    ps -e -o user,pid,ppid,lstart,stat,command | head -1;
    ps -e -o user,pid,ppid,lstart,stat,command | grep /nvmail/bin/indexd | grep -v grep
}

$ declare -F
declare -f foo
declare -f ps_indexd

:

iTunes Command-F to search local musics

카테고리 없음 2012. 1. 14. 02:53

http://www.macworld.com/article/56833/2007/03/searchtunes.html


defaults write com.apple.iTunes NSUserKeyEquivalents -dict-add "Target Search Field" "@~F"

@:command

~:option

$:shift

^:control


:

히라사와 우이 넨도로이드 구입

잡동사니 2011. 12. 13. 00:20

덕을 쌓으며 수행하기 시작한지 어느덧 2년이 훌쩍 넘어가고 있는 와중에, 드디어 또다른 덕업의 세계에 눈을 떴으니, 피규어(정확히는 넨도로이드(ねんどろいど)[각주:1] 를 구입한 것이 그것이다.

웹 서핑 중에 우연히 발견한 이후 북받쳐 오는 뽐뿌의 유혹과 지름신의 강림에 견디지 못해 굴복하고 말았으니, 아래의 사진이 지름의 대상이 되었다:


TVA けいおん!(캐이온!) 1기 12편의 에피소드에 나오는 아래의 장면을 모티브로, 표정 등을 과감하게 데포르메[각주:2]하여 귀여움을 최고로 끌어올린 위의 사진을 보고서는 사지 않고 배길 수 없었다.



그나저나, 개봉된 영화를 보려면 블루레이로 풀릴 때까지 기다려야 하겠군;;



  1. 지점토, 찰흙같은 것을 뜻하는 "넨도ねんど" 와 안드로이드를 결합해서 만들어 낸 합성어인 것으로 추측함. 모델이 되는 캐릭터의 원래 모양을 작고 둥글고 귀여운 형태로 변형시켜 만든 피규어의 통칭인 듯. [본문으로]
  2. 變形, deformer(불), 영어권에서는 deformation 으로 사용되는 모양. 전문 지식이 없어 정확한 정보는 전달할 수 없음을 이해해 주시기 바란다. 영문 위키피디아에 내용이 없는 관계로, 영문 위키피디아의 링크는 제공하지 못한다. 대신, 신빙성은 좀 약하지만, 한글 브리태니커 백과사전의 링크로 설명을 대신한다: http://preview.britannica.co.kr/bol/topic.asp?article_id=b04d4110a (영문 브리태니커 백과사전에서는 찾을 수 없었다) [본문으로]
:

Installing Io on OS X Snow Leopard(10.6.8)

Computing 2011. 12. 5. 00:21

0. Change definition of NS_INLINE:

You are going to get following error unless you make the changes:

io/libs/iovm/source/IoObject_inline.h: In function ‘IoCoroutine_rawRunTarget’:
io/libs/iovm/source/IoObject_inline.h:322: error: ‘always_inline’ function could not be inlined in call to ‘IoObject_rawGetSlot_’: recursive inlining
io/libs/iovm/source/IoObject_inline.h:344: error: called from here

Refer to https://github.com/stevedekorte/io/issues/135

1. Install yajl

git clone https://github.com/lloyd/yajl.git

Without it, you are going to encounter following error:

Linking CXX shared library _build/dll/libIoObjcBridge.dylib
ld: library not found for -lIoYajl


2. Install libevent

git clone https://github.com/libevent/libevent.git
cd libevent; autoreconf -i
./configure;make;sudo make install

Without it, you will encounter following error:

Linking CXX shared library _build/dll/libIoObjcBridge.dylib
ld: library not found for -lIoSocket


3. Check if additional libraries are available on your system

In case you cloned Io from github, go into build directory and type "ccmake .." to check which library is not on your system.
If you feel like you'll need one one of them, go and install it.


4. You are good to go make install

You will want to use build.sh script found in the io directory, if you cloned Io from github.
Or you may refer to this page: http://en.wikibooks.org/wiki/Io_Programming/Beginner%27s_Guide/Getting_Started


5. Enjoy Io

Have fun.

:

스티브 잡스 사망. 향년 56세, An iconic figure of the era has gone.

English/NBC Nightly News 2011. 10. 6. 23:26

May he rest in peace.

Breaking News at NBC Nightly News :

Brian Williams: Good evening, and before we get along with the broadcast tonight, instead we're going to begin with a late word of a breaking news story. So, for that, we go to our LA beureau to start things off with the report on the very latest details.


George Lewis: I'm George Lewis in LA. Apple Inc. announced tonight that company cofounder and former chief executive Steve Jobs has died at the age of 56. Here's a look back at his career.

He was the father of the iPhone, the iPod and the Apple Mac computer, turning electronic gadgets into objects of desire.

"I think if you do something and it turns out pretty good, then you should go do something else wonderfuler(?)"

As he was fond of saying, "Wait, there's more."

"Today, Apple is going to reinvent the phone."

And people did wait, in long lines for the first iPhones in 2007. And then three years later, they lined up for the iPad, changing the way people consume media.

"Design plus function equals the right life style, and that's what he filled."

In 1976, Jobs cofounded Apple Computer, and within a few years, was worth 100 million dollars. In 1984 he was showing off his new pride and joy, the Macintosh.

"And it has turned out insanely great."

As critics hail the Mac, Jobs was on the losing end of power struggle at his company and left Apple a year later. He went into computer animation acquiring Pixar Studios and striking __________ for the string of hit movies starting with Toy Stories.

Jobs came back to Apple in 1996 and began reinventing the Mac, dressing it up in a variety of colors.

"They look so good. You kindda wanna lick'em."

Concerns about the health of Steve Jobs began in 2004 when he underwent surgery for pancreatic cancer. A year later he spoke about that during a commencement speech at Stanford Univ.

"This was the closest I've been to facing death and I hope it's the closest I get for a few more decades."

An intensely private man with a quick temper, Jobs kept reporters at bay, saying his health was nobody's business. But Jobs was losing weight, something revealed in theses photos taken in 2007 and 2008. In April 2009, he underwent a liver transplant. Five month later, back on the job at Apple, he expressed his gratitude.

"I now have the liver of a mid-20s person who died in a car crash and was generous enough to donate their organs. And I wouldn't be here without such generosity."

On August 24 of this year, he stepped down as Apple's CEO. Back in 2005, he offered this bitter(?) advice to the Stanford Univ. Grads.

"Your time is limited. So don't waste it living someone else's life. Don't let the noise of other's opinions drown out your own inner voice."

Steve Jobs, the man whose own inner voice led him to create some of the most visionary products of the internet era. Jobs leaves behind a wife and four children.

George Lewis, NBC news Los Angeles.


George Lewis: Steve Jobs is being mourned tonight at Apple headquarters in Cupertino, CA where my colleague Janet Shamlian joins us now. Janet.

Janet Shamlian: George, here at the headquarters of Apple, the birthplace of so much of the technology that Steve Jobs has created and that the world uses. The campus is in mourn. You can see the flags behind flying at half staff. And on line, at apple.com, simply a picture of Steve Jobs and the dates of his birth and death. Apple has just released a statement that says,

"We are deeply saddened to announce that Steve Jobs passed away today. Steve's brilliance, passion and energy were the source of countless innovations that improve all of our lives. The world is immeasurably better because of Steve."

It is a statement that millions of users, of his fans all over the world would agree with.

George, back to you.

George Lewis: Thank you, Janet.

Once again, Steve Jobs, the man who gave the world the Macintosh computer, the iPhone, the iPod and the iPad, dead at 56.

Now back to Brian Williams in NY.

:

JLPT N1 합격

잡동사니 2011. 9. 1. 00:39

지난 7월 (2011년) 쏟아지는 폭우를 뚫고 시험장까지 가서 JLPT N1 시험을 치루고 왔다.

시험이 많이 어려워서 합격할 자신이 없었다. 시험을 치른 후, 고생고생하면서 시험장까지 간 것이 아깝다는 생각과, 한번쯤 시험에 떨어지는 것도 나름대로의 좋은 경험이니 아깝지 않다는 생각이 교차하면서 복잡한 심정이었다.

합격할 자신이 없었음에도 불구하고, 사람의 마음이란 '혹시나 합격할 수도 있지 않을까' 하는 근거 없는 기대를 하게 된다.

그렇게 결과를 기다린지 2개월.


오늘 발표된 시험 결과를 방금 조회해 보았다.


결과는, 합격!



: