Skip to content

Instantly share code, notes, and snippets.

class profile::web {
#vars
$app_name = hiera('webserver::app_name', undef)
$sanitized_app_name = regsubst($app_name, ' ', '-', 'G')
$sites_available_conf = "${nginx::config::nx_conf_dir}/sites-available/${sanitized_app_name}.conf"
$sites_enabled_conf = "${nginx::config::nx_conf_dir}/sites-enabled/${sanitized_app_name}.conf"
class { 'nginx':
conf_template => "profile/web/nginx.conf.erb",
}
@meatherly
meatherly / gist:4404ab91cdc0374022c8
Created May 20, 2014 02:19
Puppet and bitbucket

The problem We have multiple client NDAs. The client usually gives us access to their AWS account and let's us create web servers to host their apps. We use Capistrano to deploy the web app to their machine. The deploy user on the server needs access to our bitbucket account for that client's repo. I don't want create a key on bitbucket account and put the private key on the client's server because they would have access to all of our client's repos on bitbucket. So I'm trying to figure out a way to create the deploy user's public key on the server and then copy it over to the repo's deploy key list using bitbuckets api.

I wish there was a way I could execute code out side of the manifest to create a key pair and then copy the private key to the deploy user and copy the public key over to bitbucket.

Any good suggestions for this?

@meatherly
meatherly / gist:81041518da4fc0ef9a83
Created April 2, 2015 22:42
Add cascading foreign keys to app
class TableUpdater
attr_accessor :tables, :migration_statements
def initialize
@tables = ActiveRecord::Base.connection.tables.reject{|t| t == "schema_migrations"}
@migration_statements = []
end
def make_migration_file
@tables.each do |table|
@meatherly
meatherly / Vagrantfile.rb
Created July 28, 2015 14:59
Vagrant Phoenix set up
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
defmodule EpBot.Handlers.ImageMe do
use Hedwig.Handler
@usage """
Calls on hubot to image something.
"""
@default_params %{v: "1.0", rsz: "8", safe: "active"}
@google_search_url "https://ajax.googleapis.com/ajax/services/search/images"
def handle_event(%Message{delayed?: false} = msg, opts) do
defmodule BusTracker.Session do
alias BusTracker.User
alias BusTracker.Repo
def login(params, repo) do
user = repo.get_by(User, email: String.downcase(params["email"]))
case authenticate(user, params["password"]) do
true -> {:ok, user}
_ -> :error
end
@meatherly
meatherly / creating_hipchat_connect_notes.md
Created January 9, 2016 21:07
Creating HipChat Connect add-ons notes

Creating HipChat Connect add-ons Notes

All this was created by reading all the sections under Extensions Points on this page.

This is just my general notes/guide on creating and implementing a HipChat Connect add-on. You can learn more here.

Descriptor

First you'll need to provide a Descriptor. You can provide this via REST endpoint on your server. Use this tool to validate your Descriptor: http://atlassian-connect-validator.herokuapp.com/validate?product=hipchat

@meatherly
meatherly / SassMeister-input.scss
Created February 12, 2016 19:20
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
.top-level {
.nested-again {
.some-parent {
color: balk;
.somclass {
margin: 0 auto;
@meatherly
meatherly / popular_pizza.js
Created July 11, 2018 04:27
Get most popular Pizza
@meatherly
meatherly / genericsExample.ts
Created October 25, 2018 15:38
Typescript generics
function map<A, B>(arr: A[], fn: (el: A) => B): B[] {
return arr.map(fn);
}
// manual annotation
map<number, void>(['string'], el => el * 2)
// inferred annotation
map([1,2,4], (num) => num * 2)