This file contains 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
loop(Req, DocRoot) -> | |
Mod = ewgi_mochiweb:new(fun ?MODULE:simple_stack/1), | |
Mod:run(Req). | |
simple_stack(Ctx) -> | |
to_upper(hello_app(Ctx)). | |
hello_app({ewgi_context, Request, _Response}) -> | |
ResponseHeaders = [{"Content-type", "text/plain"}], |
This file contains 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
#All calls to urls under /dbs are proxyed to couchdb | |
# eg. a call to http://example.com/dbs/mydb becomes http://localhost:5984/mydb | |
location /dbs { | |
rewrite /dbs/(.*) /$1 break; | |
proxy_pass http://localhost:5984; | |
proxy_redirect off; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
} |
This file contains 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
def accept_languages(browser_pref_langs): | |
"""Parses the request and return language list. | |
browser_pref_langs is the plain Accept-Language http request header | |
value. | |
Stolen from Products.PloneLanguageTool, under GPL (c) Plone Foundation, | |
slightly modified. | |
Taken from tweetengine http://github.com/Arachnid/tweetengine/ | |
""" | |
browser_pref_langs = browser_pref_langs.split(',') | |
i = 0 |
This file contains 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
<?php | |
// We'll be outputting a PDF | |
header('Content-type: application/pdf'); | |
// and It will be called downloaded.pdf | |
header('Content-Disposition: attachment; filename="downloaded.pdf"'); | |
// The PDF source is in original.pdf | |
readfile('original.pdf'); | |
?> |
This file contains 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
# | |
# Wide-open CORS config for nginx | |
# | |
location / { | |
if ($request_method = 'OPTIONS') { | |
add_header 'Access-Control-Allow-Origin' 'http://10.140.10.40'; | |
# |
This file contains 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
/* See also: "Learning Javascript Design Patterns" by Addy Osmani | |
* http://addyosmani.com/resources/essentialjsdesignpatterns/book/ | |
* | |
* for examples on how to use pubsub as event aggregator (Mediator) | |
* | |
*/ | |
var pubsub = {}; | |
(function(q) { | |
var topics = {}, subUid = -1; | |
q.subscribe = function(topic, func) { |
This file contains 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
# as zimbra user | |
$ zmprov -l gaa |grep -v admin-domain.com >/tmp/accounts.zmp | |
$ zmprov -l gad |grep -v admin-domain.com >/tmp/domains.zmp |
This file contains 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
/* | |
* From the article "The Art of Error" | |
* http://dailyjs.com/2014/01/30/exception-error/ | |
*/ | |
/* node example */ | |
var assert = require('assert'); | |
var util = require('util'); | |
function NotFound(message) { |
This file contains 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
# The command below creates a tgz file with all emails for user@domain.com in .eml format: | |
# execute as root | |
/opt/zimbra/bin/zmmailbox -z -m user@domain.com getRestURL "//?fmt=tgz" > /tmp/account.tgz | |
# You can do the same via a REST URL: | |
wget http://ZIMBRA.SERVER/home/user@domain.com/?fmt=tgz | |
# to restore email: | |
/opt/zimbra/bin/zmmailbox -z -m user@domain.com postRestURL "//?fmt=tgz&resolve=reset" /tmp/account.tgz |
OlderNewer