Skip to content

Instantly share code, notes, and snippets.

View andriimosin's full-sized avatar
:shipit:
Excited

Andrii Mosin andriimosin

:shipit:
Excited
View GitHub Profile
@paul
paul / async.rb
Created December 25, 2018 04:05
Implementations of useful step adapters for dry-transaction
# frozen_string_literal: true
module Tesseract
module Transaction
module Steps
# Executes the step in a background job. Argument is either an ActiveJob
# or another Transaction (or anything that implements `#perform_later`.
#
# If the provided transaction implements a `validate` step, then that
# validator will be called on the input before the job is enqueued. This
@wesbos
wesbos / recent-places.md
Created October 29, 2015 14:04
Increase OSX "Recent Places

Increase the number of "Recent Places" that OSX shows in save dialogs. This allows you to quickly save files without having to dig through nested folders.

  1. Open your terminal and run defaults write .GlobalPreferences NSNavRecentPlacesLimit -int 10 && killall Finder
  2. OSX will now save 10, instead of the default. You won't see it take effect right away, but only after you save 5 more things.
  3. Enjoy your better life.

@wikiti
wikiti / spiral_matrix.rb
Last active September 6, 2022 05:11
Print or traverse a matrix in spiral order using Ruby language
# Helper method to clone objects
def deep_clone(object)
Marshal.load(Marshal.dump(object))
end
# The concept y pretty simple: imagine that you have the following matrix:
# 1 2 3 4
# 10 11 12 5
# 9 8 7 6
#
@xfanwu
xfanwu / xxf.zsh-theme
Last active March 9, 2025 18:22
Yet another theme for oh-my-zsh
# Copy and self modified from ys.zsh-theme, the one of default themes in master repository
# Clean, simple, compatible and meaningful.
# Tested on Linux, Unix and Windows under ANSI colors.
# It is recommended to use with a dark background and the font Inconsolata.
# Colors: black, red, green, yellow, *blue, magenta, cyan, and white.
# http://xiaofan.at
# 2 Jul 2015 - Xiaofan
# Machine name.
function box_name {
@fotinakis
fotinakis / cancan_matchers.rb
Last active August 25, 2024 16:44
Custom rspec matcher for testing CanCan abilities
# Custom rspec matcher for testing CanCan abilities.
# Originally inspired by https://github.com/ryanb/cancan/wiki/Testing-Abilities
#
# Usage:
# should have_abilities(:create, Post.new)
# should have_abilities([:read, :update], post)
# should have_abilities({manage: false, destroy: true}, post)
# should have_abilities({create: false}, Post.new)
# should not_have_abilities(:update, post)
# should not_have_abilities([:update, :destroy], post)
@hatarist
hatarist / .zshrc
Last active December 31, 2015 17:39
(zsh) Colorize iTerm2 prompt when connecting to SSH servers
alias sww="iterm_bg_color 30 0 0; ssh web-production; iterm_bg_color 0 0 0"
alias swt="iterm_bg_color 0 20 20; ssh web-test; iterm_bg_color 0 0 0"
function iterm_bg_color() {
local tty=$(tty)
osascript -e "
tell application \"iTerm\"
repeat with theTerminal in terminals
tell theTerminal
try
@sfate
sfate / vim-on-heroku.sh
Created June 7, 2012 14:39 — forked from naaman/vim-on-heroku.sh
vim on heroku
#!/usr/bin/env bash
curl https://s3.amazonaws.com/heroku-jvm-buildpack-vi/vim-7.3.tar.gz --output vim.tar.gz
mkdir vim && tar xzvf vim.tar.gz -C vim
export PATH=$PATH:/app/vim/bin
@myronmarston
myronmarston / ways_to_use_vcr.rb
Created April 13, 2012 15:00
Ways to use VCR for a request made by a let block
# 1) Use VCR.use_cassette in your let block. This will use
# the cassette just for requests made by creating bar, not
# for anything else in your test.
let(:foo) { VCR.use_cassette("foo") { create(:bar) } }
it "uses foo" do
foo
end
# 2) Wrap the it block that uses #foo in VCR.use_cassette.
@jeffkreeftmeijer
jeffkreeftmeijer / bassie.png
Created April 11, 2011 12:01
Colored image blob detection
bassie.png