Skip to content

Instantly share code, notes, and snippets.

@youhide
youhide / beanstalk_nginx_fastcgi_env_var.sh
Last active March 31, 2017 23:55
Pass environment variable to NGINX fastcgi on AWS ElasticBeanstalk
#!/usr/bin/env bash
. /opt/elasticbeanstalk/support/envvars
cp /etc/nginx/fastcgi_params.default /etc/nginx/fastcgi_params
. /opt/elasticbeanstalk/bin/get-config environment | python -c "import json,sys; obj=json.load(sys.stdin); f = open('/etc/nginx/fastcgi_params', 'a'); f.write('\n'.join(map(lambda x: 'fastcgi_param ' + x[0] + ' ' + x[1] + ';', obj.iteritems())))"
service httpd stop
service nginx restart
@youhide
youhide / awsAutoScalingIp
Created February 5, 2017 18:39
Get IP's of AutoScaling Group (AWS)
#!/bin/bash
for i in `aws autoscaling describe-auto-scaling-groups --auto-scaling-group-name GROUPNAME | grep -i instanceid | awk '{ print $2}' | cut -d',' -f1| sed -e 's/"//g'`
do
aws ec2 describe-instances --instance-ids $i | grep -i PrivateIpAddress | awk '{ print $2 }' | head -1 | cut -d"," -f1
done;
@youhide
youhide / gaLogin.js
Last active June 24, 2017 04:45
Google Analytics Login Crawler ( CasperJS )
var casper = require('casper').create();
function getLinks() {
var links = document.querySelectorAll('a');
return Array.prototype.map.call(links, function(e) {
return e.getAttribute('href');
});
}
casper.start('https://accounts.google.com/ServiceLogin#identifier');
@youhide
youhide / github_post_recieve.php
Last active August 17, 2017 15:29 — forked from cowboy/github_post_recieve.php
GitHub PHP webhook to auto-pull on repo push
<?php
// Use in the "Post-Receive URLs" section of your GitHub repo.
if ( $_POST['payload'] ) {
shell_exec( 'cd /srv/www/git-repo/ && git reset --hard HEAD && git pull' );
}
?>hi