Skip to content

Instantly share code, notes, and snippets.

View nfroidure's full-sized avatar
🌻
Getting greener

Nicolas Froidure nfroidure

🌻
Getting greener
View GitHub Profile
@nfroidure
nfroidure / README.md
Last active February 8, 2022 14:23
API docs with CORS

Usage

To use this with any API, just clone the Gist and run the following:

NGINX_API_URL=https://api.example.com API_PATH=/v0/openAPI docker-compose up

Finally browse to : http://docs.localhost:16640.

// Programme qui compte jusque l'infini
// Par Thomas et Nicolas Froidure Stiernon
const depart = Date.now();
let compteur = 0;
while(true) {
if(Math.floor(Math.log10(compteur + 1)) > Math.floor(Math.log10(compteur))) {
console.log(compteur + 1, Math.round((Date.now() - depart) / 60000));
}
@nfroidure
nfroidure / gen_pg_graph.sh
Created November 30, 2020 16:02
Generate a PGSQL Graph
docker run \
-v $(pwd)/pgsql/docs:/home/schcrwlr/share \
--name schemacrawler \
--rm -i -t \
--entrypoint=/bin/bash schemacrawler/schemacrawler \
-c "/opt/schemacrawler/schemacrawler.sh --command=schema --output-format=png --output-file=/home/schcrwlr/share/graph.png --server=postgresql --host=\$(/sbin/ip route|awk '/default/ { print \$3 }') --port=15432 --database=diagrams --schemas=public --user=postgres --password=mysecretpassword --info-level=maximum --log-level=ALL"
var CSV = require('oh-csv');
process.stdout.write(
'<?xml version="1.0" encoding="UTF-8"?>' + '\r\n' +
'<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"' + '\r\n' +
' xmlns:dsq="http://www.disqus.com/" xmlns:dc="http://purl.org/dc/elements/1.1/"' + '\r\n' +
' xmlns:wp="http://wordpress.org/export/1.0/">' + '\r\n' +
' <channel>' + '\r\n'
);
@nfroidure
nfroidure / nock-recorder.js
Last active August 5, 2019 08:11
Snippet to record HTTP traffic
import fs from 'fs';
import nock from 'nock';
nock.recorder.rec({
logging: content => fs.appendFileSync('./nock-records.log', content),
});
<json:object>
<json:string name="text">Hello world!</json:string>
</json:object>
@nfroidure
nfroidure / Promise.js
Last active March 15, 2019 09:51
A simple Promise implementation. Moved to GitHub : https://github.com/nfroidure/Promise/blob/master/Promise.js
var Promise=(function() {
var AWAIT=0, SUCCESS=1, FAIL=-1;
function Promise(logic) {
var promise=this;
promise.solved=AWAIT;
var success=function (value) {
if(AWAIT!==promise.solved)
return;
promise.solved=SUCCESS;
promise.value=value;
@nfroidure
nfroidure / knifecycle-sample2.js
Created January 26, 2019 11:15
Another example with service renaming
import { Knifecycle, constant, autoService, service } from 'knifecycle';
// Initialize the injector
const $ = new Knifecycle();
// Declare constants
$.register(constant('FTP_CONFIG', { user: 'test', password: 'test' }));
$.register(constant('FTP_CONFIG2', { user: 'test2', password: 'test2' }));
// Declare services
@nfroidure
nfroidure / knifecycle-sample.js
Last active January 26, 2019 11:13
Sample usage of Knifecycle
import { Knifecycle, constant, autoService, autoProvider } from 'knifecycle';
// Initialize the injector
const $ = new Knifecycle();
// Declare constants
$.register(constant('FTP_CONFIG', { user: 'test', password: 'test' }));
$.register(constant('DB_CONFIG', { user: 'test', password: 'test' }));
@nfroidure
nfroidure / npm-pkg-files.sh
Created January 12, 2019 07:23
Shows the result of packing a NPM module
tar tvf $(npm pack)