Skip to content

Instantly share code, notes, and snippets.

View tauren's full-sized avatar

Tauren Mills tauren

View GitHub Profile
<script>
// Load browser shims
Modernizr.load([
{
test: window.JSON,
nope: 'libs/shims/json3.js'
},
{
test: Object.getOwnPropertyNames,
nope: "libs/shims/es5-shim.js",
2012-10-05 02:40:24.209:INFO:oejs.Server:jetty-8.1.5.v20120716
2012-10-05 02:40:27.457:INFO:oejpw.PlusConfiguration:No Transaction manager found - if your webapp requires one, please configure one.
2012-10-05 02:41:41.180:WARN:oejx.XmlConfiguration:Config error at <Set name="sessionPath">/</Set> java.lang.NoSuchMethodException: class org.eclipse.jetty.server.session.HashSessionManager.setSessionPath(class java.lang.String)
2012-10-05 02:41:41.180:WARN:oejx.XmlConfiguration:Config error at <Get name="sessionManager"><Set name="sessionCookie">MYJETTYSESSION</Set><Set name="sessionPath">/</Set><Set name="secureCookies">true</Set><Set name="httpOnly">true</Set></Get> java.lang.NoSuchMethodException: class org.eclipse.jetty.server.session.HashSessionManager.setSessionPath(class java.lang.String)
2012-10-05 02:41:41.180:WARN:oejx.XmlConfiguration:Config error at <Get name="sessionHandler"><Get name="sessionManager"><Set name="sessionCookie">MYJETTYSESSION</Set><Set name="sessionPath">/</Set><Set
@tauren
tauren / data.js
Created January 29, 2013 07:50
AMD module that extracts data attributes from script tag that contains data-main attribute and returns an object containing all of the data values.
/*
* @description Extracts data attributes from script tag that contains data-main attribute
* and returns an object containing all of the data values.
* @author Tauren Mills (github.com/tauren)
*/
define(function() {
// Get all of the script tags
var scripts = document.getElementsByTagName('script');
var data = {};
@tauren
tauren / application.js
Created May 17, 2013 06:15
Sails with middleware
module.exports = {
// Name of the application (used as default <title>)
appName: "Sails Application",
// Port this Sails application will live on
port: 1337,
// The environment the app is deployed in
@tauren
tauren / constructorAOP.js
Last active December 31, 2015 16:39
Looking for a way to apply AOP before, after, or around functions to an object constructor.
// Sipmle AOP after function
var after = function(base, after) {
if (!base) {
return after;
}
return function composedAfter() {
var res = base.apply(this, arguments);
after.apply(this, arguments);
return res;
var _ = require('lodash');
/**
* Make sure to always return an array. If an array is passed, then
* return the array. If passed a string, return an array containing
* that string. If passed undefined or null, return an empty array.
*
* @param [String|Array] values A string or an array
* @return [Array]
*/
@tauren
tauren / isNotColletion.js
Created March 13, 2014 02:38
Sails.js policy that enforces current user as creator of models
module.exports = function(req, res, next) {
// Make sure request is for a single entity, not for a collection of entities
if (!req.params.id) {
return res.forbidden('error.noPermission');
}
return next();
};
@tauren
tauren / sails output
Created March 13, 2014 08:03
It seems that toJSON is being called on the results of another toJSON call.
STEP 1
npm install sails@beta -g
git clone [email protected]:coinprofit/sails-model-question.git
cd sails-model-question
npm init
sails lift
STEP 2
module.exports = {
attributes: {
// The participation that submitted this entry
participation: {
model: 'participation',
required: true
},
@tauren
tauren / websocket.js
Last active February 10, 2017 19:18
RxJS websocket issue
let candidatesToSend = []
let candidatesReceived = []
let socketSubject = Observable.webSocket({
url: 'wss://...',
openObserver: {
next: e => {
e.currentTarget.binaryType = 'arraybuffer'
candidatesToSend.forEach(candidate => {
console.log('sending candidate', candidate)