Skip to content

Instantly share code, notes, and snippets.

View lutangar's full-sized avatar

Johan Dufour lutangar

View GitHub Profile
@lutangar
lutangar / compar.js
Last active September 16, 2020 15:00
Compare, sort, javascript
export const stringCompare = (a, b) => a.toLocaleLowerCase().localeCompare(b.toLocaleLowerCase())
export const numberCompare = (a, b) => parseFloat(a) - parseFloat(b)
export const dumbCompare = (a, b) => a - b
export const dateCompare = (a, b) => (a < b ? -1 : a > b ? 1 : 0)
export const sortByArchived = (a, b) => dumbCompare(a.archived, b.archived)
export const sortByDate = (a, b) => numberCompare(a.date, b.date) * -1
export const sortInverter = sortFunction => (a, b) => sortFunction(a, b) * -1
export const composeSort = (sortA, sortB) => (a, b) => sortA(a, b) || sortB(a, b)
@lutangar
lutangar / WindowPort.ts
Created June 3, 2020 13:21
An attempt at creating a postMessage window communication class implementing the Port interface
type ResponseCallback = (response: object) => void;
type PortCallback = (port: browser.runtime.Port) => void;
interface EventListenerRegistry {
listeners: [];
}
class WindowPort implements browser.runtime.Port {
private readonly window: Window;
private readonly targetOrigin: string;
@lutangar
lutangar / edupython.md
Last active January 18, 2021 15:06
Alternative à Edupython (ou amienspython) pour Linux et Mac

Alternative à edupython

Edupython (ou amienspython) est un logiciel originalement dérivé de pyscripter (cf. documentation de edupython un logiciel écrit dans le langage de programmation delphi et donc uniquement disponible pour Windows.

Pour les utilisateurs Mac ou Linux (et même pour ceux qui utilisent Windows d'ailleurs !), je vous recommande d'utiliser le logiciel thonny qui est plus moderne, plus simple et donc mieux adapté à des débutants.

Mis au point par l'Université de Tartu en Estonie, Thonny est un IDE (environnement de développement) minimaliste qui permet d'apprendre le Python. https://korben.info/thonny-un-ide-python-pour-les-debutants.html

De plus thonny est entièrement traduit en français.

@lutangar
lutangar / docker-ce.yml
Last active October 18, 2021 19:01
Ansible task to setup docker-ce on ubuntu or debian
---
- name: Update the `apt` package index
apt:
update_cache: yes
- name: Install packages to allow apt to use a repository over HTTPS
package:
name: "{{ item }}"
state: latest
047a9aca6653b60cbf3432275f16f17048159865603d125017bca128efb95a10700c9d22ee59f2710ed9595ed767c2033ab7a618c352528eb2d03aae801e725e8c pocky
@lutangar
lutangar / ArrayCollection.php
Created June 4, 2015 12:01
ArrayCollection based on Doctrine's Collection and ArrayCollection
<?php
namespace Collection;
use ArrayIterator;
use Doctrine\Common\Collections\Collection as CollectionInterface;
use Closure;
/**
* Class ArrayCollection
@lutangar
lutangar / .gitignore
Last active August 29, 2015 14:16 — forked from octocat/.gitignore
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
function Donut(name, flavor, description) {
this.id = _.uniqueId();
this.name = name || 'A random donut';
this.flavor = name || 'Default flavor';
this.description = '';
this.stuffed = false;
};
Donut.prototype.stuff = function (jam) {
this.stuffed = true;
@lutangar
lutangar / BaseManager.php
Last active August 29, 2015 14:07
BaseManager
<?php
namespace GeorgetteParty\Manager\BaseManager;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityNotFoundException;
/**
* Class BaseManager
*
@lutangar
lutangar / example-itk.conf
Last active August 29, 2015 14:03
Sample Vhost configuration example for apache2.4 (with itk to host under your home, or without to host under /var/www)
<VirtualHost *:80>
ServerName example.io
ServerAlias my.example.io
ServerAlias example.com
DocumentRoot "/home/myuser/workspace/example.io"
# Directory
<Directory /home/myuser/workspace/example.io>
Require all granted