Skip to content

Instantly share code, notes, and snippets.

View alanmarazzi's full-sized avatar

Alan alanmarazzi

View GitHub Profile
(ns defwrapper
(:require [clojure.string :as str]))
(set! *warn-on-reflection* true)
(defn class-methods [^Class class]
(seq (.getMethods class)))
(defn constructors [^Class klazz]
(.getDeclaredConstructors klazz))
@alanmarazzi
alanmarazzi / pipeline.clj
Created October 26, 2020 11:54 — forked from JacobNinja/pipeline.clj
Clojure core.async pipeline example
(require '[clojure.core.async :as async]
'[clj-http.client :as client]
'[clojure.data.json :as json])
(def concurrency 5)
(let [in (async/chan)
out (async/chan)
request-handler (fn [url out*]
(async/go
@alanmarazzi
alanmarazzi / pokemon.csv
Created August 12, 2019 08:21
An example dataset
# Name Type 1 Type 2 HP Attack Defense Sp. Atk Sp. Def Speed Generation Legendary
1 Bulbasaur Grass Poison 45 49 49 65 65 45 1 False
2 Ivysaur Grass Poison 60 62 63 80 80 60 1 False
3 Venusaur Grass Poison 80 82 83 100 100 80 1 False
4 Mega Venusaur Grass Poison 80 100 123 122 120 80 1 False
5 Charmander Fire 39 52 43 60 50 65 1 False
6 Charmeleon Fire 58 64 58 80 65 80 1 False
7 Charizard Fire Flying 78 84 78 109 85 100 1 False
8 Mega Charizard X Fire Dragon 78 130 111 130 85 100 1 False
9 Mega Charizard Y Fire Flying 78 104 78 159 115 100 1 False
@alanmarazzi
alanmarazzi / Basic_R.R
Last active August 2, 2016 12:17
Basic R
# As a primer you saw also earlier that I wrote
# some text in the code, but it wasn't evaluated.
# These are comments, you can use them by simply
# using "#" before the text.
###### I can add also more "#" to draw the attention
# on that comment.
# Assign names
# We can do math with R as we would do in a simple calculator
@alanmarazzi
alanmarazzi / R_check.R
Last active August 2, 2016 09:57
R_check
# Generate some random number
x <- runif(10)
y <- runif(10)
# Print generated numbers
x
y
# Sum the two vectors
x + y
# Read data from csv
df <- read.csv("some_data.csv")
# Make a plot of the data
plot(df$debt, df$gdp)
# Fit a linear regression
lm(gdp ~ debt, data = df)
@alanmarazzi
alanmarazzi / Plotting R code for previous chart.R
Last active November 3, 2015 15:40
The Beginning of an AdventuRe example code
library(ggplot2) # This loads ggplot2 package, it's better and easier than base R plot
# This is the colors' palette used in the chart
pal <- c("#0E37B1", "#FF4100", "#00B65E", "#FFAE00", "#394C86", "#C66746", "#318A5F", "#C69E46")
# Here the code for the plot [don't worry, in next posts I'll
# explain better every line of code, just keep following me ;) ]
ggpoints <- ggplot(df, aes(HC, LC, color = Country))+
geom_point(size = 3, shape = 16)+
scale_color_manual(values = pal)+