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
$('#my-element').each( function() { | |
$.each($(this).data("events"), function(i, event) { | |
console.log(i); | |
$.each(event, function(j, h) { | |
console.log(h.handler); | |
}); | |
}); | |
}); |
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
module.exports = function (req, res, next) { | |
res.header("Access-Control-Allow-Origin", "*"); | |
res.header("Access-Control-Allow-Headers", "X-Requested-With"); | |
next(); | |
} |
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
// examples: | |
// create a new function : customRequest = Semaphore.request($.ajax); | |
// override a function: Backbone.sync = Semaphore.request(Backbone.sync); | |
Semaphore = function() { | |
// private attributes | |
var available = true; | |
// private api | |
function lock() { | |
available = false; |
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
$(function() { | |
if ('XDomainRequest' in window && window.XDomainRequest !== null) { | |
jQuery.ajaxSettings.xhr = function() { | |
try { return new XDomainRequest(); } | |
catch(e) { } | |
}; | |
jQuery.support.cors = true; | |
} | |
}) |
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 best distro for LXC right now is ubuntu since you'll have almost no config to get LXC networking working | |
# All LXC commands have to be run as root (or sudo) | |
# 1. DO IT once on the host | |
# 1.1 install lxc | |
apt-get install lxc | |
# 1.2 enable nat on iptables | |
echo 1 > /proc/sys/net/ipv4/ip_forward |
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
upstream service { | |
server {{ ip }}:{{ port }}; | |
} | |
server { | |
if ($http_origin ~* (https?://localhost(:[0-9]+)?)) { | |
rewrite ^ /__cors__/$request_method$uri last; | |
} |
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
upstream service { | |
server 127.0.0.1:4200; | |
} | |
server { | |
listen 443 ssl http2 default_server; | |
server_name localhost; | |
# cd /etc/nginx/ssl | |
# openssl req -x509 -sha256 -newkey rsa:2048 -keyout cert.key -out cert.pem -days 1024 -nodes -subj '/CN=local' |
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
# https://github.com/jubos/fake-s3 | |
FROM alpine | |
EXPOSE 80 | |
RUN apk update | |
RUN apk add ruby ruby-rdoc ruby-irb ruby-io-console | |
RUN gem install fakes3 | |
RUN mkdir -p /var/fakes3 |
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
app.get('/albums', function (req, res) { | |
Album | |
.findAll({ | |
where: getQueryFilters(req.query), | |
order: ['albumartist'] | |
}) | |
.then((items)=> { | |
res.json(items); | |
}); | |
}); |
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
function debounce(func, wait) { | |
let timeout; | |
return function(...args) { | |
clearTimeout(timeout); | |
timeout = setTimeout(()=> { | |
func.apply(this, args); | |
}, wait); | |
}; | |
} |
OlderNewer