Skip to content

Instantly share code, notes, and snippets.

View marcusdb's full-sized avatar

Marcus David Bronstein marcusdb

  • porto, Portugal
View GitHub Profile
@marcusdb
marcusdb / gist:1ed245e1ea5d5468c131
Created July 11, 2014 21:09
amazon linux java 8 install
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u5-b13/jdk-8u5-linux-x64.rpm"
//import org.codehaus.jackson.annotate.{ JsonTypeInfo, JsonSubTypes, JsonProperty }
//import org.codehaus.jackson.annotate.JsonSubTypes.Type
//import org.codehaus.jackson.map.ObjectMapper
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.annotation.JsonSubTypes
import com.fasterxml.jackson.annotation.JsonSubTypes.Type
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
package com.javacodegeeks.java.core;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Iterator;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonNode;
@marcusdb
marcusdb / Composite.scala
Last active August 29, 2015 14:07
JSON to SQL
package models
import scala.collection.JavaConversions.asScalaIterator
import com.fasterxml.jackson.annotation.JsonSubTypes
import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
object Processor {
val mapper: ObjectMapper = new ObjectMapper();
AWS set ulimit for ec2-user
sudo su -c "ulimit -n 64000;su - ec2-user"
checking open files
ls -l /proc/PID/fd | wc -l
@marcusdb
marcusdb / index.html
Created April 23, 2015 12:30
SVG multiple elements transition issue
<!DOCTYPE html>
<head>
<style>
.chart {
margin-left: 42px;
}
.chart rect {
fill: steelblue;
stroke: white;
@marcusdb
marcusdb / mongoIndexExport.js
Last active February 11, 2016 16:12
mongoIndexExport
db.getCollectionNames().forEach(function(collection) {
var indexes = db.getCollection(collection).getIndexes();
indexes.forEach(function(c) {
opt = ''
ixkey = JSON.stringify(c.key, null, 1).replace(/(\r\n|\n|\r)/gm, "")
ns = c.ns.substr(c.ns.indexOf(".") + 1, c.ns.length)
for (var key in c) {
if (key != 'key' && key != 'ns' && key != 'v') {
if (opt != '') {
opt += ','
echo '{"id":"TEST","level2":{"id":"Level2 id"}}' | | nc -q0 stats 28777 LOGSTASH JSON
nc localhost 5000 < /some/log/file.log
echo "local.random.diceroll 4 `date +%s`" | nc -q0 stats 2003 GRAFITE
echo "foo:1|c" | nc -u -w0 stats 8125 STATSD
finding in xml files
aws s3 ls --recursive s3://bucket/ | awk '{print $4}' | grep '.xml' | xargs -I@ aws s3 cp s3://bucket/@ - | grep '35160561230314000507550020001107201294779231' | wc -l
finding in gzip files!!!
s3cmd ls --recursive s3://notafiscal-mailing/ | awk '{print $4}' | grep '.gz' | xargs -I@ s3cmd get @ - | zgrep 'request' | wc -l
@marcusdb
marcusdb / find large arrays in documents
Created June 19, 2016 20:11
Find large arrays in documents
db.collection.aggregate( [
{ $unwind : "$l" },
{ $group : { _id : "$_id", len : { $sum : 1 } } },
{ $sort : { len : -1 } },
{ $limit : 25 }
] )