Skip to content

Instantly share code, notes, and snippets.

View fedesilva's full-sized avatar
👁️‍🗨️

federico silva fedesilva

👁️‍🗨️
View GitHub Profile

A quick "how to" on what you need to do to both setup AND recover a single-server PostgreSQL database using WAL-E

Setup:

  1. These packages:
@fedesilva
fedesilva / 1_spark-session.scala
Last active August 29, 2015 13:56
ip-not-supported es-hadoop+spark-session
import org.elasticsearch.hadoop.mr._
import org.apache.hadoop.mapred._
val q = """
{
"query": {
"match_all": {}
},
"fields": [
@fedesilva
fedesilva / user.scala
Created March 4, 2014 03:10
My Steam User
"federico".map(_+3).map(_.toChar).mkString
input {
tcp {
type => "iis_advanced_full"
port => 3333
}
}
filter {
grok {
type => "iis_advanced_full"
package pellucid.data.util
import java.util.concurrent.Executors
import java.util.concurrent.atomic.AtomicInteger
import org.joda.time.format.DateTimeFormat
import scala.util.Random
import scalaz.concurrent.Task
#!/bin/sh
# This script will migrate schema and data from a SQLite3 database to PostgreSQL.
# Schema translation based on http://stackoverflow.com/a/4581921/1303625.
# Some column types are not handled (e.g blobs).
SQLITE_DB_PATH=$1
PG_DB_NAME=$2
PG_USER_NAME=$3
@fedesilva
fedesilva / 1_overloadandnamedparams.scala
Last active August 29, 2015 14:01
Overloading and Named Parameters
class OverloadAndNamedParameters {
def method(arg1: Int, arg2: Int, arg3: String) = println( "Method1")
def method(arg1: Int, arg3: String) = println( "Method2" )
def method(arg1: Int, arg2: Double, arg3: String) = println( "Method3" )
}
// scalac -unchecked -optimise ConsistentHash.scala && scala CHApp
import scala.collection.immutable.LinearSeq
import java.util.{TreeMap => JTreeMap}
import java.util.{SortedMap => JSortedMap}
/**
* Inspired by http://www.lexemetech.com/2007/11/consistent-hashing.html
*/
@fedesilva
fedesilva / dump.log
Created July 17, 2014 02:32
Kernel Panic while running benchmark
Anonymous UUID: C752FCB2-6F53-74FD-4316-6E1B29CFD524
Wed Jul 16 23:00:18 2014
panic(cpu 3 caller 0xffffff801b654c66): "a freed zone element has been modified: expected 0 but found 0, bits changed 0, at offset 120 of 128 in zone: HFS fork"@/SourceCache/xnu/xnu-2422.110.17/osfmk/kern/zalloc.c:461
Backtrace (CPU 3), Frame : Return Address
0xffffff8207c33e00 : 0xffffff801b622f79
0xffffff8207c33e80 : 0xffffff801b654c66
0xffffff8207c33ec0 : 0xffffff801b6531e4
0xffffff8207c33f80 : 0xffffff801b698d97
0xffffff8207c33fb0 : 0xffffff801b6d7417
@fedesilva
fedesilva / global.js
Created July 25, 2014 20:01
JS Global Exception Handler
window.onerror = function (exception, source, line) {
try {
var url = "/logs/error";
var error = _.isObject(exception) ? JSON.stringify(exception) : exception.toString();
var data = "Global error ["+error+"] in "+source+":"+line;
console.error('error caught! ');
console.error(exception);
$.ajax({
type: "POST",
url: url,