text:
define([
  'knockout',
  'desktop/js/autocomplete/sql',
  'desktop/spec/autocompleterTestUtils'
], function(ko, sql, testUtils) {

  describe('sql.js SHOW statements', function() {

    beforeAll(function () {
      sql.yy.parseError = function (msg) {
        throw Error(msg);
      };
      jasmine.addMatchers(testUtils.testDefinitionMatcher);
    });

    var assertAutoComplete = testUtils.assertAutocomplete;

    it('should suggest keywords for empty statement', function() {
      assertAutoComplete({
        beforeCursor: '',
        afterCursor: '',
        dialect: 'generic',
        containsKeywords: ['SHOW'],
        expectedResult: {
          lowerCase: false
        }
      });
    });

    it('should suggest keywords after SHOW', function() {
      assertAutoComplete({
        beforeCursor: 'SHOW ',
        afterCursor: '',
        dialect: 'generic',
        expectedResult: {
          lowerCase: false,
          suggestKeywords: ['COLUMNS', 'DATABASES', 'TABLES']
        }
      });
    });

    describe('hive specific', function () {
      it('should suggest keywords after SHOW', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['COLUMNS', 'COMPACTIONS', 'CONF', 'CREATE TABLE', 'CURRENT ROLES', 'DATABASES', 'FORMATTED', 'FUNCTIONS', 'GRANT', 'INDEX', 'INDEXES', 'LOCKS', 'PARTITIONS', 'PRINCIPALS', 'ROLE GRANT', 'ROLES', 'SCHEMAS', 'TABLE EXTENDED', 'TABLES', 'TBLPROPERTIES', 'TRANSACTIONS']
          }
        });
      });

      it('should handle SHOW COMPACTIONS', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COMPACTIONS;',
          afterCursor: '',
          dialect: 'hive',
          containsKeywords: ['SELECT'],
          expectedResult: {
            lowerCase: false
          }
        });
      });

      it('should handle SHOW CONF confName', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW CONF a.b.c;',
          afterCursor: '',
          dialect: 'hive',
          containsKeywords: ['SELECT'],
          expectedResult: {
            lowerCase: false
          }
        });
      });

      it('should suggest keywords after SHOW COLUMNS', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COLUMNS ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['FROM', 'IN']
          }
        });
      });

      it('should suggest tables after SHOW COLUMNS FROM ', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COLUMNS FROM ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {}
          }
        });
      });

      it('should suggest tables after SHOW COLUMNS FROM partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COLUMNS FROM partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {}
          }
        });
      });

      it('should suggest keywords after SHOW COLUMNS FROM tableName ', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COLUMNS FROM tableName ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['FROM', 'IN']
          }
        });
      });

      it('should suggest databases after SHOW COLUMNS FROM tableName FROM', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COLUMNS FROM tableName FROM ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest databases after SHOW COLUMNS FROM tableName FROM partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COLUMNS FROM tableName FROM partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest databases after SHOW COLUMNS FROM tableName IN', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COLUMNS FROM tableName IN ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest databases after SHOW COLUMNS FROM tableName IN partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COLUMNS FROM tableName IN partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest tables after SHOW COLUMNS IN ', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COLUMNS IN ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {}
          }
        });
      });

      it('should suggest tables after SHOW COLUMNS IN partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COLUMNS IN partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {}
          }
        });
      });

      it('should suggest keywords after SHOW COLUMNS IN tableName ', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COLUMNS IN tableName ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['FROM', 'IN']
          }
        });
      });

      it('should suggest databases after SHOW COLUMNS IN tableName FROM', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COLUMNS IN tableName FROM ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest databases after SHOW COLUMNS IN tableName FROM partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COLUMNS IN tableName FROM partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest databases after SHOW COLUMNS IN tableName IN', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COLUMNS IN tableName IN ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest databases after SHOW COLUMNS IN tableName IN partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COLUMNS IN tableName IN partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest keywords after SHOW CREATE', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW CREATE ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['TABLE']
          }
        });
      });

      it('should suggest tables after SHOW CREATE TABLE', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW CREATE TABLE ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {},
            suggestDatabases: {
              appendDot: true
            }
          }
        });
      });

      it('should suggest tables after SHOW CREATE TABLE partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW CREATE TABLE partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {},
            suggestDatabases: {
              appendDot: true
            }
          }
        });
      });

      it('should suggest tables after SHOW CREATE TABLE databaseOne.', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW CREATE TABLE databaseOne.',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {
              database: 'databaseOne'
            }
          }
        });
      });

      it('should suggest tables after SHOW CREATE TABLE databaseOne.partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW CREATE TABLE databaseOne.partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {
              database: 'databaseOne'
            }
          }
        });
      });

      it('should suggest keywords after SHOW CURRENT', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW CURRENT ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['ROLES']
          }
        });
      });

      it('should suggest keywords after SHOW DATABASES', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW DATABASES ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['LIKE']
          }
        });
      });

      it('should suggest keywords after SHOW FORMATTED', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW FORMATTED ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['INDEX', 'INDEXES']
          }
        });
      });

      it('should suggest keywords after SHOW FORMATTED INDEX', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW FORMATTED INDEX ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['ON']
          }
        });
      });

      it('should suggest tables after SHOW FORMATTED INDEX ON ', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW FORMATTED INDEX ON ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {}
          }
        });
      });

      it('should suggest tables after SHOW FORMATTED INDEX ON partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW FORMATTED INDEX ON partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {}
          }
        });
      });

      it('should suggest keywords after SHOW FORMATTED INDEX ON table', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW FORMATTED INDEX ON tableName ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['FROM', 'IN']
          }
        });
      });

      it('should suggest databases after SHOW FORMATTED INDEX ON table FROM ', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW FORMATTED INDEX ON tableName FROM ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest tables after SHOW FORMATTED INDEX ON with db specified ', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW FORMATTED INDEX ON ',
          afterCursor: ' FROM databaseOne',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {
              database: 'databaseOne'
            }
          }
        });
      });

      it('should suggest keywords after SHOW FORMATTED INDEXES', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW FORMATTED INDEXES ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['ON']
          }
        });
      });

      it('should suggest tables after SHOW FORMATTED INDEXES ON ', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW FORMATTED INDEXES ON ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {}
          }
        });
      });

      it('should suggest tables after SHOW FORMATTED INDEXES ON partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW FORMATTED INDEXES ON partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {}
          }
        });
      });

      it('should suggest keywords after SHOW FORMATTED INDEX ON tableName ', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW FORMATTED INDEX ON tableOne ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['FROM', 'IN']
          }
        });
      });

      it('should suggest keywords after SHOW FORMATTED INDEXES', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW FORMATTED INDEXES ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['ON']
          }
        });
      });

      it('should suggest keywords after SHOW FORMATTED INDEXES ON tableName ', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW FORMATTED INDEXES ON tableOne ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['FROM', 'IN']
          }
        });
      });

      it('should suggest tables and keywords after SHOW GRANT', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW GRANT ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['ON']
          }
        });
      });

      it('should suggest tables and keywords after SHOW GRANT ON', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW GRANT ON ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {},
            suggestKeywords: ['ALL', 'TABLE']
          }
        });
      });

      it('should suggest tables and keywords after SHOW GRANT ON partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW GRANT ON partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {},
            suggestKeywords: ['ALL', 'TABLE']
          }
        });
      });

      it('should suggest tables after SHOW GRANT ON TABLE', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW GRANT ON TABLE ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {}
          }
        });
      });

      it('should suggest tables after SHOW GRANT ON TABLE partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW GRANT ON TABLE partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {}
          }
        });
      });

      it('should suggest tables and keywords after SHOW GRANT principal', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW GRANT pcp ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['ON']
          }
        });
      });

      it('should suggest tables and keywords after SHOW GRANT principal ON', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW GRANT pcp ON ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {},
            suggestKeywords: ['ALL', 'TABLE']
          }
        });
      });

      it('should suggest tables and keywords after SHOW GRANT principal ON partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW GRANT pcp ON partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {},
            suggestKeywords: ['ALL', 'TABLE']
          }
        });
      });

      it('should suggest tables after SHOW GRANT principal ON TABLE', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW GRANT pcp ON TABLE ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {}
          }
        });
      });

      it('should suggest tables after SHOW GRANT principal ON TABLE partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW GRANT pcp ON TABLE partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {}
          }
        });
      });

      it('should suggest keywords after SHOW INDEX', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW INDEX ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['ON']
          }
        });
      });

      it('should suggest tables after SHOW INDEX ON ', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW INDEX ON ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {}
          }
        });
      });

      it('should suggest tables after SHOW INDEX ON partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW INDEX ON partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {}
          }
        });
      });

      it('should suggest keywords after SHOW INDEX ON tableName ', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW INDEX ON tableOne ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['FROM', 'IN']
          }
        });
      });

      it('should suggest keywords after SHOW INDEXES', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW INDEXES ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['ON']
          }
        });
      });

      it('should suggest tables after SHOW INDEXES ON ', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW INDEXES ON ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {}
          }
        });
      });

      it('should suggest tables after SHOW INDEXES ON partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW INDEXES ON partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {}
          }
        });
      });

      it('should suggest keywords after SHOW INDEXES ON tableName ', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW INDEXES ON tableOne ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['FROM', 'IN']
          }
        });
      });

      it('should suggest tables and keywords after SHOW LOCKS', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW LOCKS ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {},
            suggestDatabases: { // TODO: Is this ok for hive?
              appendDot: true
            },
            suggestKeywords: ['DATABASE', 'SCHEMA']
          }
        });
      });

      it('should suggest tables and keywords after SHOW LOCKS partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW LOCKS partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {},
            suggestDatabases: { // TODO: Is this ok for hive?
              appendDot: true
            },
            suggestKeywords: ['DATABASE', 'SCHEMA']
          }
        });
      });

      it('should suggest databases after SHOW LOCKS DATABASE', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW LOCKS DATABASE ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest databases after SHOW LOCKS DATABASE partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW LOCKS DATABASE partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest databases after SHOW LOCKS SCHEMA', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW LOCKS SCHEMA ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest databases after SHOW LOCKS SCHEMA partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW LOCKS SCHEMA partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest keywords after SHOW LOCKS tableName', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW LOCKS tableName ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['EXTENDED', 'PARTITION']
          }
        });
      });

      it('should suggest keywords after SHOW LOCKS tableName PARTITION partitionSpec', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW LOCKS tableName PARTITION (ds=\'2010-03-03\', hr=\'12\') ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['EXTENDED']
          }
        });
      });

      it('should suggest tables after SHOW PARTITIONS ', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW PARTITIONS ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {},
            suggestDatabases : {
              appendDot: true
            }
          }
        });
      });

      it('should suggest tables after SHOW PARTITIONS partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW PARTITIONS partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {},
            suggestDatabases : {
              appendDot: true
            }
          }
        });
      });

      it('should suggest keywords after SHOW PARTITIONS tableName', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW PARTITIONS foo ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['PARTITION']
          }
        });
      });

      it('should suggest keywords after SHOW ROLE', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW ROLE ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['GRANT']
          }
        });
      });

      it('should suggest keywords after SHOW ROLE GRANT', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW ROLE GRANT ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['ROLE', 'USER']
          }
        });
      });

      it('should suggest keywords after SHOW SCHEMAS', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW SCHEMAS ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['LIKE']
          }
        });
      });

      it('should suggest keywords after SHOW TABLE', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TABLE ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['EXTENDED']
          }
        });
      });

      it('should suggest keywords after SHOW TABLE EXTENDED', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TABLE EXTENDED ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['FROM', 'IN', 'LIKE']
          }
        });
      });

      it('should suggest databases after SHOW TABLE EXTENDED FROM ', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TABLE EXTENDED FROM ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest functions after SHOW TABLE EXTENDED FROM database LIKE identifier', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TABLE EXTENDED FROM databaseOne LIKE \'f|oo*\' ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['PARTITION']
          }
        });
      });

      it('should suggest databases after SHOW TABLE EXTENDED IN ', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TABLE EXTENDED IN ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest functions after SHOW TABLE EXTENDED IN database LIKE identifier', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TABLE EXTENDED IN databaseOne LIKE \'f|oo*\' ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['PARTITION']
          }
        });
      });

      it('should suggest functions after SHOW TABLE EXTENDED LIKE identifier', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TABLE EXTENDED LIKE \'f|oo*\' ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['PARTITION']
          }
        });
      });

      it('should suggest keywords after SHOW TABLES', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TABLES ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['IN', 'LIKE']
          }
        });
      });

      it('should suggest databases after SHOW TABLES IN', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TABLES IN ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest keywords after SHOW TABLES IN db ', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TABLES IN db ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['LIKE']
          }
        });
      });

      it('should suggest tables after SHOW TBLPROPERTIES', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TBLPROPERTIES ',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {}
          }
        });
      });

      it('should suggest tables after SHOW TBLPROPERTIES partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TBLPROPERTIES partial',
          afterCursor: '',
          dialect: 'hive',
          expectedResult: {
            lowerCase: false,
            suggestTables: {}
          }
        });
      });

      it('should handle SHOW TRANSACTIONS', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TRANSACTIONS;',
          afterCursor: '',
          dialect: 'hive',
          containsKeywords: ['SELECT'],
          expectedResult: {
            lowerCase: false
          }
        });
      });
    });

    describe('impala specific', function () {
      it('should suggest keywords after SHOW', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['AGGREGATE FUNCTIONS', 'ANALYTIC FUNCTIONS', 'COLUMN STATS', 'CREATE TABLE', 'CURRENT ROLES', 'DATABASES', 'FUNCTIONS', 'GRANT ROLE', 'PARTITIONS', 'ROLE GRANT GROUP', 'ROLES', 'SCHEMAS', 'TABLE STATS', 'TABLES']
          }
        });
      });

      it('should suggest keywords after SHOW AGGREGATE', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW AGGREGATE ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['FUNCTIONS']
          }
        });
      });

      it('should suggest keywords after SHOW AGGREGATE FUNCTIONS', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW AGGREGATE FUNCTIONS ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['IN', 'LIKE']
          }
        });
      });

      it('should suggest databases after SHOW AGGREGATE FUNCTIONS IN', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW AGGREGATE FUNCTIONS IN ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest databases after SHOW AGGREGATE FUNCTIONS IN partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW AGGREGATE FUNCTIONS IN partial',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest keywords after SHOW ANALYTIC', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW ANALYTIC ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['FUNCTIONS']
          }
        });
      });

      it('should suggest keywords after SHOW ANALYTIC FUNCTIONS', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW ANALYTIC FUNCTIONS ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['IN', 'LIKE']
          }
        });
      });

      it('should suggest databases after SHOW ANALYTIC FUNCTIONS IN', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW ANALYTIC FUNCTIONS IN ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest databases after SHOW ANALYTIC FUNCTIONS IN partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW ANALYTIC FUNCTIONS IN partial',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest keywords after SHOW COLUMN', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COLUMN ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['STATS']
          }
        });
      });

      it('should suggest tables after SHOW COLUMN STATS', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COLUMN STATS ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestTables: {},
            suggestDatabases: {
              appendDot: true
            }
          }
        });
      });

      it('should suggest tables after SHOW COLUMN STATS partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW COLUMN STATS partial',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestTables: {},
            suggestDatabases: {
              appendDot: true
            }
          }
        });
      });

      it('should suggest keywords after SHOW CREATE', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW CREATE ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['TABLE']
          }
        });
      });

      it('should suggest tables after SHOW CREATE TABLE', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW CREATE TABLE ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestTables: {},
            suggestDatabases: {
              appendDot: true
            }
          }
        });
      });

      it('should suggest tables after SHOW CREATE TABLE partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW CREATE TABLE partial',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestTables: {},
            suggestDatabases: {
              appendDot: true
            }
          }
        });
      });

      it('should suggest keywords after SHOW CURRENT', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW CURRENT ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['ROLES']
          }
        });
      });

      it('should handle SHOW CURRENT ROLES', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW CURRENT ROLES;',
          afterCursor: '',
          dialect: 'impala',
          containsKeywords: ['SELECT'],
          expectedResult: {
            lowerCase: false
          }
        });
      });

      it('should suggest keywords after SHOW DATABASES', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW DATABASES ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['LIKE']
          }
        });
      });

      it('should suggest keywords after SHOW FUNCTIONS', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW FUNCTIONS ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['IN', 'LIKE']
          }
        });
      });

      it('should suggest databases after SHOW FUNCTIONS IN', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW FUNCTIONS IN ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest databases after SHOW FUNCTIONS IN partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW FUNCTIONS IN partial',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest keywords after SHOW GRANT', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW GRANT ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['ROLE']
          }
        });
      });

      it('should suggest tables after SHOW PARTITIONS', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW PARTITIONS ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestTables: {},
            suggestDatabases: {
              appendDot: true
            }
          }
        });
      });

      it('should suggest tables after SHOW PARTITIONS partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW PARTITIONS partial',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestTables: {},
            suggestDatabases: {
              appendDot: true
            }
          }
        });
      });

      it('should suggest keywords after SHOW ROLE', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW ROLE ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['GRANT']
          }
        });
      });

      it('should suggest keywords after SHOW ROLE GRANT', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW ROLE GRANT ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['GROUP']
          }
        });
      });

      it('should handle SHOW ROLES', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW ROLES;',
          afterCursor: '',
          dialect: 'impala',
          containsKeywords: ['SELECT'],
          expectedResult: {
            lowerCase: false
          }
        });
      });

      it('should suggest keywords after SHOW SCHEMAS', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW SCHEMAS ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['LIKE']
          }
        });
      });

      it('should suggest keywords after SHOW TABLE', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TABLE ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['STATS']
          }
        });
      });

      it('should suggest tables after SHOW TABLE STATS', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TABLE STATS ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestTables: {},
            suggestDatabases: {
              appendDot: true
            }
          }
        });
      });

      it('should suggest tables after SHOW TABLE STATS partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TABLE STATS partial',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestTables: {},
            suggestDatabases: {
              appendDot: true
            }
          }
        });
      });

      it('should suggest keywords after SHOW TABLES', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TABLES ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestKeywords: ['IN', 'LIKE']
          }
        });
      });

      it('should suggest databases after SHOW TABLES IN', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TABLES IN ',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });

      it('should suggest databases after SHOW TABLES IN partial', function() {
        assertAutoComplete({
          beforeCursor: 'SHOW TABLES IN partial',
          afterCursor: '',
          dialect: 'impala',
          expectedResult: {
            lowerCase: false,
            suggestDatabases: {}
          }
        });
      });
    });
  });
});


