Skip to content

Instantly share code, notes, and snippets.

View wegorich's full-sized avatar
💩
Crappy codding

Egor Malkevich wegorich

💩
Crappy codding
View GitHub Profile
@wegorich
wegorich / Gemfile
Last active January 3, 2016 06:39
added assets to progect with
# file uploads
gem 'paperclip', '~> 3.0'
gem 'rack-raw-upload'
@wegorich
wegorich / digitalocean.md
Last active January 3, 2016 04:09 — forked from JamesDullaghan/digitalocean.md
Deploy rails + unicorn + capistrano + nginx

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

@wegorich
wegorich / _edit_map.haml
Last active December 24, 2015 23:38
JS google map geocoding and coordinate picker
.edit-map
.attach-group
.input
%label Местонахождения
= p.text_field :location, input_html: { value: geopoint.address } , placeholder: 'Китай', class: 'map_text_field'
%i.submit_address.hide.ico-enter{title: 'Отобразить на карте'}
.input.checkbox
= p.check_box :show_location
= p.label :show_location, 'показывать в профиле'
@wegorich
wegorich / application.rb
Last active December 24, 2015 21:49
Adding simple geocodding support
# config
module AppName
class Application < Rails::Application
config.autoload_paths += %W(#{Rails.root}/app/controllers/concerns #{Rails.root}/app/models/concerns)
@wegorich
wegorich / 0_reuse_code.js
Created September 29, 2013 11:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@wegorich
wegorich / CreateUserAuthorizations
Last active December 23, 2015 02:59
multioauth authorization
class CreateUserAuthorizations < ActiveRecord::Migration
def change
create_table :user_authorizations do |t|
t.string :provider
t.string :uid
t.string :token
t.string :secret
t.hstore :data
t.belongs_to :user
t.boolean :primary, default: false
@wegorich
wegorich / gist:6550669
Created September 13, 2013 13:23
Create hash from active record by field
x.select('moderator, COUNT(*) count').group('moderator').inject({}){|h, o| h[o.moderator=="t"] = o; h }
@wegorich
wegorich / _form.haml
Created August 31, 2013 19:09
load avatar from file, url, camera in rails
.avatar-picker
.header
%span.descr
Загрузить фото
%span.radio
= radio_button_tag :option, :file, checked: true
= label_tag :option_file, 'Как файл'
%span.radio
= radio_button_tag :option, :link
= label_tag :option_link, 'Как ссылку'
@wegorich
wegorich / plural names
Created August 24, 2013 10:33
helpers._plural(n, ['элемент', 'элемента', 'элементов']) - склонения в русском языке
helpers._plural = (n, forms)->
forms[if n%10==1 && n%100!=11 then 0 else if n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) then 1 else 2]
@wegorich
wegorich / Show dialogs with fancybox
Created August 23, 2013 08:07
Simple override default dialog box with fancybox
helpers ||= {}
helpers.showMessage = (title, content)->
$.fancybox(['<div class="auth"><div class="block">',
'<h2>',title,'<a href="#" class="btn-close"><i class="icon-remove"></i></a></h2>',
'<div>',content,'</div>',
'</div></div>'].join(''),{
wrapCSS: 'modal'
closeBtn : false
})