Skip to content

Instantly share code, notes, and snippets.

@volodymyr-nt
volodymyr-nt / config.yml
Created October 25, 2018 20:01 — forked from osulyanov/config.yml
Circle CI workflows config to test and deploy Ruby on Rails application with PostgreSQL database. Test with Rspec, precompile assets then deploy with Capistrano.
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
defaults: &defaults
working_directory: ~/repo
docker:
- image: circleci/ruby:2.4.1-node-browsers
environment:
@volodymyr-nt
volodymyr-nt / action_policy__i18n.rb
Created August 22, 2018 13:34 — forked from palkan/action_policy__i18n.rb
ActionPolicy i18n basics
# See issue: https://github.com/palkan/action_policy/issues/15
module ActionPolicy
module I18n
class << self
def full_message(policy_class, rule)
# generate candidates
candidates = [:"#{policy_class.identifier}.#{rule}"]
# add global fallbacks
export default class ApiClient {
constructor(params = {}) {
this.baseURL = params.baseURl || '';
this.defaultData = params.defaultData || {};
this.defaultData.locale = params.locale || this.defaultLocale;
}
request(method, url, data = {}) {
const requestData = this.createRequestData(data, method);
return $.ajax(this.createRequestObject(method, url, requestData));
def nearest_business_day_of_week_after(day_number)
closest_monday = Date.current.monday
days_diff = day_number - closest_monday.day
jump_weeks = (days_diff.to_f / 7).ceil
closest_monday + jump_weeks.weeks
end
@volodymyr-nt
volodymyr-nt / gist:5f720c89a9af12bde52fa52db571d2ca
Created December 12, 2016 13:13 — forked from stuart11n/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
@volodymyr-nt
volodymyr-nt / tmux-cheatsheet.markdown
Created November 12, 2016 16:58 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
export function method(type) {
return function (target, key, descriptor) {
const originalMethod = descriptor.value;
descriptor.value = function (...args) {
return originalMethod.call(this, ...args)
};
return descriptor;
}
}
# base implementation of service object pattern
class Service
def self.call(*params)
new(*params).call
end
class ServiceResponse
def error?
!success?
end
@volodymyr-nt
volodymyr-nt / gist:fe9fc4599039c3ca3151f18e1fa7f05b
Created September 24, 2016 21:24 — forked from rgo/gist:2025990
Gnome-shell dual monitor separate workspaces
# By default the behavior is:
# Primary monitor work as always and second monitor only have one and fixed workspace
# I.e. you change to next workspace, primary monitor change to this workspace and second monitor remain as is.
# The desired behaviour is:
# Primary monitor and secondary monitor are linked workspace.
# I.e. you change to next workspace, primary monitor change to this workspace and second monitor too.
$ gconf-editor
# Look for /desktop/gnome/shell/windows/workspaces_only_on_primary and set to false
class CollectionPresenter
include Enumerable
def self.present(presenter_class)
instance_variable_set(:@presenter_class, presenter_class)
end
def initialize(collection)
presenter_class = extract_presenter_class
@collection = collection.map do |object|