Skip to content

Instantly share code, notes, and snippets.

View nchapon's full-sized avatar

Nicolas Chapon nchapon

View GitHub Profile
@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's solution to Nth Element
;; https://4clojure.com/problem/21
#(get (vec %) %2)
@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 )