Skip to content

Instantly share code, notes, and snippets.

View AaronPhalen's full-sized avatar

@aaron_phalen AaronPhalen

View GitHub Profile
@AaronPhalen
AaronPhalen / python_urllib2.py
Last active October 3, 2015 07:25
Examples of using python to make request, aggregate cookies, spoof proxy & user agent.
# Author: Aaron Phalen | Twitter: @aaron_phalen | Email: [email protected]
# import necessary libraries
from cookielib import Cookie, CookieJar
import urllib, urllib2
import requests
# spoofing user-agent (Mozilla FireFox)
USER_AGENT = "Mozilla/5.0"
@AaronPhalen
AaronPhalen / basic_linux_networking.txt
Last active September 30, 2015 22:26
Basic linux commands pertaining to networking
Author: Aaron Phalen | Twitter: @aaron_phalen | Email: [email protected]
Basic Linux Networking Commands
===============================
1. Hostname
a. hostname --> returns system hostname
b. hostname -d --> returns system hostname domain
c. hostname -f --> returns system hostname fully qualified domain name
@AaronPhalen
AaronPhalen / linux_ssh.txt
Last active December 15, 2016 07:36
Basic commands for configuring ssh in linux
Author: Aaron Phalen | Twitter: @aaromn_phalen | Email: [email protected]
Basic SSH Configuration Commands
================================
1. Installation
a) sudo apt-get install openssh-server
b) sudo apt-get install openssh-client
2. Configuration
@AaronPhalen
AaronPhalen / linux_file_remove_restore.txt
Last active September 28, 2015 10:06
Various Linux file system commands including file recovery techniques
Linux File Remove Command And Recovery
======================================
Motivation:
Since using an Ubuntu 12.04 server for the last couple years, I had not once erroneously
keystroked a faulty rm command. As a Linux users knows, the rm commands is used to remove a file or directory.
Futhermore, like most Linux commands various options can be added, such as: -r, -f, -i, etc.
While not pertinent to the discusion, I will define these quickly for the inquisitve reader:
1. -r recursively delete directory and child files/directories.
@AaronPhalen
AaronPhalen / python_xml_parser.py
Last active October 2, 2015 09:37
A Basix example on creating xml, reading xml, manipulating xml, and xml io
# Author: Aaron Phalen | Twitter: @aaron_phalen | Email: [email protected]
# Example of parsing xml in python with various librarie: read, write, modify, io
try:
import xml.etree.cElementTree as ET
except:
import xml.etree.ElementTree as ET
from xml.dom import minidom
@AaronPhalen
AaronPhalen / basic_vim_commands.md
Last active June 29, 2025 01:03
Useful Vi Editor Commands

Author: Aaron Phalen | Twitter: @aaron_phalen | Email: [email protected]

#Useful Vi Editor Commands

  1. :w --> save to a file
  2. :q --> quit out of editor file
  3. :q! --> quit out of editor without saving file
  4. w --> move one word forward at a time in file
  5. b --> move one word back at a time in file
  6. :wq --> save file and quit editor
@AaronPhalen
AaronPhalen / python_collections.py
Last active September 24, 2015 05:17
Python Collections Basic Examples
#Author: Aaron Phalen | Twitter: @aaron_phalen | Email: [email protected]
# Useful modules and examples from python's collections library
from collections import namedtuple
# 1. Python collections namedtuple
Parameters = namedtuple("Parameters", "x y z")
parameters = Parameters(x="1", y="2", z="3")
# Output
print parameters
# Author: Aaron Phalen | Twitter: @aaron_phalen | Email: [email protected]
# Builder Design Pattern In Python
# Creating xml without builder as constract to example
from lxml import etree
root = etree.Element("root")
child = etree.Element("child")
child.text = "sample text"
root.append(child)
# Author: Aaron Phalen | Twitter: @aaron_phalen | Email: [email protected]
# Example of python class factory
# Dynamically create classes
Class1 = type("Class1", (), {"name": "class 1"})
Class2 = type("Class2", (), {"name": "class 2"})
# create factory class
class SampleClass(object):
"""class factory"""
Author: Aaron Phalen | Twitter: @aaron_phalen | email: [email protected]
Basic Linux Shell Commands (Ubuntu 12.04)
==========================================
1. grep command
---------------
The grep commands allows for search functionality when working with
output strings, files, or directories.