Skip to content

Instantly share code, notes, and snippets.

@pygeek
pygeek / ecs_tenant_audit.rb
Last active March 18, 2019 22:41
Run audit of tenant - service versions in specified aws region - cluster.
#! /usr/bin/env ruby
require 'aws-sdk-ecs'
class EcsTenantAudit
attr_reader :region, :cluster
def initialize(region: "us-east-1", cluster: "ecs-q")
@region = region
@cluster = cluster
### Keybase proof
I hereby claim:
* I am pygeek on github.
* I am pygeek (https://keybase.io/pygeek) on keybase.
* I have a public key ASB4UGOl9pBofVKU7Or0-DNCGC9-nqGlbwBgO6mXILT4ngo
To claim this, I am signing this object:
@pygeek
pygeek / prepare-commit-msg.sh
Created February 6, 2018 21:41 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with a branch name
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
@pygeek
pygeek / nested_context_example.rb
Last active May 25, 2017 21:43
Properly testing nested if conditionals.
# This is an example of how to properly structure your tests when handle nested conditions.
# When our test structure represents the code structure, it enables us to better understand the code and more easily identify gaps in our testing coverage.
# Take an elseif condition for example
if x
put x
elsif y
put y
else
put z
@pygeek
pygeek / uniform_hegiht.js
Last active December 18, 2015 04:29
Make certain elements uniform height.
$(function(){
var uniform_el_height = {
'parent_el' : '.row#management-services_row-6451 .container', //common immediate parent of elements to make uniform height
'el' : '> .block', //element to make uniform height
'resize_els' : function(initial_offset){
var $max_height = 0;
var self = this;
for local_field in self._meta.local_fields:
if isinstance(local_field, models.fields.files.FileField):
file_attr = getattr(prev_version, local_field.attname)
if file_attr:
file_ = File(file_attr)
setattr(self, local_field.attname, file_)
self.save()
@pygeek
pygeek / gist:5286978
Created April 1, 2013 19:13
Django serves static files on debug mode
if settings.DEBUG:
urlpatterns += patterns('',
url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.STATIC_ROOT,
}),
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT,
}),
)
#credits - http://stackoverflow.com/questions/1057564/pretty-git-branch-graphs
lg1 = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative
lg2 = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(bold white)— %an%C(reset)' --abbrev-commit
lg = !"git lg1"
@pygeek
pygeek / google_analytics.py
Created December 20, 2012 18:09
# Usage: # Define GOOGLE_ANALYTICS_CODE in your settings. # In your base template put: {% google_analytics %} Python 3 compatible ;-]
rom django import template
from django.conf import settings
register = template.Library()
# Usage:
# Define GOOGLE_ANALYTICS_CODE in your settings.
# In your base template put: {% google_analytics %}
@register.simple_tag
def google_analytics():
@pygeek
pygeek / gist:4338297
Created December 19, 2012 17:01
stick footer to bottom of page regardless of (window height : content height)
$(function(){
var $footer_position = function(){
if($(document).height() <= $(window).height()){
$('footer').css({'position' : 'absolute',
'bottom' : '0px'
})
}else{
$('footer').css({'position' : 'static'})
}
};