text:
package org.apache.camel.component.mybatis;

/**
 * @version
 */
public class Account {
    private int id;
    private String firstName;
    private String lastName;
    private String emailAddress;

    @Override
    public String toString() {
        return "Account[id: " + id + " name: " + firstName + " " + lastName + " email: " + emailAddress + "]";
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getEmailAddress() {
        return emailAddress;
    }

    public void setEmailAddress(String emailAddress) {
        this.emailAddress = emailAddress;
    }
}

redpajama_set_name: RedPajamaGithub


text:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

angular.module('workshopApp',['workshopAppControllers', 'workshopAppServices', 'lodash']);


text:
package org.h2.jdbc;

import java.sql.SQLException;
import java.sql.Savepoint;

import org.h2.api.ErrorCode;
import org.h2.message.DbException;
import org.h2.message.Trace;
import org.h2.message.TraceObject;
import org.h2.util.StringUtils;

/**
 * A savepoint is a point inside a transaction to where a transaction can be
 * rolled back. The tasks that where done before the savepoint are not rolled
 * back in this case.
 */
public class JdbcSavepoint extends TraceObject implements Savepoint {

    private static final String SYSTEM_SAVEPOINT_PREFIX = "SYSTEM_SAVEPOINT_";

    private final int savepointId;
    private final String name;
    private JdbcConnection conn;

