Skip to content

Instantly share code, notes, and snippets.

View adjohu's full-sized avatar
🎶
Writing code

Adam Hutchinson adjohu

🎶
Writing code
View GitHub Profile
import {random} from 'lodash';
// import {run} from 'modules/engine';
// run();
const width = 320;
const height = 200;
const maxHeat = 255;
const size = width * height;
@adjohu
adjohu / index.js
Created March 20, 2016 21:19
react-motion-parallax
export {default as Parallax} from './parallax.js';
export {default as default} from './parallax.js';
export {Layer as Layer} from './layer.js';
@adjohu
adjohu / testThing.js
Created March 30, 2016 14:44
local styles transition group
import React, {PropTypes} from 'react';
import TransitionGroup from 'react-addons-css-transition-group';
import styles from './testThing.scss';
function randomItem() {
return {
name: Array(Math.floor(Math.random() * 15)).join('a'),
key: Math.random()
}
}
<snippet>
<content><![CDATA[
import React, {PropTypes} from 'react';
//import styles from './${TM_FILENAME/(.+).js/\1/g}.scss';
class ${TM_FILENAME/(.+).js/\u\1/g} extends React.Component {
static defaultProps = {
$4
};
import React, {PropTypes} from 'react';
import TransitionGroup from '../transitionGroup';
class StaggeredTransitionGroup extends React.Component {
constructor(props) {
super(props);
this.state = {
count: 0
};
}
// This is a modified version of vps.js for use with cloudserver presales.
// TODO: refactor configurator to be a class which is extended by VPS and Cloud.
(function ($) {
'use strict';
var capitalize = function (str) {
return str.charAt(0).toUpperCase() + str.slice(1);
};
// Model
(function ($) {
/**
* Override console in this scope so we can squash errors.
*/
var con = window.console;
var console = {
log: function () {
con && con.log && con.log(Array.prototype.slice.call(arguments));
},
$(document).on("click", ".edit_trigger", function () {
var $trigger = $(this);
// Find linked editable
var editableID = $trigger.data("editable");
var $editable = $("#" + editableID);
// Replace editable with input.
var $input = $("<input>").val($editable.html().trim());
$editable
@adjohu
adjohu / models.js
Created February 27, 2013 11:03
Simple model class
var A = function (props) {
this.properties = props;
this.constructor.addModel(this);
};
A.models = [];
A.addModel = function (model) {
model.properties.id = this.models.length + 1;
this.models.push(model);
var createPoller = function (pollFunc, interval) {
var timeout;
var poll = function () {
pollFunc();
timeout = setTimeout(poll, interval);
};
return {
start: function () {