Skip to content

Instantly share code, notes, and snippets.

Sergey Khaladzinski gansbrest

Block or report user

Report or block gansbrest

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gansbrest
gansbrest / gist:8832525
Created Feb 5, 2014
Proxy to another hostname (X-Accel-Redirect support)
View gist:8832525
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;
}
View gist:9634417
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:23d76d7773c38f8a3b6b
Created May 1, 2014
Route 53 script to list all zones and record sets
View gist:23d76d7773c38f8a3b6b
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
@gansbrest
gansbrest / gist:ecf6bf75fd75aa944887
Last active Aug 29, 2015
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/
View gist:ecf6bf75fd75aa944887
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`;
View gist:db318d6145532d47b240
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)
View gist:af76770957c79aaf68c6
input {
tcp {
'port' => 3333
'type' => 'router_nginx_logs'
}
# Some additional inputs could be here as well
}
filter {
View gist:c7d59cc7e38180b2e585
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:7b8c5138bfcb48d4192e
Last active Aug 29, 2015
http_host_proxy.patch
View gist:7b8c5138bfcb48d4192e
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'], '.')))));
+
View gist:586265cdefac9e9674e7
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']), '\,/')) {
+
View gist:7873c95c59b03a9b2e7d
containers:
php-nginx:
background: false
image: gansbrest/php5.3
workdir: "/app"
onetime: true
environment:
XDEBUG_CONFIG: idekey=PHPSTORM
ports:
- 9999:9999
You can’t perform that action at this time.