Skip to content

Instantly share code, notes, and snippets.

View gmodena's full-sized avatar

Gabriele Modena gmodena

View GitHub Profile
@gmodena
gmodena / locateip.py
Created March 16, 2011 10:45
Mine failed login attempts from auth.log and display them on a map (static google map or KML file)
import urllib2, json, re
from itertools import imap
import argparse
import simplekml
BASE = "http://freegeoip.net/json/%(ip4)s"
r1 = 'Authentication failure for .* from (?:::f{4,6}:)?(?P<host>\S+)'
r2 = '[iI](?:llegal|nvalid) user .* from (?:::f{4,6}:)?(?P<host>\S+)'
@gmodena
gmodena / install.rCharts.r
Created June 24, 2013 07:55
Install devtools rcharts
install.packages('httr')
install.packages('RCurl')
install.packages('memoise')
install.packages('whisker')
dt <- "http://cran.r-project.org/src/contrib/Archive/devtools/devtools_1.1.tar.gz"
fname <- "/tmp/devtools_1.1.tar.gz"
download.file(dt , fname)
install.packages(fname , repos = NULL , type = "source")
@gmodena
gmodena / pom.xml
Created November 17, 2013 15:00 — forked from jnatkins/pom.xml
<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>
<!-- Replace the group ID with your group ID -->
<groupId>com.mycompany.hadoopproject</groupId>
<!-- Replace the artifact ID with the name of your project -->
<artifactId>my-hadoop-project</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

Keybase proof

I hereby claim:

  • I am gmodena on github.
  • I am gmodena (https://keybase.io/gmodena) on keybase.
  • I have a public key whose fingerprint is ECBA 9561 6FDD 553A FBF6 0356 44D0 A590 6445 3826

To claim this, I am signing this object:

@gmodena
gmodena / fm.py
Created January 22, 2017 14:48
An order 2 Factorization Machine implemented on top of tensorflow
# Steffen Rendle (2012): Factorization Machines with libFM,
# in ACM Trans. Intell. Syst. Technol., 3(3), May.
# http://doi.acm.org/10.1145/2168752.2168771
import tensorflow as tf
import numpy as np
N_EPOCHS = 1000
x_data = np.matrix([[ 19., 0., 0., 0., 1., 1., 0., 0., 0.],
[ 33., 0., 0., 1., 0., 0., 1., 0., 0.],
/// String parsing example
impl FromStr for InputRange {
type Err = ParseError;
fn from_str(input: &str) -> std::result::Result<Self, Self::Err> {
lazy_static! {
static ref RE: Regex = Regex::new(r"(\d+)-(\d+)").unwrap();
};
let parse_error_msg= "Could not parse input range";
BEGIN MESSAGE.
OCGtvlQIavHF9Ef rgBiIpLuqjSWxDn R2wCYVM5FrXfcU0 1NSAjCvd80kWwlp
wopr1tYCuc5oTS4 ESaEp6nUJhuTCKq 6Xr2MZHgg6tNpjr 5FEXqpZiw6r2Xit
ry2InU0nySGcOis v6hOZXgrWVX9F5x 1XVWzfpR1Inj45S en9PN9yRb9eTcCd
d9mW08c3uZr3VEI z7YY1rxVcTcpqQK vSQkc2IP.
END MESSAGE.
def to_binary(string: str):
string = (
string.replace("B", "1").replace("F", "0").replace("R", "1").replace("L", "0")
)
return int(string, base=2)
def part1(strings):
return max([to_binary(string) for string in strings])
@gmodena
gmodena / build.gradle
Last active February 8, 2021 20:31
LearningHadoop2 - Chapter2
// Update of https://github.com/learninghadoop2/book-examples/blob/master/ch2/build.gradle
// Default to HTTPs maven central to fix broken dependencies.
apply plugin:'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories{
maven {
url = 'https://repo1.maven.org/maven2/'
}
@gmodena
gmodena / build.gradle
Last active February 8, 2021 20:32
LearningHadoop2 - Chapter3
// Update of https://github.com/learninghadoop2/book-examples/blob/master/ch3/build.gradle
// Drop Cloudera versions of Hadoop packages, and use vanilla versions instead.
apply plugin:'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
// Use maven central (over https) instead of Cloudera repos
repositories {
maven {
url = 'https://repo1.maven.org/maven2/'