Joined June 2012
·

Łukasz Niemier

Student/Backend developer
·
Poznań, PL
·
·
·

Posted to Programming Languages One-liners over 1 year ago

Let me get it straight:

Django = Rails - Ruby + Python - good_design
Ruby = Python - ugly_off_side_rule + awesome_clojures + omg_dsls_was_never_so_eazy + rubygems + bundler + easy_chains
Posted to Rails: Casting Objects as Arrays over 1 year ago

Why not [*param[:emails]]?

Posted to Absurdly Abstract @font-face mixin over 1 year ago

This is AWESOME.

Posted to Object.extend Black Magic over 1 year ago

This should be in standard.

https://coderwall.com/p/vbq-ra - the best are fix and todo.

Posted to Make your TMux status bar responsive over 1 year ago

Width of the TMux. It is used to determine which element's should be shown.

Personally I prefer CarrierWave over PaperClip. Much cleaner IMHO. Also instead of Slime has nicer syntax IMHO.

Posted to Make your TMux status bar responsive over 1 year ago

@creaktive - I would, and I will, but after Christmas. Yeah, but tmux-powerline is now abandoned and Lokaltog version depends on Python. This one is pure shell (I use Airline for Vim).

Posted to Make your TMux status bar responsive over 1 year ago

@yeraze there are Powerline separators (so you need patched font). Codes are LSEP = 0xEE 0x82 0xB0, RSEP = 0xEE 0x82 0xB2, RSEPE = 0xEE 0x82 0xB3. But you can try other chars.

@jailbot it's to simplify implementation of weak typing. If JavaScript used Integers it will add another layer of abstraction to Number. Other interpreted languages have difference between Int and Floats (like Ruby, Python or Smalltalk) but changes between types can be fluid (like / in Python or Smalltalk, first return Float, second Fraction).

Posted to Ruby's yield & blocks over 1 year ago

There is better option:

alias_method :fois, :times

@xander there are no "integers" in JS. IMHO in most cases you shouldn't bother yourself about that one is floating-point or integer. If you need to be sure that this is integer then use Math.floor, Math.ceil or Math.round. No matter if you expect Number or String.

Simpler way:

> str = '173234786123874612'
'173234786123874612'
> +str
173234786123874620
Posted to How to accept one or more arguments over 1 year ago

I preffer the first snippet. If you want to be sure that you're safe about your trap, you can always do this:

def method(*args)
  args.flatten!
  # blablabla
end

Do not use git status without --porcelain flag in your scripts. My version using "normal" AWK

git status --porcelain | awk '/^ M/ { print $2 }'

I preffer rbenv.

But why? When you call git log <sha> you will get the date and time of commit.

Posted to Autocompletion over 1 year ago

Or use PRY :D

Why not ~?

Posted to Git Configuration over 1 year ago

Why not simply git config --edit?

Posted to Easy Ruby versions from your .bashrc over 1 year ago

Why not use rbenv?

Posted to Use Mercurial for dotfiles over 1 year ago

Or create another folder and symlink all your dotfiles to this.

@dtao to thank me just keep working on Lazy.js. IMHO it is great library and is much better than Underscore, so keep going.

@dtao for symbols is %i. Also in Ruby 2.0 there is ** (splat splat) operator for named arguments, so:

def foo(**args)
  p args
end

foo(a: 10, b: 20) #=> {:a => 10, :b => 20}

In Ruby, "splatted" argument may be in the middle, so function like this:

def first_middle_last(first, *middle, last)
  p first, middle, last
end

is fully correct and functional:

first_middle_last(1, 2) #=> 1, [], 2
first_middle_last(1, 2, 3, 4) #=> 1,  [2,3], 4

IE7 and 8 have conditional comments so you don't have to use JS.

My most used

3251 g
1051 e
 877 ls
 753 rm
 690 y
 475 cat
 358 less
 355 sudo
 351 cd
 302 echo

Pretty big usage of Git and Vim.

My version is a little bit longer:

function most-used --description 'Print most used commands'
  history | awk '{print $1}' | sort | uniq -c | sort -rn | head $argv
end
Posted to Use your own vimrc when using sudo over 1 year ago

Yes. You can use Vim -u <vimrc> option.

Posted to search and replace files oneliner over 1 year ago

I prefer using sed -i.

In first example all is caused that your usage of before_save is invalid. You should use after_initialize instead. In second example nicer would be BlahMailer.blah_notifier(self).deliver or true which also always return truth value, but if first statement is successfull then return value returned by that method.

Posted to Quickly Exit Vim over 1 year ago

There is also alternative command :x. ZZ shortcut is nice, but I have some written on my own:

  • ZX - mapped to :cq which quits with error (useful when dealing with Git)
  • ZA - quit all without saving (:qa)
  • ZS - quit all with saving (:xa)
Posted to QuickSort in Python over 1 year ago

I had cannot understand quick sort until I found Haskell and this:

