Skip to content

Instantly share code, notes, and snippets.

View tabishiqbal's full-sized avatar

Tabish Iqbal tabishiqbal

  • Toronto, Ontario
View GitHub Profile
@tabishiqbal
tabishiqbal / deploy.rb
Last active September 6, 2015 01:22 — forked from fousa/deploy.rb
Deploy with mina on DigitalOcean server.
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'
require 'mina_sidekiq/tasks'
set :rails_env, 'production'
set :domain, 'YOUR_IP_OR_DOMAIN'
set :deploy_to, "/home/rails/#{rails_env}"
set :repository, 'git@github.com:fousa/<YOUR_REPOSITORY>.git'
@tabishiqbal
tabishiqbal / digital_ocean_setup.md
Created November 23, 2015 13:56 — forked from ChuckJHardy/digital_ocean_setup.md
DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3 Setup Instructions

DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3

SSH into Root

$ ssh root@123.123.123.123

Change Root Password

@tabishiqbal
tabishiqbal / gmail.rb
Created April 30, 2016 21:43 — forked from pramodshinde/gmail.rb
Gmail API (via IMAP) using gmail_xoauth - Example
# An example demonstrating Gmail API via IMAP using gmail_xoauth gem
# Add this file to your rails project to use if you don't want to use this in rails project then require
require 'net/imap'
require 'gmail_xoauth'
class Gmail
attr_accessor :email, :access_token
def initialize(args)
email = args[:email]

Creating polymorphic associations

Create Tagging feature:

Create keywords to reference our media

Tag: name: (keyword)

Steps: 1 of 3

@tabishiqbal
tabishiqbal / csv.rb
Created May 17, 2016 16:46
Ruby CSV Importer
# lib/auction_core/lot_importer/csv.rb
# We use require_dependency in our app and have this file namespaced under lib.
# This file is the entry point for using the importer.
require 'parser'
module AuctionCore
module LotImporter
module Csv
def self.import(file_to_import = nil, _klass = Lot)
parser = Parser.new(file_to_import)
@tabishiqbal
tabishiqbal / index.htm.erb
Created September 2, 2016 14:17
pg_search example
<div class="wrapper">
<div class="row">
<div class="col-md-12">
<div class="box">
<% unless @products.blank? %>
<%= render 'search/products' %>
<% end %>
<% unless @vendors.blank? %>
@tabishiqbal
tabishiqbal / base.js
Last active September 7, 2016 15:43
Bootstrap Tooltips Rails 4.2.5
var ready = function () {
$('[data-toggle="tooltip"]').tooltip({
placement: 'right',
})
}
$(document).ready(ready);
$(document).on('page:load', ready);
@tabishiqbal
tabishiqbal / line_item.rb
Last active September 8, 2016 01:38
quote
class LineItem < ActiveRecord::Base
belongs_to :quote
belongs_to :product
end
class ProductsController < ApplicationController
after_action :verify_authorized, except: :import
def index
if params[:search]
# @products = Product.where("(model) LIKE (?)", "%#{params[:search]}")
elsif params[:tag]
@products = Product.tagged_with(params[:tag])
elsif params[:id]
@tabishiqbal
tabishiqbal / products.html.erb
Created September 17, 2016 23:55
Products Import
-- views/settings/_products.html.erb
<div class="ibox-title">
<h5>Import Products</h5>
<a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
<a class=""><%= link_to "", products_path, class: "fa fa-times" %></a>
</div>
<div class="box-content">
<p>A CSV file can be used to import products. The first row should be the column name. The following columns are allowed.</p>