Kill Flash

July 14, 2015 Leave a comment

Problem
You may have heard that several vulnerabilities came out recently for Flash, thus Mozilla decided to deactivate the Flash plugin in Firefox.

How to remove Flash completely?

Solution

$ sudo dpkg --remove flashplugin-installer

Goodbye Flash, you won’t be missed!

No sound problem
In Firefox, playing HTML5 videos I had no sound. Here is how to fix it. Install the program “pavucontrol” and start it. On the Playback tab, HDMI was selected by default. Changing it to “Built-in Audio Analog Stereo” the sound came back.

Categories: firefox Tags: , , ,

taking a screenshot about a webpage

July 11, 2015 Leave a comment

Problem

You know the URL of a webpage and you want to take a screenshot of it. For instance you want a thumbnail about the webpage.

Solution

It can be done very nicely with PhantomJS.

What is PhantomJS?
PhantomJS is a headless WebKit scriptable with a JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.” (source)

How to install PhantomJS?
Follow the instructions here. Under Ubuntu I compiled it from source to get the latest version. Note that it takes a lot of time (about 30 minutes). Under Manjaro I could install it via yaourt and it took 1 minute (and got the newest version). The good news is that installation is not a problem.

How to take a screenshot?
If you download the source, you get a lot of example scripts. One of them is called rasterize.js, and this is exactly what we need.

$ phantomjs rasterize.js 
Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom]
  paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"
  image (png/jpg output) examples: "1920px" entire page, window width 1920px
                                   "800px*600px" window, clipped to 800x600

Example #1:

phantomjs rasterize.js http://raphaeljs.com/polar-clock.html clock.png


Example #2:

phantomjs rasterize.js https://www.reddit.com/ red.png

It produced an image with dimension 600×3304. It’s too narrow, let’s fix that.

Example #3:

phantomjs rasterize.js https://www.reddit.com/ red.png 1024px

Its dimension is 1024×2432. Looks much better.

Example #4:
The previous image was too high. Let’s take a photo of that part that would be visible on our screen. For this we need to clip a window.

phantomjs rasterize.js https://www.reddit.com/ red.png "1024px*768px"

Great. Now scale it down to get a thumbnail.

Scaling down an image to thumbnail size

$ phantomjs rasterize.js https://www.reddit.com/ screenshot.png "1024px*768px"
$ convert -resize 250 screenshot.png thumb.jpg

The command convert comes from the ImageMagick package. Here we resize the image to width 250px. Convert will keep the image ratio, i.e. it figures out the height value.

Links

Atom 1.0 has arrived

June 27, 2015 Leave a comment

Atom is a text editor that’s modern, approachable, yet hackable to the core—a tool you can customize to do anything but also use productively without ever touching a config file.” (source)

This text editor is developed by GitHub. I remember the early versions didn’t exist for Linux, so I was disappointed, but this is no longer an issue. The editor is cross-platform and since version 1.0 came out, I decided to give it a try.

It’s very similar to the excellent Sublime Text editor. It’s visible that they copied lots of things from it :) However, ST is not open source and there is one guy behind ST, Jon Skinner. Atom is fully open source with a large community behind it that is hard to beat…

Question
How to use Atom for Python editing?

Answer
I found a blog post that can get you started: http://www.marinamele.com/install-and-configure-atom-editor-for-python . In addition, I also installed the package ‘script‘ that lets you run your script inside Atom.

Atom has the nice feature to change your settings via a GUI. In ST you need to edit JSON files directly.

All in all, Atom seems to be a nice editor. It’s still version 1.0, so I’m sure it’ll improve a lot, but I already like it.

youtube lectures on computer science

June 27, 2015 Leave a comment

free data science books

June 27, 2015 Leave a comment

16 free data science books for the aspirational data scientist, covering statistics, Python, machine learning, the data science process, and more.

http://www.wzchen.com/data-science-books

reddit comments here

Categories: book Tags:

Rotten Tomatoes has an API

June 12, 2015 Leave a comment

If you want to get info about a movie (e.g. rating, cast, etc.), there is imdbpy, which collects data from IMDb. I just found that Rotten Tomatoes has an API too: http://developer.rottentomatoes.com/.

Update (20150622): about two weeks ago I asked for an API key. I’ve got no response since then…

Update (20150623): I got an answer from them! Here it is:

Thank you for your interest in the Rotten Tomatoes API. Unfortunately, we are unable to grant access at this time.

Due to changes in our syndication program, we're currently only offering free API access to domestic students. This may change in the future as we add additional tiers to the program.

-The Rotten Tomatoes Team
Categories: api Tags: , , ,

convert .wmv to .mp4

ffmpeg -i input.wmv -c:v libx264 -crf 23 -profile:v high -r 30 -c:a libfaac -q:a 100 -ar 48000 output.mp4

More info here.

Categories: bash Tags: , , , ,
Follow

Get every new post delivered to your Inbox.

Join 79 other followers