Skip to content

Instantly share code, notes, and snippets.

{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"surname": {
"type": "string"
}
},
function isPalindromePermutation(string) {
let counter = 0;
for (let i = 0; i < string.length; i++) {
const char = string[i];
if (char === ' ') {
continue;
}
const charCodeNormalized = char.toLowerCase().charCodeAt(0) - 'a'.charCodeAt(0);
.user-list {
border: 1px solid grey;
padding: 20px;
}
.user-list__user {
align-content: space-around;
margin-top: 5px;
}
@ianmstew
ianmstew / testBoolean.js
Created May 12, 2016 18:33
The best way to test the truthiness of a boolean
function testBoolean(boolean) {
var booleanCharArray = (function (str){
var buf = new ArrayBuffer(str.length*2); // 2 bytes for each char
var bufView = new Uint16Array(buf);
for (var i=0, strLen=str.length; i<strLen; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
}(String(!!!!!!!boolean)));

state-domain-mn-architecture.js is one approach to separating application state mangement from view state. Application state is maintainted centrally by "Domain Controllers" linked to an event bus that each manage a model or collection. Application state models are then passed into the view hierarchy. Views can use Marionette.State to express their own data needs and "sync" what they need from application state. A Marionette.State instance, in this approach, lives and dies with its View and also handles view events to establish uni-directional, closed-loop management of local view state.

For a more digestable view of Marionette.State's utility in terms of views, see the following JSBin, which addresses the utility of Marionette.State without an opinion about greater application state architecture. It is a working, slimmed-down example of a view spawning its own State instance that serves to consolidate what it needs from global application state models.

https://jsbin.com/huvovoyexe/edit?html,js,outpu

var RSVP = require('rsvp');
var jQuery = require('jquery');
// Log uncaught errors (important)
RSVP.on('error', function (reason) {
console.error((reason && reason.stack) || reason || 'Error');
});
// Shim the browser window with ES6 Promise
window.Promise = RSVP.Promise;
@ianmstew
ianmstew / http-patcher.js
Last active August 29, 2015 14:16
nodejs http patcher
var httpPatcher = function (http) {
// Patch http request() method to capture request
var originalRequestFn = http.request;
http.request = function (options, requestCb) {
console.log('>>> HTTP request >>>\n ' + options.method + ' ' +
(options.port === 443 ? 'https' : 'http') + '://' + options.host + options.path);
// Patch http request() callback to capture response
var originalRequestCb = requestCb;
@ianmstew
ianmstew / has-channel.mixin.js
Last active August 29, 2015 14:10
HasChannel mixin
define(function (require, exports, module) {
var Radio = require('backbone.radio');
var logger = require('lib/util/logger')(module);
// Supports a declarative channelName and semi-custom channelEvents hash.
// Example:
// channelName: 'notify'
// channelEvents: {
// 'error': ['on', 'onError'],
// 'show:message': ['comply', 'showMessage']
@ianmstew
ianmstew / key-github-access.md
Last active August 29, 2015 14:09
Enabling key-based Github access

Hey Sayra!

Everything is working to perfection. Here’s what you have:

Top left

  • Coda with landing.view.html and landing.less opened as tabs
  • File sidebar open to Sayra/SquareknotWorkspace/Patrick/public_html/app/subapps/landing

Bottom left