If, For Any Reason You're Not Satisfied, I Hate You. Guys, this video is the best: https://www.youtube.com/watch?v=WDaw2yXAa50 I know I'm only beginner, but videos like this help me so much! Here's what I know now: 1. For and maps case class TimeResult(i: Int, j: Int, mult: Int) val timesTable = for { i <- 1 to 5 j <- 1 to 5 } yield TimeResult(i, j, i*j) the code above is the syntactic sugar for nested foreachs flattened afterwards. It's always flatMaps and then a map in the end. val timesTablesRaw = (1 to 5).flatMap(i => (1 to 5).map(j => TimeResult(i, j, i*j))) Even better example: for { i <- 1 to 5 // flat...
Published ago by AnaPana

We are now in position above Spheron One. This is the moment we were training for all yesterday afternoon. I'd like to talk about fors: so much to learn, so many usages. Scala by the Bay made it much clearer. I'm not letting myself to forget how useful it was. Simple cases Let's get started with some basics: for (i <- 1 to 3) { println(i) } // will print // 1 2 3 // res: Unit = () The same code, but with until instead of to (will end on 2). for (i <- 1 until 3) { println(i) } // will print // 1 2 // res: Unit = () Examples above are a syntatic sugar for (1 to 3).foreach(i => println(i)) Nested loops:...
Published ago by AnaPana

Let me show you around. That's my lab table and this is my work stool and over there is my intergalactic space ship. And here is where I keep assorted lengths of wire. This article is going to be a reminder for myself. Finally I got to use some of the design patterns in Python and since I'm going to learn scala pretty soon, I'd like to keep some things written here, so I can compare them with my new knowledge. And another reminder for myself: I love programming :) Ok, let's start. I guess the easiest one is Factory Method Pattern. It's the easiest one just because you shouldn't use it :) This answer is awesome: http://stackoverflow.com/a/14992545/11...
Published ago by AnaPana

There are several ways to organize your production settings in Django. Of course it's up to you which way to  chose. 1. Separate files Some developers like to separate production/test/dev settings in different files. This is quite convenient approach if you don't have to mess with them very often. In this case there is base file base.py which contains all common settings for all environments. So assume that our Django project's structure is: . |-- README.md |-- prj_name/ | |-- settings | | |-- __init__.py | | |-- base.py | | |-- dev.py | | |-- prod.py | | |-- test.py | |-- urls.py | |-- wsgi.py |-- some_app/ ... I...
Published ago by AnaPana

Here is a short recipe for setup Django application with uWSGI server running under Nginx using socket file. I used the following links: http://uwsgi-docs.readthedocs.org/en/latest/Nginx.html http://stackoverflow.com/questions/21820444/nginx-error-13-permission-denied-while-connecting-to-upstream http://projects.unbit.it/uwsgi/wiki/Example So first of all, wsgi.py file has to be existed: import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings") # Change this with your settings path from django.core.wsgi import get_wsgi_application application = get_wsgi_application() The next thing is Nginx config. Few lines has to be a...
Published ago by AnaPana

Built-in web server uses just only tests. For production purposes could be used one of the third-party web servers. Let's up Gerrit behind Apache web server. Change httpd setting in Gerrit configuration and restart it: [httpd] listenUrl = proxy-http://*:8081/r/ $ /opt/gerrit/bin/gerrit.sh restart   Apache part... $ apt-get install -y apache2 $ a2enmod proxy_http $ cat < EOF >> /etc/apache2/sites-available/gerrit.conf <VirtualHost *> ServerName review.example.com ProxyRequests Off ProxyVia Off ProxyPreserveHost On <Proxy *> Order deny,allow Allow from all </Proxy> AllowEncodedSlashes On...
Published ago by ochirkov

In this topic we'll install Gerrit review system from command line step by step. Gerrit can work with built-in H2 database and third-party databases (Mysql, Postgresql, Oracle..) as well. So, on of the Gerrit's dependencies is a database. Let's say it will be Mysql. So, we'll prepare it for Gerrit installation:   $ apt-get update $ apt-get install -y mysql-server $ mysql -u root -p mysql> CREATE USER 'gerrit'@'localhost' IDENTIFIED BY 'gerrit'; mysql> CREATE DATABASE gerrit; mysql> GRANT ALL ON gerrit.* TO 'gerrit'@'localhost'; mysql> FLUSH PRIVILEGES;   Install JDK: $ apt-get inst...
Published ago by ochirkov

There is a little difference between using "register" statement with and without "with_items". Because I had problems with this, I'd like to share my solution here. In my example I have two tasks. The first one prints some word, the second one tries to find this word in command's output. # tasks.yml ... - name: Register variable tags: art command: echo "bla" register: echo_output1 - name: Test echo output tags: art fail: msg="bla is not in the output" when: "'bla' not in echo_output1.stdout" - name: Register variable (using with_items) tags: art command: echo "{{ item }}" ...
Published ago by AnaPana

A few days ago I was trying to pass a filename as variable in the "lookup" statement and faced with some problems. So in my case I have a file with all my variables group_vars/all and very simplified playbook tasks.yml with only one task for printing file content What I was trying to do is: #group_vars/all ... filename: my_script.sh ... #tasks.yml - name: My playbook hosts: unix - name: Print file content hosts: unix tasks: - name: Get the file contents command: echo "{{ lookup('file', {{ filename }}) }}" In this case I had an error: fatal: [127.0.0.1] => could not locate file in lookup: {{ filename...

There were few changes in application structure on Openshift after its last release (https://blog.openshift.com/openshift-online-march-2014-release-blog/). Because of this I had some troubles with creating new Django application. Here I will describe steps for creating Django 1.7 application using Python 2.7 cartridge on Openshift. 1. Create application There are two options for creating application on Openshift: using command line tools  using GUI  Both of these are described here https://developers.openshift.com/en/getting-started-overview.html#step3 2. Clone application to development machine Create empty Git repository on your machine: mkdir ...
Published ago by AnaPana

Python
Web development
Review Linux
Administration
Provisioning CVS
Windows AWS
Continuous Integration
NoSql Logging Web Servers FileSystems Scala
accurev ansible apach2 apache api application approaches architecture archivation argparse arguments artifactory automation awk aws backup bash batch-scripting beaver block build built-in caching call captcha cartridge case certificates cgi chain client cloud cloudformation cluster cmd coding collections command-line commands compression conditionals conversion convert cookbook copy counter cron crud css cut cygwin daemon datatype date dd debpackage decorator delattr deploy deque dict distributed-file-systems django DNS domain driver dropbox dump elasticcache elasticsearch encryption exit ext4 extra-tags failover file filename filters for form format freetds functions gerrit getattribute gid git globals glusterfs hardware hook iam indexing inheritance init install job-interview jquery ldap linux list locals logging logs logstash lookup magicmethods mail main-menu metadata metalogger mongodb moosefs mount mssql multiplatform multithreading mysql netcat nginx nosql open-ssh openldap openshift os packaging parse partition path pattern patterns permissions pid pil pip pipe playbook pool post post-commit processes production provisioning proxy putty python python-mysql recursively redirection redis register replication repr restore return review rotation scala script search selenium server setattr settings setup shipper signals singleton slots snapshot socket splunk ssh ssh-key ssl storage str string style subprocess sugar super switch syntactic syntaxhighlighter systeminfo tail tar templatetags time tls tune2fs tuple ubuntu unicode unique unix unixodbc usage usecases uuid uwsgi variable vars version vi virtualenv volume web web-server windows with_items __getattr__