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 / 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 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 / 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 / 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
}
@mrf345
mrf345 / gotoSleep.el
Created April 3, 2018 16:38
Put linux to sleep if emacs idle for 1 hour
;; Put system to sleep, if emacs idle for 1 hour
(defun gotoSleep ()
(interactive)
(minibuffer-message "Going to Sleep !")
(shell-command "systemctl suspend")
)
(run-with-idle-timer (* 60 60) nil 'gotoSleep)
@mrf345
mrf345 / skeptic.bat
Created May 5, 2018 12:19
RMT trojan removal batch script for windows
@echo off
rem Latest update 13 march 2015 .. Fixing bug in retrieving files from USB
rem #head
:head
setlocal enabledelayedexpansion
:tm
rem The number of temproray files is 6
set /a sn=6
set /a an=an+1
if !an! gtr !sn! ( goto :body )
@mrf345
mrf345 / getUUID.js
Last active November 26, 2018 02:46
Creating anonymous UUID in JavaScript using combination of IP address and User-Agent
const getUUID = (
service='https://api.ipify.org/?format=json',
key='ip'
) => {
return new Promise(
(resolve, reject) => {
fetch(service)
.then((r) => r.json())
.then((j) => {
let r = /\D+/g