samedi 23 mars 2013

.emacs

My .emacs file is usually :

;; .emacs

;;; uncomment this line to disable loading of "default.el" at startup
(setq inhibit-default-init 1)

;; Set your term type to vt100
; (load "term/vt100") 
;; To change the font size under X.
; (set-default-font "9x15")


(setq inhibit-splash-screen t)

;; Remove toobar
(tool-bar-mode 0)
;(menu-bar-mode nil)

;; Color feedback
(global-font-lock-mode t)

;; Visual feedback on selections
(setq transient-mark-mode t)

;; I always want a newline at the end of files
(setq require-final-newline t)

;; And please, put me the cursor where I was
(load-library "saveplace")
(setq-default save-place t)

;; When I'm wrinting text, cut my lines (default : 70)
(add-hook 'text-mode-hook 'turn-on-auto-fill)
; (setq fill-column 80)

;; Disable anoying audio-beep
(setq visible-bell t)

;; Support Wheel Mouse Scrolling
(mouse-wheel-mode t)

;; Kill the whole line (including '\n') when the cursor in col 0
;(setq kill-whole-line t)

;; Window title
(setq frame-title-format '(buffer-file-name "%b [%f]" "%b"))

;; Show line-number and column-number in the mode line
(line-number-mode t)
(column-number-mode t)

;; See current buffer's path in the mode line
(set-default 'mode-line-buffer-identification
             '(buffer-file-name ("%f") ("%b")))


;; Aliases
;(define-key global-map "\C-Menu" 'mouse-buffer-menu)
(define-key global-map "\M-g"   'goto-line)
(define-key global-map "\M-r"   're-search-forward)


;; Modes d'accentuation é
;(setq iso-accents-mode t)
;(iso-accents-mode t)
;(iso-accents-customize "french")
;(iso-accents-customize)


;; Licence 3
(setq auto-mode-alist
      (cons '("\\.hbk\\'" .tex-mode)
        (cons '("\\.bk\\'" .tex-mode)
          (cons '("\\.a[d1-9][bs]\\'" ada-mode)
            auto-mode-alist))))



(setq load-path (append load-path (list "~/.emacs.d/")))

;; Promela mode (M2)
(autoload 'promela-mode "promela-mode" "PROMELA mode" nil t)
(setq auto-mode-alist
      (append
       (list (cons "\\.promela$"  'promela-mode)
         (cons "\\.spin$"     'promela-mode)
         (cons "\\.pml$"      'promela-mode)
         ;; (cons "\\.other-extensions$"     'promela-mode)
         (cons "\\.php5$"     'php-mode)
         )
       auto-mode-alist))

;; Lua editing mode
(setq auto-mode-alist (cons '("\\.lua$" . lua-mode) auto-mode-alist))
(autoload 'lua-mode "lua-mode" "Lua editing mode." t)


(setq load-path (append load-path (list "~/.emacs.d/")))


;; ;; MetaScribe Files : projet RAAR,
;; (load "/home/cm/.emacs.d/metascribe-msf-mode.el")
;; (load "/home/cm/.emacs.d/metascribe-msm-mode.el")
;; (load "/home/cm/.emacs.d/metascribe-mssm-mode.el")
;; (load "/home/cm/.emacs.d/metascribe-msst-mode.el")


(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(case-fold-search t)
 '(current-language-environment "UTF-8")
 '(default-input-method "rfc1345")
 '(global-font-lock-mode t nil (font-lock))
 '(inhibit-startup-screen t)
 '(save-place t nil (saveplace))
 '(text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify)))
 '(transient-mark-mode t))


(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(default ((t (:inherit nil :stipple nil :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 90 :width normal :foundry "unknown" :family "DejaVu Sans Mono")))))

;;(add-to-list 'load-path "/path/to/highlight-symbol")




;; Raccourcis claviers
(global-set-key [f4] 'goto-line)
(global-set-key [f5] 'compile)
(global-set-key [f6] 'comment-region)
(global-set-key [f7] 'uncomment-region)
(global-set-key [f8] 'flyspell-mode)

;; (require 'highlight-symbol)
;; (global-set-key [(control f3)] 'highlight-symbol-at-point)
;; (global-set-key [f3] 'highlight-symbol-next)
;; (global-set-key [(shift f3)] 'highlight-symbol-prev)
;; (global-set-key [(meta f3)] 'highlight-symbol-prev)

3D printing

I recently had to test a 3D printer out of the box.

After a few hours looking for the right open-source tools, I found a proper process to make things !
  1. Draw something with Sketchup (easier, .skt files) or OpenSCAD (funnier, .scad files), or find a model on Thingiverse.com (complete models and very useful scad libraries can be found there).
  2. Export to STL format.
  3. Open ReplicatorG
  4. Generate gcode
  5. send to the printer (via memory card or USB)

NB 0 : Inkscape, DXF files,
I had no luck with Inkscape and the dxf file format so far. Converting it to a stl file seems complicated (and the inkscape plugin supposed to help doing so did not install here).

I had some troubles trying to import dxf files in an openscad code, and since I could find a proper tool to edit dxf files so far, this is still in standby.


Sketchup

Be careful : Sketchup NEEDS the STL export plugin.
Using a MacOSX system, I had to  chmod the plugin directory, or it wouldn't install
sudo chmod 777 /Library/Application\ Support/Google\ SketchUp\ 8/SketchUp/plugins/
Sketchup is pretty easy to use. Great GUI compared to the other tools I could find. Great tool for creating and visualising 3D models. A lot of tutorials are available.

sketchup http://www.sketchup.com/  
sketchup STL plugin https://github.com/SketchUp/sketchup-stl
sketchup developer tools (not tested yet) https://github.com/SketchUp/sketchup-developer-tools


OpenSCAD

It can import (but doesn't seem to be able to convert) your STL files (and DXF ? cf. NB 0), but it's easy to code in SCAD. OpenSCAD editor allows you to view and export to various formats.
BE CAREFUL : you need to compile the file before converting it to STL. The rendered image is not necesarily coherent with what's in the cache of OpenSCAD, you might have suprises once printing (I was about to print something twice the size I needed it for example, the replicatorg visualisation shown me at the next step was somewhat too big.)
http://en.wikibooks.org/wiki/OpenSCAD_User_Manual


ReplicatorG

Be sure to have the right file description for your printer. 

Useful to connect to the printer, or to write to the memory card. You first have to convert the STL file to GCODE, and then you can either print the commands to a memory card (S3G files), or send the commands directly to the printer.
There seems to be a command line interface for replicatorg, but I didn't had time to check it for now.
replicatorg --nogui
 
replicatorG https://github.com/haldean/ReplicatorG


Thingiverse.com

Nowadays, it seems to be the best platform around for sharing 3D models. A lot of them are freely available, let's hope it stays like that ! The interface even allows you to modify some customizable models, but I found it faster to just download them and recalculate them on my machine.
I suggest you to create an account. At least, it helps me keeping track of the good and interesting stuff (I have to admit there is also plenty of junk in the models... )







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/ )