Skip to content

Instantly share code, notes, and snippets.

View scalp42's full-sized avatar
👨‍🎨

Anthony Scalisi scalp42

👨‍🎨
View GitHub Profile
@scalp42
scalp42 / maintenance.html
Created July 30, 2019 03:28 — forked from svey/maintenance.html
maintenance page
<!DOCTYPE html>
<html>
<head>
<title>Maintenance</title>
<style>
body {
background: black;
padding: 25px;
}
div {
@scalp42
scalp42 / rails_log_stathat.rb
Created June 22, 2019 04:56 — forked from nono/rails_log_stathat.rb
Parse a Rails log file and send metrics to stathat
#!/usr/bin/env ruby
require 'net/http/persistent'
require 'uri'
require 'thread'
USAGE = <<EOS
Parse a Rails log file and send metrics to stathat
export EMAIL=email
@scalp42
scalp42 / new_chef_apis.md
Created February 21, 2018 16:55 — forked from lamont-granquist/new_chef_apis.md
New Chef APIs

Notifications from Resources "Bubble Up"

Release in Chef 12.9.41 via PR #4741 core chef now has a feature which has been available in Poise for awhile, which is that notifications from within resources will now notify resources in outer run contexts. This means you can write a recipe with a service resource and send a notification to it from a resource that you write.

Notifications will bubble up from arbitrarily nested resources, so users that write resources that wrap resources which wrap your resource will still find the service resource in your default recipe.

At the same time the resources collection #find() and #lookup methods and the more commonly-used DSL method resources("service[ntpd]") has been changed to also match

About the pic

Choria supports Federating multiple collectives of nodes into a large Federated collective for the purpose of orchestrating.

Federation Requests have:

  • A orchestration request as normal
  • Special headers listing which nodes its for

The client chops a large request into bundles of 200 nodes and publish them to the network for federation. Multiple federation brokers can thus take care of distributing it.

@scalp42
scalp42 / fetch-tmpl-content
Created May 27, 2017 00:13 — forked from seeder/fetch-tmpl-content
Used for fetching templates from consul for use in consul-template as plugin
#!/bin/sh
TMPL=$1
DESTINATION=/config/consultemplate/template/$TMPL
TMPDESTINATION=/tmp/$DESTINATION
LOGS=/logs/$HOSTNAME
mkdir -p $LOGS
mkdir -p "`dirname $DESTINATION`"
@scalp42
scalp42 / kms_example.sh
Created May 22, 2017 03:48 — forked from elblivion/kms_example.sh
AWS KMS for Chef data bags
$ aws kms encrypt --key-id arn:aws:kms:us-east-1:<my_account>:key/<my_key> --plaintext $(cat ~/.chef/prod-secret) --query CiphertextBlob --output text | base64 -D > secret
$ aws kms decrypt --ciphertext-blob fileb://secret --output text --query Plaintext | base64 -D > decoded
$ if [[ "$(cat decoded)" == "$(cat ~/.chef/prod-secret)" ]]; then echo "got back original chef secret"; fi
got back original chef secret
@scalp42
scalp42 / ruby-blocks-procs-lambdas.md
Created March 27, 2017 00:40 — forked from cflee/ruby-blocks-procs-lambdas.md
Discoveries about Ruby Blocks, Procs and Lambdas

Ruby: Blocks, Procs, Lambdas

Note that for blocks, {} and do ... end are interchangeable. For brevity, only the former will be listed here.

Version differences

Pre-1.9, lambda and proc are synonyms. Essentially the difference is between proc and block.

def method(&block) p block.class; p block.inspect; end
l = lambda { 5 }
@scalp42
scalp42 / ruby-blocks-procs-lambdas.md
Created March 27, 2017 00:40 — forked from cflee/ruby-blocks-procs-lambdas.md
Discoveries about Ruby Blocks, Procs and Lambdas

Ruby: Blocks, Procs, Lambdas

Note that for blocks, {} and do ... end are interchangeable. For brevity, only the former will be listed here.

Version differences

Pre-1.9, lambda and proc are synonyms. Essentially the difference is between proc and block.

def method(&block) p block.class; p block.inspect; end
l = lambda { 5 }
I do apps for a living, and lots of the people I do apps for need to make companies. In addition to owning and operating a couple myself, I am often somewhat involved in the creation of others. There are many types of company you can make, and they each have different use cases and tax advantages and audit risks
Type one for small companies that do not expect to carry over losses very often, and do not need foreign ownership or venture capital:
LLC Filed federally as a C-corporation, promoted to a S-Corp shortly after founding for the purposes of taxes: This is what I have. You have to file taxes for it separately, but you largely do not pay tax directly from this for income taxes, but you don't have to do things like hold director meetings with yourself, or maintain minutes. You get the flexibility of a LLC operating agreement, and you can employ yourself easily as well. This form is also rarely audited, and the nature of the tax structure makes book keeping rather easy, taxes rather easy, and keeping your
@scalp42
scalp42 / paginate.rb
Created January 2, 2017 10:06 — forked from soveran/paginate.rb
Pagination helper for Ohm models.
def paginate(collection, options = {})
start = options[:start] || 0
limit = options[:limit] || 0
order = options[:order]
rest = collection.size > (start + limit)
page = collection.sort(order: order, start: start, limit: limit)
[rest, page]
end