Skip to content

Instantly share code, notes, and snippets.

View Trismegiste's full-sized avatar

Florent Genette Trismegiste

  • 3rd planet from the sun
View GitHub Profile
@Trismegiste
Trismegiste / README.md
Last active November 21, 2022 16:50
Choix d'un e-commerce
@Trismegiste
Trismegiste / Cours J1.md
Last active May 5, 2022 08:31
Cours POO

Outils de Programmation Orientée Objet

Definition Paradigme de programmation qui permet de rendre compréhensible un programme autant par un terrien que par une machine. Façon de découper un problème en petites unités représentant des concepts d'un métier

Encapsulation

class Animal {
  public $couleur;
@Trismegiste
Trismegiste / BluetoothDaemon.php
Last active March 13, 2022 08:48
Bluetooth daemon with tailable cursor
<?php
/*
* eclipse-wiki
*/
namespace App\Command;
use App\Entity\BtMessage;
use App\Repository\BluetoothMsgRepository;
@Trismegiste
Trismegiste / list.txt
Last active September 14, 2018 19:36
Exemples pour ffmpeg
Crop sans recoder
-------------------
ffmpeg -i 20180905_190019A.mp4 -vcodec copy -acodec copy -ss 00:00:20.000 -t 00:01:40 connard1.mp4
ffmpeg -i rr.wav -ss 1.35 -t 8.45 cropped.wav
Fliper une vidéo
----------------
ffmpeg -i You.mp4 -vf "hflip" -c:a copy toto.mp4
Faire une GIF animé
@Trismegiste
Trismegiste / PromiseALL.js
Created November 27, 2016 21:09
javascript Promise loop & XHR
function toDataUrl(url) {
return new Promise(function (fulfill, reject) {
var xhr = new XMLHttpRequest()
xhr.responseType = 'blob'
xhr.onload = function (e) {
if (e.target.status === 200) {
var reader = new FileReader()
reader.onloadend = function (e) {
fulfill(e.target.result)
}
@Trismegiste
Trismegiste / Inheritance in ES5.js
Last active November 27, 2016 13:41
Inheritance in js ES5
var Render = function (name) {
this.name = name;
}
Render.prototype.getName = function () {
return this.name;
}
var NephilimRender = function (name) {
Render.call(this, name)
@Trismegiste
Trismegiste / model in RiotJS.md
Last active November 27, 2016 02:50
Howto: don't mess with RiotJS

3 ways to implement the model in RiotJS tags (from best to worst)

  • use a global namespace to contain the model
  • declare the model in the "root" tags and inject it in sub tags components with attributes of the tag (hard & not dry)
  • sub tags are calling this.parent.model : bad, a controller is not a mediator
@Trismegiste
Trismegiste / httpd.conf
Created July 29, 2015 22:05
Conf prod for apache
<filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
@Trismegiste
Trismegiste / mem.php
Last active August 29, 2015 14:26
memory and disk on linux
<?php
function getSystemMemInfo()
{
$data = explode("\n", file_get_contents("/proc/meminfo"));
$meminfo = array();
foreach ($data as $line) {
list($key, $val) = explode(":", $line);
$meminfo[$key] = trim($val);
}
@Trismegiste
Trismegiste / Thoughts for a symfony app.md
Last active June 10, 2021 13:51
Things to check in your symfony app

12 things to check in your symfony app

0. Start your app without a database

Let's be clear, every serious app need a db, but designing and building an app by starting with a bunch of SQL statements is a worst of the worst practice. DDD concerns dictate you must start with the Model, not the database. By starting your app with what you'll store in a database, you don't abstract anything, you can't find commonn object behavior, common class contract, all OOP is doomed forever, particulary if you use an ORM/ODM. So, start building controllers, routes, security and mock repositories for fake datas.

1. Avoid anemic model

Your model must be smart, with business-aware methods. Avoid model class with a bunch of dumb getters/setters (in that case, why use OOP ?). Strict constructor is a fast and easy way to build valid object for example.

2. Make dumb controllers

A controller in a web app deals with http "dirty work". It must know how to deal with a request, build a response, instantiate a form or choos