Skip to content

Instantly share code, notes, and snippets.

@Guri-ksolves
Guri-ksolves / inherited_resources.rb
Last active August 31, 2017 07:24
Usefull ruby patch (Inherited resources)
#Inherited Resources speeds up development by making your controllers inherit all restful actions so you just
#have to focus on what is important.
#It makes your controllers more powerful and cleaner at the same time.
#In addition to making your controllers follow a pattern,
#it helps you to write better code by following fat models and skinny controllers convention.
#There are two screencasts available besides this README:
gem 'inherited_resources'
$ gem install has_scope
$ gem install responders
@Guri-ksolves
Guri-ksolves / select.rb
Created August 30, 2017 11:54
ruby Tags for select dropdown
<%=form_for @order_item, url: list_link, remote: true, html: { id: "dropdown_item_form", class: "orderDate" } do |f| %>
<%= f.select :product_id, @products.map{|p| [p.name, p.id] }, { prompt: "select product" }, id: "search_id", class: "selectbox" %>
@Guri-ksolves
Guri-ksolves / machanize.rb
Created August 29, 2017 07:04
web_scarper
require 'rubygems'
require 'mechanize'
require 'open-uri'
require 'pry'
require 'nokogiri'
require 'active_record'
require 'httparty'
agent = Mechanize.new
@Guri-ksolves
Guri-ksolves / web_scraper.rb
Created August 28, 2017 14:23
web scrapping
require 'httparty'
require 'pry'
require 'json'
require 'nokogiri'
require 'csv'
require 'active_record'
require 'mechanize'
# model_name = "web_scraper"
# table_name = job_list
get 'admin/doctors' => 'admin/doctors_locator#index'
post 'admin/doctors/approve' => "admin/doctors_locator#approve", as: :approve_doctor
post 'admin/doctors/disapprove' => "admin/doctors_locator#disapprove", as: :disapprove_doctor
get 'admin/doctors/export' => 'admin/doctors_locator#export'
put "admin/doctors/update" => 'admin/doctors_locator#update'
get "admin/doctors/:id/edit" => 'admin/doctors_locator#edit'
resource
@Guri-ksolves
Guri-ksolves / map.js
Last active August 25, 2017 07:09
Google map api
function initialize() {
var zoom_area_coordinates = document.getElementById("coordinates").value.split(" ")
var zoom_level = 4;
if(request_type == "true" && (flash_value == "No Doctor found" || flash_value == "Please enter an address")){
zoom_level = 4;
}
else if(request_type == "true"){
zoom_level = 13;