Skip to content

Instantly share code, notes, and snippets.

Avatar

Araslanov Evgeny araslanov-e

  • Russia. Tyumen
View GitHub Profile
@egelev
egelev / connect_bluetooth_headphones.sh
Last active February 19, 2023 08:51
Connect bluetooth headphones on Ubuntu 18.04
View connect_bluetooth_headphones.sh
#!/usr/bin/env bash
function get_headphones_index() {
echo $(pacmd list-cards | grep bluez_card -B1 | grep index | awk '{print $2}')
}
function get_headphones_mac_address() {
local temp=$(pacmd list-cards | grep bluez_card -C20 | grep 'device.string' | cut -d' ' -f 3)
temp="${temp%\"}"
temp="${temp#\"}"
@DSKonstantin
DSKonstantin / Auto start puma via systemctl description
Last active October 29, 2021 10:20
Auto start puma via systemctl
View Auto start puma via systemctl description
Article: https://github.com/puma/puma/blob/master/docs/systemd.md
#1 nano /etc/systemd/system/puma.service
#2 paste from puma.service
Commands:
# After installing or making changes to puma.service
systemctl daemon-reload
# Enable so it starts on boot
systemctl enable puma.service
@haseebeqx
haseebeqx / exceed_query_limit.rb
Created October 9, 2018 17:59
n+1 issue find using rspec
View exceed_query_limit.rb
# from gitlab/spec/support/matchers/exceed_query_limit.rb
RSpec::Matchers.define :exceed_query_limit do |expected|
supports_block_expectations
match do |block|
@subject_block = block
actual_count > expected_count + threshold
end
failure_message_when_negated do |actual|
View simple_state_machine.rb
# Usage:
#
# class Mail
# include SimpleStateMachine
#
# self.initial_state = 'unread'
# self.transitions_map = {
# read: {from: 'unread', to: 'read'},
# unread: {from: 'any', to: 'unread'},
# delete: {from: 'any', to: 'deleted'},
View simple_railway.rb
module SimpleRailway
class Result
attr_accessor :success, :data
def initialize(success, data)
@success = success
@data = data
end
def success?; !!success; end
def failure?; !success?; end
@kirankarki
kirankarki / Upgrading rails 5.0 to 5.1
Created October 30, 2017 13:19
Notes on upgrading rails 5.0 to 5.1
View Upgrading rails 5.0 to 5.1
1. Change rails version in Gemfile
> gem 'rails', '~> 5.1', '>= 5.1.4'
2. Remove Gemfile.lock
> git rm Gemfile.lock
3. Run bundle install command
> bundle install --jobs=5
4. Run rails' app update to apply changes to app
@ljones140
ljones140 / rails_controller.rb
Created November 17, 2016 14:41
Rails controller view path and lookup context prefixes
View rails_controller.rb
# While having issues with to_partial_path on a view model giving inconsistent results under differing name spaces of controllers
# I use the below to see that the look up path and view paths were on an controller and modify.
# I've never put the below into production. This is merely something I found while experimenting.
# To sort my issue I used the prefixes avaialable and changed name spacing to give correct behaviour
class SomeController < ApplicationController
# Prepending (or appending) the view path allows you to add the location of view files
before_filter :prepend_view_paths
@C-Pro
C-Pro / ml_links_devfest.md
Last active November 4, 2019 11:30
Ссылочки для презентации по Machine Learning
@briankung
briankung / docker-pry-rails.md
Last active March 6, 2023 12:40
Using pry-rails with Docker
View docker-pry-rails.md

First, add pry-rails to your Gemfile:
https://github.com/rweng/pry-rails

gem 'pry-rails', group: :development

Then you'll want to rebuild your Docker container to install the gems

@davoclavo
davoclavo / up-and-running-with-edeliver-on-do.md
Last active June 6, 2022 11:55 — forked from mattweldon/up-and-running-with-edeliver-on-do.md
Getting Elixir / Phoenix running on Digital Ocean with edeliver
View up-and-running-with-edeliver-on-do.md

Build Server

  • Go to Digital Ocean
  • Create new ubuntu droplet

Setup Server