Skip to content

Instantly share code, notes, and snippets.

View HugoPoi's full-sized avatar

Hugo Poissonnet HugoPoi

View GitHub Profile
@HugoPoi
HugoPoi / sources.list
Created February 4, 2022 12:06
Default sources list Bullseye
deb http://deb.debian.org/debian bullseye main
deb-src http://deb.debian.org/debian bullseye main
deb http://security.debian.org/debian-security bullseye-security main
deb-src http://security.debian.org/debian-security bullseye-security main
deb http://deb.debian.org/debian bullseye-updates main
deb-src http://deb.debian.org/debian bullseye-updates main
@HugoPoi
HugoPoi / Install Mastodon-Twitter Crossposter on Docker.md
Last active April 5, 2020 21:25
Install Mastodon-Twitter Crossposter on Docker

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 February 1, 2019 17:08
MongoDB get estimate oplog per collection with profiler
// 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 January 30, 2019 16:21
MongoDB Get collections storage sizes in GB sorted
(() => {
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 October 3, 2023 06:55
How to resize virtual machine partition after extend the disk

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 June 18, 2018 16:55
Loopback sample mocha unit test
'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 June 4, 2018 10:55
Test concurrent calls with an agentClass ( mocha runner )
/*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 March 15, 2018 16:16
Iptables reset policies
#!/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 September 22, 2019 12:01
Liste de noël