Skip to content

Instantly share code, notes, and snippets.

View karimmtarek's full-sized avatar

Karim Tarek karimmtarek

View GitHub Profile
@karimmtarek
karimmtarek / vimtutor summary
Last active August 29, 2015 14:22
vimtutor summary
Lesson 1 SUMMARY
1. The cursor is moved using either the arrow keys or the hjkl keys.
h (left) j (down) k (up) l (right)
2. To start Vim from the shell prompt type: vim FILENAME <ENTER>
3. To exit Vim type: <ESC> :q! <ENTER> to trash all changes.
OR type: <ESC> :wq <ENTER> to save the changes.
# Hauleth's Rails app template
# Sass helpers and nicer views
gem 'autoprefixer-rails'
# Faster HTML escaping
gem 'escape_utils'
# Translations
gem 'r18n-rails'
@karimmtarek
karimmtarek / rails_interview_question.md
Last active August 29, 2015 14:18
Ruby on Rails interview questions

#Ruby on Rails Interview Questions

What is CSRF and how do you prevent it?
What are strong parameters introduced in Rails 4 and what is the reasoning behind the change?
Explain how you test your Rails app. Explain the various test levels available out of the box (controllers/integration/mailers/models).
What is a Rails engine?
What are different ways you could modularize a huge Rails app?
What code would you put in app/controllers/concern?
What does “keep your controllers thin and your models fat” mean?
How would you remove logic from your views?
When would you use a class vs instance variables in RoR ?
@karimmtarek
karimmtarek / ruby_interview_questions.md
Last active August 29, 2015 14:18
Interview_Questions_Ruby

#Ruby Interview Questions

What are blocks for?

Plain old english: Ways of grouping code we want to run. The simplest explanation for a block is that it is a chunk of code between {} or do...end, that can't be stored in a variable and isn't an object. A block is just part of the syntax of a method call. It doesn’t mean anything on a standalone basis and can only appear in argument lists.

What are the difference between p and puts?

The difference is subtle, but p prints the true value of an object, rather than a string-ified version of the object. This will make more sense soon, but for the sake of simplicity, we'll use the p command throughout the exercises, as we'll want to see the true values of our code returned to the output window.

@karimmtarek
karimmtarek / gist:b66461bf1588e29bc2ce
Last active August 7, 2017 13:40
Montreal Ruby Shops
### Install OpenJDK
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Download and Install ElasticSearch
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.1.deb
sudo dpkg -i elasticsearch-1.3.1.deb
ApplicationController.allow_forgery_protection = false
app.post('/whatever_my_user_model_is/sign_in', {"whatever_my_user_model_is"=>{"email"=>"users@email.com", "password"=>"users_password"}})
@karimmtarek
karimmtarek / todowiz curl syntax
Last active August 29, 2015 14:14
todowiz curl syntax
### Get lists
curl -X GET http://todowiz:3000/v1/lists -H 'Authorization: Token token="c7fb3b4e268c1dfaa91c"'
### Update lists
curl -X PUT http://todowiz:3000/v1/lists/5 -H 'Authorization: Token token="13da9ded671555ef5aaa"' -d "list[permission]=private"
### get header information
curl -X GET http://todowiz:3000/v1/lists -I
### Create new user

Ubuntu 12.04 Ruby on Rails Development Environment

I haven't set up an install guide for the latest ubuntu release, largely because the last set of instructions worked pretty closely with the latest and greatest Ubuntu, 12.04 Precise Pangolin, however when installing today, I found that there were enough differences in the way that I configure my setup to justify an update, so here it goes. Yes, I'm late to the party, but a quick google search didn't find anything that I felt was as complete for my requirements as my previous install guides, so here I go.

As always with my install guides, I have included here is just about everything you'll need (and then some) to get started with ruby on rails development with Ubuntu 12.04 as a platform. These are my settings and preferences, and this is certainly not the only way of doing things, so keep that in mind.

Step 1: Get the repos ready and run updates.

sudo apt-get update && sudo apt-get upgrade
@karimmtarek
karimmtarek / index.md
Last active August 29, 2015 14:12 — forked from rstacruz/index.md

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one