Skip to content

Instantly share code, notes, and snippets.

@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: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']);
input {
tcp {
'port' => 3333
'type' => 'router_nginx_logs'
}
# Some additional inputs could be here as well
}
filter {
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)
@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`;
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: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
var handleApiRequest = function(req, plugin, next) {
validate_path(req.path, function(err) {
if (err) {
var error = plugin.hapi.error.badRequest(err);
next(error);
}
});
next();
}
@gansbrest
gansbrest / gist:8832525
Created February 5, 2014 20:38
Proxy to another hostname (X-Accel-Redirect support)
location ~* ^/(assets)/(.*) {
set $remote_host "static.fc.com";
# needed to resolve the dynamic host in proxy_pass
resolver 172.16.0.23;
proxy_set_header HOST $remote_host;
proxy_pass http://$remote_host/$1/$2;
}
service "opscenter-agent" do
supports :status => true
start_command "#{agent_dir}/bin/opscenter-agent"
status_command "ps aux | grep -q '[o]pscenter-agent'"
stop_command "kill $(ps aux | grep '[o]pscenter-agent' | awk '{print $2}')"
action :start
end