Skip to content

Instantly share code, notes, and snippets.

@jarosite
jarosite / public_enc_example.sh
Created November 21, 2019 16:32 — forked from thinkerbot/public_enc_example.sh
Public-key encryption example using OpenSSL
#!/bin/bash
#
# Public-Key Encryption and Decryption
# * http://www.openssl.org/
# * http://barelyenough.org/blog/2008/04/fun-with-public-keys/
#
# Mac OS X 10.6.4
# OpenSSL 0.9.8l 5 Nov 2009
# Generate keys
const https = require('https');
const url = require('url');
// to get the slack hook url, go into slack admin and create a new "Incoming Webhook" integration
const slack_url = 'https://hooks.slack.com/services/XXXX/XXXXX/XXXXXX';
const slack_req_opts = url.parse(slack_url);
const slack_channel = '@user_name'; //or channel name
slack_req_opts.method = 'POST';
slack_req_opts.headers = {'Content-Type': 'application/json'};
exports.handler = function(event, context, callback) {
#!/bin/sh
set -e
set -x
#{
#date
export zabbixemailto=$1
export zabbixsubject=$2
export zabbixbody=$3
slack_web_hook_url=https://hooks.slack.com/services/#####/#####/##########
@jarosite
jarosite / zabbix_sendemail
Created March 26, 2016 13:38
send email notification from zabbix using AWS SES
#!/bin/sh
set -e
set -x
#{
#date
export [email protected]
export zabbixemailto=$1
export zabbixsubject=$2
export zabbixbody=$3
@jarosite
jarosite / ec2tags.rb
Last active August 29, 2015 14:27 — forked from rafaelfelix/ec2tags.rb
Hack to get ec2 tags to facter. Depends on aws-cli (https://github.com/aws/aws-cli), jq (http://stedolan.github.io/jq/) and the JSON RubyGem (http://rubygems.org/gems/json)
require 'facter'
require 'json'
if Facter.value("ec2_instance_id") != nil
instance_id = Facter.value("ec2_instance_id")
region = Facter.value("ec2_placement_availability_zone")[0..-2]
tags = Facter::Util::Resolution.exec("aws ec2 describe-tags --filters \"name=resource-id,values=#{instance_id}\" --region #{region} | jq '[.Tags[] | {key: .Key, value: .Value}]'")
parsed_tags = JSON.parse(tags)
parsed_tags.each do |tag|
@jarosite
jarosite / gist:61936e241e91738ba719
Last active August 29, 2015 14:27
Puppet external fact for EC2 Tags
#!/bin/bash
region=`facter ec2_placement_availability_zone | sed 's/[a-z]$//g'`
instanceId=`facter ec2_instance_id`
/usr/bin/aws ec2 describe-tags --filters "Name=resource-id,Values=${instanceId}" --region ${region} | jq '.Tags[] | "ec2_tag_" + .Key + "=" + .Value' | tr [:upper:] [:lower:] | tr -d '"'
exit 0
@jarosite
jarosite / docker_clean_stopped_containers.sh
Last active August 29, 2015 14:22
remove stopped docker containers
docker rm $(docker ps -q -f status=exited)
filter {
# Format Nginx Error logs
if [type] =~ /nginx_.*_error/ {
grok {
match => {
"message" => [
"%{DATESTAMP:timestamp} \[%{DATA:severity}\] (%{NUMBER:pid:int}#%{NUMBER}: \*%{NUMBER}|\*%{NUMBER}) %{GREEDYDATA:message}",
"%{DATESTAMP:timestamp} \[%{DATA:severity}\] %{GREEDYDATA:message}",
"%{DATESTAMP:timestamp} %{GREEDYDATA:message}"
]
#!/bin/bash
set -x
set -e
REPO_NAME=production
YUM_SERVER_URL=http://localhost:8888/yum-repo-server
FILES=*.rpm
curl -s -d "name=$REPO_NAME" $YUM_SERVER_URL/repo
for f in $FILES
do
echo "Processing $f file..."
@jarosite
jarosite / clean_rev.bat
Created October 24, 2014 07:50
If you get 400 on pull from mercurial, while push is working, probably you have a lot of closed branches but not merged anywhere. Create trash branch, and run this script.
for /F %%x in ('hg log -r "heads(all()) and closed()" --template "{rev}"\n') do (call :merge "%%x")
GOTO :eof
:merge
hg --config ui.merge=internal:local -y merge --rev %1
hg commit -m merge
GOTO :eof