Skip to content

Instantly share code, notes, and snippets.

View nchapon's full-sized avatar

Nicolas Chapon nchapon

View GitHub Profile
@nchapon
nchapon / VoodooClass.java
Created January 19, 2011 13:09
Voodoo Code
public static URL getJarURLFromURLEntry(URL url, String entry) throws IllegalArgumentException {
URL jarUrl;
String file = url.getFile();
if ( ! entry.startsWith( "/" ) ) entry = "/" + entry;
file = file.substring( 0, file.length() - entry.length() );
if ( file.endsWith( "!" ) ) file = file.substring( 0, file.length() - 1 );
try {
String protocol = url.getProtocol();
if ( "jar".equals( protocol )
;; nchapon's solution to Nth Element
;; https://4clojure.com/problem/21
#(get (vec %) %2)
@nchapon
nchapon / gist:1509747
Created December 22, 2011 09:49
Faillite Technique
public static void updateAuthoritiesFile(File file, UserSession userSession,ArrayList<GrantedAuthority> author) {
// UserServiceFacade userFacade = (UserServiceFacade) ControllerUtility
// .getBean("userServiceFacade");
SecurityContext context = SecurityContextHolder.getContext();
Authentication auth = context.getAuthentication();
UserDetails userDetails = (UserDetails) auth.getPrincipal();
ArrayList<GrantedAuthority> authorities = null;
if(CommonUtility.isNullOrEmpty(author)){
authorities = new ArrayList<GrantedAuthority>(
userDetails.getAuthorities());
@nchapon
nchapon / emacs
Created July 27, 2012 12:53
Emacs snapshot install broken
Dépaquetage de emacs-snapshot-gtk (à partir de .../emacs-snapshot-gtk_2%3a20120721-1~ppa2~oneiric1_all.deb) ...
Traitement des actions différées (« triggers ») pour « man-db »...
Traitement des actions différées (« triggers ») pour « install-info »...
Paramétrage de emacsen-common (1.4.19ubuntu2) ...
emacsen-common: Handling install of emacsen flavor emacs
Paramétrage de emacs-snapshot-common (2:20120721-1~ppa2~oneiric1) ...
Paramétrage de emacs-snapshot-bin-common (2:20120721-1~ppa2~oneiric1) ...
update-alternatives: erreur: le chemin alternatif /usr/bin/ctags.emacs-snapshot n'existe pas.
dpkg : erreur de traitement de emacs-snapshot-bin-common (--configure) :
le sous-processus script post-installation installé a retourné une erreur de sortie d'état 2
@nchapon
nchapon / sql-connection
Created January 6, 2015 22:13
SQL connect with ido
;; Sql specfic config
(setq sql-connection-alist
'((cnp (sql-product 'mysql)
(sql-port 3306)
(sql-server "localhost")
(sql-user "cnp")
;;(sql-password "pwd")
(sql-database "cnp"))
@nchapon
nchapon / my-nn
Created February 5, 2015 21:20
two lisp function
;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.
(defun my-nn ()
"DOCSTRING"
(interactive)
(let (w (select-word))
(forward-char)
@nchapon
nchapon / tomcat
Created March 24, 2015 15:28
Apache Tomcat Start / Stop / Status init.d script that works fine with ansible
#!/bin/sh
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
# source function library
. /etc/rc.d/init.d/functions
TOMCAT_USER=tomcat
LOCKFILE=/var/lock/tomcat
;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.
(require 'f)
;; List all files
(f-files "/home/nchapon/notes/GTD/days")
# Bindings de keys
set -g prefix C-a
# Windows navigation with Maj + Arrows
bind -n S-Left previous-window
bind -n S-Right next-window
# Pane navigation with Alt + Arrows
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
# Bindings de keys
set -g prefix C-a
# Free the original key binding
unbind C-b
# Setting the delay between the prefix and command
set -sg escape-time 1
# Ensure that we can send Ctrl-A to other apps