<commit_before>/** @jsx React.DOM */

var React = require('react'),
	SetClass = require('classnames'),
	Tappable = require('../touchstone/tappable'),
	Navigation = require('../touchstone/navigation'),
	Link = require('../touchstone/link'),
	UI = require('../touchstone/ui');

var Icons = {
	QR: require('../components/svg/icon-qr'),
	Logo: require('../components/svg/icon-logo')
};

var moment = require('moment')

var SimpleListItem = React.createClass({
	mixins: [Navigation],

	showDetailsView: function() {
		this.showView('details', 'show-from-right', { user: this.props.user })
	},

	render: function() {

		return (
			<Tappable onTap={this.showDetailsView} className="list-item list-item-has-chevron" component="div">

{this.props.user.name}

			</Tappable>
		);
	}
});

var SimpleList = React.createClass({
	render: function() {

		var users = [];

		this.props.users.forEach(function(user, i) {
			user.key = 'user-' + i;
			users.push(React.createElement(SimpleListItem, { user: user }));
		});

		return (

Simple List

					{users}

		);
	}
});

var ComplexListItem = React.createClass({
	mixins: [Navigation],

	showDetailsView: function() {
		this.showView('details', 'show-from-right', { user: this.props.user })
	},

	render: function() {

		return (
			<Tappable onTap={this.showDetailsView} className="list-item user-item list-item-icon-left list-item-has-chevron" component="div">

{this.props.user.name}

{this.props.user.location}

			</Tappable>
		);
	}
});

var ComplexList = React.createClass({
	render: function() {

		var users = [];

		this.props.users.forEach(function(user, i) {
			user.key = 'user-' + i;
			users.push(React.createElement(ComplexListItem, { user: user }));
		});

		return (

Complex List

					{users}

		);
	}
});

module.exports = React.createClass({
	mixins: [Navigation],

	getInitialState: function() {
		return {
			centre: '',
			gate: '',
			scanButtonActiveState: undefined
		}
	},

	scannerIsAvailable: function() {
		return !(typeof cordova === 'undefined');
	},

	loadScanner: function() {

		console.log('clicked', this);

		if (this.state.scannerIsLoading) {
			return;
		}

		this.setState({
			scannerIsLoading: true
		});

		cordova.plugins.barcodeScanner.scan(
			// success
			function (result) {

				var newState = {
					scannerIsLoading: false
				};

				if (!result.cancelled) {
					var decode = this.props.api.decodePaymentURI(result.text);

					_.extend(newState, {
						targetAddress: decode.address,
						targetDescription: decode.description,
						targetValue: decode.amount
					});
				}

				this.setState(newState);

			}.bind(this),
			// error
			function (error) {

				this.setState({
					scannerIsLoading: false
				});

				navigator.notification.alert(
					error,               // message
					function() {},       // callback
					'Scanning Failed',   // title
					'OK'                 // buttonName
				);

			}.bind(this)
		);

		var scanResult;

	},

	render: function() {
		var viewClassName = this.props.viewClassName + ' home-view';

		var scanButtonClassName = SetClass({
			'scan-button': true,
			'enter-active': this.state.scanButtonActiveState === 'enter',
			'leave-active': this.state.scanButtonActiveState === 'leave'

		});

		var makeLicensePlate = function() {
			var text = "";
			var possible = "ABCDEFGHIJKLMNPQRSTUVWXYZ0123456789";

			for( var i=0; i < 6; i++ ) {
				text += possible.charAt(Math.floor(Math.random() * possible.length));
			}

			text = [text.slice(0,3), text.slice(3,6)].join(' ');

			return text;
		}

		// Stub users
		var users = [
			{ name: 'Benjamin Lupton',   joinedDate: 'Mar 8, 2009',   location: 'Sydney, AU',          img: 'https://avatars0.githubusercontent.com/u/61148?v=3&s=460' ,    flavour: 'vanilla'},
			{ name: 'Boris Bozic',       joinedDate: 'Mar 12, 2013',  location: 'Sydney, AU',          img: 'https://avatars1.githubusercontent.com/u/3838716?v=3&s=460' ,  flavour: 'chocolate'},
			{ name: 'Carlos Colon',      joinedDate: 'Nov 7, 2013',   location: 'New Hampshire, USA',  img: 'https://avatars3.githubusercontent.com/u/5872515?v=3&s=460' ,  flavour: 'caramel'},
			{ name: 'David Banham',      joinedDate: 'Feb 22, 2011',  location: 'Sydney, AU',          img: 'https://avatars3.githubusercontent.com/u/631832?v=3&s=460' ,   flavour: 'strawberry'},
			{ name: 'Frederic Beaudet',  joinedDate: 'Mar 12, 2013',  location: 'Montreal',            img: 'https://avatars0.githubusercontent.com/u/3833335?v=3&s=460' ,  flavour: 'strawberry'},
			{ name: 'James Allen',       joinedDate: 'Feb 14, 2013',  location: 'Manchester',          img: 'https://avatars1.githubusercontent.com/u/3593671?v=3&s=460' ,   flavour: 'banana'},
			{ name: 'Jed Watson',        joinedDate: 'Jun 24, 2011',  location: 'Sydney, AU',          img: 'https://avatars1.githubusercontent.com/u/872310?v=3&s=460' ,   flavour: 'banana'},
			{ name: 'Joss Mackison',     joinedDate: 'Nov 6, 2012',   location: 'Sydney, AU',          img: 'https://avatars2.githubusercontent.com/u/2730833?v=3&s=460' ,  flavour: 'lemon'},
			{ name: 'Johnny Estilles',   joinedDate: 'Sep 23, 2013',  location: 'Philippines',         img: 'https://avatars3.githubusercontent.com/u/5514878?v=3&s=460' ,  flavour: 'lemon'},
			{ name: 'Markus Padourek',   joinedDate: 'Oct 17, 2012',  location: 'London, UK',          img: 'https://avatars2.githubusercontent.com/u/2580254?v=3&s=460' ,  flavour: 'pastaccio'},
			{ name: 'Mike Grabowski',    joinedDate: 'Oct 2, 2012',   location: 'London, UK',          img: 'https://avatars3.githubusercontent.com/u/2464966?v=3&s=460' ,  flavour: 'vanilla'},
			{ name: 'Rob Morris',        joinedDate: 'Oct 18, 2012',  location: 'Sydney, AU',          img: 'https://avatars3.githubusercontent.com/u/2587163?v=3&s=460' ,  flavour: 'chocolate'},
			{ name: 'Simon Taylor',      joinedDate: 'Sep 14, 2013',  location: 'Sydney, AU',          img: 'https://avatars1.githubusercontent.com/u/5457267?v=3&s=460' ,  flavour: 'caramel'},
			{ name: 'Steven Steneker',   joinedDate: 'Jun 30, 2008',  location: 'Sydney, AU',          img: 'https://avatars3.githubusercontent.com/u/15554?v=3&s=460' ,    flavour: 'strawberry'},
			{ name: 'Tom Walker',        joinedDate: 'Apr 19, 2011',  location: 'Sydney, AU',          img: 'https://avatars2.githubusercontent.com/u/737821?v=3&s=460' ,   flavour: 'banana'},
			{ name: 'Tuan Hoang',        joinedDate: 'Mar 19, 2013',  location: 'Sydney, AU',          img: 'https://avatars0.githubusercontent.com/u/3906505?v=3&s=460',   flavour: 'lemon' }
		];

		// Conditional UI
		var scanButton = this.scannerIsAvailable() ? (
			<UI.FlexBlock height="60px" className="scan-button-wrapper">
				<Tappable onTap={this.loadScanner} className={scanButtonClassName} component="button">

							Scan

							Code

				</Tappable>
			</UI.FlexBlock>
		) : null;

		return (
			<UI.FlexLayout className={viewClassName}>
				<UI.FlexBlock height={this.context.app.state.isNativeApp ? '150px' : '130px'} className="home-hero">
					<Icons.Logo className="home-hero-logo" />
					<UI.StripButtons className="home-buttons">
						<UI.StripButton showView="components"  viewTransition="show-from-right" label="Components"  icon="ion-ios7-keypad" />
						<UI.StripButton showView="transitions" viewTransition="show-from-right" label="Transitions" icon="ion-ios7-photos" />
					</UI.StripButtons>
				</UI.FlexBlock>
				<UI.FlexBlock scrollable>
					<SimpleList users={users} />
					<ComplexList users={users} />
				</UI.FlexBlock>
				{scanButton}
			</UI.FlexLayout>
		);
	}
});
<commit_msg>Add empty bio needed for props in details<commit_after>/** @jsx React.DOM */

var React = require('react'),
	SetClass = require('classnames'),
	Tappable = require('../touchstone/tappable'),
	Navigation = require('../touchstone/navigation'),
	Link = require('../touchstone/link'),
	UI = require('../touchstone/ui');

var Icons = {
	QR: require('../components/svg/icon-qr'),
	Logo: require('../components/svg/icon-logo')
};

var moment = require('moment')

var SimpleListItem = React.createClass({
	mixins: [Navigation],

	showDetailsView: function() {
		this.showView('details', 'show-from-right', { user: this.props.user })
	},

	render: function() {

		return (
			<Tappable onTap={this.showDetailsView} className="list-item list-item-has-chevron" component="div">

{this.props.user.name}

			</Tappable>
		);
	}
});

var SimpleList = React.createClass({
	render: function() {

		var users = [];

		this.props.users.forEach(function(user, i) {
			user.key = 'user-' + i;
			users.push(React.createElement(SimpleListItem, { user: user }));
		});

		return (

Simple List

					{users}

		);
	}
});

var ComplexListItem = React.createClass({
	mixins: [Navigation],

	showDetailsView: function() {
		this.showView('details', 'show-from-right', { user: this.props.user })
	},

	render: function() {

		return (
			<Tappable onTap={this.showDetailsView} className="list-item user-item list-item-icon-left list-item-has-chevron" component="div">

{this.props.user.name}

{this.props.user.location}

			</Tappable>
		);
	}
});

