Skip to content

Instantly share code, notes, and snippets.

@kyle-ssg
kyle-ssg / auth-middleware.js
Created October 10, 2016 18:48
Treat any API call with Auth header the same as a call with username/password body
const jwt = require('jsonwebtoken');
const privateKey = 'secret';
module.exports = function (req, res, next) {
const oldSend = res.json;
const token = req.headers.authorization;
var body = req.body;
//When returning json from a username+password request, return a signed token
<View style={{flex:1}}>
<View style={{flex:1}}>
<Button><Text>Hi</Text></Button>
<ListItem><Text>Hi</Text></ListItem>
<Switch onChange={this.toggleState("switchVal")} value={this.state.switchVal}/>
<Checkbox onChange={this.toggleState("checkboxVal")} value={this.state.checkboxVal}/>
<Radio onChange={this.toggleState("radioVal")} value={this.state.radioVal}/>
<Loader/>
<TextInput
@kyle-ssg
kyle-ssg / Chatify
Created July 22, 2015 15:11
Parse posts
this.content = Autolinker.link( content, {
replaceFn: function (autolinker, match) {
switch (match.getType()) {
case 'url' :
if (match.url.match(/\.(jpeg|jpg|gif|png)$/) != null) {
image = match.url;
if (image.indexOf('http') !=0) {
image = 'http://'+image;
}
} else if (Modernizr.video && match.url.match(/\.(mp4|webm)$/) != null) {
@kyle-ssg
kyle-ssg / BaseComponent
Last active August 29, 2015 14:15
BaseComponent for React with store listener handling
/** @jsx React.DOM */
module.exports = function (options) {
return React.createClass( _.assign({}, options, {
_listeners: [],
listenTo: function (store, event, callback) {
this._listeners.push({
store: store,
event: event,