xenogenesi::blog
memento
3d adt android apache2 app apt aria2 build bullet cflags chromium codeigniter debian demoscene dependencies dpkg driver emulator freeglut gcc gfx git glut htaccess javascript json kernel linux make metalink minimal mysql opengl php python raspbian realtime rpi specs template toolchain update-alternatives video wifi wordpress
Sab, 10 Giu 2017 07:54:58 +0200

Some quick note.

install create run lxc container

sudo apt-get install lxc debootstrap

create from mirror with debootstrap

sudo MIRROR=http://httpredir.debian.org/debian lxc-create -n sid64 -t debian -- -r sid -a amd64

create a container from lxc template (default jessie, the host is 64)

sudo lxc-create -t /usr/share/lxc/templates/lxc-debian -n debian

create a container from lxc debian template, pass lxc-debian argument after --

sudo lxc-create -t /usr/share/lxc/templates/lxc-debian -n debian2 -- -r stretch

-d daemon (background)

sudo lxc-start -n sid64 -d 
sudo lxc-stop -n sid64

-F foreground

sudo lxc-start -n sid64 -F

change root password

sudo lxc-attach -n sid64 passwd

list container->dhcp ip

sudo lxc-ls --fancy

mount host directory inside the container

lxc.mount.entry=/host/dir /var/lib/lxc/{container-name}/rootfs/dir none bind 0 0

create a copy of the container using overlayfs

sudo lxc-copy -s -B overlayfs -n {base-container} -N {new-container-name}

install and enable the bridge

sudo apt-get install libvirt-clients libvirt-daemon-system ebtables dnsmasq

sudo virsh net-info default

# /var/lib/libvirt/network/default.xml
sudo less /etc/libvirt/qemu/networks/default.xml

always same ip by mac addr

<dhcp>
  <range start="192.168.122.100" end="192.168.122.254" />
  <host mac="00:FF:AA:00:00:01" name="foo.example.com" ip="192.168.122.101" />
  <host mac="00:FF:AA:00:00:02" name="bar.example.com" ip="192.168.122.102" />
</dhcp>

sudo virsh net-start default
/sbin/ifconfig -a

sudo vi /var/lib/lxc/{container-name}/config

lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = virbr0
lxc.network.hwaddr = 00:FF:AA:00:00:01
lxc.network.ipv4 = 0.0.0.0/24

bridge autostart (optional)

sudo virsh net-autostart default
sudo virsh net-info default

use host br0 instead of virsh lxc-nat

configure host br0 and add eth0 to it, /etc/network/interfaces:

auto br0
iface br0 inet static
    address 192.168.2.210
        netmask 255.255.255.0
        network 192.168.2.0
        broadcast 192.168.2.255
        gateway 192.168.2.1
    bridge-ifaces eth0
    bridge-ports eth0
    up ifconfig eth0 up

iface eth0 inet manual

edit /var/lib/lxc/{container}/config:

lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0
lxc.network.hwaddr = 00:FF:AA:00:00:10
lxc.network.ipv4 = 192.168.2.20/24
lxc.network.ipv4.gateway = 192.168.2.1

references: 1 2 3 4

Categories: debian
Tags: · · · ·
Sab, 25 Mar 2017 15:21:45 +0100

Create a new vmoptions file with the tmpdir value only in a place where won’t be replaced by android-studio installation

echo "-Djava.io.tmpdir=$HOME/install/android-studio/tmp" >$HOME/install/android-studio-tmpdir.vmoptions

Create a wrapper

#!/bin/sh    
export STUDIO_VM_OPTIONS=$HOME/install/android-studio-tmpdir.vmoptions
exec $HOME/install/android-studio/bin/studio.sh

reference

Categories: android
Tags:
Sab, 04 Mar 2017 11:21:30 +0100
vi /etc/apt/sources.list
## add the deb-src repository
apt-get update

apt-get build-dep xtables-addons-source
apt-get install module-assistant xtables-addons-source
m-a unpack xtables-addons
cd /usr/src/modules/xtables-addons/
autoreconf -i -v -f
./configure --with-kbuild=/lib/modules/3.16.0-4-amd64/build
sed 's/(uname -r)/{KVERS}/' -i configure.ac

