This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#gem install httparty | |
require 'httparty' | |
url = 'http://httpbin.org/user-agent' | |
response = HTTParty.get(url) | |
p response.parsed_response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_record' | |
ActiveRecord::Base.establish_connection ({ | |
:adapter => "mysql2", | |
:host => "localhost", | |
:username => "root", | |
:password => "", | |
:database => ""}) | |
class TableName < ActiveRecord::Base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support/core_ext/hash/conversions' | |
def xml_to_hash filename | |
doc = Nokogiri::XML.parse(File.open(filename)) | |
Hash.from_xml(doc.to_s) | |
end | |
p xml_to_hash 'file/to/path/filename.xml' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery('element').livequery(function(){ | |
//element available now. | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def escape_string str | |
str.gsub!(/\"/,'\\u0022') if str.include? '"' | |
str.gsub!(/\'/,'\\u0027') if str.include? "'" | |
str.gsub!(/\,/,'\\u002C') if str.include? "," | |
str | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* npm install dns */ | |
var dns = require('dns'); | |
/* domain name to lookup */ | |
domain_name = 'example.com'; | |
dns.lookup(domain_name, function(err, addresses, family){ | |
/* handle if look up fails inside if condition */ | |
if(err){return console.log(err.stack);} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support/core_ext/hash/conversions' | |
Hash.from_xml XML_STRING |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |