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
@AhmedNadar
AhmedNadar / tinyurl.rb
Created May 18, 2012 22:18 — forked from woods/tinyurl.rb
Ruby: A complete URL-shortening web application in Sinatra.
#!/usr/bin/env ruby
#
# A complete URL-shortening web application, written in Ruby/Sinatra. Run it
# from the command line, and then visit http://localhost:4567/
#
# Or to run it under apache/passenger, you'll need a config.ru file with the
# following contents:
#
# require 'tinyurl'
# run Sinatra::Application
@AhmedNadar
AhmedNadar / gist:6409369
Last active December 22, 2015 03:18 — forked from padolsey/gist:527683
JavaScript: Detect IS
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@AhmedNadar
AhmedNadar / photo_essay.rb
Created September 2, 2013 05:53 — forked from levity/photo_essay.rb
Ruby: photo assay
#!/usr/bin/ruby
require 'yaml'
# DATA is a little-used feature of the Ruby language; it's a file handle
# whose contents are everything in the current file after the __END__.
# YAML is "Yet Another Markup Language".
data = YAML.load(DATA)
def url_for(entry_num)
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'
# 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"
## 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
# 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
# Helpers
def git_update(message)
git :add => ".", :commit => "-m '#{message}'"
end
def git_remove(file)
git :rm => file
end
# 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