Skip to content

Instantly share code, notes, and snippets.

/**
* Get zoom level to fit in
*
* @see http://stackoverflow.com/questions/6048975/google-maps-v3-how-to-calculate-the-zoom-level-for-a-given-bounds
*
* @param bounds
* @param mapWidth
* @param mapHeight
* @returns {number}
*/
module.exports = {
entry: './main.js',
output: {
path: './build', // This is where images AND js will go
publicPath: 'build/', // This is used to generate URLs to e.g. images
filename: 'bundle.js'
},
module: {
loaders: [,
{ test: /\.json$/, loader: 'json-loader' },
/** @jsx React.DOM */
'use strict';
// Libs
var React = require( 'react' );
var uniqueIdCount = 0;
/**
/** @jsx React.DOM */
'use strict';
// Libs
var React = require( 'react' );
var AutoGrowTextarea = React.createClass( {
getInitialState: function() {
return {
@pieterv
pieterv / context.example.js
Last active December 14, 2015 00:49
Wire.js plugin that can connect event handlers after an object is initialised, and disconnect them when an object is destroyed.
define( {
plugins: [
{ module: 'wire/backbone/events' }
],
model: {
create: {
module: 'model',
}
},
@pieterv
pieterv / builder.js
Last active October 1, 2015 07:27
Builder plugin for r.js to build Wire.js files
/**
* @license Copyright (c) 2010-2011 Brian Cavalier
* LICENSE: see the LICENSE.txt file. If file is missing, this file is subject
* to the MIT License at: http://www.opensource.org/licenses/mit-license.php.
*/
/**
* Builder plugin for r.js
*/
define([ 'wire/base' ], function() {
@pieterv
pieterv / backbone.spec.wire.js
Created January 22, 2012 02:28
Example best practice wire spec
define( {
plugins: [
{ module: 'wire/jquery/dom' },
// Responsible for `dom.query.context!`
// This would make dom queries in the context of the current view
// You would delegate out to backbones `view.$()` function for this
// (http://backbonejs.org/#View-dollar)
// A better plugin name could be thought up, maybe `view.query` dunno
@pieterv
pieterv / site
Created January 10, 2012 02:04
Navigate to a project code folder in a users Sites directory
# Move to site dir
function site()
{
# Colors
col='\e[41m'
txtrst='\e[0m'
# Find dir
cd ~ && cd "./Sites"
if [ $1 ]; then