Skip to content

Instantly share code, notes, and snippets.

View insin's full-sized avatar
⚠️
Cannot read property 'status' of undefined

Jonny Buchanan insin

⚠️
Cannot read property 'status' of undefined
View GitHub Profile
@insin
insin / 01-gulpfile.js
Last active August 29, 2015 14:16
Regular Gulp 3.* implementation of http://davidwalsh.name/gulp-run-sequence - tasks can specify their own dependencies, but the secret is to *always* return the stream (or accept and call a callback function argument if the work isn't being done by a stream) so Gulp can figure out when a task has completed
gulp.task('copy-js-dir', function() {
return ...
})
gulp.task('copy-php-files', function() {
return ...
})
gulp.task('copy-image-files', function() {
return ...
@insin
insin / gist:96b47423d66d5b3373ee
Last active August 29, 2015 14:16
Minimal CSS for Bootstrap 3-style fluid grid with 50% columns only - see also http://www.helloerik.com/the-subtle-magic-behind-why-the-bootstrap-3-grid-works
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.container {
margin-right: auto;
margin-left: auto;
padding-left: 15px;
padding-right: 15px;
@insin
insin / mithril.html
Last active July 6, 2018 23:08
Templates for code snippets for various UI libraries in Stack Overflow answers (or anywhere else, really)
<meta charset="UTF-8">
<script src="https://npmcdn.com/[email protected]/mithril.js"></script>
<script src="https://npmcdn.com/[email protected]/dist/MSXTransformer.js"></script>
<div id="app"></div>
<script type="text/msx;harmony=true">void function() { 'use strict';
var App = {
view(ctrl, attrs) {
return <h1>Hello {attrs.who}!</h1>
}
@insin
insin / refactoring
Created January 31, 2015 01:47
Refactoring with my JSHint buddies, undef and unused
C:\repos\newforms>gulp
[01:44:34] Using gulpfile C:\repos\newforms\gulpfile.js
[01:44:34] Starting 'lint'...
[01:44:34] Starting 'watch'...
[01:44:34] Finished 'watch' after 196 ms
C:\repos\newforms\lib\Field.js
line 6 col 5 'time' is defined but never used.
line 7 col 5 'url' is defined but never used.
line 10 col 5 'env' is defined but never used.
<script src="http://fb.me/react-with-addons-0.12.2.js"></script>
<script src="http://fb.me/JSXTransformer-0.12.2.js"></script>
<script type="text/jsx;harmony=true">void function() { 'use strict';
var App = React.createClass({
render() {
return <div>
<Hello who="World"/>
<Hello who="Reddit"/>
</div>
@insin
insin / boolean-attrs.tag
Last active August 29, 2015 14:14
Riot.js Boolean Attribute Test Case - http://bl.ocks.org/insin/raw/4ce0df7537a567f1eecb/
<boolean-attrs>
<p><code>riot.version: {opts.version}</code></p>
<p>Try using the toggle button before and after clicking on the checkboxes. Not working in v2.0.5.</p>
<p><code>bool: {String(this.bool)}</code></p>
<label><input type="checkbox" checked={this.bool}> <code>checked=\{this.bool\}</code></label>
<br>
<label><input type="checkbox" checked={!this.bool}> <code>checked=\{!this.bool\}</code></label>
<br>
<button type="button" onclick={toggleBool}>Toggle <code>bool</code></button>
var CommentList = React.createClass({
render() {
return <div className="commentList">
{this.props.data.map(comment => <Comment author={comment.author}>
{comment.text}
</Comment>)}
</div>
}
})
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Riot.js Test</title>
</head>
<body>
<test-form></test-form>
<script src="test-form.tag" type="riot/tag"></script>
<script src="test-component.tag" type="riot/tag"></script>
<script src="https://raw.githubusercontent.com/muut/riotjs/master/riot.js"></script>
@insin
insin / gulpfile.js
Last active August 29, 2015 14:14
Code snippet for "Publishing flat modules to npm"
var gulp = require('gulp')
var flatten = require('gulp-flatten')
var flattenRequires = require('gulp-flatten-requires')
var npmDir = './npm-react-router'
var sourceDirs = 'actions behaviors components locations mixins utils'.split(' ')
var sources = sourceDirs.map(function(dir) { return dir + '/*.js' }).concat(['index.js'])
gulp.task('npm-js', function() {
return gulp.src(sources)
>>> var C = React.createClass({
getInitialState: function() {
return {1: 2}
},
render: function() {
return React.createElement('div', 'test')
}
})
undefined
>>> var original = C.type.prototype.getInitialState