    JdbcSavepoint(JdbcConnection conn, int savepointId, String name,
            Trace trace, int id) {
        setTrace(trace, TraceObject.SAVEPOINT, id);
        this.conn = conn;
        this.savepointId = savepointId;
        this.name = name;
    }

    /**
     * Release this savepoint. This method only set the connection to null and
     * does not execute a statement.
     */
    void release() {
        this.conn = null;
    }

    /**
     * Get the savepoint name for this name or id.
     * If the name is null, the id is used.
     *
     * @param name the name (may be null)
     * @param id the id
     * @return the savepoint name
     */
    static String getName(String name, int id) {
        if (name != null) {
            return StringUtils.quoteJavaString(name);
        }
        return SYSTEM_SAVEPOINT_PREFIX + id;
    }

    /**
     * Roll back to this savepoint.
     */
    void rollback() {
        checkValid();
        conn.prepareCommand(
                "ROLLBACK TO SAVEPOINT " + getName(name, savepointId),
                Integer.MAX_VALUE).executeUpdate();
    }

    private void checkValid() {
        if (conn == null) {
            throw DbException.get(ErrorCode.SAVEPOINT_IS_INVALID_1,
                    getName(name, savepointId));
        }
    }

    /**
     * Get the generated id of this savepoint.
     * @return the id
     */
    @Override
    public int getSavepointId() throws SQLException {
        try {
            debugCodeCall("getSavepointId");
            checkValid();
            if (name != null) {
                throw DbException.get(ErrorCode.SAVEPOINT_IS_NAMED);
            }
            return savepointId;
        } catch (Exception e) {
            throw logAndConvert(e);
        }
    }

    /**
     * Get the name of this savepoint.
     * @return the name
     */
    @Override
    public String getSavepointName() throws SQLException {
        try {
            debugCodeCall("getSavepointName");
            checkValid();
            if (name == null) {
                throw DbException.get(ErrorCode.SAVEPOINT_IS_UNNAMED);
            }
            return name;
        } catch (Exception e) {
            throw logAndConvert(e);
        }
    }

    /**
     * INTERNAL
     */
    @Override
    public String toString() {
        return getTraceObjectName() + ": id=" + savepointId + " name=" + name;
    }

}


text:
package se.mah.elis.adaptor.fooprovider.internal;

import java.util.Properties;

import se.mah.elis.adaptor.device.api.data.DeviceIdentifier;
import se.mah.elis.data.OrderedProperties;

/**
 * Identifier for E.On devices.
 *
 * @author Marcus Ljungblad
 * @since 1.0
 * @version 1.0
 */
public class FooDeviceIdentifier implements DeviceIdentifier {
	private String id;

	public FooDeviceIdentifier(String id) {
		this.id = id;
	}

	public String getId() {
		return this.id;
	}

	@Override
	public String toString() {
		return this.id;
	}

	@Override
	public boolean equals(Object o) {
		if (o instanceof FooDeviceIdentifier)
			return this.getId().equals( ((FooDeviceIdentifier)o).getId() );
		return false;
	}

	@Override
	public OrderedProperties getProperties() {
		OrderedProperties props = new OrderedProperties();

		props.put("id", id);

		return props;
	}

	@Override
	public OrderedProperties getPropertiesTemplate() {
		OrderedProperties props = new OrderedProperties();

		props.put("id", "32");

		return props;
	}

	@Override
	public void populate(Properties props) {
		id = (String) props.getProperty("id");
	}
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">

  <title>Description of RNA</title>
  <meta name="keywords" content="RNA">
  <meta name="description" content="RNA">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 © 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../../../../../../../m2html.css">

Home >  simulation > src > +edu > +stanford > +covert > +cell > +sim > +analysis > RNA.m

RNA

PURPOSE

RNA

SYNOPSIS

This is a script file.

DESCRIPTION

RNA

 Author: Jonathan Karr, jkarr@stanford.edu
 Affiliation: Covert Lab, Department of Bioengineering, Stanford University
 Last Updated: 4/22/2011

CROSS-REFERENCE INFORMATION

This function calls:

RNA	RNA

This function is called by:

RNA	RNA

SUBFUNCTIONS

function run(sim, nSample, nIter, fileName)

function [content, colLabels, indentation] = tabulateRNASynthesisExpression(sim, expRnaSyn, expRnaExp, simRnaSyn, simRnaExp)

function plotRnaSynthesis(axesHandle, sim, expRnaSyn, simRnaSyn)

function plotRnaExpression(axesHandle, sim, expRnaExp, simRnaExp)

function [rnaSyn, rnaExp] = calcExpectedSynthesisExpression(sim)

function [rnaSyn, rnaExp] = sampleRNASynthesis(sim, nSample, nIter)

function [rnaSyn, rnaExp] = simulateRNASynthesis(nIter, seed)

SOURCE CODE

0001 %RNA
0002 %
0003 % Author: Jonathan Karr, jkarr@stanford.edu
0004 % Affiliation: Covert Lab, Department of Bioengineering, Stanford University
0005 % Last Updated: 4/22/2011
0006 classdef RNA
0007     methods (Static = true)
0008         function run(sim, nSample, nIter, fileName)
0009             import edu.stanford.covert.cell.sim.analysis.RNA;
0010             import edu.stanford.covert.cell.sim.util.PlotUtil;
0011             import edu.stanford.covert.cell.sim.util.PrintUtil;
0012
0013             %simulate
0014             [expRnaSyn, expRnaExp] = RNA.calcExpectedSynthesisExpression(sim);
0015             [simRnaSyn, simRnaExp] = RNA.sampleRNASynthesis(sim, nSample, nIter);
0016
0017             %print
0018             [content, colLabels, indentation] = RNA.tabulateRNASynthesisExpression(sim, expRnaSyn, expRnaExp, simRnaSyn, simRnaExp);
0019             if nargin == 3
0020                 PrintUtil.printToStdIO(content, colLabels, struct('indentation', indentation));
0021             else
0022                 PrintUtil.printToFile(content, colLabels, [fileName '.xls'], 'Synthesis-Expression', struct('indentation', indentation));
0023             end
0024
0025             %plot
0026             if nargin == 3
0027                 RNA.plotRnaSynthesis(PlotUtil.newAxesHandle(), sim, expRnaSyn, simRnaSyn);
0028                 RNA.plotRnaExpression(PlotUtil.newAxesHandle(), sim, expRnaExp, simRnaExp);
0029             else
0030                 [axesHandle, figHandle] = edu.stanford.covert.cell.sim.util.PlotUtil.newAxesHandle();
0031
0032                 RNA.plotRnaSynthesis(axesHandle, sim, expRnaSyn, simRnaSyn);
0033                 saveas(figHandle, [fileName '-Synthesis.pdf']);
0034
0035                 RNA.plotRnaExpression(axesHandle, sim, expRnaExp, simRnaExp);
0036                 saveas(figHandle, [fileName '-Expression.pdf']);
0037
0038                 close(figHandle);
0039             end
0040         end
0041     end
0042
0043     methods (Static = true)
0044         function [content, colLabels, indentation] = tabulateRNASynthesisExpression(sim, expRnaSyn, expRnaExp, simRnaSyn, simRnaExp)
0045             rna = sim.state('Rna');
0046             matIdxs = rna.matureIndexs;
0047
0048             colLabels = [
0049                 'ID', 'Name', 'Transcription Unit', ...
0050                 'Expected Synthesis (molecules / cell cycle)', 'Mean Simulated Synthesis (molecules / cell cycle)', 'Std Simulated Synthesis (molecules / cell cycle)', ...
0051                 cellfun(@(x) ['Synthesis - Simulation #' num2str(x)], num2cell(1:size(simRnaSyn, 2)), 'UniformOutput', false), ...
0052                 'Expected Expression (molecules * s / cell cycle)', 'Mean Simulated Expression (molecules * s / cell cycle)', 'Std Simulated Expression (molecules * s / cell cycle)', ...
0053                 cellfun(@(x) ['Expression - Simulation #' num2str(x)], num2cell(1:size(simRnaExp, 2)), 'UniformOutput', false), ...
0054                 ];
0055
0056             [~, tuIdxs] = find(rna.nascentRNAMatureRNAComposition);
0057
0058             content = [
0059                 rna.wholeCellModelIDs(matIdxs) rna.names(matIdxs) rna.wholeCellModelIDs(tuIdxs) ...
0060                 num2cell([
0061                 expRnaSyn mean(simRnaSyn, 2) std(simRnaSyn, 0, 2) simRnaSyn ...
0062                 expRnaExp mean(simRnaExp, 2) std(simRnaExp, 0, 2) simRnaExp ...
0063                 ])];
0064
0065             indentation = zeros(size(content, 1), 1);
0066         end
0067
0068         function plotRnaSynthesis(axesHandle, sim, expRnaSyn, simRnaSyn)
0069             rna = sim.state('Rna');
0070
0071             hold(axesHandle, 'on');
0072
0073             h = [
0074                 plot(axesHandle, expRnaSyn(rna.matureMRNAIndexs), mean(simRnaSyn(rna.matureMRNAIndexs, :), 2), 'r.')
0075                 plot(axesHandle, expRnaSyn(rna.matureRRNAIndexs), mean(simRnaSyn(rna.matureRRNAIndexs, :), 2), 'g.')
0076                 plot(axesHandle, expRnaSyn(rna.matureSRNAIndexs), mean(simRnaSyn(rna.matureSRNAIndexs, :), 2), 'b.')
0077                 plot(axesHandle, expRnaSyn(rna.matureTRNAIndexs), mean(simRnaSyn(rna.matureTRNAIndexs, :), 2), 'c.')
0078                 ];
0079             line([0 max(max(expRnaSyn), max(mean(simRnaSyn, 2)))], [0 max(max(expRnaSyn), max(mean(simRnaSyn, 2)))], 'Parent', axesHandle);
0080             xlim(axesHandle, [0 max(max(expRnaSyn), max(mean(simRnaSyn, 2)))]);
0081             ylim(axesHandle, [0 max(max(expRnaSyn), max(mean(simRnaSyn, 2)))]);
0082             axis(axesHandle, 'square');
0083             box(axesHandle, 'on');
0084             xlabel(axesHandle, 'Expected Synthesis', 'FontSize', 12);
0085             ylabel(axesHandle, 'Mean Simulated Synthesis', 'FontSize', 12);
0086             legend(h, {'mRNA', 'rRNA', 'sRNA', 'tRNA'}, 'Location', 'NorthEastOutside');
0087         end
0088
0089         function plotRnaExpression(axesHandle, sim, expRnaExp, simRnaExp)
0090             rna = sim.state('Rna');
0091
0092             hold(axesHandle, 'on');
0093
0094             h = [
0095                 plot(axesHandle, expRnaExp(rna.matureMRNAIndexs), mean(simRnaExp(rna.matureMRNAIndexs, :), 2), 'r.')
0096                 plot(axesHandle, expRnaExp(rna.matureRRNAIndexs), mean(simRnaExp(rna.matureRRNAIndexs, :), 2), 'g.')
0097                 plot(axesHandle, expRnaExp(rna.matureSRNAIndexs), mean(simRnaExp(rna.matureSRNAIndexs, :), 2), 'b.')
0098                 plot(axesHandle, expRnaExp(rna.matureTRNAIndexs), mean(simRnaExp(rna.matureTRNAIndexs, :), 2), 'c.')
0099                 ];
0100             line([0 max(max(expRnaExp), max(mean(simRnaExp, 2)))], [0 max(max(expRnaExp), max(mean(simRnaExp, 2)))], 'Parent', axesHandle);
0101             xlim(axesHandle, [0 max(max(expRnaExp), max(mean(simRnaExp, 2)))]);
0102             ylim(axesHandle, [0 max(max(expRnaExp), max(mean(simRnaExp, 2)))]);
0103             axis(axesHandle, 'square');
0104             box(axesHandle, 'on');
0105             xlabel(axesHandle, 'Expected Expression', 'FontSize', 12);
0106             ylabel(axesHandle, 'Mean Simulated Expression', 'FontSize', 12);
0107             legend(h, {'mRNA', 'rRNA', 'sRNA', 'tRNA'}, 'Location', 'NorthEastOutside');
0108         end
0109
0110         function [rnaSyn, rnaExp] = calcExpectedSynthesisExpression(sim)
0111             import edu.stanford.covert.util.ConstantUtil;
0112
0113             time = sim.state('Time');
0114             mass = sim.state('Mass');
0115             rna = sim.state('Rna');
0116
0117             exp = rna.expression(rna.matureIndexs);
0118             mws = rna.molecularWeights(rna.matureIndexs) / ConstantUtil.nAvogadro;
0119             drs = rna.decayRates(rna.matureIndexs);
0120
0121             initCnts = exp * mass.cellInitialDryWeight * mass.dryWeightFractionRNA / (exp' * mws);
0122
0123             rnaExp = initCnts * time.cellCycleLength / log(2);
0124             rnaSyn = initCnts + initCnts .* drs * time.cellCycleLength / log(2);
0125         end
0126
0127         function [rnaSyn, rnaExp] = sampleRNASynthesis(sim, nSample, nIter)
0128             import edu.stanford.covert.cell.sim.analysis.RNA;
0129
0130             rna = sim.state('Rna');
0131             nRna = size(rna.matureIndexs, 1);
0132
0133             rnaSyn = zeros(nRna, nSample);
0134             rnaExp = zeros(nRna, nSample);
0135
0136             for i = 1:nSample
0137                 [rnaSyn(:, i), rnaExp(:, i)] = RNA.simulateRNASynthesis(nIter, i);
0138             end
0139         end
0140
0141         function [rnaSyn, rnaExp] = simulateRNASynthesis(nIter, seed)
0142             %% references
0143             sim = edu.stanford.covert.cell.sim.SimulationFixture.load([], {
0144                 'Metabolism'
0145                 'Transcription'
0146                 'RNAProcessing'
0147                 'RNAModification'
0148                 'tRNAAminoacylation'
0149                 'RNADecay'});
0150
0151             g = sim.gene;
0152             rna = sim.state('Rna');
0153             time = sim.state('Time');
0154             pm = sim.state('ProteinMonomer');
0155             pc = sim.state('ProteinComplex');
0156
0157             %% seed
0158             sim.applyOptions('seed', seed);
0159             sim.seedRandStream();
0160
0161             for i = 1:numel(sim.states)
0162                 o = sim.states{i};
0163                 o.seed = seed;
0164                 o.seedRandStream();
0165             end
0166
0167             for i = 1:numel(sim.processes)
0168                 o = sim.processes{i};
0169                 o.seed = seed;
0170                 o.seedRandStream();
0171             end
0172
0173             %% turn off decay
0174             rna.decayRates(setdiff(1:end, rna.intergenicIndexs)) = 0;
0175
0176             %% keep track of initial state
0177             initRNAs = rna.counts;
0178             initMonomers = pm.counts;
0179             initComplexs = pc.counts;
0180
0181             %% simulate
0182             allRnaSyn = zeros(size(rna.counts));
0183             allRnaExp = zeros(size(rna.counts));
0184             for i = 1:nIter
0185                 %mock protein synthesis
0186                 pm.counts = ceil(initMonomers * exp(i * log(2) / time.cellCycleLength));
0187                 pc.counts = ceil(initComplexs * exp(i * log(2) / time.cellCycleLength));
0188
0189                 %remember old RNA counts
0190                 oldRnaCounts = rna.counts;
0191
0192                 %simulate
0193                 sim.evolveState();
0194
0195                 %accounting of new RNAs
0196                 allRnaSyn = allRnaSyn + max(0, rna.counts - oldRnaCounts);
0197
0198                 %accounting of expressed RNAs
0199                 allRnaExp = allRnaExp + rna.counts;
0200                 allRnaExp(rna.matureIndexs(setdiff(1:end, rna.matureMRNAIndexs)), sim.compartment.cytosolIndexs) = ...
0201                     allRnaExp(rna.matureIndexs(setdiff(1:end, rna.matureMRNAIndexs)), sim.compartment.cytosolIndexs) + ...
0202                     sum(pc.proteinComplexComposition(setdiff(1:end, g.mRNAIndexs), :, :), 3) * sum(initComplexs(pc.matureIndexs, :) + initComplexs(pc.boundIndexs, :), 2);
0203             end
0204
0205             rnaSyn = allRnaSyn(rna.matureIndexs, sim.compartment.cytosolIndexs);
0206             aminoacylatedTfs = allRnaSyn(rna.aminoacylatedIndexs, sim.compartment.cytosolIndexs) ~= 0;
0207             rnaSyn(aminoacylatedTfs) = allRnaSyn(rna.aminoacylatedIndexs(aminoacylatedTfs), sim.compartment.cytosolIndexs) - ...
0208                 initRNAs(rna.matureIndexs(aminoacylatedTfs), sim.compartment.cytosolIndexs);
0209
0210             rnaExp = ...
0211                 allRnaExp(rna.processedIndexs, sim.compartment.cytosolIndexs) + ...
0212                 allRnaExp(rna.matureIndexs, sim.compartment.cytosolIndexs) + ...
0213                 allRnaExp(rna.aminoacylatedIndexs, sim.compartment.cytosolIndexs) + ...
0214                 allRnaExp(rna.boundIndexs, sim.compartment.cytosolIndexs) + ...
0215                 allRnaExp(rna.misfoldedIndexs, sim.compartment.cytosolIndexs) + ...
0216                 allRnaExp(rna.damagedIndexs, sim.compartment.cytosolIndexs);
0217
0218             %% scale to cell cycle
0219             rnaSyn = rnaSyn * 1 / (exp(nIter * log(2) / time.cellCycleLength) - 1);
0220             rnaExp = rnaExp * 1 / (exp(nIter * log(2) / time.cellCycleLength) - 1);
0221         end
0222     end
0223 end

<address>Generated on Thu 19-Jul-2012 18:32:13 by m2html © 2005</address>


text:
package org.jetbrains.plugins.scala.project.notification.source;

import com.intellij.codeInsight.AttachSourcesProvider;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.roots.LibraryOrderEntry;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.ui.DescendentBasedRootFilter;
import com.intellij.openapi.roots.libraries.ui.FileTypeBasedRootFilter;
import com.intellij.openapi.roots.libraries.ui.OrderRoot;
import com.intellij.openapi.roots.libraries.ui.RootDetector;
import com.intellij.openapi.roots.libraries.ui.impl.LibraryRootsDetectorImpl;
import com.intellij.openapi.roots.libraries.ui.impl.RootDetectionUtil;
import com.intellij.openapi.roots.ui.configuration.LibraryJavaSourceRootDetector;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.ui.popup.ListSeparator;
import com.intellij.openapi.ui.popup.PopupStep;
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.scala.ScalaFileType;

import javax.swing.*;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author Alexander Podkhalyuzin
 */

//todo: copy/paste from AttachSourcesNotificationProvider, remove it
public class AttachSourcesUtil {

    public static class AttachJarAsSourcesAction implements AttachSourcesProvider.AttachSourcesAction {
        private final VirtualFile myClassFile;

        public AttachJarAsSourcesAction(VirtualFile classFile) {
            myClassFile = classFile;
        }

        public String getName() {
            return ProjectBundle.message("module.libraries.attach.sources.immediately.button");
        }

        public String getBusyText() {
            return ProjectBundle.message("library.attach.sources.action.busy.text");
        }

        public ActionCallback perform(List<LibraryOrderEntry> orderEntriesContainingFile) {
            final List<Library.ModifiableModel> modelsToCommit = new ArrayList<Library.ModifiableModel>();
            for (LibraryOrderEntry orderEntry : orderEntriesContainingFile) {
                final Library library = orderEntry.getLibrary();
                if (library == null) continue;
                final VirtualFile root = findRoot(library);
                if (root == null) continue;
                final Library.ModifiableModel model = library.getModifiableModel();
                model.addRoot(root, OrderRootType.SOURCES);
                modelsToCommit.add(model);
            }
            if (modelsToCommit.isEmpty()) return new ActionCallback.Rejected();
            new WriteAction() {
                protected void run(final Result result) {
                    for (Library.ModifiableModel model : modelsToCommit) {
                        model.commit();
                    }
                }
            }.execute();

            return new ActionCallback.Done();
        }

        @Nullable
        private VirtualFile findRoot(Library library) {
            for (VirtualFile classesRoot : library.getFiles(OrderRootType.CLASSES)) {
                if (VfsUtil.isAncestor(classesRoot, myClassFile, true)) {
                    return classesRoot;
                }
            }
            return null;
        }
    }

    public static class ChooseAndAttachSourcesAction implements AttachSourcesProvider.AttachSourcesAction {
        private final Project myProject;
        private final JComponent myParentComponent;

        public ChooseAndAttachSourcesAction(Project project, JComponent parentComponent) {
            myProject = project;
            myParentComponent = parentComponent;
        }

        public String getName() {
            return ProjectBundle.message("module.libraries.attach.sources.button");
        }

        public String getBusyText() {
            return ProjectBundle.message("library.attach.sources.action.busy.text");
        }

        public ActionCallback perform(final List<LibraryOrderEntry> libraries) {
            final Library firstLibrary = libraries.get(0).getLibrary();
            VirtualFile root = firstLibrary != null ? findRoot(firstLibrary) : null;

            List<VirtualFile> files = scanAndSelectDetectedJavaSourceRoots(root);
            if (files.isEmpty()) return new ActionCallback.Rejected();

            Map<Library, LibraryOrderEntry> librariesToAppendSourcesTo = new HashMap<>();
            for (LibraryOrderEntry library : libraries) {
                librariesToAppendSourcesTo.put(library.getLibrary(), library);
            }
            if (librariesToAppendSourcesTo.size() == 1) {
                appendSources(firstLibrary, files);
            } else {
                librariesToAppendSourcesTo.put(null, null);

                LibraryOrderEntry[] orderEntries = librariesToAppendSourcesTo.values().toArray(new LibraryOrderEntry[0]);
                BaseListPopupStep<LibraryOrderEntry> popupStep = new BaseListPopupStep<LibraryOrderEntry>("Multiple libraries contain file.
 Choose libraries to attach sources to", orderEntries) {

                    @Nullable
                    @Override
                    public ListSeparator getSeparatorAbove(@Nullable LibraryOrderEntry entry) {
                        return entry == null ? new ListSeparator() : null;
                    }

                    @NotNull
                    @Override
                    public String getTextFor(@Nullable LibraryOrderEntry entry) {
                        return entry != null
                                ? entry.getPresentableName() + " (" + entry.getOwnerModule().getName() + ")"
                                : "All";
                    }

                    @Nullable
                    @Override
                    public PopupStep onChosen(@Nullable LibraryOrderEntry entry, boolean finalChoice) {
                        if (entry != null) {
                            appendSources(entry.getLibrary(), files);
                        } else {
                            for (Library library : librariesToAppendSourcesTo.keySet()) {
                                if (library != null) {
                                    appendSources(library, files);
                                }
                            }
                        }
                        return FINAL_CHOICE;
                    }
                };
                JBPopupFactory.getInstance().createListPopup(popupStep).showCenteredInCurrentWindow(myProject);
            }

            return new ActionCallback.Done();
        }

        /**
         * This method takes a candidates for the project root, then scans the candidates and
         * if multiple candidates or non root source directories are found whithin some
         * directories, it shows a dialog that allows selecting or deselecting them.
         *
         * @param root a candidates for root
         * @return a array of source folders or empty array if non was selected or dialog was canceled.
         */
        private List<VirtualFile> scanAndSelectDetectedJavaSourceRoots(@Nullable VirtualFile root) {
            List<RootDetector> rootDetectors = Arrays.asList(
                    new LibraryJavaSourceRootDetector(),
                    DescendentBasedRootFilter.createFileTypeBasedFilter(OrderRootType.SOURCES, false, ScalaFileType.INSTANCE, "source")
            );

            List<OrderRoot> orderRoots = RootDetectionUtil.detectRoots(
                    chooseFiles(myProject, root),
                    myParentComponent,
                    null,
                    new LibraryRootsDetectorImpl(rootDetectors),
                    new OrderRootType[0]
            );

            List<VirtualFile> result = orderRoots.stream()
                    .map(OrderRoot::getFile)
                    .collect(Collectors.toList());

            return Collections.unmodifiableList(result);
        }

        @Nullable
        private static VirtualFile findRoot(@NotNull Library library) {
            VirtualFile[] files = library.getFiles(OrderRootType.CLASSES);
            return files.length != 0 ? files[0] : null;
        }

        @NotNull
        private static List<VirtualFile> chooseFiles(@NotNull Project project, @Nullable VirtualFile root) {
            FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, true, false, true, true);
            descriptor.setTitle(ProjectBundle.message("library.attach.sources.action"));
            descriptor.setDescription(ProjectBundle.message("library.attach.sources.description"));

            return Arrays.asList(FileChooser.chooseFiles(descriptor, project, root));
        }
    }

    public static void appendSources(Library library, Collection<VirtualFile> files) {
        ApplicationManager.getApplication().runWriteAction(() -> {
            Library.ModifiableModel model = library.getModifiableModel();
            for (VirtualFile virtualFile : files) {
                model.addRoot(virtualFile, OrderRootType.SOURCES);
            }
            model.commit();
        });
    }
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
    <type>com.microchip.mplab.nbide.embedded.makeproject</type>
    <configuration>
        <data xmlns="http://www.netbeans.org/ns/make-project/1">
            <name>wolfcrypt_test</name>
            <creation-uuid>b34c4937-7042-4352-88b1-7717bcdf8aeb</creation-uuid>
            <make-project-type>0</make-project-type>
            <c-extensions>c</c-extensions>
            <cpp-extensions/>
            <header-extensions/>
            <sourceEncoding>ISO-8859-1</sourceEncoding>
            <asminc-extensions/>
            <make-dep-projects>
                <make-dep-project>../wolfssl.X</make-dep-project>
                <make-dep-project>../zlib.X</make-dep-project>
            </make-dep-projects>
        </data>
    </configuration>
</project>


text:
import { alias } from '@ember/object/computed';
import Component from '@ember/component';
import Analytics from 'ember-osf/mixins/analytics';

import { validator, buildValidations }
    from 'ember-cp-validations';
import emailValidationRegex from '../utils/email-validation';

/* Validations for adding unregistered contributor form.  fullName must be present
and have three letters, and the username (email) must be present and of appropriate format.
*/
const Validations = buildValidations({
    fullName: {
        description: 'Full Name',
        validators: [
            validator('presence', true),
            validator('length', {
                min: 3,
            }),
        ],
    },
    username: {
        validators: [
            validator('presence', true),
            validator('format', {
                type: 'email',
                regex: emailValidationRegex,
            }),
        ],
    },
});
/**
 * @module ember-preprints
 * @submodule components
 */

/**
 * Allows user to add author to their preprint by name and email
 *
 * Sample usage:
 * ```handlebars
 * {{unregistered-contributor-form
 *      editMode=editMode
 *      resetfindContributorsView=(action 'resetfindContributorsView')
 *      addUnregisteredContributor=(action 'addUnregisteredContributor')
 * }}
 * ```
 * @class unregistered-contributor-form
 */
export default Component.extend(Validations, Analytics, {
    fullName: null,
    username: null,
    isFormValid: alias('validations.isValid'),
    actions: {
        addUnregistered(fullName, email) {
            this.get('metrics')
                .trackEvent({
                    category: 'button',
                    action: 'click',
                    label: `${this.get('editMode') ? 'Edit' : 'Submit'} - Add Author By Email`,
                });
            if (this.get('isFormValid')) {
                this.attrs.addUnregisteredContributor(fullName, email);
            }
        },
    },

});


text:
require 'chefspec'

describe 'mount::disable' do
  let(:chef_run) { ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe) }

  it 'disables a mount with an explicit action' do
    expect(chef_run).to disable_mount('/tmp/explicit_action')
    expect(chef_run).to_not disable_mount('/tmp/not_explicit_action')
  end

  it 'disables a mount with attributes' do
    expect(chef_run).to disable_mount('/tmp/with_attributes').with(dump: 3)
    expect(chef_run).to_not disable_mount('/tmp/with_attributes').with(dump: 5)
  end
end


text:
from django.core.management.base import BaseCommand, CommandError
import time

from django_celery_beat.models import PeriodicTask
from django.utils import timezone
from datetime import timedelta

from atlas.prodtask.views import send_alarm_message

class Command(BaseCommand):
    args = 'None'
    help = 'Check celery beat health'

    def handle(self, *args, **options):
        if not args:
            self.stdout.write(f'Start celery beat health check {timezone.now()}')

            try:
                try:
                    last_executed_task = PeriodicTask.objects.all().order_by('-last_run_at')[0]
                except Exception as e:
                    send_alarm_message('Alarm: the celery beat health check problem',
                              f'Celery beat health check problem {e}')
                    raise e
                if (timezone.now() - last_executed_task.last_run_at) > timedelta(hours=3):
                    send_alarm_message('Alarm: the celery beat is stuck',
                                       f'Celery beat last updated {last_executed_task.last_run_at}')
            except Exception as e:
                raise CommandError('Some problem during alarm mail sending check: %s'%e)


text:
require 'soap/rpc/standaloneServer'
require 'net/http'
require 'soap/rpc/driver'
require 'tempfile'
require 'uri'

@@PORT = 10556
@@SERVICE = 'urn:ForeCite/ParsHed'
@@ID = 'ParsHed'
@@Web_Service_ID = 'urn:ForeCite'
@@Web_Service_Port = '10570'
#@@Web_Service_Host = 'wing.comp.nus.edu.sg'
@@Web_Service_Host = 'aye'

class ParsHedServer < SOAP::RPC::StandaloneServer
  @@CMD = "~/services/parscit/bin/headExtract.pl" # in parscit distribution

  def on_init
    @log.level = Logger::Severity::INFO
    add_method(self, 'extract_header', 'uri_or_path')
    add_method(self, 'ping')
  end

  def ping
    "ping"
  end

  def extract_header(uri_or_path)
    uri = URI.extract(uri_or_path)
    localfile = ""
    if (uri.size == 0) # get local file to process
      localfile = uri_or_path
    else # get file to process from uri specification
      tempfile = Tempfile.new("ParsHedServer")
      tempfile.binmode
      tempfile.puts(Net::HTTP.get(URI.parse(uri_or_path)))
      tempfile.close()
      localfile = tempfile.path()
    end
    `#{@@CMD} #{localfile}`
  end
end

if $0 == __FILE__
  if (defined? ARGV[0])
    case ARGV[0]
    when '-r' # use -r to register with web service server
      hostname = `hostname -f`
      hostname.chomp!()
      s = SOAP::RPC::Driver.new("http://#{@@Web_Service_Host}:#{@@Web_Service_Port}/", @@Web_Service_ID)
      puts "# #{$0} info\tRegistering with web service server #{@@Web_Service_Host}\n"
      s.add_method('register','service','machine')
      s.register('extract_header',hostname)
    when '-h'
      puts "#{$0} Usage:\n"
      puts "\t-r\tRegister with web service server\n"
      exit()
    end
  end

  server = ParsHedServer.new(@@ID, @@SERVICE, '0.0.0.0', @@PORT)
  trap(:INT) do
    server.shutdown
  end
  server.start
end


text:
namespace FlatFile.Core.Attributes.Base
{
    using System;
    using FlatFile.Core.Base;
    using FlatFile.Core.Extensions;

    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public abstract class FieldSettingsBaseAttribute : Attribute, IFieldSettings
    {
        public int? Index { get; set; }

        public bool IsNullable
        {
            get { return !string.IsNullOrEmpty(NullValue); }
        }

        public string NullValue { get; set; }

        public Type Converter { get; set; }

        public ITypeConverter TypeConverter
        {
            get { return (ITypeConverter) ReflectionHelper.CreateInstance(Converter, true); }
        }

        protected FieldSettingsBaseAttribute(int index)
        {
            Index = index;
        }
    }
}


text:
import os
import sys
import time
import urllib2
import json
from slackclient import SlackClient

# starterbot's ID as an environment variable
BOT_ID = "sam"

# constants
AT_BOT = "<@U12345678>"
# change these to test your configuations before adding them to Sam
BOTCHANNELS = "D12345678"
ALLOWED = "<@U12345678>"

# instantiate Slack & Twilio clients
slack_client = SlackClient("TOKEN_HERE")

def handle_command(command, channel, user, seclvl):
    response = "Message"
    if (command.startswith('test') and (seclvl >= 1)):
        response = "Channel spy command test"
        slack_client.api_call("chat.postMessage", channel=channel,
                          text=response, as_user=True)

def get_user_name(userinfo):
    # change to your bot ID
    if userinfo != 'U12345678':
        # add your token here
        f = urllib2.urlopen('https://slack.com/api/users.info?user=' + userinfo + '&token=TOKEN_HERE')
        json_string = f.read()
        parsed_json = json.loads(json_string)
        realname = parsed_json['user']['profile']['first_name']
        return realname
    return "Sam"

def parse_slack_output(slack_rtm_output):
    output_list = slack_rtm_output
    if output_list and len(output_list) > 0:
        for output in output_list:
            if ((output and 'text' in output) and (AT_BOT in output['text'])):
                if (output['user'] in ALLOWED):
                    seclvl = 2
                else:
                    seclvl = 1
                return output['text'].split(AT_BOT)[1].strip(), \
                       output['channel'], \
                       output['user'], \
                       seclvl
            if ((output and 'text' in output) and (output['channel'] in BOTCHANNELS)):
                if (output['user'] in ALLOWED):
                    seclvl = 2
                else:
                    seclvl = 1
                return output['text'], \
                       output['channel'], \
                       output['user'], \
                       seclvl
    return None, None, None, None

if __name__ == "__main__":
    READ_WEBSOCKET_DELAY = 1 # 1 second delay between reading from firehose
    if slack_client.rtm_connect():
        print("channel spy online and connected")
        while True:
            command, channelo, usero, seclvl = parse_slack_output(slack_client.rtm_read())
            if command and channelo:
                print "Message: " + command
                print "User: " + usero
                realname = get_user_name(usero)
                print "Real Name: " + realname
                trucommand = command.replace(": ", "")
                trucommand = trucommand.replace(":", "")
                print "Channel: " + channelo
                #chlinfo = slack_client.api_call("channels.info", channel=channelo)
                #print chlinfo
                print "Security Level: " + str(seclvl)
                handle_command(trucommand, channelo, usero, seclvl)
            time.sleep(READ_WEBSOCKET_DELAY)


text:
<?php

namespace Surfnet\Conext\EntityVerificationFramework\Metadata;

use ArrayIterator;
use Countable;
use IteratorAggregate;
use Surfnet\Conext\EntityVerificationFramework\Assert;

final class PemEncodedX509CertificateList implements IteratorAggregate, Countable
{
    /**
     * @var PemEncodedX509Certificate[]
     */
    private $certs;

