Gerardo Grimaldi

Post Top Ad

LightBlog

Post Top Ad

Your Ad Spot

Friday, April 17, 2020

The Video converter I needed

April 17, 2020 1
Handbrake it's an open-source video transcoder and a lifesaver! 
For people that don't have a lot of time for transcoding or don't know a lot about video. I was trying to get working an OGM file on my TV and the format was not recognized by it. It even wasn't visible by Plex that is a great server-client app for organizing video.
So I decided to convert those stupid files. 
The solution... Handbrake it was like magic! 

It let me:
  • Choose the format to convert the files
  • Select various types of files
  • Remove annoying audio tracks on the file
  • Add some subtitles 
  • Force subtitles that were necessary for the video.
So I give you the link for this miraculous and simple app that lets you work on all your videos at once.

https://handbrake.fr/rotation.php?file=HandBrake-1.3.1-x86_64-Win_GUI.exe

The web site for this guy is https://handbrake.fr/ go check it out.

HandBrake logo
Read More

I hate the PDF format

April 17, 2020 1
The other day I was trying to get a graphical novel from the web but the only format that I found was PDF. In some manner, I was sure it was all that I needed but the PDF format was messing with the images on my Kindle Paper White. 

The solution: Extract the images.
The problem: PDF.

The PDF format its crap, because of everyone it's trying to get a piece of the action behind it. So every extractor, converter or creator costs money or its freemium(for paying later) or its a scam. I searched for an open-source way of a deal with it and I came across this tool. It was fantastic!

Pkpdfconverter lets you export text images tex + images in an elegant and simple way the interface look kind of old but it deserves being checked out.

Here is the link to the project in Sourceforge:

https://sourceforge.net/projects/pkpdfconverter/


Read More

Tuesday, December 18, 2018

Free DNS setup for a domain showing a Blogger web page

December 18, 2018 22

I was very busy with some configuration for a friend's blog on Blogger.
She was paying a fee for the DNS redirect from her national DNS service to blogger, and I help her to stop paying for that.

I'll write the steps to reproduce the free DNS setup via CloudFlare, that by the way its an excellent way to manage the DNS for free.

Step 1
In the first place, you need to add the domain to Cloudflare after creating an account in Cloudflare.
After that, we must provide the DNS of Cloudflare to our national domains service, usually, they are:

fred.ns.cloudflare.com
pola.ns.cloudflare.com

Step 2
The next step it's to locate the "configuration area" in Blogspot > Settings > Basic > Publishing >  Blog Address > "+ Set up a third-party URL for your blog - Point your own registered URL to your blog."

Step 3
In there is an input box for setting your domain URL including the subdomain www o blog or whatever... after you put it, it will throw an error and a description and link that downloads a text file that has all the information for upload to the DNS configuration in cloud flares the links says "DNS settings file", the content of the file looks something like this:


  • @ 3600 IN A 216.239.32.21
  • @ 3600 IN A 216.239.34.21
  • @ 3600 IN A 216.239.36.21
  • @ 3600 IN A 216.239.38.21
  • www 3600 IN CNAME ghs.google.com
  • 6n3klf7wtapc 3600 IN CNAME gv-3srif7ga7v6d4w.dv.googlehosted.com


This configuration shows to Blogger that you own the Domain and your point that domain from your DNS to Blogger.

Step 4
The importation of this config it made via a tool of Cloudflare in the tab DNS in DNS Records we look for the Advance button and after that, it will show a configuration panel with a button for Upload DNS File.

We select out just download DNS configuration file from Blogger and Cloudflare configures the DNS for us as Blogger wishes.

Step 5
Wait a while for DNS to deploy return to Blogger and insist on Step 3, it should now take the configuration of your domain and check that you own it. 

Step 6
In Blogger check on the checkbox that says Redirect from the domain alone to the domain with www or blog or whatever...

Step 5
In the same screen in Blogger check for HTTPS > HTTPS Availability and HTTPS Redirect. And put yes in both.

Step 5.1
And as an add-on, you can redirect in the Page Rules tab add the complete URL/Description of the domain and the redirect 301 that it's permanent to the URL with https and www.

Read More

NativeScript/Angular for dummies (practical guide)

December 18, 2018 1

Soo I begin to wonder what to write next and the response now that I know that Phone/Cordova it's a stinky pile of s... is clear to me now...

This is a thing that I'll surely regret try or write for in some years but let's begin with some easy tutorial for NativeScript.

The way I see it the only cool wat to see this is via the internal app for the playground of the team: Playground NAtivescrip Android for practically we will use Android because we all know that iOS sucks. First, let's install the CLI
npm install -g nativescript
The requirements for a full build of an app are here:
https://docs.nativescript.org/angular/start/quick-setup
Then we proceed to make a new app:
tns create HelloWorld --template tns-template-blank-ng
And for last we try to see our magnificent app in the preview panel:
tns preview
This will throw a QR code that we can scan with our playground app and the app will just pop up in the phone. Well, that's for now, a little guide to make a new app in NativeScript/Angular. See you next time.
Read More

