User Tools

Site Tools


start

This is my technical blog where I post about various stuffs. Take a look at my resume if you want to know more about me.

GLSL demo - shadertoy

Shadertoy clone done in C.

Check it on GitHub : https://github.com/MaximeMorel/glsl-demo

Here is an example shader based on iq work.

Screenshots

Video

On the second video, I show with a colored scale (blue - red) the number of iterations per pixel. (blue : less, red : more)

Secure Surfing

Here is multiple methods to have a secure internet connection :

All these methods can be set up on a Raspberry Pi. Let's assume it can be accessed on domain.net on any ports.

SSH

You need a SSH access on the Pi and an opened port (here, 8080) :

ssh user@domain.net -D 8080

This command opens SOCKS server. You can use it to tunnel your traffic.

Firefox usage

Edit → Preferences → Advanced → Network → Connection → Settings…

Then in the URL bar, go to : about:config

And change “network.proxy.socks_remote_dns” to true. (There is a graphical button for this in Firefox nightly 30.xx next to SOCKS radio buttons)

OpenVPN

I followed this wiki : https://wiki.archlinux.org/index.php/Openvpn

I didn't used everything. I will explain my procedure later.

Once the server is running, generate keys for your clients.

(see this : https://wiki.archlinux.org/index.php/Create_a_Public_Key_Infrastructure_Using_the_easy-rsa_Scripts)

./build-key client-name

Copy for “client-name” :

  • ca.crt
  • ta.key
  • client-name.crt
  • client-name.key

And create client-name.ovpn file :

client
dev tun
proto udp
remote domain.net 1194
resolv-retry infinite
nobind
user nobody
group nobody
persist-key
persist-tun
ca ca.crt
cert client-name.crt
key client-name.key
ns-cert-type server
tls-auth ta.key 1
comp-lzo
verb 3

Put these 5 files in the same folder and load client-name.ovpn in any OpenVPN client :

Privoxy

Install Privoxy :

pacman -S privoxy

Configure it to fit your needs by editing “/etc/privoxy/config”. I only changed “listen-address” parameter. By default it will listen to localhost on port 8118.

Run Privoxy :

systemctl enable privoxy.service
systemctl start privoxy.service

Chromium usage

chromium --proxy-server="domain.net:8118"

Android usage

https://play.google.com/store/apps/details?id=org.proxydroid

In the app, set :

  • Host : domain.net
  • Port : 8118
  • Proxy Type : HTTP

It can be configured to auto connect when using 3G or WIFI connection.

A lot more stuffs about it here : https://wiki.archlinux.org/index.php/Privoxy

ownCloud

Let's assume your ownCloud instance is accessible on https://domain.net/owncloud.

As always, there is still Archlinux wiki : https://wiki.archlinux.org/index.php/Owncloud

Android sync

Here, with an account “user” :

Calendar sync

Use this app : https://play.google.com/store/apps/details?id=org.dmfs.caldav.lib

Add a caldav account and set remote address (with a calendar named “calendar_name”) :

https://domain.net/owncloud/remote.php/caldav/calendars/user/calendar_name

Contacts sync

Use this app : https://play.google.com/store/apps/details?id=org.dmfs.carddav.sync

Add a carddav account and set remote address (with an address book named “addressbook_name”) :

https://domain.net/owncloud/remote.php/carddav/addressbooks/user/addressbook_name

Update

Better using DAVdroid now.

If https is used with a self signed certificate, CAdroid can be used too.

Backup

Line filter JS

A little JS experiment allowing to filter curves drawn by mouse.

Try to draw something (it should be a loop, or strange things can happen) and hit “Draw FT”.

http://www.mmorel.eu/line-filter

Screenshots

  • raw points
  • raw curve
  • filtered curve

https://github.com/MaximeMorel/LineFilterJS

HTML5 video

Memo for encoding video in various formats for HTML5.

-vb parameter should be adapted if quality is too low (video bitrate).

mp4

ffmpeg -i video_src.format -vcodec libx264 -preset slow -crf 24 video.mp4

ogv

ffmpeg -i video_src.format -vb 800k -vcodec libtheora -g 30 video.ogv

webm

ffmpeg -i video_src.format -vcodec libvpx -vb 400k -maxrate 8000k -bufsize 1000K -minrate 10k -qmin 3 -qmax 30 -rc_lookahead 16 -keyint_min 0 -g 360 -skip_threshold 0 -level 116 -preset slow video.webm

HTML

<video width="1280" height="720" controls="controls" >
    <source src="video.ogv" type="video/ogg">
    <source src="video.webm" type="video/webm">
    <source src="video.mp4" type="video/mp4">
</video>

Usage in Dokuwiki

Modification of html5video plugin allowing usage of multiple video formats :

{{ videos:vid.webm|videos:vid.ogv|videos:vid.mp4|320x240|loop }}

https://www.dokuwiki.org/plugin:html5video#development

https://github.com/MaximeMorel/dokuwiki_plugin_html5video

Email backup

Here is some details about my email backup system hosted on my Raspberry Pi. The purpose of this backup system is to allow access to this backup with IMAP.

I use dovecot as IMAP server and mbsync to sync IMAP account on the Pi.

First, install needed packages, Archlinux way :

pacman -S dovecot
yaourt -S isync-git

Dovecot setup

I changed a few things : protocols served, listen address, ports

vim /etc/dovecot/dovecot.conf

Only enable IMAP :

protocols = imap

Disable ipv6 :

listen = *

vim /etc/dovecot/conf.d/10-master.conf

Ports can be changed in “inet_listener imap” and “inet_listener imaps” sections if needed.

Run the service :

systemctl enable dovecot.service
systemctl start dovecot.service

Now we will suppose you are logged with “user” on “domain.net”. It means your IMAP account will be accessible through your dovecot server with email “user@domain.net”.

Maildir setup

Create a directory to put mails in (Maildir format) :

mkdir -p ~/.mail/INBOX
cd ~/.mail

Next, create a mbsync config file for each account you want to sync. In this example, we use login@yahoo.fr :

vim .mbsyncrc1

################################################################################
IMAPAccount login@yahoo.fr
Host imap.mail.yahoo.com
User login
Pass pass
UseIMAPS yes
CertificateFile /etc/ssl/certs/ca-certificates.crt

IMAPStore login@yahoo.fr-remote
Account login@yahoo.fr

MaildirStore login@yahoo.fr-local
Path ~/.mail/INBOX/login@yahoo.fr/
#Inbox ~/.mail/INBOX/login@yahoo.fr/INBOX

Channel login@yahoo.fr
Master :login@yahoo.fr-remote:
Slave :login@yahoo.fr-local:
Patterns *
Create Both
SyncState *
################################################################################

“Inbox” command is commented here. This commands helps mbsync by telling it where is INBOX, because with some providers, it can't find it. Here, yahoo.fr doesn't need it.

Providers needing “Inbox” command :

  • gmail.com
  • free.fr
  • orange.fr

Create directories to store mails about login@yahoo.fr :

mkdir -p INBOX/login@yahoo.fr/{cur,new,tmp}

cur, new and tmp are used to have a valid Maildir folder.

You can reiterate by creating another mbsync config file for another email account.

Ex : .mbsyncrc2, .mbsyncrc3, …

You can check Archlinux wiki page for some details about mbsync : https://wiki.archlinux.org/index.php/Isync

Once your mbsync config files are done, write a little script to update everything :

vim mbsync.sh

#!/bin/bash
cd ~/.mail
for i in $(ls .mbsyncrc*)
do
        mbsync -c ~/.mail/$i -a
done

Your logins and passwords are stored in plain text in the config file, so protect it by making it readable only by your user :

chmod 600 .mbsyncrc*

Update with cron

crontab -e

07,22,37,52 * * * * ~/.mail/mbsync.sh

Here, it is updated every 15 minutes. I use these strange values to avoid running the same time of another cron job.

Access with Thunderbird

Add an email account using “user@domain.net” as email, user as login, domain.net as IMAP server. You have to put a dummy smtp server to let Thunderbird enable the creation of the account.

Once it's ok, you should see all your emails in subdirs like “login@yahoo.fr” in the Inbox.

Remember, as is, it can only be used to receive emails. And every action done on “user@domain.net” is synced. So if you delete some emails, they will be removed from the master server (in this example, yahoo.fr) !

Game Dev Party : Les 5 gardiens

Here is the game we developed at the Game Jam 5.

It's a webapp done with html5 and javascript (webgl using three.js).

Here is a live demo here : Les 5 gardiens

Screenshots

Video

Bash and Linux tips

I put some tips and stuffs about bash and linux here.

Find all extensions in $folder :

find $folder -type f -name "*.*" | awk -F. '!a[$NF]++{print $NF}'

Autosuspend script for server :

Batch subtitle download :

To have fr and en subtitles :

for f in *.avi; do subdl --lang=fre "$f" ; done
for f in *.avi; do subdl --lang=eng,fre "$f" ; done

Pictures and videos encode script :

Keyboard layout in gdm

Edit Option “XkbLayout” in /etc/X11/xorg.conf.d/10-evdev.conf :

Section "InputClass"
        Identifier "evdev keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"

        Option "XkbLayout" "fr"
EndSection

Cloth simulation

This is a simple cloth simulation in C++, OpenGL, GLSL. This is a spring-mass system with some eye-candy stuffs like per pixel lighting, shadow map. It also uses OpenMP for parallelization in critical parts.

Video

In this video, there is a wind force.

In this one, one attach point of the cloth is moved by the user.

Sublime Text

As a memo, here is my Sublime Text config file :

// Sublime Text config file : Preferences -> Settings - User
{
    "color_scheme": "Packages/Color Scheme - Default/Sunburst.tmTheme",
    "ensure_newline_at_eof_on_save": true,
    "font_face": "Consolas",
    "font_size": 11,
    "move_to_limit_on_up_down": true,
    "rulers":
    [
        80
    ],
    "shift_tab_unindent": true,
    "translate_tabs_to_spaces": true,
    "trim_trailing_white_space_on_save": true,
    "file_exclude_patterns": [".tags", ".tags_sorted_by_file", ".gemtags"]
}

To use ctags, first install “Package control” using this : https://sublime.wbond.net/installation

Then do :

  • type : ctrl+shit+p
  • type : ctags
  • press enter
  • it's installed !

Then, in your project, you can use ctrl+shit+p and filter with “ctags” to see available commands (like rebuild tags). After, it is possible to use alt+shift+s to find any symbol in the project.

Augmented Reality

Coming soon…

Munin

Munin installation on archlinux

It follows mostly archlinux wiki. Just adding some tweaks.

First tweak is to change permissions to /var/log/munin. Else, munin-cgi-* can't write logs there and hangs.

chmod 777 /var/log/munin

Maybe lesser permissions could be used, but I should take a look for that. (I think multiple users write to this folder : root, munin, http)

Next tweak is for cgi graph. Same permission problem : user http needs write access to /var/lib/munin/cgi-tmp/ :

chown -R http:http /var/lib/munin/cgi-tmp

Munin installation on debian

First, install needed packages :

apt-get install munin munin-node

Edit munin config file to set the hostname of the machine to monitor :

vim /etc/munin/munin.conf

# a simple host tree
[localhost] -> change to [yourhostname]
    address 127.0.0.1
    use_node_name yes

Configure nginx :

vim /etc/nginx/sites-available/munin

Here is the config :

server {
    server_name vhost.org;
    #listen 80;
    root /var/cache/munin/www/;
    index index.html;

    location / {
        try_files $uri $uri/ /index.html;
    }
    
    # TODO : enable cgi graph
}

Enable the site :

ln -s /etc/nginx/sites-available/munin /etc/nginx/sites-enabled/

Restart services :

service php-fastcgi restart
service nginx restart

Enable munin service at boot : (TODO)

update-rc.d ...

Start service to test now without reboot :

service start munin
service start munin-node

Data gather is done using cron every 5 minutes

smartctl plugin fix

smartctl patch : /usr/share/munin/plugins/smart_:127
-smart_values[string.replace(smart_attribute[1],'-','_')]={"value":smart_attribute[3],"threshold":smart_attribute[5]}
+smart_values[string.replace(smart_attribute[1],'-','_')]={"value":smart_attribute[9],"threshold":smart_attribute[5]}

Thresholds should be adjusted.

Plugins management

Plugins in munin are activated by putting a symbolic link in /etc/munin/plugins/

It can be verified with this :

ls -l /etc/munin/plugins

To disable a plugin, remove the symbolic link.

Ex : to remove entropy plugin :

rm /etc/munin/plugins/entropy

To enable it again :

ln -s /usr/share/munin/plugins/entropy /etc/munin/plugins/

Open Destruction Derby

This game is a 1995 Destruction Derby clone. The main goal is to crush into opponents cars and make them spinning to earn points. Or you can simply destroy the cars or try to survive in the arena ! Like in the original game, cars deform and there is smoke and tire tracks everywhere !

Everything is pure C and OpenGL (all below OpenGL 2.0, mostly vertex arrays). Physics interactions are self made using a lot of dot products and squared distances. Car models are homemade using blender and textures using Gimp.

Screenshots

Video

Download

DCS headtracker

Here is my modification of a headtracker for DCS. It's working with freetrack and opentrack.

You can check it out on github : https://github.com/MaximeMorel/DCS-headtracker

Tags

start.txt · Last modified: 2015/06/19 23:39 by popux