Skip to content

Instantly share code, notes, and snippets.

View VallaDanger's full-sized avatar
🎯
Focusing

chux VallaDanger

🎯
Focusing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am VallaDanger on github.
  • I am valladanger (https://keybase.io/valladanger) on keybase.
  • I have a public key whose fingerprint is BCF1 C38F 00E0 3FED C3AC 29E1 3F3A B7E0 8A7B 963E

To claim this, I am signing this object:

@VallaDanger
VallaDanger / RecursiveStringReverse.java
Last active April 23, 2016 01:04
Reverse String [for & recursive]
public class Main {
public static void main(String[] args) throws Exception {
System.out.println(reverse("0123456789"));
}
private static String reverse(String str) {
int size;
if((str == null) || (size = str.length()) == 0) {
return str;
@VallaDanger
VallaDanger / FizzBuzz.java
Created April 22, 2016 05:14
FizzBuzz Java (using CharSequence)
public class Main {
public static void main(String[] args) throws Exception {
System.out.println(new StringBuilderFizzBuzz(100).get());
System.out.println(new StringFizzBuzz(100).get());
}
private static abstract class FizzBuzz<C extends CharSequence> {
private final int limit;
@VallaDanger
VallaDanger / FizzBuzz.java
Last active April 22, 2016 04:18
FizzBuzz Java (recursive)
public class Main {
public static void main(String[] args) throws Exception {
System.out.println(getText(new StringBuilder("1,2,"), 3));
}
private static StringBuilder build(StringBuilder sb, int i) {
if(i%3 == 0) {
sb.append("Fizz");
}
@VallaDanger
VallaDanger / ImmutableListDeserializer.java
Last active April 21, 2016 04:31
GSON JsonArray to Guava ImmutableList
public static void main(String[] args) {
Type type = getCollectionType(ImmutableList.class, Number.class);
Gson gson = new GsonBuilder().registerTypeAdapter(type, new ImmutableList_TypeAdapter<Number>()).create();
ImmutableList<Number> list = gson.fromJson("[1,2,3]", type);
ListVO vo = gson.fromJson("{\"numbers\":[1,2,3]}", ListVO.class);
}
private static class ListVO {
@Expose @SerializedName("numbers")
ImmutableList<Number> numbers;