Skip to content

Instantly share code, notes, and snippets.

View flaudanum's full-sized avatar

Frédéric Laudarin flaudanum

  • 365Talents
  • Lyon, France
View GitHub Profile
@flaudanum
flaudanum / Makefile
Created March 8, 2018 21:34
C++ stringtools dynamic library
# Install the dynamic library:
# make CLEAN
# make
# LIB_SONAME="libstrtools.so"
# ln -sf $PWD/$LIB_SONAME.1.0 $PERSO_LIB_DIR/$LIB_SONAME
# ln -sf $PWD/$LIB_SONAME.1.0 $PERSO_LIB_DIR/$LIB_SONAME.1
# C++ compiler
CC = g++
@flaudanum
flaudanum / matrix.hpp
Created March 8, 2018 21:28
C++ templating - Class Matrix
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <vector>
#include<random>
#include<chrono>
typedef unsigned int size_type;
@flaudanum
flaudanum / ColorBar.cpp
Last active March 8, 2018 21:25
Qt C++ code samples (fractal palette)
#include "ColorBar.hpp"
QPen ColorBar::pen(Qt::black, 1, Qt::SolidLine);
ColorBar::ColorBar(QWidget* parent) : QDialog(parent)
{
@flaudanum
flaudanum / center.py
Last active March 6, 2018 21:02
PyQt5 basic examples from the zetcode.com tutorial
# -*- coding: utf-8 -*-
"""
ZetCode PyQt5 tutorial
This program centers a window
on the screen.
Author: Jan Bodnar
Website: zetcode.com
@flaudanum
flaudanum / subprocess1.py
Created February 15, 2018 09:19
Python: run a shell process with subprocess.run (python >=3.5)
"""
Synopsis:
Run the shell command 'du -h -d 1 /home/user_name/DEV' from a python script. Print the output
Python 3.5 and later
"""
import subrprocess
# Option 1
@flaudanum
flaudanum / postgresql1.sql
Last active February 14, 2018 11:07
PostgreSQL operation conditionned by the existence of a role
DO
$body$
BEGIN
IF EXISTS (
SELECT FROM pg_roles WHERE rolname = 'role_name') THEN
DROP ROLE cba_admin;
END IF;
END
$body$;