Skip to content

Instantly share code, notes, and snippets.

View mrf345's full-sized avatar

Mohamed Feddad mrf345

  • UAE
View GitHub Profile
@mrf345
mrf345 / form.py
Created December 6, 2018 02:27
Modified form with translation
class Touch_name(FlaskForm):
name = SelectField(coerce=str)
submit = SubmitField("Register")
def __init__(self, defLang='en', *args, **kwargs):
super(Touch_name, self).__init__(*args, **kwargs)
self.name.label = gtranslator.translate("Select one of the following options :", 'en', [defLang])
self.name.choices = [(t[0], gtranslator.translate(t[1], 'en', [defLang])) for t in [
("First option", "First option"),
("Second option", "Second option"),
{% macro beloadingNotifier(version, beload=True, firefox="firefox", release="new release") %}
<!--
Simple macro to load beloading for fading and browser_notifier for
firefox confirmation and new release confirmation
-->
<script src="{{ url_for('static', filename='beloading.js') }}"></script>
<script src="{{ url_for('static', filename='browserNotifier.js') }}"></script>
<script type='text/javascript'>
$(document).ready(function () {
/*
@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
@mrf345
mrf345 / send_sms.py
Created July 26, 2018 08:12 — forked from m0rff/send_sms.py
Sending a SMS with Python and pyserial via an USB 3G Modem on pfSense/FreeBSD
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
#
# Sending a SMS with Python and pyserial via an USB 3G Modem on pfSense/FreeBSD
# tested with: Huawei Technologies Co., Ltd. E620 USB Modem
# and a Telekom SIM card
import serial
from curses import ascii
import time
@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 / 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 / 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 / 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 / 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