This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'dotenv' | |
Dir.chdir '/home/deployer/apps/APP' | |
Dotenv.load | |
DB_HOST = 'user@host' | |
DB_NAME = ENV['DB_NAME'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# prepares github pull request with full clean view of the selected files | |
# to run it | |
# * delete some files after commit that is pushed, and leave them unstaged | |
# * pull-request-prepare.rb will | |
# * create branch-review-start with all marked files deleted | |
# * create branch-review-end with all marked files re-added | |
# * leave starting branch untouched | |
# * open github url for pull request |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SimpleMock | |
attr_reader :object | |
@@mock_data = {} | |
@@sequence ||= {} | |
class << self | |
def define name, &block | |
@@mock_data[name] = block | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'colorize' | |
@actions = {} | |
@branch = `git rev-parse --abbrev-ref HEAD`.to_s.chomp.sub(/\*\s/,'') | |
def cputs(data) | |
puts data.split("\n").map{ |el| " #{el}" }.join("\n") | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DecoratorClone | |
def initialize(model) | |
@model = model | |
end | |
def method_missing(m, *args) | |
raise NameError, "Decorator method '#{m}' not found" unless @model.respond_to?(m) | |
@model.send(m, *args) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// using built in jQuery and Zepto serializeArray() | |
/*** | |
$('#form').serializeHash() | |
should return : | |
{ | |
'user[name]': 'Dux' | |
} | |
***/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ok article https://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html | |
but shorter and more accurate | |
1. in server manager as linode assign private IP address | |
2. ps aux | grep postgres | |
/usr/lib/postgresql/9.6/bin/postgres -D /var/lib/postgresql/9.6/main -c config_file=/etc/postgresql/9.6/main/postgresql.conf | |
3. open postgresql.conf and set |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DefaultPolicy < Policy | |
def before(action) | |
# return true for admins | |
admin? | |
end | |
def admin? | |
@user.try(:is_admin?) || false | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. fill markers/locations array | |
# 2. pass objects and draw them | |
# @markers = Model.all.inject([]) { |list, el| list.push({ id:el.id, lat:el.latitude, lng:el.longitude, name:el.name, city:el.city, path:el.admin_path }); list } | |
# --- | |
# var markers = #{@markers.to_json}; | |
# GoogleMap.init('map2', { lat: 50.9188435, lng: 9.3206294, zoom: 6 }); | |
# GoogleMap.add_markers(markers, function(o) { | |
# return '<div><b><a href="'+o.path+'">'+o.name+'</a></b><br /><br />'+o.city+'</div>' | |
# }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Page.init '#full_page' | |
# Page.skip (el) -> ! /\/admin\//.test(el) | |
# Page.after_load -> | |
# window.initMap() | |
# $('.focus').first().focus(); | |
# clearInterval(window.total_time_interval); | |
# alert 'loaded' | |
# | |
# Page.after_load() |