Saturday, March 15, 2014

Making a scraper in Node.js...

March 15, 2014 1
Let's make a multi link crawler for a multi page query in a web page listing jobs opportunities.

First let's make a module of it, in a separate file from our server in node whatever it is and we gonna call it with

var worker = require('worker.js');

It will be called with this sentence from our express router or whatever you are using.

First we gonna need two libraries 

var request = require("request");
var cheerio = require("cheerio");

One for making requests more easy(request) and another for making jQuery available on the server side(cheerio).

Now we need the list of pages of the main web site, this one makes a default paged list with the jobs listed that day in in one link, and paginates on base of that link so...

var url = "http://www.bumeran.com.ar/empleos-publicacion-hoy.html";

Now for exporting this function to the node server we gona make a "start" function and export it.

In this example we gona make a request to the url of before and read the body with cheerio taking the 
number of pages of that list from the paginator in the bottom. 

Then we send that number of pages to the scraper function 

exports.start = function(req, res) {
    request(url, function() {
        return function(err, resp, body) {
            if (err && resp.statusCode == 200) {
                console.log(err); //throw err;
            }
            $ = cheerio.load(body);
            var pages = $(".paginador.box a:nth-last-child(2)").text().trim();
            console.log(pages); 
            scraper(pages);
        };
    });
};  

The function scraper must have the variable url by the number of page in this case it gona be:

var url = "http://www.bumeran.com.ar/empleos-publicacion-hoy-pagina-" + NUMBEROFPAGE + ".html";

The function scraper will only recive the number of pages from the scraping from before.

It will read every list in every page, and send specific links to the pages with the job descriptions to the scraperLinks function this process will be asynchronously by the nature of node.js. 

function scraper(pages) {
    for(var i = 0; i < pages ; i++){
        var url = "http://www.bumeran.com.ar/empleos-publicacion-hoy-pagina-" + (i + 1) + ".html";
        request(url, ( function(i) {
            return function(err, resp, body) {
                if (err && resp.statusCode == 200){
                  console.log(err); //throw err;
                }
                $ = cheerio.load(body);
                $(".aviso_box.aviso_listado").each(function(index, tr) {
                    console.log("Scrapping..." + $(this).attr("href")); 
                    scraperLinks($(this).attr("href"));
                });
            };
        })(i));
    }
}
NOTE: We are sending the value from "i" to the function as a value itself not a ref because it would not work as expected for the asynchronously way of work.


For last scraperLinks will get every link to a details page and get the info we need with plain jQuery:

function scraperLinks(link) {
            var url = "http://www.bumeran.com.ar" + link;
            request(url, function(err, resp, body) {
                    if (err && resp.statusCode == 200) { console.log(err); } //throw err;
                    $ = cheerio.load(body);            //console.log(body); 
                    var location = $('.aviso-resumen-datos tr td').last().text().trim(); // $('#.aviso-resumen-datos tr').last().find( "a" ).text();
                    var detail = $("#contenido_aviso p:nth-child(2)").text();//$("#contenido_aviso p").first().text();
                    var title = $(".box h2").first().text().trim();
                    var date = $(".aviso-resumen-datos tbody tr td").first().text().trim();
                    console.log("Saving..." + url); 
                    saveAd(url, location, detail, title, date);
                });
        }  

In this case we get title, date, and details from the published job, and send it to the saveAdd funtion that will recive the values and store them in any way posible. 

Well that's all 
Read More

Monday, July 1, 2013

The file conversion solution!

July 01, 2013 0
So... Last night, I was dealing with a stupid pdf file, this one in particularly was having a core data for a my next app, a perfectly well formed xls inside a stupid pdf file, the solution:

http://www.zamzar.com/

In seconds I was able to convert every file to xls, now the next problem after export the formatted xls to csv, was the conversion to json itself. That I resolve with this web app:

http://www.convertcsv.com/csv-to-json.htm

So the steps are various, but the effort its minimal.

Good luck with your conversions!

bye

Read More

Tuesday, June 25, 2013

Check if Mongoose it's already conected

June 25, 2013 1

You can tell if mongoose is already connected or not by simply checking:
if(mongoose.connection.readyState){}
0 = no
1 = yes
Read More

Monday, June 24, 2013

Error ! [rejected] master -> master (non-fast-forward) on Heroku/Git

June 24, 2013 0
$ git push origin master
# To https://github.com/user/repo.git
#  ! [rejected]        master -> master (non-fast-forward)
# error: failed to push some refs to 'https://github.com/user/repo.git'
# To prevent you from losing history, non-fast-forward updates were rejected
# Merge the remote changes (e.g. 'git pull') before pushing again.  See the
# 'Note about fast-forwards' section of 'git push --help' for details.
This error can be a bit overwhelming at first, do not fear. 
Simply put, git push -f https//github.com/user/repo.git to force the upload.

Read More

Tuesday, June 4, 2013

Mini Tutorial Node.js, Express, and Jade.

June 04, 2013 0

