Skip to main content

Posts

command line mail with accent

Send characters like é è à in a command line mail I run CentOS 6, and made my first try with the "bsd-mailx" "mail" command line. #!/bin/bash export LANG=fr_FR.UTF-8 export LC_ALL=fr_FR.UTF-8 echo "Tâches du $( date +"%a %d %b %Y" -d "+1days" )" | mail -s "$( date +"%a %d %b %Y" -d "+1days" )" toto@rktmb.org When current month is "August", "Août" in French, it is just the big mess: characters are not encoded! I tried with mail -a "Content-Type: text/plain; charset=UTF-8" But it displayed right for the body, the subject was screwed yet Then I switched to "mailx": # yum remove bsd-mailx # yum install mailx I tried with mail -S sendcharsets=utf-8,iso-8859-1 And this works!

antlr java parser tree tokens

Use antlr to get a tree view of a Java piece of code Let this loop be (save it under ~/workdir/LoopOne.java): class LoopOne { public static void main(String[] args) { float x = Float.parseFloat(args[0]); while ( 0 - x <= 0){ x = x - 1; } } } If you want to get it parsed, you can use Antlr ( http://www.antlr.org/ ) cd ~/workdir curl -O http://www.antlr.org/download/antlr-4.5-complete.jar curl -O https://raw.githubusercontent.com/antlr/grammars-v4/master/java8/Java8.g4 In ".bashrc": export CLASSPATH=".:/home/mrakotomandimby/workdir/antlr-4.5-complete.jar:$CLASSPATH" alias antlr4='java -Xmx500M -cp ".:/home/mrakotomandimby/workdir/antlr-4.5-complete.jar:$CLASSPATH" org.antlr.v4.Tool' alias grun='java org.antlr.v4.runtime.misc.TestRig' antlr4 Java8.g4 javac LoopOne.java Java8*.java grun Java8 compilationUnit -tree LoopOne.java grun Java8 compilationUnit -gui LoopOne.java

archlinux lxc debian centos container

Create Debian8 and CentOS7 LXC containers on Archlinux host Using LXC to create Debian 8 and CentOS 7 containers require to play with AUR. In order to ease the work: # pacman -S base-devel In   /etc/pacman.conf [archlinuxfr] SigLevel = Never Server = http://repo.archlinux.fr/$arch # pacman -S lxc   arch-install-scripts netctl # pacman -S yaourt $ yaourt -S debootstrap yum This last command will pull several packages from AUR then expect some long time compiling I dont really know why, but I had to reboot to have everything working smoothly. Create a CentOS7 container # export CONTAINER_NAME=c7-00 # lxc-create  -t centos --name ${CONTAINER_NAME} -- --release 7 --arch x86_64 \                --repo YOU_CUSTOM_REPO Then edit the configuration: # nano -w /var/lib/lxc/${CONTAINER_NAME}/config Mine looks like this lxc.rootfs = /var/lib/lxc/c7-00/rootfs lxc.include = /usr/share/...

archlinux switch to bridge network

Switch from normal networking to bridged Just after installation, you need to run networking on a traditional way in order to make initial setup (some needed packages like SSH, netctl,...) "Traditional networking" is here to use the "ethN" or "enoZZZZZ" interface and assign an IP to that interface. But if you want to switch to bridged one, you need to disable that traditional setting and activate the bridged one. Traditional setting Interface name: eth0 Address assignation: static /etc/systemd/network/wired.network [Match] Name=eth0 [Network]  DNS=192.168.128.108 [Address] Address=192.168.129.148/23 [Route] Gateway=192.168.128.108 Start "systemd-networkd.service" # systemctl start systemd-networkd To enable it at boot, # systemctl enable systemd-networkd Switch to bridged setting # pacman -S netctl /etc/netctl/lxcbridge Description="LXC bridge" Interface=br0 Connection=bridge Bi...

docker network centos debian

Docker Network configuration on Debian 8 and CentOS 7 My configuration is to run a full VM and then launch several containers on it. Tha VM can be a CentOS or a Debian. As of writing, current versions are Debian 8 and CentOS 7 Debian 8 You can decide what subnet you want the containers work in. Default is "172.17.0.0/16", and the "docker0" belongs to that range. By setting up the "--bip" option in "/etc/default/docker" you can force "docker0" range: DOCKER_OPTS=" --bip=172.17.250.1/24 " CentOS 7 CentOS has a slightly different configuration layout. By setting up the "--bip" option in "/etc/sysconfig/docker-network" you can force "docker0" range: DOCKER_NETWORK_OPTIONS=" --bip=172.17.250.1/24 "

docker discovery usefull commands

Some usefull commands and settings when using docker # docker login Will create a .dockercfg file which is reusable on other hosts Usefull if you choosed a PITA username and password, like I did. # docker pull xxx # docker --name zzz run xxx:yyy Can be chortened as # docker run --name zzz [...] xxx:yyy It will pull for you. If the container zzz ever stopped # docker start zzz Show the full parameters of a container # docker inspect zzz You'll see it's a JSON file, and if you just want to print some parameters: # docker inspect --format '{{.NetworkSettings.IPAddress}}' zzz

debian packaging basic environment

When packaging with Debian, this is the minimal set of package that shoudl be installed   # apt-get install build-essential devscripts debhelper dh-make git subversion  Go to the source directory   $ mk-build-deps This will generate a "<package-name>-build-deps_1.0_amd64.deb" file Move that file one directory up   $ mv "<package-name>-build-deps_1.0_amd64.deb" ../ as root:   # dpkg -i /home/mrakotomandimby/<package-name>-build-deps_1.0_amd64.deb This will output an error (dont worry) But continue with   # apt-get install -f