Skip to content

Instantly share code, notes, and snippets.

View barek2k2's full-sized avatar

Abdul Barek barek2k2

  • Right Codes Solution
  • Dhaka, Bangladesh
View GitHub Profile
{
"id": 3,
"login": "[email protected]",
"email": "[email protected]",
"created_at": "2015-04-17T13:48:56-05:00",
"updated_at": "2015-04-17T13:48:56-05:00",
"first_name": null,
"last_name": null,
"title": null,
"company": {
---
registryData:
header: |
Whois Server Version 2.0
Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.
updatedDateNormalized: 2015-03-31 00:00:00 UTC
referralURL: http://www.OnlineNIC.com
<p>Dear <%= @carer.user.first_name.titleize %>,</p>
<p><%= @job.user.public_name.titleize %> has posted a new child care job on Kindy, in your area. Here are the details:</p>
<p><strong>Job location: </strong><%= @job.user.location.suburb %></p>
<p>
<strong>Time: </strong>
<% job_date = @job.once_off_date || @job.ongoing_start_date %>
<%= job_date.strftime("%B %d, %Y @ %I:%H") %>
</p>
@barek2k2
barek2k2 / gist:c4d9326dbf37850f322d
Created June 29, 2014 16:18
questions controller
class QuestionsController < ApplicationController
def show
@question = Question.find(params[:id])
end
def next
question = Question.find(params[:question_id])
next_question = question.next_question_for(params[:answer])
redirect_to question_url(next_question)
end
class Question < ActiveRecord::Base
scope :start_questions, -> { where(start: true) }
def end_question?
self.next_question_id_for_yes.nil? && self.next_question_id_for_no.nil?
end
def start_question?
self.start?
@barek2k2
barek2k2 / gist:ce41f942f17f1cdfa6a9
Created June 29, 2014 15:57
question table's schema
ActiveRecord::Schema.define(version: 20140628141443) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "questions", force: true do |t|
t.string "title"
t.text "description"
t.integer "next_question_id_for_yes"
t.integer "next_question_id_for_no"
@barek2k2
barek2k2 / gist:09f296581eb0fc727cfe
Created June 9, 2014 19:40
Rails Model Controller Example
class Course < ActiveRecord::Base
def self.search(params)
courses = []
if params[:subject_id].present?
subject = Subject.find(params[:subject_id])
courses = subject.courses
elsif params[:near].present?
courses = Course.around_me
elsif params[:most_popular].present?
courses = Course.most_popular
@barek2k2
barek2k2 / gist:5ac1ee993f8de1b3075b
Last active January 1, 2017 08:36
My Favorite ruby gems for rails
devise, sidekiq, resque, globalize3,jbuilder, state_machine, thinking-sphinx,active_admin, redis,
friendly_id,roo,cancan,ransack, meta_search, activerecord-sqlserver-adapter, ar-octopus,
acts_as_follower,atcs_as_taggable,geocoder,simple_form,rable, better_errors,spreadsheet,
puma, letter_opener, elastic_search_engine, algoliasearch-rails
whenever, rufus_scheduler, new_relic, capistrano, unicorn, exception_notification
will_paginate, kaminari
paperclip,carrierwave, attachment_fu, aws-s3,aws-ses, asset_sync
def confirm
@request_order = RequestOrder.find(params[:id])
if current_user
begin
invoice = @quickbooks_client.create_invoice(@request_order.total_amount, @request_order.package.name)
@request_order.update_attributes({
step: 'dashboard',
redirect_after_login_url: dashboard_request_order_url(@request_order),
invoice_id: invoice.id
})
@barek2k2
barek2k2 / gist:9978097
Created April 4, 2014 16:21
quick book exception trace
["/home/barek/.rvm/gems/ruby-2.0.0-p247/gems/quickbooks-ruby-0.1.1/lib/quickbooks/service/base_service.rb:255:in `parse_and_raise_exception'", "/home/barek/.rvm/gems/ruby-2.0.0-p247/gems/quickbooks-ruby-0.1.1/lib/quickbooks/service/base_service.rb:240:in `check_response'", "/home/barek/.rvm/gems/ruby-2.0.0-p247/gems/quickbooks-ruby-0.1.1/lib/quickbooks/service/base_service.rb:211:in `do_http'", "/home/barek/.rvm/gems/ruby-2.0.0-p247/gems/quickbooks-ruby-0.1.1/lib/quickbooks/service/base_service.rb:180:in `do_http_get'", "/home/barek/.rvm/gems/ruby-2.0.0-p247/gems/quickbooks-ruby-0.1.1/lib/quickbooks/service/base_service.rb:79:in `fetch_collection'", "/home/barek/.rvm/gems/ruby-2.0.0-p247/gems/quickbooks-ruby-0.1.1/lib/quickbooks/service/service_crud.rb:6:in `query'", "/home/barek/projects/easygiant/lib/quickbooks_client.rb:128:in `find_entry_by_email'", "/home/barek/projects/easygiant/lib/quickbooks_client.rb:138:in `find_or_create_customer'", "/home/barek/projects/easygiant/lib/quickbooks_client.rb:25:in `cr