I was having some problems deploying some jade web pages over Node.js with Jade template engine.
So I'm leaving a small tutorial for not forgetting what i have done so far...

Let's see first install everything we need:

>npm install express
>npm install jade

Now we have the pieces lest make the directory structure for this project, just add the directories "views" and "public" we will save the static things in public, like JavaScript and CSS files and jade views in views. Pretty obvious right...
Now lets write some server code...

var app = express();
app.configure(function(){
    app.set('port', process.env.PORT || 3000); //set the port
    app.set('views', __dirname + '/views'); //set views dir
    app.set('view engine', 'jade'); // set the template engine
    app.use(express.favicon()); //set the favicon
   app.use(express.static(path.join(__dirname, 'public'))); //set the public dir for static content
});
app.get('/', function(req, res){
  res.render('index.jade', {title: 'Jade Example'}); //sends title to the template and renders it
});
app.listen(3000);

Let's make some views...
First the layout: layout.jade
!!! 5
html
  head
    title= title
    link(rel='stylesheet', href='/css/bootstrap.css')
    link(rel='stylesheet', href='/css/bootstrap-responsive.min.css')
  body

   header.site-header
     a.logo(href='/', title='Express, Jade and Stylus') Express, Jade and Stylus
       nav.site-nav
         ul.nav
           li.current
             a(href='/', title='Home') Home
    block content
p
  | Created by 
  a(href='http://http://grimaldigerardo.blogspot.com.ar/') Gerardo Grimaldi

Then a simple index: index.jade

extends layout

block content
  h1 = title
  p Welcome to #{title}


The bootstrap css it's inside the public directory in: '/public/css/bootstrap.css'
All ready, let's take it for a spin...

node app.js


Bye


Read More

Monday, May 27, 2013

Let's send some mails via Node.js

May 27, 2013 1
In my Android app I'm having a unique comments section from the users to contact me, they send comments and messages to my mail via this layout...




Now lets see i want to send a mail, with this three fields, to myself, via my app... I know!
An get request to a server, sending this three fields in a mail to myself!

Let's do this... first of all... lets fins a library that sends mails
bingo!  Nodemailer it s very appropriate for this task...
https://github.com/andris9/Nodemailer
https://npmjs.org/package/nodemailer

Lets's install it..

I use Cloud9 for developing in Node.js the pros are enough and the ide just IDE just works it coud debug in real time, and it got an console with some practice you can make a server and deploying it in no time, now lets see install node mailer.

Node has npm (node package manager) it resolves the dependencies via the Package.json or installing the stuf directly into the app via the npm install <name_of_the_library>, we gona use that for our app.

Just get inside the console and type : npm install nodemailer

This will install the necessary stuf for call the library inside the app.

Now let's make a js file that sends files

var nodemailer = require("nodemailer");
var smtpTransport = nodemailer.createTransport("SMTP",{
    service: "Gmail",
    auth: {
        user: "me@gmail.com",
        pass: "pass"
    }
});
var mailOptions = {
    from: "Server <me@gmail.com>", // sender address
    to: "me@gmail.com", // list of receivers
    subject: "", // Subject line
    text: "", // plaintext body
    html: "" // html body
};

exports.mailOptions = mailOptions;
exports.sendMail = function () {
    smtpTransport.sendMail(mailOptions, function(error, response){
        if(error){
            console.log(error);
        }else{
            console.log("Message sent: " + response.message);
        }
        /* if you don't want to use this transport object anymore, uncomment following line
        //smtpTransport.close(); // shut down the connection pool, no more messages*/
    });  
};
Note: This example is almost identical to the one in the page of the library in Github my server is set in this one.

Now this library exposes itself like a public atribute in a class via the "exports". I assign to them the the methods and properties I want to access from another js file in this case the server one I want for principal obviously requiring it first...

Let's go for the server itself...
var express = require('express');var mail = require("./nodemail");var app = express();
app.use(express.logger());
app.get('/mail/:name/:subject/:text/:securitytoken', function(req, res) {
    if (req.params.securitytoken != 'Salt742!') return res.send('Error: Wrong password...');    try {        newMail(req.params.name,req.params.subject, req.params.text);    }    catch(err) { onError(err); }});
app.listen(process.env.PORT);
function newMail(name, subject, text) {    mail.mailOptions.subject = 'Message from User: ' + name +  ' with Subject : ' + subject;    mail.mailOptions.text = text;    mail.sendMail();}
function onError(err) {    console.log(err);}
console.log('Server HTTP Listening on port ' + process.env.PORT + '...');

Well I'm gona explain this mess:
  1. First we use 'express' for listen to the get requests.
  2. In the get request we read the fields im sending from the app an one security token
  3. First of all we read the token and compare it to the one we got.
  4. Then we load the the data in the function newMail this one will set the values in the nodemail.js 
  5. After this we call the function in nodemail.js that will trigger the mails.
Well people that's all for now. I want some feedback, so please let me know if this is useful for you people out there. Or what would you like to see next in the blog. 

Bye.


Read More