Skip to content

Instantly share code, notes, and snippets.

View mverzilli's full-sized avatar

Martin Verzilli mverzilli

View GitHub Profile
@mverzilli
mverzilli / circle.yml
Created June 15, 2016 14:35
CircleCI for Crystal Projects
# Include this file in your project's root folder to integrate with CircleCI.
# Replace 0.18.0 with the Crystal version you're using.
dependencies:
cache_directories:
- "crystal-0.18.0-1"
pre:
- if [[ ! -e crystal-0.18.0-1 ]]; then wget https://github.com/crystal-lang/crystal/releases/download/0.18.0/crystal-0.18.0-1-linux-x86_64.tar.gz && tar xvfz crystal-0.18.0-1-linux-x86_64.tar.gz; fi
test:
pre:
- crystal-0.18.0-1/bin/crystal deps
@mverzilli
mverzilli / kmanas.cr
Created March 7, 2016 18:02
Crystal implementation of Kmeans for a poll @ Manas,
require "csv"
MINIMUM_DISTANCE = 0.85
SIMILARITY_LOW_BOUND = 0.30
SIMILARITY_HIGH_BOUND = 0.60
BIT_DICTIONARY = ["1a", "1b", "1c", "1d", "2a", "2b", "2c", "2d", "3a", "3b", "4a", "4b", "4c", "5a", "5b", "5c", "5d", "6a", "6b", "6c", "7a", "7b", "7c", "8a", "8b", "8c", "9a", "9b", "9c", "9d", "9e", "9f", "9g", "10a", "10b", "10c", "10d", "11a", "11b", "12a", "12b", "12c", "13a", "13b", "13c", "13d"]
RANDOM = Random.new 23
@mverzilli
mverzilli / pseudo_hash
Created December 15, 2015 13:46
Simulando acceso indexado en CodeGames :)
function states(i)
if i == 0
state0
else
if i == 1
state1
else
if i == 2
state2
else
@mverzilli
mverzilli / inverse_matrix.cr
Created October 18, 2015 21:28
Invert a matrix with Crystal via Lapack bindings
@[Link(framework: "Accelerate")]
lib LibLapack
fun sgetrf_(m: Int32*, n: Int32*, a: Void*, lda: Int32*, ipiv: Int32*, info: Int32*)
fun sgetri_(n: Int32*, a: Void*, lda: Int32*, ipiv: Int32*, work: Void*, lwork: Int32*, info: Int32*)
end
# Matrix A (the one being inverted)
# Matrix [1 2
# 3 4]
### Keybase proof
I hereby claim:
* I am mverzilli on github.
* I am mverzilli (https://keybase.io/mverzilli) on keybase.
* I have a public key whose fingerprint is 1A62 F4E8 C9E1 3F5E 913E 60A4 029B 117E D8E9 4948
To claim this, I am signing this object:
package simurrythmia.ui.util;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import Html (..)
import Html.Attributes (..)
import Html.Events (..)
import Signal
import Graphics.Collage (collage, filled, rect, toForm, move, rotate)
import Graphics.Element (Element, image)
import Window
import Color (..)
import Keyboard (arrows)
import Text (asText)
@mverzilli
mverzilli / pi.elm
Created February 28, 2015 16:02
Estimando PI con Montecarlo y Elm
import List (..)
import Random (pair, float, generate, Seed, initialSeed)
import Signal
import Time (every, millisecond, Time)
import Graphics.Collage (collage, Form, filled, circle, move, toForm)
import Graphics.Element (Element)
import Color (..)
import Window (dimensions)
import Text
import String
## Facility Operating hours
CSDOperatingHours => XXX (*)
CSDChildOf => CSDFacility (*)
## Open flag (Yes/No field)
CSDOpenFlag => ''
## Day of the week (Integer, Sunday=0, Monday=1, ...)
CSDDayOfTheWeek => ''
## Contact points
CSDType => "contactPoint" (*)
CSDCode => XXX (*)
## For each contact point text field (see page 95)
CSDContactData => YYY (one of: "equipment", "purpose", "certificate")