Skip to content

Instantly share code, notes, and snippets.

The Atom sync-settings package will automatically sync settings across all Atom instances using this gist.
@johndaley-me
johndaley-me / devops_bamboo_mocha_istanbul.sh
Last active January 29, 2016 19:48
Run Mocha and Istanbul for node tests on Bamboo
echo 'Running server tests with coverage'
node server/testing/load_test_fixtures.js
# Refer to https://github.com/gotwarlost/istanbul/issues/44#issuecomment-16093330
# for issues around specific command syntax to run mocha with istanbul
# mocha -R xunit -O output=test-reports/mocha.xml 'server/testing/tests/**/*.js'
istanbul cover --report lcov --report clover _mocha -- -R xunit -O output=test-reports/mocha.xml 'tests/**/*.js'
# ensure that non-zero is returned for any failures
# because istanbul may return 0 even in case of a test failure
if [ -r test-reports/mocha.xml ]; then
@johndaley-me
johndaley-me / setup-exim.sh
Last active August 29, 2015 14:27
Exim On Linux with Yum
# Add EPEL repository needed for exim
sudo curl -LO https://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -ivh epel-release-6-8.noarch.rpm
sudo rm -f epel-release-6-8.noarch.rpm
sudo yum -y install exim
# Edit the configuration file at /etc/exim/exim.conf
# Do something like the following for small, automated configuration tweaks:
# sed -ie 's/domainlist relay_to_domains =/domainlist relay_to_domains = example.com/' /etc/exim/exim.conf
@johndaley-me
johndaley-me / Reroute.sh
Created August 20, 2015 12:59
Reroute Outbound Traffic Linux
sudo iptables -t nat -A OUTPUT -p tcp --dport 25 -j DNAT --to-destination :587
@johndaley-me
johndaley-me / Global.asax.cs
Created June 25, 2015 15:55
CORS for Web API < 2
#if DEBUG
protected void Application_BeginRequest(object sender, System.EventArgs e)
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
{
// These headers are handling the "pre-flight" OPTIONS call sent by the browser
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE");
// Match these to those in the request
@johndaley-me
johndaley-me / index.html
Last active August 29, 2015 14:22
Lazy Load language files for angular-gettext
<script>
(function () {
// remove ng-app from body
function bootstrapApp() {
angular.element(document).ready(function () {
angular.bootstrap(document, ['myApp']);
});
}
var key = window.localStorage.getItem('language');
@johndaley-me
johndaley-me / JavaScript Cheat Sheet
Last active April 29, 2016 15:05
JavaScript Cheat Sheet
// Regex
var myAllergies = /\bmy (seasonal )?allergies\b/i;
var text = 'My allergies are acting up. I need some medicine.';
if(text.search(myAllergies) > -1) {
}
// Object.defineProperty
function Car() {