Skip to content

Instantly share code, notes, and snippets.

View cowlibob's full-sized avatar
💭
Eyeballing the code

James Cowlishaw cowlibob

💭
Eyeballing the code
View GitHub Profile
class Race < ActiveRecord::Base
has_many :boats
accepts_nested_attributes_for :boats
end
class Boat < ActiveRecord::Base
has_many :sailors, :through => :competitors
accepts_nested_attributes_for :sailors
end
@cowlibob
cowlibob / domain.rb
Created November 27, 2010 00:57
Uses win32ole to extract computer names from a Windows domain.
require 'win32ole'
class Domain
ADS_SECURE_AUTHENTICATION = 0x1
# Return a deep hash of computer and OU names
def domain_query
# Connect to ADSI interface via COM
connection = WIN32OLE.connect("LDAP:")
@cowlibob
cowlibob / win32ole.rb
Created November 27, 2010 01:18
Patched win32ole.rb which calls OleInitialize and OleUninitialize for main thread. Raises exception when required from thread other than main.
require 'win32ole.so'
# Fail if not required by main thread.
# Call OleInitialize and OleUninitialize for main thread to satisfy the following:
#
# The first thread in the application that calls CoInitialize with 0 (or CoInitializeEx with COINIT_APARTMENTTHREADED)
# must be the last thread to call CoUninitialize. Otherwise, subsequent calls to CoInitialize on the STA will fail and the
# application will not work.
#
# See http://msdn.microsoft.com/en-us/library/ms678543(v=VS.85).aspx
@cowlibob
cowlibob / gist:2340191
Created April 8, 2012 22:43
Git push origin works, where GitHub.app sync fails
James-Cowlishaws-MacBook:When-Boats-Met james$ git status
# Not currently on any branch.
# Unmerged paths:
# (use "git reset HEAD <file>..." to unstage)
# (use "git add/rm <file>..." as appropriate to mark resolution)
#
# both modified: Gemfile
# deleted by us: app/controllers/events_controller.rb
#
no changes added to commit (use "git add" and/or "git commit -a")
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>WebApp Title</title>
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<!-- Make this thing web-app capable -->
<meta name="apple-mobile-web-app-capable" content="yes"/>
@cowlibob
cowlibob / kick
Created July 10, 2014 15:29
kick a chef deploy
#!/bin/sh
ssh vhost$1 -l root -t 'killall -USR1 chef-client && tail -f -n1000 /var/log/chef/client.log'
@cowlibob
cowlibob / server?
Created July 11, 2014 10:11
Search to find out which server an app name is deployed to.
#!/bin/sh
ag $1 ~/Projects/chef-repo/nodes/*

Keybase proof

I hereby claim:

  • I am cowlibob on github.
  • I am jamescowlishaw (https://keybase.io/jamescowlishaw) on keybase.
  • I have a public key whose fingerprint is 53B6 9D6C 9891 72D3 9265 0BA7 6BB7 676D 6198 F760

To claim this, I am signing this object:

#
# Author:: Daniel DeLeo (<dan@kallistec.com>)
# Copyright:: Copyright (c) 2008 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@cowlibob
cowlibob / gist:bf30048a0a23e687560d
Last active August 29, 2015 14:22
Installing boot2docker
correctedtime|vagrant⚡ ⇒ brew install boot2docker
.
.
.
correctedtime|vagrant⚡ ⇒ boot2docker init
.
.
.
correctedtime|vagrant⚡ ⇒ boot2docker up
Waiting for VM and Docker daemon to start...