Skip to content

Instantly share code, notes, and snippets.

View ka8725's full-sized avatar
🚀
Ruby on Rails expert with business development mindset | WideFix Founder

Andrei Kaleshka ka8725

🚀
Ruby on Rails expert with business development mindset | WideFix Founder
View GitHub Profile
@rahularity
rahularity / work-with-multiple-github-accounts.md
Last active July 23, 2024 10:26
How To Work With Multiple Github Accounts on your PC

How To Work With Multiple Github Accounts on a single Machine

Let suppose I have two github accounts, https://github.com/rahul-office and https://github.com/rahul-personal. Now i want to setup my mac to easily talk to both the github accounts.

NOTE: This logic can be extended to more than two accounts also. :)

The setup can be done in 5 easy steps:

Steps:

  • Step 1 : Create SSH keys for all accounts
  • Step 2 : Add SSH keys to SSH Agent
@himanshu-myupchar
himanshu-myupchar / webp.rb
Created March 28, 2019 07:49
Convert any image format to webp
class Post
has_attached_file :asset,
:storage => :s3,
:processors => [:webp],
:url => ":s3_alias_url",
:path => ":id/:filename",
:s3_region => "your-region",
styles: {
webp: {
format: 'webp'
@giannisp
giannisp / gist:ebaca117ac9e44231421f04e7796d5ca
Last active July 14, 2024 18:27
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
@Chocksy
Chocksy / .1details.md
Last active April 9, 2020 16:26
Gemfile local that will allow for special gems only on local env

Differences between team gemfile and your preferences

The solution for the above problem is to have a different gemfile that you run your rails app against. It can be easily done by adding some terminal aliases to use a different gemfile file. I made that in the current configuration and it works well.

@brianstorti
brianstorti / priority_queue.rb
Last active November 17, 2022 16:14
Priority queue implementation in Ruby
class PriorityQueue
attr_reader :elements
def initialize
@elements = [nil]
end
def <<(element)
@elements << element
bubble_up(@elements.size - 1)
@JunichiIto
JunichiIto / alias_matchers.md
Last active July 18, 2024 15:03
List of alias matchers in RSpec 3

This list is based on aliases_spec.rb.

You can see also Module: RSpec::Matchers API.

matcher aliased to description
a_truthy_value be_truthy a truthy value
a_falsey_value be_falsey a falsey value
be_falsy be_falsey be falsy
a_falsy_value be_falsey a falsy value
@rosenfeld
rosenfeld / application_controller.rb
Created July 18, 2014 11:47
Supporting automatic return from render/redirect/head in Rails
# Please don't comment in this gist since I'm not notified by any comments here:
# https://github.com/isaacs/github/issues/21
# This is the discussion to comment on: http://blog.arkency.com/2014/07/4-ways-to-early-return-from-a-rails-controller/
class ApplicationController < ActionController::Base
# ...
around_action :catch_halt
def render(*args)
@just3ws
just3ws / convert_string_hash_representation_to_ruby_hash.rb
Last active December 12, 2023 01:27
Converting a string representation of a Ruby Hash back into a Ruby Hash
require 'pp'
require 'json'
s = "{:exit_url=>\"null\", :exit_target_type=>\"left\", :furthest_scrolled=>\"locations\", :time_spent=>\"543210\", :user_id=>\"123456\", :visited_at=>789101112, :user=>nil}"
pp JSON.parse("{" + s.gsub(/^{|}$/, '').split(', ').map { |pair| pair.split('=>') }.map {|k, v| [k.gsub(/^:(\w*)/, '"\1"'), v == 'nil' ? "null" : v].join(": ") }.join(", ") + "}")
=> {"exit_url"=>"null", "exit_target_type"=>"left", "furthest_scrolled"=>"locations", "time_spent"=>"543210", "user_id"=>"123456", "visited_at"=>789101112, "user"=>nil}
@niquola
niquola / list.md
Last active May 20, 2018 04:52
Must Read from Ravil Bayramgalin (https://github.com/brainopia) + my small adds :)

Books

Concepts-Techniques-Models-Computer-Programming CMT это известная книжка CMT, за которой слава закрепилась не хуже чем у SICP

это из этой книжки классификация различных парадигм Если присмотришься, то увидишь, что Oz поддерживает большинство вариаций (с этой целью его и конструировали, чтобы можно было наглядно продемонстрировать различные подходы в одном языке)

@tzvetkoff
tzvetkoff / gist:7287456
Last active January 8, 2019 06:44
Make it more test-ish
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', :github => 'rails/rails'
gem 'sqlite3'
GEMFILE
system 'bundle'
end