var ComplexList = React.createClass({
	render: function() {

		var users = [];

		this.props.users.forEach(function(user, i) {
			user.key = 'user-' + i;
			users.push(React.createElement(ComplexListItem, { user: user }));
		});

		return (

Complex List

					{users}

		);
	}
});

module.exports = React.createClass({
	mixins: [Navigation],

	getInitialState: function() {
		return {
			centre: '',
			gate: '',
			scanButtonActiveState: undefined
		}
	},

	scannerIsAvailable: function() {
		return !(typeof cordova === 'undefined');
	},

	loadScanner: function() {

		console.log('clicked', this);

		if (this.state.scannerIsLoading) {
			return;
		}

		this.setState({
			scannerIsLoading: true
		});

		cordova.plugins.barcodeScanner.scan(
			// success
			function (result) {

				var newState = {
					scannerIsLoading: false
				};

				if (!result.cancelled) {
					var decode = this.props.api.decodePaymentURI(result.text);

					_.extend(newState, {
						targetAddress: decode.address,
						targetDescription: decode.description,
						targetValue: decode.amount
					});
				}

				this.setState(newState);

			}.bind(this),
			// error
			function (error) {

				this.setState({
					scannerIsLoading: false
				});

				navigator.notification.alert(
					error,               // message
					function() {},       // callback
					'Scanning Failed',   // title
					'OK'                 // buttonName
				);

			}.bind(this)
		);

		var scanResult;

	},

	render: function() {
		var viewClassName = this.props.viewClassName + ' home-view';

		var scanButtonClassName = SetClass({
			'scan-button': true,
			'enter-active': this.state.scanButtonActiveState === 'enter',
			'leave-active': this.state.scanButtonActiveState === 'leave'

		});

		var makeLicensePlate = function() {
			var text = "";
			var possible = "ABCDEFGHIJKLMNPQRSTUVWXYZ0123456789";

			for( var i=0; i < 6; i++ ) {
				text += possible.charAt(Math.floor(Math.random() * possible.length));
			}

			text = [text.slice(0,3), text.slice(3,6)].join(' ');

			return text;
		}

		// Stub users
		var users = [
			{ name: 'Benjamin Lupton',   joinedDate: 'Mar 8, 2009',   location: 'Sydney, AU',          img: 'https://avatars0.githubusercontent.com/u/61148?v=3&s=460',    bio: '',  flavour: 'vanilla'},
			{ name: 'Boris Bozic',       joinedDate: 'Mar 12, 2013',  location: 'Sydney, AU',          img: 'https://avatars1.githubusercontent.com/u/3838716?v=3&s=460',  bio: '',  flavour: 'chocolate'},
			{ name: 'Carlos Colon',      joinedDate: 'Nov 7, 2013',   location: 'New Hampshire, USA',  img: 'https://avatars3.githubusercontent.com/u/5872515?v=3&s=460',  bio: '',  flavour: 'caramel'},
			{ name: 'David Banham',      joinedDate: 'Feb 22, 2011',  location: 'Sydney, AU',          img: 'https://avatars3.githubusercontent.com/u/631832?v=3&s=460',   bio: '',  flavour: 'strawberry'},
			{ name: 'Frederic Beaudet',  joinedDate: 'Mar 12, 2013',  location: 'Montreal',            img: 'https://avatars0.githubusercontent.com/u/3833335?v=3&s=460',  bio: '',  flavour: 'strawberry'},
			{ name: 'James Allen',       joinedDate: 'Feb 14, 2013',  location: 'Manchester',          img: 'https://avatars1.githubusercontent.com/u/3593671?v=3&s=460',  bio: '',  flavour: 'banana'},
			{ name: 'Jed Watson',        joinedDate: 'Jun 24, 2011',  location: 'Sydney, AU',          img: 'https://avatars1.githubusercontent.com/u/872310?v=3&s=460',   bio: '',  flavour: 'banana'},
			{ name: 'Joss Mackison',     joinedDate: 'Nov 6, 2012',   location: 'Sydney, AU',          img: 'https://avatars2.githubusercontent.com/u/2730833?v=3&s=460',  bio: '',  flavour: 'lemon'},
			{ name: 'Johnny Estilles',   joinedDate: 'Sep 23, 2013',  location: 'Philippines',         img: 'https://avatars3.githubusercontent.com/u/5514878?v=3&s=460',  bio: '',  flavour: 'lemon'},
			{ name: 'Markus Padourek',   joinedDate: 'Oct 17, 2012',  location: 'London, UK',          img: 'https://avatars2.githubusercontent.com/u/2580254?v=3&s=460',  bio: '',  flavour: 'pastaccio'},
			{ name: 'Mike Grabowski',    joinedDate: 'Oct 2, 2012',   location: 'London, UK',          img: 'https://avatars3.githubusercontent.com/u/2464966?v=3&s=460',  bio: '',  flavour: 'vanilla'},
			{ name: 'Rob Morris',        joinedDate: 'Oct 18, 2012',  location: 'Sydney, AU',          img: 'https://avatars3.githubusercontent.com/u/2587163?v=3&s=460',  bio: '',  flavour: 'chocolate'},
			{ name: 'Simon Taylor',      joinedDate: 'Sep 14, 2013',  location: 'Sydney, AU',          img: 'https://avatars1.githubusercontent.com/u/5457267?v=3&s=460',  bio: '',  flavour: 'caramel'},
			{ name: 'Steven Steneker',   joinedDate: 'Jun 30, 2008',  location: 'Sydney, AU',          img: 'https://avatars3.githubusercontent.com/u/15554?v=3&s=460',    bio: '',  flavour: 'strawberry'},
			{ name: 'Tom Walker',        joinedDate: 'Apr 19, 2011',  location: 'Sydney, AU',          img: 'https://avatars2.githubusercontent.com/u/737821?v=3&s=460',   bio: '',  flavour: 'banana'},
			{ name: 'Tuan Hoang',        joinedDate: 'Mar 19, 2013',  location: 'Sydney, AU',          img: 'https://avatars0.githubusercontent.com/u/3906505?v=3&s=460',  bio: '',  flavour: 'lemon' }
		];

		// Conditional UI
		var scanButton = this.scannerIsAvailable() ? (
			<UI.FlexBlock height="60px" className="scan-button-wrapper">
				<Tappable onTap={this.loadScanner} className={scanButtonClassName} component="button">

							Scan

							Code

				</Tappable>
			</UI.FlexBlock>
		) : null;

		return (
			<UI.FlexLayout className={viewClassName}>
				<UI.FlexBlock height={this.context.app.state.isNativeApp ? '150px' : '130px'} className="home-hero">
					<Icons.Logo className="home-hero-logo" />
					<UI.StripButtons className="home-buttons">
						<UI.StripButton showView="components"  viewTransition="show-from-right" label="Components"  icon="ion-ios7-keypad" />
						<UI.StripButton showView="transitions" viewTransition="show-from-right" label="Transitions" icon="ion-ios7-photos" />
					</UI.StripButtons>
				</UI.FlexBlock>
				<UI.FlexBlock scrollable>
					<SimpleList users={users} />
					<ComplexList users={users} />
				</UI.FlexBlock>
				{scanButton}
			</UI.FlexLayout>
		);
	}
});
<|endoftext|>


<commit_before>#! /usr/bin/env node
const p = require('path');
const fs = require('fs-extra');
const readdir = require('recursive-readdir');
const request = require('request-promise-native');
const urljoin = require('url-join');
const chalk = require('chalk');
const ora = require('ora');

const IDYLL_PUB_API = 'https://idyll-pub-api.now.sh';

const colors = {
  progress: chalk.hex('#6122fb'),
  success: chalk.green,
  failure: chalk.red
};

exports.command = 'publish'
exports.description = 'Publish your project to idyll.pub'
exports.builder = {}
exports.handler = async (yargs) => {
  const projectDir = process.cwd();
  const tokenPath = p.join(projectDir, '.idyll', 'token');
  const config = require(p.join(projectDir, 'package.json'))

  let spinner = ora({
    text: colors.progress('Deploying your project to idyll.pub...')
  });

  spinner.start();

  try {
    // TODO: configurable build path.
    let buildDir = p.join(projectDir, 'build');
    let token = await getProjectToken(tokenPath, config);
    let files = await readdir(buildDir);

    let formData = files.reduce((acc, f) => {
      acc[p.relative(projectDir, f)] = fs.createReadStream(f);
      return acc;
    }, {});
    formData.token = token;

    let { alias } = await request.post({
      url: urljoin(IDYLL_PUB_API, 'deploy'),
      formData: formData,
      json: true
    });

    spinner.succeed(colors.success(`Project deployed at https://${alias}.now.sh`));
  } catch (err) {
    spinner.fail(colors.failure(`Could not deploy your project: ${err}`));
  }
}

/**
 * Try to read the project token from the .idyll directory.
 * If it does not exist, create/save one into .idyll/token.
 */
async function getProjectToken (tokenPath, config) {
  var token;
  try {
    token = await fs.readFile(tokenPath, { encoding: 'utf-8' });
  } catch (err) {
    let deployment = await request.post({
      url: urljoin(IDYLL_PUB_API, 'create'),
      body: {
        name: config.name
      },
      json: true
    });
    token = deployment.token;
    await fs.writeFile(tokenPath, token, { encoding: 'utf-8' });
  }
  return token;
}
<commit_msg>now.sh -> idyll.pub<commit_after>#! /usr/bin/env node
const p = require('path');
const fs = require('fs-extra');
const readdir = require('recursive-readdir');
const request = require('request-promise-native');
const urljoin = require('url-join');
const chalk = require('chalk');
const ora = require('ora');

const IDYLL_PUB_API = 'https://api.idyll.pub';

const colors = {
  progress: chalk.hex('#6122fb'),
  success: chalk.green,
  failure: chalk.red
};

