Skip to content

Instantly share code, notes, and snippets.

Hugo HugoPoi

Block or report user

Report or block HugoPoi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@HugoPoi
HugoPoi / oplog_estimate_per_collection.js
Created Feb 1, 2019
MongoDB get estimate oplog per collection with profiler
View oplog_estimate_per_collection.js
// https://docs.mongodb.com/manual/tutorial/manage-the-database-profiler/#enable-and-configure-database-profiling
(() => {
return db.system.profile.aggregate([
{ $match: { $or: [{op: {$in: ['update', 'insert', 'delete']}}, {'command.writeConcern': {$exists: true}}] } },
{ $group: {_id: {op : '$op', ns: '$ns', client: "$client"}, count: {$sum: 1}, start: {$min: "$ts"}, end: {$max: "$ts"} } },
{ $match: { count: { $gt: 50}}},
{ $sort: {count: -1} }
]).map((requestStats) => {
@HugoPoi
HugoPoi / get_collections_sizes.js
Created Jan 30, 2019
MongoDB Get collections storage sizes in GB sorted
View get_collections_sizes.js
(() => {
let datas = [];
db.getCollectionNames().forEach(colName => {
let stats = db.getCollection(colName).stats();
datas.push({
colName,
size : stats.storageSize,
humanSize: (stats.storageSize / (1024*1024*1024)) + ' GB'
});
@HugoPoi
HugoPoi / Resize virtual machine partition.md
Last active Mar 17, 2019
How to resize virtual machine partition after extend the disk
View Resize virtual machine partition.md

Resize a VM system disk

Introduction

  • You have a VM with small disk
  • You have GPT partition table
  • You NOT USE LVM (you should)
  • You need to extend a partition on the main drive
  • You use Debian 8.x aka Jessie

Extend the disk

@HugoPoi
HugoPoi / sample.test.js
Created Jun 18, 2018
Loopback sample mocha unit test
View sample.test.js
'use strict';
const loopback = require('loopback');
const expect = require('chai').expect;
const request = require('supertest');
describe('Test relations update support', function() {
// Create a new loopback app.
@HugoPoi
HugoPoi / concurrent-request-agent.test.js
Created Jun 4, 2018
Test concurrent calls with an agentClass ( mocha runner )
View concurrent-request-agent.test.js
/*jshint node: true*/
"use strict";
process.env.NODE_ENV = 'test';
const assert = require('assert');
const Request = require('request-promise');
const HttpsAgent = require('socks5-https-client/lib/Agent');
const Promise = require('bluebird');
@HugoPoi
HugoPoi / iptables_reset.sh
Created Mar 15, 2018
Iptables reset policies
View iptables_reset.sh
#!/bin/sh
IPTABLES="$(which iptables)"
# RESET DEFAULT POLICIES
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -t nat -P PREROUTING ACCEPT
$IPTABLES -t nat -P POSTROUTING ACCEPT
$IPTABLES -t nat -P OUTPUT ACCEPT
@HugoPoi
HugoPoi / liste_de_noel.md
Last active Sep 22, 2019
Liste de noël
View liste_de_noel.md
@HugoPoi
HugoPoi / robomongo.desktop
Created Nov 10, 2017
Shorcut robomongo cinnamon ~/.local/share/applications/
View robomongo.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Encoding=UTF-8
Name=Robomongo
Comment=Launch Robomongo
Icon=/opt/robomongo/robomongo.png
Exec=/usr/sbin/robomongo
Terminal=false
Type=Application
Categories=Developer;
@HugoPoi
HugoPoi / dbxcligetfiles.sh
Created Jul 5, 2017
Download only certain file with dbxcli
View dbxcligetfiles.sh
#!/bin/bash
#
# Usage : dbxcligetfiles.sh "\*\.png" /Webdesign
#
dbxcli search $1 $2 | while read line
do
echo $line
mkdir -p ".${line%/*}"
dbxcli get "$line" ".$line"
done
You can’t perform that action at this time.