...
Just my blog

Blog about everything, mostly about tech stuff I made. Here is the list of stuff I'm using at my blog. Feel free to ask me about implementations.

Soft I recommend
Py lib I recommend

I'm using these libraries so you can ask me about them.

vk execute

https://vk.com/dev/execute py_vk Продолжаю линейку ознакомительных постов на тему "в мире эльфийских языков программирования" или "говнокод - как стиль жизни". Был вот такой вот пост, который вроде как-бы объяснял как сделать execute при помощи javascript и все такое: http://habrahabr.ru/post/248725/ но язык, которым была написана статья - выглядит настолько эльфийским, я уже не говорю про сраную разметку, которая съехала набикрень просто, как и моя голова, с несозревшими пайтоновскими правилами отступов тоже съехала. Так вот, пытаясь разобраться в этих письменах и отделить зерна от плевел, чтобы наконец понять, как работает этот долбанный vk execute мне пришлось убрать весь говнокод, чтобы найти чистый vk execute, также используя хорошую, но не очевидную, документацию ВК по ссылке выше, я смог родить то, чего пока, мне кажется, никто не родил: Простой и понятный пример того, как работает этот, ослицу его мать, vk execute. Вот очень простой пример while:

var a = 1;
var …

Read...

vk execute method working example on python 3

vk execute

vk execute

  РУС: Сраный интернет и хабрахабры просто завален всякими говнопримерами про vk execute method, каждый круче предыдущего, и никто так и не смог написать нормальный код, я два дня пытался читать тот эльфийский говнокод, в который хабровчанин превратил пайтон, силясь понять что он куда передает, до тех пор, пока не послал все к "%s собачим" и не сделал методом тыка сам. Все оказалось пипецки просто, смотрите сами, код внизу спокойно себе возвращает то, что нам нужно. python(vk execute method):

import requests

owner_id = "-PAGE_ID"
token = 'TOKEN'

# may use return%20API.wall.get where "%20" is for HTTP encode of space symbol
# also can work with regular space sybmol - in my version is working fine
r = requests.post('https://api.vk.com/method/execute?access_token='+token+'&code=return API.wall.get({"owner_id":"'+owner_id+'","count":"1"});')
response_data = r.json()
print(response_data)

Далее просто нужно будет разобраться, как работает этот вк скрипт и написать соотв. запросы для своих нужд. Передавать, как оказалось - можно в сыром виде, …

Read...

"Output" за год Python

Фиг знает, когда там принято делать выводы за год, я сделаю их сегодня. Screenshot_13 Ровно год назад, я поменял проект с простого сапорта виндовых серверов, на какой-то мудреный девелопмент-недопрограмминг. Для общего понимания читателю, если он читает - я ничего не смыслил в таких словах из программирования как: функция, переменная, стринги, интеджеры. То есть я как-бы основные понятия знал, даже что-то ковырял и делал на уровне сайта и 'php' (прости господи), но если я слышал, например слово "декоратор функции" или "лямбда функция" - я просто делал вид, что думал о чем-то более важном. Так вот, поставил я себе задачу, выучить этот ваш "Python" - задачу все еще выполняю, но мне кажется, я заслужил  на то, чтобы отметить один пройденный этап. Не смотря на все злоключения и лень поганую, честно признаться, на само изучение я потратил не больше двух месяцев, первый мой прорыв был еще в мае, когда я попытался сделать …

Read...

For list of dicts: merge same key values, sum another diff. values, count each merge iteration +1 Python

If anybody can help me with some task? I have list of dicts(or tuples), where: if tuples:

 comment_id, user_id,     comment_date, comment_time, comment_likes
('51799',   '112801710', '2015-12-07',  '00:03:21',   '0'),
('51761',   '112801710', '2015-12-06',  '19:31:46',   '3'),
('51764',   '112801710', '2015-12-06',  '19:54:19',   '0'),
('51741',   '112801710', '2015-12-06',  '14:17:34',   '2'),
('51768',   '52879933',  '2015-12-06',  '20:03:34',   '0'),
('51766',   '52879933',  '2015-12-06',  '21:33:34',   '0'),

or can be converted to dict like:

{'comm_count': 1, 'user_id': '217407103', 'likes': 0},
  • comment_id - is always unique and cannot meet twice in this list,
  • user_id - is not unique for this list, it can be there as much times as comments were left in the set of posts (naturally I wanted to use this as counter)
  • comment_date and comment_time - can be ignored, needed to sel from db,
  • comment_likes - how much likes each comment has.

The task - make one list of tuples or dictionaries where I have just one 'user_id' unique, next how much 'likes' …

Read...

JAVA_HOME and other Oracle tales

RUS: Открываю заявку на вступление в джентельменский клуб "Пуканы запеченые от продуктов Oracle" принимайте меня!

