Skip to content

Instantly share code, notes, and snippets.

@gansbrest
gansbrest / gist:23d76d7773c38f8a3b6b
Created May 1, 2014 18:19
Route 53 script to list all zones and record sets
require 'aws-sdk'
r53 = AWS::Route53.new
resp = r53.client.list_hosted_zones
# Get list of all zones
resp[:hosted_zones].each do |zone|
zone_id = zone[:id][12..-1]
# initialize zone objects
server
{
# To avoid changing your app config
# point Nginx to the Solr port
listen 8983;
# Set read/write variables
set $solr_write "0";
set $solr_read "1";
set $solr_admin "0;
@gansbrest
gansbrest / gist:ecf6bf75fd75aa944887
Last active August 29, 2015 14:04
Little trick to get AWS instance_id as variable in Nginx. Source: distinctplace.com/2014/07/22/little-trick-to-get-aws-instance_id-as-variable-in-nginx/
perl_set $instance_id '
sub {
if ($id)
{
# since this gets executed for EACH request, so use simple caching
return $id;
}
# GET AWS instance metadata
$id = `curl -s http://169.254.169.254/latest/meta-data/instance-id`;
var strtr = function(str, from, to) {
// discuss at: http://phpjs.org/functions/strtr/
// original by: Brett Zamir (http://brett-zamir.me)
// input by: uestla
// input by: Alan C
// input by: Taras Bogach
// input by: jpfle
// bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// bugfixed by: Brett Zamir (http://brett-zamir.me)
input {
tcp {
'port' => 3333
'type' => 'router_nginx_logs'
}
# Some additional inputs could be here as well
}
filter {
@gansbrest
gansbrest / gist:c7d59cc7e38180b2e585
Created May 25, 2015 13:49
Drupal 6 Jquery Update
function academy_site_preprocess_page(&$vars, $hook) {
.....
if (in_array(arg(0), array('admin', 'panels', 'ctools')) || arg(1) == 'add' || arg(2) == 'edit') {
} else {
$scripts = drupal_add_js();
$new_jquery = array(drupal_get_path('theme', 'academy') . '/js/jquery-1.7.2.min.js' => $scripts['core']['misc/jquery.js']);
$scripts['core'] = array_merge($new_jquery, $scripts['core']);
unset($scripts['core']['misc/jquery.js']);
@gansbrest
gansbrest / gist:586265cdefac9e9674e7
Created June 18, 2015 15:24
scrip_name_proxy.patch
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 5b28e98..a9b3410 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -438,7 +438,14 @@ function conf_init() {
// $_SERVER['SCRIPT_NAME'] can, in contrast to $_SERVER['PHP_SELF'], not
// be modified by a visitor.
- if ($dir = trim(dirname($_SERVER['SCRIPT_NAME']), '\,/')) {
+
@gansbrest
gansbrest / gist:7b8c5138bfcb48d4192e
Last active August 29, 2015 14:23
http_host_proxy.patch
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 80b6eb1..5b28e98 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -333,7 +333,15 @@ function conf_path($require_settings = TRUE, $reset = FALSE) {
$confdir = 'sites';
$uri = explode('/', $_SERVER['SCRIPT_NAME'] ? $_SERVER['SCRIPT_NAME'] : $_SERVER['SCRIPT_FILENAME']);
- $server = explode('.', implode('.', array_reverse(explode(':', rtrim($_SERVER['HTTP_HOST'], '.')))));
+
containers:
php-nginx:
background: false
image: gansbrest/php5.3
workdir: "/app"
onetime: true
environment:
XDEBUG_CONFIG: idekey=PHPSTORM
ports:
- 9999:9999
<?php
echo "TEST";
if ($argv[1]) {
sleep(10);
echo "RUN AGAIN";
exit;
}