Skip to content

Instantly share code, notes, and snippets.

View jrtaylor-com's full-sized avatar

James "Jim" Taylor jrtaylor-com

View GitHub Profile
@jrtaylor-com
jrtaylor-com / youtubeDurationToSeconds
Created May 1, 2015 21:57
Parse Youtube v3 API Duration to seconds with Javascript
function youtubeDurationToSeconds(duration) {
var hours = 0;
var minutes = 0;
var seconds = 0;
// Remove PT from string ref: https://developers.google.com/youtube/v3/docs/videos#contentDetails.duration
duration = duration.replace('PT','');
// If the string contains hours parse it and remove it from our duration string
if (duration.indexOf('H') > -1) {
<?php
/**
* Utilize Constant Contact API v2 endpoints
*/
class ConstantContactV2 {
/**
* Username.
*
* @var string
"set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'tpope/vim-sleuth'
Bundle 'joonty/vdebug.git'
call vundle#end()
@jrtaylor-com
jrtaylor-com / local.mouse.ipcam.job.plist
Created December 24, 2015 18:28
OS X Launchd plist to run Ansible job
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>local.mouse.ipcam.job</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/ansible-playbook</string>
<string>-i</string>
@jrtaylor-com
jrtaylor-com / gist:9f4b50913be2d6b1b572
Created February 19, 2016 17:05
Do something with js/css files modified in the last month
for f in $(find /path/to/file -mmin +0 -mmin -43200 -name '*.js' -or -mmin +0 -mmin -43200 -name '*.css');
do
if [[ $f != *"/exclude_this_directory/"* ]]
then command_to_run_against_match $f
fi done;
@jrtaylor-com
jrtaylor-com / ansible_conditionals_examples.yaml
Created April 14, 2016 12:46 — forked from marcusphi/ansible_conditionals_examples.yaml
Ansible 1.3 Conditional Execution -- Very complete example with comments -- I find the conditional expressions to be ridiculously hard to get right in Ansible. I don't have a good model of what's going on under the surface so I often get it wrong. What makes it even harder is that there has been at least three different variants over the course …
---
# This has been tested with ansible 1.3 with these commands:
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts isFirstRun=false"
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts isFirstRun=true"
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts"
# NB: The type of the variable is crucial!
- name: Ansible Conditionals Examples
hosts: $hosts
vars_files:
@jrtaylor-com
jrtaylor-com / Contract Killer 3.md
Created May 2, 2017 13:25
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@jrtaylor-com
jrtaylor-com / gitflow-breakdown.md
Created September 15, 2017 11:08 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
git commit --allow-empty -m "Initial commit"
git checkout -b develop master

Connect to the remote repository

@jrtaylor-com
jrtaylor-com / mongo-docker.bash
Created March 4, 2020 13:01 — forked from davideicardi/mongo-docker.bash
Running mongodb inside a docker container (with mongodb authentication)
# Create a container from the mongo image,
# run is as a daemon (-d), expose the port 27017 (-p),
# set it to auto start (--restart)
# and with mongo authentication (--auth)
# Image used is https://hub.docker.com/_/mongo/
docker pull mongo
docker run --name YOURCONTAINERNAME --restart=always -d -p 27017:27017 mongo mongod --auth
# Using the mongo "localhost exception" (https://docs.mongodb.org/v3.0/core/security-users/#localhost-exception)
# add a root user
SELECT
om.mundane_id AS ORKID,
om.persona,
COUNT(*) AS numParagons,
(SELECT COUNT(*) FROM ork_awards sub WHERE sub.mundane_id = om.mundane_id AND sub.`kingdomaward_id` IN(SELECT kingdomaward_id FROM ork_kingdomaward subk WHERE subk.award_id = 27)) as ootwCnt
FROM
ork_awards oa
LEFT JOIN ork_kingdomaward oka ON oka.kingdomaward_id = oa.kingdomaward_id