domingo, 4 de diciembre de 2016

What to do after installing a new Ubuntu system

To be able to keep a list of all packages that we install next, edit /etc/logrotate.d/{apt,dpkg}


List of packages that have been installed in Ubuntu


From http://unix.stackexchange.com/questions/288024/how-can-i-get-a-list-of-packages-that-i-have-installed-using-apt-get

This will give you a list of packages that have been installed, in the order that they were installed:

zgrep -h ' install ' /var/log/dpkg.log* | sort | awk '{print $4}'

However, only the last 12 months of/var/log/dpkg.log* files are kept by default. To change this, edit /etc/logrotate.d/{apt,dpkg}. For example, change rotate 12 to rotate 1200 to keep the last 1200 months (100 years) worth - effectively forever, never delete the old logs.

Use dpkg to list all packages installed on a system: dpkg --get-selections



balllalalala

viernes, 18 de noviembre de 2016

Negative scanning with a DSLR camera

From https://www.flickr.com/groups/canondslr/discuss/72157620448786604


Well, I've archived over 500 shots this weekend and it's working really well. Since you asked, here's exactly how I did it :-)

* Tripod with legs barely extended, splayed wide for stability so the camera body is only about 40cm off the ground. Fully-adjustable ball head and/or horizontal centre column. I use a Manfrotto 190 with standard rubber feet.
* DSLR with a macro lens with 1:1 capability - or near enough - pointing straight down (use a spirit level on the screen.)
* Lightbox - I got a tiny lightbox (size of a small paperback book) from the clearance bin at Jessops in London. I chose a small one for cost (didn't want to waste much money on an experiment) and the fact that my apartment is small and cluttered. In fact, the box's small size turned out to be an asset during shooting, as you'll see.

As I was set up on the wooden floor, I needed so sit on the floor for extended periods so a cushion was necessary :-) If you can set up on a low coffee table so that it's comfortable to sit on a chair while you peer through the viewfinder then that may be a better solution. Don't set up on a carpet or rug - you need a hard, smooth surface. Also remember to set up somewhere fairly shady and without overhead lighting. Reflections from the surface of the lightbox or negative will ruin the shot.

Here's how it looked:

Setup

* Fiddle endlessly with the tripod to get the focus and framing exactly right - you want to capture the full frame plus a little of the surrounding area. Without a little room to maneuvre you'll spend ages framing each shot to avoid slicing off bits of the frame. If you have a lot of negatives to get through you'll regret it. On the other hand, the more megapixels you have in the actual negative the better the resolution. With ISO 100 consumer colour print film I found the grain to be quite a bit bigger than the pixels on my 8MP 20D, so a 10% margin all round was fine. This part is tedious but crucial. I used my trusty old 20D so that it could be left set up for a few days without interfering with my normal shooting. If you only have one camera body then make sure you have a quick-release plate so you don't have to fiddle with the tripod or head between sessions, it'll drive you crazy. Failing that, or if you can't leave the tripod set up in between sessions, measure the leg extensions and head height and make notes so they're easier to replicate later.

* Focus on a negative, switch to manual focus and tweak until you're sure it's a sharp as possible.

