Skip to content

Instantly share code, notes, and snippets.

View leemour's full-sized avatar

Viacheslav Ptsarev leemour

View GitHub Profile
@leemour
leemour / without_habtm_association.rb
Created June 14, 2016 10:06
Rails: HABTM - find all records with no association
Buyer.joins("left join buyers_metro_stations bms on buyers.id = bms.buyer_id").where("bms.id is null")
@leemour
leemour / gist:e2917a24193718a13d8360645e982f1a
Created June 16, 2016 17:48 — 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
@leemour
leemour / morpher.rb
Created June 21, 2016 12:59
Morpher ruby склонение по падежам
require 'savon'
class Morpher
def initialize(phrase)
client = Savon.client do |globals|
globals.wsdl 'http://morpher.ru/WebService.asmx?WSDL'
globals.soap_version 2
globals.soap_header header
end
@leemour
leemour / . Setup Ubuntu install.sh
Last active February 12, 2025 11:19
Ubuntu setup for Ruby on Rails
# Git
sudo apt-get install git
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.new checkout -b
git config --global alias.lg log --oneline -25
git config --global core.editor nano
git config --global user.name leemour
@leemour
leemour / install-comodo-ssl-cert-for-nginx.rst
Created October 26, 2016 06:23 — forked from bradmontgomery/install-comodo-ssl-cert-for-nginx.rst
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@leemour
leemour / keepassx.sh
Created February 16, 2017 09:54
Keepassx Ubuntu install script (keepass2)
# http://www.linuxrussia.com/2015/12/keepassx2-ubuntu.html
#!/bin/bash -vx
sudo apt-get install build-essential cmake checkinstall libqt4-dev libgcrypt-dev libxtst-dev
export QT_SELECT=qt4
cd /tmp/ && wget https://www.keepassx.org/releases/2.0.3/keepassx-2.0.3.tar.gz && tar xzvf keepassx-2.0.3.tar.gz
cd keepassx-2.0/ && mkdir build && cd build/
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local
sudo checkinstall --pkgname keepassx
@leemour
leemour / rails_helper.rb
Created March 31, 2017 07:22
Rails helper example
############################
## Make it simple =) ##
############################
module RemoteFormHelper
def remote_form(path, &block)
simple_form_for path, remote: true do |f|
yield f
concat f.submit 'Save', class: 'ui save green button'
concat link_to 'Cancel', '#', class: 'ui cancel button'
@leemour
leemour / routes.rb
Created April 27, 2017 09:00 — forked from kryzhovnik/routes.rb
Интеграция Яндекс.Кассы с Rails
# config/routes.rb
YandexKassaIntegration::Application.routes.draw do
# ...
scope '/yandex_kassa' do
controller 'yandex_kassa', constraints: { subdomain: 'ssl' } do
post :check
post :aviso
get :success
get :fail
@leemour
leemour / postgresql_configuration_on_ubuntu_for_rails.md
Created January 15, 2018 14:34 — forked from p1nox/postgresql_configuration_on_ubuntu_for_rails.md
PostgreSQL configuration without password on Ubuntu for Rails

Abstract

You could have postgre installed on localhost with password (or without user or password seted after instalation) but if we are developing we really don't need password, so configuring postgre server without password for all your rails project is usefull.

Install Postgre packages

  • postgresql
  • postgresql-client
  • libpq-dev
@leemour
leemour / rename_file_extensions.sh
Last active February 14, 2018 12:13
Change file extensions. Change from .css.scss to .scss
find app/assets/stylesheets -name "*.css.scss" -exec rename 's/\.css.scss$/.scss/' '{}' \;
#!/bin/sh
for file in $(find ./app/assets/stylesheets/ -name "*.css.scss")
do
git mv $file `echo $file | sed s/\.css//`
done