Skip to content

Instantly share code, notes, and snippets.

@keithrbennett
keithrbennett / gist:9106009
Created February 20, 2014 02:33
Apple's gcc refuses to run without accepting the license at runtime.
> sudo pip install ansible
...
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/private/tmp/pip_build_root/pycrypto':
configure: error: C compiler cannot create executables
@keithrbennett
keithrbennett / gist:9277536
Last active August 29, 2015 13:56
Sample output of ISTEAUT-225 report as of 2/28/04 14:00.
-------------------------------------------------------------------------------
ISTEAUT-225 Report
-------------------------------------------------------------------------------
Start Time: : 2014-02-28 18:35:23 -0500
End Time: : 2014-02-28 18:35:27 -0500
Duration: : 3 s
-------------------------------------------------------------------------------
@keithrbennett
keithrbennett / inner_method.rb
Created March 12, 2014 16:08
Illustrates that a method can contain a method definition, but that the inner defined method becomes a regular instance method, rendering the code nesting misleading.
#!/usr/bin/env ruby
class C
def foo
def bar
puts "I am bar."
end
bar
end
end
@keithrbennett
keithrbennett / test-jruby-swing-action.rb
Last active August 29, 2015 13:58
Illustrates JRuby Swing Action issues.
require 'java'
java_import javax.swing.TransferHandler
java_import javax.swing.Action
cut = TransferHandler.getCutAction
puts "Cut action is an instance of class #{cut.class}."
cut.putValue('fruit', 'mango')
puts "retrieved fruit value = '#{cut.getValue('fruit')}'."
<script type="text/coffeescript" src="assets/barChart.coffee"></script>
<script type="text/coffeescript">
window.showBySite()
</script>
coffee> obj = { x: 3, y: 4 }
{ x: 3, y: 4 }
coffee> keys = (key for key of obj)
[ 'x', 'y' ]
coffee> vals = keys.map (key) -> obj[key]
[ 3, 4 ]
class Base
def initialize(thing)
puts thing
end
end
class Derived < Base
def initialize(a_thing)
super()
end
TASK: [Install needed gems. (Can install several with one command if needed)] ***
<99.99.99.99> ESTABLISH CONNECTION FOR USER: kbennett
<99.99.99.99> REMOTE_MODULE gem name=my_gem state=present user_install=no
<99.99.99.99> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/Users/kbennett/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', '99.99.99.99', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1400612491.6-209146241172243 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1400612491.6-209146241172243 && echo $HOME/.ansible/tmp/ansible-tmp-1400612491.6-209146241172243'"]
<99.99.99.99> PUT /var/folders/y0/f7tfl1t52vlg79cknv71nr01r1rz9t/T/tmphAJi8c TO /home/kbennett/.ansible/tmp/ansible-tmp-1400612491.6-209146241172243/gem
<99.99.99.99> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'Co
@keithrbennett
keithrbennett / leap_year_spec.rb
Last active August 29, 2015 14:02
Leap Year Calculation with Lambdas
#!/usr/bin/env rspec
def leap_year?(year)
is_mult_of = ->(year, multiplier) { year % multiplier == 0 }
return false unless is_mult_of.(year, 4)
return true unless is_mult_of.(year, 100)
return is_mult_of.(year, 400)
end
@keithrbennett
keithrbennett / gist:77d2ab5512f7d9b7a286
Created June 17, 2014 20:09
Shows how YAML generates back references and JSON does not
2.1.2 :010 > h = { fruit: 'mango' }
=> {:fruit=>"mango"}
2.1.2 :011 > a = [h, h]
=> [{:fruit=>"mango"}, {:fruit=>"mango"}]
2.1.2 :013 > puts a.to_yaml
---
- &1
:fruit: mango
- *1
=> nil