Skip to content

Instantly share code, notes, and snippets.

View artschwagerb's full-sized avatar

Brian Artschwager artschwagerb

View GitHub Profile

Keybase proof

I hereby claim:

  • I am artschwagerb on github.
  • I am artschwagerb (https://keybase.io/artschwagerb) on keybase.
  • I have a public key ASAkoWhW5kPQRIhRGS1m6bKMSolDCk13wC_Bh9Ss9hKk3Qo

To claim this, I am signing this object:

@artschwagerb
artschwagerb / WMF5Latest.ps1
Created February 15, 2018 15:16 — forked from mgreenegit/WMF5Latest.ps1
Get latest WMF5 and quietly install, reboot suppressed
# Use shortcode to find latest TechNet download site
$confirmationPage = 'http://www.microsoft.com/en-us/download/' + $((invoke-webrequest 'http://aka.ms/wmf5latest' -UseBasicParsing).links | ? Class -eq 'mscom-link download-button dl' | % href)
# Parse confirmation page and look for URL to file
$directURL = (invoke-webrequest $confirmationPage -UseBasicParsing).Links | ? Class -eq 'mscom-link' | ? href -match 'Win8.1AndW2K12R2-KB3134758-x64.msu' | % href | select -first 1
# Download file to local
$download = invoke-webrequest $directURL -OutFile $env:Temp\wmf5latest.msu
# Install quietly with no reboot
if (test-path $env:Temp\wmf5latest.msu) {
start -wait $env:Temp\wmf5latest.msu -argumentlist '/quiet /norestart'
}
@artschwagerb
artschwagerb / logging_example.py
Last active July 20, 2016 18:35
Python Logging
import logging
# Standard instance of a logger with __name__
logger = logging.getLogger(__name__)
# choose your own adventure
logger.info('message goes here')
logger.debug('message goes here')
logger.warning('message goes here')
logger.exception('message goes here')
@artschwagerb
artschwagerb / settings.py
Last active July 22, 2020 13:07
Django Logging to Syslog
from logging.handlers import SysLogHandler
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'standard': {
'format' : "[YOUR PROJECT NAME] [%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
'datefmt' : "%d/%b/%Y %H:%M:%S"
},
'verbose': {
@artschwagerb
artschwagerb / not_securly.html
Last active May 6, 2016 15:55
Not Securly iFrame
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<form>
Enter URL to load: <input type="text" id="url" />
<input type="button" value="Load URL" onclick="loadUrl()" />
@artschwagerb
artschwagerb / views.py
Last active April 18, 2016 19:43
Django Templates
from django.shortcuts import render_to_response, get_object_or_404, render
from django.template import RequestContext, loader, Template
from myapp.models import Model_name
# Template from app directory (lumber), passing in "data"
doc_template = loader.get_template('lumber/%s/result.txt' % ("my_label"))
doc_context = RequestContext(request, {
'data': result['source'],
})
doc_html = doc_template.render(doc_context)
@artschwagerb
artschwagerb / deploy_django.yml
Created January 11, 2016 20:15
Deploy Django App using Ansible
---
- hosts: django_app_servers
serial: 1
remote_user: admin
sudo: yes
tasks:
- name: Send Maintenance Mode Command to HaProxy
shell: curl --data "s={{inventory_hostname}}&b=#12&action=drain" http://user:password@haproxy1.local:8080/haproxy?stats
@artschwagerb
artschwagerb / osx_developer_installation.rst
Last active August 29, 2015 14:27 — forked from stefanfoulis/osx_developer_installation.rst
Instructions on how to setup an OSX developer machine for (python/django) development

OSX Developer System installation

This guide assumes a fresh install of Mac OSX 10.7 Lion.

Brew User

### USAGE
###
### ./ElasticSearch.sh 1.5.0 will install Elasticsearch 1.5.0
### ./ElasticSearch.sh 1.4.4 will install Elasticsearch 1.4.4
### ./ElasticSearch.sh will fail because no version was specified (exit code 1)
###
### CLI options Contributed by @janpieper
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch
### ElasticSearch version
@artschwagerb
artschwagerb / gist:7636463a718339b67768
Created July 15, 2015 18:00
Check AD Username/Password
$cred = Get-Credential #Read credentials
$username = $cred.username
$password = $cred.GetNetworkCredential().password
# Get current domain using logged-on user's credentials
$CurrentDomain = "LDAP://hillsborough.k12.nj.us"
$domain = New-Object System.DirectoryServices.DirectoryEntry($CurrentDomain,$UserName,$Password)
if ($domain.name -eq $null)
{