ls /usr/src/*.deb
/usr/src/xtables-addons-modules-3.16.0-4-amd64_2.6-1_amd64.deb
Categories: debian
Mer, 22 Feb 2017 14:37:09 +0100
git clone https://github.com/crosstool-ng/crosstool-ng.git
cd crosstool-ng
./bootstrap
./configure --prefix=$HOME/install/crosstool-ng
make install
echo 'export PATH="${PATH}:$HOME/install/crosstool-ng/bin"' >>~/install/crosstool-ng/crosstool-ng.env

. ./install/crosstool-ng/crosstool-ng.env
mkdir -p ~/workdir
cd ~/workdir
ct-ng list-samples
ct-ng i686-ubuntu16.04-linux-gnu
ct-ng menuconfig
nice -19 ct-ng build.4

ls ~/x-tools/i686-xg-linux-gnu/
Categories: compiler
Tags: · ·
Dom, 17 Apr 2016 20:39:35 +0200

create the external package repository

    cd ~/src/repo
    git init --bare package.git

clone the package and create the basic tree

    cd /tmp
    git clone /path/package.git
    cd package
    mkdir -p src
    touch src/file_with_classes.php
    touch composer.json

edit composer.json

    {
        "name": "vendor/package",
            "autoload": {
                "classmap": ["src/"]
            }
    }

I’m using classmap because I want more classes in the same php file, but there are more options, if using classmap remember to refresh the autoloader when classes are added/removed (composer -o dumpautoload)

and commit-push

    git commit src/file_with_classes.php composer.json
    git push

initialize composer within the new project

    cd project/backend
    composer init

edit composer.json

    "repositories": [
        {
            "type": "vcs",
            "url": "/home/user/src/repo/package.git"
        }
    ],

or, if using lan repositories shared with something like

git daemon --base-path=. --export-all --verbose --enable=receive-pack

edit composer.json

"repositories": [
    {
        "type": "vcs",
        "url": "git://192.168.1.1/package.git"
    }
],
"config": {
    "secure-http": false
},

require the package within the project

    composer require "vendor/package" "dev-master"
Categories: composer
Tags: ·
Mer, 24 Feb 2016 16:35:39 +0100

~/ttyACM0:

#!/bin/sh
exec /usr/bin/picocom -b 115200 /dev/ttyACM0

initialization:

ATZ
AT+VCID=1
ATS0=0

attach tmux:

tmux attach

detach from tmux:

Ctrl+b d

Categories: Senza categoria
Tags: · ·
Lun, 15 Feb 2016 21:31:50 +0100

PhpStorm versions older than 9.5 may have some trouble running phpunit tests:

PHP Fatal error:  Call to undefined method PHP_CodeCoverage_Filter::addFileToBlacklist()

so:

composer require --dev "phpunit/phpunit=4.*" # to install phpunit as dev dependency then...
# not working with phpunit 5
composer require --dev phpunit/php-code-coverage dev-master#b8436b000263f6d72fbad1d36890e247ce84857e

reference

Categories: Senza categoria · webdev
Tags: · ·
Mer, 30 Dic 2015 13:34:40 +0100

A friend with a WordPress website asked for help cleaning up from spam about ~400 thousands comments (about ~200M), he had guests enabled to comment.

I chosen to use python with curses (ncurses) and this pybayesantispam python module.

The curses GUI is a list with an abstract from the comment content and a column with the current spam rating, a cursor to select a comment and some key to tag it as (s)pam or (h)am, the bayesian module require some manual training, (n)ext (p)revious to browse the comments table.

The code is ugly, had a very limited time, but I been impressed how fast got a good result.

The current code include GeoIP and show the country code but isn’t used to filter the spam, in this case was an overhead, but would have been easy to add more weight factors: create a whitelist of emails from manually tagged ham, blacklist from manually tagged spam, guests users have id 0, blacklist/whitelist of ip from manually tagged comments.

py-curses-wp-spam.tgz

Categories: mysql · python
Tags: · · · ·
Mer, 23 Dic 2015 22:57:44 +0100

1) import the whole CSV as a table, look for load data infile (or just use some tool like phpMyAdmin), here will be vit_orig.

2) create a table for each column to normalize, I usually use something like an id uint(11) auto-increment primary-key, descr varchar(255)

3) populate the created tables using the import, for each table, vit_tipo in the example, use something like:

INSERT INTO vit_tipo( descr ) 
SELECT tipo
FROM vit_orig
GROUP BY tipo

4), create the new table (vit_rel_mmmist in the example) with the needed <table>_id relations, then populate it with ids regenerated finding text from the original vit_orig and the normalized created at point 2:

INSERT INTO vit_rel_mmmist (marca_id, modello_id, misura_id, indice_id, stagione_id, tipo_id)
SELECT ma.id , mo.id , mi.id , ind.id, st.id, ti.id
FROM vit_orig2
LEFT JOIN vit_marca ma ON marca=ma.descr
LEFT JOIN vit_modello mo ON modello=mo.descr
LEFT JOIN vit_misura mi ON misura=mi.descr
LEFT JOIN vit_indice ind ON indice=ind.descr
LEFT JOIN vit_stagione st ON stagione=st.descr
LEFT JOIN vit_tipo ti ON tipo=ti.descr

In the example marca, modello, misura, indice, stagione, tipo are the column names of vit_orig.

Categories: mysql
Tags: · · ·
Lun, 14 Dic 2015 12:38:25 +0100

I just started a project to create a vagrant box using buildroot, still a work in progress but already working and also with a LAMP configuration (Apache2.4/php5(fpm)/MySql/phpMyAdmin).

github/vbox-buildroot-vagrant

Categories: vagrant
Tags: · · · ·