View conduit.connect.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Connect = function() { | |
this.fs = require('fs'); | |
this.crypto = require('crypto'); | |
this.http = require('http'); | |
this.url = require('url'); | |
this.q = require('q'); | |
this.initialize(); | |
}; |
View conduit.apiquery.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ApiQuery = function() { | |
this.http = require('http'); | |
this.q = require('q'); | |
this.Connect = require('./conduit.connect'); | |
this.initialize(); | |
}; | |
ApiQuery.prototype = { | |
initialize: function() { |
View gist:94e39847361d7e5b360d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Q = require('q'); | |
var util = require('util'); | |
var request = require('request'); | |
var _ = require('lodash'); | |
var sso = {}; | |
/** | |
* Redirect to the SSO login page. | |
*/ |
View add.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add(...args) { | |
const sum = args.reduce((prev, curr) => prev + curr, 0); | |
const ret = add.bind(void 0, sum); | |
ret.value = ret.valueOf = () => sum; | |
ret.add = ret; | |
return ret; | |
} | |
console.log(add(1, 2).value() === 3); | |
console.log(add(1, 2)(3).value() === 6); |
View node-sass-functions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const path = require('path'); | |
const fs = require('fs'); | |
const types = require('node-sass').types; | |
function svgContentWrapper(svgContent) { | |
return `url('data:image/svg+xml;charset=UTF-8,${svgContent.replace(/\r?\n|\r/g, '')}')`; | |
} |
View react-authenticate-route.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Authenticate component using a wrapper | |
*/ | |
import React, {Component} from 'react'; | |
import { connect } from 'react-redux'; | |
export default function(ComposedComponent) { | |
class Auth extends Component { | |
static contextTypes = { |
View bem-class.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
BEM Class helper: | |
const c = makeClass('myparentclass'); | |
className={c`myclass myclass--active`} | |
becomes: className="myparentclass__myclass myparentclass__myclass--active" | |
*/ | |
export const makeClass = (cls) => | |
(subCls) => subCls[0].split(' ').reduce((acc, s) => | |
`${acc}${cls}__${s} `, '').trimRight(); |
View copyToClipboard.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const copyToClipboard = (function initClipboardText() { | |
const id = 'copy-to-clipboard-helper'; | |
const element = document.getElementById(id); | |
const textarea = element || document.createElement('textarea'); | |
if (!element) { | |
textarea.id = id; | |
// Place in top-left corner of screen regardless of scroll position. | |
textarea.style.position = 'fixed'; | |
textarea.style.top = 0; |
View AuthBlockade.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Example usage: | |
StackNavigator({ | |
Login: { screen: Login }, | |
Play: { screen: AuthBlockade(Play) }, | |
}, { | |
initialRouteName: 'Play', | |
}); | |
*/ |
View adaptiveComponent.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* globals matchMedia */ | |
import React, { PureComponent } from 'react'; | |
function adaptiveComponent(mediaQueries) { | |
const firstMatchingQuery = Object.keys(mediaQueries).find(mediaQuery => | |
matchMedia(mediaQuery).matches); | |
if (!firstMatchingQuery) { | |
throw new Error(`No media query matches found in ${mediaQueries}`); | |
} |
OlderNewer