Skip to content

Instantly share code, notes, and snippets.

View fcamblor's full-sized avatar

Frédéric Camblor fcamblor

View GitHub Profile
Java puzzler on my Intellij issue today ...
Given following classes :
public class A {
   public String foo(){ return "foo"; }
}
public class B {
   public String bar(){ return "bar"; }
}
public class C {
@fcamblor
fcamblor / gist:1676147
Created January 25, 2012 12:58
Java Puzzler #2
What happens when this code is compiled/executed ?
public class A<T> {
   public List<T> listOfTs = new ArrayList<T>();
   public List<Long> listOfLongs = Arrays.asList(1l, 2l, 4l);
   
   public A(List<T> _t){ this.listOfTs = _t; }
   
   public static void main(String[] args){
       hello(new A<String>(Arrays.asList("1", "2", "4")));
@fcamblor
fcamblor / gist:1722519
Created February 2, 2012 09:18
Spring joda mybatis integration
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!-- ..... -->
<property name="typeHandlersPackage" value="org.joda.time.mybatis.handlers" />
</bean>
@fcamblor
fcamblor / JavaPPuzzler
Created February 8, 2012 16:29
Full JavaPPuzzler class
package com.puzzlers;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.util.ClassUtils;
import org.springframework.util.SystemPropertyUtils;
@fcamblor
fcamblor / gist:1771083
Created February 8, 2012 17:05
JavaPPuzzler : answers
(1) 10 classes !
Obvious ones :
com.puzzlers.a.SimpleEnum
com.puzzlers.b.SimpleAnonymousEnum
com.puzzlers.c.ClassWithNestedEnum
com.puzzlers.c.ClassWithNestedEnum$NestedEnum
com.puzzlers.d.ClassWithNestedAnonymousEnum
com.puzzlers.d.ClassWithNestedAnonymousEnum$NestedAnonymousEnum
com.puzzlers.JavaPPuzzler
@fcamblor
fcamblor / _Puzzler on JavaP
Created February 8, 2012 17:06
JavaPPuzzler :)
Given these 5 classes, could you guess :
(1) What is the number of total generated classes ?
(2) and (3) : Can you guess what are superclasses and implemented interfaces for every generated classes in (1) ?
Answers are here : https://gist.github.com/1771083
// Array Remove - By John Resig (MIT Licensed)
// See http://ejohn.org/blog/javascript-array-remove/
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
// "Ghosting" remove function in order to not iterate over it during a for(.. in ..) loop
// on arrays
@fcamblor
fcamblor / gist:3285107
Created August 7, 2012 13:00
Google doodle beaten :)
// Execute this script in frame "hplogo-complex" on https://www.google.com/doodles/hurdles-2012 :-)
var script = document.createElement('script');
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);
window.skip = false;
window.target = "#hplogo_pc";
// Define here the time interval between 2 arrow hits :)
window.interval = 15;
@fcamblor
fcamblor / gist:3294986
Created August 8, 2012 13:22
google doodle beaten (2)
// Execute this script in console on https://www.google.com/doodles/basketball-2012 :)
/////////////////////////////////////////////////////////////////////////////////////
// Add this prior to anything : it will allow you to use jquery in your page :)
var script = document.createElement('script');
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);
/////////////////////////////////////////////////////////////////////////////////////
I--J--K--L
/ /
F--G--H /
/ /
A--B /
\ /
C--D---E
I want to rebase branch "L" on branch "H", ideally having something like this :