lundi 25 février 2013

Reusing SSH Connection

SOURCE : http://sshmenu.sourceforge.net/articles/transparent-mulithop.html

"The transparent multi-hop connections can be very useful but you may find that it takes a second or two to establish each connection. This delay can become annoying if it happens a lot (e.g.: every time you save a file from the text editor).
The good news is that if you can configure SSH to reuse an existing connection. This means that for example if you have an SSH shell session running then a new connection for SCP can skip the connection setup phase. Two steps are required:
First, you must create a directory (or 'folder') which SSH will use to keep track of established connections:
mkdir ~/.ssh/tmp
Next, add these two lines at the start of your ~/.ssh/config (make sure to use your username in place of 'YOUR-NAME'):


ControlMaster auto
ControlPath   /home/YOUR-NAME/.ssh/tmp/%h_%p_%r

As you can see, a small investment in time setting up your SSH configuration can pay back dividends in convenience."



vendredi 8 février 2013

SVN backup repository with history

Copier toutes l'historique d'un repository SVN auquel vous avez accès (en lecture), 
mais pas les droits d'administration :
 
 
  svnadmin create localrepos
  emacs localrepos/hooks/pre-revprop-change # make it 'exit 0' 
  chmod +x localrepos/hooks/pre-revprop-change
  svnsync init --username USERNAME file:///path/to/localrepos https://myproject.googlecode.com/svn
  Copied properties for revision 0.
  svnsync sync --username USERNAME file:///path/to/localrepos
 
Source : http://code.google.com/p/support/wiki/SubversionFAQ#How_do_I_download_my_Subversion_history? 
 
 
 
Donc :
$ svnadmin creat localrepos
$ cat > localrepos/hooks/pre-revprop-change
#! /bin/bash
exit 0

$ chmod a+x localrepos/hooks/pre-revprop-change
$ svnsync init --username USERNAME file:///NEWREPO https://OLDREPO
   Copied properties for revision 0.
$ svnsync sync --username USERNAME file:///NEWREPO 
[...copie de toutes les révisions...] 
 
 
 
Sur la machine où j'ai copié l'historique, j'ai du utiliser une feinte :
$ svnadmin setuuid UUID-OLDREPO
 
 
Puis, pour changer les "checkouts" de source, svn switch :
$ svn switch --relocate https://OLDREPO svn+ssh://NEWREPO 

Et voilà !


PS : si vous avez les accès svnadmin sur les deux machines, il y a plus simple comme solution.
http://particul.es/blog/index.php?post/Reprendre-un-projet-%3A-svn-tips-pour-changer-l-url-du-d%C3%A9pot


lundi 4 février 2013

Ext4 (non crypté) macosx

 sudo fuse-ext2 /dev/disk2s1 /Volumes/elem/ -o force



Avec :
http://osxfuse.github.com/

dimanche 27 janvier 2013

PDF reduce size of file


Pour réduire la taille d'un pdf, en utilisant ghostscript :

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=OUT.pdf CV.pdf
 
 
Source : http://www.fiat-tux.fr/fr/2010/12/reduire-la-taille-dun-pdf/ 

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.