Skip to content

Instantly share code, notes, and snippets.

View shoaibmalik786's full-sized avatar

Shoaib Malik shoaibmalik786

View GitHub Profile

Audit Report

Specs

  • controllers are not covered with rspecs
  • gem 'simplecov' is added in Gemfile but is not correctly implemented and it is not generating the html file to check the specs coverage.

Code audit

  • Query should not be written on views. check on app/views/component/gupdates_index/_index.html.erb
  • There is an examples controller which is of no use, we should not keep the redundant code.
  • provide_names_and_ids method is not being used anywhere in the code which is defined in concern inside model
@shoaibmalik786
shoaibmalik786 / InstallElasticSearch.sh
Last active August 29, 2015 14:15
Install Elasticsearch in ubuntu 14.04
### Install OpenJDK
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Download and Install ElasticSearch
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.3.deb
sudo dpkg -i elasticsearch-1.4.3.deb
@shoaibmalik786
shoaibmalik786 / Deploy Rails on amazon server
Last active August 29, 2015 14:10
Setup Rails On Amazon Server Ubuntu Instance with Nginx and Unicorn using putty.
MANAGE SERVER WITH PUTTY
- Once you setup your amazon server and get an amazon instance, you should have a private key private_key.pem
- Open puttygen
- Browse private_key.pem
- Generate .ppk file
- Open Putty
- Enter IP Address in session and save session with a name.
- Click SSH/Auth and browse private key generated by puttygen
- Double click on the name of saved session, you will get your server window, type password of your instance.
@shoaibmalik786
shoaibmalik786 / model.rb
Created June 19, 2014 06:17
Self refrencial associaion
Let’s begin with some basic assumptions: we have a model class called User and we want the User to know three things:
a list of users directly linked to (me someone)
a list of users directly linked from (someone me)
a list of users directly linked, no matter to or from (e.g. if A B and B C, then A and C should be on B‘s linked list)
As we can see, the relationship between two users is directed: one user initiated it and the other responded. But when looking for a path between two ‘distant’ users, we don’t care who initiated an individual relationship that could be part of the path, so we also need an undirected view on relationships.
I left out the confirmation feature, as this is easy and not particularly interesting to implement.
Database
@shoaibmalik786
shoaibmalik786 / Usage Note
Last active December 4, 2021 13:22
File upload using ajax
Usage Note:
-----------
// Just put this file in assets/javascripts and require it in application.js
// call function ajaxForm() on id of form containing file while submitting.
Do not use both ajaxSubmit and ajaxForm on the same form. These
functions are mutually exclusive. Use ajaxSubmit if you want
to bind your own submit handler to the form. For example,
@shoaibmalik786
shoaibmalik786 / gist:9484731
Created March 11, 2014 12:34
unit test model
test "set key value" do
assert ConfigSetting.all.size > 1
end
test "found the value" do
assert_not_nil ConfigSetting.get('email')
end
test "return string value" do
email = ConfigSetting.get('email')