Skip to content

Instantly share code, notes, and snippets.

@nnarhinen
nnarhinen / datepicker.hbs
Last active August 29, 2015 13:55
Datepicker using Bacon.js and CLNDR.js (with Foundation5 styles)
<div class="clndr-controls row">
<div class="large-7 columns">
<div class="row">
<div class="clndr-previous-button large-2 columns">&lsaquo;</div>
<div class="month large-8 columns">{{month}}</div>
<div class="clndr-next-button large-2 columns">&rsaquo;</div>
</div>
</div>
</div>
<div class="clndr-grid large-7 columns">
@nnarhinen
nnarhinen / navigation-controller.js
Last active August 29, 2015 14:02
How I do navigation / routing with backbone
var vent = require('./vent'),
UsersView = require('./users-view'),
UserView = require('./user-view');
module.exports = function(container) {
var activeView,
renderView = function(view) {
if (activeView) activeView.remove();
activeView = view;
container.html(view.render().el);

Keybase proof

I hereby claim:

  • I am nnarhinen on github.
  • I am nnarhinen (https://keybase.io/nnarhinen) on keybase.
  • I have a public key whose fingerprint is 5587 FD3D 1EAE E010 5C54 5676 123E FEEF 96F1 689E

To claim this, I am signing this object:

/**
* @jsx React.DOM
*/
var React = require('react'),
ReactRouter = require('react-router'),
ActiveState = ReactRouter.ActiveState,
Link = ReactRouter.Link;
var MenuItem = module.exports = React.createClass({
@nnarhinen
nnarhinen / openssl.js
Last active August 29, 2015 14:10
Openssl wrapper for nodejs
'use strict';
var spawn = require('child_process').spawn,
Promise = require('bluebird'),
_ = require('underscore'),
concat = require('concat-stream');
var o = module.exports = {};
o.req = function(privKeyPem, subjectData) {
return new Promise(function(resolve, reject) {
@nnarhinen
nnarhinen / README.md
Created November 29, 2014 10:33
Browserify not reading package.json?

Works:

./node_modules/.bin/browserify -t [reactify --es6] src/frontend/index.js 

Does not work:

./node_modules/.bin/browserify src/frontend.index.js
@nnarhinen
nnarhinen / TodoActions.js
Created November 30, 2014 13:52
Reflux - handling ajax errors on creation
var Reflux = require('reflux'),
_ = require('underscore'),
api = require('./api');
var TodoActions = Reflux.createActions(['create', 'created', 'errored']);
TodoActions.create.preEmit = function(data) {
data = _.extend({_iid: _.uniqueId('todo_')}, data);
api.createTodo(data).then(function(todo) { TodoActions.created(_.extend({_iid: data._iid}, todo)); })
.catch(function(err) { TodoActions.errored(_.extend({_iid: data._iid}, {_error: err}))});
dist/application.min.js
@nnarhinen
nnarhinen / Makefile
Last active August 29, 2015 14:14
How to import bootstrap and react-widgets theme to your stylus file
export PATH := ./node_modules/.bin/:$(PATH)
node_modules_less_files = $(shell find node_modules -type f -name '*.less')
default.css: bootstrap.css react-widgets.css default.styl
stylus --include-css -u nib --import nib -p default.styl > $@
bootstrap.css: build-bootstrap.less $(node_modules_less_files)
lessc build-bootstrap.less > $@
react-widgets.css: build-react-widgets.less $(node_modules_less_files)
<validator name="atleastonerecipient" class="arraylength">
<arguments>
<argument>to</argument>
</arguments>
<ae:parameters>
<ae:parameter name="min">1</ae:parameter>
</ae:parameters>
<errors>
<error>Valitse vähintään yksi sähköpostiosoite</error>
</errors>