This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HostnameMiddleware(object): | |
"""Middleware that adds a header X-Hostname to erroneous pages.""" | |
def process_response(self, request, response): | |
try: | |
if response.status_code != 200: | |
import socket | |
hostname = socket.gethostname() | |
addresses = ",".join( socket.gethostbyname_ex(hostname)[2] ) | |
response['X-Host-Name'] = hostname | |
response['X-Host-IP'] = addresses |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* definition */ | |
(function($){ | |
$.fn.each_slice = function( iterator ) { | |
var index, objects; | |
objects = this; | |
for (index=0; index<=objects.length-1; index++) { | |
var single = objects.slice(index, index+1); | |
this = single; | |
iterator(single); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" SWITCH BETWEEN TEST AND PRODUCTION CODE | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
function! OpenTestAlternate() | |
let new_file = AlternateForCurrentFile() | |
exec ':e ' . new_file | |
endfunction | |
function! AlternateForCurrentFile() | |
let current_file = expand("%") | |
let current_path = expand("%:h") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rack/test' | |
describe SampleMiddleware do | |
include Rack::Test::Methods | |
let(:inner_app) do | |
lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['All good!'] } | |
end | |
let(:app) { SampleMiddleware.new(inner_app) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
# | |
# create a test user at developer.facebook.com and set these | |
# | |
FULL_NAME="Bob+Amchicieafci+Martinazziman" | |
APP_ID="123456123456123" | |
APP_SECRET="123abc123abc123abc123abc123abc12" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# installs and configures a graphite server | |
# | |
# depends on two modules from: | |
# - https://github.com/uggedal/puppet-module-nginx | |
# - https://github.com/uggedal/puppet-module-python | |
# global path for exec | |
Exec { | |
path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
curl -XPUT "http://localhost:9200/_template/rsyslog_per_index?pretty=true" -d ' | |
{ | |
"template" : "rsyslog*", | |
"settings" : { | |
"number_of_shards" : 4, | |
"index.cache.field.type" : "soft", | |
"index.refresh_interval" : "5s", | |
"index.store.compress.stored" : true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source :rubygems | |
gem 'json', '= 1.5.4' # knife/chef 11.0 and 11.20 is broken with json 1.5.5/1.7.7 | |
gem 'vagrant' | |
gem 'vagrant-hostmaster' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ERROR: knife encountered an unexpected error | |
This may be a bug in the 'cookbook upload' knife command or plugin | |
Please collect the output of this command with the `-VV` option before filing a bug report. | |
Exception: NameError: undefined local variable or method `cookbook' for #<Chef::Knife::CookbookUpload:0x007fb50ac8d4c8> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
renderTemplate = (template, data) -> | |
template | |
.replace(/{{example_page}}/g, data["example_page"]) | |
.replace(/{{page_type}}/g, data["page_type"]) | |
mockupHtmlTemplate = '<div> | |
<label>Example page:<input onchange="textChanged(this)" name="example_page" value="{{example_page}}"></label><br/> | |
<label>Page type:<input onchange="textChanged(this)" name="page_type" value="{{page_type}}"></label> | |
</div>' |