Skip to content

Instantly share code, notes, and snippets.

View mrf345's full-sized avatar

Mohamed Feddad mrf345

  • UAE
View GitHub Profile
@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",
@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 / 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 / isint.py
Created October 23, 2017 15:40
isInt the right way python3
def isInt(inp):
return isinstance(inp, int)
@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 / 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 / wallpapers.sh
Created March 31, 2018 13:06
feh wallpapers setting loop
#!/bin/bash
d=$1 # Directory
t=$2 # Duration
if [ "$1" == "" ];then
d=~/Pictures/Cities
fi
if [ "$2" == "" ];then
t=300 # 5 minuts
fi
@mrf345
mrf345 / compton.conf
Last active March 31, 2018 13:13
exwm compton configuration file
backend = "glx";
glx-no-rebind-pixmap = true;
shadow = false;
menu-opacity = 0.8;
inactive-opacity = 0.7;
active-opacity = 1;
frame-opacity = 0.9;
inactive-opacity-override = true;
alpha-step = 0.06;
blur-background = true;
@mrf345
mrf345 / brightness.sh
Last active February 9, 2019 12:44
control backlight brightness on linux window manager
#!/bin/bash
config_file=/sys/class/backlight/intel_backlight/brightness
brightness=$(cat $config_file)
max_brightness=100000
brightness_measure=$(( max_brightness / 10 ))
function get_percentage() {
percent=$(( $brightness * 100 / $max_brightness ))
echo Brightness: $percent/100
}
@mrf345
mrf345 / redshifted.sh
Created April 3, 2018 13:10
to control redshift backlight
#!/bin/bash
tmp_file=/tmp/redshifted
max_tem=7000
if [ ! -f $tmp_file ];then echo $max_tem > $tmp_file ;fi
current_tem=$(cat $tmp_file)
function get_percentage () {
echo Redshift $(( $current_tem * 100 / $max_tem ))/100
}