Skip to content

Instantly share code, notes, and snippets.

View Musinux's full-sized avatar

Louis Cherel Musinux

View GitHub Profile
@Musinux
Musinux / guacamole-add-connection.js
Created January 12, 2017 09:34
CLI Add an instance to an user for guacamole
var parseString = require('xml2js').parseString
var builder = new (require('xml2js').Builder)()
var fs = require('fs')
var argv = require('optimist')
.usage('Usage: $0 --input <input.xml> --name <machine-name>')
.options('hostname', {default: '@host'})
.options('port', {default: '3389'})
.options('serverLayout', {default: 'fr-fr-azerty'})
.options('colorDepth', {default: '16'})
.demand('name')
@Musinux
Musinux / install-packages.sh
Last active March 29, 2021 12:49
VNC xstartup for unity WARNING ! THIS WAS WRITTEN A LONG TIME AGO (2018), IT MAY NOT BE RELEVANT ANYMORE
#!/bin/bash
# WARNING ! THIS WAS WRITTEN A LONG TIME AGO (2018), IT MAY NOT BE RELEVANT ANYMORE
sudo apt-get install vnc4server ubuntu-desktop
sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
@Musinux
Musinux / javascript-functions-contexts.js
Last active March 24, 2017 09:22
Hint of different behaviors of functions depending on context in which the function is defined and executed
'use strict' // attention ces considérations ne sont valides qu'en utilisant le mode strict
var globale = 'globale'
var methode3 = () => {
if (!this || !this.attrLocal) {
console.log(' > methode3() NE partage PAS le contexte de Classe1')
}
if (this && this.attrLocal) {
console.log(' > methode3() partage le contexte de Classe1')
#!/usr/local/bin/node
var irc = require('irc')
var me = 'me'
var channel = '#chann'
var dest = 'dest'
var data = '\x24\xb1\x04\x08' // 0x804b120
var client = new irc.Client('irc.root-me.org', me, {
@Musinux
Musinux / node-postgres-benchmark.js
Last active October 1, 2017 11:25
Small benchmark tool for db drop, create, insert and select *
const { Pool } = require('pg')
const debug = require('debug')('a')
const defaultParams = {
database: 'postgres',
user: 'myuser',
password: 'mysecretpassword',
host: 'localhost',
port: 5432
}
@Musinux
Musinux / drive-v3-fetch-children.js
Created January 17, 2018 00:00
nodejs drive api v3 fetch children files from folder
const GoogleAuth = require('google-auth-library')
const OAuth2Client = GoogleAuth.OAuth2Client
const google = require('googleapis')
const clientId = '<YOUR_CLIENT_ID>'
const clientSecret = '<YOUR_CLIENT_SECRET>'
const redirectUri = '<Your URI Callback>'
const oauth2Client = new OAuth2Client(clientId, clientSecret, redirectUri)
// your oauth method, see documentation
@Musinux
Musinux / cssToInlineStyle.js
Created July 4, 2018 07:48
Node.js implementation of transforming a <style> tag to inline style. Useful to tranform Google Documents into Email-compatible format
const cssParser = require('css')
const { JSDOM } = require('jsdom')
function cssToInlineStyle (inputHtml) {
let style = inputHtml.match(/(?:<style[^>]*>)((?:[\r\n]|.)*?)(?:<\/style>)/)
const html = inputHtml.replace(/<style[^>]*>(([\r\n]|.)*?)<\/style>/, '')
if (!style) {
throw new Error('error while parsing')
}
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Titre de la page</title>
<style>
nav ul li {
display: inline-block;
border: 1px solid red;
width: 200px;
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Titre de la page</title>
<style>
nav ul li {
display: inline-block;
border: 1px solid red;
width: 200px;
/* globals Vue */
;(function () {
'use strict'
const template = `
<section id="accueil">
<h1>Titre de ma page d'accueil</h1>
<p>Mon super texte</p>
</section>
`