quicksort :: Ord a => [a] -> [a]
quicksort []     = []
quicksort (p:xs) = (quicksort lesser) ++ [p] ++ (quicksort greater)
    where
        lesser  = filter (< p) xs
        greater = filter (>= p) xs

I wolud write Haskell code some other way:

mod3 :: Int -> Int
mod3 = reverse mod 3

mod5 :: Int -> Int
mod5 = reverse mod 5

select35 :: [Int] -> [Int]
select35 = select mod5 $ select mod3

main :: IO ()
main = print . sum . select35 [1..1000]
Posted to Bower and Rails. Friends forever. over 1 year ago

@royletron, yes convention.You should keep some organisation in your code. For me app/ folder is only for my application code, not for any library.

Also I don't keep any of Bower installed libs in Git repo. All of them are downloaded on server before assets:precompile to keep application repository with only my app code. IMHO it is the best options. If you wan't store external libs in your Git tree then you should think about using Git submodules instead of Bower.

Posted to Bower and Rails. Friends forever. over 1 year ago

DO NOT USE app/assets/ FOR EXTERNAL ASSETS.

For this you have vendor/assets. Next thing is that then you do not need to place all your assets in extra folder.

Posted to Reset git history over 1 year ago

@erivello: Then why not simply use git gc --prune=now? Also using Git to version binary files is bad idea. Maybe it will be fixed in 2.0, but I bet that it won't.

Posted to Column formatting in vim over 1 year ago

I prefer using Tabular gem.

Posted to Yank a whole file in Vim. over 1 year ago

I would rather use <Leader>fy as <Leader>y is nicer to have binded to "+y.

@raymondchou - because RVM sucks.

PS use rbenv.

Posted to Reset git history over 1 year ago

Why the hell anybody should do that?

Posted to simple git auto-pull over 1 year ago

Except that I disagree with using git pull it is nice idea.

Do not use #create in seeds.rb. Use #create! to be sure that your models are created.

Posted to git command aliases over 1 year ago

I prefer have it as a git aliases than as a shell aliases. It is more general then.

Posted to let do it over 1 year ago

I still doesn't see use-case for assignment in view.

Why not use gp instead p? Works out-of-the-box.

You can use simpler and faster di} (assume you are inside the block).

Posted to Command: github-clone over 1 year ago

There are 2 ways to do it better:

  • use address alias (add this to .gitconfig and then use it git clone gh:name/repo):

    [url "git@github.com"]
      insteadOf = gh
  • use Hub

Posted to Find your fat modules over 1 year ago

@vohof: find look for all files that ends with .m, then awk wraps each line (found file) with " (quotes), count lines, and sort by it.

Posted to Kill Rails Server over 1 year ago

Why not use killall?

Posted to vim pasting without making a mess over 1 year ago

Or you can use gp instead p.

Posted to Indenting text in a file with vi/vim over 1 year ago

Better idea is to select text to indent and use >>, = or :retab

Posted to Find your fat modules over 1 year ago

You forgot -n flag in sort

Also for Git projects you can use:

git ls-files '*.m' | xargs wc -lm | sort -n
Posted to Getting around Em inheritance over 1 year ago

Or you can try rem values.

@limpangel: I used Vundle for some time, but I cannot get along with it so I switched to Pathogen. But using submodules is really awesome idea.

Also I don't like and don't recommend installing NERDtree. There is no usage of this (you can use built in :e dir command) and only confuse user. My own configuration (and come other confs also) can be found at https://github.com/hauleth/dotfiles

Why not simply add pry-rails gem? IMHO a little bit easier and cleaner.

For me it is nasty usage of Bash aliases. It is better to use Git aliases instead, i. e instead your gitassumeunchanged I have git skip (git config --global alias.skip update-index --assume-unchanged).

You forgot about git rebase -i for squashing

Also nice is :xa which save and quit all files. In case to use it as ZZ (save and quit) I have mapped some more:

map ZX :cq " quit and return error (helpful when using Vim with Git)
map ZA :qa " quit all buffers
map ZS :xa " quit and save all buffers 

Isn't deviantArt something like that?

Posted to Auto-run tests in Node.js over 1 year ago

Why not use Karma instead.

Or you can use Hub which provide some more features.

Posted to `rbenv shell` and fish over 1 year ago

@jtomaszewski Fish allow setting empty variables so there is no need to create fallback to empty string, so if there is no arguments then rbenv will be called without any arguments. Everything works as expected.

Posted to `rbenv shell` and fish over 1 year ago

@jtomaszewski give example when this snippet doesn't work. I cannot found that one. But if it really bother you then you can write set -l command "$argv[1]".

Posted to `rbenv shell` and fish over 1 year ago

@jtomaszewski There is no need to do that. In fish (like in any other shell) when you try to access to non-existent variable then you get empty value.

The best of it is that it propely work with tag closing. http://jsfiddle.net/nxeGZ/12/

Posted to Make life faster - one letter aliases over 1 year ago

@enlavin I use fish and there it work that way also but not for -, so I write it down also.

Posted to Count today's commits in Git on *nix over 1 year ago

