Max Gonzih

KEEP CALM and CODE ON

How I Cook Ctags in Vim

| Comments

Ctags is great piece of software. And it took me some time to realize how I can use ctags with vim in optimal for me way. My solution is petty simle. I have few vim functions that vim runs when buffer write is done.

Blue Midnight Commander Color Scheme

| Comments

I spend today few hours reading mc documentation about color scheme configuration. Came up with following color scheme. Enjoy :)

Blue Midnight Commander color scheme

.config/mc/ini
1
2
[Colors]
base_color=lightgray,blue:normal=blue,default:reverse=green,default:gauge=gray,lightgray:selected=white,blue:marked=yellow,default:markselect=yellow,default:directory=brightblue,default:executable=brightgreen,default:link=cyan,default:device=brightmagenta,default:core=red,default:special=lightgray,default:dnormal=lightgray,blue:dfocus=lightgray,black:dhotnormal=yellow,blue:dhotfocus=yellow,black:menunormal=lightgray,blue:menuhot=yellow,blue:menusel=lightgray,black:menuhotsel=yellow,black:menuinactive=lightgray,gray:errors=lightgray,red:errdhotnormal=yellow,red:errdhotfocus=yellow,lightgray:input=lightblue,gray:inputunchanged=blue,gray:inputmark=white,blue:bbarhotkey=white,black:bbarbutton=lightgray,blue:viewbold=lightgray,default:viewunderline=lightblue,default:viewselected=lightgray,grey:helpnormal=lightgray,default:helpitalic=lightblue,default:helpbold=lightgray,default:helplink=green,default:helpslink=lighgreen,defalt:

For more information take look at mc wiki and run mc --help-color to see available color variables in your mc version. Format of color configuration is what=foreground,background:. All configuration shoud be in one line (ofcourse you can write it in multiple lines and then use vim (or other cool editor) magic).

Easy HTML5 Validation Fallback for Older Browsers Using Modernizr and JQuery Validation Plugin

| Comments

So I heard that you hate IE. Also I heard that you love HTML5. Is that true? Great, I feel the same about IE. So here is quick fallback script for html5 validation in older browsers (or crappy ones, like IE). You will need three things for that.

First is Modernizr javascript library. It allows you to detect which features are supported by your browser and which aren’t.

Second is JQuery. I think you are already familiar with it, so there is no need to tell you why it’s awesome and how to use it.

Third is JQuery Validation Plugin. It provides mechanism for form validation based on input classes.

So now only things you need to do is to convert html5 validation attributes to html classes and run validation plugin. Here is small CoffeeScript snippet:

1
2
3
4
5
6
7
8
9
10
11
# initialize plugin on page ready
$ ->
  unless (Modernizr.input.required)
    $('form').find('input[required]').each ->
      $(this).attr('class', 'required ' + this.getAttribute('type')).removeAttr('required')

    $('form').each ->
      $(this).validate()

# check if form is valid by hand
$('form').valid()

And as always, Have a nice day! :)

Note on Privacy #1

| Comments

Today I removed from my blog all staff that can track users. I removed Twitter follow and tweet buttons, Google +1 button, Google Analytics script, Facebook related crap.

Why? Because it’s just unfair. Why would you provide any information about yourself by just being curious? I actually not interested in how many people are reading my blog, anything about traffic sources. Only thing that I am interested in is feedback from users. That is why I left Disqus unchanged. Maybe later I will find something more open and replace Disqus with it. But for now if privacy is issue for you check out Ghostery exstension for Google Chrome (Chromium).

Programmer Dvorak and Switching Workspaces in XMonad

| Comments

Recently I migarted from awesome to xmonad. I’m Programmer Dvorak freak, so I stuck with controlling current workspace from numbers row. First hack was to use functional keys [F1..F12] like so:

1
2
3
4
5
6
-- mod-[F1..F12]       Switch to workspace N
-- mod-shift-[F1..F12] Move client to workspace N
--
[((m .|. modm, k), windows $ f i)
    | (i, k) <- zip (XMonad.workspaces conf) [xK_F1 .. xK_F12]
    , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]

But after some research I found that I can detect key symbol using xev command. Here is my latest solution:

1
2
3
4
5
6
7
8
-- Programmer Dvorak
-- mod-[1..9]       Switch to workspace N
-- mod-shift-[1..9] Move client to workspace N
--
[((m .|. modm, k), windows $ f i)
    | (i, k) <- zip (XMonad.workspaces conf) [xK_ampersand, xK_bracketleft, xK_braceleft, xK_braceright, xK_parenleft
                                             ,xK_equal, xK_asterisk, xK_parenright, xK_plus, xK_bracketright, xK_exclam]
    , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]

Hooray! It works!