Skip to content

Instantly share code, notes, and snippets.

@ijin
ijin / lambda_git.py
Created February 18, 2016 03:01
use git from lambda
from __future__ import print_function
import os
import sys
import subprocess
import boto3
from botocore.client import Config
from dulwich.errors import (
SendPackError,
@ijin
ijin / pm_deploy_and_notify.sh
Last active June 29, 2017 17:35
Deploy with pm2 and notify via slack
#!/bin/bash
set -x
export SHA1=`echo ${CIRCLE_SHA1} | cut -c1-7`
export ENV=`echo $1 | rev | cut -d \- -f1 | rev`
pm2 deploy ./app/config/deploy/deploy.json $1 update --force
if [ $? -eq 0 ]; then
export SL_COLOR="good"
@ijin
ijin / echo_and_notify.sh
Last active June 26, 2017 04:57
echo_and_notify_sh
#!/bin/bash
set -x
export SHA1=`echo ${CIRCLE_SHA1} | cut -c1-7`
export ENV=`echo $1 | rev | cut -d \- -f1 | rev`
echo "hi"
if [ $? -eq 0 ]; then
export SL_COLOR="good"
@ijin
ijin / myFunction.js
Last active June 21, 2017 04:06
AWS Lambda function to set an Auto Scaling instance to be Unhealthy in response to a SNS message
console.log('Loading event');
var aws = require('aws-sdk');
var s3 = new aws.S3({apiVersion: '2006-03-01'});
var autoscaling = new aws.AutoScaling({apiVersion: '2011-01-01'});
exports.handler = function(event, context) {
console.log('Received event:');
console.log(event);
//console.log(typeof event.Subject);
if (event.hasOwnProperty('Message')) {
@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|
Running setup.py install for PyYAML
checking if libyaml is compilable
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/check_libyaml.c -o build/temp.linux-x86_64-2.7/check_libyaml.o
build/temp.linux-x86_64-2.7/check_libyaml.c:2:18: fatal error: yaml.h: No such file or directory
#include <yaml.h>
^
compilation terminated.
libyaml is not found or a compiler error: forcing --without-libyaml
(if libyaml is installed correctly, you may need to
specify the option --include-dirs or uncomment and
@ijin
ijin / pip_install_lamvery.sh
Created January 13, 2017 09:05
lamvery install problem
[ec2-user@ip-172-31-22-129 ~]$ sudo yum -y install gcc libyaml-devel
.....
....
...
..
.
Installed:
gcc.noarch 0:4.8.3-3.20.amzn1 libyaml-devel.x86_64 0:0.1.6-6.7.amzn1
Dependency Installed:
@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
@ijin
ijin / lamvery_deploy_and_notify.sh
Last active December 15, 2016 18:10
Deploy to Lambda using Lamvery and notify via Slack
#!/bin/bash
set -x
export SHA1=`echo ${CIRCLE_SHA1} | cut -c1-7`
export ENV=`echo $1 | rev | cut -d \- -f1 | rev`
case "$1" in
'production')
export ENV_PREFIX=$PROD_PREFIX
# HAProxy configuration - haproxy-mysql-failover.cfg
global
log 127.0.0.1 local0
maxconn 4096
user haproxy
group haproxy
daemon
defaults