Wandbox: a social compilation service

July 30, 2014 1 comment

Wandbox is a project that allows you to try several languages in your browser. Just paste the code and Wandbox will compile/interpret it and show you the result.

Try it here. The source code is on GitHub.

The service can be called via an API too! The API doc. is here: https://github.com/melpon/wandbox/blob/master/kennel/API.rst.

Dr. Strangelove or: How I Learned to Stop Worrying and Love Bash

July 30, 2014 1 comment

In this post, Steve shows how to include Python code snippets in Bash scripts! Do you hate Bash? Me too :) However, with this trick bash becomes much less painful.

For more info, please refer to Steve’s post. Here I write a short summary for future references.

Example 1:

#!/bin/bash

function current_datetime {
python - <<END
import datetime
print datetime.datetime.now()
END
}

# Call it
current_datetime

# Call it and capture the output
DT=$(current_datetime)
echo Current date and time: $DT

Example 2 (passing parameters to the wrapping function):


#!/bin/bash

function line {
PYTHON_ARG="$1" python - <<END
import os
line_len = int(os.environ['PYTHON_ARG'])
print '-' * line_len
END
}

# Do it one way
line 80

echo 'Handy'

# Do it another way
echo $(line 80)

You can find another example with JSON at Steve’s blog.

Categories: bash, python Tags:

Black Hat youtube videos

July 13, 2014 Leave a comment
Categories: Uncategorized Tags: ,

Gmail users have an extra email address

July 12, 2014 Leave a comment

TIL that if you have a Gmail address (e.g. name@gmail.com), then you also have a name@googlemail.com address. Give it a try. Send something to your googlemail.com address, and it will be delivered to you gmail.com inbox.

This tip is from here.

Categories: google Tags: ,

my current Ubuntu wallpaper

July 11, 2014 Leave a comment

broken_windows-wallpaper-1920x1080

Categories: fun, ubuntu, windows Tags:

machine shuts down, then restarts in a few seconds

July 11, 2014 Leave a comment

Problem
My new desktop machine has a strange behaviour. It shuts down normally, but after a few seconds it restarts automatically.

Solution
I found the solution here. In short:

Edit the file “/etc/default/grub” and modify this line:

GRUB_CMDLINE_LINUX_DEFAULT="acpi=noirq quiet splash"

The new thing is the “acpi=noirq” part. Don’t forget to run “sudo update-grub” at the end.

It solved the problem but when I hit the SPACE button on the keyboard, the machine wakes up as if I had pressed the power button. Strange, but maybe it’s normal for new machines.

Categories: ubuntu Tags: , ,

open links in okular with Firefox

July 10, 2014 Leave a comment

Problem
You have a PDF that contains links. You click on a link but it opens in a strange browser (Konqueror?). How to open links with Firefox?

Solution

  1. Run the command “kcmshell4 filetypes“. File Associations – KDE Control Module will open.
  2. Search for html and select the file type text/html.
  3. Move the application name you want to be a default for html in the “Application Preference Order” to the top.

I copied this solution from here. Credits go to djhurio.

Categories: ubuntu Tags: , , ,
Follow

Get every new post delivered to your Inbox.

Join 72 other followers