* Set the ISO to 100 and take some shots of blank and non-blank negatives to determine the required exposure very carefully. You want to 'expose to the right' but without any possibility of blown highlights in the negative itself. Some/most of the sprocket holes will blow out (and flash during histogram review) if you're doing it right. Bear in mind that the base colour of different films varies quite a lot, so be cautious and do your experimentation on one of the lightest films you have - Agfacolour for example is a light lilac colour, whereas some of the Kodacolour films are a deep orange. You won't have the patience to check the histogram with every shot, and blown highlights are impossible to recover. On the other hand, I suppose, they translate to 'blown blacks' so the effect isn't disastrous - you'll probably find the dark parts of the shot pretty ugly anyway if you've got used to digital. Anyway, I digress. Once you've calculated the correct exposure, use manual mode with the aperture on the lens set to f/8-f/16. The shutter speed will work out somewhere between 1/10 and 1s unless you have a weird lightbox. You need the small aperture for decent depth of field - some negatives are a bit curved and although you can reduce that by flattening the frames either side you risk scratching them and will slow yourself down. The curvature's correctible in post processing, unless it's really extreme. Flattening with a glass sheet, by the way, is not recommended. Not only do you reduce contrast and risk scratches, you also risk interference patterns ('Newton's rings') from the trapped air layer, which are really ugly.

* Set capture mode to Raw+smallest jpg.

* Take a shot of a blank neg and set the white balance to 'custom' and use this as the reference point. It doesn't matter for the raw shot but the thumbnail jpgs will look nicer 'out of the box'.

* If you haven't worked with film for a while I should remind you of the vulnerability of negatives to scratches and fingerprints. Individual shots can also be messed up by dust and hairs and you might not see them throught the viewfinder. Keep a rocket blower handy, keep your gear clean and wash & dry your hands regularly. Cool clothing helps reduce hand sweat too.

* Set 'Mirror Lockup' to ON in your Custom Functions menu and set the drive mode to Self Timer. On my 20D it defaults to a 2s delay which is perfect.

* Try to get the orientation of the neg strip correct before shooting. It's not much effort to flip/rotate the files on the computer but it's almost zero to get it right first time.

* Shoot a whole film and then go to the computer and do your final checks for highlights, pixel-peeping for sharpness (i.e. focus and/or shake). During shooting I found positioning the negatives to be fairly easy if I just dropped the strips onto the light box 'any old how' and then fine-tuned the position by moving and rotating the lightbox itself. It's much easier to be precise and avoids too much touching of the negative. This is the reason that a small lightbox is better - you don't want it knocking your tripod legs or needing two hands to move because you'll have one hand on the shutter most of the time. Try to ensure the edges of the negative and viewfinder frames are close to parallel - rotating shots by a degree here and a degree there is a pain.

Here's an example jpg straight from the camera:

Original jpeg

* On the computer, batch invert all the jpgs so you have 'thumbnails' that can be understood without the need for LSD, and leave the raw files alone. Resist the temptation to fiddle with the raw files before they've been properly archived and backed up.

* Be organised - shoot a whole film, then put the negs back in their sleeves and file them away in a separate place so they don't get mixed up with the yet-to-be-shot ones. Same goes for putting them in separate directories/folders on the computer. When you get in the groove you'll be churning through a 36-exp film every 3-4 minutes, so the shots quickly mount up. Shoot on two different memory cards so one is downloading while the other is being shot.

So, how to produce the finished article? Open up a raw file, invert it, adjust the exposure with reference to the histogram and then fix the colours, which will have a pronounced blue cast. I found the 'black dropper' (using the unexposed frame edge if necessary) and 'white dropper' to be sufficient for 95% of the shots, with only occasional recourse to more careful channel adjustment needed for some of my very oldest films.

Here is the finished product, processed from the raw file of the jpg above:

Finished product

Beats paying money for a big slow scanner you might never use again (and fighting with crappy software, for that matter). Let me know if you have any questions, and feel free to add your own tips.

On Macro Extension Tubes and Lenses


This is from http://photo.stackexchange.com/questions/36225/can-i-use-macro-extension-tubes-with-a-non-manual-lens:


I am new to macro extension tubes and I want to buy one but I don't have a manual lens (one where I could change the aperture manually) so I don't know if an extension tube would work with my lenses or not. Could anyone help me out with this please? Also there are macro tube ranging from $10 to more than $100. what is the difference between the cheap ones and the expensive ones?


    

2 Answers


Yes you can.
The more expensive extension tubes has camera-lens connections that let you control aperture.
With the cheaper tubes you still have options:
  1. Obviously, you can use whatever aperture the lens uses when not connected (for Canon it's wide open, for Nikon it's fully stopped down).
  2. For Canon, connect the lens to the camera (without the tube), set your aperture, press the DOF preview button, with that button pressed detach the lens - the lens will now stay in that aperture until you reconnect it to the camera.
  3. For Nikon, the aperture is operated by a small mechanical lever, you can set an aperture by using something sticky to fix the lever position - make sure you use something that peels off completely and does not leave residue behind.

lunes, 24 de octubre de 2016

CAD 3D, figures orgàniques, etc


Una barreja de openscad i python
https://github.com/SolidCode/SolidPython

Corbes i superfícies NURBS. Relacionat amb corbes de beziers.

Python i Rhino. Rhino és un software comercial que sembla potent
https://en.wikipedia.org/wiki/Rhinoceros_3D
Buscar "Python Rhinoceros". Surt tutorial guapo

Algorisme per suavitzar objectes
https://en.wikipedia.org/wiki/Catmull%E2%80%93Clark_subdivision_surface

Objectes guapos fets amb Rhinoceros
http://www.shapeways.com/product/4KM9MDWCH/klein-bottle?optionId=161525&li=related-items-solr

El blog que ha inspirat aquestes cerques. Barreja openscad i altres
http://kitwallace.tumblr.com/post/134738715634/catmull-clark-surface-smoothing

Un tutorial de openscad 3D
http://www.tridimake.com/2014/09/how-to-use-openscad-tricks-and-tips-to.html

viernes, 12 de agosto de 2016

Using rsync to copy a movie and start watching inmediately

Sometimes I want to watch a movie that is on my home server. With standard copy you have to wait for the whole file to be transferred.

The following bash script does it:

#!/bin/bash
rsync -aP --inplace user@x.y.z:/home/mydir/"${1// /\\ \\}" .


Usage
myscript 'filename perhaps with spaces in it'

Explanations
--inplace makes the file inmediately accessible for playing.
The strange items instead of $1 escape spaces in the filename.
Do not forget the trailing dot '.'

martes, 9 de agosto de 2016

WiFi disabled by hardware switch

On my compaq presario cq60 laptop, WiFi gets sometimes off and there is no way to reactivate it: the network manager keeps saying "WiFi disabled by hardware switch". The hardware button does nothing. In fact, when working correctly the hardware LED is sometimes red, sometimes blue but keeps working!

This is probably a driver issue.
Things to try

rfkill list all
rfkill unblock all

But these do not work for me.

What does work is shut down the PC and, while restarting, press thousands of times the WiFi button.

martes, 21 de junio de 2016

Network Manager CLI

nmcli device list




OpenVPN howto

  1. Download the OpenVPNConfigFile.ovpn. Note that you can rename the file to anything you like.
  2. Move the oven file to /etc/openvpn
  3. cd /etc/openvpn folder and enter sudo nano yourserver.txt
    your_server_user_name
    your_server_passowrd
    
    Save and Close
  4. sudo nano OpenVPNConfigFile.ovpn
    Find auth-user-pass and add yourserver.txt next to it so that it becomes
    auth-user-pass yourserver.txt
    
    This will allow you to skip entering your credentials everytime you start openvpn connection
  5. Rename OpenVPNConfigFile.ovpn to OpenVPNConfigFile.conf
    sudo mv OpenVPNConfigFile.ovpn OpenVPNConfigFile.conf
    
  6. sudo nano /etc/default/openvpn
    Uncomment AUTOSTART="all"
  7. sudo service openvpn start
    You should see a message saying that you are connected. The connection will be established every time you start your computer.


> On the server machine i run the init script and openvpn starts up fine. 
> On the client machine i do the same but get prompted for a private key
> password.  I put in the password and the connection is built and things
> work fine.  
> 
> Why am i getting this password prompt on one machine and not the other. 
> I'm assuming that it's the tls-auth that is asking for the password, is
> that correct? 
> 
> If i want the vpn to come up automatically if the machine reboots or
> power cycles or whatever, what do i have to do?
> 

You should check, if your key is password protected. For security
reasons this is very useful - you need to have the key and you need to
have knowledge of the passphrase to authenticate yourself against the
server.

If you want to remove the passphrase you can use the openssl command as
follows:
"openssl rsa -in client.key -out client.key"

I hope this is helpful
leh

domingo, 1 de mayo de 2016

Climber Model

Hi ha alguna font, però no tot suma el 100% https://www.quora.com/Whats-the-weight-distribution-in-the-average-human-body






75
Trunk 50.80% 50.6 38.1
Thigh 9.88% 9.88 7.41
Head 7.30% 7.3 5.475
Lower leg 4.65% 4.65 3.4875
Upper arm 2.7% 2.7 2.025
Forearm 1.60% 1.6 1.2
Foot 1.45% 1.45 1.0875
Hand 0.66% 0.66 0.495




78.84 59.28



He trobat això: http://www.humanics-es.com/ADA304353.pdf
i això http://people.unica.it/brunoleban/files/2012/04/Drills-Contini-1966-Body-Segment-Parameters.pdf

GoPro

Software lliure per controlar la GoPro, aquí.

Manual de la GoPro Hero3+ silver, aquí.

viernes, 15 de abril de 2016

Dual Monitor in LXDE

La clau està en instal·lar el arandr. Informació general aquí.

I created two scripts in the .screenlayout/ directory with the help of ARandR:



~/.screenlayout$ cat single.sh 
#!/bin/sh
xrandr --output LVDS1 --mode 1024x600 --pos 0x0 --rotate normal --output VGA1 --off
lxpanelctl restart

~/.screenlayout$ cat dual.sh 
#!/bin/sh
xrandr --output LVDS1 --mode 1024x600 --pos 0x0 --rotate normal --output VGA1 --mode 1920x1080 --pos 1024x0 --rotate normal
lxpanelctl restart

adding the string "lxpanelctl restart" by hand (ARandR doesn't do it). Then, in the file
~/.config/openbox/lxde-ec.xml
I added the following lines between two </keybind> lines:


Code:
  </keybind>
  <keybind key="W-2">
  <action name="Execute">
  <command>sh ~/.screenlayout/dual.sh</command>
  </action>
  </keybind>
  <keybind key="W-1">
  <action name="Execute">
  <command>sh ~/.screenlayout/single.sh</command>
  </action>
</keybind>

so that using <super(windws)><1> and <super(windws)><2> I can switch between single and dual monitor configuration.

I hope this will be useful for others!

martes, 12 de abril de 2016

Anomenar fitxers correlativament

Tenim una carpeta amb fitxers a.png, bbbb.png cc-cccc.png i volem tenir-los com a 001.png, 002.png, 003.png

#!/bin/bash

i=1;
for file in *.png
do
  a=$(printf "%03d" $i)
  echo "$file" "$a.png"
  mv "$file" "$a.png"
  ((i++))
done

lunes, 11 de abril de 2016

PDF que no es mostra correctament (non-embedded fonts)

Un fitxer pdf no es mostra correctament perquè hi ha una font que no està embedded. Amb aquesta ordre ghostscript pot reparar el fitxer. Una explicació molt acurada, aquí.


gs -o repaired_file.pdf -dPDFSETTINGS=/prepress -sDEVICE=pdfwrite file.pdf

viernes, 8 de abril de 2016

Eines mikrotik

Safe mode

Safe mode is entered by pressing [CTRL]+[X]. To save changes and quit safe mode, press [CTRL]+[X] again. To exit without saving the made changes, hit [CTRL]+[D]

sábado, 2 de abril de 2016

Utilitats guifi

Baixar una pàgina web i mostrar les adreces IP que hi surten, ordenades. És un curl i dos pipes:

curl http://guifi.net/ca/MNBufalvent | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'  | sort -t . -k 3,3n -k 4,4n

i si volem eliminar duplicats, afegim -u al darrer sort:
curl http://guifi.net/ca/MNBufalvent | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'  | sort -u -t . -k 3,3n -k 4,4n

Mostrar les adreces IP d'un fitxer de text, ordenades com toca:

grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' bufalvent.txt | sort -t . -k 3,3n -k 4,4n 

Veure el tràfic que passa per l'interface antena-router

tcpdump -nnvvS




ip route add 192.168.88.0/24 dev eth0 src 192.168.88.11
ip route
ip address

Download pictures from web server

Download all pics named pic01-pic16:

wget -nd http://www.zzz.com/path/pic{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16}.jpg

Rename these pictures from pic01 to name_pic01:
rename -n -v 's/(pic.)/name_$1/' *.jpg


Convertir fitxers ODT en PDF

Existeix l'opció manual de fer-ho. Però si n'hi ha un munt, això és útil:

for file in *.odt; do unoconv -f pdf "$file"; done

Truecrypt Ubuntu 14.04

Montar un fitxer truecrypt amb ubuntu 14.04 o posteriors, que ja no tenen l'aplicació

sudo losetup -f
---> /dev/loop0
sudo losetup /dev/loop0 DATA.CRYPT
sudo tcplay -m DATA.CRYPT -d /dev/loop0
---> passphrase  (entrar password)
---> All ok!

Manipulacions amb gràfics


Canviar colors de captures de pantalla de l'oscil·loscopi

converteix el negre en blanc
mogrify  -fill "#ffffff" -opaque "#000000" tek00016.png  

converteix el blau fosc en blanc 
mogrify  -fill "#ffffff" -opaque "#394994" tek00016.png 

converteix el blau clar en blanc
mogrify  -fill "#ffffff" -opaque "#5286e7" tek00016.png  

Convertir pdf en altres

Convertir un pdf a tiff amb una determinada densitat en dpi
convert -units PixelsPerInch -density 300 a.pdf a.tiff 

Convertir un pdf a png amb una densitat determinada i conservant el fons blanc
convert -flatten -density 600 entrada.pdf sortida.png 

Convertir svg en altres

Convertir un svg a escala de grisos
inkscape -f Figura.svg --verb EditSelectAll --verb org.inkscape.color.desaturate.noprefs --verb FileSave --verb FileQuit   

Convertir tots els svg d'un directori a png
for file in *.svg ; do convert "$file" "${file%.*}.png" ; done

Script svg2png: convertir un fitxer svg a png
#!/bin/sh
NAME=`echo "$1" | cut -d'.' -f1`
EXTENSION=`echo "$1" | cut -d'.' -f2`
inkscape $NAME.svg --export-area-page --export-dpi=300 -e $NAME.png



Script svg2pdf: convertir un fitxer svg a png
#!/bin/sh
NAME=`echo "$1" | cut -d'.' -f1`
EXTENSION=`echo "$1" | cut -d'.' -f2`
inkscape $NAME.svg -D -A=$NAME.pdf


Fer una còpia de fitxers en baixa resolució

Agafa tots els fitxers d'un directori, els canvia de resolució (dimensió màxima 800). Els nous fitxers tenen com a nom el prefix r_ més el nom original del fitxer. Útil per passar fotos a un marc digital, per fer thumbnails...
for file in `ls`; do convert -resize 800x800 -quality 80 $file r_$file; done

Canviar el tamany d'uns fitxers

Canvia de resolució (dimensió màxima 1200, respectant la rel·lació d'aspecte) tots els fitxers d'un directori
mogrify -resize 1200x1200 *