Skip to content

Instantly share code, notes, and snippets.

View fievelk's full-sized avatar

Pierpaolo Pantone fievelk

View GitHub Profile
@laozhu
laozhu / logoutview.py
Created January 4, 2014 02:54
Class Based Logout View of Django
# -*- coding: utf-8 -*-
from django.core.urlresolvers import reverse
from django.contrib.auth import logout
from django.views.generic import RedirectView
class LogoutView(RedirectView):
"""
A view that logout user and redirect to homepage.
"""
@hreeder
hreeder / parser.py
Last active February 27, 2024 03:53
Python nginx Log Parser
#!/usr/bin/env python
import gzip
import os
import sys
import re
INPUT_DIR = "nginx-logs"
lineformat = re.compile(r"""(?P<ipaddress>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) - - \[(?P<dateandtime>\d{2}\/[a-z]{3}\/\d{4}:\d{2}:\d{2}:\d{2} (\+|\-)\d{4})\] ((\"(GET|POST) )(?P<url>.+)(http\/1\.1")) (?P<statuscode>\d{3}) (?P<bytessent>\d+) (["](?P<refferer>(\-)|(.+))["]) (["](?P<useragent>.+)["])""", re.IGNORECASE)
@brianshumate
brianshumate / docker-macos-terraform.md
Last active April 16, 2024 02:18
The Simplest Terraform with Docker on macOS

If you'd like to experiment with Terraform on macOS locally, a great provider for doing so is the Docker provider. You can get set up in a few simple steps, like so:

1. Install Docker

Install Docker for Mac if you have not already.

@mpdude
mpdude / my-workflow.yml
Last active August 25, 2023 13:00
Setup a SSH deploy key so that workflow steps can fetch dependencies from private GitHub repos
# .github/workflows/my-workflow.yml
# ... other config here
jobs:
build:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- name: Setup SSH Keys and known_hosts
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock