Skip to content

Instantly share code, notes, and snippets.

View Lh4cKg's full-sized avatar
🐍
Working

Lasha Gogua Lh4cKg

🐍
Working
View GitHub Profile
@Lh4cKg
Lh4cKg / nbg.py
Created September 19, 2018 15:44
NBG currency rates
"""
Service API:
public string GetCurrency(Currency cur) აბრუნებს ვალუტის კურსს, მაგ. "1.0754"
public string GetCurrencyDescription(Currency cur) აბრუნებს ვალუტის აღწერას, მაგ. "10 ესტორნური კრონი"
public string GetCurrencyChange(Currency cur) აბრუნებს ვალუტის ცვლილების მნიშვნელობას, მაგ. "-0.0121"
public int GetCurrencyRate(Currency cur) 1 - თუ გაიზარდა; -1 - თუ დაიკლო, 0 - თუ იგივე დარჩა
public string GetDate() აბრუნებს კურსების შესაბამის თარიღს
"""
@Lh4cKg
Lh4cKg / django_setup.py
Last active May 22, 2018 21:25
configure and run django script file
# old django version: 1.6.x
# configure and run django script
if __name__ == '__main__':
import os
import sys
import importlib
proj_path = '/home/gogua/projects/profenv/profiling/'
sys.path.append(proj_path)
@Lh4cKg
Lh4cKg / geo_alphabet.py
Last active October 26, 2017 07:15
Georgian Alphabet Range
# Python 2.x
for x in [unichr(i) for i in range(ord(u'ა'),ord(u'ჰ') +1)]:
pattern = unicode("!@#$%^&*()_+=-~`[]\{}|:\"?><,./;'\`„\"")
char = re.sub('[%s]' % re.escape(''.join(pattern)), '', x.strip())
print char
# Python 3.x
for x in [chr(i) for i in range(ord('ა'),ord('ჰ') +1)]:
pattern = "!@#$%^&*()_+=-~`[]\{}|:\"?><,./;'\`„\""
@Lh4cKg
Lh4cKg / Django + Ajax dynamic forms .py
Created May 26, 2017 09:41 — forked from goldhand/Django + Ajax dynamic forms .py
Django form with Ajax. A simple Task model that can be updated using a CBV with an AJAX mixin. The view sends post data with ajax then updates the view with a callback to a DetailView with a json mixin.There is an abstract CBV, AjaxableResponseMixin, based on the example form django docs, that is subclassed in the TaskUpdateView CBV. TaskUpdateV…
#models.py
class Task(models.Model):
title = models.CharField(max_length=255)
description = models.TextField()
def __unicode__(self):
return self.title
@Lh4cKg
Lh4cKg / forms.py
Last active March 21, 2021 18:24
Django Bootstrap Registration Form | Jqwidgets Style Registration Form, using jqwidgets
# _*_ coding: utf-8 _*_
"""
IPC
Created on Apr 24, 2017
@author: lasha gogua
"""
from django import forms
@Lh4cKg
Lh4cKg / celery.py
Last active January 23, 2020 06:12
Installing And Configuration Django 1.10 && Celery 4.0.2 && RabbitMQ
1. django (latest version)
$ pip install django
2. celery (latest version)
$ pip install celery
first steps
docs: http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html
install celery extension
$ pip install django-celery-beat
docs: http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html#django-celery-beat
@Lh4cKg
Lh4cKg / pyreq.sh
Last active June 25, 2016 12:30
requirements python installation on ubuntu / debian
# ubutnu/debian Python installation requirements
sudo apt -y install build-essential checkinstall
sudo apt -y install libreadline-gplv2-dev libncursesw5-dev \
libsqlite3-dev tk-dev libgdbm-dev libc6-dev
sudo apt -y install libjpeg-dev libpng-dev
sudo apt -y install zlib1g-dev libbz2-dev
sudo apt -y install krb5-multidev
sudo apt -y install openssl libssl-dev
sudo apt -y install libffi-dev
sudo apt -y install libgmp-dev
@Lh4cKg
Lh4cKg / beautiful_idiomatic_python.md
Created May 30, 2016 20:19 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@Lh4cKg
Lh4cKg / kill python processes
Last active December 7, 2018 12:29
kill all python process
[innotec@innotec ~]$ ps aux | grep 'manage.py' | awk '{print $2}' | xargs kill -9
# add alias in .bashrc
# kill python processes
alias ppsk="pkill -f manage.py"
# or
[innotec@innotec ~]$ killall python
# or
alias pk="ps aux | grep 'manage.py' | awk '{print $2}' | xargs kill -9"
@Lh4cKg
Lh4cKg / cmd.sh
Created April 27, 2016 08:58
Fedora 24/Centos 7 set locale LANG configuration in terminal output non-ASCII character
[innotec@innotec ~]$ export LANG=en_US.UTF-8
[innotec@innotec ~]$ sudo localectl set-locale LANG=en_US.UTF-8
[innotec@innotec ~]$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"