Get XML Data won’t parse XML object – Pentaho

I had an issue with Pentaho today. It wasn’t able to simply parse this XML that I was fetching from Amazon Marketplace Webservice.

Here’s the data I got :

<SubmitFeedResponse xmlns="http://mws.amazonaws.com/doc/2009-01-01/">
<SubmitFeedResult>
<FeedSubmissionInfo>
<FeedSubmissionId>MY_FEED_ID</FeedSubmissionId>
<FeedType>_POST_INVENTORY_AVAILABILITY_DATA_</FeedType>
<SubmittedDate>2016-08-01T19:28:30+00:00</SubmittedDate>
<FeedProcessingStatus>_SUBMITTED_</FeedProcessingStatus>
</FeedSubmissionInfo>
</SubmitFeedResult>
<ResponseMetadata>
<RequestId>MY_REQUEST_ID</RequestId>
</ResponseMetadata>
</SubmitFeedResponse>

The step “Get XML Data” couldn’t parse it because of the xmlns attribute tag. So I had to add a step “Replace in string” that would delete this attribute.

Screenshot from 2016-08-01 17:18:56


Write a new task using Capistrano

Capistrano can be a great tool to run a task on several servers. It can be a task like uploading a maintenance page or deleting some logs :

task :NAME_OF_YOUR_TASK do
desc <<-DESC
This is my awesome task. Description appears in help so write it carefully.
DESC
run "rm -rf #{logs_folder}"
run "mkdir #{destination_folder}"
top.upload("index.html", "#{destination_folder}/index.html")
end

You can read more about writing Capistrano tasks here.

 




Create a copy of a Vagrant machine

1. Stop your vagrant machine

vagrant halt

2. Create the copy (it can take sometime)

vagrant package --base <name_of_your_machine>  --output path/to/newly/created/package

The machine name is on Virtual Box 🙂


Prototype – Cheat Sheet

I had to deal with Prototype while working with Magento. Here’s a little cheat sheet of some very simple stuff I had to do.

Make an Ajax Request with parameters

new Ajax.Request(url, {
                   method:'get',
                   params : { data1 : 'myParam' }
                   onSuccess: function(xhr){
                    console.log(xhr.responseText); 
                    var json = JSON.parse(transport.responseText);
                    }
});

Change value of an input

$('ID OF THE ELEMENT').setValue('The new value');

Change data within a span tag

$('ID OF THE ELEMENT').update('Your new data');

 


Magento – Custom routing

If you implemented several store views in your Magento shop (let’s say for French and English), if you implement a new router, he will be associated to this views.

Ex: In Magento’s default behavior,

your-store.com/my_router # KO 
your-store.com/fr/my_router # OK 
your-store.com/en/my_router # OK

The solution to this problem is to implement custom routing. Inchoo wrote an awesome article about it.

 



Increase security on a WordPress site

WordPress is an extremely popular framework, which makes it easier to hack. Here are couple of ways to increase the security of your WordPress installation :

  • Hide your admin back-end to a list of whitelisted IPs through server rules on Apache / Nginx
  • Change the path to your admin back-end
  • Protect the wp-login.php script
  • Change the prefix of your tables
  • Use complicated passwords and change them often

For people who are not necessarily developers, the plugin “iThemes Security” does some of the steps I mentioned pretty well.

 


NoMethodError /Ruby/Gems/2.0.0/gems/sass-3.4.8/lib/sass/plugin/compiler.rb Undefined method start

I had the weirdest issue when initializing my compass project for Greenie.

kikoo:greenie leiluspocus$ sudo compass watch --trace
>>> Compass is watching for changes. Press Ctrl-C to Stop.
NoMethodError on line ["402"] of /Library/Ruby/Gems/2.0.0/gems/sass-3.4.8/lib/sass/plugin/compiler.rb: undefined method `start' for #<Thread:0x007f90d1afd098 sleep>
  /Library/Ruby/Gems/2.0.0/gems/sass-3.4.8/lib/sass/plugin/compiler.rb:402:in `map'
  /Library/Ruby/Gems/2.0.0/gems/sass-3.4.8/lib/sass/plugin/compiler.rb:402:in `listen_to'
  /Library/Ruby/Gems/2.0.0/gems/sass-3.4.8/lib/sass/plugin/compiler.rb:338:in `watch'
  /Library/Ruby/Gems/2.0.0/gems/compass-1.0.3/lib/compass/sass_compiler.rb:46:in `watch!'
  /Library/Ruby/Gems/2.0.0/gems/compass-1.0.3/lib/compass/commands/watch_project.rb:41:in `perform'
  /Library/Ruby/Gems/2.0.0/gems/compass-1.0.3/lib/compass/commands/base.rb:18:in `execute'
  /Library/Ruby/Gems/2.0.0/gems/compass-1.0.3/lib/compass/commands/project_base.rb:19:in `execute'
  /Library/Ruby/Gems/2.0.0/gems/compass-1.0.3/lib/compass/exec/sub_command_ui.rb:43:in `perform!'
  /Library/Ruby/Gems/2.0.0/gems/compass-1.0.3/lib/compass/exec/sub_command_ui.rb:15:in `run!'
  /Library/Ruby/Gems/2.0.0/gems/compass-1.0.3/bin/compass:30:in `block in <top (required)>'
  /Library/Ruby/Gems/2.0.0/gems/compass-1.0.3/bin/compass:44:in `call'
  /Library/Ruby/Gems/2.0.0/gems/compass-1.0.3/bin/compass:44:in `<top (required)>'
  /usr/local/bin/compass:23:in `load'
  /usr/local/bin/compass:23:in `<main>'

I solved it by using a more recent version of Ruby using RVM. RVM is pretty cool because you can switch your Ruby versions very easily. Note that I had to re-install compass afterwards.