    public function __construct(array $certs = [])
    {
        Assert::allIsInstanceOf($certs, PemEncodedX509Certificate::class);

        $this->certs = $certs;
    }

    /**
     * @param PemEncodedX509Certificate $cert
     * @return PemEncodedX509CertificateList
     */
    public function add(PemEncodedX509Certificate $cert)
    {
        return new PemEncodedX509CertificateList(array_merge($this->certs, [$cert]));
    }

    public function getIterator()
    {
        return new ArrayIterator($this->certs);
    }

    public function count()
    {
        return count($this->certs);
    }

    public function __toString()
    {
        return sprintf('PemEncodedX509CertificateList(%s)', join(', ', array_map('strval', $this->certs)));
    }
}


text:
package de.bytefish.jtinycsvparser.typeconverter;

import java.lang.reflect.Type;
import java.text.NumberFormat;
import java.util.Locale;

public class IntegerConverter implements ITypeConverter<Integer> {

    private NumberFormat numberFormat;

    public IntegerConverter() {
        this(NumberFormat.getInstance(Locale.US));
    }

    public IntegerConverter(NumberFormat numberFormat) {
        this.numberFormat = numberFormat;
    }

    @Override
    public Integer convert(String value) {
        try {
            return numberFormat.parse(value).intValue();
        } catch(Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public Type getTargetType() {
        return Integer.class;
    }

    @Override
    public String toString() {
        return "IntegerConverter{" +
                "numberFormat=" + numberFormat +
                '}';
    }
}


text:
NS_ASSUME_NONNULL_BEGIN

/// A view that displays search ads.
/// To show search ads:
///   1) Create a GADSearchBannerView and add it to your view controller's view hierarchy.
///   2) Create a GADSearchRequest ad request object to hold the search query and other search data.
///   3) Call GADSearchBannerView's -loadRequest: method with the GADSearchRequest object.
@interface GADSearchBannerView : GADBannerView

/// If the banner view is initialized with kGADAdSizeFluid and the corresponding request is created
/// with dynamic height parameters, this delegate will be called when the ad size changes.
@property(nonatomic, weak, nullable) IBOutlet id<GADAdSizeDelegate> adSizeDelegate;

@end

NS_ASSUME_NONNULL_END


text:
package org.goodsManagement.dao.impl;

import org.goodsManagement.dao.BasedaoA;
import org.goodsManagement.po.GetGoodsDto;
import org.goodsManagement.po.GoodsDto;
import org.goodsManagement.vo.GetGoodsVO;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by johnny on 2015/9/23.
 */
@Component
public class GetGoodsDaoImpl extends BasedaoA<GetGoodsDto> {
    /**
     * 通过主键删除
     *
     * @param id
     * @return
     */
    @Override
    public int deleteByPrimaryKey(Integer id) {
        return sessionTemplate.delete("org.goodsManagement.mapper.GetGoodsDtoMapper.deleteByPrimaryKey", id);
    }
    /**
     * 插入记录,必须指定所有的字段
     *
     * @param record
     * @return
     */
    @Override
    public int insert(GetGoodsDto record) {
        return sessionTemplate.insert("org.goodsManagement.mapper.GetGoodsDtoMapper.insert", record);
    }
    /**
     * 插入记录,必须指定非空的字段,但是其他字段可选
     *
     * @param record
     * @return
     */
    @Override
    public int insertSelective(GetGoodsDto record) {
        return sessionTemplate.insert("org.goodsManagement.mapper.GetGoodsDtoMapper.insertSelective", record);
    }
    /**
     * 通过主键获取实体
     *
     * @param id
     * @return
     */
    @Override
    public GetGoodsDto selectByPrimaryKey(Integer id) {
        return sessionTemplate.selectOne("org.goodsManagement.mapper.GetGoodsDtoMapper.getGoodsById", id);
    }

    /**
     * 更新实体类,不需要指定所有的键
     *
     * @param record
     * @return
     */
    @Override
    public int updateByPrimaryKeySelective(GetGoodsDto record) {
        return sessionTemplate.update("org.goodsManagement.mapper.GetGoodsDtoMapper.updateByPrimaryKeySelective", record);
    }
    /**
     * 通过主键来更新实体类
     *
     * @param record
     * @return
     */
    @Override
    public int updateByPrimaryKey(GetGoodsDto record) {
        return sessionTemplate.update("org.goodsManagement.mapper.GetGoodsDtoMapper.updateByPrimaryKey", record);
    }

    /**
     * 通过id获取页面显示信息
     * @param id 传入的id
     * @return VO用于显示
     */
    public GetGoodsVO getGoodsById(Integer id) {
        return sessionTemplate.selectOne("org.goodsManagement.mapper.GetGoodsDtoMapper.getGoodsById", id);
    }

    public List<GetGoodsVO> allGetGoodsInfo() {
        return sessionTemplate.selectList("org.goodsManagement.mapper.GetGoodsDtoMapper.allGetGoodsInfo");
    }
}