Skip to content

Instantly share code, notes, and snippets.

View mrf345's full-sized avatar

Mohamed Feddad mrf345

  • UAE
View GitHub Profile
@mrf345
mrf345 / compton.conf
Last active December 10, 2019 09:55
compton config on archlinux nvidia drivers
#################################
#
# Backend
#
#################################
# Backend to use: "xrender" or "glx".
# GLX backend is typically much faster but depends on a sane driver.
backend = "glx";
@mrf345
mrf345 / choice.js
Last active March 6, 2018 06:46
Choose randomly from an Array ES6
const Choice = (list) => {
// to choose randomly from an Array
let powerOfLength = Math.floor(list.length / 10)
if (powerOfLength <= 0) powerOfLength = 1
let toReturn = list[Math.floor(Math.random() * (10 * powerOfLength))]
return toReturn ? toReturn : Choice(list)
}
Choice([1, 2, 3, 4, ,5])
@mrf345
mrf345 / isint.py
Created October 23, 2017 15:40
isInt the right way python3
def isInt(inp):
return isinstance(inp, int)
@mrf345
mrf345 / grid.py
Created October 23, 2017 14:58
Function to draw a grid Python3
def quare(leng=4, height=4, hmh=2, hmv=2, counter=1):
if counter > hmv:
return True
def pit(inp, num):
print(inp * num)
pit("+" + "-" * leng + "+" + " ", hmh)
for a in range(height-1):
pit("|" + " " * leng + "|" + " ", hmh)
pit("+" + "-" * leng + "+" + " ", hmh)
return quare(leng, height, hmh, hmv, counter+1)
@mrf345
mrf345 / build_flask_.sh
Created October 7, 2017 13:20
Building one-file executable for Python Flask using Pyinstaller
#!/bin/bash
pyinstaller -F -w \
--hidden-import='email.mime.multipart' \
--hidden-import='email.mime.message' \
--hidden-import='email.mime.text' \
--hidden-import='email.mime.image' \
--hidden-import='email.mime.audio' \
--hidden-import='sqlalchemy.sql.default_comparator' \
--hidden-import='jinja2' \
main.py
@mrf345
mrf345 / setup.py
Created July 22, 2017 17:45
Flask app's cx_freeze's setup.py file.
from cx_Freeze import setup, Executable
include_files = [ 'app/templates/',
'app/static/',]
# Note: without 'jinja2.ext' in this list, we won't get the templates working.
include = [ 'jinja2', 'jinja2.ext',]
flaskapp = Executable(script="run.py",
base="Win32GUI",