Skip to content

Instantly share code, notes, and snippets.

View efazati's full-sized avatar
🎯
Focusing

Mohammad Efazati efazati

🎯
Focusing
View GitHub Profile
@efazati
efazati / title.py
Created January 4, 2013 10:21
flask title decorator, set title easy and simple
from functools import wraps
def title(title=None):
def decorator(f):
@wraps(f)
def decorated_function(*args, **kwargs):
g.page_title = title
return f(*args, **kwargs)
return decorated_function
@efazati
efazati / persian.js
Created January 4, 2013 10:47
convert English number to Persian
$("body td").each(function(){
$(this).html(
$(this).html().replace(/\d/g, function(v) {
return String.fromCharCode(v.charCodeAt(0) + 0x06C0);
})
);
})
@efazati
efazati / router.js
Created September 10, 2012 08:25
router
router = {};
router.hashchange = {
"requstables": [],
'add': function (regex, requstable) {
router.hashchange.requstables.push({'regex': regex, 'requstable': requstable});
},
'handler': function () {
for (var i = 0; i < router.hashchange.requstables.length; i++) {
var r = router.hashchange.requstables[i];
@efazati
efazati / zshrc
Created July 26, 2012 01:44
my zsh rc code
# Filename: /etc/zsh/zshrc
# Purpose: config file for zsh (z shell)
# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
# Bug-Reports: see http://grml.org/bugs/
# License: This file is licensed under the GPL v2.
################################################################################
# This file is sourced only for interactive shells. It
# should contain commands to set up aliases, functions,
# options, key bindings, etc.
#
@efazati
efazati / OptionParser.py
Created June 30, 2015 08:22
OptionParser
from optparse import OptionParser
import time
def fn1():
print 'test'
if __name__ == '__main__':
parser = OptionParser()
@efazati
efazati / ThreadedTCPRequestHandler.py
Last active August 29, 2015 14:16
ThreadedTCPRequestHandler.py
class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler):
def handle(self):
logger.info({'module': 'server', 'msg': 'Client connected %s' % self.client_address[0]})
cur_thread = threading.current_thread()
data = self.request.recv(1024) # clip input at 1Kb
try:
msg_analyser(data)
response = "{}: {}".format(cur_thread.name, data)
@efazati
efazati / app.ini
Created December 7, 2014 07:40
uwsgi
[uwsgi]
socket = /tmp/app.sock
chdir = /opt/www/app/
processes = 8
master = true
touch-reload = /opt/www/app/reload
plugins = python
module = deploy
callable = application
#virtualenv = /opt/www/app/env
@efazati
efazati / input.py
Created November 24, 2014 11:28
simple get data
from optparse import OptionParser
import time
import sys
def show_lcd(text):
print text
if __name__ == '__main__':
parser = OptionParser()
@efazati
efazati / i3rc
Created November 17, 2014 13:26
i3rc
#!/bin/bash
xrandr --output VGA1 --left-of HDMI1
setxkbmap -option grp:switch,grp:alt_shift_toggle,grp_led:scroll us,ir
feh --bg-fill ~/Pictures/background/wallpaper-base.jpg
@efazati
efazati / change_language.sh
Created August 17, 2014 07:01
change language with alt+shift setxkbmap
setxkbmap -option grp:switch,grp:alt_shift_toggle,grp_led:scroll us,ir