Skip to content

Instantly share code, notes, and snippets.

@proteste-dcm
proteste-dcm / run2.rb
Last active February 16, 2017 12:49
given a json file, create a csv with the same data from json (json to csv)
require 'json'
require 'csv'
raise Exception, 'you must provide a json file' unless ARGV[0]
json = JSON.parse(File.open(ARGV[0]).read)
CSV.open(ARGV[0].split(".").first+".csv", "w") do |csv|
csv << json.first.collect {|k,v| k}
//product by category controller
// dentro do init
this.options = {
placeholder: "Select segments...",
dataTextField: "name",
dataValueField: "id",
valuePrimitive: true,
autoBind: false,
dataSource: {
this.checkProcessOnGoing = setInterval(function() {
if($state.current.name==='main.import_test_data') {
Snapshot.checkHasProcessOngoing(project_id).then(function (response) {
self.onGoingProcess = response.data;
if (self.onGoingProcess != undefined) {
self.progressBar = self.onGoingProcess.progress;
if (self.onGoingProcess.error) {
alerts.add('danger', 'Problem Importing', self.onGoingProcess.error);
Snapshot.deleteCheckProcessWithError(project_id);
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#date").blur(function(){
var dateReg = /^\d{2}[/]\d{2}[/]\d{4}$/;
var day = parseInt($(this).val().split('/')[0]);
var mounth = parseInt($(this).val().split('/')[1]);
<!DOCTYPE html>
<!-- TE AMOOOOOOOOOOO -->
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
function validaEmail(obj) {
var valor = obj;
console.log(valor.value)
def push_data
crawler_id= DataUpdateStat.last.id
r = params[:webservice]
scobject = SiteCategory.find_by_listing_url(r[:sc])
scsite = scobject.site
def migrate_all
WorkitCrawler.puts_action("======= Start migrate_all #{Time.now}")
data_update_stat = DataUpdateStat.last.id
DataUpdateStat.execute_procedure :WorkIT_to_OLP, data_update_stat, 'param2'
INSERT INTO [ForceIndiaCurrentRun].[dbo].[workit_product_prices]
([workit_bpl_list_id]
,[base_product_id]
,[category_id]
,[icrt_code]
,[site_id]
,[site_name]
,[url]
,[brand]
,[title]
INSERT INTO [ForceIndiaCurrentRun].[dbo].[workit_product_prices]
([workit_bpl_list_id]
,[base_product_id]
,[category_id]
,[icrt_code]
,[site_id]
,[site_name]
,[url]
,[brand]
,[title]
def save_file(file_path)
WorkitCrawler.puts_action("saving: #{File.basename(file_path)}")
file = File.open(file_path)
doc = Nokogiri::XML(file)
workit_product_prices_array = []
workit_product_price_attributes = []
workit_product_price_attributes_catalog = []
quantity_to_be_process = 0
doc.xpath('//CATALOGPRODUCT').each_with_index do |catalog_product_node,indice|