Skip to main content

Posts

CentOS Install SSH server and configure for VirtualBox testing

I have had some tasks to configure and install a CentOS distribution for my bug-tracking needs. Hope to help out someone with similar problems and or tasks. I'll be using a fresh install of a CentOS Minimal 6.5.  And a Mac Book Pro with VirtualBox installed (as my testing environment). First after install of a clean CentOS you need an SSH server to work in your usual environment. So to connect to a Linux, installed in a VirtualBox you will need basically 2 things: openssh-server install disable firewall VirtualBox Port configuration/Access configuration OpenSSH server install To install server you need to run in your VirtualBox Guest system (CentOS VM): yum -y install openssh-server And start and add it to auto launch at system startup: chkconfig sshd on service sshd start Also make sure port 22 is opened in your VM. type: netstat -tulpn | grep :22 Firewall settings Because it's a VM you can simply disable the firewall. But be sure not to do this a...

Python Generators explained simply.

I'm often confused by recent obsession of generators in python. I'll try to explain them as simply as possible. Say you have never used iterators but coded in python. BUT I'm sure you have used dictionaries ( dict ) and have met requirement to iterate through it's keys and/or values. TADA! You have used generators already ;). So generator is a  function  in python. Except for it uses a keyword  yield  in it's code. Thus making it the iterator. So you could call this function in a sequence like you would probably do iterating over a dictionary already. E.g.: # typical iteration through dictionary key: value set for key, value in dict .iteritems(): # do someth # Usage of your own iterator for item in iterator_functuon(): # do something with function generated output So this function returns an iterator generator like the  dict()  type has by default. And has a  next()  function, like usual iterators have. So in attempt t...

AJAX form in Django with jQuery.form plugin

Here I will describe an example form using jQuery Form  plugin. It will provide a good frontend, while Django serving a simple backend. I made this AJAX form using unobtrusive javascript. With human language it means the form will function with JavaScript disabled. And so jQuery.form plugin will work as an AJAX speedup addition and not as a major requirement. Features: * Works both with JavaScript  and without. * Uses standard Django ideology/hooks. * Uses the most known jQuery plugin for forms AJAX handling. Theory: Main idea that Django supports both normal and AJAX request in a standard view. And has a handy request.is_ajax() request method. It returns True/False depending on if request search has HTTP_X_REQUESTED_WITH header for the string 'XMLHttpRequest' . jQuery.form plugin sure does have that. Backend Django. We will create an app called 'contact' for our task and place it in the example django project. Urls from the project will redirect to ...

CouchDB restoring deleted/updated documents and their data

We are using CouchDB for production and happy with it. It is much more lightweight rather then MongoDB yet powerful. (For our needs at least). But sometimes you have situations that some code deleted/spoiled your Couch Database data. We had some bugs leading to deleting indexes. However compaction have not been run and here is the decision. There are several ways for different situations. I'll try to cover them all. So for deleted CouchDB documents you need to: 1. Make sure your document with this id is Deleted. To do it you need to request CouchDB for this document. E.g. with this string: $db/$id Where  $db  is your CouchDB database name and  $id  is your deleted document id it should return something like this: { "error" : "not_found" , "reason" : "deleted" } 2. Get all the revisions of the deleted document. With this request: $db/$id?revs= true &open_revs=all Where $db is your CouchDB database name and $id is ...

OS X Mavericks and Last.FM scrobling of iTunes radio

I have used iTunes radio dramatically after installing a new version of iTunes. But the problem is my musical taste is recorded (Historically) at Last.FM profile. So It is something like combining your Last.FM profile with your iTunes Geniuos data. AFAIK iTunes uses it's data to play songs in a given station. After trying several decisions I have found a nice one that simply works. You need an app called Bowtie . It's built for older OS X'es. But works nicely for this purpose. It has a themed desktop applet. So it's something like a nice bonus. Anyway you can connect it with Last.FM and that's it. Just one thing it sits in your memory. But I have found it does not consume too much resources or has obvious flaws that spoil Mac anyway. One trick to install it you need to enable it install your system. It is not from apple store so... as per stackoverflow question it can be done like so: Go to  System Preferences... > Security & Privacy  and ther...

install ssh-copy-id on Mac OS X best way

You often need to create identities for unknown/new servers. Then welcome to this article. I believe i have a best practice way of doing it on a MAC system. First of all you need your identity file: 1. Generating ssh keys set You need to use tool that any unix system usually has. It's ssh-keygen. (Skip if you have it already) Last login: Wed Aug 21 16 : 07 : 34 on ttys002 console@username:~$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/Users /username/ .ssh/id_rsa): yourkeyname Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in yourkeyname. Your public key has been saved in yourkeyname.pub. The key fingerprint is: XX.XX.XX.XX.XX.XX.XX.XX.XX.XX.XX.XX. console@username The key 's randomart image is: +--[ RSA 2048]----+ | + | | + | | + | | + ...

Django: Add Permission model to admin panel

How to add a permissions model to your Django admin? You may add those lines to anywhere in your code. But it is more convinient to add this to your admin.py or place where django admin custom code lies. Here are them: from django.contrib.auth.models import Permission admin.site.register(Permission) Now you can manage them in in your Django admin panel. May look like this: Hope this helps.