Skip to content

Instantly share code, notes, and snippets.

View joshuaconner's full-sized avatar

Joshua Conner joshuaconner

View GitHub Profile
@joshuaconner
joshuaconner / mysql_splitdump.sh
Last active August 29, 2015 14:26 — forked from jasny/mysql_splitdump.sh
Split MySQL dump SQL file into one file per table or extract a single table
#!/bin/bash
####
# Split MySQL dump SQL file into one file per table
# based on http://blog.tty.nl/2011/12/28/splitting-a-database-dump
####
if [ $# -lt 1 ] ; then
echo "USAGE $0 DUMP_FILE [TABLE]"
exit
@joshuaconner
joshuaconner / fullwidth.sh
Last active October 24, 2021 21:51
fullwidth unicode converter in bash
# fullwidth() - converts input into full-width unicode
fullwidth() {
local readonly ARGS="$@"
# fast_chr and unichr from: http://stackoverflow.com/a/23436040/604614
fast_chr() {
local __octal
local __char
printf -v __octal '%03o' $1
printf -v __char \\$__octal

This is a D3.js Heatmap example showing how the highest sun position of the day (which directly correlates with average temperature) changes over the year depending on the latitude of the place. The actual temperature chart would be shifted to the right a bit beacuse of thermal lag.

The data for the chart is calculated using SunCalc.

@joshuaconner
joshuaconner / README.md
Last active August 29, 2015 14:02 — forked from mbostock/.block

This choropleth encodes unemployment rates from 2008 with a quantize scale ranging from 0 to 15%. A threshold scale is a useful alternative for coloring arbitrary ranges.

Keybase proof

I hereby claim:

  • I am joshuaconner on github.
  • I am jconner (https://keybase.io/jconner) on keybase.
  • I have a public key whose fingerprint is 5E09 50F9 8567 0E75 E107 BD9D AA83 B273 6BBE 2B47

To claim this, I am signing this object:

@joshuaconner
joshuaconner / docker_pull_print_output.py
Last active August 29, 2015 14:00
client.pull() output from docker-py
import docker.client
client = docker.Client()
stream = client.pull('bowery/java', stream=True)
for chunk in stream:
print "\n\n\n%s" % chunk
@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'
#!/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 / 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
@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