exports.command = 'publish'
exports.description = 'Publish your project to idyll.pub'
exports.builder = {}
exports.handler = async (yargs) => {
  const projectDir = process.cwd();
  const tokenPath = p.join(projectDir, '.idyll', 'token');
  const config = require(p.join(projectDir, 'package.json'))

  let spinner = ora({
    text: colors.progress('Deploying your project to idyll.pub...')
  });

  spinner.start();

  try {
    // TODO: configurable build path.
    let buildDir = p.join(projectDir, 'build');
    let token = await getProjectToken(tokenPath, config);
    let files = await readdir(buildDir);

    let formData = files.reduce((acc, f) => {
      acc[p.relative(buildDir, f)] = fs.createReadStream(f);
      return acc;
    }, {});
    formData.token = token;

    let { alias } = await request.post({
      url: urljoin(IDYLL_PUB_API, 'deploy'),
      formData: formData,
      json: true
    });

    spinner.succeed(colors.success(`Project deployed at https://idyll.pub/post/${alias}`));
  } catch (err) {
    spinner.fail(colors.failure(`Could not deploy your project: ${err}`));
  }
}

/**
 * Try to read the project token from the .idyll directory.
 * If it does not exist, create/save one into .idyll/token.
 */
async function getProjectToken (tokenPath, config) {
  var token;
  try {
    token = await fs.readFile(tokenPath, { encoding: 'utf-8' });
  } catch (err) {
    let deployment = await request.post({
      url: urljoin(IDYLL_PUB_API, 'create'),
      body: {
        name: config.name
      },
      json: true
    });
    token = deployment.token;
    await fs.writeFile(tokenPath, token, { encoding: 'utf-8' });
  }
  return token;
}
<|endoftext|>


<commit_before>/*
Language: C++
Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
Contributors: Evgeny Stepanischev <imbolk@gmail.com>, Zaven Muradyan <megalivoithos@gmail.com>, Roel Deckers <admin@codingcat.nl>
Category: common, system
*/

