This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| have_library: checking for t_open() in -lnsl... -------------------- no | |
| "gcc -o conftest -I/usr/local/include/ruby-1.9.1/x86_64-linux -I/usr/local/include/ruby-1.9.1/ruby/backward -I/usr/local/include/ruby-1.9.1 -I. -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/usr/local/lib -L/usr/local/lib -lruby-static -lpthread -lrt -ldl -lcrypt -lm -lc" | |
| checked program was: | |
| /* begin */ | |
| 1: #include "ruby.h" | |
| 2: | |
| 3: int main() {return 0;} | |
| /* end */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Controller | |
| class MongobrokersController < ApplicationController | |
| skip_before_filter :verify_authenticity_token | |
| #dont forget to change 56800 to 3600 | |
| def air_hour | |
| @air = Mongobroker.where(status: "up", node: "air", timestamp: (Time.now - 86400)..Time.now) | |
| render :json => @air | |
| end | |
| def ema_hour |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #This Script would ask for a person's first name, middle name, last name, and age separately, and would print, My first name is Ayodele, Adeniyi Abejide, I am 28 years old | |
| puts "what is your first name?" | |
| first_name = gets.chomp | |
| puts "what is your middle name?" | |
| middle_name = gets.chomp | |
| puts "what is your last name?" | |
| last_name = gets.chomp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Controller Method | |
| def search | |
| if params[:search_option] == "ink" | |
| @ink = Ink.where("name LIKE ?", "%#{params[:name]}%") | |
| elsif params[:search_option] == "printer" | |
| @ink = Ink.where("brand_name LIKE ? AND serie_name LIKE ? AND printer_name LIKE ?", "%#{params[:brand]}%", "%#{params[:series]}%", "%#{params[:printer]}%") | |
| end | |
| @search = @ink | |
| render :html => @search |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class InksController < ApplicationController | |
| before_filter :db_check | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #The assumption here is a one-to-one mapping between controllers and models | |
| class ApplicationController < ActionController::Base | |
| protect_from_forgery | |
| protected | |
| def db_check | |
| model = self.class.to_s.gsub("Controller", '').singularize | |
| Uploader.csv_loader(model) if eval(model).all.empty? | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Model | |
| uploader.rb | |
| #The csv I am using were created from some code manipulation hence not well formatted, I am stripping off new lines and merging fields in some cases | |
| class Uploader | |
| def self.csv_loader(model) | |
| File.open("#{Rails.root}/data/#{model}.csv", 'r').each do |row| | |
| new_row = row.split(",") | |
| case | |
| when model == 'Brand' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Ruby code: | |
| require 'csv' | |
| class Phonecsvtoarray | |
| attr_accessor :arr_path | |
| def csv_to_array | |
| arr = [] | |
| CSV.foreach(@arr_path) do |row| | |
| arr << row |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| User Model: | |
| include Mongoid::Document | |
| # Include default devise modules. Others available are: | |
| # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable | |
| devise :database_authenticatable, :registerable, | |
| :recoverable, :rememberable, :trackable, :validatable | |
| field :username | |
| field :firstname |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| View | |
| <%= form_for(:session, :url => sessions_path) do |f| %> | |
| <%= f.text_field :password %> | |
| <% end %> | |
| Controller | |
| class SessionsController < ApplicationController | |
| def new | |
| end |