This file contains hidden or 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 hidden or 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 'mysql' | |
class MigrationDB | |
def initialize domain, user_name, password, db_name | |
begin | |
@db_connection = Mysql.new(domain, user_name, password) | |
@db_name = db_name | |
rescue Exception => e | |
p "Error connecting to DB Server.." |
This file contains hidden or 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 'ruby-cheerio' | |
require 'mysql' | |
class MigrationDB | |
def initialize domain, user_name, password, db_name | |
begin | |
@db_connection = Mysql.new(domain, user_name, password) | |
@db_name = db_name | |
rescue Exception => e |
This file contains hidden or 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
<script> | |
var api_key = "API-KEY"; | |
function update_custom_field(ticket_field_id, callback){ | |
var payload = '{"custom_fields":{"account": "{{ticket.company.account}}"}}'; | |
var url = 'https://'+window.location.hostname+window.location.pathname.replace('/helpdesk','/api/v2') | |
jQuery.ajax({ | |
type: 'PUT', | |
url: url, | |
data : payload, |
This file contains hidden or 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 'csv' | |
#writes hash to csv file | |
def write_to_csv title, hashv | |
CSV.open("#{title}.csv", "w", :write_headers=> true, :headers => hashv.first.keys) do |csv| | |
hashv.each do |h| | |
csv << h.values | |
end | |
end | |
end |
This file contains hidden or 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/all' | |
def json_to_xml root_key, file_name | |
file_name = "#{file_name}.json" unless file_name.ends_with? ".json" | |
xml_doc = '<?xml version="1.0" encoding="UTF-8"?>'+"<#{root_key}s>" | |
(File.readlines file_name).each do |line| | |
hash_to_xml = (JSON.parse(line).to_xml) | |
xml_doc = xml_doc + (((hash_to_xml.gsub "<hash>", "<#{root_key}>").gsub "</hash>", "</#{root_key}>").gsub('<?xml version="1.0" encoding="UTF-8"?>', '')) | |
end | |
xml_doc = xml_doc+"</#{root_key}s>" |
This file contains hidden or 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 'ruby-cheerio' | |
require 'mysql' | |
class MigrationDB | |
def initialize domain, user_name, password, db_name | |
begin | |
@db_connection = Mysql.new(domain, user_name, password) | |
@db_name = db_name | |
rescue Exception => e |
This file contains hidden or 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 'nokogiri' # gem install nokogiri | |
require 'ruby-cheerio' # gem install ruby-cheerio | |
#Specify the file name to be chunked here | |
xml_file = "tickets.xml"; | |
#No of chunks to be made | |
no_of_chunks = 4 | |
doc = Nokogiri::XML(File.open(xml_file)); |
This file contains hidden or 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 'mysql' # gem install mysql | |
require 'csv' | |
db_name = "" # Database Name | |
db_connection = Mysql.new("localhost","root","","#{db_name}") # Change the creds, if needed. | |
csv_files = Dir["*.csv"] # Script goes to the current directory of the csv files. | |
csv_files.each do |csv_file| | |
headers = (CSV.read csv_file)[0] | |
db_connection.query "CREATE TABLE IF NOT EXISTS #{csv_file.split('.')[0]}("+headers.map{|c| "`#{c}` TEXT"}.join(',')+")" | |
p "table created for #{csv_file} " |
OlderNewer