Skip to content

Instantly share code, notes, and snippets.

@vova
vova / zsh-keyboard-shortucts.md
Created May 12, 2022 22:34 — forked from mkfares/zsh-keyboard-shortucts.md
Common zsh Keyboard Shortcuts on macOS Catalina

Common zsh Keyboard Shortcuts on macOS

Navigation

CTRL + A : Move the cursor to the beginning of the line
CTRL + E : Move the cursor to the end of the line
OPTION + Left Arrow : Move the cursor one word backward
OPTION + Right arrow : Move the cursor one word forward
Left Arrow : Move the cursor one character backward
Right Arrow : Move the cursor one character forward

@vova
vova / CHRUBY_add_ruby_version.md
Created July 19, 2018 21:34 — forked from yannvery/CHRUBY_add_ruby_version.md
CHRUBY - How to install a new ruby version

Install a new ruby version with chruby

OSX

First of all you must update ruby-build to update definitions list.

brew update

And update ruby-build

@vova
vova / README.md
Created May 21, 2017 22:25 — forked from csswizardry/README.md
Vim without NERD tree or CtrlP

Vim without NERD tree or CtrlP

I used to use NERD tree for quite a while, then switched to CtrlP for something a little more lightweight. My setup now includes zero file browser or tree view, and instead uses native Vim fuzzy search and auto-directory switching.

Fuzzy Search

There is a super sweet feature in Vim whereby you can fuzzy find your files using **/*, e.g.:

:vsp **/*<partial file name><Tab>
@vova
vova / gist:4650631759877e36091a
Created June 9, 2015 15:19 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote

Use the debugger gem with unsupported Ruby versions

  • replace the version of debugger-ruby_core_source in the path below, with the one you're using
gem install minitar
gem install debugger-ruby_core_source // or install it with bundler
cd ~/.rbenv/versions/2.0.0-p598/lib/ruby/gems/2.0.0/gems/debugger-ruby_core_source-1.3.7 && rake add_source VERSION=2.0.0-p598 && cd -
@vova
vova / gist:8f4c13eb6ca3c95fe701
Created April 7, 2015 12:47
ruby with gc tuning parameters
#!/bin/sh
# wrap ruby with gc tuning parameters
export RUBY_HEAP_MIN_SLOTS=<%= @node[:ruby][:gc][:heap_min_slots] %>
export RUBY_HEAP_SLOTS_INCREMENT=<%= @node[:ruby][:gc][:heap_slots_increment] %>
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=<%= @node[:ruby][:gc][:heap_slots_growth_factor] %>
export RUBY_GC_MALLOC_LIMIT=<%= @node[:ruby][:gc][:malloc_limit] %>
export RUBY_HEAP_FREE_MIN=<%= @node[:ruby][:gc][:heap_free_min] %>
exec "<%= @node[:languages][:ruby][:ruby_bin] %>" "$@"
$('body').html('<table id="words"><thead><tr><th>Language</th><th>Category</th><th>Word</th><th>Strength</th></thead><table>');
var ld = duo.user.attributes.language_data;
for (l in ld) {
ld[l].skills.models.forEach(function(model) {
var a = model.attributes;
if (a.progress_percent > 0) {
$.get('/skills/' + a.language + '/' + a.url_title, function(skill) {
skill.path.forEach(function(path) {
if (path.words && path.strength > 0) {
path.words.forEach(function(word) {
# A few examples about how to use Ruby for parsing files as we could do
# with Awk or Grep. This is based on what I learn fro this post:
# http://code.joejag.com/2009/using-ruby-as-an-awk-replacement/
# Split each line with ':' and print the first $F[0] field
awk -F: '{ print $1 }' /etc/passwd
ruby -F: -nae 'puts $F[0]' /etc/passwd
# Parse the 'ps aux' output
# It'll print the ID process for the 'jojeda' user
#!/usr/bin/env ruby
spec_hits = []
checks = {
'_spec\.rb$' => ['focus:[:space:]*true'],
'\.rb$' => ['binding\.pry', 'debugger']
}
# Find the names of all the filenames that have been (A)dded (C)opied or (M)odified
filenames = `git diff --cached --name-only --diff-filter=ACM`.split("\n")
@vova
vova / remove_unused_helpers
Created September 19, 2013 11:51
Remove rails helpers which doesn't have any methods (often created by a generator)
ruby -e 'require "fileutils";Dir.glob("app/helpers/**/*.rb").each{|file| if (!File.read(file).index("def")); FileUtils.rm file; FileUtils.rm_f file.sub("app/", "spec/").sub(".rb", "_spec.rb") if File.exist?("spec"); end}'