Author: simion

Manually generate Django password reset token

Ever needed to manually generate a password reset token?

For example, imagine this situation:
You create a user from a custom form, and you want the user to set his own password.
Solution: generate a password reset token,  email him the link, and let him choose his own password.

Here’s how you implement this:

To display the link in the email, you must set the password reset url, and display it:

 

Deploy with fabric on multiple servers

Ever needed to deploy with fabric on multiple machines?
Here’s a simple solution to aproach this issue.

In your fabfile.py , add these two methods:

Now, when deploying, for example:

you must use the following commands, in the correct order:

Fabric runs the “staging” or “deploy” commands first, setting the envrinoment variables, and then it runs the “deploy” command doing whatever you asked it to do.

jqPlot resize bar charts

To make a jqPlot bar chart resizeable, you need to do this:

where “chart” is the object returned by $.plot when initializing the plot.

logo_comfortaa_small_180px

Top things to do after installing Manjaro KDE

In this article I’ll explain what you should to after installing Manjaro Linux with KDE  (current version 0.8.8)

Overview on my desktop

So, here’s my current Manjaro KDE desktop look:
snapshot2

 

Here are the most important things I’ve done after installing Manjaro linux:

Appeareance

Fonts

First thing, and the most important, was to fix fonts. Default KDE fonts aren’t that pretty, so I’ve installed “infinality fonts” and cairo ubuntu.

Here’s my current font configuration:

Read More

Ubuntu – resize window with alt-right click

To enable this functionality in ubuntu, install gconf-editor:

run it, and navigate to apps/metacity/general and enable "resize_with_right_button"  key.

 

In Ubuntu 14.04

Click Window Management and Resize Window.

Set the key to “<Alt>Button3”

 

For Linux Mint (version now: 17):

 

Pip PIL error: Could not find any downloads that satisfy the requirement PIL

When installing “PIL” with pip, I got this error:

 Fix: use “Pillow” instead of “PIL”. Make sure you uninstall PIL first.

 

Slow SSH login on Ubuntu

I have recently experienced a slow ssh login issue on ubuntu 13.10 (xubuntu actually).
Tried all kind of solutions from internet, nothing worked, except this:

Edit the following file:

Find the following line:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

replace with

hosts: files dns

Voilà!

Ssh authentication working like a charm!

Compare integer variable in django templates

Ever needed to compare some variable (that may come from db, forms, etc) in django templates with an integer?
Example:

The above example will not work. Django’s template engine interprets the variable as a string.

Workaround for integer comparison:

By using the “add” filter, the variable is transformed into an integer.