Skip to content

Instantly share code, notes, and snippets.

View joshuaconner's full-sized avatar

Joshua Conner joshuaconner

View GitHub Profile
@joshuaconner
joshuaconner / gist:4273530
Created December 13, 2012 02:27
using bash to lowercase file extensions
for f in *.JPG; do mv "$f" "${f%.*}.jpg"; done
@joshuaconner
joshuaconner / batch_resize.sh
Last active December 13, 2015 16:39
Copy this into your .bash_profile! Bash function to batch-resize images according to the geometry specified in resize-arg. If no destination directory is specified, the converted images' filenames have "-resized" appended so as to not overwrite the original images.
resize () {
SUFFIX="-resized"
if [ -n "$1" ] ; then
if [ ! -f "${@: -1}" ] ; then
SUFFIX=""
DEST="${@: -1}"
mkdir -p "$DEST"
fi
geom="$1"
@joshuaconner
joshuaconner / dabblet.css
Created June 6, 2013 00:09
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
/*flickering Neon*/
@keyframes neon {
0%, 9%, 12%, 13%, 16%, 75%, 78%, 80%, 83%, 100% {
text-shadow: 0 0 5px #fff,
0 0 10px #fff,
// think of this as the "constructor" function - returns a GridSpace object
// so do your init stuff here
var GridSpace = function (x, y, height) {
this.x = x;
this.y = y;
this.height = height;
};
// this of this as sort of the "class definition", define your other functions here
// be warned though: everything in the prototype is shared between all GridSpace instances!
Denying load of chrome-extension://[Chromoji extension ID]/jquery.min.map. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.
@joshuaconner
joshuaconner / playbook1.yml
Created December 3, 2013 03:15
env-or-else with Ansible... possible?
---
- name: test jinja2 default filter
hosts: localhost
gather_facts: False
tasks:
- name: debug
debug: msg="{{ lookup('env', 'UNDEFINED_THING')|default('foo') }}"
@joshuaconner
joshuaconner / gist:8947448
Created February 12, 2014 00:29
joshuaconner's Ansible Module Skeleton
#!/usr/bin/env python
#
###############################################################################
# joshuaconner's Ansible Module skeleton
#
# This is a skeleton of an Ansible module I've been using to make quick-and-
# dirty Ansible modules. Just drop the code in `{{ PLAYBOOK_ROOT }}/library`
# and it will be accessible like any other Ansible module.
#
# This is probably not a "best practices" module skeleton, but I'd like it to
@joshuaconner
joshuaconner / site.yml
Created February 13, 2014 23:32
Ansible: possible to pass a dict to a module?
---
- name: Ensure nginx is set up
tasks:
- name: Ensure nginx is installed
apt: pkg=nginx
- name: Ensure nginx.conf is in place
template: "{{ nginx_template_opts }}"
notify: restart nginx
#!/usr/bin/python
#
# all_docker_containers
#
# The Ansible `docker` module only returns the containers you've changed, but
# what if you need to get ALL of the docker containers running on a machine?
#
# That's what this is for - it uses the docker API to return all of the running
# containers on a machine, so if you need to stuff to containers you haven't
@joshuaconner
joshuaconner / main.yml
Last active August 29, 2015 14:00
docker_image hack
- name: Ensure an image has been built
hosts: main
vars:
image: joshuaconner/someimage
tag: sometag
tasks:
- name: Check if image has already been built using some fancy grep
shell: if [ -z "$(docker images | grep '{{ image }}[[:blank:]]*{{ tag }}')" ]; then echo image not built; else echo image built; fi
register: cmd_docker_images_grepped
changed_when: cmd_docker_images_grepped.stdout != 'image built'