Skip to content

Instantly share code, notes, and snippets.

View ollie314's full-sized avatar

Mehdi Lefebvre ollie314

View GitHub Profile
@ollie314
ollie314 / main.c
Created April 13, 2024 16:27
Sample Gtk application
/* Sample using gtk3 */
/* Compiling: gcc `pkg-config --cflags gtk+-3.0` -o main main.c `pkg-config --libs gtk+-3.0`*/
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
void on_window_destroy(GtkWidget *widget, gpointer data)
{
gtk_main_quit();
}
@ollie314
ollie314 / dynamic-col-table.component.html
Created November 8, 2022 22:21
Gist for dynamic table sample (dipm)
<p-button label="Add Col" (onClick)="addColumn()"></p-button>&nbsp;
<div class="flex">
<div *ngFor="let col of colsHeader; index as j; trackBy: colTrackFunc"
[ngClass]="getRowClass()">
<div class="dipm-col-item" *ngIf="j === 0">Nom colonne</div>
<div class="dipm-col-item" *ngIf="j > 0">
<button pButton pRipple label="Remove Column" class="p-button-outlined mr-2" (click)="removeColumn(j)"></button>
</div>
</div>
</div>
@ollie314
ollie314 / stopwatch.elm
Created May 10, 2022 05:45
Elm Stopwatch sample
import Browser
import Html exposing (..)
import Html.Events exposing (onClick)
import Task
import Time
main =
Browser.element
{ init = init
, view = view
@ollie314
ollie314 / iam.ts
Last active May 29, 2022 13:58
Sample DDD implementation
// This is a work in progress to support a workshop.
module Utils {
export namespace Duration {
export type DurationTime = number;
export type DurationUnit =
| "h"
| "hours"
| "m"
| "min"
| "mins"
@ollie314
ollie314 / Dockerfile
Last active March 26, 2022 13:21
nestjs multistage non root dockerfile
# =========== Build ===========
FROM node:16.14.2-buster As development
WORKDIR /usr/src/app
RUN chown -R node:node /usr/src/app
USER node:node
COPY --chown=node:node package*.json ./
RUN npm ci
COPY --chown=node:node . .
RUN npm run build
@ollie314
ollie314 / yo-generator.js
Last active June 26, 2021 22:44
Simple yeoman generator for recursive structure (sample excerpt)
const Generator = require('yeoman-generator');
const faker = require('faker');
const uuid = require('uuid');
const chalk = require('chalk');
const id = () => uuid.v4();
const rand = (min, max) => Math.ceil(Math.random() * (max - min)) + min;
const params = (type, max) => ({
@ollie314
ollie314 / sample.py
Created December 7, 2020 14:20
Oracle connection and database export with python 3.6+
1# https://oracle.github.io/python-cx_Oracle/samples/tutorial/Python-and-Oracle-Database-Scripting-for-the-Future.html#overview
2import cx_Oracle
3import db_config
4
5
6###################################################################################
7# Connect to an oracle database
8###################################################################################
9con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
10print("Database version: ", con.version)
@ollie314
ollie314 / rank.js
Created November 14, 2020 08:14
Simple implementation of last step of the random condorcet toss
const echo = m => console.log(m);
const rand = (max, min = 0) => Math.ceil(Math.random() * (max - min) + min);
const even = x => x % 2 == 0;
const rank = (stack) => {
const f = (b) => {
if(b.length == 0) return; // shouldn't happens
if(b.length == 1) {
echo(b[0]);
return;
}
@ollie314
ollie314 / identityResolver.fs
Created September 6, 2020 22:08
Simple sample to resolve identity
module IdentificationProcessing
open System
open Domain
open ContractDomain
type DataSubjectIdentityResolver =
string // the name of the type
-> obj // the object instance to look into
-> string // the owner identity
@ollie314
ollie314 / sample.js
Created August 19, 2020 20:10
This is a simple function to demonstrate the first step of the event enrichment process principle.
const { generateKeyPair, createHash, publicEncrypt, privateDecrypt, constants: { RSA_PKCS1_PADDING } } = require('crypto');
const path = require('path');
const { readFileSync } = require('fs');
const chalk = require('chalk');
function genKey() {
generateKeyPair('rsa', {
modulusLength: 4096,
publicKeyEncoding: {
type: 'spki',