General Problem solving workflow

Here is a neat problem solving workflow i borrowed here.
It is really helpful when you're in the middle of a sprint and you've hit a
blocker.
Another strategy which i would advocate for and which normally works is
describing the problem to a colleague, most of the time you will answer yourself
while in the process of explaining the problem.
Heavy reliance on google isn't good as many have pointed that out.Try to solve it yourself if you really want to sharpen your skills.

Also i would also recommend taking a nap.Research shows that it leads to higher levels of productivity especially during the late hours of the day, you can find a good guide on taking a nap here.

1) Try it.
2) Get up and walk away.
3) Try again.
4) Go for a walk / do some pushups (gets the blood flowing)
4) Try again.
5) Read the documentation.
6) Try again.
7) Go to the whiteboard and draw it out.
8) Keep trying.
9) Go back to the docs.
10) Try again
11) Look through some sample source code.
12) Try again.
13) Meditate.
14) Try again
15) Keep trying
16) Google it
17) Find a good answer on stack overflow.

Linux: How to download flash videos part 2

As a follow up to part 1 entitled Linux: How to download flash videos from any site i went ahead and created a shell script for automating the entire process.So instead of typing the whole series of commands, just create this script and execute it whenever you wish to download a video.Remember, make sure the video has loaded fully before running the script.The video will be downloaded to the desktop.

#!/bin/bash
# shell script for downloading flash video files from the active browser

proc_number=`pgrep -f flashplayer | wc -l`

if [ $proc_number = "1" ]
then
proc_id=`pgrep -f flashplayer`
cd /proc/$proc_id/fd
file_number=`ls -l | grep 'deleted' | awk '{ print $8 }'`
cp $file_number ~/Desktop
echo "One file copied to desktop, name is $file_number"
else
echo "No files copied"
fi


Save the file and run chmod 755 to make it executable.Now run it by typing ./[filename]

Secure Login to your Google Account

If you find yourself in a situation where you need to log into your google account using a public computer, the following steps will let you login without having to type your password on the computer.

This is a useful protective feature by Google to that can help keep your password safe from keyloggers (tools that monitor key presses to determine what the user was typing). Unfortunately, it only works if you have a phone with a QR code scanner.

Steps:

  1. Go to https://accounts.google.com/sesame
  2. Scan the QR code that is presented to you.
  3. Open the provided link on your phone browser and login to your Google Account.
  4. Confirm that your really want to give the computer access to you account
  5. Once you confirm, the page with the QR code on the computer's browser will automatically reload into your account.
NB: Always remember to logout from your Google Account once you are done if using a public computer.

Linux: How to download flash videos from any site

Navigate to the site on your browser and allow the video to load fully.

Open up the shell and type the following.

~$ pgrep -f flashplayer

This will give you some process id(s) of currently active flash player, note this id.
Change directory to the processes folder, and into the fd folder.

~$ cd /proc/(pid)/fd
~$ ls -l

From the list, find an entry which is located in the tmp directory and has the name deleted in brackets.Note the number just before the path.In this case below it's 25, this represents the file name of the video.

lr-x------ 1 name name 64 2010-01-13 14:41 25 -> /tmp/FlashXXLMneo8 (deleted)

copy the video to somewhere convenient like your desktop.

~$ cp 25 /home/user/Desktop

Check your desktop, the file should be present, rename it appropriately.

How to create an emacs alias for shell mode

Most of the time, i launch emacs from the shell.I usually prefer to use it inside the shell, that is why using the command brings up emacs in windowed mode which is rather annoying.

~$ emacs

to use emacs in shell mode you have to give it the no window flag, this way.

~$ emacs -nw

so, this works fine but the problem is that you have to type this every time with the no window flag.To overcome this, you can create a shell alias.This is done by editing the .bashrc file which is usually present in your home directory.At the bottom add the following line, also from examples you can easily learn how to create aliases.

alias emacs='emacs -nw'

Save the changes and restart the shell, you can now try it out.

how to send mail with django

import the following.


from django.core.mail impore EmailMessage


in your settings.py put the following:

EMAIL_HOST defines the host for sending email
EMAIL_PORT defines the port for sending email

EMAIL_HOST_USER (optional)used to authenticate to the smtp server
EMAIL_HOST_PASSWORD (optional) also used to authenticate to the smtp server

EMAIL_USE_TLS (True/False) controls whether a secure connection is used

create an EmailMessage object


email = EmailMessage('Title', 'Body', 'from@email.com',
['to@email.com'], ['bcc@email.com'],
headers = {'Reply-To': 'someone@anonymous.com'})

send email

email.send(fail_silently=True)

or

email.send(fail_silently=False)

or

email.send()