Skip to content

Instantly share code, notes, and snippets.

@vcastellm
vcastellm / ecs-run
Last active April 15, 2024 17:55
Run task and wait for result in AWS ECS
#!/usr/bin/env bash
set -e
function usage() {
set -e
cat <<EOM
##### ecs-run #####
Simple script for running tasks on Amazon Elastic Container Service
One of the following is required:
Required arguments:
@willdages
willdages / slack-interactive-messages-api-gateway-mapping-template.vtl
Last active March 6, 2024 07:37
Slack's Interactive Messages endpoint reports a Content-Type of `application/x-www-form-urlencoded` but responds with something like looks like `payload=%7B%22actions%22%3A%5B%7B%22...`, which is encoded JSON inside the payload parameter, which takes the API Gateway VTL templates for a loop.
## The `substring(8)` returns the input with everything after "payload=" which is the only parameter passed in,
## everything else is encoded JSON inside that parameter.
#set ($encodedJSON = $input.body.substring(8))
$util.urlDecode(${encodedJSON})
@akira345
akira345 / RTX1200.cfg
Created August 11, 2016 04:59
RTX1200でNAT2つ作る設定サンプルです。
# RTX1200 Rev.10.01.65 (Tue Oct 13 12:23:48 2015)
# Memory 128Mbytes, 3LAN, 1BRI
# main: RTX1200 ver=b0 serial=XXXXXXXX MAC-Address=XX:XX:XX:XX:XX:XX MAC-Address=XX:XX:XX:XX:XX:XX MAC-Address=XX:XX:XX:XX:XX:XX
# Reporting Date: Aug 7 17:18:23 2016
# セキュリティクラス 3(シリアルからのみログイン許可)
# Telnet SSHコマンド使用不可
security class 3 on off off
# タイムゾーンはJST
@ijin
ijin / s3_sync_and_notify.sh
Last active December 26, 2016 06:59
Sync to S3 and notify via Slack
#!/bin/bash
set -x
export S3=`echo $1`
export SHA1=`echo ${CIRCLE_SHA1} | cut -c1-7`
export ENV=`echo $1 | rev | cut -d \- -f1 | rev`
aws --region $REGION s3 sync . s3://$S3/ --exclude 'circle.yml' --exclude '.*' --exclude '*.swp' --exclude 's3*.sh' --delete
if [ $? -eq 0 ]; then
@chaeplin
chaeplin / mqtt-tls.ino
Last active January 10, 2022 01:59
mqtt-tls.ino
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <PubSubClient.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include "/usr/local/src/ap_setting.h"
#define DEBUG_PRINT 1
@tarom
tarom / eb-rails-console.sh
Created March 2, 2015 12:36
Elastic Beanstalk 上で `rails console` 動かす用
set -xe
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
EB_APP_DEPLOY_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir)
EB_APP_USER=$(/opt/elasticbeanstalk/bin/get-config container -k app_user)
EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir)
. $EB_SUPPORT_DIR/envvars
. $EB_SCRIPT_DIR/use-app-ruby.sh
@ijin
ijin / consul_dynamic_inventory.rb
Created June 22, 2014 15:22
dynamic inventory script for ansible using consul
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'json'
output = {}
s_json = JSON.parse(Net::HTTP.get_response(URI.parse('http://localhost:8500/v1/catalog/services')).body)
services = s_json.keys.reject{|k| k == 'consul'}
services.each do |srv|
@jrochkind
jrochkind / gist:2161449
Created March 22, 2012 18:40
A Capistrano Rails Guide

A Capistrano Rails Guide

by Jonathan Rochkind, http://bibwild.wordpress.com

why cap?

Capistrano automates pushing out a new version of your application to a deployment location.

I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".

@hotchpotch
hotchpotch / unicorn_killer.rb
Created October 3, 2011 08:11
Unicorn process killer utility
# # your config.ru
# require 'unicorn_killer'
# use UnicornKiller::MaxRequests, 1000
# use UnicornKiller::Oom, 400 * 1024
module UnicornKiller
module Kill
def quit
sec = (Time.now - @process_start).to_i
warn "#{self.class} send SIGQUIT (pid: #{Process.pid})\talive: #{sec} sec"