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
"3 5".split.map(&:to_i).inject{|q,k| q+k} |
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
a=['a','b','b','h','h','a'] | |
puts a.select{|l| a.count(l)>1}.uniq | |
puts "--sec time in a row:--" | |
a.each_with_index do |item,index| | |
if item==a[index+1] | |
puts item | |
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
t = Thread.new do | |
tx=File.new("text.txt", "w+") | |
(0..2).each do |n| | |
begin | |
File.open("part#{n}.txt") do |f| | |
tx.write(f.readline) | |
end | |
rescue Errno::ENOENT | |
puts "error #{n}" | |
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
before_action :logged_in_user, only: [:edit, :update] | |
before_action :correct_user, only: [:edit, :update] | |
def logged_in_user | |
unless logged_in? | |
flash[:danger] = "Please log in" | |
redirect_to login_path | |
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
nums = [3,4,2,6,1] | |
def bubble_sort(arr) | |
sorted = false | |
until sorted | |
sorted = true | |
(arr.count - 1).times do |i| | |
if arr[i] > arr[i + 1] | |
arr[i], arr[i + 1] = arr[i + 1], arr[i] | |
sorted = false |
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
# Login as root | |
ssh root@domain | |
# Create deploy user | |
adduser <username> #Adds User with username given. Enter Password when Prompted. Other Details are Optional | |
# Add user to sudo group | |
usermod -g <groupname> <username> | |
# Add .ssh/authorized_keys for deploy user |
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
# Add devise to Gemfile | |
gem 'devise' | |
# Run bundle | |
bundle install | |
# Run devise install | |
rails generate devise:install | |
# Make sure alert code in application.html.erb |
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
require 'mina/bundler' | |
require 'mina/rails' | |
require 'mina/git' | |
# require 'mina/rbenv' # for rbenv support. (http://rbenv.org) | |
require 'mina/rvm' # for rvm support. (http://rvm.io) | |
set :domain, '148.211.114.67' | |
set :user, 'user' | |
set :webroot, '/var/www' | |
set :app_name, 'your_rails_app' |
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
<!-- before: --> | |
<a class="twitter-timeline" | |
href="https://twitter.com/twitterapi" | |
data-widget-id="YOUR-WIDGET-ID">Tweets by @twitterapi</a> | |
<!-- after: --> | |
<div class="twiiter-timeline-container" | |
data-widget-id="YOUR-WIDGET-ID" | |
data-widget-options="<%= { borderColor: '#abcdef' }.to_json %>"> | |
</div> |
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
require 'mina/bundler' | |
require 'mina/rails' | |
require 'mina/git' | |
require 'mina/rvm' | |
set :domain, 'domain.com' | |
set :deploy_to, '/var/www/app_name' | |
set :repository, 'git@github.com:username/repo_name.git' | |
set :branch, 'master' |
OlderNewer