Skip to content

Instantly share code, notes, and snippets.

View vparihar01's full-sized avatar

Vivek Parihar vparihar01

View GitHub Profile
@vparihar01
vparihar01 / active_admin.rb
Created November 20, 2013 13:15
When downloading a csv of a model using active admin hat had around 24k records. But the csv was limited to only 10krows of data ,as it's hardcoded in active admin https://github.com/gregbell/active_admin/blob/master/lib/active_admin/resource_controller/data_access.rb#L276 . So if we try to download the CSV which have more then 12,000 records it…
# Monkey patch to increase the number of records
# exported in csv download -default is 10k
module ActiveAdmin
class ResourceController
module DataAccess
# in active admin 0.6
def max_csv_records
30_000
end
# needed for current active admin master
@vparihar01
vparihar01 / rmagick_solution.md
Created August 23, 2013 09:11
Solution for error installing Rmagick on Mountain Lion and after installation error in rmagick gem.

Error ->

dlopen(/Users/vivek/.rvm/gems/ruby-1.9.3-p327/gems/rmagick-2.13.1/lib/RMagick2.bundle, 9): Library not loaded: /usr/local/lib/libjpeg.8.dylib Referenced from: /usr/local/opt/imagemagick/lib/libMagickCore.5.dylib Reason: Incompatible library version: libMagickCore.5.dylib requires version 13.0.0 or later, but libjpeg.8.dylib provides version 12.0.0 - /Users/vivek/.rvm/gems/ruby-1.9.3-p327/gems/rmagick-2.13.1/lib/RMagick2.bundle

Step1 : Update XCode. Get the latest one Xcode 4.6 Mountain Lion does not come with ruby headers installed before hand, so you need to do this manually from XCode. Go to Xcode Preferences/Downloads.

Install Command Line Tools

<html>
<head>
<title>Geek Hours</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- Save for Web Slices (Email - invoice notification.psd) -->
<table align="center" border="0" cellpadding="0" cellspacing="0" width="620" >
<tr>
require 'mail'
Mail.defaults do
delivery_method :smtp, { :address => "smtp.sendgrid.net",
:port => 587,
:domain => "xyz.com",
:user_name => "[email protected]",
:password => "xyz",
:authentication => 'plain',
:enable_starttls_auto => true }
end
@vparihar01
vparihar01 / setting_hostname_sendmail_in_ubuntu.md
Created June 27, 2013 11:55
For changing the mail hosts name from your local machine name to domain name.Setting the hostname in sendmail.

If you need to change the hostname that Sendmail announces itself as, just add the following to sendmail.mc:

define(`confDOMAIN_NAME', `mail.yourdomain.com')dnl

For example-: Your domain name is www.xyz.com, then

define(`confDOMAIN_NAME', `www.xyz.com')dnl
@vparihar01
vparihar01 / printingJavascriptObject.js
Created June 25, 2013 13:23
for printing down the javascript [object Object] value.This get all properties values of a Javascript Object (without knowing the keys).
for(var key in objects) {
var value = objects[key];
}
Object.values = function (obj) {
var vals = [];
for( var key in obj ) {
if ( obj.hasOwnProperty(key) ) {
vals.push(obj[key]);
}
@vparihar01
vparihar01 / nokogiri_libxml_homebrew_lion_installation.sh
Created June 25, 2013 07:01
How to fix: Nokogiri Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib provides version 10.0.0. dlopen bundle.open. Using homebrew on lion to install nokogiri and lixml
FIXME:
WARNING: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.8
or
ERROR -: Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib provides version 10.0.0
gem uninstall nokogiri libxml-ruby
brew update
brew uninstall libxml2
require 'oauth_util.rb'
require 'net/http'
o = OauthUtil.new
o.consumer_key = 'examplek9SGJUTUpocjZ5QjBJmQ9WVdrOVVFNHdSR2x1TkhFbWNHbzlNQS0tJnM9Y29uc3VtkZXJzZWNyZXQmeD0yYg--';
o.consumer_secret = 'exampled88d4109c63e778dsadcdd5c1875814977';
url = 'http://query.yahooapis.com/v1/yql?q=select%20*%20from%20social.updates.search%20where%20query%3D%22search%20terms%22&diagnostics=true';

Polymorphic Associations reversed

It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media

This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.

1. An issue popups in Github. A bug or a feature request.
2. Developer starts coding after understanding the issue. He makes sure to add issue number in the form of #XXX - XXX is issue number - to the commit message. This links issue with the commit that was made. It's important to know 'why the commit was made'.
3. A CI listens to pushes to the Github repo and runs all the specs and optionally deploys the code to one of the staging servers.
4. After developer is done with coding, s/he assigns the issue to another developer for code review.
5. Code reviewer makes sure that all the tests are passing along with presence of code and test coverage. Code reviewer can assign issue back to the developer if there is some issue with the code. Developer will start at step 1 again.
6. Code reviewer assigns issue to QA. If QA is not happy, s/he adds issues that were found as comment to the original issue or possibly create new issues depending upon severity of the problem s/he found out.
7. If QA is happy, she assigns th