Skip to content

Instantly share code, notes, and snippets.

View atheiman's full-sized avatar
😬

Austin Heiman atheiman

😬
View GitHub Profile
@atheiman
atheiman / Spreeder
Last active April 14, 2024 15:08
Input text and it will display in spreeder format.
Input text and it will display in a spreeder format. There you go, Chris.
@atheiman
atheiman / README.md
Last active August 29, 2015 14:10
Simple Django

Single file Django project template from the O'Reilly book Lightweight Django.

Minimal, simplified, deployable, production ready Django app. 33 lines of Python.

Info

Django can be overwhelming when starting out. Most Django projects have a very large codebase broken into dozens of files, but the idea of this Gist is to show that it doesn't have to be large. Many of the components of the default django-admin.py startproject my_project project template are confusing to new users, so this project template only includes the minimum required settings to run an application with one url and one view.

Usage

@atheiman
atheiman / Django Apache Deploy
Last active September 19, 2018 15:02
Simplified Django deploy using Apache HTTP Server.
Simplified Django deploy using Apache HTTP Server.
@atheiman
atheiman / utils.js
Last active August 29, 2015 14:16
js-utils
function debug(logString) {
DEBUG = (typeof DEBUG === "undefined") ? true : DEBUG;
if (DEBUG)
console.log('DEBUG: ' + logString);
}
function checkArrayForDuplicates(array, arrayNameStr) {
// return false if no dups, return array of error strings if dups
// parameters:
// array | required | Array with potential duplicates
@atheiman
atheiman / get-zip.js
Created November 24, 2015 19:29
Get a client zip code using google maps api
window.navigator.geolocation.getCurrentPosition(function(pos){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
var regex = /(\d{5})",\s*.*postal_code/;
var matches = regex.exec(xhttp.responseText);
console.log('ZIP code:', matches[1]);
}
};
var url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' +
@atheiman
atheiman / logging.sh
Created June 6, 2016 21:12
simple shell script logging utility - logging.sh
#!/bin/bash
# Prints all arguments passed to the function with a timestamp prepended. `LOG_DATE_STRING` can be
# overridden by exporting the var. Prepend to the log using `LOG_LEVEL`.
log() {
[[ -z "$LOG_LEVEL" ]] && log_str='' || log_str="$LOG_LEVEL "
log_str="${log_str}$(date "+${LOG_DATE_STRING-%Y-%m-%d %H:%M:%S}") $@"
echo "$log_str"
}
info() { LOG_LEVEL='INFO' log "$@"; }
@atheiman
atheiman / chef_search_nodes.rb
Last active June 11, 2016 18:46
Chef Node Search API
require 'chef'
def config_chef
chef_config_env_var = 'CHEF_CONFIG'
if ENV[chef_config_env_var]
chef_config = ENV[chef_config_env_var]
else
default_chef_configs = ['~/.chef/knife.rb', '/etc/chef/client.rb']
default_chef_configs.each do |c|
if File.exists?(File.expand_path(c))
@atheiman
atheiman / call_parent_module_method.rb
Last active June 11, 2016 23:21
ruby call parent module (or parent class) method
def my_method
'out of module'
end
module MyMod
def self.my_method
'in module'
end
class MyClass

Messing around with knife exec

SEARCH='chef_environment:*dev*' knife exec partial_search.rb
# - name: node-a
#   hostname: node-a
#   fqdn: node-a.domain.net
#   ipaddress: 10.190.116.124
#   run_list:
# - role[base_os]