Skip to content

Instantly share code, notes, and snippets.

View base10's full-sized avatar

Nathan L. Walls base10

View GitHub Profile
@base10
base10 / gist:6132733
Created August 1, 2013 15:59
Monkey patching Fixnum to shorten looking at epoch strings. Doing a bit of this today and I got tired of typing 'Time.at <epoch value>'.
class Fixnum
def at
Time.at self
end
end
# [36] pry(main)> 1374575803.at
# => 2013-07-23 06:36:43 -0400
@base10
base10 / response.txt
Created August 13, 2013 15:44
Here's some fun with monkey patching a class to see an XMLRPC response. I can't directly get at seeing what I'm going to send to an XMLRPC service with the XMLRPC::Client object itself. If I try to reach in and call 'create().methodCall', I'm told it's private. So, why not create a method where I can make a call and see what's going to happen, w…
$ ruby xmlrpc-test.rb
"<?xml version=\"1.0\" ?><methodCall><methodName>command</methodName><params><param><value><struct><member><name>expr</name><value><array><data><value><string>2 * 3</string></value></data></array></value></member></struct></value></param></params></methodCall>\n"
@base10
base10 / ansible output
Last active December 23, 2015 09:29
Troubleshooting amazon termination
GATHERING FACTS ***************************************************************
<localhost> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-1379534403.68-80673291747765 && chmod a+rx $HOME/.ansible/tmp/ansible-1379534403.68-80673291747765 && echo $HOME/.ansible/tmp/ansible-1379534403.68-80673291747765']
<localhost> REMOTE_MODULE setup
<localhost> PUT /var/folders/4k/1wyf_lds3dvfy66qd11ys5m40000gp/T/tmplpcQKN TO /Users/nathan/.ansible/tmp/ansible-1379534403.68-80673291747765/setup
<localhost> EXEC ['/bin/sh', '-c', '/usr/local/bin/python /Users/nathan/.ansible/tmp/ansible-1379534403.68-80673291747765/setup; rm -rf /Users/nathan/.ansible/tmp/ansible-1379534403.68-80673291747765/ >/dev/null 2>&1']
ok: [localhost]
TASK: [show ec2 instances] ****************************************************
ok: [localhost] => {"item": "", "msg": "Instance Ids are [u'i-e0d0f889']"}
@base10
base10 / gather-results.yml
Last active December 24, 2015 02:29
Local action directory "fails"
---
- name: gather test results
hosts: '{{ec2_host_group }}'
user: '{{ user }}'
gather_facts: True
vars_files:
- group_vars/all
vars:
results_base_path: /tmp/mysql_slap_results
run_datetime: '{{ lookup("pipe", "date +%Y-%m-%dT%H:%M:%SZ") }}'
@base10
base10 / create-ec2-instances.yml
Last active December 24, 2015 09:49
I'm getting an error message when trying to use a variable with async and poll options on a task. It's no problem to use variables elsewhere, but for poll and async, it's a problem. Example below with just poll. Thoughts?
---
- name: Create ec2 instances
hosts: local
gather_facts: True
vars_files:
- group_vars/all
vars:
poll_interval: 5
roles:
- { role: create-instances, query_group: 'assignment_take_small' }
@base10
base10 / add-users.yml
Created October 2, 2013 21:55
Testing out users and user creation with ansible. Goal: Determine if running the user module regenerates ssh keys across multiple ansible runs. Context: Behavior seen by cheboygan in Ansible 1.2 series, reported in #ansible on October 2, 2013. Setup: - Ansible devel (as of bff47df) - Python 2.7.5 - Three Amazon EC2 instances, same AMI (spun up o…
- name: deploy test files
hosts: tag_Name_usertest
user: '{{ user }}'
sudo: true
gather_facts: True
vars:
new_user: nathan
tasks:
- name: generate ssh keys
user: >
@base10
base10 / personal-laptop.txt
Created October 15, 2013 15:13
Ruby Friends, I'm having some trouble with Net::SSH on a machine connecting to a local virtual machine, created through veewee. When veewee attempts to connect to the VM it just created, it fails with an authentication error. I've reduced it to Net::SSH as the issue. I've spun up a virtual machine through veewee on two machines (Ruby 2.0.0 on bo…
D, [2013-10-10T10:17:22.970863 #12659] DEBUG -- net.ssh.transport.session[3fdf324ca274]: establishing connection to 127.0.0.1:7222
D, [2013-10-10T10:17:22.971295 #12659] DEBUG -- net.ssh.transport.session[3fdf324ca274]: connection established
I, [2013-10-10T10:17:22.971369 #12659] INFO -- net.ssh.transport.server_version[3fdf324cf634]: negotiating protocol version
D, [2013-10-10T10:17:22.975480 #12659] DEBUG -- net.ssh.transport.server_version[3fdf324cf634]: remote is `SSH-2.0-OpenSSH_5.3'
D, [2013-10-10T10:17:22.975552 #12659] DEBUG -- net.ssh.transport.server_version[3fdf324cf634]: local is `SSH-2.0-Ruby/Net::SSH_2.7.0 x86_64-darwin12.4.0'
D, [2013-10-10T10:17:22.977023 #12659] DEBUG -- tcpsocket[3fdf324cfe7c]: read 784 bytes
D, [2013-10-10T10:17:22.977121 #12659] DEBUG -- tcpsocket[3fdf324cfe7c]: received packet nr 0 type 20 len 780
I, [2013-10-10T10:17:22.977179 #12659] INFO -- net.ssh.transport.algorithms[3fdf324cea40]: got KEXINIT from server
I, [2013-10-10T10:17:22.977275 #12659] INFO -- net.ssh.tra
@base10
base10 / Vagrantfile
Last active January 3, 2016 04:29
Vagrant/Ansible bootstrap
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# NB: This is a V2 file. Vagrant 1.2 or later is required for the
# Ansible provisioner
config.vm.define :db do |db|
db.vm.box = "core-ubuntu-12.04.2"
db.vm.box_url = "http://example.com/vagrants/core-ubuntu-12.04.2.box"
case day_of_week
when 'Monday', 'Wednesday' then hours = hours_m_w
when 'Tuesday', 'Thursday' then hours = hours_t_th
when 'Friday' then hours = hours_f
else hours = "Weekend!"
end
@base10
base10 / create.js.erb.diff
Last active January 28, 2016 02:47
Making Capybara happy
-$("<%= escape_javascript render(@feed) %>").insertAfter(
- "tr[data-role='feed']:last-child"
+$("table[data-role='feeds']").append(
+ "<%= escape_javascript render(@feed) %>"
);