Welcome to my Blog

Featured

Welcome to my blog !!!

My website was born on 1997, I closed it many years ago due to the social networks advent.
Actually I notice that Social Networks have some limits, for this reason I opened a new blog about the Information Technology: my world.
I hope to be able to post some useful stuffs
I’m waiting your suggestions & feedbacks, in the meanwhile. please excuse me for my bad english 🙂

Peppe La Rosa

My new Puppet Test environment by Vagrant

I did a very basic Vagrant test environment based on Puppet 3.x and VirtualBox 5.
My purpose is create an environment to test Puppet modules on different OS flavours without implementing a Puppet Master server.
Using Vagrant, I can create from scratch VMs provisioning by Puppet just run a command. Moreover I can destroy & recreate them in few seconds!

Take a look on my vagrant-test-env github repo. It contains a short tutorial and some codes.

How to test JSON result from RoR functional tests

If your Rails controllers return JSON code, you have to call ActiveSupport::JSON.decode on the response body to get a hash to use in your functional tests.
First of all, add the code below on test/test_helper.rb file inside the ActionController::TestCase class:

# Added to support JSON test
def json
    ActiveSupport::JSON.decode @response.body
end

So, next step is make the JSON test. If you have an index method as below:

def index
    respond_to do |format|
        format.html
        format.json { render json: UserDatatable.new(view_context) }
    end
end

The test below covers the HTML part:

test "should get index" do
    get :index
    assert_response :success
    assert_not_nil assigns(:user)
end

To cover also the JSON code, just add the following:

test "should get JSON index " do
    get :index , :format => :json
    assert_response :success
    assert_not_nil assigns(:user).to_json, @response.body
end

Check the doc to go in deep about encode e decode methods here,

Rotating videos with FFmpeg

We’re not all professional videomaker. I love photograph, but I hate to make video, so often I use my smartphone as a camera choosing the wrong orientation.

I find a way out to avoid to flip my monitor when I see videos.

Se avete un video da girare in senso orario di 90º bastera’ posizionarsi sulla directory contenente il/i video e digitare : To rotate a video

# ffmpeg -i myVideo.avi -vf "transpose=1" myFixedVideo.avi

take a look to the transpose values :

0 = 90 CounterCLockwise and Vertical Flip (default)
1 = 90 Clockwise
2 = 90 CounterClockwise
3 = 90 Clockwise and Vertical Flip

That’s all.

Fast audio format convertion using ffmpeg

FFMPEG is the swiss army knife of Internet Streaming. As written in the homepage “is a very fast video and audio converter that can also grab from a live audio/video source. It can also convert between arbitrary sample rates and resize video on the fly with a high quality polyphase filter. “

Now, we are going to convert all FLAC files from a specific directory to MP3 256K.  It’s not a good idea from the quality perspective, but, you know, some players don’t support FLAC file.

First step is installing FFMPEG with all required codecs. If you are using a Debian base distro just run the following command:

# sudo apt-get install ffmpeg lame flac

unfortunately, ffmpeg is not part of Ubuntu 14.04 official repositories, so we need to add it before installing it:

# sudo apt-add-repository ppa:jon-severinsson/ffmpeg
# sudo apt-get update

Now from the source directory we can run something like that:

# (for FILE in *.flac ; do ffmpeg -i "$FILE" -f mp3 -ab 256000 "`basename "$FILE" .flac`.mp3" || break; done

this is only an example: ffmpeg can handle a lot of formats. To have a list:

# ffmpeg -formats

I suggest to read the official doc to go in deep

Using TrueCrypt is not secure as it may contain unfixed security issues

This is not a my personal opinion, but it’sreported on Truecrypt homepage :

http://truecrypt.sourceforge.net/

a backdoor was injected by NSA ?

In Feb 2015 a security assestment was published and it showed no evidence backdoors or potential dangerous bugs. Unfortunately the project is no longer active. It’s hard to understand what happened with NSA.