Skip to content

Instantly share code, notes, and snippets.

View dineshsprabu's full-sized avatar

Dineshprabu S dineshsprabu

  • Bangalore, India.
View GitHub Profile
@dineshsprabu
dineshsprabu / perform_action_when_element_available.js
Created July 28, 2016 06:36 — forked from dineshprabu-freshdesk/perform_action_when_element_available.js
[JQUERY] Perform an action only when element is Available
jQuery('element').livequery(function(){
//element available now.
});
@dineshsprabu
dineshsprabu / render_partial_multiple_label_select.rb
Created August 15, 2016 06:56
[RAILS][VIEW] Rendering partials with labels and selections
# partial '_list_form.html.erb'
<%= form_tag('/controller/action', method: :post) do %>
<% left.each do |left_label| %>
<%= label_tag "field[#{left_label}]", left_label %>
<%= select("field", left_label, right, { include_blank: true }) %>
<% end %>
<%= submit_tag "Submit" %>
<% end %>
@dineshsprabu
dineshsprabu / restclient_request_execute_with_basic_auth.rb
Created August 16, 2016 02:50
[RUBY] RestClient Request Execute with Basic Authentication
require 'rest-client'
require 'base64'
RestClient::Request.execute(url: 'ENDPOINT', method: :get, headers:{Authorization: "Basic #{Base64.encode64('USERNAME:PASSWORD')}"})
@dineshsprabu
dineshsprabu / escape_single_double_quote_comma.rb
Created August 17, 2016 11:13
[RUBY] Escaping single quote, double quotes and comma properly
def escape_string str
str.gsub!(/\"/,'\\u0022') if str.include? '"'
str.gsub!(/\'/,'\\u0027') if str.include? "'"
str.gsub!(/\,/,'\\u002C') if str.include? ","
str
end
@dineshsprabu
dineshsprabu / xml_to_hash.rb
Created August 30, 2016 06:32
[RUBY] XML to HASH conversion in ruby
require 'active_support/core_ext/hash/conversions'
Hash.from_xml XML_STRING
@dineshsprabu
dineshsprabu / selenium_phantom_dynamic_webpage_crawling.js
Last active September 12, 2016 10:00
[SELENIUM] How to run Selenium Server and Crawl Dynamic WebPages?
/*
1. Download latest version of Selenium Standalone Server from http://selenium-release.storage.googleapis.com/index.html
2. Run java -jar selenium-server-standalone-2.53.1.jar -port 8910
3. Replace the file name with your JAR file name.
4. Download phantomjs from http://phantomjs.org/download.html and set the path to access it from anywhere in the machine.
Note: Refer https://www.npmjs.com/package/selenium-webdriver for nodejs.
*/
var webdriver = require('selenium-webdriver'); //npm install selenium-webdriver
var proxy = '127.0.0.1';
@dineshsprabu
dineshsprabu / installing_enabling_mongodb_wiredtiger_ubuntu.txt
Created September 24, 2016 13:07
[MONGODB] Installing mongodb and enabling wiredtiger as storage engine on ubuntu server.
Follow Link for installation: https://docs.mongodb.com/v3.0/tutorial/install-mongodb-on-ubuntu/
After installation
1. sudo service mongod stop
2. sudo vi ~/etc/mongod.conf
3. update #engine: to engine: wiredTiger
4. sudo rm -rf /var/lib/mongodb/*
5. sudo rm -rf /var/log/mongodb/*
6. sudo service mongod start
7. check using db.serverStatus().storageEngine on mongo.
@dineshsprabu
dineshsprabu / phantomjs_horseman_dynamic_page_crawling.js
Created September 27, 2016 03:28
[NodeJS] Dynamic Page Crawling with PhantomJS and Horseman
var Horseman = require('node-horseman');
var horseman = new Horseman();
horseman
.open('http://httpbin.org/ip')
.setProxy('http://api-key:@proxy.crawlera.com:8010') //change the proxy before use.
.html('body')
.then(function(body) {
console.log(body);
});
@dineshsprabu
dineshsprabu / phantomjs_horseman_dynamic_page_crawling_with_crawlera.js
Created September 27, 2016 03:36
[NodeJS] PhantomJS Horseman with Crawlera Proxies.
var Horseman = require('node-horseman');
var horseman = new Horseman();
var apiKey = '' //upated the api key.
horseman
.authentication(apiKey, '')
.open('http://proxy.crawlera.com:8010/fetch?url=https://httpbin.org/ip')
.html('body')
.then(function(body) {
@dineshsprabu
dineshsprabu / openresty_installation_usage.txt
Last active November 26, 2016 06:37
[RUBY] OpenResty Installation on Mac and Usage
brew tap killercup/homebrew-openresty
brew install openresty
brew services start homebrew/nginx/openresty
brew services stop homebrew/nginx/openresty
Installation Errors:
******** OpenSSL error(default) ************
Last 15 lines from /Users/user/Library/Logs/Homebrew/ngx_openresty/01.configure: