Skip to content

Instantly share code, notes, and snippets.

@paultyng
paultyng / dedent-template.js
Created September 5, 2016 15:42 — forked from zenparsing/dedent-template.js
Dedenting Template Strings
function dedent(callSite, ...args) {
function format(str) {
let size = -1;
return str.replace(/\n(\s+)/g, (m, m1) => {
if (size < 0)
size = m1.replace(/\t/g, " ").length;

Better SSH Authorized Keys Management

A seemingly common problem that people encounter is how to handle all of your users authorized_keys file.

People struggle over management, ensuring that users only have specific keys in the authorized_keys file or even a method for expiring keys. A centralized key management system could help provide all of this functionality with a little scripting.

One piece of functionality overlooked in OpenSSH is the AuthorizedKeysCommand configuration keyword. This configuration allows you to specify a command that will run during login to retrieve a users public key file from a remote source and perform validation just as if the authorized_keys file was local.

Here is an example directory structure for a set of users with SSH public keys that can be shared out via a web server:

@paultyng
paultyng / install_awscli.cmd
Created March 17, 2016 13:31
Install AWSCLI via Powershell
Invoke-WebRequest -Uri https://s3.amazonaws.com/aws-cli/AWSCLI64.msi -Outfile Z:\AWSCLI64.msi
@paultyng
paultyng / finding-programming-answers.md
Last active October 9, 2015 20:04
Finding stuff about programming online
@paultyng
paultyng / 01-c9-workspace-config.png
Last active October 9, 2015 15:25
C9 Rails Getting Started
01-c9-workspace-config.png
@paultyng
paultyng / getting-started.md
Last active September 28, 2015 15:43
Getting Started with Rails

Installation Instructions

  1. Install GitHub for Windows
  2. Install Ruby 2.2 (not x64)
  • Install folder should be c:\Ruby22
  • Check Add Ruby executables to your PATH
  1. Install the appropriate DevKit
  • Install folder should be c:\RubyDevKit
  1. Run Git Shell
  2. Go to the DevKit folder cd \RubyDevKit
@paultyng
paultyng / bling.js
Last active August 29, 2015 14:23 — forked from paulirish/bling.js
/* bling.js */
window.$ = document.querySelectorAll.bind(document)
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn)
}
NodeList.prototype.__proto__ = Array.prototype
  1. General Background and Overview
@paultyng
paultyng / redis_queue.rb
Created July 9, 2014 02:20
RedisQueue mock for SQS
require 'redis'
RedisMessage = Struct.new(:body)
class RedisQueue
def initialize(redis)
@redis = redis
end
def poll(&block)
# see http://stackoverflow.com/questions/5880962/how-to-destroy-jobs-enqueued-by-resque-workers - old version
# see https://github.com/defunkt/resque/issues/49
# see http://redis.io/commands - new commands
namespace :resque do
desc "Clear pending tasks"
task :clear => :environment do
queues = Resque.queues
queues.each do |queue_name|
puts "Clearing #{queue_name}..."