Skip to content

Instantly share code, notes, and snippets.

View jirikolarik's full-sized avatar

Jiri Kolarik jirikolarik

View GitHub Profile
@jirikolarik
jirikolarik / page.rb
Last active December 17, 2015 23:38
Globalize3 + RailsAdmin
# app/models/page.rb
class Page < ActiveRecord::Base
validates :translations, presence: :true
translates :name, :content
accepts_nested_attributes_for :translations, allow_destroy: true
mount_uploader :image, ImageUploader
def to_param
@jirikolarik
jirikolarik / gist:6641406
Last active December 23, 2015 13:19
Install RVM + Passenger + Apache
# Install RVM
\curl -L https://get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
# Install Ruby
rvm install 2.0.0
# Install passenger
gem install passenger
@jirikolarik
jirikolarik / gist:6641740
Last active December 23, 2015 13:19
Update Passenger
# Update passenger
gem update passenger
# Show available passengers
gem list passenger
# Uninstall old passengers
gem uninstall passenger -v 4.0.18
# Install new Apache module
@jirikolarik
jirikolarik / gist:6641866
Last active December 23, 2015 13:19
Setup domain for Ruby App (Capistrano deploy)
# Open ISPConfig and setup Apache on your domain
DocumentRoot /var/www/domain.tld/web/current/public
PassengerPreStart http://domain.tld/
@jirikolarik
jirikolarik / gist:6932255
Created October 11, 2013 09:48
Errbit Devise.secret_key was not set
Last login: Fri Oct 11 11:34:49 on ttys002
jiris-imac:errbit jirikolarik$ cap deploy:setup deploy db:create_mongoid_indexes
* 2013-10-11 11:35:43 executing `deploy:setup'
* executing "mkdir -p /var/www/errbit2 /var/www/errbit2/releases /var/www/errbit2/shared /var/www/errbit2/shared/system /var/www/errbit2/shared/log /var/www/errbit2/shared/pids"
servers: ["errbit.imin.cz"]
Password:
[errbit.imin.cz] executing command
command finished in 169ms
* executing "chmod g+w /var/www/errbit2 /var/www/errbit2/releases /var/www/errbit2/shared /var/www/errbit2/shared/system /var/www/errbit2/shared/log /var/www/errbit2/shared/pids"
servers: ["errbit.imin.cz"]
@jirikolarik
jirikolarik / routes.rb
Last active December 27, 2015 00:19
Devise + OmniAuth in engine
MyEngine::Engine.routes.draw do
devise_scope :user do
providers = Regexp.union(Devise.omniauth_providers.map(&:to_s))
match 'users/auth/:provider',
constraints: { provider: providers },
to: 'omniauth_callbacks#passthru',
as: :omniauth_authorize,
via: [:get, :post]
@jirikolarik
jirikolarik / missing.rb
Created November 15, 2013 19:46
Monkey Patching
module Missing
def new_method
# Do something
end
def override_method this_should_be_false = false
super
end
end
@jirikolarik
jirikolarik / video_uploader.rb
Last active November 15, 2018 18:26
CarrierWave FFmpeg Uploader example
class VideoUploader < CarrierWave::Uploader::Base
include ::CarrierWave::Backgrounder::Delay
include CarrierWave::FFmpeg
RESOLUTIONS = [
{ version: :p1080, resolution: '1920x1080'},
{ version: :p720, resolution: '1280x720'}
]
# Choose what kind of storage to use for this uploader:
@jirikolarik
jirikolarik / gist:525accba90a40237171e
Created January 23, 2015 09:04
Postgres isn't running fix on homebrew
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
rm /usr/local/var/postgres/postmaster.pid
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
[
{
"code": "ab",
"name": "Abkhaz"
},
{
"code": "aa",
"name": "Afar"
},
{