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 / push_node_exporter.sh
Created September 15, 2017 14:43
push node_exporter metrics to push gateway
curl -s http://localhost:9100/metrics | curl --data-binary @- http://pushgateway.example.org:9091/metrics/job/some_job/instance/some_instance
@marcusdb
marcusdb / Program.cs
Created March 21, 2017 17:52
runge-Kutta Method for Solving Differential Equations c#
using System;
using System.Collections.Generic;
namespace Orbital
{
public class RK
{
public struct fValues
ssh -i KEY -C2qTnN -D 8080 USER@HOST
find . -name "*.pdf" -print0 | xargs -0 rm
find . -name "*.req" -print0 | xargs -0 -I file mv file ../
@marcusdb
marcusdb / ntp
Created June 22, 2016 15:22
ntp
sudo service ntp stop
sudo ntpdate -s ntp.ubuntu.com
sudo service ntp start
@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 }
] )
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
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
@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 += ','