Share WiFi via Ethernet on Ubuntu 17.10

There is a hidden method to share your WiFi over Ethernet in the latest Gnome.

  1. Type nm-connection-editor in your terminal.
  2. Add a shared network connection by pressing the Add button.
  3. Choose Ethernet from the list and press Create.
  4. Click IPv4 Settings in the left.
  5. Choose Shared to other computers by clicking the Method drop-down menu.
  6. Enter a new name like Shared WiFi LAN as the Connection name at the top

Dislocker script

This script aims to mount a Bitlocker encrypted drive in linux.
The binaries can be downloaded at https://pkgs.org/download/dislocker.

#!/bin/bash

# Dislocker binary can be downloaded from https://pkgs.org/download/dislocker
# All credits to Cesário Garcia Mil-Homens - www.cesariogarcia.com

if [ ! -d "/media/mount" ] && [ ! -d "/media/bitlocker" ]; then
        sudo mkdir /media/bitlocker
        sudo mkdir /media/mount
    else
        sudo fdisk -l
        read -n1 -r -p "Press any key to continue..." key
        echo "Insert volume and partition eg. sdaX"
        read volume
        echo "Enter password"
        read -s password
        sudo dislocker -V /dev/$volume -u$password -- /media/bitlocker
        sudo mount /media/bitlocker/dislocker-file /media/mount/ -o loop
        echo "Press u to umount device"
        read key
        if echo "$key" | grep -iq "^u" ;then
                sudo umount /media/mount
                sudo umount /media/bitlocker
        fi
fi

Validação de NIF em C++

Algoritmo de validação de um NIF em C++

#include <iostream>

int nif, n, nif_d[8], resto, dig_controlo, verificacao;
int resultado=0;

int main(){
  printf("Insira o seu NIF \n");
  scanf("%d",&amp;nif);

  //Separação de dígitos num array
  for(n=9;n>=1;n--){
    nif_d[n]=nif%10;
    nif/=10;
  }

  //Atribui o último dígito à variável verificacao
  verificacao = nif_d[9];

  //Verificar se o NIF possuí 9 dígitos e consequente verificação dos primeiros dígitos
  if((nif<=999999999||nif>99999999)&amp;&amp;((nif_d[1]==1||nif_d[1]==2||nif_d[1]==3)||(nif_d[1]==4&amp;&amp;nif_d[2]==5)||(nif_d[1]==5)||(nif_d[1]==6)||(nif_d[1]==7&amp;&amp;nif_d[2]==0)||(nif_d[1]==7&amp;&amp;nif_d[2]==4)||(nif_d[1]==7&amp;&amp;nif_d[2]==5)||(nif_d[1]==7&amp;&amp;nif_d[2]==1)||(nif_d[1]==7&amp;&amp;nif_d[2]==2)||(nif_d[1]==7&amp;&amp;nif_d[2]==7)||(nif_d[1]==7&amp;&amp;nif_d[2]==8)||(nif_d[1]==7&amp;&amp;nif_d[2]==9)||(nif_d[1]==8)||(nif_d[1]==9&amp;&amp;nif_d[2]==0)||(nif_d[1]==9&amp;&amp;nif_d[2]==1)||(nif_d[1]==9&amp;&amp;nif_d[2]==8)||(nif_d[1]==9&amp;&amp;nif_d[2]==9))){

    //Calcular o valor da soma da multiplicação dos dígitos
    for(n=9;n>=2;n--){
      resultado+=nif_d[10-n]*n;
    }

    //Calcular o valor do resto
    resto=resultado%11;

    //Cálculo do dígito de controlo
    if(resto<2){
      dig_controlo=0;
    }else{
      dig_controlo=11-resto;
    }

    //Verificação com o dígito de controlo
    if(dig_controlo==verificacao){
      printf("O NIF é válido\n");
    }else{
      printf("O NIF é inválido\n");
    }
  }else{
    printf("O NIF é inválido\n");
  }
}

Transmission Peer Blocklist for Windows – TiBL4Win – v1.0

