Skip to content

Instantly share code, notes, and snippets.

View fayimora's full-sized avatar
🕺

Fayi FB fayimora

🕺
  • London, England
View GitHub Profile

application_helper:

 def img_name_help(name)
        name.gsub " ", "%20"
    end

view:

<%= image_tag img_name_help "rails copy.png" %>
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
void printPrimes(int*start, int*finish)
{
int length = *finish+1;
int upperBoundSqrt = (int) sqrt((double)*finish); // compute limit to marking off primes
bool primes[length];
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
void printPrimes(int start, int finish)
{
int length = finish+1;
int upperBoundSqrt = (int) sqrt((double)finish); // compute limit to marking off primes
bool primes[length];
@fayimora
fayimora / role.rb
Created February 12, 2012 18:19 — forked from mongrelion/role.rb
Dynamic Role methods for Role and User models
class Role < ActiveRecord::Base
ROLES = [ :group_admin, :agency_admin ]
# - Relationships -
has_many :user_roles
has_many :users, :through => :user_roles
# - Class Methods -
class << self
@fayimora
fayimora / ApplicationHelper.rb
Created February 15, 2012 14:28
Navigation builder
module ApplicationHelper
def build_navigation(ls=nil)
ls ||= links
res = ""
ls.each do |link|
if controller.controller_name == link[:url][:controller] && controller.action_name == link[:url][:action]
link[:html_options].merge!({ :class => "#{link[:html_options][:class]} current" } )
end
res << "<li class=\"#{link[:html_options][:class]}\">"
class Post < ActiveRecord::Base
has_many :tags, as: :taggable, through: :tag_joins
end
class Projects < ActiveRecord::Base
has_many :tags, as: :taggable, through: :tag_joins
end
class Tag < ActiveRecord::Base
has_many :taggables, through: :tag_joins
class TagJoin < ActiveRecord::Migration
def change
create_table :taggables do |t|
t.string :name
t.integer :taggable_id
t.string :taggable_type
t.timestamps
end
end
end
@fayimora
fayimora / post.rb
Created February 20, 2012 20:46 — forked from davidcelis/post.rb
Polymorphism 101
class Post < ActiveRecord::Base
has_many :tag_links, :as => :tags
# ...
end
@fayimora
fayimora / post.rb
Created February 23, 2012 01:04 — forked from davidcelis/post.rb
Polymorphism 101
class Post < ActiveRecord::Base
has_many :tag_links
has_many :tags, :through => :tag_links
# ...
end
require "bundler/capistrano"
set :application, "myapp"
#github stuff
set :repository, "git@github.com:fayimora/myapp.git"
set :scm, :git
set :scm_username, "xxx"
set :scm_passphrase, "xxx"