Skip to content

Instantly share code, notes, and snippets.

@serkanh
serkanh / UserData script for setup CloudWatch
Last active September 21, 2020 12:46 — forked from martinzuern/UserData script for setup CloudWatch
With this user data script, you can set up cron job to put some custom metrics for CloudWatch at instance initiation.
#!/bin/sh
yum install -y perl-Switch perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https perl-Digest-SHA unzip
cd /home/ec2-user
curl http://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.1.zip -O
unzip CloudWatchMonitoringScripts-1.2.1.zip
rm -rf CloudWatchMonitoringScripts-1.2.1.zip
chown ec2-user:ec2-user aws-scripts-mon
echo "* * * * * /home/ec2-user/aws-scripts-mon/mon-put-instance-data.pl --mem-util --swap-util --aggregated --auto-scaling --from-cron" >> /var/spool/cron/ec2-user
echo "0 * * * * /home/ec2-user/aws-scripts-mon/mon-put-instance-data.pl --disk-space-used --disk-space-avail --disk-space-util --disk-path=/ --aggregated --auto-scaling --from-cron" >> /var/spool/cron/ec2-user
@serkanh
serkanh / hipchat-v2.sh
Created July 21, 2016 18:57 — forked from danriti/hipchat-v2.sh
HipChat API v2 - Send a message to a room using cURL
#!/bin/bash
# Set the ROOM_ID & AUTH_TOKEN variables below.
# Further instructions at https://www.hipchat.com/docs/apiv2/auth
ROOM_ID=XXX
AUTH_TOKEN=XXX
MESSAGE="Hello world!"
curl -H "Content-Type: application/json" \
#!/bin/bash
#
# Install Postgres 9.1, PostGIS and create PostGIS template on a clean Ubuntu 11.10 Oneiric Ocelot box
# http://wildfish.com
# add the ubuntu gis ppa
sudo apt-get -y install python-software-properties
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
@serkanh
serkanh / geojson_serializer.py
Created November 20, 2012 21:18 — forked from glenrobertson/geojson_serializer.py
GeoJSON serializer for Geodjango
"""
Modified from: https://gist.github.com/967274
CHANGES:
* Serialize pk in feature.id and remove from feature.properties
* Added default date format and time format for encoder
* Allow geometryfield option, which doesn't have to be a field, e.g. a @property
USAGE:
@serkanh
serkanh / geojson_serializer.py
Created November 20, 2012 21:07 — forked from danielsokolowski/geojson_serializer.py
GeoJSON Serializer for GeoDjango (gis)
'''
Created on 2011-05-12
@author: Daniel Sokolowski
Extends django's built in JSON serializer to support GEOJSON encoding
Requirements:
Install and setup geodjango (django.contrib.gis)