Skip to content

Instantly share code, notes, and snippets.

View Sigmanificient's full-sized avatar
🎲
Continuing random projets

Yohann Boniface Sigmanificient

🎲
Continuing random projets
View GitHub Profile
@Sigmanificient
Sigmanificient / _stack.py
Last active January 16, 2022 16:51
Python Stack module, in 1 line !
Stack = (lambda _stack, _example: _stack, lambda _stack, _example: print(_example))[__name__ == '__main__'](((EmptyStack := type("EmptyStack", (), {})), (_stack := type("Stack", (), {'__init__': lambda self: setattr(self, "__stack", []), 'add': lambda self, item: (self.__stack.append(item), self)[1], 'peek': lambda self: self.__stack[-1] if len(self.__stack) else EmptyStack(), 'pop': lambda self: self.__stack.pop() if len(self.__stack) else EmptyStack(), '__len__': lambda self: len(self.__stack), '__iter__': lambda self: iter(self.pop() for _ in self.__stack), '__repr__': lambda self: "<Stack(%s)>" % ', '.join(repr(item) for item in self.__stack), '__list__': lambda self: list(self.__stack)})))[1], _stack().add("Hello").add("world"))
@Sigmanificient
Sigmanificient / pypi_upload.bat
Created August 29, 2021 16:13
Bat script to upload to pypi automatically with venv
cd ..
venv\Scripts\python.exe -m setup sdist bdist_wheel
venv\Scripts\python.exe -m twine check dist/*
venv\Scripts\python.exe -m twine upload --repository-url https://upload.pypi.org/legacy/ dist/* -u %1 -p %2 --skip-existing
@Sigmanificient
Sigmanificient / pipenv.bat
Last active August 29, 2021 16:17
Adding pipenv
pip install pipenv :: Install pipenv
cd your_project :: Going to your project
pipenv shell :: Initializing and entering shell
pipenv install %1 :: install any package in your isolated env now
pip freeze :: This will show pipenv's modules if shell is activated
@Sigmanificient
Sigmanificient / function.mysql
Created October 11, 2021 01:53
A mysql routine to insert value within a table and retrieve the pk (with autoincrement)
drop function if exists create_server;
delimiter $$
CREATE FUNCTION create_server(server_name varchar(50), user_id int)
RETURNS int
DETERMINISTIC
BEGIN
INSERT INTO server(name, owner_id) VALUES (server_name, user_id);
return last_insert_id();
@Sigmanificient
Sigmanificient / .scrutinizer.yml
Created October 13, 2021 21:38
A small snippet of yaml for 3.8.6 scrutinizer configuation
build:
environment:
python:
version: 3.8.6
virtualenv: true
checks:
python:
code_rating: true
duplicate_code: true
from string import ascii_lowercase
from time import perf_counter
from typing import Tuple, Generator, List
CHARSET_LENGTH = len(ascii_lowercase)
Pair = Tuple[int, int]
Key = Tuple[int, int, int, int]
@Sigmanificient
Sigmanificient / makefile
Created March 24, 2022 11:31
A Makefile to create a production mode symfony app within the localserver.
SHELL := /bin/bash
SERVER_PATH := /srv/http
ARROW := \033[1m\033[31m>\033[32m>\033[33m>\033[39m
CL_GREEN := \033[32m
CL_RESET := \033[39m
local:
@Sigmanificient
Sigmanificient / fizzbuzz.sm
Created April 7, 2022 23:28
FizzBuzz in Samarium
=> * {
i: /;
.. {
string: "";
? i --- // :: \ {
string+: "fizz";
}
? i --- /\/ :: \ {
string+: "buzz";
}
@Sigmanificient
Sigmanificient / deploy.yml
Created April 7, 2022 23:32
Deploy a vue app from CI/CD
name: 🚀 Deploy website on push
on:
workflow_dispatch:
push:
branches:
- master
jobs:
web-deploy:
name: 🎉 Deploy
@Sigmanificient
Sigmanificient / Makefile
Created April 27, 2022 18:15
lolcat echo support check for prettier Makefile
# - lolcat suffix check -
COLOR := $(shell command -v lolcat)
ifeq (, $(COLOR))
COLOR=
else
COLOR= |lolcat
endif
# ----------------------