Just copy the code below to script.bat to where you want, execute as administrator, this will update the transmission blocklist with ips from Peer Block (http://www.peerblock.com/).

Just follow the instructions below in the configuration to download wget and gzip.

::This script creates the same lists as peerblock http://www.peerblock.com/, it outputs a file that you
::can use on Transmission automatically.
::This script was created by Cesário Garcia Mil-Homens - http://www.cesariogarcia.com just for the fun.
::TiBL4Win - v1.0

::CONFIGURATION - WARNING THE DIRECTORIES SHOULD ALREADY EXIST.

::In order for this script to work wget.exe and gzip.exe should be in the tmp directory do not remove them
::Download wget from: https://eternallybored.org/misc/wget/
::Download gzip from: http://gnuwin32.sourceforge.net/packages/gzip.htm
::Setup Transmission Blocklist folder.
set destination_folder="%appdata%\transmission\blocklists"

::DO NOT EDIT BELOW THIS LINE unless you know what you are doing
pushd "%~dp0"
cd tmp
wget -O - "http://list.iblocklist.com/?list=bt_ads&amp;amp;amp;amp;fileformat=p2p&amp;amp;amp;amp;archiveformat=gz" &amp;amp;amp;gt; bt_ads.txt.gz
wget -O - "http://list.iblocklist.com/?list=bt_level1&amp;amp;amp;amp;fileformat=p2p&amp;amp;amp;amp;archiveformat=gz" &amp;amp;amp;gt; bt_level1.txt.gz
wget -O - "http://list.iblocklist.com/?list=bt_spyware&amp;amp;amp;amp;fileformat=p2p&amp;amp;amp;amp;archiveformat=gz" &amp;amp;amp;gt; bt_spyware.txt.gz
gzip -d *.gz
copy *.txt lists
copy lists %destination_folder%
del lists
del *.txt
del *.gz

Text-To-Speech (TTS) no Android em pt_PT e em todas as línguas

Recentemente pretendi que o meu telemóvel lesse alguns livros, comecei por utilizar o motor de TTS da Google e para além de ser pouco natural, estava em Português do Brasil.

Após alguma pesquisa, encontrei uma solução grátis e muito boa, que ultrapassa largamente em qualidade algumas app’s pagas da playstore. O software foi criado por um grupo de Húngaros e baseia-se no motor de TTS da Nuance.

Após a instalação da app, esta ficará como motor TTS predefinido do nosso dispositivo Android.

Guia de instalação

  1. Efetuar o download da app aqui. Lembre-se que para instalar esta aplicação deverá permitir nas definições a instalação de aplicações de fontes desconhecidas (Definições -> Segurança -> Fontes desconhecidas).
  2. Executar o ficheiro vocalizer_e.tts_1.0.2.3k.apk e instalar.
  3. Efetuar o download dos ficheiros das vozes:
  4. Renomear a extensão do ficheiro pretendido para ZIP.
  5. Descompactar o ficheiro.
  6. Criar no dispositivo Android a directoria /storage/sdcard0/VocalizerEx (sdcard0 é a memória interna).
  7. Copiar para a directoria criada anteriormente a directoria obtida na descompactação do ficheiro ZIP.
  8. Indicar o novo motor TTS como predefinido em Definições -> Idioma e entrada -> Saída de texto para voz e Selecionar VocalizerEx TTS.

Ubuntu Linux 12.04 LTS – World Wide VPN’s

In Windows you can get free VPN software like Anchor Free, SoftFlux and Expat Shield.
But what about Linux?

US – http://www.anchorfree.com/
US – http://www.spotflux.com/
UK – http://www.expatshield.com/

So how can we create a VPN that gives us the country IP we want?

So things we will install

  • Vidalia – Vidalia offers a graphical user interface to start and stop Tor, view its status at a glance, and monitor its bandwidth usage.
  • Tor – Tor is a connection-based low-latency anonymous communication system which addresses many flaws in the original onion routing design.
  • Privoxy – Privoxy is a non-caching web proxy with advanced filtering capabilities for enhancing privacy, modifying web page data and HTTP headers, controlling access, and removing ads and other obnoxious Internet junk.

Let’s install them on terminal (Ctrl + Alt + t)

sudo apt-add-repository ppa:ubun-tor/ppa
sudo apt-get update
sudo apt-get install tor privoxy vidalia

If you want a UK ip everytime you start Tor open Vidalia and go to “View the network”. Here you will see a bunch of relays, sort them by country and copy the nicknames of wich you want to look like the ones below.

ExitNodes TorLand2, TorLand1, TorLand5, st0nerhenge, c00psTOR, EnfluraneNode, microlah, YoureOnCCTV, hamtor
StrictExitNodes 1

Go to terminal

sudo gedit /etc/tor/torrc

Insert the lines you created save and exit.

Start tor

tor &amp;

Go to Network GUI -> Proxy

Socks Server: 127.0.0.1
Port: 9050

If you want to logoff the VPN set proxy to none and stop tor

sudo killall tor

PBLS4Lin v1.0 – Peerblock for Linux and Transmission

Um script para linux que permite utilizar as listas do Peerblock.
Estas listas podem ser utilizadas no Transmission.

#!/bin/bash

#This script creates the same lists as peerblock http://www.peerblock.com/, it outputs a file that you
#can use on Transmission under Edit -&gt; Preferences -&gt; Privacy -&gt; Blocklist. In the first time copy the
#http link and use it. All lists are from http://www.iblocklist.com
#This script was created by Cesário Garcia Mil-Homens - http://www.cesariogarcia.com just for the fun.
#PBLS4Lin - v1.0

#CONFIGURATION - WARNING THE DIRECTORIES SHOULD ALREADY EXIST.

#Insert here the dir where is your Dropbox/Google Drive/etc public folders or you local server with apache
#Using Dropbox
#destination_folder=&quot;$HOME/Dropbox/Public&quot;
#Using localhost
destination_folder=&quot;/var/www/peerblock&quot;

#Insert here your own temporary download folder, do not use /tmp
temp=&quot;$HOME/tmp&quot;

#DO NOT EDIT BELOW THIS LINE

clear
echo &quot;Peerblock Lists - Automatic Uptades for Transmission&quot;
echo &quot;My destination folder is $destination_folder and my temporary download folder is $temp is this correct? (y/n)&quot;

function download() {
	sudo cd $temp
	sudo wget -O - &quot;http://list.iblocklist.com/?list=bt_ads&amp;fileformat=p2p&amp;archiveformat=gz&quot; &gt; bt_ads.txt.gz
	sudo wget -O - &quot;http://list.iblocklist.com/?list=bt_level1&amp;fileformat=p2p&amp;archiveformat=gz&quot; &gt; bt_level1.txt.gz
	sudo wget -O - &quot;http://list.iblocklist.com/?list=bt_spyware&amp;fileformat=p2p&amp;archiveformat=gz&quot; &gt; bt_spyware.txt.gz
	sudo gunzip *.gz
	}

function combine() {
	sudo cat bt_ads.txt bt_level1.txt bt_spyware.txt &gt; peerblock.txt
	sudo rm bt_ads.txt
	sudo rm bt_level1.txt
	sudo rm bt_spyware.txt
	 }

function upload() {
	sudo mv -f peerblock.txt $destination_folder
	}

read op

case $op in
	y) download; combine; upload;;
	*) exit;;
esac

MIT – Circuits and Electronics 6.002x

MIT - Circuits and Electronics 6.002x

O meu certificado do MIT 😀

Aqui estão as estatísticas oficiais do curso do MIT 154763 pessoas que se registaram e apenas acabaram 7157, eu sou uma destas 7157 😀

Course statistics: 6.002x had 154,763 registrants. Of these, 69,221 people looked at the first problem set, and 26,349 earned at least one point on it. 13,569 people looked at the midterm while it was still open, 10,547 people got at least one point on the midterm, and 9,318 people got a passing score on the midterm. 10,262 people looked at the final exam while it was still open, 8,240 people got at least one point on the final exam, and 5,800 people got a passing score on the final exam. Finally, after completing 14 weeks of study, 7,157 people have earned the first certificate awarded by MITx, proving that they successfully completed 6.002x.

https://verify.edxonline.org/cert/7645de2e02614b20a492757e4cad049d

BBC Click

Em Portugal e em muitos outros países o site da BBC não nos permite ver o programa de ciência e tecnologia BBC Click, descobri um excelente canal que de semana a semana coloca online no youtube o programa da semana. Vale apena ver.

Canal:

Programa BBC Click do dia 07-04-2012