Skip to content

Instantly share code, notes, and snippets.

View AhmedNadar's full-sized avatar
🌎
Ready to work remote with you 😀 💻 🤝 👏🏼

Ahmed Nadar AhmedNadar

🌎
Ready to work remote with you 😀 💻 🤝 👏🏼
View GitHub Profile
# Update, upgrade and install development tools:
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install build-essential git-core libssl-dev libsqlite3-dev curl nodejs nginx
# Install rbenv
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
# Add rbenv to the path:
echo 'export RBENV_ROOT=~/.rbenv' >> ~/.bash_profile
{
"after_callback": "",
"auto_complete_commit_on_tab": true,
"before_callback": "",
"bold_folder_labels": true,
"check_for_bundler": true,
"check_for_rbenv": true,
"check_for_rvm": true,
"check_for_spring": true,
"color_scheme": "Packages/User/Flatland Monokai (SL).tmTheme",
# Helpers
def git_update(message)
git :add => ".", :commit => "-m '#{message}'"
end
def git_remove(file)
git :rm => file
end
# add gems
gem 'whenever'
gem 'kaminari'
gem 'hpricot'
gem 'ruby_parser'
gem 'jquery-rails'
gem "jquery-ui-rails"
gem 'bcrypt-ruby', '~> 3.0.0'
gem "rspec-rails", :group => [ :development, :test ]
gem "ffaker", :group => :test
## Rails App Template
## Updated for Rails 3.2.8
## Updated on 9/24/12
## Run using $ rails new [appname] -JT -m https://raw.github.com/gist/960988/template.rb
## Gems
# General
gem 'rake', '0.9.2.2'
# Warden and Devise for security
# coding: utf-8
# This is a Rails init template
# Usage
#
# $ rails new app_name -d postgresql -m https://raw.github.com/gist/3303948 --skip-bundle
#
# remove files
run "rm README.rdoc"
run "touch README.md"
git :init
git add: "."
git commit: %Q{ -m 'Initial commit' }
# Twitter bootstrap baby
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
# Incase you want less
gem 'less-rails'
# jQuery is the win
gem 'jquery-rails'
@AhmedNadar
AhmedNadar / application.html.erb
Created November 22, 2013 21:33
Using rails flash messages with Twitter Bootstrap. 1- Add <%= flash_messages %> to "application.html.erb" 2- Add 'flash_messages' method to "application_helper.rb"
<body>
<div class="container">
<%= render "layouts/header" %>
<%= flash_messages %>
<%= yield %>
<%= render "layouts/footer" %>
</div
</body>
@AhmedNadar
AhmedNadar / gist:7256203
Created October 31, 2013 20:08
Define a method sum_to_n? which takes an array of integers and an additional integer, n, as arguments and returns true if any two elements in the array of integers sum to n. An empty array should sum to zero by definition.
def sum_to_n?(arr, n)
(arr.empty? && n.zero?) || arr.permutation(2).any? { |a, b| a + b == n }
end
# OR
def sum_to_n?(arr, n)
return true if arr.empty? && n.zero?
arr.combination(2).any? {|a, b| a + b == n }
end