vrijdag 23 december 2016

How to select files in a directory with the boolean operator AND

I want to select (find/grep/ls) certain files in a directory starting with certain words and ending with a certain extension. Example:
  • bluebelt_hans_hoff.jpg
  • bluebelt_hans_hoff.JPEG
  • bluebelt_peter_gort.jpg
  • bluebelt_peter_gort.JPEG
I only want the files starting with "bluebelt" AND ending with only the ".jpg" extension (and not the JPEG extension). How to do this on the commandline?

Answer:  ls bluebelt* | grep .jpg

donderdag 22 december 2016

Index in LaTeX: dit spreekt voor zichzelf.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{imakeidx}
\makeindex[columns=3, title=Alphabetical Index, intoc]
 
\begin{document}
 
\tableofcontents
 
\section{Introduction}
In this example several keywords\index{keywords} will be 
used which are important and deserve to appear in the 
Index\index{Index}.
 
Terms like generate\index{generate} and some\index{others} 
will also show up. Terms in the index can also be 
nested \index{Index!nested}
 
\clearpage
 
\section{Second section}
This second section\index{section} may include some special 
word, and expand the ones already used\index{keywords!used}.
 
\printindex
\end{document}

dinsdag 6 december 2016

How to delete empty lines in LibreOffice

There is a way to delete empty lines in LibreOffice with regex. 
It is this command: ^$
But sometimes this doesn't work. Because the above mentioned command actually deletes a paragraph and not a line.
What to do in a case like this one:

Marco Borsato
Wat is mijn hart

De Dijk

Niemand in de stad

The above mentioned command doesn't work and doesn't erase the line between the two texts.

What you need to do, is to clear formatting.
Also make sure that after clearing lines, there are no spaces left at the beginning of the lines.

dinsdag 29 november 2016

Latex-page

I have had a lot of problems creating this page:
\documentclass[A4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\rhead{Share\LaTeX}
\lhead{Guides and tutorials}
\rfoot{Page \thepage}
\newcommand{\french}[1]{\textbf{#1}}

\begin{document}


\section{Voilà}

                                               
Essential French Expression

   Meaning       (where to begin?)
   Literally     there is
   Register      normal, informal
   Pronunciation   [vwah lah]
             IPA   [vwa la]

   Usage notes: Voilà is the quintessential French word – commonly used in
   French, easy to say, and exotic sounding (and therefore used in English
   to give a bit of je ne sais quoi to whatever you’re saying).

   Voilà has any number of meanings, it’s definitely one of those words
   that you pick up a feeling for when spending time with native speakers.
   In the meantime, here are lots of examples to help you understand the
   different uses.

\paragraph{1. Presentation}

   The original meaning of voilà is "there is, there are," as when
   pointing out one or more distant objects to another person. The nearby
   equivalent is voici (here is, here are), but in spoken French, voilà
   tends to be used in both cases, except when a distinction needs to be
   made.
   Voilà notre école.
   Here’s) our school.
   \french{Voici mon sandwich} et voilà le sien.   Here’s my sandwich and there’s his.
\end{document}

woensdag 23 november 2016

How to combine two sets of data.

How to combine two sets of data?

There are two lists:
A (a1, a2, a3, a4, a5 etc.)
B (b1, b2, b3, b4, b5 etc.)

In this case, it was text that was to be combined, so I made use of Excel:
C1 = a1&b1
Then drag the corner of the rectangle down and I got the combination that I wanted.

Supposedly, it can be done differently:
>>> a = ['a1', 'a2', 'a3', 'a4', 'a5']<br>
>>> b = ['b1', 'b2', 'b3', 'b4', 'b5']<br>
>>> [elem for pair in zip(a, b) for elem in pair]<br>
['a1', 'b1', 'a2', 'b2', 'a3', 'b3', 'a4', 'b4', 'a5', 'b5']<br>

maandag 21 november 2016

AWS

I made an Ubuntu server on AWS.

If you want to log in with the command line, you have to use the following command:

ssh -i xxx.pem ubuntu@ec2-xxx.amazonaws.com

To download something from the server to the local machine:
scp -i xxx.pem ubuntu@ec2-xxx.amazonaws.com:~/documenten/drunkensailor.txt .

The point at the end of the sentence stands for the folder used on the local machine.

It is also possible to use the program Filezilla to log in to the server. It is all very easy.



vrijdag 22 januari 2016

Counting the number of characters in a string

# Counting the total number of the letter "a" in a string.
 
x = ("What shall we do with the drunken sailor?")

i = "a"
print (x.count(i, 0, 40))

Result:
3

Print a line in reversal

# print the text in reversal.
import sys
x = ("What shall we do with the drunken sailor?")

y = (len(x)-1)
print (y)

while y > 0:
    y = y - 1
    sys.stdout.write(x[y])
print("\n")

Result:
40
rolias neknurd eht htiw od ew llahs tahW

Perl script: What shall we do with the drunken sailor?

#!/usr/bin/perl
use strict;
use warnings;

my $x = "What shall we do with the drunken sailor?\n";
my $y = "Early in the morning.\n\n";
print "$x" x 3;
print "$y";

my $z = "Heave ho, and up she rises\n";
print $z x 3;
print $y;

Result: 
What shall we do with the drunken sailor.
What shall we do with the drunken sailor.
What shall we do with the drunken sailor.
Early in the morning.

Heave ho, and up she rises.
Heave ho, and up she rises.
Heave ho, and up she rises.
Early in the morning.

Online editors van Codingground

The online editors van Codingground:

http://www.tutorialspoint.com/codingground.htm

Making an error in the text

# Hello World program in Python
 
x ="What shall we do with the drunken sailor?"
print (len(x))
print (x[0:5] +"hs"+ x[7:40])

Result: What hsall we do with the drunken sailor

Editing text with python

# editing text with python
 
x = ("What shall we do with the drunken sailor?\n")

print (x[0:4])
print (len(x))
print (x[40])

Enlarging Libreoffice window completely with command

 You can open the LibreOffice window completely by pressing the CTRL+Shift+J keys together.