Skip to main content

Posts

Showing posts from April, 2018

MS SQL - How to read xml data with multiple namespaces

The XML: <?xml version="1.0"?>-<ns0:usp_Moodlerooms_Cache_GetResponse xmlns:ns0=" http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/BizTalk " xmlns:ns3=" http://schemas.microsoft.com/Sql/2008/05/ProceduresResultSets/BizTalk/usp_Moodlerooms_Cache_Get " xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "> -<ns0:StoredProcedureResultSet0> -<ns3:StoredProcedureResultSet0><ns3:SSO_UserId>3632303</ns3:SSO_UserId><ns3:SSO_UserName> maveales@yahoo.com </ns3:SSO_UserName><ns3:UserName> maveales@yahoo.com </ns3:UserName><ns3:FirstName>Mave</ns3:FirstName><ns3:MiddleName>Bent</ns3:MiddleName><ns3:LastName>Moras</ns3:LastName><ns3:EmailAddress> maveales@yahoo.com </ns3:EmailAddress><ns3:City>Esta City</ns3:City><ns3:Country>Philippines</ns3:Country><ns3:CompetenceName>0089 - Medical Care</ns3:CompetenceName...

Ruby : Code Snippets - How to Mass renaming files with specific extension

folder_path = "C:\\MyDocs\\Work\\Venture\\eStore\\New folder" puts "Renaming files..." puts folder_path Dir.open(folder_path).each do |p|   next if File.extname(p) != ".mp4"   filename = File.basename(p)   newname = filename.gsub 'School - Episode ', 'School - Episode 0'    newname = newname    puts "#{folder_path}/#{p} #{folder_path}/#{newname}"   File.rename( "#{folder_path}/#{p}", "#{folder_path}/#{newname}") end puts "Renaming complete."

Ruby : Code Snippets - How to Downloading 600+ files under https links

require 'nokogiri' #install gem nokigiri require 'open-uri' require 'openssl' def get_page(url) return Nokogiri::HTML(open(url, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE})) end def read_file(the_html_file) return Nokogiri::HTML(open(the_html_file))   end html_file = 'C:\Users\OSMCAN\Desktop\baliwtm.html' page = read_file(html_file)    #puts page sources = page.css('source').map { |source| source['src'] } #puts sources sources.each do |url| if url.include? "?" url = url.split('?').first end puts url the_filename = File.basename(url) puts "the_filename: #{the_filename}" the_url = "#{File.dirname(url)}/#{the_filename}"  puts "the_url: #{the_url}" open(the_filename, 'wb') do |file|   file << open(the_url, {ssl_verify_mode: 0}).read #require 'openssl' end #exit end