Skip to content

Instantly share code, notes, and snippets.

View karimmtarek's full-sized avatar

Karim Tarek karimmtarek

View GitHub Profile
<% pages = sitemap.resources.find_all{|p| p.source_file.match(/\.html/) } %>
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<% pages.each do |p| %>
<url>
<loc>http://youdomain.com/<%=p.destination_path.gsub('/index.html','')%></loc>
<priority>0.7</priority>
</url>
<% end %>
</urlset>
To replace $130 with 130&thinesp;$
Search: \$(\d+)
Replace: \1&thinsp;$
To strip classes/id/style
Search: \s+class="[^"]*"
Replace:
@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

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 / 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
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"}})
### 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
@karimmtarek
karimmtarek / gist:b66461bf1588e29bc2ce
Last active August 7, 2017 13:40
Montreal Ruby Shops