Skip to content

Instantly share code, notes, and snippets.

View davejlong's full-sized avatar

David Long davejlong

View GitHub Profile
@davejlong
davejlong / new.sh
Last active February 5, 2016 17:30
I just shortened 53 lines of code to 1
DAY=$(date --date="-1 day" +%d)

Keybase proof

I hereby claim:

  • I am davejlong on github.
  • I am davejlong (https://keybase.io/davejlong) on keybase.
  • I have a public key ASC_AnHvZ6nBfTn67CtZNNGjfVkL08V_Z2Jm0LZvbhU4hAo

To claim this, I am signing this object:

@davejlong
davejlong / conference.rb
Last active October 4, 2015 10:35
Representing relationships in Lotus::Model
class Conference
include Lotus::Entity
attributes :title, :call_code, :technician_id
# Are the following 2 methods correct for representing the relationship to Technician
def technician
@technician ||= TechnicianRepository.find @technician_id
end
records = [
{ id: "PU525", note: "Foo" },
{ id: "PU525", note: "Bar" },
{ id: "DT525", note: "Hello World" },
{ id: "PU680", note: "Fubar" }
]
[:id, :note].zip(
records.group_by { |record| record[:id] }
.map do |k, v|
@davejlong
davejlong / gist:c54285de0e87141d523a
Created March 11, 2015 16:02
Apples idea of Verbose
$ sudo mdutil -E /
/:
Indexing enabled.
$ sudo mdutil -Ev /
/:
Indexing enabled.
@davejlong
davejlong / install_ruby.yml
Last active August 29, 2015 14:16
Install Ruby if not already installed
- name: Download Ruby source
get_url: url=https://.../ruby-{{ ruby_version }}.tar.gz dest=/tmp/ruby.tar.gz
tags: ruby_install
- name: Make tmp directory for Ruby source
file: path=/tmp/ruby state=directory
tags: ruby_install
... Run through the rest of the configuration ...
@davejlong
davejlong / archive.applescript
Created January 27, 2015 00:22
Rebuilding Quick Actions in Outlook for Mac
(*
Script to Mark Item as Read and Move to folder "Archive"
For Microsoft Outlook 15
*)
tell application "Microsoft Outlook"
activate
set msgSet to current messages
if msgSet = {} then
error "No Messages selected. Select at least one message."
@davejlong
davejlong / my_controller.rb
Last active August 29, 2015 14:13
Angular With Rails - Fixing XHR
class MyController < ApplicationController
def show
@something = MyModel.all
render layout: false if request.xhr?
end
end
@davejlong
davejlong / Vagrantfile
Last active August 29, 2015 14:08
Mesosphere Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "master01" do |master|
master.vm.box = "ubuntu/trusty64"
master.vm.provision "ansible" do |ansible|
@davejlong
davejlong / netrestart.sh
Created October 3, 2014 14:47
Restart interface on Ubuntu now that they've disabled `service networking restart`
#!/bin/bash
iface=$1
echo "Restarting $iface"
ifdown $iface
sleep 5
ifup $iface