Why not git log --since=$(date +%U)?

@jacaetevha so what's the problem? Then you simply write:

git recent-branches --count=1

I will override previous flag.

Why that way and not simply:

[alias]
  recent-branches = for-each-ref --sort=-committerdate --count=10 --format='%(refname:short)' refs/heads/
Posted to The single most useful thing in bash over 1 year ago

@glitchmr not only you :)

Posted to Enable unicode support in IRB over 1 year ago

Or just start using Pry.

Posted to Keep TODOs in git over 1 year ago

Don't like that solution. IMHO better is using in-code TODOs and my git todo alias, external TODO file or use git notes.

Posted to i18n a list over 1 year ago

IMHO better idea is to use YAML array:

en:
  steps:
    - do this
    - do that
    - do this again

and then you can use it as an normal array:

<ul>
  <%- t('steps').each do |step| -%>
    <li><%= step %></li>
  <%- end -%>
</ul>

@bartlomiejdanek I understand what you mean but my point is that sometimes I work on bunch of files and I wanna commit only part of them. Then your hook will unable me to do that if in some of them I still have, i.e. a binding.pry. In my way it stop you if and only if you have that in code that you are trying to commit.

@bartlomiejdanek but why bother about untracked/unindexed files? Maybe I still workin on them and I want commit only that files. Then your hook will unable me to do sa if I don't disable hooks for this commit. IMHO that much better idea to check only indexed and commited files, not all.

As I see, you use grep command. As this hook work on Git-only repositories why not use git grep --cached? It will work faster and you won't need to run git diff-index --name-only HEAD --.

Also I will move keywords to Git config. Then you can add this as template and for every project you can have another keywords that you don't want to see in public repo.

Posted to Don't fight the CSS cascade. over 1 year ago

You can also use some kind of compressor that find the same selectors and merge them into one block.

Posted to Using .reject with .map in Ruby over 1 year ago

Why are you using #map? #to_a is much better.

Posted to Use twitter flight with rails over 1 year ago

Please, use lib/ and vendor/ for assets that are not strictly connected with your app.

Posted to Gemfile: Better Errors over 1 year ago

Don't work for me (crashing on Ruby 1.9.x)

@gahtune not IDE. A tool like Rake or Capistrano that will only manage projects and run required apps/daemons. No editor or something like that. You should use editor of your choice (I use Vim and I'm happy).

@gahtune My goal is to write tool that will read some config file inside that dir and run processes needed in development mode like Guard, DB process or something like that (maybe in screen processes).

Posted to Wishing you a multilingual Christmas over 1 year ago

C++:

string Christmas = "beer ";
string NewYear = "more beer";
if (Christmas + NewYear == "beer more beer")
  cout << "festive hangover\n";

Haskell:

let after a b = if b ++ a == "beer more beer" then "festive hangover" else ""
let Christmas = "beer "
let NewYear = "more beer"
main = putStrLn $ NewYear `after` Christmas

D:

string Christmas = "beer ";
string NewYear = "more beer";
if (Christmas ~ NewYear == "beer more beer")
  writeln("festive hangover");
Posted to Using bash? Check zsh out!! over 1 year ago

Try fish, it awesomness beat ZSH twice.

Posted to Invoke a rake task from another task over 1 year ago

Much simpler, and more acceptable is:

task :invoke_another_task => %w[another:task one:another:task]
Posted to Git: Temporarily ignoring files over 1 year ago

I would prefer skip aliases instead of ignore because I use ignore command to add file to .gitignore.

Posted to git clone github:user/repo over 1 year ago

Why not use hub?

Posted to Shorter Git URLs over 1 year ago

For GitHub you can also install hub and use only git clone name/repo

Posted to return from block over 1 year ago

Sometimes break is better. For example if we want to escape from #each.

Posted to Markdown with RDiscount over 1 year ago

I prefer Redcarpet gem that use Sunshine native library. It's faster and has a little bit better support (at least GitHub is not small company).

Use pry to quickly resolve any Ruby argument.

Posted to Faster preview of Sass/SCSS projects over 1 year ago

@shadowfiend Yes, but sometimes Compass is over bloated or i.e. we are creating independent theme/framework (like Bootstrap or MetroUI), not whole website frontend. Then not relying on any existing framework is good idea.

Posted to commandline output for coderwall.com over 1 year ago

You can accomplish that also by selecting your code and hitting <kbd>Tab</kbd>

@gavinblair I will check it when I switch to Windows. What version of Git you have?

I've always wandering why not simply font-size: 0px;?

Posted to Keep your feature branch up to date. over 1 year ago

@clowder and even git config alias.update 'pull --rebase origin master ' and then running just git update.

Posted to Magical oh-my-zsh prompt over 1 year ago

Great theme, but I still prefer bira :)

Posted to Bored? Have a shell? over 1 year ago

Great nerd joy.

Posted to cd to git root over 1 year ago

Faster and easier is

cd $(git rev-parse --show-toplevel)
Achievements
774 Karma
53,589 Total ProTip Views