sábado, 16 de agosto de 2014

How to install Django and its virtual-env




1.

#sudo apt-get install python-setuptools

2. Instal virtual environment

sudo easy_install virtualenv==1.10.1

(or a more recent version)

3. Create a virtual environment the name of mine is 'dd'

#virtualenv --no-site-packages dd

4. Activate the virtual enviroment, you have to do this everytime you want to start your server.

#source dd/bin/activate

5.

You will see now that at the left of your prompy the virtualenv is activated

(dd)#

7. Go to dd directory which is our root system for the created virtual env

# cd dd

6. It is time to install Django

#easyinstall Django


7. Once installed you can find some django scripts in bin directory:

(dd)alex@tic:~/dd$ pwd
/home/alex/dd
(dd)alex@tic:~/dd$ ls bin/
activate       activate_this.py  easy_install-2.7  python
activate.csh   django-admin.py   pip               python2
activate.fish  easy_install      pip-2.7           python2.7
(dd)alex@tic:~/dd$


8. You can see the djanho help and its options

(dd)alex@tic:~/dd$ django-admin.py 
Usage: django-admin.py subcommand [options] [args]

Options:
  -v VERBOSITY, --verbosity=VERBOSITY
                        Verbosity level; 0=minimal output, 1=normal output,
                        2=verbose output, 3=very verbose output
  --settings=SETTINGS   The Python path to a settings module, e.g.
                        "myproject.settings.main". If this isn't provided, the
                        DJANGO_SETTINGS_MODULE environment variable will be
                        used.
  --pythonpath=PYTHONPATH
                        A directory to add to the Python path, e.g.
                        "/home/djangoprojects/myproject".
  --traceback           Raise on exception
  --version             show program's version number and exit
  -h, --help            show this help message and exit

Type 'django-admin.py help <subcommand>' for help on a specific subcommand.

Available subcommands:

[django]
    check
    cleanup
    compilemessages
    createcachetable
    dbshell
    diffsettings
    dumpdata
    flush
    inspectdb
    loaddata
    makemessages
    runfcgi
    runserver
    shell
    sql
    sqlall
    sqlclear
    sqlcustom
    sqldropindexes
    sqlflush
    sqlindexes
    sqlinitialdata
    sqlsequencereset
    startapp
    startproject
    syncdb
    test
    testserver
    validate
(dd)alex@tic:~/dd$


9. Create a new Django project:

#(dd)alex@tic:~/dd$ django-admin.py startproject first_project
(dd)alex@tic:~/dd$ ls f*
first_project  manage.py
(dd)alex@tic:~/dd$

10. Go to yout new project directory and runserver:

(dd)alex@tic:~/dd$ cd first_project/
(dd)alex@tic:~/dd/first_project$ ls
first_project  manage.py
(dd)alex@tic:~/dd/first_project$ python manage.py runserver
Validating models...

0 errors found
August 17, 2014 - 01:00:09
Django version 1.6.5, using settings 'first_project.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

11. Go to your web browser and type the address shown above:

http://127.0.0.1:8000/

You will see something like:

It worked!

Congratulations on your first Django-powered page.

Of course, you haven't actually done any work yet. Next, start your first app by running python manage.py startapp [appname].
You're seeing this message because you have DEBUG = True in your Django settings file and you haven't configured any URLs. Get to work!

12. Hit Ctrl+C to stop your server 

13. end your virtual environment session 
#deactivate and you will loose the (dd) environment from step 5


Enjoy!
.Alex

P.S. The first flags were used to assist military co-ordination on battlefields

Installing GIT on Mac snow Leopard


I am probably save you some time .. This is a response I verified on:

https://help.github.com/articles/does-github-for-mac-run-on-os-x-10-7-lion

Does GitHub for Mac run on OS X 10.6 Snow Leopard?
No, GitHub for Mac requires OS X 10.7 (Lion) or higher.
We made this decision because the app relies on a number of technologies which are not available in Mac OS X 10.6 or earlier. We want to provide the best experience possible for the app's users, so we've made the choice to only support 10.7 and above, and not make earlier versions available.

