samedi 29 décembre 2012

Emacs encoding pb w/ macosx

Using : GNU Emacs 22.1.1 I had a utf-8 file, opened by default in iso-latin-1.
C-x  r utf-8 
(via : https://discussions.apple.com/message/6319077#6319077 )

vendredi 30 novembre 2012

LaTeX tip & tricks

I recently discovered the "trim" option of the includegraphics command :
\includegraphics[trim=Wcm Xcm Ycm Zcm]{image-file}
%left bottom right top
Will remove Wcm on the left, Xon the bottom side, Ycm on the right side, and Zcm on the top side. Be careful when trim AND angle are used at the same time !

LaTeX template pour document littéraire

Having to edit a document of a friend studying "art history" and "english language", I created this LaTeX template after some research on the bibliography styles needed for those fields. The bib style needed was : MLA. The default MLA install of LaTeX didn't match what was expected, and I found mla-good.bst. You can download it here : http://www.reed.edu/cis/help/latex/images/mla-good.bst.zip or here : http://pastebin.com/bBg7CUkM (and others styles : http://www.reed.edu/cis/help/latex/bibtexstyles.html).
%% LaTeX Template for littérature student, using article class and mla-good.bst 
%% by : Corentin Mehat (30 Novembre 2012)

%% compile it using :
%%    "rubber -d "
%% or "pdflatex ; bibtex ; pdflatex "

\documentclass[12pt, a4paper]{article}%  font, a4paper : paper size
\usepackage{fullpage} % reduce the default margin

\usepackage[utf8]{inputenc} % encoding : UTF8
\usepackage[T1]{fontenc} % fonts
\usepackage{lmodern} % to avoid the use of bitmap fonts.
\usepackage{amsmath} % math for "XV$^{ème}$ siècle"
\usepackage{amssymb} % math

\usepackage{graphicx} % Deal with external images (cf. template code at the end)

%\usepackage{setspace} % spacing lines
%\doublespacing
%\onehalfspacing
%\setstretch{baselinestretch}



\usepackage[english]{babel} % English hyphenation
%\usepackage[french]{babel} % French hyphenation

\usepackage[round, authoryear, sectionbib]{natbib} % Deal with the references & Bibliography

% To generate the bib file on the first compilation of this file. Run BibLaTeX over it after, and recompile
%code in the next begin/end must be a well formed bibtex file
\begin{filecontents}{outputed-biblio-file.bib}
\end{filecontents}


% For  "TODO" notes : \todo{...} or \todo[inline]{...}
\usepackage[disable]{todonotes} %disable
%\usepackage[french,colorinlistoftodos]{todonotes} %enable


%
\usepackage[a4paper,colorlinks,plainpages=false,pdftex,backref]{hyperref}
 \hypersetup{
     unicode=false,          % non-Latin characters in Acrobat’s bookmarks
     pdftoolbar=true,        % show Acrobat’s toolbar?
     pdfmenubar=true,        % show Acrobat’s menu?
     pdffitwindow=true,      % page fit to window when opened
     colorlinks=true,        % false: boxed links; true: colored links
     linkcolor=blue,         % color of internal links
     citecolor=green,        % color of links to bibliography
     filecolor=magenta,      % color of file links
     urlcolor=cyan,          % color of external links
     linktocpage=true,       % make page number, not text, be link in TOC, LOF and LOT
     breaklinks=true,        % allow links to break over lines
     pdfkeywords={keywork1, keyword2}, % list of keywords
     pdftitle={Document Title (not printed, but in the pdf file)},
     pdfauthor={Author of the document (not printed, but in the pdf file)},
     pdfsubject={Subject of the document (not printed, but in the pdf file)}
 }

\title{Title}
\author{author}
\date{\today} %

% % % % % % %%% BEGIN DOCUMENT
\begin{document}

%\newcommand{\test}{THIS IS A TEST} %macro/command example


\maketitle
%\tableofcontents
\begin{abstract}
You can write your introduction / Abstract / Résumé of the doc here.
\end{abstract}

Write your document here

% Organise your document with : (put the section title into the '{}' )
%\section*{} % will not be numbered
%\section{} % will be numbered
%\subsection*{}
%\subsubsection{}



\begin{figure}
\begin{center}
%\includegraphics*[trim= 0cm 0cm 0cm 0cm, angle=0,scale=0.45]{file-name}
\caption{cartel of the image}
\label{fig:a-unique-name} %in the text : \ref{fig:a-unique-name}
\end{center}
\end{figure}

% % % % BIBLIOGRAPHY
\newpage 

\renewcommand\refname{Bibliography} % Change the bibliography heading title

% Use the "mla-good.bst" style file for bibliography (same directory, or installed where it should)
\bibliographystyle{mla-good} % for MLA bibliography style
\bibliography{outputed-biblio-file} % Use the outputted file for the ref.

\nocite{*} %include all refs from the file (not only the one \citeX{key}

\end{document}

mercredi 28 novembre 2012

Show full path in Finder

In the Terminal.app (default cmd line in macosx) :
defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES 
(Source : http://www.tuaw.com/2008/12/05/terminal-tips-enable-path-view-in-finder/ )

jeudi 12 juillet 2012

Mettre un stamp sur une image

Avec convert (de Imagemagick), fonctionne bien avec la version :

$convert --version
Version: ImageMagick 6.5.7-8 2009-11-26 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
Features: OpenMP


#!/bin/bash
# stamp timbre A_marquer Img_finale

# (c) 2007-2010 by C.M.
# under the GPL License

# prendre deux fichiers d'images
# l'un étant un "sceau" et l'autre une photo
# et marquer la photo du sceau, en bas à droite (ou gauche)
# Image timbre
SCEAU="$1"
# Image à marquer
PIC="$2"
# Fichier de sortie
OUT_IMAGE="$3"
# Proportion du timbre par rapport à l'image
SCALE="/ 20"
# Texte ajouté sous le timbre
TEXTE=""


# dimensions de l'image à marquer
width_pic=`identify -format %w "$PIC"`
height_pic=`identify -format %h "$PIC"`

# dimensions du sceau
width_sceau=`identify -format %w "$SCEAU"`
height_sceau=`identify -format %h "$SCEAU"`

# dimensions auxquelles réduire le sceau
stamp_w=$(( $width_pic $SCALE * 2))
stamp_h=$(( $height_pic $SCALE))



Install NetBSD via clef USB


Voici le challenge :


créer une clef usb bootable en NetBSD, en n'ayant qu'une seule clef dispo et pas de machine netbsd sous la main. Le principal problème est de formater la clef USB dans le bon format (et pas de mkfs dispo pour ce systeme de fichier BSD)


Solution trouvée :


booter netbsd-Live en virtualisé dans Qemu pour transférer vers le disque dur virtuel de Qemu les fichiers à copier sur la clef usb, puis formater la clef usb et y remettre les fichiers de boot.

Nettoyer les metadonnées d'images

j'ai pour cela trouvé jhead :
jhead -purejpg [img.jpg]
jhead is used to display and manipulate data contained in the Exif header of JPEG images from digital cameras. By default, jhead displays the more useful camera settings from the file in a user-friendly for‐ mat. jhead can also be used to manipulate some aspects of the image relating to JPEG and Exif headers, such as changing the internal timestamps, removing the thumbnail, or transferring Exif headers back into edited images after graphical editors deleted the Exif header. jhead can also be used to launch other programs, similar in style to the UNIX find command, but much simpler.

Command(s) of the day

Some colleagues started putting commands on the white-board every X days under
  • comm compare two sorted files line by line
  • paste merge lines of files
  • colordiff diff, with colors
  • colorgcc
  • pgrep look for a process name
  • pkill kill processes by name, not by pid
  • ...

lundi 21 mai 2012

Research Social Networks

Social Networks for people doing research : Mendeley seems to be based on dealing with your PDF collection. Alternative Android application : http://blog.mendeley.com/tipstricks/android-on-mendeley-an-app-guide/ Researchgate http://www.researchgate.net/ Academia.edu http://academia.edu/

lpoptions, default printing options for *nix (with cups)

The default command to send printing jobs under linux is "lpr", and all the commands that comes with it. To configure some options by default, for example for my office computer, I have to set them in the file : ~/.cups/lpoptions. This is what I have :
Default The_Printer_Name Binding=LeftBinding KMDuplex=Double StapleOption=1StapleLeft StapleSet=True
This will hence configure those option by default.
  • Binding : by default, put the binding ("reliure" (fr) ) on the left
  • KMDuplex : by default, print in duplex mode ("recto-verso" (fr)).
  • StapleOption : by default, staple once, on the left corner
  • StapleSet : by default, staple all documents.
NB 1 : Of course, I can modify all those options before printing, for example in acrobat-reader (acroread), or okular, or evince, or whatever I'm using. NB 2 : Those options may (or should I say "will") vary from one brand to another... (This is for a "KONICA MINOLTA bizhub C360 - 0" printer)

vendredi 11 mai 2012

Mac applications

Nouvel ordinateur : un mac book pro, avant qu'ils ne fassent sauter le lecteur cd/dvd. Première étape : savoir quelles sont les applications nécessaires pour que ça tourne bien. J'en suis pour l'instant à cette liste, compilant les conseils de différentes personnes : TeX/LaTeX & bib. & cie.
* textmate (eq. emacs) (Payant)
* bibdesk (pour ta biblio)
* skim (pour lire/annoter des pdfs, pour les PDF et DVI automatiquement mis à jour en cas de génération à partir de LaTeX) (gratuit)
* TexShop
* TeXnicle (?)
* MacTeX (pour avoir LaTeX),
* Latexit (si jamais il te prend l'envie de vouloir générer des équations au format latex et de les insérer (glisser déposer) comme des images dans un document rédigé avec autre chose que Latex)

* Papers (payant) pour la gestion de tes articles scientifiques

* ITerm2

* Carbon Emacs (avec .emacs adapté)
* Terminal.app
* Gnu utils (car je n'aime pas les BSD utils),
(pour avoir GCC, mais le GCC que j'utilise est une version que j'ai compilée à partir des sources),
* Xcode (pour avoir GCC, mais le GCC que j'utilise est une version que j'ai compilée à partir des sources)

* macports pour le monde unix.
* fink (http://www.finkproject.org/)

* omnigraffle (pour faire des schémas vite et bien) (Payant)
* keynote (eq. powerpoint) (Payant)

* 1password combiné avec
* dropbox,
* cyberduck (pour le ftp/etc)
* Fugu comme client SFTP/SSH


* vlc
* adium pour les IM
* TorBrowser parce que

* Activity Monitor.app
"Je conseille fortement de créer un dossier dans / pour installer les applications compilées par soi-même, car si elles sont mises dans les dossiers qui sont présents par défaut, ils sont virés en cas de réinstallation ou mise-à-jour du système !"

Ubuntu modifications

Nouvelle ressource de modifications à apporter à Ubuntu pour une plus grande facilité d'installation. http://modifyubuntu.com/12.04

mercredi 4 avril 2012

MPlayer to record live streaming video / audio

All you need to record a live stream from the web is MPlayer. Use the -dumpstream argument to capture a MMS, ASF or Live WMV stream to a file called stream.dump. For example:
mplayer -dumpstream mmsh://streamer3.carnation.hu/mtvonlinem2?MSWMExt=.asf
will create a stream.dump file that you can later rename to my_recorded_stream.wmv. Note: this will not work with Flash-powered streams.
(from : http://tips4linux.com/use-mplayer-to-record-live-streams-from-the-internet/ )

jeudi 15 mars 2012

Security tools

Sans revenir sur la possibilité très élevée que le fameux Anon-os soit en fait plein de chevaux de troie (trojan), notons avec intérêt les quelques softs qui sont livrés avec :
Here some of preinstalled apps on Anonymous-OS: - ParolaPass Password Generator - Find Host IP - Anonymous HOIC - Ddosim - Pyloris - Slowloris - TorsHammer - Sqlmap - Havij - Sql Poison - Admin Finder - John the Ripper - Hash Identifier - Tor - XChat IRC - Pidgin - Vidalia - Polipo - JonDo - i2p - Wireshark - Zenmap - ...

jeudi 16 février 2012

signaux et terminaux, stty

A la base, une simple question de la part d'une collègue : comment envoyer un SIGQUIT dans un terminal sous mac OS.
Une rapide recherche sur le net donne comme réponse "^\", contrairement à linux où c'est usuellement "^d" qui sert à cela.

Comment configurer cela, comment trouver cela ?


STTY(1)                          User Commands                         STTY(1)
NAME
       stty - change and print terminal line settings

SYNOPSIS
       stty [-F DEVICE | --file=DEVICE] [SETTING]...
       stty [-F DEVICE | --file=DEVICE] [-a|--all]
       stty [-F DEVICE | --file=DEVICE] [-g|--save]

DESCRIPTION
       Print or change terminal characteristics.

Qui chez moi par exemple (Ubuntu) me donne :
 
$ stty -a
speed 38400 baud; rows 40; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?;
swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc ixany imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt 
Donc en fait "^d" envoie un "eof", pas un sig_quit...