Skip to content

Instantly share code, notes, and snippets.

@gpedote
gpedote / normalize_numpy.py
Created June 23, 2017 20:51 — forked from perrygeo/normalize_numpy.py
Normalize a 2D numpy array so that each "column" is on the same scale (Linear stretch from lowest value = 0 to highest value = 100)
import numpy as np
rawpoints = np.array(
[[2500, 0.15, 12],
[1200, 0.65, 20],
[6200, 0.35, 19]]
)
# Scale the rawpoints array so that each "column" is
# normalized to the same scale
@gpedote
gpedote / dunn-sklearn.py
Created June 23, 2017 16:05
Dunn index for sklearn-generated clusters
def dunn(c, distances):
"""
Dunn index for cluster validation (the bigger, the better)
.. math:: D = \\min_{i = 1 \\ldots n_c; j = i + 1\ldots n_c} \\left\\lbrace \\frac{d \\left( c_i,c_j \\right)}{\\max_{k = 1 \\ldots n_c} \\left(diam \\left(c_k \\right) \\right)} \\right\\rbrace
where :math:`d(c_i,c_j)` represents the distance between
clusters :math:`c_i` and :math:`c_j`, given by the distances between its
two closest data points, and :math:`diam(c_k)` is the diameter of cluster
:math:`c_k`, given by the distance between its two farthest data points.
@gpedote
gpedote / teste_lista.c
Last active June 13, 2017 18:29
Modelo de entrada e saída do primeiro trabalho de ED
int qtd_elementos;
scanf("%d", &qtd_elementos);
while (qtd_elementos >= 1) {
dimInicLista(&lista_dinamica);
estInicLista(&lista_estatica);
int i = 0;
int elemento;
for (i = 0; i < qtd_elementos; i++) {
scanf("%d", &elemento);
@gpedote
gpedote / backbone.localStorage.async.js
Created November 1, 2016 23:31 — forked from anonymous/backbone.localStorage.async.js
Async version of the backbone.localStorage module
/**
* Backbone localStorage Adapter
* https://github.com/jeromegn/Backbone.localStorage
*/
(function(_, Backbone) {
// A simple module to replace `Backbone.sync` with *localStorage*-based
// persistence. Models are given GUIDS, and saved into a JSON object. Simple
// as that.
@gpedote
gpedote / config.json
Created November 14, 2015 10:05 — forked from anonymous/config.json
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
$(document).ready(function() {
var gameStartDiff = Math.abs(new Date() - new Date('2014/07/08 17:00:00'));
var minuteInMileseconds = 60 * 1000;
var update = function () {
var brazilGoals = Math.round(gameStartDiff / (90 * minuteInMileseconds));
var germanGoals = Math.round(gameStartDiff / (12 * minuteInMileseconds));
$('#brazil-goals').html(brazilGoals);
$('#german-goals').html(germanGoals);
}
setTimeout(function(){ update(); }, 60000);
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static