Skip to content

Instantly share code, notes, and snippets.

Avatar

Evan Light elight

  • Heroku
  • Washington, DC
View GitHub Profile
View add_user.rb
#!/usr/bin/env ruby
CHARACTERS = (('A'..'Z').to_a + ('a'..'z').to_a + (0..9).to_a)
GROUP = 53
MY_MACHINE_DYNDNS_ADDRESS = "Put your DynDns DNS name here"
MY_SSH_PORT = "Your router's external port that will forward to SSH" # as a Fixnum
def ridiculous_password
(1..20).map do
@elight
elight / dci_alt.rb
Created Nov 25, 2011
DCI with delegation instead of extension
View dci_alt.rb
class User < ActiveRecord::Base
# ... lots of persistence stuff
end
class GitHubUserProvisioner < SimpleDelegator
def provision_with!(user_info, extra_user_hash)
self.github_login = extra_user_hash['login']
self.name = user_info['name']
self.email = user_info['email']
self.github_url = user_info['urls']['GitHub']
View us_regional_ruby_confs
Mountain West Ruby Conf
Golden Gate Ruby Conf
Ruby Nation
Gotham Ruby Conf
Windy City Rails
Madison+ Ruby
Rocky Mountain Ruby
Lone Star Ruby (next held in 2015?)
Ruby DCamp
Cascadia Ruby
View dns_manager.rb
module API::Clients
class DnsManager < Base
def initialize(url)
headers = {
"Accept" => "application/json",
"Content-Type" => "application/json",
"Request-Id" => API::RequestStore.request_ids,
"X-Request-Id" => API::RequestStore.request_id,
}
super(url, "heroku-dns-manager", headers: headers)
View dns_manager.rb
def params(action:, domain:, target:, type:)
body = {
change: {
:action => action,
"resource-record-set" => {
:name => domain
}
}
}.tap do |b|
case type
View gist:a78c566c5721b44ce794
require 'json'
cert=File.read('cert.pem')
key=File.read('key.pem')
app = "afternoon-citadel-7280"
body = {
app: { id: app },
certificate_chain: cert,
private_key: key
@elight
elight / whitelist_github.js
Last active Jan 2, 2016
Only getting dem Github notification emails on weekdays
View whitelist_github.js
function whitelistGithub() {
if (isWeekend() || isEvening()) { return; }
var label = GmailApp.getUserLabelByName("github");
var threads = label.getThreads();
for (var i = 0; i < threads.length; i++) {
if (threads[i].isUnread()) {
threads[i].moveToInbox();
}
}
View authentication_controller.rb
login_info = login_information
username = login_info.name
password = login_info.password
View example.rb
AUTH_URL = "https://identity.api.rackspacecloud.com/v2.0/tokens"
compute = Fog::Compute.new(
:provider => "OpenStack",
# Appears to require Rackspace user password and *not* API key :-(
:openstack_api_key => ENV["OS_PASSWORD"],
:openstack_username => ENV["OS_USERNAME"],
:openstack_auth_url => AUTH_URL,
:openstack_region => "IAD"
)
View servers_spec.rb
context "when I create a server" do
Given { pending "we're having a timeout issue here'" }
Given(:private_key) { home.join '.ssh/id_rsa' }
Given do
FileUtils.mkdir_p private_key.dirname, mode: 0700
`echo -e "y\n" | ssh-keygen -t rsa -C "test@example.com" -N "testing" -f "#{private_key}"`
end
When {VCR.use_cassette('servers/create') {run "rumm create server --name silly-saffron"}}
Then {all_stdout =~ /created server/}
And {last_exit_status.should eql 0}