export EDITOR=emacs
gem install knife-solo
knife solo init chef
cd chef
touch Gemfile, add custom stuff
| def color_code | |
| colors_code = %w(1;32 0;32 0;36 1;36 1;37 0;37 1;30 0;30 0;34 1;34 0;35 1;35 0;31 1;31 0;33 1;33) | |
| colors_code.each do |color| | |
| puts "#{color} : \033[#{color}m color \033[0;30m" | |
| end | |
| nil | |
| end |
| Mailer.send_mail('subject', 'message') | |
| class Mailer < ActionMailer::Base | |
| def send_mail(subject, message) | |
| subject = subject | |
| @message = message | |
| mail(to: '[email protected]', subject: subject) | |
| end | |
| end |
| class UsersController < ApplicationController | |
| def create | |
| @user = User.new(user_params) | |
| # blablabla | |
| end | |
| private | |
| def user_params | |
| params.require(:user).permit(:user_id, :username, :name, :password) |
export EDITOR=emacs
gem install knife-solo
knife solo init chef
cd chef
touch Gemfile, add custom stuff
| require File.expand_path('../lib/tasks/hooks', __FILE__) | |
| require File.expand_path('../config/application', __FILE__) | |
| Rails.application.load_tasks |
| # http://www.comptechdoc.org/os/linux/usersguide | |
| # http://www.tecmint.com/20-advanced-commands-for-linux-experts/ | |
| man ls # format and display the on-line manual pages | |
| pwd # print working directory | |
| cd new_directory # change current directory to new_directory | |
| cd ~ # Move to the user's home directory which is "/home/username". The '~' indicates the users home directory. | |
| cd # same as cd ~ |
| Delayed::Job.find(X).invoke_job |
| task :task, [:arg1] => :environment do |_, args| | |
| arg1 = args.arg1 || 'default_value' | |
| puts arg1 | |
| end |
| class Oauth | |
| def client | |
| consumer = OAuth::Consumer.new( | |
| consumer_key, consumer_secret, site: BASE_URL) | |
| token = { | |
| oauth_token: access_token, | |
| oauth_token_secret: access_token_secret | |
| } |
| module API | |
| module V1 | |
| class ApplicationController < ActionController::Base | |
| before_filter :authenticate | |
| TOKEN = ENV['my_api_token'].freeze | |
| protected | |
| def authenticate | |
| authenticate_or_request_with_http_token do |token, _| |