Move files in current subdirectories to the current directory.
find . -mindepth 2 -type f -exec mv -t . -i '{}' +
Delete local folders that are empty.
find . -empty -type d -delete
Move files in current subdirectories to the current directory.
find . -mindepth 2 -type f -exec mv -t . -i '{}' +
Delete local folders that are empty.
find . -empty -type d -delete
# Get the HTML page content
from urllib import request
html = request.urlopen("https://silveiraneto.net").read()
# Get the title tag
from bs4 import BeautifulSoup
title = BeautifulSoup(html, 'html.parser').find('title')
print(title.string)
This uses the XML/HTML library BeautifulSoup . This could also be done using regex but playing with HTML and regex is usually a bad idea.
Found on reddit
çççç ççç ççç ççç ççç ççç ççç ççç ççç çççç çç çç
Fiz esse script (cedilha.sh) pra fazer o c-cedilha (ç) funcionar no Ubuntu 16.04. Como é uma tarefa chata que eu já tive que fazer muitas vezes fica mais fácil pra mim ter um script pra fazer isso e pode ser que seja útil a outras pessoas. Infelizmente é uma solução que exige baixar e executar como root um script da internet. Eu recomendo que você leia o script e entenda o que está acontecendo antes de executá-lo. Esse script altera vários arquivos importantes e ele faz um backup (.bak) desses arquivos.
wget https://raw.githubusercontent.com/silveira/cedilha.sh/master/cedilha.sh sudo bash cedilha.sh
Por favor, se o script funcionou pra você também, diga nos comentários. Se você não está usando Ubuntu 16.04 e quer testar o script ainda assim, edite o script e remova a verificação no inicio do programa.
import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.TimeUnit; class ParallelCounterExample { public static void main(String[] args) throws InterruptedException { int threads = 2000; ExecutorService executor = Executors.newFixedThreadPool(threads); final AtomicInteger atomi = new AtomicInteger(); for(int i=0; i<threads; i++) { executor.execute( new Runnable() { @Override public void run() { atomi.getAndIncrement(); } }); } executor.awaitTermination(1, TimeUnit.SECONDS); executor.shutdown(); System.out.println(atomi.get()); } }
Problem: Match strings that contains a single quotation mark ('), but not multiple ones together.
Solution:
(?<!')'(?!')
This is a regex for a single quotation mark with a (?<!') in the left and a (?!’) in the right. The (?<!') is a ?< look behind if not ! a single quotation mark '. The (?!') is a look ahead ? if not ! a single quotation mark '.
Java code:
import java.util.regex.Pattern; public class RegexProblem { public static void main(String args[]) { Pattern single_quote = Pattern.compile("(?<!')'(?!')"); String[] phrases = { "", "'", "a'a", "aaa", "aa'aa", "aa''aa", "aa'''aaa", "aaa''''aaa" }; for(String phrase: phrases){ System.out.println(String.format("For %s is %s.", phrase, single_quote.matcher(phrase).find())); } } }
The output is:
For is false. For ' is true. For a'a is true. For aaa is false. For aa'aa is true. For aa''aa is false. For aa'''aaa is false. For aaa''''aaa is false.