- Login to https://console.cloud.google.com/
- Create a project (take note of project's ID)
- Enable billing
- Go to https://console.cloud.google.com/compute/instances
- Create a VM instance
- Name: use a semantic name (take note of instance's name)
- Region and zone: most local
- Machine type: smallest possible f1-micro
This file contains 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. SSH to server | |
2. $ sudo gem install backup | |
3. $ backup generate:model --trigger=db_backup --databases='postgresql' --storages='dropbox' | |
4. Edit the /Backup folder | |
5. Test it manually | |
$ backup perform -t db_backup | |
6. Install whenever at /Backup folder | |
$ sudo gem install whenever | |
7. $ mkdir config | |
8. $ wheneverize |
This file contains 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
# install necessary plugins | |
sudo apt-get update | |
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev nodejs | |
cd | |
git clone https://github.com/rbenv/rbenv.git ~/.rbenv | |
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc | |
echo 'eval "$(rbenv init -)"' >> ~/.bashrc | |
exec $SHEL |
This file contains 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
# text | |
<%= best_in_place @item, :name, :type => :input %> | |
# textarea | |
<%= best_in_place @item, :name, :type => :textarea %> | |
# select dropdown | |
<%= best_in_place @item, :name, :type => :select, :collection => [[1, "Table"],[2, "Chair"]] %> | |
# boolean |
This file contains 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
# delayed job method on model | |
def process_images(urls) | |
require 'open-uri' | |
item = self | |
image_urls = urls.split(", ") | |
image_urls.each do |url| | |
file = URI.parse(url).open | |
item.images.build(:cat => cat, :avatar => file) | |
end |
This file contains 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
<%= s3_uploader_form callback_url: s3_image_path, id:"s3-form" do %> | |
<%= file_field_tag :file, multiple: true, :class => "item-s3form-input", :accept => ".png,.jpg,.jpeg,.gif" %> | |
<button type="button" class="btn btn-primary add-images" data-dismiss="modal">Add Photograph of break Images</button> | |
<% end %> |
This file contains 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
# config/initializers/s3_direct_upload.rb | |
S3DirectUpload.config do |c| | |
c.access_key_id = ENV['AWS_ACCESS_KEY_ID'] | |
c.secret_access_key = ENV['AWS_SECRET_ACCESS_KEY'] | |
c.bucket = ENV['AWS_DIRECT_BUCKET'] | |
end |
This file contains 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
$('.ajax-datatable').DataTable | |
sPaginationType: "full_numbers" | |
bProcessing: true | |
bServerSide: true | |
sAjaxSource: $('.ajax-datatable').data('source') |
This file contains 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
def index_datatable | |
respond_to do |format| | |
format.json { render json: ItemsDatatable.new(view_context) } | |
end | |
end |
This file contains 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 ItemsDatatable | |
delegate :params, :h, to: :@view | |
def initialize(view) | |
@view = view | |
end | |
def as_json(options = {}) | |
{ | |
sEcho: params[:sEcho].to_i, |
NewerOlder