Skip to content

Instantly share code, notes, and snippets.

View coboshm's full-sized avatar

Marc Cobos Hernandez coboshm

View GitHub Profile
@coboshm
coboshm / golang_kinesis_redshift.go
Created August 28, 2017 09:12
Golang Script to put and consume from kinesis + store to redshift
package main
import (
"log"
"encoding/json"
"fmt"
"os"
"math/rand"
@coboshm
coboshm / golang_kinesis.go
Created August 21, 2017 07:54
Golang + Kinesis firehose
package main
import (
"log"
"encoding/json"
"fmt"
"os"
"math/rand"
@coboshm
coboshm / benchmark_aggregation.js
Last active February 27, 2017 09:52
Aggregation benchmark
var db = connect('localhost:27020/dev');
// timed queries
var numQueries = 1000, start = Date.now(), res;
for (var i = numQueries; i--;) {
res = db.scan.aggregate([
{ $match: { client_id: ObjectId("58b19c4872d797313163b8f4"), country: {$in: ["ITA", "FRA", "ES"]} } },
{ $group: { _id: "$summary_id", status: { $min: "$status"}, score: { $max: "$score"}}},
{ $sort: { created_at: 1} },
@coboshm
coboshm / README
Created February 8, 2015 22:05
TCP Modbus java (master) - python (slave)
Marc Cobos
======
To execute the modbus master you have to do the following commands:
javac -classpath jamod-1.2-SNAPSHOT.jar:opencsv-3.1.jar modbus_client.java
java -cp jamod-1.2-SNAPSHOT.jar:opencsv-3.1.jar:. modbus_client
======
This code use the jamod and opencsv libraries
@coboshm
coboshm / gist:196ed76b65cad07d8d04
Created February 8, 2015 22:03
Get number of each petition access.log
#!/bin/bash
# Author: Marc Cobos
FILE=test.access.log
types=(GET PUT DELETE HEAD POST TRACE OPTIONS CONNECT PATCH);
for i in ${!types[*]}
do
COUNT=`grep ${types[$i]} $FILE |wc -l`;
echo "$COUNT: ${types[$i]}";
@coboshm
coboshm / gist:fa40190cd039eb68ade9
Created February 8, 2015 22:03
Access.log get the first five ip with more visits and the number of visits
#!/bin/bash
# Author: Marc Cobos
FILE=test.access.log
for ip in `cat $FILE |cut -d ' ' -f 1 |sort |uniq`;
do
COUNT=`grep ^$ip $FILE |wc -l`;
echo $COUNT ' : ' $ip
done | sort -rn -k1 | head -5