Skip to content

Instantly share code, notes, and snippets.

View costis's full-sized avatar
🎯
Focusing

Costis Panagiotopoulos costis

🎯
Focusing
View GitHub Profile
@costis
costis / gist:1652950
Created January 21, 2012 14:38
Removing all gems
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
@costis
costis / gist:1707556
Created January 30, 2012 23:39
inspect
80 def inspect
81 variables = (instance_variables - uninspect_variables).collect do |name|
82 "%s=%s" % [name, instance_variable_get(name)]
83 end.join(' ')
84 uninspect = uninspect_variables.collect do |name|
85 var = instance_variable_get name
86 "%s=%s[%i]" % [name, var.class, var.size]
87 end.join(' ')
88 sprintf "#<%s:0x%014x %s %s>", self.class, object_id,
89 variables, uninspect
@costis
costis / colors.sh
Created March 3, 2012 12:14
Print ANSI color table in a console
for i in {0..255} ; do
printf "\x1b[38;5;${i}mcolour${i}\n"
done
@costis
costis / benchmark.sh
Created March 8, 2012 15:32
Benchmarking linux servers
for i in cpu threads mutex memory; do
sysbench --test=$i run
done
@costis
costis / gist:2558269
Created April 30, 2012 13:15
Rails console logging
http://rors.org/2011/07/17/inline-logging-in-rails-console.html
@costis
costis / gist:2629139
Last active October 4, 2015 11:37
Checkinstall - Make debian packages
checkinstall -D --fstrans=0 make install
@costis
costis / tmux-term-colors
Created June 4, 2012 11:39
Tmux and terminal colors
Don't set TERM in .bashrc
Start tmux with 'tmux -2' (this will enable 256 colors)
Use the following script to display color palette in terminal:
for i in {0..255} ; do
printf "\x1b[38;5;${i}mcolour${i}\n"
done
@costis
costis / gist:3032221
Created July 2, 2012 09:16
Convert html, markdown etc to PDF
Use pandoc
@costis
costis / gist:3885595
Created October 13, 2012 18:06
Search and replace in files
The other big option here is simply not to use vim:
sed -i 's/pattern/replacement/' <files>
or if you have some way of generating a list of files, perhaps something like this:
find . -name *.cpp | xargs sed -i 's/pattern/replacement/'
grep -rl 'pattern1' | xargs sed -i 's/pattern2/replacement/'
and so on!
@costis
costis / gist:4025267
Last active October 12, 2015 12:17
Send to Tmux from Vim
map <f9> :silent !tmux send-keys -t left 'ruby %' C-m<cr>
map <Leader>rl :silent !tmux send-keys -t right 'ruby %' C-m<cr>
# Clear screen and redrew Vim buffer.
map <Leader>aa :silent !tmux send-keys -t right 'clear; ruby %' C-m<CR>:redraw!<CR>
# Send current buffer to Ruby
nnoremap <leader>g :execute "!tmux send-keys -t bottom 'clear; ruby '" . expand('%:p') . "\r"<cr>