ENG: How to Install JAVA 7 (JDK 7u79) on CentOS/RHEL 7/6/5 and Fedora javaee1

Configuring Environment Variables

Most of Java based application’s uses environment variables to work. Use following commands to set up these variable properly. It’s also good to add following commands to any start-up script like ~/.bashrc or ~/.bash_profile.

  • Setup JAVA_HOME Variable
# export JAVA_HOME=/opt/jdk1.7.0_79
  • Setup JRE_HOME Variable
# export JRE_HOME=/opt/jdk1.7.0_79/jre
  • Setup PATH Variable
# export PATH=$PATH:/opt/jdk1.7.0_79/bin:/opt/jdk1.7.0_79/jre/bin

From: http://tecadmin.net/steps-to-install-java-on-centos-5-6-or-rhel-5-6/#

Read...

Centos 7 extend volume

One more guide which help me to save nerves. https://www.rootusers.com/how-to-increase-the-size-of-a-linux-lvm-by-expanding-the-virtual-machine-disk/ LVM_original_description Part from it:

Increasing the logical volume

We use the pvcreate command which creates a physical volume for later use by the logical volume manager (LVM). In this case the physical volume will be our new /dev/sda3 partition.

root@Mega:~# pvcreate /dev/sda3
  Device /dev/sda3 not found (or ignored by filtering).

In order to get around this you can either reboot, or use partprobe/partx as previously mentioned to avoid a reboot, as in this instance the disk does not appear to be there correctly despite showing in “fdisk -l”. After a reboot or partprobe/partx use the same command which will succeed.

root@Mega:~# pvcreate /dev/sda3
  Physical volume "/dev/sda3" successfully created

Next we need to confirm the name of the current volume group using the vgdisplay command. The name will vary depending on your setup, for me it is the name of my test …

Read...

How to convert an OVA virtual machine to VHD

This is "How to convert an OVA virtual machine to VHD" guide link

My approve for this guide, it's worked:

talend_vhd talend_vhd_hyper-v talend_vhd_hyper-v_GIU How to convert an OVA virtual machine to VHD    

Read...

Шпаргалки для Python 3

Сохранил себе, даю и вам. Всякие мудаки в интернете по линкам на эти гайды делают редирект на свои грязные сайты.

 python_shpora

 

PDF - внизу: memento python 3 - russian memento python 3 english KeyMap for Pycharm PyCharm_ReferenceCard  

Read...

Django static files

How to find where def. static stores?

[root@test smm_py]# python3 manage.py findstatic css/base.css admin/js/core.js
No matching file found for 'css/base.css'.
Found 'admin/js/core.js' here:
  /usr/local/lib/python3.4/site-packages/django/contrib/admin/static/admin/js/core.js

Then move it into the folder you need. [su_note]Don't forget to chown and chmod[/su_note] Then update django's.conf file:

Alias /static/ "/var/www/smm_tools/site/"

And check the settings.py:

103 # Static files (CSS, JavaScript, Images)
104 # https://docs.djangoproject.com/en/1.8/howto/static-files/
105
106 STATIC_URL = '/static/'

https://docs.djangoproject.com/en/1.8/howto/static-files/  

Read...

Django + Python3.4 + Mysql(MariaDB)

Just hint for future me: [su_note]How to install django with mysqld - log[/su_note]

[root@test smm_py]# vim settings.py 
[root@test smm_py]# python manage.py makemigrations
                    import MySQLdb as Database
                    ImportError: No module named 'MySQLdb'
                    django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'
[root@test smm_py]# pip install mysql-python3
                    Collecting mysql-python
                    Downloading MySQL-python-1.2.5.zip (108kB)
                    100% || 110kB 812kB/s 
                    ImportError: No module named 'ConfigParser'
                    ----------------------------------------
                    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-t64nwwtb/mysql-python
[root@test smm_py]# easy_install mysql-python
                    ImportError: No module named 'ConfigParser'
                    ImportError: No module named 'ConfigParser'
[root@test smm_py]# pip3 install ConfigParser
                    Collecting ConfigParser
                    _KEYCRE = re.compile(ur"%\(([^)]+)\)s")
                    SyntaxError: invalid syntax
                    ----------------------------------------
[root@test smm_py]# pip3.4 install --allow-external mysql-connector-python mysql-connector-python
                    Collecting mysql-connector-python
                    Downloading http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip (277kB)
                    100% || 278kB 3.7MB/s 
                    Successfully built mysql-connector-python
                    Successfully installed mysql-connector-python-2.0.4
[root@test smm_py]# vim /smm_py/settings.py 
                     76 
                     77 DATABASES = {
                     78     'default': {
                     79 'ENGINE': 'django.db.backends.mysql',
[root@test smm_py]# python3 manage.py makemigrations
                    django.core.exceptions.ImproperlyConfigured: 'mysql.connector.django' isn't an available database backend.
                    Try using …

Read...