Skip to content

Instantly share code, notes, and snippets.

Avatar
😁

Amin NAIRI aminnairi

😁
View GitHub Profile
View pip.fish
#!/usr/bin/env fish
# File: $HOME/.config/fish/functions/pip.fish
# Author: Amin NAIRI <https://github.com/aminnairi>
# Usage: pip DOCKER_ARGUMENTS -- NODE_ARGUMENTS
# Example: pip -- install package-name
# Example: pip --publish 8080:8080 -- install package-name
function pip
# A local array of Node.js arguments to proxy
set -l pip_arguments
View python.fish
#!/usr/bin/env fish
# File: $HOME/.config/fish/functions/python.fish
# Author: Amin NAIRI <https://github.com/aminnairi>
# Usage: python DOCKER_ARGUMENTS -- ENTRYPOINT_ARGUMENTS
# Example: python -- --version
# Example: python --tag 8.0.0 -- --version
# Example: python -- script.mjs
# Example: python --tag 8.0.0 -- script.mjs
# Example: python -- --experimental-json-modules module.mjs
@aminnairi
aminnairi / challenge.py
Created Jan 12, 2021
Challenge: write a function difference that compute the difference between
View challenge.py
def difference(first, second):
intersection = []
for item in first:
if not item in second:
intersection.append(item)
for item in second:
if not item in first:
intersection.append(item)
View challenge.js
const asciiTable = text => {
const rows = text.split("\n");
const nonEmptyRows = rows.filter(row => 0 !== row.trim().length);
const normalizedRows = nonEmptyRows.map(row => row.trim());
const rowsColumns = normalizedRows.map(row => row.split("|"));
const initialPadding = [];
const padding = rowsColumns.reduce((pad, row) => row.map((column, index) => {
if ("undefined" === typeof pad[index]) {
return column.length;
@aminnairi
aminnairi / deploy.sh
Last active Sep 8, 2020
GitHub Pages deploy script for Docker Compose project using Yarn
View deploy.sh
#!/bin/sh
# sh deploy.sh
docker-compose exec node yarn build
git add --force dist
git commit -m ":package: new build"
git subtree split --prefix dist -b gh-pages
git push --force origin gh-pages:gh-pages
git reset --hard HEAD^
@aminnairi
aminnairi / docker-compose.yaml
Last active May 26, 2020
Docker Compose settings for Elastic Search + Kibana
View docker-compose.yaml
version: "3"
# docker-compose up --detach
# docker-compose down --remove-orphans --volumes --timeout 0
services:
elasticsearch:
restart: always
image: docker.elastic.co/elasticsearch/elasticsearch:7.7.0
environment:
- "discovery.type=single-node"
@aminnairi
aminnairi / capitalize.js
Created Jun 9, 2019
Capitalize files in a directory recursively
View capitalize.js
const { readdirSync, statSync, renameSync } = require('fs');
function capitalize(input) {
return input.slice(0, 1).toUpperCase() + input.slice(1);
}
function recursivelyCapitalizeFilesAndDirectories(path) {
for (const file of readdirSync(path)) {
const capitalizedFile = capitalize(file);
@aminnairi
aminnairi / MaterializeSelect.js
Last active Mar 5, 2021
Vue.js wrapper for the MaterializeCSS's select component
View MaterializeSelect.js
'use strict';
// https://codesandbox.io/s/v37l3k0k53
const Vue = require('vue') // npm install vue
const M = require('materialize-css') // npm install materialize-css@^1.*
Vue.component('MaterializeSelect', {
template: `
<select :value='value'>
@aminnairi
aminnairi / index.php
Last active Jan 8, 2017
Démonstration image de captcha avec boutton de rechargement en JQuery
View index.php
<!-- type de document -->
<!doctype html>
<!-- dialecte -->
<html lang='fr-FR'>
<head>
<!-- encodage -->
<meta charset='utf8'>
<title>Captcha avec bouton de rechargement</title>
</head>
<body>