function(hljs) {
  var CPP_PRIMATIVE_TYPES = {
    className: 'keyword',
    begin: '\\b[a-z\\d_]*_t\\b'
  };

  var CPP_KEYWORDS = {
    keyword: 'false int float while private char catch export virtual operator sizeof ' +
      'dynamic_cast|10 typedef const_cast|10 const struct for static_cast|10 union namespace ' +
      'unsigned long volatile static protected bool template mutable if public friend ' +
      'do goto auto void enum else break extern using true class asm case typeid ' +
      'short reinterpret_cast|10 default double register explicit signed typename try this ' +
      'switch continue inline delete alignof constexpr decltype ' +
      'noexcept nullptr static_assert thread_local restrict _Bool complex _Complex _Imaginary ' +
      'atomic_bool atomic_char atomic_schar ' +
      'atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong ' +
      'atomic_ullong',
    built_in: 'std string cin cout cerr clog stringstream istringstream ostringstream ' +
      'auto_ptr deque list queue stack vector map set bitset multiset multimap unordered_set ' +
      'unordered_map unordered_multiset unordered_multimap array shared_ptr abort abs acos ' +
      'asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp ' +
      'fscanf isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper ' +
      'isxdigit tolower toupper labs ldexp log10 log malloc memchr memcmp memcpy memset modf pow ' +
      'printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp ' +
      'strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan ' +
      'vfprintf vprintf vsprintf'
  };
  return {
    aliases: ['c', 'cc', 'h', 'c++', 'h++', 'hpp'],
    keywords: CPP_KEYWORDS,
    illegal: '</',
    contains: [
      CPP_PRIMATIVE_TYPES,
      hljs.C_LINE_COMMENT_MODE,
      hljs.C_BLOCK_COMMENT_MODE,
      {
        className: 'string',
        variants: [
          hljs.inherit(hljs.QUOTE_STRING_MODE, { begin: '((u8?|U)|L)?"' }),
          {
            begin: '(u8?|U)?R"', end: '"',
            contains: [hljs.BACKSLASH_ESCAPE]
          },
          {
            begin: '\'\\\\?.', end: '\'',
            illegal: '.'
          }
        ]
      },
      {
        className: 'number',
        begin: '\\b(\\d+(\\.\\d*)?|\\.\\d+)(u|U|l|L|ul|UL|f|F)'
      },
      hljs.C_NUMBER_MODE,
      {
        className: 'preprocessor',
        begin: '#', end: '$',
        keywords: 'if else elif endif define undef warning error line pragma',
        contains: [
          {
            begin: /\\\n/, relevance: 0
          },
          {
            begin: 'include\\s*[<"]', end: '[>"]',
            keywords: 'include',
            illegal: '\\n'
          },
          hljs.C_LINE_COMMENT_MODE
        ]
      },
      {
        begin: '\\b(deque|list|queue|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*<', end: '>',
        keywords: CPP_KEYWORDS,
        contains: ['self', CPP_PRIMATIVE_TYPES]
      },
      {
        begin: hljs.IDENT_RE + '::',
        keywords: CPP_KEYWORDS
      },
      {
        // Expression keywords prevent 'keyword Name(...) or else if(...)' from
        // being recognized as a function definition
        beginKeywords: 'new throw return else',
        relevance: 0
      },
      {
        className: 'function',
        begin: '(' + hljs.IDENT_RE + '\\s+)+' + hljs.IDENT_RE + '\\s*\\(', returnBegin: true, end: /[{;=]/,
        excludeEnd: true,
        keywords: CPP_KEYWORDS,
        contains: [
          {
            begin: hljs.IDENT_RE + '\\s*\\(', returnBegin: true,
            contains: [hljs.TITLE_MODE],
            relevance: 0
          },
          {
            className: 'params',
            begin: /\(/, end: /\)/,
            keywords: CPP_KEYWORDS,
            relevance: 0,
            contains: [
              hljs.C_BLOCK_COMMENT_MODE
            ]
          },
          hljs.C_LINE_COMMENT_MODE,
          hljs.C_BLOCK_COMMENT_MODE
        ]
      }
    ]
  };
}
<commit_msg>More C built-ins: stdin, stdout, stderr, realloc.<commit_after>/*
Language: C++
Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
Contributors: Evgeny Stepanischev <imbolk@gmail.com>, Zaven Muradyan <megalivoithos@gmail.com>, Roel Deckers <admin@codingcat.nl>
Category: common, system
*/

function(hljs) {
  var CPP_PRIMATIVE_TYPES = {
    className: 'keyword',
    begin: '\\b[a-z\\d_]*_t\\b'
  };

  var CPP_KEYWORDS = {
    keyword: 'false int float while private char catch export virtual operator sizeof ' +
      'dynamic_cast|10 typedef const_cast|10 const struct for static_cast|10 union namespace ' +
      'unsigned long volatile static protected bool template mutable if public friend ' +
      'do goto auto void enum else break extern using true class asm case typeid ' +
      'short reinterpret_cast|10 default double register explicit signed typename try this ' +
      'switch continue inline delete alignof constexpr decltype ' +
      'noexcept nullptr static_assert thread_local restrict _Bool complex _Complex _Imaginary ' +
      'atomic_bool atomic_char atomic_schar ' +
      'atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong ' +
      'atomic_ullong',
    built_in: 'std string cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream ' +
      'auto_ptr deque list queue stack vector map set bitset multiset multimap unordered_set ' +
      'unordered_map unordered_multiset unordered_multimap array shared_ptr abort abs acos ' +
      'asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp ' +
      'fscanf isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper ' +
      'isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow ' +
      'printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp ' +
      'strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan ' +
      'vfprintf vprintf vsprintf'
  };
  return {
    aliases: ['c', 'cc', 'h', 'c++', 'h++', 'hpp'],
    keywords: CPP_KEYWORDS,
    illegal: '</',
    contains: [
      CPP_PRIMATIVE_TYPES,
      hljs.C_LINE_COMMENT_MODE,
      hljs.C_BLOCK_COMMENT_MODE,
      {
        className: 'string',
        variants: [
          hljs.inherit(hljs.QUOTE_STRING_MODE, { begin: '((u8?|U)|L)?"' }),
          {
            begin: '(u8?|U)?R"', end: '"',
            contains: [hljs.BACKSLASH_ESCAPE]
          },
          {
            begin: '\'\\\\?.', end: '\'',
            illegal: '.'
          }
        ]
      },
      {
        className: 'number',
        begin: '\\b(\\d+(\\.\\d*)?|\\.\\d+)(u|U|l|L|ul|UL|f|F)'
      },
      hljs.C_NUMBER_MODE,
      {
        className: 'preprocessor',
        begin: '#', end: '$',
        keywords: 'if else elif endif define undef warning error line pragma',
        contains: [
          {
            begin: /\\\n/, relevance: 0
          },
          {
            begin: 'include\\s*[<"]', end: '[>"]',
            keywords: 'include',
            illegal: '\\n'
          },
          hljs.C_LINE_COMMENT_MODE
        ]
      },
      {
        begin: '\\b(deque|list|queue|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*<', end: '>',
        keywords: CPP_KEYWORDS,
        contains: ['self', CPP_PRIMATIVE_TYPES]
      },
      {
        begin: hljs.IDENT_RE + '::',
        keywords: CPP_KEYWORDS
      },
      {
        // Expression keywords prevent 'keyword Name(...) or else if(...)' from
        // being recognized as a function definition
        beginKeywords: 'new throw return else',
        relevance: 0
      },
      {
        className: 'function',
        begin: '(' + hljs.IDENT_RE + '\\s+)+' + hljs.IDENT_RE + '\\s*\\(', returnBegin: true, end: /[{;=]/,
        excludeEnd: true,
        keywords: CPP_KEYWORDS,
        contains: [
          {
            begin: hljs.IDENT_RE + '\\s*\\(', returnBegin: true,
            contains: [hljs.TITLE_MODE],
            relevance: 0
          },
          {
            className: 'params',
            begin: /\(/, end: /\)/,
            keywords: CPP_KEYWORDS,
            relevance: 0,
            contains: [
              hljs.C_BLOCK_COMMENT_MODE
            ]
          },
          hljs.C_LINE_COMMENT_MODE,
          hljs.C_BLOCK_COMMENT_MODE
        ]
      }
    ]
  };
}
<|endoftext|>


<commit_before>import React, {
  useMemo,
  useCallback,
  useState,
  useRef,
  useEffect,
} from "react";
import PropTypes from "prop-types";
import {
  parsePhoneNumberFromString,
  parseDigits,
  formatIncompletePhoneNumber,
  getCountryCallingCode,
} from "libphonenumber-js";
import { FixedSizeList as List } from "react-window";
import AutoSizer from "react-virtualized-auto-sizer";
import TextInput from "@crave/farmblocks-input-text";
import { fontSizes, colors } from "@crave/farmblocks-theme";
import Popover from "@crave/farmblocks-popover";
import { FormWrapperHeader } from "@crave/farmblocks-form-wrapper";

import CountrySelectorTrigger from "./CountrySelectorTrigger";
import { countries, flags } from "./countries.json";
import CountryRow from "./CountryRow";
import { useCountrySearch, useHighlight } from "./PhoneInput.hooks";

const fullScreenBreakpoint = "500px";

/**
 * This component uses the [libphonenumber-js](https://github.com/catamphetamine/libphonenumber-js) library to convert phone numbers typed in their national standard to the [RFC3966](https://www.ietf.org/rfc/rfc3966.txt) notation.
 */
const PhoneInput = ({
  value,
  defaultCountry,
  onChange,
  textSelectCountryTitle,
  textSelectCountryCancel,
  textSelectCountrySearch,
  priorityCountries,
  disabled,
  ...props
}) => {
  const dismissRef = useRef();
  const listRef = useRef();
  const searchInputRef = useRef();
  const numberInputRef = useRef();

  const [selectedCountry, setSelectedCountry] = useState(defaultCountry);
  const [popoverOpen, setPopoverOpen] = useState(false);
  const [countryQuery, setCountryQuery] = useState("");

  const phone = useMemo(() => parsePhoneNumberFromString(value), [value]);

  const country = useMemo(
    () => phone?.country || selectedCountry || defaultCountry,
    [phone, selectedCountry, defaultCountry],
  );
  const filteredCountries = useCountrySearch(
    countries,
    countryQuery,
    priorityCountries,
  );

  useEffect(() => {
    if (!value) {
      setSelectedCountry(null);
    }
  }, [value]);

  const triggerChange = useCallback(
    (number, code = country) => {
      onChange?.(
        parsePhoneNumberFromString(number, code)?.getURI() ||
          `tel:+${getCountryCallingCode(code)}${number}`,
      );
    },
    [country, onChange],
  );

  const handleNumberChange = useCallback(
    ({ target }) => {
      const newValue = parseDigits(target?.value);
      triggerChange(newValue);
    },
    [country],
  );

  const handleCountrySelection = useCallback(code => {
    setSelectedCountry(code);
    setCountryQuery("");
    triggerChange("", code);
    dismissRef.current?.();
  }, []);

  const { handleKeyDown, highlightIndex, resetIndex } = useHighlight({
    items: filteredCountries,
    listRef,
    selectFn: handleCountrySelection,
    cancelFn: dismissRef.current,
  });

  const handleSearchChange = useCallback(event => {
    setCountryQuery(event.target.value);
    resetIndex();
    listRef.current?.scrollTo(0);
  }, []);

  const handlePopoverOpen = useCallback(() => {
    setPopoverOpen(true);
    resetIndex();
    setImmediate(() => {
      searchInputRef.current?.focus?.();
    });
  }, []);
  const handlePopoverClose = useCallback(() => {
    setPopoverOpen(false);
    setImmediate(() => {
      numberInputRef.current?.focus?.();
    });
  }, []);

  const listData = useMemo(
    () => ({
      items: filteredCountries,
      handler: handleCountrySelection,
      highlightIndex,
    }),
    [filteredCountries, highlightIndex],
  );

  return (
    <TextInput
      innerRef={numberInputRef}
      prefix={
        <Popover
          onOpen={handlePopoverOpen}
          onClose={handlePopoverClose}
          tooltipProps={{
            padding: "0",
            fullScreenBreakpoint,
          }}
          disabled={disabled}
          trigger={
            <CountrySelectorTrigger
              disabled={disabled}
              callingCode={getCountryCallingCode(country)}
              flag={flags[country]}
              code={country}
            />
          }
          content={dismiss => {
            dismissRef.current = dismiss;
            return (
              // eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
              <div
                onClick={event => {
                  // We stop propagation to avoid giving focus to the main input
                  // This happens because the popover is inside the input wrapper
                  event.stopPropagation();
                }}
                css="
                display: flex;
                flex-direction: column;
                height: 100%;
                min-height: 340px;
                min-width: 300px;
              "
              >
                <FormWrapperHeader
                  title={textSelectCountryTitle}
                  cancelLabel={textSelectCountryCancel}
                  onCancel={dismiss}
                />
                <TextInput
                  placeholder={textSelectCountrySearch}
                  type="search"
                  fontSize={fontSizes.SMALL}
                  margin="8px"
                  value={countryQuery}
                  onChange={handleSearchChange}
                  onKeyDown={handleKeyDown}
                  innerRef={searchInputRef}
                  data-testid="country-search-input"
                />
                <ul
                  css={`
                    padding: 0;
                    margin: 0;
                    border-top: solid 1px ${colors.GREY_16};
                    flex: 1;
                    width: 100%;
                  `}
                >
                  <AutoSizer>
                    {({ height, width }) => (
                      <List
                        height={height}
                        itemCount={listData.items.length}
                        itemData={listData}
                        itemKey={index => filteredCountries[index].code}
                        itemSize={54}
                        width={width}
                        ref={listRef}
                      >
                        {CountryRow}
                      </List>
                    )}
                  </AutoSizer>
                </ul>
              </div>
            );
          }}
        />
      }
      active={popoverOpen}
      value={formatIncompletePhoneNumber(phone?.format("NATIONAL"), country)}
      onChange={handleNumberChange}
      inputMode="tel"
      css={`
        .input {
          overflow: unset;
          @media only screen and (max-width: ${fullScreenBreakpoint}) {
            input {
              /* This prevents iOS from zooming in the input on focus */
              font-size: 16px;
            }
          }
        }
        .prefix {
          padding: 0;
          align-items: stretch;

          .popover__trigger {
            height: 100%;
          }
        }
      `}
      disabled={disabled}
      {...props}
      data-testid="national-number-input"
    />
  );
};

PhoneInput.defaultProps = {
  value: "",
  defaultCountry: "US",
  textSelectCountryTitle: "Select Country",
  textSelectCountryCancel: "Cancel",
  textSelectCountrySearch: "Search",
  disabled: false,
};

PhoneInput.propTypes = {
  /**
   * The phone number to show in the input. Should follow the RFC3966 notation.
   * E.g. "tel:+12133734253"
   */
  value: PropTypes.string,

  /**
   * Code for the Country selected by default, when `value` is empty
   */
  defaultCountry: PropTypes.string,

  /**
   * Countries to show at the top of the list, like the ones with your
   * biggest user base, so most users can easily select their country
   * without the need to search in the full list.
   * Use a string of country codes separated by colons. E.g. `"US,CA,BR"`.
   */
  priorityCountries: PropTypes.string,

  /**
   * Function called with the new value after a user interaction.
   * Will return the phone number formated in the RFC3966 notation.
   */
  onChange: PropTypes.func,

  /**
   * Text for the title of the country selection popover
   */
  textSelectCountryTitle: PropTypes.string,

  /**
   * Text for the cancel button of the country selection popover
   */
  textSelectCountryCancel: PropTypes.string,

  /**
   * Text for the search field of the country selection popover
   */
  textSelectCountrySearch: PropTypes.string,

  /**
   * Displays the input greyed out and prevents edition
   */
  disabled: PropTypes.bool,
};

export default PhoneInput;
<commit_msg>fix(input-phone): border radius of prefix<commit_after>import React, {
  useMemo,
  useCallback,
  useState,
  useRef,
  useEffect,
} from "react";
import PropTypes from "prop-types";
import {
  parsePhoneNumberFromString,
  parseDigits,
  formatIncompletePhoneNumber,
  getCountryCallingCode,
} from "libphonenumber-js";
import { FixedSizeList as List } from "react-window";
import AutoSizer from "react-virtualized-auto-sizer";
import TextInput from "@crave/farmblocks-input-text";
import { fontSizes, colors } from "@crave/farmblocks-theme";
import Popover from "@crave/farmblocks-popover";
import { FormWrapperHeader } from "@crave/farmblocks-form-wrapper";

import CountrySelectorTrigger from "./CountrySelectorTrigger";
import { countries, flags } from "./countries.json";
import CountryRow from "./CountryRow";
import { useCountrySearch, useHighlight } from "./PhoneInput.hooks";

const fullScreenBreakpoint = "500px";

/**
 * This component uses the [libphonenumber-js](https://github.com/catamphetamine/libphonenumber-js) library to convert phone numbers typed in their national standard to the [RFC3966](https://www.ietf.org/rfc/rfc3966.txt) notation.
 */
const PhoneInput = ({
  value,
  defaultCountry,
  onChange,
  textSelectCountryTitle,
  textSelectCountryCancel,
  textSelectCountrySearch,
  priorityCountries,
  disabled,
  ...props
}) => {
  const dismissRef = useRef();
  const listRef = useRef();
  const searchInputRef = useRef();
  const numberInputRef = useRef();

  const [selectedCountry, setSelectedCountry] = useState(defaultCountry);
  const [popoverOpen, setPopoverOpen] = useState(false);
  const [countryQuery, setCountryQuery] = useState("");

  const phone = useMemo(() => parsePhoneNumberFromString(value), [value]);

  const country = useMemo(
    () => phone?.country || selectedCountry || defaultCountry,
    [phone, selectedCountry, defaultCountry],
  );
  const filteredCountries = useCountrySearch(
    countries,
    countryQuery,
    priorityCountries,
  );

  useEffect(() => {
    if (!value) {
      setSelectedCountry(null);
    }
  }, [value]);

  const triggerChange = useCallback(
    (number, code = country) => {
      onChange?.(
        parsePhoneNumberFromString(number, code)?.getURI() ||
          `tel:+${getCountryCallingCode(code)}${number}`,
      );
    },
    [country, onChange],
  );

  const handleNumberChange = useCallback(
    ({ target }) => {
      const newValue = parseDigits(target?.value);
      triggerChange(newValue);
    },
    [country],
  );

  const handleCountrySelection = useCallback(code => {
    setSelectedCountry(code);
    setCountryQuery("");
    triggerChange("", code);
    dismissRef.current?.();
  }, []);

  const { handleKeyDown, highlightIndex, resetIndex } = useHighlight({
    items: filteredCountries,
    listRef,
    selectFn: handleCountrySelection,
    cancelFn: dismissRef.current,
  });

  const handleSearchChange = useCallback(event => {
    setCountryQuery(event.target.value);
    resetIndex();
    listRef.current?.scrollTo(0);
  }, []);

  const handlePopoverOpen = useCallback(() => {
    setPopoverOpen(true);
    resetIndex();
    setImmediate(() => {
      searchInputRef.current?.focus?.();
    });
  }, []);
  const handlePopoverClose = useCallback(() => {
    setPopoverOpen(false);
    setImmediate(() => {
      numberInputRef.current?.focus?.();
    });
  }, []);

  const listData = useMemo(
    () => ({
      items: filteredCountries,
      handler: handleCountrySelection,
      highlightIndex,
    }),
    [filteredCountries, highlightIndex],
  );

  return (
    <TextInput
      innerRef={numberInputRef}
      prefix={
        <Popover
          onOpen={handlePopoverOpen}
          onClose={handlePopoverClose}
          tooltipProps={{
            padding: "0",
            fullScreenBreakpoint,
          }}
          disabled={disabled}
          trigger={
            <CountrySelectorTrigger
              disabled={disabled}
              callingCode={getCountryCallingCode(country)}
              flag={flags[country]}
              code={country}
            />
          }
          content={dismiss => {
            dismissRef.current = dismiss;
            return (
              // eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
              <div
                onClick={event => {
                  // We stop propagation to avoid giving focus to the main input
                  // This happens because the popover is inside the input wrapper
                  event.stopPropagation();
                }}
                css="
                display: flex;
                flex-direction: column;
                height: 100%;
                min-height: 340px;
                min-width: 300px;
              "
              >
                <FormWrapperHeader
                  title={textSelectCountryTitle}
                  cancelLabel={textSelectCountryCancel}
                  onCancel={dismiss}
                />
                <TextInput
                  placeholder={textSelectCountrySearch}
                  type="search"
                  fontSize={fontSizes.SMALL}
                  margin="8px"
                  value={countryQuery}
                  onChange={handleSearchChange}
                  onKeyDown={handleKeyDown}
                  innerRef={searchInputRef}
                  data-testid="country-search-input"
                />
                <ul
                  css={`
                    padding: 0;
                    margin: 0;
                    border-top: solid 1px ${colors.GREY_16};
                    flex: 1;
                    width: 100%;
                  `}
                >
                  <AutoSizer>
                    {({ height, width }) => (
                      <List
                        height={height}
                        itemCount={listData.items.length}
                        itemData={listData}
                        itemKey={index => filteredCountries[index].code}
                        itemSize={54}
                        width={width}
                        ref={listRef}
                      >
                        {CountryRow}
                      </List>
                    )}
                  </AutoSizer>
                </ul>
              </div>
            );
          }}
        />
      }
      active={popoverOpen}
      value={formatIncompletePhoneNumber(phone?.format("NATIONAL"), country)}
      onChange={handleNumberChange}
      inputMode="tel"
      css={`
        .input {
          overflow: unset;
          @media only screen and (max-width: ${fullScreenBreakpoint}) {
            input {
              /* This prevents iOS from zooming in the input on focus */
              font-size: 16px;
            }
          }
        }
        .prefix {
          padding: 0;
          align-items: stretch;
          border-radius: 3px 0 0 3px;

          .popover__trigger {
            height: 100%;
          }
        }
      `}
      disabled={disabled}
      {...props}
      data-testid="national-number-input"
    />
  );
};

PhoneInput.defaultProps = {
  value: "",
  defaultCountry: "US",
  textSelectCountryTitle: "Select Country",
  textSelectCountryCancel: "Cancel",
  textSelectCountrySearch: "Search",
  disabled: false,
};

PhoneInput.propTypes = {
  /**
   * The phone number to show in the input. Should follow the RFC3966 notation.
   * E.g. "tel:+12133734253"
   */
  value: PropTypes.string,

  /**
   * Code for the Country selected by default, when `value` is empty
   */
  defaultCountry: PropTypes.string,

  /**
   * Countries to show at the top of the list, like the ones with your
   * biggest user base, so most users can easily select their country
   * without the need to search in the full list.
   * Use a string of country codes separated by colons. E.g. `"US,CA,BR"`.
   */
  priorityCountries: PropTypes.string,

  /**
   * Function called with the new value after a user interaction.
   * Will return the phone number formated in the RFC3966 notation.
   */
  onChange: PropTypes.func,

  /**
   * Text for the title of the country selection popover
   */
  textSelectCountryTitle: PropTypes.string,

  /**
   * Text for the cancel button of the country selection popover
   */
  textSelectCountryCancel: PropTypes.string,

  /**
   * Text for the search field of the country selection popover
   */
  textSelectCountrySearch: PropTypes.string,

  /**
   * Displays the input greyed out and prevents edition
   */
  disabled: PropTypes.bool,
};

export default PhoneInput;
<|endoftext|>


<commit_before>/*
Language: SQL
*/

hljs.LANGUAGES.sql =
{
  case_insensitive: true,
  defaultMode:
  {
    lexems: [hljs.IDENT_RE],
    contains: ['string', 'number', 'comment'],
    keywords: {
      'keyword': {'all': 1, 'partial': 1, 'global': 1, 'month': 1, 'current_timestamp': 1, 'using': 1, 'go': 1, 'revoke': 1, 'smallint': 1, 'indicator': 1, 'end-exec': 1, 'disconnect': 1, 'zone': 1, 'with': 1, 'character': 1, 'assertion': 1, 'to': 1, 'add': 1, 'current_user': 1, 'usage': 1, 'input': 1, 'local': 1, 'alter': 1, 'match': 1, 'collate': 1, 'real': 1, 'then': 1, 'rollback': 1, 'get': 1, 'read': 1, 'timestamp': 1, 'session_user': 1, 'not': 1, 'integer': 1, 'bit': 1, 'unique': 1, 'day': 1, 'minute': 1, 'desc': 1, 'insert': 1, 'execute': 1, 'like': 1, 'ilike': 2, 'level': 1, 'decimal': 1, 'drop': 1, 'continue': 1, 'isolation': 1, 'found': 1, 'where': 1, 'constraints': 1, 'domain': 1, 'right': 1, 'national': 1, 'some': 1, 'module': 1, 'transaction': 1, 'relative': 1, 'second': 1, 'connect': 1, 'escape': 1, 'close': 1, 'system_user': 1, 'for': 1, 'deferred': 1, 'section': 1, 'cast': 1, 'current': 1, 'sqlstate': 1, 'allocate': 1, 'intersect': 1, 'deallocate': 1, 'numeric': 1, 'public': 1, 'preserve': 1, 'full': 1, 'goto': 1, 'initially': 1, 'asc': 1, 'no': 1, 'key': 1, 'output': 1, 'collation': 1, 'group': 1, 'by': 1, 'union': 1, 'session': 1, 'both': 1, 'last': 1, 'language': 1, 'constraint': 1, 'column': 1, 'of': 1, 'space': 1, 'foreign': 1, 'deferrable': 1, 'prior': 1, 'connection': 1, 'unknown': 1, 'action': 1, 'commit': 1, 'view': 1, 'or': 1, 'first': 1, 'into': 1, 'float': 1, 'year': 1, 'primary': 1, 'cascaded': 1, 'except': 1, 'restrict': 1, 'set': 1, 'references': 1, 'names': 1, 'table': 1, 'outer': 1, 'open': 1, 'select': 1, 'size': 1, 'are': 1, 'rows': 1, 'from': 1, 'prepare': 1, 'distinct': 1, 'leading': 1, 'create': 1, 'only': 1, 'next': 1, 'inner': 1, 'authorization': 1, 'schema': 1, 'corresponding': 1, 'option': 1, 'declare': 1, 'precision': 1, 'immediate': 1, 'else': 1, 'timezone_minute': 1, 'external': 1, 'varying': 1, 'translation': 1, 'true': 1, 'case': 1, 'exception': 1, 'join': 1, 'hour': 1, 'default': 1, 'double': 1, 'scroll': 1, 'value': 1, 'cursor': 1, 'descriptor': 1, 'values': 1, 'dec': 1, 'fetch': 1, 'procedure': 1, 'delete': 1, 'and': 1, 'false': 1, 'int': 1, 'is': 1, 'describe': 1, 'char': 1, 'as': 1, 'at': 1, 'in': 1, 'varchar': 1, 'null': 1, 'trailing': 1, 'any': 1, 'absolute': 1, 'current_time': 1, 'end': 1, 'grant': 1, 'privileges': 1, 'when': 1, 'cross': 1, 'check': 1, 'write': 1, 'current_date': 1, 'pad': 1, 'begin': 1, 'temporary': 1, 'exec': 1, 'time': 1, 'update': 1, 'catalog': 1, 'user': 1, 'sql': 1, 'date': 1, 'on': 1, 'identity': 1, 'timezone_hour': 1, 'natural': 1, 'whenever': 1, 'interval': 1, 'work': 1, 'order': 1, 'cascade': 1, 'diagnostics': 1, 'nchar': 1, 'having': 1, 'left': 1},
      'aggregate': {'count': 1, 'sum': 1, 'min': 1, 'max': 1, 'avg': 1}
    }
  },

  modes: [
    hljs.C_NUMBER_MODE,
    hljs.C_BLOCK_COMMENT_MODE,
    {
      className: 'comment',
      begin: '--', end: '$'
    },
    {
      className: 'string',
      begin: '\'', end: '\'',
      contains: ['escape', 'squote'],
      relevance: 0
    },
    {
      className: 'squote',
      begin: '\'\'', end: '^', noMarkup: true
    },
    {
      className: 'string',
      begin: '"', end: '"',
      contains: [ 'escape', 'dquote'],
      relevance: 0
    },
    {
      className: 'dquote',
      begin: '""', end: '^', noMarkup: true
    },
    {
      className: 'string',
      begin: '`', end: '`',
      contains: ['escape']
    },
    hljs.BACKSLASH_ESCAPE
  ]
};
<commit_msg>Parsing SQL in proper statements to defeat its greediness due to large keyword set.<commit_after>/*
Language: SQL
*/

hljs.LANGUAGES.sql =
{
  case_insensitive: true,
  defaultMode:
  {
    contains: ['operator', 'comment']
  },

  modes: [
    {
      className: 'operator',
      begin: '(begin|start|commit|rollback|savepoint|lock|alter|create|drop|rename|call|delete|do|handler|insert|load|replace|select|truncate|update|set|show)\\b', end: ';|$',
      contains: ['string', 'number', 'newline'],
      lexems: ['[a-zA-Z][a-zA-Z0-9_\\.]*'],
      keywords: {
        'keyword': {
          'all': 1, 'partial': 1, 'global': 1, 'month': 1,
          'current_timestamp': 1, 'using': 1, 'go': 1, 'revoke': 1,
          'smallint': 1, 'indicator': 1, 'end-exec': 1, 'disconnect': 1,
          'zone': 1, 'with': 1, 'character': 1, 'assertion': 1, 'to': 1,
          'add': 1, 'current_user': 1, 'usage': 1, 'input': 1, 'local': 1,
          'alter': 1, 'match': 1, 'collate': 1, 'real': 1, 'then': 1,
          'rollback': 1, 'get': 1, 'read': 1, 'timestamp': 1,
          'session_user': 1, 'not': 1, 'integer': 1, 'bit': 1, 'unique': 1,
          'day': 1, 'minute': 1, 'desc': 1, 'insert': 1, 'execute': 1,
          'like': 1, 'ilike': 2, 'level': 1, 'decimal': 1, 'drop': 1,
          'continue': 1, 'isolation': 1, 'found': 1, 'where': 1,
          'constraints': 1, 'domain': 1, 'right': 1, 'national': 1, 'some': 1,
          'module': 1, 'transaction': 1, 'relative': 1, 'second': 1,
          'connect': 1, 'escape': 1, 'close': 1, 'system_user': 1, 'for': 1,
          'deferred': 1, 'section': 1, 'cast': 1, 'current': 1, 'sqlstate': 1,
          'allocate': 1, 'intersect': 1, 'deallocate': 1, 'numeric': 1,
          'public': 1, 'preserve': 1, 'full': 1, 'goto': 1, 'initially': 1,
          'asc': 1, 'no': 1, 'key': 1, 'output': 1, 'collation': 1, 'group': 1,
          'by': 1, 'union': 1, 'session': 1, 'both': 1, 'last': 1,
          'language': 1, 'constraint': 1, 'column': 1, 'of': 1, 'space': 1,
          'foreign': 1, 'deferrable': 1, 'prior': 1, 'connection': 1,
          'unknown': 1, 'action': 1, 'commit': 1, 'view': 1, 'or': 1,
          'first': 1, 'into': 1, 'float': 1, 'year': 1, 'primary': 1,
          'cascaded': 1, 'except': 1, 'restrict': 1, 'set': 1, 'references': 1,
          'names': 1, 'table': 1, 'outer': 1, 'open': 1, 'select': 1,
          'size': 1, 'are': 1, 'rows': 1, 'from': 1, 'prepare': 1,
          'distinct': 1, 'leading': 1, 'create': 1, 'only': 1, 'next': 1,
          'inner': 1, 'authorization': 1, 'schema': 1, 'corresponding': 1,
          'option': 1, 'declare': 1, 'precision': 1, 'immediate': 1, 'else': 1,
          'timezone_minute': 1, 'external': 1, 'varying': 1, 'translation': 1,
          'true': 1, 'case': 1, 'exception': 1, 'join': 1, 'hour': 1,
          'default': 1, 'double': 1, 'scroll': 1, 'value': 1, 'cursor': 1,
          'descriptor': 1, 'values': 1, 'dec': 1, 'fetch': 1, 'procedure': 1,
          'delete': 1, 'and': 1, 'false': 1, 'int': 1, 'is': 1, 'describe': 1,
          'char': 1, 'as': 1, 'at': 1, 'in': 1, 'varchar': 1, 'null': 1,
          'trailing': 1, 'any': 1, 'absolute': 1, 'current_time': 1, 'end': 1,
          'grant': 1, 'privileges': 1, 'when': 1, 'cross': 1, 'check': 1,
          'write': 1, 'current_date': 1, 'pad': 1, 'begin': 1, 'temporary': 1,
          'exec': 1, 'time': 1, 'update': 1, 'catalog': 1, 'user': 1, 'sql': 1,
          'date': 1, 'on': 1, 'identity': 1, 'timezone_hour': 1, 'natural': 1,
          'whenever': 1, 'interval': 1, 'work': 1, 'order': 1, 'cascade': 1,
          'diagnostics': 1, 'nchar': 1, 'having': 1, 'left': 1, 'call': 1,
          'do': 1, 'handler': 1, 'load': 1, 'replace': 1, 'truncate': 1,
          'start': 1, 'lock': 1, 'show': 1},
        'aggregate': {'count': 1, 'sum': 1, 'min': 1, 'max': 1, 'avg': 1}
      }
    },
    {
      className: 'newline',
      begin: '\\n', end: '^', noMarkup: true
    },
    hljs.C_NUMBER_MODE,
    hljs.C_BLOCK_COMMENT_MODE,
    {
      className: 'comment',
      begin: '--', end: '$'
    },
    {
      className: 'string',
      begin: '\'', end: '\'',
      contains: ['escape', 'squote'],
      relevance: 0
    },
    {
      className: 'squote',
      begin: '\'\'', end: '^', noMarkup: true
    },
    {
      className: 'string',
      begin: '"', end: '"',
      contains: [ 'escape', 'dquote'],
      relevance: 0
    },
    {
      className: 'dquote',
      begin: '""', end: '^', noMarkup: true
    },
    {
      className: 'string',
      begin: '`', end: '`',
      contains: ['escape']
    },
    hljs.BACKSLASH_ESCAPE
  ]
};
<|endoftext|>


<commit_before>/*jshint esversion: 6,node: true,-W041: false */
"use strict";
const converter = require('../util/converter');

class WundergroundAPI_new {
    constructor(apiKey, location, l, d) {
        this.attribution = 'Powered by Weather Underground';
        this.reportCharacteristics = [
            'ObservationStation',
            'ObservationTime',
            'WindDirection',
            'Humidity',
            'SolarRadiation',
            'UVIndex',
            'Temperature',
            'DewPoint',
            'AirPressure',
            'WindSpeed',
            'WindSpeedMax'
        ];

        /* no example data for forecasts */
        /*
        this.forecastCharacteristics = [
            'Condition',
            'ConditionCategory',
            'ForecastDay',
            'Humidity',
            'RainChance',
            'RainDay',
            'Temperature',
            'TemperatureMin',
            'WindDirection',
            'WindSpeed',
            'WindSpeedMax'
        ];
        this.forecastDays = 4;
        */

        this.location = location;
        this.apiKey = apiKey;

        this.log = l;
        this.debug = d;

    }

    update(callback) {
        this.debug("Updating weather with weather underground");

        const queryUri = "https://api.weather.com/v2/pws/observations/current?apiKey="+this.apiKey+"&stationId="+this.location+"&format=json&units=s";
        request(encodeURI(queryUri), function (err, response, body) {
            if (!err) {
                // Current weather report
                const jsonObj = JSON.parse(body);
                this.parseReport(jsonObj.query.results.channel, callback);
            } else {
                this.log.error("Error retrieving weather report and forecast");
                this.log.error("Error Message: " + err);
                callback(err);
            }
        }.bind(this));
    }

    parseReport(values) {
        let report = {};

        /* EXAMPLE values

		observations
			0
				stationID	"KCASANJO898"
				obsTimeUtc	"2019-09-01T19:03:41Z"
				obsTimeLocal	"2019-09-01 12:03:41"
				neighborhood	"West San Jose - Casa de la Niles"
				softwareType	"WS-1002 V2.4.6"
				country	"US"
				solarRadiation	719.2
				lon	-122.01569366
				realtimeFrequency	null
				epoch	1567364621
				lat	37.30566025
				uv	9
				winddir	326
				humidity	49
				qcStatus	1
				metric_si	# imperial | metric | metric_si | uk_hybrid	(I always fetch metric_si)
					temp	30
					heatIndex	31
					dewpt	18
					windChill	30
					windSpeed	3
					windGust	3
					pressure	1010.16
					precipRate	0
					precipTotal	0
					elev	105
		*/

        try {
        	var observation = values.observations[0]
            var metric_si = observation.metric;

            report.ObservationStation = observation.stationID + " : " + observation.neighborhood;
            report.ObservationTime = observation.obsTimeUtc.split(' ')[4];

        	report.WindDirection = converter.getWindDirection(isNaN(parseInt(observation.wind_dir)) ? 0 : parseInt(values.wind_dir));
            report.Humidity = isNaN(parseInt(observation.humidity)) ? 0 : parseInt(values.humidity);
            report.SolarRadiation = isNaN(parseInt(observation.solarRadiation)) ? 0 : parseInt(observation.solarRadiation);
            report.UVIndex = isNaN(parseInt(observation.uv)) ? 0 : parseInt(observation.uv);

            report.Temperature = values.metric.temp;
            report.DewPoint = parseInt(metric.dewpt);
            report.AirPressure = parseInt(metric.pressure);
            report.WindSpeed = parseFloat(metric.windSpeed);
            report.WindSpeedMax = parseFloat(metric.windGusts);
        }
        catch(error) {
            this.log.error("Error retrieving weather report for Weather Underground");
            this.log.error("Error Message: " + error);
        }

        return report;
    }

    parseForecasts(forecastObjs, timezone) {
        let forecasts = [];
        var observation = values.observations[0]

    /* I DON'T HAVE AN EXAMPLE WITH FORECASTS*/
    /*
        for (let i = 0; i < forecastObjs.length; i++) {
            const values = forecastObjs[i];
            const forecast = {};
            forecast.Condition = values.text;
            forecast.ConditionCategory = converter.getConditionCategoryOwm(parseInt(values.code));
            forecast.ForecastDay = moment(values.date, "DD MMM YYYY").tz(timezone).format("dddd");
            forecast.Temperature = values.high;
            forecast.TemperatureMin = values.low;
            forecasts[forecasts.length] = forecast;
        }
    */
        return forecasts;
    }
}

module.exports = {
    WundergroundAPI_new: WundergroundAPI_new
};
<commit_msg>Update weatherunderground_new.js<commit_after>/*jshint esversion: 6,node: true,-W041: false */
"use strict";
const request = require('request'),
	converter = require('../util/converter');

class WundergroundAPI_new {
    constructor(apiKey, location, l, d) {
        this.attribution = 'Powered by Weather Underground';
        this.reportCharacteristics = [
            'ObservationStation',
            'ObservationTime',
            'WindDirection',
            'Humidity',
            'SolarRadiation',
            'UVIndex',
            'Temperature',
            'DewPoint',
            'AirPressure',
            'WindSpeed',
            'WindSpeedMax'
        ];

        /* no example data for forecasts */
        /*
        this.forecastCharacteristics = [
            'Condition',
            'ConditionCategory',
            'ForecastDay',
            'Humidity',
            'RainChance',
            'RainDay',
            'Temperature',
            'TemperatureMin',
            'WindDirection',
            'WindSpeed',
            'WindSpeedMax'
        ];
        this.forecastDays = 4;
        */

        this.location = location;
        this.apiKey = apiKey;

        this.log = l;
        this.debug = d;

    }

    update(callback) {
        this.debug("Updating weather with weather underground");

        const queryUri = "https://api.weather.com/v2/pws/observations/current?apiKey="+this.apiKey+"&stationId="+this.location+"&format=json&units=s";
        request(encodeURI(queryUri), function (err, response, body) {
            if (!err) {
                // Current weather report
                const jsonObj = JSON.parse(body);
                this.parseReport(jsonObj.query.results.channel, callback);
            } else {
                this.log.error("Error retrieving weather report and forecast");
                this.log.error("Error Message: " + err);
                callback(err);
            }
        }.bind(this));
    }

    parseReport(values) {
        let report = {};

        /* EXAMPLE values

		observations
			0
				stationID	"KCASANJO898"
				obsTimeUtc	"2019-09-01T19:03:41Z"
				obsTimeLocal	"2019-09-01 12:03:41"
				neighborhood	"West San Jose - Casa de la Niles"
				softwareType	"WS-1002 V2.4.6"
				country	"US"
				solarRadiation	719.2
				lon	-122.01569366
				realtimeFrequency	null
				epoch	1567364621
				lat	37.30566025
				uv	9
				winddir	326
				humidity	49
				qcStatus	1
				metric_si	# imperial | metric | metric_si | uk_hybrid	(I always fetch metric_si)
					temp	30
					heatIndex	31
					dewpt	18
					windChill	30
					windSpeed	3
					windGust	3
					pressure	1010.16
					precipRate	0
					precipTotal	0
					elev	105
		*/

        try {
        	var observation = values.observations[0]
            var metric_si = observation.metric;

            report.ObservationStation = observation.stationID + " : " + observation.neighborhood;
            report.ObservationTime = observation.obsTimeUtc.split(' ')[4];

        	report.WindDirection = converter.getWindDirection(isNaN(parseInt(observation.wind_dir)) ? 0 : parseInt(values.wind_dir));
            report.Humidity = isNaN(parseInt(observation.humidity)) ? 0 : parseInt(values.humidity);
            report.SolarRadiation = isNaN(parseInt(observation.solarRadiation)) ? 0 : parseInt(observation.solarRadiation);
            report.UVIndex = isNaN(parseInt(observation.uv)) ? 0 : parseInt(observation.uv);

            report.Temperature = values.metric.temp;
            report.DewPoint = parseInt(metric.dewpt);
            report.AirPressure = parseInt(metric.pressure);
            report.WindSpeed = parseFloat(metric.windSpeed);
            report.WindSpeedMax = parseFloat(metric.windGusts);
        }
        catch(error) {
            this.log.error("Error retrieving weather report for Weather Underground");
            this.log.error("Error Message: " + error);
        }

        return report;
    }

    parseForecasts(forecastObjs, timezone) {
        let forecasts = [];
        var observation = values.observations[0]

    /* I DON'T HAVE AN EXAMPLE WITH FORECASTS*/
    /*
        for (let i = 0; i < forecastObjs.length; i++) {
            const values = forecastObjs[i];
            const forecast = {};
            forecast.Condition = values.text;
            forecast.ConditionCategory = converter.getConditionCategoryOwm(parseInt(values.code));
            forecast.ForecastDay = moment(values.date, "DD MMM YYYY").tz(timezone).format("dddd");
            forecast.Temperature = values.high;
            forecast.TemperatureMin = values.low;
            forecasts[forecasts.length] = forecast;
        }
    */
        return forecasts;
    }
}

module.exports = {
    WundergroundAPI_new: WundergroundAPI_new
};
<|endoftext|>


<commit_before>import React from "react"
import Link from "gatsby-link"
import { Container } from "react-responsive-grid"
import Back from 'react-icons/lib/fa/arrow-left'
import { slide as Menu } from 'react-burger-menu'
import { rhythm, scale } from "../utils/typography"

class Template extends React.Component {
  checkMobile () {
    var check = false;
    (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);
    return check
  }

  showSettings (event) {
    event.preventDefault();
  }

  render () {
    const { location, children } = this.props
    const height = this.checkMobile() ? 56 : 64
    styles.bmBurgerButton.left = this.checkMobile() ? 16 : 24
    styles.bmBurgerButton.top = this.checkMobile() ? 16 : 20
    let header, title
    if (location.pathname === "/") {
      title = 'Fuck Up Some Comics'
      header = (
        <Menu styles={styles} >
          Home
        </Menu>
          // Settings
      )
    } else {
      title = 'Comics'
      header = (
        <Link
          style={{
            boxShadow: "none",
            textDecoration: "none",
            color: "inherit",
          }}
          to={"/"}
        >
          <Back size={24} color={'white'} style={styles.bmBurgerButton} />
        </Link>
      )
    }
    return (

{title}

        {header}
        <Container
          style={{
            maxWidth: rhythm(24),
            padding: `${rhythm(1.5)} ${rhythm(3 / 4)}`,
          }}
        >
          {children()}
        </Container>

    )
  }
}

Template.propTypes = {
  children: React.PropTypes.function,
  location: React.PropTypes.object,
  route: React.PropTypes.object,
}

var styles = {
  bmBurgerButton: {
    position: 'absolute',
    width: 24,
    color: 'white',
    height: 24,
    left: 16,
    top: 16
  },
  bmBurgerBars: {
    background: 'white'
  },
  bmCrossButton: {
    height: '24px',
    width: '24px'
  },
  bmCross: {
    background: '#bdc3c7'
  },
  bmMenu: {
    background: '#373a47',
    padding: '2.5em 1.5em 0',
    fontSize: '1.15em'
  },
  bmMorphShape: {
    fill: '#373a47'
  },
  bmItemList: {
    color: '#b8b7ad',
    padding: '0.8em'
  },
  bmOverlay: {
    background: 'rgba(0, 0, 0, 0.3)'
  }
}

export default Template
<commit_msg>check for navigator<commit_after>import React from "react"
import Link from "gatsby-link"
import { Container } from "react-responsive-grid"
import Back from 'react-icons/lib/fa/arrow-left'
import { slide as Menu } from 'react-burger-menu'
import { rhythm, scale } from "../utils/typography"

class Template extends React.Component {
  checkMobile () {
    if (navigator) {
      var check = false;
      (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);
      return check
    }
  }

  showSettings (event) {
    event.preventDefault();
  }

  render () {
    const { location, children } = this.props
    const height = this.checkMobile() ? 56 : 64
    styles.bmBurgerButton.left = this.checkMobile() ? 16 : 24
    styles.bmBurgerButton.top = this.checkMobile() ? 16 : 20
    let header, title
    if (location.pathname === "/") {
      title = 'Fuck Up Some Comics'
      header = (
        <Menu styles={styles} >
          Home
        </Menu>
          // Settings
      )
    } else {
      title = 'Comics'
      header = (
        <Link
          style={{
            boxShadow: "none",
            textDecoration: "none",
            color: "inherit",
          }}
          to={"/"}
        >
          <Back size={24} color={'white'} style={styles.bmBurgerButton} />
        </Link>
      )
    }
    return (

{title}

        {header}
        <Container
          style={{
            maxWidth: rhythm(24),
            padding: `${rhythm(1.5)} ${rhythm(3 / 4)}`,
          }}
        >
          {children()}
        </Container>

    )
  }
}

Template.propTypes = {
  children: React.PropTypes.function,
  location: React.PropTypes.object,
  route: React.PropTypes.object,
}

var styles = {
  bmBurgerButton: {
    position: 'absolute',
    width: 24,
    color: 'white',
    height: 24,
    left: 16,
    top: 16
  },
  bmBurgerBars: {
    background: 'white'
  },
  bmCrossButton: {
    height: '24px',
    width: '24px'
  },
  bmCross: {
    background: '#bdc3c7'
  },
  bmMenu: {
    background: '#373a47',
    padding: '2.5em 1.5em 0',
    fontSize: '1.15em'
  },
  bmMorphShape: {
    fill: '#373a47'
  },
  bmItemList: {
    color: '#b8b7ad',
    padding: '0.8em'
  },
  bmOverlay: {
    background: 'rgba(0, 0, 0, 0.3)'
  }
}

export default Template
<|endoftext|>


<commit_before>/* eslint-disable no-console */
/**
 * Lemmatizer for English using TreeTagger
 */
import TreeTagger from 'treetagger';
import path from 'path';

// This env. variable will be used by treetagger package.
process.env.TREETAGGER_HOME =
  path.join(__dirname, '..', '..', 'vendor', 'treetagger', 'cmd');

const tagger = new TreeTagger();

export default function (text) {
  return new Promise((resolve, reject) => {
    tagger.tag(text, (err, results) => {
      if (err) {
        reject(err);
        return;
      }

      const sentence = results.map((parsed, i) => {
        // Get a context around the processing word.
        const getPart = () => {
          const prev = results[i - 1] ? results[i - 1].t : '';
          const next = results[i + 1] ? results[i + 1].t : '';

          return `${prev} ${parsed.t} ${next}`;
        };

        let shouldSpaced = true;
        let lemma;

        // Warn if an extra period is inserted
        // because it will affect the sentence separation process.
        if (!parsed.t.includes('.') && parsed.l.includes('.')) {
          console.warn('"." is added!:', getPart());
        }

        // A word TreeTagger failed to determine the lemma is usually
        // a proper noun. But sometimes inappropriate unicode characters
        // are also reported as <unknown>, which should be removed.
        if (parsed.l === '<unknown>') {
          const isSign = /^\W+$/.test(parsed.t);

          if (isSign) {
            console.log(parsed, `sign: ${isSign}, part: ${getPart()}`);
            lemma = '';
          } else {
            lemma = parsed.t;
          }
        } else {
          switch (parsed.pos) {
            case 'CD':
              // cardinal numbers have no lemma.
              // (TreeTagger put '@CARD@' as a lemma of CD)
              lemma = parsed.t;
              break;

            case 'PP':
              // Replace personal pronouns with abstract ones.
              if (/sel(?:f|ves)$/.test(parsed.t)) {
                lemma = 'oneself';
              } else {
                lemma = 'one';
              }
              break;

            case 'PP$':
              // Replace possessive pronoun with abstract one.
              lemma = 'one\'s';
              break;

            case 'POS':
              // Always use "'s" even for plural nouns
              // to enable QuizGenerator process easily.
              lemma = '\'s';
              shouldSpaced = false;
              break;

            default:
              if (results[i + 1] && results[i + 1].pos === 'POS') {
                // Replace all possessive proper nouns with "one's".
                lemma = 'one';
              } else if (parsed.t.includes('\'')) {
                // If the input word have an apostrophe (e.g. 'm as in I'm),
                // make sure the lemma also have an apostrophe
                // and doesn't spaced between the previous word
                // so that a word count will not be differed
                // among a source and lemmatized texts.
                lemma = `'${parsed.l}`;
                shouldSpaced = false;
              } else {
                lemma = parsed.l || parsed.t;
              }
              break;
          }
        }

        return shouldSpaced ? ` ${lemma}` : lemma;
      }).join('');

      resolve(sentence.trim());
    });
  });
}
<commit_msg>Exclude error handlings from isparta coverage<commit_after>/* eslint-disable no-console */
/**
 * Lemmatizer for English using TreeTagger
 */
import TreeTagger from 'treetagger';
import path from 'path';

// This env. variable will be used by treetagger package.
process.env.TREETAGGER_HOME =
  path.join(__dirname, '..', '..', 'vendor', 'treetagger', 'cmd');

const tagger = new TreeTagger();

export default function (text) {
  return new Promise((resolve, reject) => {
    tagger.tag(text, (err, results) => {
      /* istanbul ignore if */
      if (err) {
        reject(err);
        return;
      }

      const sentence = results.map((parsed, i) => {
        // Get a context around the processing word.
        const getPart = () => {
          const prev = results[i - 1] ? results[i - 1].t : '';
          const next = results[i + 1] ? results[i + 1].t : '';

          return `${prev} ${parsed.t} ${next}`;
        };

        let shouldSpaced = true;
        let lemma;

        // Warn if an extra period is inserted
        // because it will affect the sentence separation process.
        /* istanbul ignore if */
        if (!parsed.t.includes('.') && parsed.l.includes('.')) {
          console.warn('"." is added!:', getPart());
        }

        // A word TreeTagger failed to determine the lemma is usually
        // a proper noun. But sometimes inappropriate unicode characters
        // are also reported as <unknown>, which should be removed.
        if (parsed.l === '<unknown>') {
          const isSign = /^\W+$/.test(parsed.t);

          /* istanbul ignore if */
          if (isSign) {
            console.warn(
              'Unknown sign is found!!: ',
              parsed,
              `sign: ${isSign}, part: ${getPart()}`
            );
            lemma = '';
          } else {
            lemma = parsed.t;
          }
        } else {
          switch (parsed.pos) {
            case 'CD':
              // cardinal numbers have no lemma.
              // (TreeTagger put '@CARD@' as a lemma of CD)
              lemma = parsed.t;
              break;

            case 'PP':
              // Replace personal pronouns with abstract ones.
              if (/sel(?:f|ves)$/.test(parsed.t)) {
                lemma = 'oneself';
              } else {
                lemma = 'one';
              }
              break;

            case 'PP$':
              // Replace possessive pronoun with abstract one.
              lemma = 'one\'s';
              break;

            case 'POS':
              // Always use "'s" even for plural nouns
              // to enable QuizGenerator process easily.
              lemma = '\'s';
              shouldSpaced = false;
              break;

            default:
              if (results[i + 1] && results[i + 1].pos === 'POS') {
                // Replace all possessive proper nouns with "one's".
                lemma = 'one';
              } else if (parsed.t.includes('\'')) {
                // If the input word have an apostrophe (e.g. 'm as in I'm),
                // make sure the lemma also have an apostrophe
                // and doesn't spaced between the previous word
                // so that a word count will not be differed
                // among a source and lemmatized texts.
                lemma = `'${parsed.l}`;
                shouldSpaced = false;
              } else {
                lemma = parsed.l || parsed.t;
              }
              break;
          }
        }

        return shouldSpaced ? ` ${lemma}` : lemma;
      }).join('');

      resolve(sentence.trim());
    });
  });
}
<|endoftext|>


<commit_before>var locastyle = locastyle || {};

locastyle.customFields = (function() {
  'use strict';

  function init() {
    customSelect();
  };

  function customSelect(){
    $('.ls-custom-select').wrap(function(){
      var selectClasses = $(this).attr('class');
      $(this).removeAttr('class').addClass('ls-select');
      return '

';
    });
  };

  return {
    init: init
  };

}());
<commit_msg>fix custom select<commit_after>var locastyle = locastyle || {};

locastyle.customFields = (function() {
  'use strict';

  function init() {
    customSelect();
  };

  function customSelect(){
    $('select.ls-custom-select').wrap(function(){
      var selectClasses = $(this).attr('class');
      $(this).removeAttr('class').addClass('ls-select');
      return '

';
    });
  };

  return {
    init: init
  };

}());
<|endoftext|>


<commit_before>/*
 * Copyright (C) 2015 - present Instructure, Inc.
 *
 * This file is part of Canvas.
 *
 * Canvas is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License as published by the Free
 * Software Foundation, version 3 of the License.
 *
 * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */

import React from 'react'
import ReactDOM from 'react-dom'
import TestUtils from 'react-addons-test-utils'
import CourseList from 'jsx/epub_exports/CourseList'

QUnit.module('CourseListSpec', {
  setup() {
    this.props = {
      1: {
        name: 'Maths 101',
        id: 1
      },
      2: {
        name: 'Physics 101',
        id: 2
      }
    }
  }
})

test('render', function() {
  let CourseListElement = <CourseList courses={{}} />
  let component = TestUtils.renderIntoDocument(CourseListElement)
  let node = component.getDOMNode()
  equal(node.querySelectorAll('li').length, 0, 'should not render list items')
  ReactDOM.unmountComponentAtNode(node.parentNode)
  CourseListElement = <CourseList courses={this.props} />
  component = TestUtils.renderIntoDocument(CourseListElement)
  node = ReactDOM.findDOMNode(component)
  equal(
    node.querySelectorAll('li').length,
    Object.keys(this.props).length,
    'should have an li element per course in @props'
  )
  ReactDOM.unmountComponentAtNode(node.parentNode)
})
<commit_msg>spec: fix CourseListSpec.js to work with react 15<commit_after>/*
 * Copyright (C) 2015 - present Instructure, Inc.
 *
 * This file is part of Canvas.
 *
 * Canvas is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License as published by the Free
 * Software Foundation, version 3 of the License.
 *
 * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */

import React from 'react'
import ReactDOM from 'react-dom'
import TestUtils from 'react-addons-test-utils'
import CourseList from 'jsx/epub_exports/CourseList'

QUnit.module('CourseListSpec', {
  setup() {
    this.props = {
      1: {
        name: 'Maths 101',
        id: 1
      },
      2: {
        name: 'Physics 101',
        id: 2
      }
    }
  }
})

test('render', function() {
  let CourseListElement = <CourseList courses={{}} />
  let component = TestUtils.renderIntoDocument(CourseListElement)
  let node = ReactDOM.findDOMNode(component)
  equal(node.querySelectorAll('li').length, 0, 'should not render list items')
  ReactDOM.unmountComponentAtNode(node.parentNode)
  CourseListElement = <CourseList courses={this.props} />
  component = TestUtils.renderIntoDocument(CourseListElement)
  node = ReactDOM.findDOMNode(component)
  equal(
    node.querySelectorAll('li').length,
    Object.keys(this.props).length,
    'should have an li element per course in @props'
  )
  ReactDOM.unmountComponentAtNode(node.parentNode)
})
<|endoftext|>