Skip to content

Instantly share code, notes, and snippets.

Avatar

Hugo HugoPoi

View GitHub Profile
@HugoPoi
HugoPoi / Install Mastodon-Twitter Crossposter on Docker.md
Last active Apr 5, 2020
Install Mastodon-Twitter Crossposter on Docker
View Install Mastodon-Twitter Crossposter on Docker.md

Setup on Docker

Start the stuff

  1. docker-compose up -d --build

Setup the db

  1. docker exec mastodon-twitter-poster_web_1 bundle exec rake db:setup ^ this crash because it assume you have psql localy and direct connection
  2. cat db/structure.sql | docker exec -i mastodon-twitter-poster_db_1 psql --user postgres --db mastodon_twitter_poster_production

Other usefull command

@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 Jun 8, 2020
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;
You can’t perform that action at this time.