Skip to content

Instantly share code, notes, and snippets.

Alexandre Grison agrison

View GitHub Profile
View grid.h
#ifndef TICTACTOE_GRID_H
#define TICTACTOE_GRID_H
#define COLOR1 "\x1B[32m"
#define COLOR2 "\x1B[35m"
#define NORMAL "\x1B[0m"
#define GRID "\t\t+-------+-------+-------+\n" \
"\t\t| | | |\n" \
"\t\t| %s | %s | %s |\n" \
View grid.h
#define GRID "\t\t+-------+-------+-------+\n" \
"\t\t| | | |\n" \
"\t\t| %s | %s | %s |\n" \
"\t\t| 1| 2| 3|\n" \
"\t\t+-------+-------+-------+\n" \
"\t\t| | | |\n" \
"\t\t| %s | %s | %s |\n" \
"\t\t| 4| 5| 6|\n" \
"\t\t+-------+-------+-------+\n" \
"\t\t| | | |\n" \
@agrison
agrison / Spark.java
Created Oct 30, 2016
spark java 8 count
View Spark.java
JavaRDD<String> textFile = sc.textFile("hdfs://...");
JavaPairRDD<String, Integer> counts = textFile
.flatMap(line -> Arrays.asList(line.split(" ")))
.mapToPair(w -> new Tuple2<>(w, 1))
.reduceByKey((x, y) -> x + y);
counts.saveAsTextFile("hdfs://...");
@agrison
agrison / api.json
Created Sep 28, 2016
Master Component in Java & Spring
View api.json
[
{
"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 Sep 28, 2016
Monster Component in Java & Spring
View soap-request.xml
<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 / Cat.java
Last active Sep 29, 2016
Monster Component in Java & Spring
View Cat.java
package foo;
// imports skipped
/**
* @author @algrison
*/
@Getter // generate getters
@Setter // generate setters
@Aspect // we are an aspect
@agrison
agrison / pom.xml
Created Sep 28, 2016
Monster Component in Java & Spring pom.xml
View pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
@agrison
agrison / gems-one-liner.clj
Created Sep 27, 2016
HackerRank gems-one-liner.clj
View 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 Sep 27, 2016
HackerRank gems.clj
View 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 Mar 3, 2016
Create a Dash dockset from ricostacruz.com/cheatsheets
View foo.sh
# Download it all
wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--domains ricostacruz.com \
--no-parent \
You can’t perform that action at this time.