Skip to content

Instantly share code, notes, and snippets.

View agrison's full-sized avatar

Alexandre Grison agrison

View GitHub Profile
@agrison
agrison / Cat.java
Last active September 29, 2016 06:22
Monster Component in Java & Spring
package foo;
// imports skipped
/**
* @author @algrison
*/
@Getter // generate getters
@Setter // generate setters
@Aspect // we are an aspect
@agrison
agrison / api.json
Created September 28, 2016 17:59
Master Component in Java & Spring
[
{
"id":"266d9729-7678-4e5d-8ddb-40d2c5631d0c",
"url":"http://random.cat/i/065_-_AhrGPRl.gif"
},
{
"id":"ccaa6a40-d3a5-4761-8f85-ca9e5ad8623a",
"url":"http://random.cat/i/dDVns.gif"
},
{
@agrison
agrison / soap-request.xml
Created September 28, 2016 17:55
Monster Component in Java & Spring
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:gs="http://ws.foo">
<soapenv:Header/>
<soapenv:Body>
<gs:getRandomCatRequest />
</soapenv:Body>
</soapenv:Envelope>
@agrison
agrison / gems-one-liner.clj
Created September 27, 2016 06:44
HackerRank gems-one-liner.clj
(use '[clojure.string :only (split-lines)]
'[clojure.set :only (intersection)])
(->> (slurp *in*) split-lines rest (map set) (apply intersection) count println)
@agrison
agrison / gems.clj
Created September 27, 2016 06:43
HackerRank gems.clj
(use '[clojure.string :only (split-lines)]
'[clojure.set :only (intersection)])
(->> split-lines (slurp *in*)
rest
(map set)
(apply intersection)
count
println)
@agrison
agrison / foo.sh
Created March 3, 2016 08:43
Create a Dash dockset from ricostacruz.com/cheatsheets
# Download it all
wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--domains ricostacruz.com \
--no-parent \
@agrison
agrison / Unicorn.java
Last active December 13, 2015 23:59
Magical Java Puzzle: Pat the unicorns
/** See: http://zeroturnaround.com/fun/magical-java-puzzle-pat-the-unicorns/ */
import java.util.*;
public class Unicorn {
static Set<Integer> lines = new HashSet<Integer>();
public static boolean pat() {
int callerLine = Thread.currentThread().getStackTrace()[3].getLineNumber();
return lines.add(callerLine);
}
(*
See: http://thecodersbreakfast.net/index.php?post/2013/02/18/Coding-challenge-maman-les-petits-avions
---
compile & run:
$ ocamlfind ocamlc -package batteries -linkpkg avions.ml -o avions
$ ./avions
*)
open Batteries;;
(* The syracuse suite *)
@agrison
agrison / challenge.ml
Last active December 13, 2015 19:19
Coding challenge Cédric Beust - OCaml
(*
See: http://beust.com/weblog/2008/06/27/
---
compile & run:
$ ocamlfind ocamlc -package batteries -linkpkg challenge.ml -o challenge
$ ./challenge
*)
open Batteries;
(* Test whether a number have repeating digits *)
@agrison
agrison / generate-meta-model.neo4j.cql
Last active September 28, 2015 13:28
Create a meta model of nodes and relationship already in Neo4J.
MATCH (n1)-[r]->(n2)
WITH labels(n1) AS node1_labels, type(r) AS relation_type, labels(n2) AS node2_labels
UNWIND node1_labels as node1_label
UNWIND node2_labels as node2_label
MERGE (n1:Meta_Node {name: node1_label})
MERGE (n2:Meta_Node {name: node2_label})
MERGE (n1)-[:META_RELATIONSHIP {name:relation_type}]->(n2)