Skip to content

Instantly share code, notes, and snippets.

View fahadgudu's full-sized avatar
😀

Fahad fahadgudu

😀
  • Bitstorm
  • Lahore
View GitHub Profile
@fahadgudu
fahadgudu / spec_helper.rb
Created April 25, 2019 10:16 — forked from PareshGupta/spec_helper.rb
RSpec matcher for ensuring a model is accepting nested attributes for an association, and accepting/rejecting the right values.
# Use: it { should accept_nested_attributes_for(:association_name).and_accept({valid_values => true}).but_reject({ :reject_if_nil => nil })}
RSpec::Matchers.define :accept_nested_attributes_for do |association|
match do |model|
@model = model
@nested_att_present = model.respond_to?("#{association}_attributes=".to_sym)
if @nested_att_present && @reject
model.send("#{association}_attributes=".to_sym,[@reject])
@reject_success = model.send("#{association}").empty?
end
model.send("#{association}").clear
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
alias ..="cd .."
@fahadgudu
fahadgudu / active_admin.rb
Created March 22, 2017 04:25 — forked from tinynumbers/active_admin.rb
ActiveAdmin controller extension to persist resource index filters between requests.
# this stuff goes in config/initializers/active_admin.rb
ActiveAdmin.setup do |config|
# ...
# put these lines in the "Controller Filters" section of the ActiveAdmin.setup block
# These two are defined in ActiveAdmin::FilterSaver::Controller, which is loaded below.
config.before_filter :restore_search_filters
@fahadgudu
fahadgudu / active_admin.rb
Created July 28, 2016 09:00 — forked from fred/active_admin.rb
extend active admin to prettier boolean values
# It extends activeadmin to show pretty boolean values
#
# config/initializers/active_admin.rb
module ActiveAdmin
module Views
class TableFor
def bool_column(attribute)
column(attribute){ |model| model[attribute] ? '✔'.html_safe : '✗'.html_safe }
end
@fahadgudu
fahadgudu / Galaxy Of Tutorial Torrents
Created April 26, 2016 07:55 — forked from iHassan/Galaxy Of Tutorial Torrents
Ultimate Galaxy Of Tutorial Torrents
=============================
**http://kickass.to/infiniteskills-learning-jquery-mobile-working-files-t7967156.html
**http://kickass.to/lynda-bootstrap-3-advanced-web-development-2013-eng-t8167587.html
**http://kickass.to/lynda-css-advanced-typographic-techniques-t7928210.html
**http://kickass.to/lynda-html5-projects-interactive-charts-2013-eng-t8167670.html
**http://kickass.to/vtc-html5-css3-responsive-web-design-course-t7922533.html
*http://kickass.to/10gen-m101js-mongodb-for-node-js-developers-2013-eng-t8165205.html
*http://kickass.to/cbt-nuggets-amazon-web-services-aws-foundations-t7839734.html
@fahadgudu
fahadgudu / gist:c3971a72d6af0d0a5153
Last active August 29, 2015 14:28 — forked from ryansobol/gist:5252653
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

# Login as root
ssh root@domain
# Create deploy user
adduser <username> #Adds User with username given. Enter Password when Prompted. Other Details are Optional
# Add user to sudo group
usermod -g <groupname> <username>
# Add .ssh/authorized_keys for deploy user
@fahadgudu
fahadgudu / Important shell commands
Created December 19, 2014 05:34
some important Work related Commands to know
1- ssh -i ~/Desktop/eventappkey.pem ubuntu@107.22.254.2
2- backup: # mysqldump -u root propelius_production > dumpfilename.sql -p
3- scp -i ~/Desktop/eventappkey.pem ubuntu@107.22.254.2:/home/ubuntu/dumpfilename.sql /home/bilal/Desktop/
4- chmod 600 ~/Desktop/eventapp-test.pem
5- scp -i ~/Desktop/eventapp-test.pem /home/bilal/Desktop/dumpfilename.sql ubuntu@ec2-54-226-196-5.compute-1.amazonaws.com:/home/ubuntu/
@fahadgudu
fahadgudu / gist:87e768491c7a8edd2bf3
Created November 25, 2014 06:29
Rails server deployment issues
Postgresql: password authentication failed for user “postgres”
$ sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
Done! You saved User = postgres and password = postgres.
If you do not have a password for the User postgres ubuntu do:
$ sudo passwd postgres
Memory issues ans swap areas
@fahadgudu
fahadgudu / action_import
Last active August 29, 2015 14:08 — forked from maxivak/00.md
controller do
..
def import
@product = Product.find(params[:id])
# access uploaded file - params[:file]
# do the job