четверг, 14 февраля 2019 г.

Random thoughts...?

Why people try to earn so much money(and much more afterwards)? When they use them, they seem happy... Because when you get something you wanted, it makes you feel happy. What about work? Do you like your work? Do you have enough? Do you wanted more(of course you are isn't it?)? What will make you feel satisfied? For how long? You should think about it by yourself.

An empty metal box is out there, somewhere. I mean its empty, but if you close it, someone who didn't know its empty might think that it is not. The pre-assumption of most people is that the box have something. But nothing is too a thing. Its nothing. The nothing could be nothing and nothing else than nothing.

I climbed a trees when I was younger, I'we been thinking that its fun. But it was! The time when I believed it was fun, it actually was! If you believe so. Anything you believe could be your pleasure/happiness or opposite. So choose what to believe! Believe in something that turns your mind/doings/whatever into a pleasure/happiness.

I have a dog, its not just a dog. Its a dog that likes to be chased. When I chase him looks so adorable sits,ups and making face and eyes like that the most beautiful thing he ever seen. What he thinks of it? Whats on his mind when we're playing? Is it all about fun? Is it all about food? No, I doubt that I ever know....

Writing the code it isn't so simple, you have to know what are you trying to accomplish, in your mind you have to imagine the result of what are you trying to accomplish, and then step-by-step think-and-write on how to do it. Sometimes you can't clearly imagine what the result should be, in that case you should swap the direction of think-and-write, just start writing the something simple, then think about how can you improve it, and after some everything will become something like the "unclear result" you wanted at the start, or even something more.

Why do there are no more dinosaurs? There was so many(if the encyclopedias is the one you can believe) types, with so strange and different bodies. They were just like some kind of a race. Some of them could fly, some could swim, some lived all of the live on the ground. But all of them have something in common, that is why we called them dinosaurs(yeah, everything you know, every single word created by some human). And why all of them disappeared? I mean ALL of them? Not a single one? Well thats kinda sad, you 'now? That means anytime another race, for example birds, could disappear entirely... But that is the world, that is how it lives, that is how everything is going, that is where everything is going. To an end. And end is end. Not a new beginning, not that is too optimistic. End is end, and there is nothing to do with it. If rain is falling, you can't make it go back to the sky.

That is end.

среда, 13 февраля 2019 г.

How to use Vim's folding: the Expr and Marker methods.

The idea:

Folding can save you some time when navigating through file(s), but in Vim not all languages-plugins have built-in folding methods. Not so long ago I created a simple folding for "AutoHotkey" language-plugin, and I wanted to share with everyone on how I did it. In Vim there are variable named foldmethod that determines the method of folding, possible values: manual, diff, marker, expr, indent and syntax. The most powerful out of all is expr, with it you can do pretty much any kind of folding, but for that you should know how the folding actually works, read the :h fold.

Lets back to my AutoHotkey language folding script. So for the start is - the location of the script, you can use the ~/.vim/ftplugin/{LANGUAGE}/{ANYNAME}.vim, so for the my AutoHotkey fold it will be: ~/.vim/ftplugin/autohotkey/folding.vim.

The "Marker" method:


The marker method is very simple: You just define the start point and the end point delimited by comma, for example:

setlocal foldmethod=marker
setlocal foldmarker=SECTION,ENDSECTION

(If you use have spaces you should escape them, e.g. my\ fold\ start for the "my fold start")

Quite simple. Just 2 lines. First line tells Vim to use marker fold method, second defines folding start as SECTION and end as ENDSECTION. So lets open the *.ahk file, and add the SECTION and ENDSECTION to it(in the comments of course :)), lets take for example that file:

; SECTION Variables
funname := "thefunction"
; ENDSECTION
;SECTION Functions
thefunction(x, y) {
    s := x+y
    msgbox, Sum: %s%
}
; ENDSECTION
; SECTION Main
%funname%(24,18)
; ENDSECTION

with the folding script, that I mentioned earlier, in Vim now it will look like:

+-- 3 lines: ; Variables
+-- 6 lines: ;Functions
+-- 3 lines: ; Main

And when you try to i(edit) it it will unfold and display the code that were folded. You can also fold back the section that you have under cursor with :foldclose or shorter: :foldc.

The "Expr" method:

Expr method could be one complex one line or an function, lets use a function:

setlocal foldmethod=expr
setlocal foldexpr=SECTFOLD(v:lnum)
let b:IN=1
let b:ST='^\s*.\?;\s*.\?SECTION'
let b:EN='^\s*.\?;\s*.\?ENDSECTION'
function! SECTFOLD(linenum)
    let lt = getline(a:linenum)
    if lt =~ b:ST
      let b:IN = b:IN+1
      return '>' . b:IN
    elseif lt =~ b:EN
      let b:IN = b:IN-1
      return '<' . b:IN
    endif
    return '='
endfunction

Looks quite complex isn't it? So, the logic is: set foldexpr to function, and pass the line number v:lnum, then process each line. The SECTFOLD function works like the marker fold method, but it has the regex support! and with it we can define that the fold won't actually fold the variable or text named SECTION, so we make it count only the lines starting with ;(comment) and n-spaces and a SECTION. The b:IN holds fold level, b:ST regex for fold start, b:EN fold end regex.

Q/A:


Q: Why using setlocal?
A: If you use set the folding will be gone global, and after closing the AutoHotkey file the folding method will work for all other files.

Q: Marker method inside comments?
A: The closest to regex is: ;\ SECTION,;\ ENDSECTION but you'll need to enter EXACTLY 1 space after ;, and it will work even in inline comments...

Q:Expr method checking for matching ENDSECTION, if no don't fold.
A:You can use the add subfunction inside if lt =~ b:ST, to check if there is ending match, use line('$') to find out the last line index, and line('.') for the current, then loop over that range and return true if there is ending, else do not start he fold in if lt =~ b:ST.

понедельник, 24 декабря 2018 г.

hold it on the moon
based on the spoon
call it that way
until the day of decay

from the day of the Sixths
will be future from a fairytale
when there will be no bits
because this actually is a realtale

月に持って
スプーンに基づく
そのように呼ぶ
崩壊の日まで

シックスの日から
おとぎ話から未来になります
ビットがなくなるとき
これは実際には実話ですから