Advertisements
Skip to content

Recent Articles

22
Feb

Pip and virtualenv on Windows

Install pip

Pip (Python Package Installer), official documentation for pip.

Usually Python3 comes with pip preinstalled. If you get an error “pip command not found”, use the following command to install pip:

Download get-pip.py, make sure you’re saving file to Desktop

In your Command Prompt navigate to Desktop

cd Desktop

Execute get-pip.py

python get-pip.py

Now pip should work system wide.

virtualenv

In your Command Prompt enter:

pip install virtualenv

Launch virtualenv

In your Command Prompt navigate to your project:

cd your_project

Within your project:

virtualenv env

Activate your virtualenv:

on Windows, virtualenv creates a batch file

\env\Scripts\activate.bat

to activate virtualenv on Windows, activate script is in the Scripts folder :

\path\to\env\Scripts\activate

Example:

C:\Users\'Username'\venv\Scripts\activate.bat

Another way to install pip

Save the “ez_setup.py” file to your desktop form https://bootstrap.pypa.io/ez_setup.py

In your Command Prompt navigate to Desktop:

cd Desktop

Execute ez_setup.py:

python ez_setup.py

install pip:

easy_install pip

Advertisements
20
Feb

DJANGO Cheat Sheet

Set up the virtual environment and create a new project in DJANGO.

linux:
virtualenv --python=python3.6 venv
windows:
virtualenv venv

linux:
source venv/bin/activate

windows:
\path\to\env\Scripts\activate

pip3 install django
pip3 install pillow
django-admin startproject [project name]

Verify project creation and start DJANGO server.

# Navigate to the newly created project folder.
. python3 manage.py runserverall

# Create a superuser
python3 manage.py createsuperuser [username]

# Test Server
python3 manage.py runserver

Creating a Django App

1. Open terminal and navigate to django project folder (where manage.py exists)
2. django-admin startapp [app name] # use pluralised names, e.g. posts
3. Navigate to new app folder.
4. Create new subfolder called “templates”
5. Navigate to new templates folder.
6. Create new subfolder called same name as your app (e.g. posts)
7. Go back to project folder
8. Open project urls.py and add “from [appname] import views”. Then add url path for new view.
e.g. url(r’^$’, views.home, name=‘home’)
9. Open views.py and add:
def home(request):
return render(request, ‘posts/home.html’)
10. Navigate to projectfolder\appfolder\templates\appfolder
11. Create new file ‘home.html’
12. Go to project folder and open settings.py. Scroll down to INSTALLED_APPs and add
‘appname’, to the end of the list of apps.

Connecting PostgreSQL to a Django Project

1. Create a new database in PostgreSQL, and assign a DB user with admin privileges
2. Go to project settings.py and scroll down to DATABASES section. Replace with:

DATABASES = {
 'default': {
 'ENGINE': 'django.db.backends.postgresql',
 'NAME': ‘[databasename]’,
 'USER': ‘[username]’,
 'PASSWORD': ‘[password]’,
 'HOST': '127.0.0.1',
 'PORT': '5432',
 }
}

3. Scroll down to TIMEZONE and replace code. e.g. TIME_ZONE = ‘Australia/Perth’

18
Dec

Bulk Rename Files and File Extensions on Windows

Bulk/Batch rename files and file extensions on Windows using cmd.exe.

You have a folder full of saved pcap files however you forgot to add the file extension when you created your capture configuration. Open a cmd.exe and navigate to the folder. In this example the folder is located at C:\pcaps.

You want to add the extension .pcap to each file. Execute the following command.

C:\pcaps>ren *. *.pcap
6
Dec

Download Splunk _raw data from Index using the Web Interface

Select the appropriate time range.

In the Splunk search window, search for the index and table the _raw data.

Capture1.PNG

Download the search results. Click on the Export button.

Capture2.PNG

Save the file as a csv.

Capture1.PNG

8
Oct

Desperate Flip

Marvin stopped the car and fished his hands around for the gold coin.
A local ranger casually walked up. “Looks like you cant watch him all the time.”
Don’t get angry. It’s just bait, they will be watching.
They walk in conversation to the pier.
“I heard you’re mamma raised you better then this.”
“Uh huh.”
“Of course my mamma raised us to know right from wrong and wasn’t raising a pack of heathens.”
Enough was enough. One flip for the day only. Fine.
*Flip*
My bothers fine, sitting in his car in his parking spot.
*Catch*
Death appeared. “NEXT TIME”

7
Oct

Rolling Cheese

It was Tuesday and everyone was standing along a hill and drinking and shouting.
“I’m Impossibility. The winner gets a shiny gold coin.” The strange man introduced his new game.
The players didn’t know why wanted to play this new game. Moments before it hadn’t existed and now suddenly, a wheel of cheese at the top of the hill and the overwhelming need to get to the bottom first.
Someone rolled the cheese and their bodies moved with impossible speed rolling strait down the hill!
“Good job boy.” Said a voice as it pressed a heavy gold coin into his hand.

7
Oct

Check the Barn

Death sat back in his chair. He was surrounded by time but none of it was his to spend.

The spirit of a cat he had collected earlier moved around his feet.

“PRETTY. KITTY.” Death said. “RUN ALONG. THERE WILL BE MANY ETHEREAL VERMIN TO FIND AND, WELL, FIND AGAIN.”

The spirit of the cat silently wisped out of the room.

“TRY THE BARN.”

A ghostly meow thanked him from the hallway.

Yes he thought. Plenty of time to chase the other spirits in the barn. He had unlimited time now.

But he would never actually get to catch him.

5
Oct

Splunk Universal Forwarder Setup

Inside of the Splunk server enable the Splunk listener on port 9997.

download the correct universal forwarder for your device. In this case I am using raspberry pi and used the arm version. Navigate to the directory you downloaded the universal forwarder in and run the following commands to install the forwarder as root, start at boot, and start monitoring the /var/log directory. Change your Server IP address.

sudo tar xzvf splunkforwarder-7.0.0-c8a78efdd40f-Linux-arm.tgz -C /opt
sudo /opt/splunkforwarder/bin/splunk splunk start –answer-yes –no-prompt –accept-license
sudo /opt/splunkforwarder/bin/splunk add forward-server X.X.X.X:9997
sudo /opt/splunkforwarder/bin/splunk add monitor /var/log
sudo /opt/splunkforwarder/bin/splunk restart
sudo /opt/splunkforwarder/bin/splunk enable boot-start

5
Oct

100 Years to Live

Eugene slipped. It was embarrassing really. He just knew he was going to die and because of a cat of all things. He was going to be the joke of the after life.
Time suddenly slowed down. He could see the ground. And the cat.
Death appeared. He didn’t say anything. He just stood there, looking.
“Umm. Can I help you?” Eugene asked.
“Sorry?” Asked the hooded figure.
“Are you here to kill me?”
“No.”
“Am I going to die?”
“You have one hundred years to live. I am here for the cat.” Said death.
Eugene landed on the cat.