Skip to content

Instantly share code, notes, and snippets.

View swalberg's full-sized avatar

Sean Walberg swalberg

View GitHub Profile
use_inline_resources if defined?(use_inline_resources)
def whyrun_supported?
true
end
action :create do
package "patch" do
action :upgrade
SeanWalbergsMacBookPro:surveys(master *) $ dig +short www.winnipegtransit.com @NS6.SO.CG.SHAWCABLE.NET
SeanWalbergsMacBookPro:surveys(master *) $ dig +short www.winnipegtransit.com @ns56.st.vc.shawcable.net
SeanWalbergsMacBookPro:surveys(master *) $ dig +short www.winnipegtransit.com @NS5.NO.CG.SHAWCABLE.NET
winnipegtransit.com.
198.163.45.39
SeanWalbergsMacBookPro:surveys(master *) $ dig +short www.winnipegtransit.com @cowapdns1.winnipeg.ca
winnipegtransit.com.
198.163.45.39
action :create do
chef_gem 'f5-icontrol'
if pool_does_not_exist?
converge_by("Create pool #{pool}") do
create_pool
Chef::Log.info("#{new_resource} created pool #{pool}")
end
end
@swalberg
swalberg / gist:0f6dc4f58bae6e653082
Created November 10, 2014 19:26
Post to HipChat from browser (default to highlighted text)
// Get your token from the HipChat website "API Access" menu
// Add the token and room where indicated in this line (we use "Easylog")
// Make a new page in your button bar with this in it:
javascript:(function(){function getSelectionText() { var text = "";if (window.getSelection) { text = window.getSelection().toString();} else if (document.selection && document.selection.type != "Control") {text = document.selection.createRange().text;} return text;} var auth_token = "MYTOKENGOESHERE";var room = "Easylog";var ajax = new XMLHttpRequest;var url = "https://api.hipchat.com/v2/room/" + encodeURIComponent(room) + "/notification?auth_token=" + auth_token;ajax.open('POST', url, true);ajax.setRequestHeader("Content-type", "application/json");var message = prompt('log entry?', getSelectionText()); if (message) {ajax.send('{"color":"green", "message": "' + message + '"}');} })()
// getSelectionText() copied from http://stackoverflow.com/questions/5379120/get-the-highlighted-selected-text
# Before
SeanWalbergsMacBookPro:~ $ dd if=/dev/zero of=testing bs=1m count=1024
1024+0 records in
1024+0 records out
1073741824 bytes transferred in 11.015328 secs (97477062 bytes/sec)
# After
SeanWalbergsMacBookPro:~ $ dd if=/dev/zero of=testing bs=1m count=1024
1024+0 records in
1024+0 records out
# Inside the gem
class ActionController::Base
def self.check_webhook_signature(key, *args)
before_filter lambda { |controller| controller.check_webhook_signature(key, controller)}, *args
end
def check_webhook_signature(key, controller)
# Do the work
end
end
<?php
// From http://ertw.com/blog/2013/11/05/using-an-ip-phone-with-twilio/
// Connect an incoming call to your SIP phone through Twilio
$called = preg_replace('/sip:1?(.*?)@.*/', '{$1}', $_POST['Called']);
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
require 'active_support/concern'
module NationBuilderApi
extend ActiveSupport::Concern
def token
self.class.token
end
def nationbuilder(to, data)
module MyApp
module Database
def connect(pool_size = nil, reap_time = nil)
return unless defined? ActiveRecord::Base
config = Rails.application.config.database_configuration[Rails.env]
config['reaping_frequency'] = reap_time || ENV['AR_DB_REAP_FREQ'] || 10 # seconds
config['pool'] = pool_size || ENV['AR_DB_POOL'] || 5
ActiveRecord::Base.establish_connection(config)
end
# perl test.pl | more
Name = root
UID = 0
Comment =
Gcos = root
HOME DIR = /root
Name = root
UID = 0
Comment =