Skip to content

Instantly share code, notes, and snippets.

@KensoDev
KensoDev / tatsd_instrumentation.rb
Created January 25, 2016 16:08
statsd_instrumentation.rb
ActiveSupport::Notifications.subscribe(/process_action.action_controller/) do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
controller = event.payload[:controller]
action = event.payload[:action]
format = event.payload[:format] || "all"
format = "all" if format == "*/*"
status = event.payload[:status]
key = "#{controller}.#{action}.#{format}"
# Send the status of the controller without the controller name
@KensoDev
KensoDev / main.tf
Created January 5, 2016 15:36
Terraform example
# Specify the provider and access details
provider "aws" {
region = "${var.aws_region}"
}
# Create a VPC to launch our instances into
resource "aws_vpc" "default" {
cidr_block = "10.0.0.0/16"
}
@KensoDev
KensoDev / wix_signature_default.rb
Created October 23, 2015 20:09
Wix signature handle documentation
encoded_json_hack = encoded_json + ('=' * (4 - encoded_json.length.modulo(4)))
json_str = Base64.urlsafe_decode64(encoded_json_hack)
hmac = OpenSSL::HMAC.digest(OpenSSL::Digest::SHA256.new, APP_SECRET, encoded_json)
# bug in ruby. why are there '=' chars on urlsafe_encode ?!
my_signature = Base64.urlsafe_encode64(hmac).gsub('=','')
@KensoDev
KensoDev / list-instance-types.sh
Created April 7, 2015 16:21
GET list of running instance types on Amazon
ec2-describe-instances | grep running | awk '{print $9}'
diff -ur orig/ext/readline/readline.c fixed/ext/readline/readline.c
--- orig/ext/readline/readline.c 2014-03-18 13:53:31.866359527 +0100
+++ fixed/ext/readline/readline.c 2014-03-18 13:56:26.390247250 +0100
@@ -1883,7 +1883,7 @@
rl_attempted_completion_function = readline_attempted_completion_function;
#if defined(HAVE_RL_PRE_INPUT_HOOK)
- rl_pre_input_hook = (Function *)readline_pre_input_hook;
+ rl_pre_input_hook = (rl_hook_func_t *)readline_pre_input_hook;
#endif
@KensoDev
KensoDev / 23-nginx-access
Created December 10, 2014 14:25
Ship Logs to logstash using Rsyslog
$ModLoad imfile # Load the imfile input module
# <syslog-tag> Tag you give to syslog in order to identigy the input coming from this file eg: nginx-access/rails/some_other_name
# <statefile-name> What do you want the state file to be called eg: nginx-access-state
# use @@ if you want to send logs over TCP
# use @ if you want to send logs over UDP
$InputFileName /path/to_log_location.log
$InputFileTag <syslog-tag>:
$InputFileStateFile <statefile-name>
@KensoDev
KensoDev / read_pipe.sh
Created September 7, 2014 19:00
read_pipe.sh
#!/bin/bash
DEFAULT_PIPE_NAME=".plumber"
PIPE_NAME="${1:-$DEFAULT_PIPE_NAME}"
if [ ! -p $PIPE_NAME ]; then
echo "Created pipe ${PIPE_NAME}..."
mkfifo $PIPE_NAME
fi
@KensoDev
KensoDev / .tmux.conf
Created August 31, 2014 09:03
my tmux configuration
# use UTF8
set -g utf8
set-window-option -g utf8 on
# make tmux display things in 256 colors
set -g default-terminal "screen-256color"
set -g default-terminal "screen-256color"
# set scrollback history to 10000 (10k)
set -g history-limit 10000
@KensoDev
KensoDev / launch-server.sh
Created July 17, 2014 19:19
create new web server using the ec2-tools
#!/bin/bash
region=us-west-2
ami=ami-927613a2
# http://cloud-images.ubuntu.com/locator/ec2/
echo "Input server name: "
read server_name
USERDATA=$(cat <<-EOF
@KensoDev
KensoDev / s3_folder_upload.rb
Created March 7, 2014 14:52
S3 Folder upload
require 'aws'
class S3FolderUpload
attr_reader :folder_path, :total_files, :s3_bucket
attr_accessor :files
# Initialize the upload class
#
# folder_path - path to the folder that you want to upload
# bucket - The bucket you want to upload to