Skip to content

Instantly share code, notes, and snippets.

@muffinresearch
muffinresearch / flexible-constructor.js
Last active February 4, 2018 14:42
Constructor that works without new keyword.
function MyConstructor(foo){
if (!(this instanceof MyConstructor)){
return new MyConstructor(foo);
}
this.foo = foo;
return this;
}
var instance1 = MyConstructor('foo1');
var instance2 = new MyConstructor('foo2');
@muffinresearch
muffinresearch / gist:324030c72f8c3a5ed8d4
Last active June 8, 2016 02:08
Switch to nfs instead of vboxfs for FFOS Marketplace boot2docker env (on OSX)
# Backup /etc/exports
sudo cp /etc/exports{,.bck}
# Append a link onto /etc/exports to configure nfs
echo '"'$(mkt root)'"' -alldirs -mapall=$(id -u $USER):$(id -g $USER) $(boot2docker ip) | sudo tee -a /etc/exports
sudo /sbin/nfsd restart
# Next let's unmount the old mount, start nfs and mount the nfs share.
boot2docker ssh "sudo umount $(mkt root)"
boot2docker ssh "sudo /usr/local/etc/init.d/nfs-client start"
boot2docker ssh "sudo mount $(boot2docker config | grep HostIP | cut -d'"' -f2):$(mkt root) $(mkt root) -o rw,async,noatime,rsize=32768,wsize=32768,proto=tcp"
language: node_js
node_js:
- "0.10"
addons:
firefox: "18.0"
install:
- "npm install"
before_script:
- export SLIMERJSLAUNCHER=$(which firefox) DISPLAY=:99.0 PATH=$TRAVIS_BUILD_DIR/slimerjs:$PATH
- export SLIMERVERSION=0.10.0pre
@muffinresearch
muffinresearch / custom-prefs.js
Last active August 29, 2015 14:07
Prefs for payments testing
pref("dom.payment.skipHTTPSCheck", true);
pref("dom.identity.enabled", true);
pref("toolkit.identity.debug", true);
pref("dom.mozApps.signed_apps_installable_from", "https://marketplace.firefox.com,https://marketplace.allizom.org,https://marketplace-dev.allizom.org");
pref("dom.payment.provider.1.name", "firefoxmarketdev");
pref("dom.payment.provider.1.description", "marketplace-dev.allizom.org");
pref("dom.payment.provider.1.uri", "https://marketplace-dev.allizom.org/mozpay/?req=");
pref("dom.payment.provider.1.type", "mozilla-dev/payments/pay/v1");
pref("dom.payment.provider.1.requestMethod", "GET");
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Simple command that prints out the current n last levels of the CWD
replacing the prefix with a horizontal ellipsis
Usage pwdn [numdirs]
"""
/*
* Copyright (c) 2008-09, Stuart Colville
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
#!/usr/bin/env python
"""A noddy fake smtp server."""
import smtpd
import asyncore
class FakeSMTPServer(smtpd.SMTPServer):
"""A Fake smtp server"""
def __init__(*args, **kwargs):
<form class="ddg" name="x" action="//duckduckgo.com/">
<input type="hidden" value="muffinresearch.co.uk" name="sites"></input>
<input type="hidden" value="1" name="kh"></input>
<input type="hidden" value="1" name="kn"></input>
<input type="hidden" value="1" name="kac"></input>
<input type="search" placeholder="Search" name="q"></input>
<button class="button" type="submit">GO</button>
</form>
@muffinresearch
muffinresearch / settings_local.js
Created August 8, 2014 12:13
Example settings for fireplace in docker dev-env.
define('settings_local', [], function() {
// Override settings here!
return {
api_url: 'http://mp.dev',
media_url: 'http://mp.dev/media',
// Fix this or Persona doesn't work
persona_site_logo: 'https://marketplace-dev-cdn.allizom.org/media/fireplace/img/logos/128.png'
};
});
@muffinresearch
muffinresearch / Dockerfile
Created August 8, 2014 10:12
Python Base Image example
FROM centos:centos6
# The repo file is local to this dockerfile
ADD mkt.repo /etc/yum.repos.d/mkt.repo
RUN yum install -y python27 \
git \
gcc \
python27-m2crypto \
python27-python-lxml \