Skip to content

Instantly share code, notes, and snippets.

View joet3ch's full-sized avatar

Joe Nicosia joet3ch

View GitHub Profile
@joet3ch
joet3ch / gist:4631702
Created January 25, 2013 04:18
New ObjectId using Mongoose
ObjectId = require("mongoose").Types.ObjectId
new ObjectId('xxxx')
@joet3ch
joet3ch / cf-ddns.sh
Created December 22, 2012 19:43
cloudflare ddns
#!/bin/sh
# modified by jfro from http://www.cnysupport.com/index.php/linode-dynamic-dns-ddns-update-script
# Uses curl to be compatible with machines that don't have wget by default
# modified by Ross Hosman for use with cloudflare.
cfkey=
cfuser=
cfhost=
WAN_IP=`curl -s http://ip.skafari.com`
@joet3ch
joet3ch / CORS Configuration
Created December 9, 2012 18:34 — forked from cyberwombat/CORS Configuration
JQuery file upload plugin (blueimp) with NodeJs Express3 directly to Amazon S3 with public access
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
@joet3ch
joet3ch / fab_ec2.py
Created January 19, 2012 00:57
Use fabric with dynamic auto scaling
def web_cluster():
env.user = 'ubuntu'
env.key_filename = ['mykey.pem']
env.conftype = 'prod'
env.project = 'sample'
ec2conn = ec2.connection.EC2Connection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
web_group = ec2conn.get_all_security_groups(groupnames=['web'])
for i in web_group[0].instances():
hostname = i.__dict__['public_dns_name']
@joet3ch
joet3ch / api-monitor.py
Created January 18, 2012 15:23
Simple script to check api availability and send alerts via SES
#!/usr/bin/env python
import os
import sys
import time
import random
import string
import json
import hashlib
import socket
@joet3ch
joet3ch / test01.py
Created January 17, 2012 19:49
testing
#!/usr/bin/env python
print 'hello'
use File::Tail;
my @errors = (’Bad protocol version identification’,'Failed password’,'Did not receive identification string’);
my $line;
my $file = File::Tail->new(”/var/log/auth.log”);
while (defined($line=$file->read)) {
if ($line =~ /$errors[0]|$errors[1]|$errors[2]/) {
open(SSHALERT, “>/tmp/sshalert.txt”);
print SSHALERT “$line”;
#!/usr/bin/perl
use strict;
open(DID, ">>/path/to/iDid.txt");
my $time = &gettime();
sub gettime {
my @timearray = (my $_sec,my $_min,my $_hour,my $_mday,my $_mon,my $_year,my $_wday,my $_yday,my $_isdst) = localtime(time);
my $months = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')[(localtime)[4]];
#!/bin/bash
logger System VM Weekly Snapshot Begin
vmrun snapshot /dir/to/vm/images/image_name.vmx weekly_auto_backup
vmrun snapshot /dir/to/vm/images/image_name.vmx weekly_auto_backup
mount /dev/name /mnt/location
rsync -avg --ignore-errors /dir/to/vm/images/ /mnt/location/VM-BACKUP/
umount /dev/name
logger System VM Weekly Snapshot Complete
use strict;
use File::Tail;
use Net::Syslog;
my $s=new Net::Syslog(Facility=>’local7′,Priority=>’System’,SyslogPort=>’514′,SyslogHost=>’10.0.0.5′);
my $log=File::Tail->new(’c:windowssystem32logfilesw3svc1www.log’);
while (defined(my $line=$log->read)) {
$s->send($line,Priority=>’system’);
}