Normally I would do something like (but doesn't work):

http://git-scm.com/download

Then choose Mac OS X for example

The snow leopard version is compatible with Lion.

Your dmg files starts downloading. then just install it.

Restart bash sessions
------------------------------
This include GNU screen sessions, TMUX sessions, etc.

Enjoy!.

P.S. There are some yellow flags!

Create a linux boot USB with OS X



1. Download the ISO you want

http://www.ubuntu.com/download/desktop

2. Insert the USB

3. Press Comand+space

4. Type "disk utility"

5. Select the USB

6. Click on erase

7. Go to Partition

8. Select 1 partition in the volume scheme

9. Go to options and make sure the GUID  Partition Table is selected.

10. Also make sure that the format is Mac OS Extended (journaled)

11. Download the iso you want to install, in my case I have ubuntu 14.04:

$ ls -l *.iso
-rw-r--r--@ 1 user  staff  1010827264 Jun 23 15:11 ubuntu-14.04-desktop-amd64.iso


12. Convert your iso to the right format. I am naming it ubu14.img
$ hdiutil convert -format UDRW -o ubu14.img ubuntu-14.04.1-desktop-amd64.iso
Reading Driver Descriptor Map (DDM : 0)…
Reading Ubuntu 14.04.1 LTS amd64         (Apple_ISO : 1)…
Reading Apple (Apple_partition_map : 2)…
Reading Ubuntu 14.04.1 LTS amd64         (Apple_ISO : 3)…
..............................................................................................................................................................
Reading EFI (Apple_HFS : 4)…
..............................................................................................................................................................
Reading Ubuntu 14.04.1 LTS amd64         (Apple_ISO : 5)…
....................................................................................................................................................................
Elapsed Time:  1m 25.631s
Speed: 11.5Mbytes/sec
Savings: 0.0%
created: /Users/user/Downloads/ubu14.img.dmg

13. You might se a .dmg extension attached to your converted file, in my case it is ubu14.img.dmg

$ ls ubu*
ubu14.img.dmg ubuntu-14.04-desktop-amd64.iso ubuntu-14.04.1-desktop-amd64.iso


14. Identify your USB device in this case /dev/disk1

$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS MacOSX                  300.0 GB   disk0s2
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *7.8 GB     disk1
   1:                        EFI                         209.7 MB   disk1s1
   2:                  Apple_HFS Untitled 1              7.5 GB     disk1s2


15. Umount your USB device:

$ diskutil umountDisk /dev/disk1
Unmount of all volumes on disk1 was successful

16. Write the iso to the usb

$ sudo dd if=ubu14.img.dmg of=/dev/rdisk1 bs=1m
Password:
981+0 records in
981+0 records out
1028653056 bytes transferred in 224.304496 secs (4585967 bytes/sec)

17. You might see a warning saying that the device is not readable, dont do anything you will close it later.

18. List and umount

$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS MacOSX                  300.0 GB   disk0s2
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     Apple_partition_scheme                        *7.8 GB     disk1
   1:        Apple_partition_map                         4.1 KB     disk1s1
   2:                  Apple_HFS                         2.4 MB     disk1s2

$ diskutil umountDisk /dev/disk1
Unmount of all volumes on disk1 was successful


19. Then click on ignore on the warning dialog that says your device was not readable.

Finally remove your USB, it is ready to be used as a boot USB.

Enjoy!

P.S. Ubuntu flag?

jueves, 14 de agosto de 2014

Installing git on redhat 5.10

You only need 2 commands: Install epel and install git:

# wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
or
# wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

Then just:

#yum install git


i.e.

[root@ip-172-31-30-151 ~]# wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
--2014-08-14 15:45:32--  http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
Resolving download.fedora.redhat.com... failed: Name or service not known.
wget: unable to resolve host address `download.fedora.redhat.com'
[root@ip-172-31-30-151 ~]# rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
Retrieving http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
warning: /var/tmp/rpm-xfer.VE4DbP: Header V3 DSA signature: NOKEY, key ID 217521f6
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]
[root@ip-172-31-30-151 ~]# yum install git
Loaded plugins: amazon-id, fastestmirror, product-id, rhui-lb, security
Loading mirror speeds from cached hostfile
 * epel: mirror.pnl.gov
 * rhui-REGION-client-config-server-5: rhui2-cds01.us-west-2.aws.ce.redhat.com
 * rhui-REGION-rhel-server: rhui2-cds01.us-west-2.aws.ce.redhat.com
epel                                                                                              | 3.7 kB     00:00  
epel/primary_db                                                                                   | 4.0 MB     00:00  
Excluding Packages from Red Hat Enterprise Linux Server 5 (RPMeng-gazzangs)
Finished
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:1.8.2.1-1.el5 set to be updated
--> Processing Dependency: perl-Git = 1.8.2.1-1.el5 for package: git
--> Processing Dependency: perl(Term::ReadKey) for package: git
--> Processing Dependency: perl(Git) for package: git
--> Processing Dependency: perl(Error) for package: git
--> Running transaction check
---> Package perl-Error.noarch 1:0.17010-1.el5 set to be updated
---> Package perl-Git.x86_64 0:1.8.2.1-1.el5 set to be updated
---> Package perl-TermReadKey.x86_64 0:2.30-4.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================================
 Package                           Arch                    Version                           Repository             Size
=========================================================================================================================
Installing:
 git                               x86_64                  1.8.2.1-1.el5                     epel                  7.4 M
Installing for dependencies:
 perl-Error                        noarch                  1:0.17010-1.el5                   epel                   26 k
 perl-Git                          x86_64                  1.8.2.1-1.el5                     epel                   49 k
 perl-TermReadKey                  x86_64                  2.30-4.el5                        epel                   32 k

Transaction Summary
=========================================================================================================================
Install       4 Package(s)
Upgrade       0 Package(s)

Total download size: 7.5 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): perl-Error-0.17010-1.el5.noarch.rpm                                                        |  26 kB     00:00  
(2/4): perl-TermReadKey-2.30-4.el5.x86_64.rpm                                                     |  32 kB     00:00  
(3/4): perl-Git-1.8.2.1-1.el5.x86_64.rpm                                                          |  49 kB     00:00  
(4/4): git-1.8.2.1-1.el5.x86_64.rpm                                                               | 7.4 MB     00:01  
-------------------------------------------------------------------------------------------------------------------------
Total                                                                                    4.5 MB/s | 7.5 MB     00:01  
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 217521f6
epel/gpgkey                                                                                       | 1.7 kB     00:00  
Importing GPG key 0x217521F6 "Fedora EPEL <epel@fedoraproject.org>" from /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : perl-TermReadKey                                                                                  1/4
  Installing     : perl-Error                                                                                        2/4
  Installing     : git                                                                                               3/4
  Installing     : perl-Git                                                                                          4/4

Installed:
  git.x86_64 0:1.8.2.1-1.el5                                                                                          

Dependency Installed:
  perl-Error.noarch 1:0.17010-1.el5      perl-Git.x86_64 0:1.8.2.1-1.el5      perl-TermReadKey.x86_64 0:2.30-4.el5  

Complete!
[root@ip-172-31-30-151 ~]# git clone https://user@bitbucket.org/user/hardening.git
Cloning into 'hardening'...
Password for 'https://user@bitbucket.org':
remote: Counting objects: 191, done.
remote: Compressing objects: 100% (173/173), done.
remote: Total 191 (delta 79), reused 0 (delta 0)
Receiving objects: 100% (191/191), 31.29 KiB, done.
Resolving deltas: 100% (79/79), done.
[root@ip-172-31-30-151 ~]# ls
git-2.0.4.tar.xz  hardening
[root@ip-172-31-30-151 ~]#


Enjoy!
.Alex

P.S. Is there a undiscovered flag?