text:
"use strict";

var thrift = require('thrift');
var Thrift = thrift.Thrift;
var Q = thrift.Q;

var bean_ttypes = require('./bean_types');

var ttypes = require('./service_types');
//HELPER FUNCTIONS AND STRUCTURES

var BannerService_insert_args = function(args) {
  this.banner = null;
  if (args) {
    if (args.banner !== undefined && args.banner !== null) {
      this.banner = new bean_ttypes.Banner(args.banner);
    }
  }
};
BannerService_insert_args.prototype = {};
BannerService_insert_args.prototype.read = function(input) {
  input.readStructBegin();
  while (true)
  {
    var ret = input.readFieldBegin();
    var fname = ret.fname;
    var ftype = ret.ftype;
    var fid = ret.fid;
    if (ftype == Thrift.Type.STOP) {
      break;
    }
    switch (fid)
    {
      case 1:
      if (ftype == Thrift.Type.STRUCT) {
        this.banner = new bean_ttypes.Banner();
        this.banner.read(input);
      } else {
        input.skip(ftype);
      }
      break;
      case 0:
        input.skip(ftype);
        break;
      default:
        input.skip(ftype);
    }
    input.readFieldEnd();
  }
  input.readStructEnd();
  return;
};

BannerService_insert_args.prototype.write = function(output) {
  output.writeStructBegin('BannerService_insert_args');
  if (this.banner !== null && this.banner !== undefined) {
    output.writeFieldBegin('banner', Thrift.Type.STRUCT, 1);
    this.banner.write(output);
    output.writeFieldEnd();
  }
  output.writeFieldStop();
  output.writeStructEnd();
  return;
};

var BannerService_insert_result = function(args) {
  this.success = null;
  if (args) {
    if (args.success !== undefined && args.success !== null) {
      this.success = args.success;
    }
  }
};
BannerService_insert_result.prototype = {};
BannerService_insert_result.prototype.read = function(input) {
  input.readStructBegin();
  while (true)
  {
    var ret = input.readFieldBegin();
    var fname = ret.fname;
    var ftype = ret.ftype;
    var fid = ret.fid;
    if (ftype == Thrift.Type.STOP) {
      break;
    }
    switch (fid)
    {
      case 0:
      if (ftype == Thrift.Type.I32) {
        this.success = input.readI32();
      } else {
        input.skip(ftype);
      }
      break;
      case 0:
        input.skip(ftype);
        break;
      default:
        input.skip(ftype);
    }
    input.readFieldEnd();
  }
  input.readStructEnd();
  return;
};

BannerService_insert_result.prototype.write = function(output) {
  output.writeStructBegin('BannerService_insert_result');
  if (this.success !== null && this.success !== undefined) {
    output.writeFieldBegin('success', Thrift.Type.I32, 0);
    output.writeI32(this.success);
    output.writeFieldEnd();
  }
  output.writeFieldStop();
  output.writeStructEnd();
  return;
};

var BannerService_update_args = function(args) {
  this.banner = null;
  if (args) {
    if (args.banner !== undefined && args.banner !== null) {
      this.banner = new bean_ttypes.Banner(args.banner);
    }
  }
};
BannerService_update_args.prototype = {};
BannerService_update_args.prototype.read = function(input) {
  input.readStructBegin();
  while (true)
  {
    var ret = input.readFieldBegin();
    var fname = ret.fname;
    var ftype = ret.ftype;
    var fid = ret.fid;
    if (ftype == Thrift.Type.STOP) {
      break;
    }
    switch (fid)
    {
      case 1:
      if (ftype == Thrift.Type.STRUCT) {
        this.banner = new bean_ttypes.Banner();
        this.banner.read(input);
      } else {
        input.skip(ftype);
      }
      break;
      case 0:
        input.skip(ftype);
        break;
      default:
        input.skip(ftype);
    }
    input.readFieldEnd();
  }
  input.readStructEnd();
  return;
};

BannerService_update_args.prototype.write = function(output) {
  output.writeStructBegin('BannerService_update_args');
  if (this.banner !== null && this.banner !== undefined) {
    output.writeFieldBegin('banner', Thrift.Type.STRUCT, 1);
    this.banner.write(output);
    output.writeFieldEnd();
  }
  output.writeFieldStop();
  output.writeStructEnd();
  return;
};

var BannerService_update_result = function(args) {
  this.success = null;
  if (args) {
    if (args.success !== undefined && args.success !== null) {
      this.success = args.success;
    }
  }
};
BannerService_update_result.prototype = {};
BannerService_update_result.prototype.read = function(input) {
  input.readStructBegin();
  while (true)
  {
    var ret = input.readFieldBegin();
    var fname = ret.fname;
    var ftype = ret.ftype;
    var fid = ret.fid;
    if (ftype == Thrift.Type.STOP) {
      break;
    }
    switch (fid)
    {
      case 0:
      if (ftype == Thrift.Type.I32) {
        this.success = input.readI32();
      } else {
        input.skip(ftype);
      }
      break;
      case 0:
        input.skip(ftype);
        break;
      default:
        input.skip(ftype);
    }
    input.readFieldEnd();
  }
  input.readStructEnd();
  return;
};

BannerService_update_result.prototype.write = function(output) {
  output.writeStructBegin('BannerService_update_result');
  if (this.success !== null && this.success !== undefined) {
    output.writeFieldBegin('success', Thrift.Type.I32, 0);
    output.writeI32(this.success);
    output.writeFieldEnd();
  }
  output.writeFieldStop();
  output.writeStructEnd();
  return;
};

var BannerService_remove_args = function(args) {
  this.id = null;
  if (args) {
    if (args.id !== undefined && args.id !== null) {
      this.id = args.id;
    }
  }
};
BannerService_remove_args.prototype = {};
BannerService_remove_args.prototype.read = function(input) {
  input.readStructBegin();
  while (true)
  {
    var ret = input.readFieldBegin();
    var fname = ret.fname;
    var ftype = ret.ftype;
    var fid = ret.fid;
    if (ftype == Thrift.Type.STOP) {
      break;
    }
    switch (fid)
    {
      case 1:
      if (ftype == Thrift.Type.I32) {
        this.id = input.readI32();
      } else {
        input.skip(ftype);
      }
      break;
      case 0:
        input.skip(ftype);
        break;
      default:
        input.skip(ftype);
    }
    input.readFieldEnd();
  }
  input.readStructEnd();
  return;
};

BannerService_remove_args.prototype.write = function(output) {
  output.writeStructBegin('BannerService_remove_args');
  if (this.id !== null && this.id !== undefined) {
    output.writeFieldBegin('id', Thrift.Type.I32, 1);
    output.writeI32(this.id);
    output.writeFieldEnd();
  }
  output.writeFieldStop();
  output.writeStructEnd();
  return;
};

var BannerService_remove_result = function(args) {
  this.success = null;
  if (args) {
    if (args.success !== undefined && args.success !== null) {
      this.success = args.success;
    }
  }
};
BannerService_remove_result.prototype = {};
BannerService_remove_result.prototype.read = function(input) {
  input.readStructBegin();
  while (true)
  {
    var ret = input.readFieldBegin();
    var fname = ret.fname;
    var ftype = ret.ftype;
    var fid = ret.fid;
    if (ftype == Thrift.Type.STOP) {
      break;
    }
    switch (fid)
    {
      case 0:
      if (ftype == Thrift.Type.I32) {
        this.success = input.readI32();
      } else {
        input.skip(ftype);
      }
      break;
      case 0:
        input.skip(ftype);
        break;
      default:
        input.skip(ftype);
    }
    input.readFieldEnd();
  }
  input.readStructEnd();
  return;
};

BannerService_remove_result.prototype.write = function(output) {
  output.writeStructBegin('BannerService_remove_result');
  if (this.success !== null && this.success !== undefined) {
    output.writeFieldBegin('success', Thrift.Type.I32, 0);
    output.writeI32(this.success);
    output.writeFieldEnd();
  }
  output.writeFieldStop();
  output.writeStructEnd();
  return;
};

var BannerService_findById_args = function(args) {
  this.id = null;
  if (args) {
    if (args.id !== undefined && args.id !== null) {
      this.id = args.id;
    }
  }
};
BannerService_findById_args.prototype = {};
BannerService_findById_args.prototype.read = function(input) {
  input.readStructBegin();
  while (true)
  {
    var ret = input.readFieldBegin();
    var fname = ret.fname;
    var ftype = ret.ftype;
    var fid = ret.fid;
    if (ftype == Thrift.Type.STOP) {
      break;
    }
    switch (fid)
    {
      case 1:
      if (ftype == Thrift.Type.I32) {
        this.id = input.readI32();
      } else {
        input.skip(ftype);
      }
      break;
      case 0:
        input.skip(ftype);
        break;
      default:
        input.skip(ftype);
    }
    input.readFieldEnd();
  }
  input.readStructEnd();
  return;
};

BannerService_findById_args.prototype.write = function(output) {
  output.writeStructBegin('BannerService_findById_args');
  if (this.id !== null && this.id !== undefined) {
    output.writeFieldBegin('id', Thrift.Type.I32, 1);
    output.writeI32(this.id);
    output.writeFieldEnd();
  }
  output.writeFieldStop();
  output.writeStructEnd();
  return;
};

var BannerService_findById_result = function(args) {
  this.success = null;
  if (args) {
    if (args.success !== undefined && args.success !== null) {
      this.success = new bean_ttypes.Banner(args.success);
    }
  }
};
BannerService_findById_result.prototype = {};
BannerService_findById_result.prototype.read = function(input) {
  input.readStructBegin();
  while (true)
  {
    var ret = input.readFieldBegin();
    var fname = ret.fname;
    var ftype = ret.ftype;
    var fid = ret.fid;
    if (ftype == Thrift.Type.STOP) {
      break;
    }
    switch (fid)
    {
      case 0:
      if (ftype == Thrift.Type.STRUCT) {
        this.success = new bean_ttypes.Banner();
        this.success.read(input);
      } else {
        input.skip(ftype);
      }
      break;
      case 0:
        input.skip(ftype);
        break;
      default:
        input.skip(ftype);
    }
    input.readFieldEnd();
  }
  input.readStructEnd();
  return;
};

BannerService_findById_result.prototype.write = function(output) {
  output.writeStructBegin('BannerService_findById_result');
  if (this.success !== null && this.success !== undefined) {
    output.writeFieldBegin('success', Thrift.Type.STRUCT, 0);
    this.success.write(output);
    output.writeFieldEnd();
  }
  output.writeFieldStop();
  output.writeStructEnd();
  return;
};

var BannerService_selectAll_args = function(args) {
};
BannerService_selectAll_args.prototype = {};
BannerService_selectAll_args.prototype.read = function(input) {
  input.readStructBegin();
  while (true)
  {
    var ret = input.readFieldBegin();
    var fname = ret.fname;
    var ftype = ret.ftype;
    var fid = ret.fid;
    if (ftype == Thrift.Type.STOP) {
      break;
    }
    input.skip(ftype);
    input.readFieldEnd();
  }
  input.readStructEnd();
  return;
};

BannerService_selectAll_args.prototype.write = function(output) {
  output.writeStructBegin('BannerService_selectAll_args');
  output.writeFieldStop();
  output.writeStructEnd();
  return;
};

var BannerService_selectAll_result = function(args) {
  this.success = null;
  if (args) {
    if (args.success !== undefined && args.success !== null) {
      this.success = Thrift.copyList(args.success, [bean_ttypes.Banner]);
    }
  }
};
BannerService_selectAll_result.prototype = {};
BannerService_selectAll_result.prototype.read = function(input) {
  input.readStructBegin();
  while (true)
  {
    var ret = input.readFieldBegin();
    var fname = ret.fname;
    var ftype = ret.ftype;
    var fid = ret.fid;
    if (ftype == Thrift.Type.STOP) {
      break;
    }
    switch (fid)
    {
      case 0:
      if (ftype == Thrift.Type.LIST) {
        var _size32 = 0;
        var _rtmp336;
        this.success = [];
        var _etype35 = 0;
        _rtmp336 = input.readListBegin();
        _etype35 = _rtmp336.etype;
        _size32 = _rtmp336.size;
        for (var _i37 = 0; _i37 < _size32; ++_i37)
        {
          var elem38 = null;
          elem38 = new bean_ttypes.Banner();
          elem38.read(input);
          this.success.push(elem38);
        }
        input.readListEnd();
      } else {
        input.skip(ftype);
      }
      break;
      case 0:
        input.skip(ftype);
        break;
      default:
        input.skip(ftype);
    }
    input.readFieldEnd();
  }
  input.readStructEnd();
  return;
};

BannerService_selectAll_result.prototype.write = function(output) {
  output.writeStructBegin('BannerService_selectAll_result');
  if (this.success !== null && this.success !== undefined) {
    output.writeFieldBegin('success', Thrift.Type.LIST, 0);
    output.writeListBegin(Thrift.Type.STRUCT, this.success.length);
    for (var iter39 in this.success)
    {
      if (this.success.hasOwnProperty(iter39))
      {
        iter39 = this.success[iter39];
        iter39.write(output);
      }
    }
    output.writeListEnd();
    output.writeFieldEnd();
  }
  output.writeFieldStop();
  output.writeStructEnd();
  return;
};

var BannerService_select_args = function(args) {
  this.banner = null;
  if (args) {
    if (args.banner !== undefined && args.banner !== null) {
      this.banner = new bean_ttypes.Banner(args.banner);
    }
  }
};
BannerService_select_args.prototype = {};
BannerService_select_args.prototype.read = function(input) {
  input.readStructBegin();
  while (true)
  {
    var ret = input.readFieldBegin();
    var fname = ret.fname;
    var ftype = ret.ftype;
    var fid = ret.fid;
    if (ftype == Thrift.Type.STOP) {
      break;
    }
    switch (fid)
    {
      case 1:
      if (ftype == Thrift.Type.STRUCT) {
        this.banner = new bean_ttypes.Banner();
        this.banner.read(input);
      } else {
        input.skip(ftype);
      }
      break;
      case 0:
        input.skip(ftype);
        break;
      default:
        input.skip(ftype);
    }
    input.readFieldEnd();
  }
  input.readStructEnd();
  return;
};

BannerService_select_args.prototype.write = function(output) {
  output.writeStructBegin('BannerService_select_args');
  if (this.banner !== null && this.banner !== undefined) {
    output.writeFieldBegin('banner', Thrift.Type.STRUCT, 1);
    this.banner.write(output);
    output.writeFieldEnd();
  }
  output.writeFieldStop();
  output.writeStructEnd();
  return;
};

var BannerService_select_result = function(args) {
  this.success = null;
  if (args) {
    if (args.success !== undefined && args.success !== null) {
      this.success = Thrift.copyList(args.success, [bean_ttypes.Banner]);
    }
  }
};
BannerService_select_result.prototype = {};
BannerService_select_result.prototype.read = function(input) {
  input.readStructBegin();
  while (true)
  {
    var ret = input.readFieldBegin();
    var fname = ret.fname;
    var ftype = ret.ftype;
    var fid = ret.fid;
    if (ftype == Thrift.Type.STOP) {
      break;
    }
    switch (fid)
    {
      case 0:
      if (ftype == Thrift.Type.LIST) {
        var _size40 = 0;
        var _rtmp344;
        this.success = [];
        var _etype43 = 0;
        _rtmp344 = input.readListBegin();
        _etype43 = _rtmp344.etype;
        _size40 = _rtmp344.size;
        for (var _i45 = 0; _i45 < _size40; ++_i45)
        {
          var elem46 = null;
          elem46 = new bean_ttypes.Banner();
          elem46.read(input);
          this.success.push(elem46);
        }
        input.readListEnd();
      } else {
        input.skip(ftype);
      }
      break;
      case 0:
        input.skip(ftype);
        break;
      default:
        input.skip(ftype);
    }
    input.readFieldEnd();
  }
  input.readStructEnd();
  return;
};

BannerService_select_result.prototype.write = function(output) {
  output.writeStructBegin('BannerService_select_result');
  if (this.success !== null && this.success !== undefined) {
    output.writeFieldBegin('success', Thrift.Type.LIST, 0);
    output.writeListBegin(Thrift.Type.STRUCT, this.success.length);
    for (var iter47 in this.success)
    {
      if (this.success.hasOwnProperty(iter47))
      {
        iter47 = this.success[iter47];
        iter47.write(output);
      }
    }
    output.writeListEnd();
    output.writeFieldEnd();
  }
  output.writeFieldStop();
  output.writeStructEnd();
  return;
};

var BannerServiceClient = exports.Client = function(output, pClass) {
    this.output = output;
    this.pClass = pClass;
    this._seqid = 0;
    this._reqs = {};
};
BannerServiceClient.prototype = {};
BannerServiceClient.prototype.seqid = function() { return this._seqid; };
BannerServiceClient.prototype.new_seqid = function() { return this._seqid += 1; };
BannerServiceClient.prototype.insert = function(banner, callback) {
  this._seqid = this.new_seqid();
  if (callback === undefined) {
    var _defer = Q.defer();
    this._reqs[this.seqid()] = function(error, result) {
      if (error) {
        _defer.reject(error);
      } else {
        _defer.resolve(result);
      }
    };
    this.send_insert(banner);
    return _defer.promise;
  } else {
    this._reqs[this.seqid()] = callback;
    this.send_insert(banner);
  }
};

BannerServiceClient.prototype.send_insert = function(banner) {
  var output = new this.pClass(this.output);
  output.writeMessageBegin('insert', Thrift.MessageType.CALL, this.seqid());
  var args = new BannerService_insert_args();
  args.banner = banner;
  args.write(output);
  output.writeMessageEnd();
  return this.output.flush();
};

BannerServiceClient.prototype.recv_insert = function(input,mtype,rseqid) {
  var callback = this._reqs[rseqid] || function() {};
  delete this._reqs[rseqid];
  if (mtype == Thrift.MessageType.EXCEPTION) {
    var x = new Thrift.TApplicationException();
    x.read(input);
    input.readMessageEnd();
    return callback(x);
  }
  var result = new BannerService_insert_result();
  result.read(input);
  input.readMessageEnd();

  if (null !== result.success) {
    return callback(null, result.success);
  }
  return callback('insert failed: unknown result');
};
BannerServiceClient.prototype.update = function(banner, callback) {
  this._seqid = this.new_seqid();
  if (callback === undefined) {
    var _defer = Q.defer();
    this._reqs[this.seqid()] = function(error, result) {
      if (error) {
        _defer.reject(error);
      } else {
        _defer.resolve(result);
      }
    };
    this.send_update(banner);
    return _defer.promise;
  } else {
    this._reqs[this.seqid()] = callback;
    this.send_update(banner);
  }
};

BannerServiceClient.prototype.send_update = function(banner) {
  var output = new this.pClass(this.output);
  output.writeMessageBegin('update', Thrift.MessageType.CALL, this.seqid());
  var args = new BannerService_update_args();
  args.banner = banner;
  args.write(output);
  output.writeMessageEnd();
  return this.output.flush();
};

BannerServiceClient.prototype.recv_update = function(input,mtype,rseqid) {
  var callback = this._reqs[rseqid] || function() {};
  delete this._reqs[rseqid];
  if (mtype == Thrift.MessageType.EXCEPTION) {
    var x = new Thrift.TApplicationException();
    x.read(input);
    input.readMessageEnd();
    return callback(x);
  }
  var result = new BannerService_update_result();
  result.read(input);
  input.readMessageEnd();

  if (null !== result.success) {
    return callback(null, result.success);
  }
  return callback('update failed: unknown result');
};
BannerServiceClient.prototype.remove = function(id, callback) {
  this._seqid = this.new_seqid();
  if (callback === undefined) {
    var _defer = Q.defer();
    this._reqs[this.seqid()] = function(error, result) {
      if (error) {
        _defer.reject(error);
      } else {
        _defer.resolve(result);
      }
    };
    this.send_remove(id);
    return _defer.promise;
  } else {
    this._reqs[this.seqid()] = callback;
    this.send_remove(id);
  }
};

BannerServiceClient.prototype.send_remove = function(id) {
  var output = new this.pClass(this.output);
  output.writeMessageBegin('remove', Thrift.MessageType.CALL, this.seqid());
  var args = new BannerService_remove_args();
  args.id = id;
  args.write(output);
  output.writeMessageEnd();
  return this.output.flush();
};

BannerServiceClient.prototype.recv_remove = function(input,mtype,rseqid) {
  var callback = this._reqs[rseqid] || function() {};
  delete this._reqs[rseqid];
  if (mtype == Thrift.MessageType.EXCEPTION) {
    var x = new Thrift.TApplicationException();
    x.read(input);
    input.readMessageEnd();
    return callback(x);
  }
  var result = new BannerService_remove_result();
  result.read(input);
  input.readMessageEnd();

  if (null !== result.success) {
    return callback(null, result.success);
  }
  return callback('remove failed: unknown result');
};
BannerServiceClient.prototype.findById = function(id, callback) {
  this._seqid = this.new_seqid();
  if (callback === undefined) {
    var _defer = Q.defer();
    this._reqs[this.seqid()] = function(error, result) {
      if (error) {
        _defer.reject(error);
      } else {
        _defer.resolve(result);
      }
    };
    this.send_findById(id);
    return _defer.promise;
  } else {
    this._reqs[this.seqid()] = callback;
    this.send_findById(id);
  }
};

BannerServiceClient.prototype.send_findById = function(id) {
  var output = new this.pClass(this.output);
  output.writeMessageBegin('findById', Thrift.MessageType.CALL, this.seqid());
  var args = new BannerService_findById_args();
  args.id = id;
  args.write(output);
  output.writeMessageEnd();
  return this.output.flush();
};

BannerServiceClient.prototype.recv_findById = function(input,mtype,rseqid) {
  var callback = this._reqs[rseqid] || function() {};
  delete this._reqs[rseqid];
  if (mtype == Thrift.MessageType.EXCEPTION) {
    var x = new Thrift.TApplicationException();
    x.read(input);
    input.readMessageEnd();
    return callback(x);
  }
  var result = new BannerService_findById_result();
  result.read(input);
  input.readMessageEnd();

  if (null !== result.success) {
    return callback(null, result.success);
  }
  return callback('findById failed: unknown result');
};
BannerServiceClient.prototype.selectAll = function(callback) {
  this._seqid = this.new_seqid();
  if (callback === undefined) {
    var _defer = Q.defer();
    this._reqs[this.seqid()] = function(error, result) {
      if (error) {
        _defer.reject(error);
      } else {
        _defer.resolve(result);
      }
    };
    this.send_selectAll();
    return _defer.promise;
  } else {
    this._reqs[this.seqid()] = callback;
    this.send_selectAll();
  }
};

BannerServiceClient.prototype.send_selectAll = function() {
  var output = new this.pClass(this.output);
  output.writeMessageBegin('selectAll', Thrift.MessageType.CALL, this.seqid());
  var args = new BannerService_selectAll_args();
  args.write(output);
  output.writeMessageEnd();
  return this.output.flush();
};

BannerServiceClient.prototype.recv_selectAll = function(input,mtype,rseqid) {
  var callback = this._reqs[rseqid] || function() {};
  delete this._reqs[rseqid];
  if (mtype == Thrift.MessageType.EXCEPTION) {
    var x = new Thrift.TApplicationException();
    x.read(input);
    input.readMessageEnd();
    return callback(x);
  }
  var result = new BannerService_selectAll_result();
  result.read(input);
  input.readMessageEnd();

  if (null !== result.success) {
    return callback(null, result.success);
  }
  return callback('selectAll failed: unknown result');
};
BannerServiceClient.prototype.select = function(banner, callback) {
  this._seqid = this.new_seqid();
  if (callback === undefined) {
    var _defer = Q.defer();
    this._reqs[this.seqid()] = function(error, result) {
      if (error) {
        _defer.reject(error);
      } else {
        _defer.resolve(result);
      }
    };
    this.send_select(banner);
    return _defer.promise;
  } else {
    this._reqs[this.seqid()] = callback;
    this.send_select(banner);
  }
};

BannerServiceClient.prototype.send_select = function(banner) {
  var output = new this.pClass(this.output);
  output.writeMessageBegin('select', Thrift.MessageType.CALL, this.seqid());
  var args = new BannerService_select_args();
  args.banner = banner;
  args.write(output);
  output.writeMessageEnd();
  return this.output.flush();
};

BannerServiceClient.prototype.recv_select = function(input,mtype,rseqid) {
  var callback = this._reqs[rseqid] || function() {};
  delete this._reqs[rseqid];
  if (mtype == Thrift.MessageType.EXCEPTION) {
    var x = new Thrift.TApplicationException();
    x.read(input);
    input.readMessageEnd();
    return callback(x);
  }
  var result = new BannerService_select_result();
  result.read(input);
  input.readMessageEnd();

  if (null !== result.success) {
    return callback(null, result.success);
  }
  return callback('select failed: unknown result');
};
var BannerServiceProcessor = exports.Processor = function(handler) {
  this._handler = handler;
}
;
BannerServiceProcessor.prototype.process = function(input, output) {
  var r = input.readMessageBegin();
  if (this['process_' + r.fname]) {
    return this['process_' + r.fname].call(this, r.rseqid, input, output);
  } else {
    input.skip(Thrift.Type.STRUCT);
    input.readMessageEnd();
    var x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname);
    output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid);
    x.write(output);
    output.writeMessageEnd();
    output.flush();
  }
}
;
BannerServiceProcessor.prototype.process_insert = function(seqid, input, output) {
  var args = new BannerService_insert_args();
  args.read(input);
  input.readMessageEnd();
  if (this._handler.insert.length === 1) {
    Q.fcall(this._handler.insert, args.banner)
      .then(function(result) {
        var result_obj = new BannerService_insert_result({success: result});
        output.writeMessageBegin("insert", Thrift.MessageType.REPLY, seqid);
        result_obj.write(output);
        output.writeMessageEnd();
        output.flush();
      }, function (err) {
        var result;
        result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
        output.writeMessageBegin("insert", Thrift.MessageType.EXCEPTION, seqid);
        result.write(output);
        output.writeMessageEnd();
        output.flush();
      });
  } else {
    this._handler.insert(args.banner, function (err, result) {
      var result_obj;
      if ((err === null || typeof err === 'undefined')) {
        result_obj = new BannerService_insert_result((err !== null || typeof err === 'undefined') ? err : {success: result});
        output.writeMessageBegin("insert", Thrift.MessageType.REPLY, seqid);
      } else {
        result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
        output.writeMessageBegin("insert", Thrift.MessageType.EXCEPTION, seqid);
      }
      result_obj.write(output);
      output.writeMessageEnd();
      output.flush();
    });
  }
};
BannerServiceProcessor.prototype.process_update = function(seqid, input, output) {
  var args = new BannerService_update_args();
  args.read(input);
  input.readMessageEnd();
  if (this._handler.update.length === 1) {
    Q.fcall(this._handler.update, args.banner)
      .then(function(result) {
        var result_obj = new BannerService_update_result({success: result});
        output.writeMessageBegin("update", Thrift.MessageType.REPLY, seqid);
        result_obj.write(output);
        output.writeMessageEnd();
        output.flush();
      }, function (err) {
        var result;
        result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
        output.writeMessageBegin("update", Thrift.MessageType.EXCEPTION, seqid);
        result.write(output);
        output.writeMessageEnd();
        output.flush();
      });
  } else {
    this._handler.update(args.banner, function (err, result) {
      var result_obj;
      if ((err === null || typeof err === 'undefined')) {
        result_obj = new BannerService_update_result((err !== null || typeof err === 'undefined') ? err : {success: result});
        output.writeMessageBegin("update", Thrift.MessageType.REPLY, seqid);
      } else {
        result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
        output.writeMessageBegin("update", Thrift.MessageType.EXCEPTION, seqid);
      }
      result_obj.write(output);
      output.writeMessageEnd();
      output.flush();
    });
  }
};
BannerServiceProcessor.prototype.process_remove = function(seqid, input, output) {
  var args = new BannerService_remove_args();
  args.read(input);
  input.readMessageEnd();
  if (this._handler.remove.length === 1) {
    Q.fcall(this._handler.remove, args.id)
      .then(function(result) {
        var result_obj = new BannerService_remove_result({success: result});
        output.writeMessageBegin("remove", Thrift.MessageType.REPLY, seqid);
        result_obj.write(output);
        output.writeMessageEnd();
        output.flush();
      }, function (err) {
        var result;
        result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
        output.writeMessageBegin("remove", Thrift.MessageType.EXCEPTION, seqid);
        result.write(output);
        output.writeMessageEnd();
        output.flush();
      });
  } else {
    this._handler.remove(args.id, function (err, result) {
      var result_obj;
      if ((err === null || typeof err === 'undefined')) {
        result_obj = new BannerService_remove_result((err !== null || typeof err === 'undefined') ? err : {success: result});
        output.writeMessageBegin("remove", Thrift.MessageType.REPLY, seqid);
      } else {
        result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
        output.writeMessageBegin("remove", Thrift.MessageType.EXCEPTION, seqid);
      }
      result_obj.write(output);
      output.writeMessageEnd();
      output.flush();
    });
  }
};
BannerServiceProcessor.prototype.process_findById = function(seqid, input, output) {
  var args = new BannerService_findById_args();
  args.read(input);
  input.readMessageEnd();
  if (this._handler.findById.length === 1) {
    Q.fcall(this._handler.findById, args.id)
      .then(function(result) {
        var result_obj = new BannerService_findById_result({success: result});
        output.writeMessageBegin("findById", Thrift.MessageType.REPLY, seqid);
        result_obj.write(output);
        output.writeMessageEnd();
        output.flush();
      }, function (err) {
        var result;
        result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
        output.writeMessageBegin("findById", Thrift.MessageType.EXCEPTION, seqid);
        result.write(output);
        output.writeMessageEnd();
        output.flush();
      });
  } else {
    this._handler.findById(args.id, function (err, result) {
      var result_obj;
      if ((err === null || typeof err === 'undefined')) {
        result_obj = new BannerService_findById_result((err !== null || typeof err === 'undefined') ? err : {success: result});
        output.writeMessageBegin("findById", Thrift.MessageType.REPLY, seqid);
      } else {
        result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
        output.writeMessageBegin("findById", Thrift.MessageType.EXCEPTION, seqid);
      }
      result_obj.write(output);
      output.writeMessageEnd();
      output.flush();
    });
  }
};
BannerServiceProcessor.prototype.process_selectAll = function(seqid, input, output) {
  var args = new BannerService_selectAll_args();
  args.read(input);
  input.readMessageEnd();
  if (this._handler.selectAll.length === 0) {
    Q.fcall(this._handler.selectAll)
      .then(function(result) {
        var result_obj = new BannerService_selectAll_result({success: result});
        output.writeMessageBegin("selectAll", Thrift.MessageType.REPLY, seqid);
        result_obj.write(output);
        output.writeMessageEnd();
        output.flush();
      }, function (err) {
        var result;
        result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
        output.writeMessageBegin("selectAll", Thrift.MessageType.EXCEPTION, seqid);
        result.write(output);
        output.writeMessageEnd();
        output.flush();
      });
  } else {
    this._handler.selectAll(function (err, result) {
      var result_obj;
      if ((err === null || typeof err === 'undefined')) {
        result_obj = new BannerService_selectAll_result((err !== null || typeof err === 'undefined') ? err : {success: result});
        output.writeMessageBegin("selectAll", Thrift.MessageType.REPLY, seqid);
      } else {
        result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
        output.writeMessageBegin("selectAll", Thrift.MessageType.EXCEPTION, seqid);
      }
      result_obj.write(output);
      output.writeMessageEnd();
      output.flush();
    });
  }
};
BannerServiceProcessor.prototype.process_select = function(seqid, input, output) {
  var args = new BannerService_select_args();
  args.read(input);
  input.readMessageEnd();
  if (this._handler.select.length === 1) {
    Q.fcall(this._handler.select, args.banner)
      .then(function(result) {
        var result_obj = new BannerService_select_result({success: result});
        output.writeMessageBegin("select", Thrift.MessageType.REPLY, seqid);
        result_obj.write(output);
        output.writeMessageEnd();
        output.flush();
      }, function (err) {
        var result;
        result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
        output.writeMessageBegin("select", Thrift.MessageType.EXCEPTION, seqid);
        result.write(output);
        output.writeMessageEnd();
        output.flush();
      });
  } else {
    this._handler.select(args.banner, function (err, result) {
      var result_obj;
      if ((err === null || typeof err === 'undefined')) {
        result_obj = new BannerService_select_result((err !== null || typeof err === 'undefined') ? err : {success: result});
        output.writeMessageBegin("select", Thrift.MessageType.REPLY, seqid);
      } else {
        result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
        output.writeMessageBegin("select", Thrift.MessageType.EXCEPTION, seqid);
      }
      result_obj.write(output);
      output.writeMessageEnd();
      output.flush();
    });
  }
};


text:
package com.simpleerp.database;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class BDCore extends SQLiteOpenHelper {
    private ScriptSQL scriptSQL;
    private static final String NOME_BD = "BDSimpleERP";
    private static final int VERSAO_BD = 2;

    public BDCore(Context ctx){
        super(ctx, NOME_BD, null, VERSAO_BD);
    }

    @Override
    public void onCreate(SQLiteDatabase bd) {
        scriptSQL = new ScriptSQL();
        bd.execSQL(scriptSQL.getCreateUsuario());
        bd.execSQL(scriptSQL.getCreateInsumo());
        bd.execSQL(scriptSQL.getCreateProducao());
        bd.execSQL(scriptSQL.getCreateProducaoProduto());
        bd.execSQL(scriptSQL.getCreateProduto());
        bd.execSQL(scriptSQL.getCreateProdutoInsumo());
    }

    @Override
    public void onUpgrade(SQLiteDatabase bd, int arg1, int arg2) {
        bd.execSQL("drop table usuario;");
        onCreate(bd);
    }

}

redpajama_set_name: RedPajamaGithub


text:
<!-- start custom head snippets -->

<!-- insert favicons. use http://realfavicongenerator.net/ -->

<link rel="apple-touch-icon" sizes="180x180" href="{{ absolute_url }}/assets/images/apple-touch-icon.png">
<link rel="icon" type="image/png" href="{{ absolute_url }}/assets/images/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="{{ absolute_url }}/assets/images/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="{{ absolute_url }}/assets/images/manifest.json">
<link rel="mask-icon" href="{{ absolute_url }}/assets/images/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="{{ absolute_url }}/assets/images/favicon.ico">
<meta name="msapplication-config" content="{{ absolute_url }}/assets/images/browserconfig.xml">
<meta name="theme-color" content="#ffffff">

<!-- end custom head snippets -->


text:
set -o errexit
set -o nounset

# these can be overridden but otherwise default to the current stable image
# used to build kubernetes from the master branch
IMAGE_NAME="${IMAGE_NAME:-gcr.io/k8s-testimages/planter}"
TAG="${TAG:-0.23.0}"
IMAGE=${IMAGE:-${IMAGE_NAME}:${TAG}${CROSS+-cross}}

# We want to mount our bazel workspace and the bazel cache
# - WORKSPACE is assumed to be in your current git repo, or alternatively $PWD
REPO=$(git rev-parse --show-toplevel 2>/dev/null || true)
REPO=${REPO:-${PWD}}

# Ensure the bazel cache directory exists, as otherwise docker will create it,
# possibly with the wrong owner.
BAZEL_CACHE="${HOME}/.cache/bazel"
if [ ! -d "${BAZEL_CACHE}" ] ; then
    mkdir -p "${BAZEL_CACHE}"
fi

# Construct the set of docker run options (RUN_OPTS)
# - Don't keep the container after it exits
RUN_OPTS="--rm"
# - run interactively, which gives a better user experience
RUN_OPTS="${RUN_OPTS} -it"

# we want a fixed hostname because this leaks into the env when building
RUN_OPTS="${RUN_OPTS} --hostname=planter"

# - NOTE: SELinux disabled for this container to prevent relabeling $HOME (!)
RUN_OPTS="${RUN_OPTS} --security-opt label=disable"

# - supply the host user's `id` info so we can run as the host user and create
#   a matching environment for the purposes of building, see the Dockerfile and
#   entrypoint.sh for more details.
_UID="$(id -u "${USER}")"
_GID="$(id -g "${USER}")"
RUN_OPTS="${RUN_OPTS} --user ${_UID}:${_GID} -e GID=${_GID} -e UID=${_UID}"
# macOS has the convenient `id -F` and no getent, unix has getent
if command -v getent >/dev/null 2>&1; then
    FULL_NAME="$(getent passwd "${USER}" | cut -d : -f 5)"
else
    FULL_NAME="$(id -F "${USER}")"
fi
RUN_OPTS="${RUN_OPTS} -e USER=${USER} -e FULL_NAME='${FULL_NAME}'"
RUN_OPTS="${RUN_OPTS} -e HOME=${HOME}"

# - We mount the following folders:
# + `/tmp` which needs to be a suitable tmpfs mounted with exec so that bazel
#   can use it when executing various things
RUN_OPTS="${RUN_OPTS} --tmpfs /tmp:exec,mode=777"

# + `${HOME}/.cache/bazel` to share bazel cache across builds
RUN_OPTS="${RUN_OPTS} -v ${BAZEL_CACHE}:${BAZEL_CACHE}:delegated"

# + `${REPO}` so we can build the code in REPO
RUN_OPTS="${RUN_OPTS} -v ${REPO}:${REPO}:delegated"

# NOTE: We use the delegated option on both persistent mounts to improve
# performance on macOS. https://docs.docker.com/docker-for-mac/osxfs-caching/

# - we set the working directory to $PWD, which already must have been in $REPO
#   This needs to be set at runtime because $REPO isn't known when we build the
#   planter image.
#   $PWD specifically can also make commands other than bazel more consistent
RUN_OPTS="${RUN_OPTS} -w ${PWD}"

# Preserve GOPATH if any
if [ -n "${GOPATH:-}" ]; then
    RUN_OPTS="${RUN_OPTS} -e GOPATH=${GOPATH}"
fi

# - pass through any extra user-supplied options
if [ -n "${DOCKER_EXTRA:-}" ]; then
    RUN_OPTS="${RUN_OPTS} ${DOCKER_EXTRA}"
fi

# this is the command we will actually run
CMD="docker run ${RUN_OPTS} ${IMAGE} ${1+"$@"}"
# if not NO_PULL then including pulling the image before running
if [ -z "${NO_PULL+set}" ]; then
    CMD="docker pull ${IMAGE} && ${CMD}"
fi

# run the command or echo it if dry run
if [ -z "${DRY_RUN+set}" ]; then
    eval "${CMD}"
else
    echo "${CMD}"
fi


text:
<?
//the example of inserting data with variable from HTML form
//input.php
mysql_connect("localhost","root","");//database connection
mysql_select_db("CONJOURN");

//inserting data order
$order = "INSERT INTO profiles
			(email, twiliono,phno,location,loclat,loclong,ploclat,ploclong,dispname)
			VALUES
			('$_POST[gmailid]',
			'$_POST[tno]',
			'$_POST[phno]', null,
			 $_POST[latitude],
			 $_POST[longitude],
			 $_POST[latitude],
			 $_POST[longitude],
			'$_POST[dpname]')";

echo $order;

//declare in the order variable
$result = mysql_query($order);	//order executes
if($result){
	echo("
Account creation succeed");
        header( 'Location: index.html' ) ;

} else{
	echo("
Input data is fail");
}
?>


text:
package com.google.cloud.documentai.v1beta3.samples;

// [START documentai_v1beta3_generated_documentprocessorserviceclient_disableprocessor_async]
import com.google.api.core.ApiFuture;
import com.google.cloud.documentai.v1beta3.DisableProcessorRequest;
import com.google.cloud.documentai.v1beta3.DocumentProcessorServiceClient;
import com.google.cloud.documentai.v1beta3.ProcessorName;
import com.google.longrunning.Operation;

public class AsyncDisableProcessor {

  public static void main(String[] args) throws Exception {
    asyncDisableProcessor();
  }

  public static void asyncDisableProcessor() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (DocumentProcessorServiceClient documentProcessorServiceClient =
        DocumentProcessorServiceClient.create()) {
      DisableProcessorRequest request =
          DisableProcessorRequest.newBuilder()
              .setName(ProcessorName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
              .build();
      ApiFuture<Operation> future =
          documentProcessorServiceClient.disableProcessorCallable().futureCall(request);
      // Do something.
      Operation response = future.get();
    }
  }
}
// [END documentai_v1beta3_generated_documentprocessorserviceclient_disableprocessor_async]


text:
$(function() {
    var targets = $('[rel~=tooltip]'),
        target = false,
        tooltip = false,
        title = false,
        tip;

    targets.bind('mouseover', function() {
        target = $(this);
        tip = target.attr('title');
        tooltip = $('

');

        if (!tip || tip === '') {
            return false;
        }

        target.removeAttr('title');
        tooltip.css('opacity', 0)
            .html(tip)
            .appendTo('body');

        var initTooltip = function() {
            if ($(window).width() < tooltip.outerWidth() * 1.5) {
                tooltip.css('max-width', $(window).width() / 2);
            } else if (tip.indexOf(' ') > -1) {
                tooltip.css('max-width', 340);
            }

            var posLeft = target.offset().left + (target.outerWidth() / 2) - (tooltip.outerWidth() / 2),
                posTop = target.offset().top - tooltip.outerHeight() - 20;

            if (posLeft < 0) {
                posLeft = target.offset().left + target.outerWidth() / 2 - 20;
                tooltip.addClass('left');
            } else
                tooltip.removeClass('left');

            if (posLeft + tooltip.outerWidth() > $(window).width()) {
                posLeft = target.offset().left - tooltip.outerWidth() + target.outerWidth() / 2 + 20;
                tooltip.addClass('right');
            } else
                tooltip.removeClass('right');

            if (posTop < 0) {
                posTop = target.offset().top + target.outerHeight();
                tooltip.addClass('top');
            } else
                tooltip.removeClass('top');

            tooltip.css({
                left: posLeft,
                top: posTop
            }).animate({
                top: '+=10',
                opacity: 1
            }, 120);
        };

        initTooltip();
        $(window).resize(initTooltip);

        var removeTooltip = function() {
            tooltip.animate({
                top: '-=10',
                opacity: 0
            }, 120, function() {
                $(this).remove();
            });

            target.attr('title', tip);
        };

        target.bind('mouseout', removeTooltip);
        tooltip.bind('click', removeTooltip);
    });
});


text:
A command line interface replicating the OS X native cal utility.

Usage:

To display the current month
```
node cal.js;
```

To display a particular year
```
node cal.js 2013;
```

To display a particular month
```
node cal.js 1999 12;
```


text:
package com.sampson.yjj.xianba.weather;

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.sampson.yjj.xianba.R;
import com.sampson.yjj.xianba.db.City;
import com.sampson.yjj.xianba.db.County;
import com.sampson.yjj.xianba.db.Province;
import com.sampson.yjj.xianba.utils.OkHttpUtil;
import com.sampson.yjj.xianba.utils.Utility;

import org.litepal.crud.DataSupport;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;

/**
 * Created by yjj on 2017/6/14.
 */

public class ChooseAreaFragment extends Fragment {
    public static final int LEVEL_PROVINCE = 0;
    public static final int LEVEL_CITY = 1;
    public static final int LEVEL_COUNTY = 2;

    private ProgressDialog progressDialog;
    private TextView titleText;
    private Button backButton;
    private ListView listView;
    private ArrayAdapter<String> adapter;
    private List<String> dataList = new ArrayList<>();

    /**
     * 省列表
     */
    private List<Province> provinceList;
    /**
     * 市列表
     */
    private List<City> cityList;
    /**
     * 县列表
     */
    private  List<County> countyList;
    /**
     * 选中的省份
     */
    private Province selectedProvince;
    /**
     * 选中的城市
     */
    private City selectedCity;
    /**
     * 当前选中的级别
     */
    private int currentLevel;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.chose_area,container,false);
        titleText = (TextView) view.findViewById(R.id.title_text);
        backButton = (Button) view.findViewById(R.id.back_button);
        listView = (ListView) view.findViewById(R.id.list_view);
        adapter = new ArrayAdapter<String>(getContext(),android.R.layout.simple_list_item_1,dataList);
        listView.setAdapter(adapter);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//                Toast.makeText(getContext(),"12345",Toast.LENGTH_LONG).show();
                if(currentLevel == LEVEL_PROVINCE)
                {
                    selectedProvince = provinceList.get(position);
                    queryCities();
                }else if(currentLevel == LEVEL_CITY)
                {
                    selectedCity = cityList.get(position);
                    queryCounties();
                }
                else if (currentLevel == LEVEL_COUNTY)
                {
                    String weatherId = countyList.get(position).getWeatherId();
//                    if(getActivity() instanceof WeatherAreaActivity)
//                    {
                        Intent intent = new Intent(getActivity(), WeatherActivity.class);
//                        Toast.makeText(getContext(),weatherId,Toast.LENGTH_SHORT).show();
                        intent.putExtra("weather_id",weatherId);
                        startActivity(intent);
                        getActivity().finish();
//                    }
//                    else if(getActivity() instanceof WeatherActivity)
//                    {
//                        WeatherActivity activity = (WeatherActivity) getActivity();
////                        activity.drawerLayout.closeDrawers();
//                        activity.swipeRefresh.setRefreshing(true);
//                        activity.requestWeather(weatherId);
//                    }
                }
            }
        });
        backButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(currentLevel == LEVEL_COUNTY)
                {
//                    Toast.makeText(getContext(),"这里是城市了",Toast.LENGTH_LONG).show();

                    queryCities();
                }else if(currentLevel == LEVEL_CITY)
                {
//                    Toast.makeText(getContext(),"这历史省",Toast.LENGTH_LONG).show();

                    queryProvinces();
                }
            }
        });
        queryProvinces();
    }

    /**
     * 查询所有的省份,先从数据库查,没有从服务器
     */
    private void queryProvinces(){
        titleText.setText("中国");
        backButton.setVisibility(View.GONE);
        provinceList = DataSupport.findAll(Province.class);
        if(provinceList.size()>0)
        {
//            Toast.makeText(getContext(),"这历史省"+dataList.size(),Toast.LENGTH_LONG).show();
            dataList.clear();
            for(Province province :provinceList)
            {
                dataList.add(province.getProvinceName());
            }
            adapter.notifyDataSetChanged();
            listView.setSelection(0);
            currentLevel = LEVEL_PROVINCE;
        }else{
            String address = "http://guolin.tech/api/china";
//
            queryFromServer(address,"province");
        }
    }
    /**
     * 查询选中省的城市,先从数据库查,没有从服务器
     */
    private void queryCities(){

        titleText.setText(selectedProvince.getProvinceName());
        backButton.setVisibility(View.VISIBLE);
        cityList = DataSupport.where("provinceid = ?",String.valueOf(selectedProvince.getId())).find(City.class);
        if(cityList.size()>0)
        {
            dataList.clear();
            for(City city : cityList)
            {
                dataList.add(city.getCityName());
            }
            adapter.notifyDataSetChanged();
            listView.setSelection(0);
            currentLevel = LEVEL_CITY;
        }else{
            int provinceCode = selectedProvince.getProvinceCode();
            String address = "http://guolin.tech/api/china/"+provinceCode;
            queryFromServer(address,"city");
        }
    }
    /**
     * 查询选中市的县,先从数据库查,没有从服务器
     */
    private void queryCounties(){
        titleText.setText(selectedCity.getCityName());
        backButton.setVisibility(View.VISIBLE);
        countyList = DataSupport.where("cityid = ?",String.valueOf(selectedCity.getId())).find(County.class);
        if(countyList.size()>0)
        {
            dataList.clear();
            for(County county :countyList)
            {
                dataList.add(county.getContyName());
            }
            adapter.notifyDataSetChanged();
            listView.setSelection(0);
            currentLevel = LEVEL_COUNTY;
        }else{
            int provinceCode = selectedProvince.getProvinceCode();
            int cityCode = selectedCity.getCityCode();
            String address = "http://guolin.tech/api/china/"+provinceCode+"/"+cityCode;
            queryFromServer(address,"county");
        }
    }
    /**
     * 根据传入的地址和类型从服务器上查询数据
     */
    private void queryFromServer(String address,final String type){
        showProgressDialog();
        OkHttpUtil.sendOkHttpRequest(address, new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

                getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        closeProgressDialog();
                        Toast.makeText(getContext(),"加载失败",Toast.LENGTH_LONG).show();
                    }
                });
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String responseText =response.body().string();
                boolean result = false;
                if("province".equals(type))
                {
                    // Toast.makeText(getContext(),"tyyyyy",Toast.LENGTH_LONG).show();
//                    Log.d("tag",1111+"");
                    result = Utility.handleProvinceResponse(responseText);
//                    Toast.makeText(getContext(),"这历史省1111"+result+"",Toast.LENGTH_LONG).show();
                }else if("city".equals(type)){
                    result = Utility.handleCityResponse(responseText,selectedProvince.getId());
                }else if ("county".equals(type))
                {
                    result = Utility.handleContyResponse(responseText,selectedCity.getId());
                }
                if(result)
                {
//                    Log.d("tag","222");
                    getActivity().runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
//                            Log.d("tag","close前");
                            closeProgressDialog();
//                            Log.d("tag","close后");
                            if("province".equals(type))
                            {
//                                Log.d("tag","query前");

                                queryProvinces();
//                                Log.d("tag","query后");
                            }else if("city".equals(type))
                            {
                                queryCities();
                            }else if("county".equals(type))
                            {
                                queryCounties();
                            }
                        }
                    });
                }
            }
        });
    }
    /**
     * 显示进度对话框
     */
    private void showProgressDialog(){
        if(progressDialog == null)
        {
            progressDialog = new ProgressDialog(getActivity());
            progressDialog.setMessage("正在加载..");
            progressDialog.setCanceledOnTouchOutside(false);
        }
        progressDialog.show();
    }
    /**
     * 关闭进度对话框
     */
    private void closeProgressDialog(){
        if(progressDialog !=null)
        {
            progressDialog.dismiss();
        }
    }
}


text:
typedef void (^CCViewControllerConfigComplete)(void);
typedef void (^CCViewControllerConfigBeforeAction)(id controller);
typedef void (^CCViewControllerConfigBeforeAsyncAction)(id controller, CCViewControllerConfigComplete complete);

@interface CCBeforeAction : NSObject

@property (nonatomic, strong) NSString *name;
@property (nonatomic, readonly) BOOL isAsync;

- (id)initSyncActionWithName:(NSString *)name actionBlock:(CCViewControllerConfigBeforeAction)block;
- (id)initAsyncActionWithName:(NSString *)name actionBlock:(CCViewControllerConfigBeforeAsyncAction)block;

- (id)actionBlock;

@end


text:
var Phauxy = require('../../index');
var TextModel = require('../TextModel');

var results = null;
var textItems = Phauxy.Dictionary({
    World: new TextModel('World'),
    Galaxy: new TextModel('Galaxy'),
    Universe: new TextModel('Universe')
});

// ---

// length = 3
console.log('length = ' + textItems.length);

// ---

// Access the underlying values array, keys and keyToIndex so you can use lodash or others to enumerate the dictionary values.

// [{"text":"World"},{"text":"Galaxy"},{"text":"Universe"}]
console.log(JSON.stringify(textItems.values));
// ["World","Galaxy","Universe"]
console.log(JSON.stringify(textItems.keys));
// {"World":0,"Galaxy":1,"Universe":2}
console.log(JSON.stringify(textItems.keyToIndex));

// ---

textItems.forEach(function(model, key) {
    console.log(key + ' = ' + model.text);
});

// ---

results = textItems.map(function(model, key) {
    return model.text + '!';
});

// ["World!","Galaxy!","Universe!"]
console.log(JSON.stringify(results));

// ---

results = textItems.reduce(function(value, model, key) {
    return value + model.text + ' ~ ';
}, '');

// World ~ Galaxy ~ Universe ~
console.log(results);

// ---

// Most methods in Array.prototype. Dictionary is made to present itself as an array where possible.


text:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- From: file:/Users/Nilesh/AndroidStudioProjects/Audio/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/values-w600dp/values.xml -->
    <eat-comment/>
    <dimen name="abc_search_view_text_min_width">192dip</dimen>
    <integer name="abc_max_action_buttons">5</integer>
</resources>


text:
try:
    from Crypto.Hash import keccak
    sha3_256 = lambda x: keccak.new(digest_bits=256, data=x).digest()
    sha3_512 = lambda x: keccak.new(digest_bits=512, data=x)
except:
    import sha3 as _sha3
    sha3_256 = lambda x: _sha3.sha3_256(x).digest()
    sha3_512 = lambda x: _sha3.sha3_512(x).digest()
from rlp.utils import decode_hex, encode_hex
import sys

WORD_BYTES = 4                    # bytes in word
DATASET_BYTES_INIT = 2**30        # bytes in dataset at genesis
DATASET_BYTES_GROWTH = 2**23      # growth per epoch (~7 GB per year)
CACHE_BYTES_INIT = 2**24          # Size of the dataset relative to the cache
CACHE_BYTES_GROWTH = 2**17        # Size of the dataset relative to the cache
EPOCH_LENGTH = 30000              # blocks per epoch
MIX_BYTES = 128                   # width of mix
HASH_BYTES = 64                   # hash length in bytes
DATASET_PARENTS = 256             # number of parents of each dataset element
CACHE_ROUNDS = 3                  # number of rounds in cache production
ACCESSES = 64                     # number of accesses in hashimoto loop

FNV_PRIME = 0x01000193

def fnv(v1, v2):
    return (v1 * FNV_PRIME ^ v2) % 2**32

# Assumes little endian bit ordering (same as Intel architectures)
def decode_int(s):
    return int(encode_hex(s[::-1]), 16) if s else 0

def encode_int(s):
    a = "%x" % s
    return b'' if s == 0 else decode_hex('0' * (len(a) % 2) + a)[::-1]

def zpad(s, length):
    return s + b'\x00' * max(0, length - len(s))

def serialize_hash(h):
    return b''.join([zpad(encode_int(x), 4) for x in h])

def deserialize_hash(h):
    return [decode_int(h[i:i+WORD_BYTES]) for i in range(0, len(h), WORD_BYTES)]

def hash_words(h, sz, x):
    if isinstance(x, list):
        x = serialize_hash(x)
    y = h(x)
    return deserialize_hash(y)

def to_bytes(x):
    if sys.version_info.major > 2 and isinstance(x, str):
        x = bytes(x, 'utf-8')
    return x

# sha3 hash function, outputs 64 bytes
def sha3_512(x):
    return hash_words(sha3_512(to_bytes(v)).digest(), 64, x)

def sha3_256(x):
    return hash_words(sha3_256(to_bytes(v)).digest(), 32, x)

def xor(a, b):
    return a ^ b

# Works for dataset and cache
def serialize_cache(ds):
    return b''.join([serialize_hash(h) for h in ds])

serialize_dataset = serialize_cache

def deserialize_cache(ds):
    return [deserialize_hash(ds[i:i+HASH_BYTES])
            for i in range(0, len(ds), HASH_BYTES)]

deserialize_dataset = deserialize_cache

class ListWrapper(list):
    def __init__(self, data):
        self.data = data
        self.len = len(data) / HASH_BYTES

    def __len__(self):
        return self.len

    def __getitem__(self, i):
        if i >= self.len:
            raise Exception("listwrap access out of range")
        return deserialize_hash(self.data[i*HASH_BYTES:(i+1)*HASH_BYTES])

    def __iter__(self):
        for i in range(self.len):
            yield self[i]

    def __repr__(self):
        return repr([x for x in self])

def isprime(x):
    for i in range(2, int(x**0.5)):
        if not x % i:
            return False
    return True

def get_cache_size(block_number):
    sz = CACHE_BYTES_INIT + CACHE_BYTES_GROWTH * (block_number // EPOCH_LENGTH)
    sz -= HASH_BYTES
    while not isprime(sz / HASH_BYTES):
        sz -= 2 * HASH_BYTES
    return sz

def get_full_size(block_number):
    sz = DATASET_BYTES_INIT + DATASET_BYTES_GROWTH * (block_number // EPOCH_LENGTH)
    sz -= MIX_BYTES
    while not isprime(sz / MIX_BYTES):
        sz -= 2 * MIX_BYTES
    return sz


text:
#ifndef LIBVIRT_GO_NETWORK_PORT_COMPAT_H__
#define LIBVIRT_GO_NETWORK_PORT_COMPAT_H__

/* 5.5.0 */

#if LIBVIR_VERSION_NUMBER < 5005000
typedef struct _virNetworkPort *virNetworkPortPtr;
#endif

#ifndef VIR_NETWORK_PORT_CREATE_RECLAIM
#define VIR_NETWORK_PORT_CREATE_RECLAIM (1 << 0)
#endif

#ifndef VIR_NETWORK_PORT_BANDWIDTH_IN_AVERAGE
#define VIR_NETWORK_PORT_BANDWIDTH_IN_AVERAGE "inbound.average"
#endif

#ifndef VIR_NETWORK_PORT_BANDWIDTH_IN_PEAK
#define VIR_NETWORK_PORT_BANDWIDTH_IN_PEAK "inbound.peak"
#endif

#ifndef VIR_NETWORK_PORT_BANDWIDTH_IN_BURST
#define VIR_NETWORK_PORT_BANDWIDTH_IN_BURST "inbound.burst"
#endif

#ifndef VIR_NETWORK_PORT_BANDWIDTH_IN_FLOOR
#define VIR_NETWORK_PORT_BANDWIDTH_IN_FLOOR "inbound.floor"
#endif

#ifndef VIR_NETWORK_PORT_BANDWIDTH_OUT_AVERAGE
#define VIR_NETWORK_PORT_BANDWIDTH_OUT_AVERAGE "outbound.average"
#endif

#ifndef VIR_NETWORK_PORT_BANDWIDTH_OUT_PEAK
#define VIR_NETWORK_PORT_BANDWIDTH_OUT_PEAK "outbound.peak"
#endif

#ifndef VIR_NETWORK_PORT_BANDWIDTH_OUT_BURST
#define VIR_NETWORK_PORT_BANDWIDTH_OUT_BURST "outbound.burst"
#endif

/* 7.8.0 */

#ifndef VIR_NETWORK_PORT_CREATE_VALIDATE
#define VIR_NETWORK_PORT_CREATE_VALIDATE (1 << 1)
#endif

#endif /* LIBVIRT_GO_NETWORK_PORT_COMPAT_H__ */


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using GenericLoginFramework;

namespace GLFTestWPF
{
    /// <summary>
    /// Interaction logic for ToolboxTest.xaml
    /// </summary>
    public partial class ToolboxTest : Window
    {
        public ToolboxTest()
        {
            InitializeComponent();

            btn_facebook.Click += async (sender, e) =>
            {
                string token = btn_facebook.Token;
                User user = await GLF.Instance.GetUserFromFacebookToken(token);
                txtbx_output.Text = GLF.UserToString(user);
            };

            btn_google.Click += async (sender, e) =>
            {
                string token = btn_google.Token;
                User user = await GLF.Instance.GetUserFromGoogleToken(token);
                txtbx_output.Text = GLF.UserToString(user);
            };

            btn_generic.Click += (sender, e) =>
            {
                User user = GLF.Instance.LoginWithGeneric(btn_generic.Username, btn_generic.Password);
                txtbx_output.Text = GLF.UserToString(user);
            };
        }
    }
}


text:
#import "EC2DescribeInstancesRequestMarshaller.h"

@implementation EC2DescribeInstancesRequestMarshaller

+(AmazonServiceRequest *)createRequest:(EC2DescribeInstancesRequest *)describeInstancesRequest
{
    AmazonServiceRequest *request = [[EC2Request alloc] init];

    [request setParameterValue:@"DescribeInstances"           forKey:@"Action"];
    [request setParameterValue:@"2013-10-15"   forKey:@"Version"];

    [request setDelegate:[describeInstancesRequest delegate]];
    [request setCredentials:[describeInstancesRequest credentials]];
    [request setEndpoint:[describeInstancesRequest requestEndpoint]];
    [request setRequestTag:[describeInstancesRequest requestTag]];

    if (describeInstancesRequest != nil) {
        if (describeInstancesRequest.dryRunIsSet) {
            [request setParameterValue:(describeInstancesRequest.dryRun ? @"true":@"false") forKey:[NSString stringWithFormat:@"%@", @"DryRun"]];
        }
    }

    if (describeInstancesRequest != nil) {
        int instanceIdsListIndex = 1;
        for (NSString *instanceIdsListValue in describeInstancesRequest.instanceIds) {
            if (instanceIdsListValue != nil) {
                [request setParameterValue:[NSString stringWithFormat:@"%@", instanceIdsListValue] forKey:[NSString stringWithFormat:@"%@.%d", @"InstanceId", instanceIdsListIndex]];
            }

            instanceIdsListIndex++;
        }
    }

    if (describeInstancesRequest != nil) {
        int filtersListIndex = 1;
        for (EC2Filter *filtersListValue in describeInstancesRequest.filters) {
            if (filtersListValue != nil) {
                if (filtersListValue.name != nil) {
                    [request setParameterValue:[NSString stringWithFormat:@"%@", filtersListValue.name] forKey:[NSString stringWithFormat:@"%@.%d.%@", @"Filter", filtersListIndex, @"Name"]];
                }
            }

            if (filtersListValue != nil) {
                int valuesListIndex = 1;
                for (NSString *valuesListValue in filtersListValue.values) {
                    if (valuesListValue != nil) {
                        [request setParameterValue:[NSString stringWithFormat:@"%@", valuesListValue] forKey:[NSString stringWithFormat:@"%@.%d.%@.%d", @"Filter", filtersListIndex, @"Value", valuesListIndex]];
                    }

                    valuesListIndex++;
                }
            }

            filtersListIndex++;
        }
    }
    if (describeInstancesRequest != nil) {
        if (describeInstancesRequest.nextToken != nil) {
            [request setParameterValue:[NSString stringWithFormat:@"%@", describeInstancesRequest.nextToken] forKey:[NSString stringWithFormat:@"%@", @"NextToken"]];
        }
    }
    if (describeInstancesRequest != nil) {
        if (describeInstancesRequest.maxResults != nil) {
            [request setParameterValue:[NSString stringWithFormat:@"%@", describeInstancesRequest.maxResults] forKey:[NSString stringWithFormat:@"%@", @"MaxResults"]];
        }
    }

    return [request autorelease];
}

@end


text:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectModuleManager">
    <modules>
      <module fileurl="file://$PROJECT_DIR$/.idea/biblioteka.iml" filepath="$PROJECT_DIR$/.idea/biblioteka.iml" />
    </modules>
  </component>
</project>


text:
""" Tests for decompiling lambdas """

import unittest

from raco.python.exceptions import PythonConvertException
from raco.python.util import decompile

class TestDecompileLambdas(unittest.TestCase):
    def test_simple(self):
        s = decompile.get_source(lambda: 0)
        self.assertEquals(eval(s)(), 0)

    def test_no_space(self):
        s = decompile.get_source(lambda:0)
        self.assertEquals(eval(s)(), 0)

    def test_space_after_colon(self):
        s = decompile.get_source(lambda :0)
        self.assertEquals(eval(s)(), 0)

    def test_variable(self):
        f = lambda: 0
        s = decompile.get_source(f)
        self.assertEquals(eval(s)(), f())

    def test_newline(self):
        f = \
            lambda: 0
        s = decompile.get_source(f)
        self.assertEquals(eval(s)(), f())

    def test_newline2(self):
        f = lambda: \
            0
        s = decompile.get_source(f)
        self.assertEquals(eval(s)(), f())

    def test_tuple(self):
        t = (lambda: 0), 5
        s = decompile.get_source(t[0])
        self.assertEquals(eval(s)(), t[0]())

    def test_tuple2(self):
        f = lambda :  (0, 5)
        s = decompile.get_source(f)
        self.assertEquals(eval(s)(), f())

    def test_multiple_lambdas(self):
        t = lambda: 1, lambda: 2, lambda: 3
        for f in t:
            s = decompile.get_source(f)
            self.assertEquals(eval(s)(), f())

    def test_embedded_lambda_token(self):
        f = lambda: "lambda: 0"
        s = decompile.get_source(f)
        self.assertEquals(eval(s)(), f())

    def test_parameters(self):
        f = lambda x: x
        s = decompile.get_source(f)
        self.assertEquals(eval(s)(5), f(5))

    def test_multiple_parameters(self):
        f = lambda x, y: x + y
        s = decompile.get_source(f)
        self.assertEquals(eval(s)(5, 6), f(5, 6))

    def test_args_kwargs(self):
        f = lambda *args, **kwargs: args[0] + kwargs['foo']
        s = decompile.get_source(f)
        self.assertEqual(eval(s)(5, foo=6), f(5, foo=6))

    def test_unpacking(self):
        """ Unpacking is not currently supported """
        f = lambda (x, y): x + y
        self.assertRaises(PythonConvertException,
                          lambda: decompile.get_source(f))


text: Create a Bluetooth connect to BLE device


text:
@font-face{
    font-family: 'Fira Mono';
    src: url('eot/FiraMono-Regular.eot');
    src: local('Fira Mono'),
         url('eot/FiraMono-Regular.eot') format('embedded-opentype'),
         url('woff/FiraMono-Regular.woff') format('woff'),
         url('ttf/FiraMono-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

@font-face{
    font-family: 'Fira Mono';
    src: url('eot/FiraMono-Bold.eot');
    src: local('Fira Mono Bold'),
         url('eot/FiraMono-Bold.eot') format('embedded-opentype'),
         url('woff/FiraMono-Bold.woff') format('woff'),
         url('ttf/FiraMono-Bold.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
}


text:
package org.apache.storm.logging;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ThriftAccessLogger {
  private static final Logger LOG = LoggerFactory.getLogger(ThriftAccessLogger.class);
  public void log(String logMessage) {
    LOG.info(logMessage);
  }
}


text:
import java.util.*;

public class MultiplyStrings {

    public static void main(String[] args) {
        MultiplyStrings ms = new MultiplyStrings();
        System.out.println("Result = " + ms.multiply(args[0], args[1]));
    }

    public String multiply(String num1, String num2) {

        int len1 = num1.length();

        int len2 = num2.length();

        List<String> toSum = new ArrayList<String>();

        int maxLen = 0;

        for (int i = 0; i < len1; i++) {

            int x = Character.getNumericValue(num1.charAt(i));

            int carry = 0;

            StringBuffer total = new StringBuffer();

            for (int j = len2-1; j >= 0; j--) {

                int y = Character.getNumericValue(num2.charAt(j));

                int interim = x*y + carry;

                int value = interim % 10;

                carry = interim / 10;
                total.append(value);

            }

            if (carry > 0) {
                total.append(carry);
            }

            int numZero = len1 - 1 - i;

            for (int k = 0; k < numZero; k++) {

                total.insert(0, "0");

            }

            if (total.length() > maxLen) {

                maxLen = total.length();

            }

            toSum.add(total.toString());

        }

        return sum(toSum, maxLen);

    }

    private String sum(List<String> toSum, int maxLen) {

        StringBuffer res = new StringBuffer();

        int carry = 0;

        for (int i = 0; i < maxLen; i++) {

            int total = carry;

            for (String s : toSum) {

                if (i < s.length()) {

                    total += Character.getNumericValue(s.charAt(i));

                }

            }

            int value = total % 10;

            res.append(value);

            carry = total / 10;

        }

        String finalRes = res.reverse().toString();
        if (carry > 0) {
            finalRes = carry + finalRes;
        }

        return (finalRes.matches("^0*$")) ? "0" : finalRes;

    }

}


text:
<?php

namespace Lassi\App;

use Lassi\App\Exception\NotFoundException;
use Lassi\App\Exception\UnreadableException;

/**
 * Util
 *
 * @author Jabran Rafique <hello@jabran.me>
 * @license MIT License
 */
class Util
{

    /**
     * Set app environment variables
     *
     * @param string $root
     * @return void
     */
    public static function setEnvVariables($root = '/')
    {
        $configs = null;

        // Set custom handler to catch errors as exceptions
        set_error_handler(
            create_function(
                '$severity, $message, $file, $line',
                'throw new \ErrorException($message, $severity, $severity, $file, $line);'
            )
        );

        if (file_exists($root . '/.dev.env') && is_readable($root . '/.dev.env')) {
            $configs = file_get_contents($root . '/.dev.env');
        } else {
            if (file_exists($root . '/.dist.env') && is_readable($root . '/.dist.env')) {
                $configs = file_get_contents($root . '/.dist.env');
            } else {
                if (file_exists($root . '/.test.env') && is_readable($root . '/.test.env')) {
                    $configs = file_get_contents($root . '/.test.env');
                } else {
                    if (file_exists($root . '/.env') && is_readable($root . '/.env')) {
                        $configs = file_get_contents($root . '/.env');
                    } else {
                        throw new NotFoundException('No configuration file found.');
                    }
                }
            }
        }

        if (false === $configs || null !== error_get_last()) {
            throw new UnreadableException('Configuration not readable.');
        }

        // Restore original error handler
        restore_error_handler();

        $configs = explode("\n", trim($configs));
        array_map(function ($config) {

            // Remove whitespaces
            $config = preg_replace('(\s+)', '', $config);

            // Add as environment variables
            putenv($config);
        }, $configs);
    }
}


text:
let container = document.getElementById("container");
let breakTestFontsize = parseFloat(getComputedStyle(container).fontSize);
let nbsp = String.fromCharCode(0xA0);
nbsp = nbsp + nbsp;

class LineBreakTestElement {
  constructor(last, current) {
    let element = document.createElement('div');
    element.textContent = nbsp + String.fromCharCode(last) + String.fromCharCode(current);
    container.appendChild(element);
    this.element = element;
  }

  get canBreak() {
    return this.element.offsetHeight / breakTestFontsize > 1.9;
  }
}

class LineBreakTest {
  constructor(begin, end) {
    let rows = [];
    for (let last = begin; last < end; last++) {
      let row = [];
      for (let current = begin; current < end; current++)
        row.push(new LineBreakTestElement(last, current));
      rows.push(row);
    }
    this.begin = begin;
    this.rows = rows;
  }

  toResultString() {
    let header = [];
    for (let i = 0; i < this.rows.length; i++)
      header.push(String.fromCharCode(this.begin + i));
    let rows = ["  " + header.join("")];
    for (let i = 0; i < this.rows.length; i++) {
      let row = String.fromCharCode(this.begin + i) + " " +
          this.rows[i].map((test) => test.canBreak ? "/" : "X")
          .join("");
      rows.push(row);
    }
    return rows.join("\n");
  }
}


text:
package com.gritzer.util.math;

import org.joml.Vector2f;

public class Circle {

  private final Vector2f center;
  private final float radius;

  public Circle(final Vector2f center, float radius) {
    this.center = center;
    this.radius = radius;
  }

  public Vector2f getCenter() {
    return center;
  }

  public float getRadius() {
    return radius;
  }

}


text:
package baseContainer;

public class Stupid {

    public Stupid() { }

    public int x;
}


text:
QUnit.test( "Check if we provide the correct time format in messages", function( assert ) {
  var now  = new Date().getTime(),
  zeroHours = 1420153200000;

  assert.equal(typeof jsxc.getFormattedTime, "function", "getFormattedTime is defined and a function type")
  assert.equal(jsxc.getFormattedTime(now).length, 5, "Current time should look like: 'HH:MM'");
  assert.equal(jsxc.getFormattedTime(zeroHours).length, 16, "Do not strip zero number from string and display: 'DD.MM.YYYY HH:MM'");
});


text:
package org.apache.hadoop.hive.ql.exec.util;

import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.utils.SecurityUtils;
import org.apache.hadoop.security.UserGroupInformation;

import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

/**
 * Class to implement any retry logic in case of exceptions.
 */
public class Retryable {
  private static final long MINIMUM_DELAY_IN_SEC = 60;

  private long totalDurationInSeconds;
  private List<Class<? extends Exception>> retryOn;
  private List<Class<? extends Exception>> failOn;
  private long initialDelayInSeconds;
  private long maxRetryDelayInSeconds;
  private double backOff;
  private int maxJitterInSeconds;

  private Retryable() {
    this.retryOn = new ArrayList<>();
    this.failOn = new ArrayList<>();
    this.initialDelayInSeconds = HiveConf.toTime(HiveConf.ConfVars.REPL_RETRY_INTIAL_DELAY.defaultStrVal,
      HiveConf.getDefaultTimeUnit(HiveConf.ConfVars.REPL_RETRY_INTIAL_DELAY), TimeUnit.SECONDS);
    this.maxRetryDelayInSeconds = HiveConf.toTime(HiveConf.ConfVars.REPL_RETRY_MAX_DELAY_BETWEEN_RETRIES.defaultStrVal,
      HiveConf.getDefaultTimeUnit(HiveConf.ConfVars.REPL_RETRY_MAX_DELAY_BETWEEN_RETRIES), TimeUnit.SECONDS);
    this.backOff = HiveConf.ConfVars.REPL_RETRY_BACKOFF_COEFFICIENT.defaultFloatVal;
    this.maxJitterInSeconds = (int) HiveConf.toTime(HiveConf.ConfVars.REPL_RETRY_JITTER.defaultStrVal,
      HiveConf.getDefaultTimeUnit(HiveConf.ConfVars.REPL_RETRY_JITTER), TimeUnit.SECONDS);
    this.totalDurationInSeconds = HiveConf.toTime(HiveConf.ConfVars.REPL_RETRY_TOTAL_DURATION.defaultStrVal,
      HiveConf.getDefaultTimeUnit(HiveConf.ConfVars.REPL_RETRY_TOTAL_DURATION), TimeUnit.SECONDS);;
  }

  public static Builder builder() {
    return new Builder();
  }

  public <T> T executeCallable(Callable<T> callable) throws Exception {
    long startTime = System.currentTimeMillis();
    long delay = this.initialDelayInSeconds;
    Exception previousException = null;
    while(true) {
      try {
        if (UserGroupInformation.isSecurityEnabled()) {
          SecurityUtils.reloginExpiringKeytabUser();
          return UserGroupInformation.getLoginUser().doAs((PrivilegedExceptionAction<T>) () -> callable.call());
        } else {
          return callable.call();
        }
      } catch (Exception e) {
        if (this.failOn.stream().noneMatch(k -> e.getClass().equals(k))
          && this.retryOn.stream().anyMatch(k -> e.getClass().isAssignableFrom(k))) {
          if (elapsedTimeInSeconds(startTime) + delay > this.totalDurationInSeconds) {
            // case where waiting would go beyond max duration. So throw exception and return
            throw e;
          }
          sleep(delay);
          //retry case. compute next sleep time
          delay = getNextDelay(delay, previousException, e);
          // reset current captured exception.
          previousException = e;
        } else {
          // Exception cannot be retried on. Throw exception and return
          throw e;
        }
      }
    }
  }

  private void sleep(long seconds) {
    try {
      Thread.sleep(seconds * 1000);
    } catch (InterruptedException e) {
      // no-op.. just proceed
    }
  }

  private long getNextDelay(long currentDelay, final Exception previousException, final Exception currentException) {
    if (previousException != null && !previousException.getClass().equals(currentException.getClass())) {
      // New exception encountered. Returning initial delay for next retry.
      return this.initialDelayInSeconds;
    }
    if (currentDelay <= 0) { // in case initial delay was set to 0.
      currentDelay = MINIMUM_DELAY_IN_SEC;
    }
    currentDelay *= this.backOff;
    if (this.maxJitterInSeconds > 0) {
      currentDelay += new Random().nextInt(this.maxJitterInSeconds);
    }
    if (currentDelay > this.maxRetryDelayInSeconds) {
      currentDelay = this.maxRetryDelayInSeconds;
    }
    return  currentDelay;
  }

  private long elapsedTimeInSeconds(long fromTimeMillis) {
    return (System.currentTimeMillis() - fromTimeMillis)/ 1000;
  }

  public static class Builder {
    private final Retryable runnable = new Retryable();
    public Builder() {
    }

    public Builder withHiveConf(HiveConf conf) {
      runnable.totalDurationInSeconds = conf.getTimeVar(HiveConf.ConfVars.REPL_RETRY_TOTAL_DURATION, TimeUnit.SECONDS);
      runnable.initialDelayInSeconds = conf.getTimeVar(HiveConf.ConfVars.REPL_RETRY_INTIAL_DELAY, TimeUnit.SECONDS);
      runnable.maxRetryDelayInSeconds = conf.getTimeVar(HiveConf.ConfVars
        .REPL_RETRY_MAX_DELAY_BETWEEN_RETRIES, TimeUnit.SECONDS);
      runnable.backOff = conf.getFloatVar(HiveConf.ConfVars.REPL_RETRY_BACKOFF_COEFFICIENT);
      runnable.maxJitterInSeconds = (int) conf.getTimeVar(HiveConf.ConfVars.REPL_RETRY_JITTER, TimeUnit.SECONDS);
      return this;
    }

    public Retryable build() {
      return runnable;
    }

    public Builder withTotalDuration(long maxDuration) {
      runnable.totalDurationInSeconds = maxDuration;
      return this;
    }

    // making this thread safe as it appends to list
    public synchronized Builder withRetryOnException(final Class<? extends Exception> exceptionClass) {
      if (exceptionClass != null &&
        runnable.retryOn.stream().noneMatch(k -> exceptionClass.equals(k))) {
        runnable.retryOn.add(exceptionClass);
      }
      return this;
    }

    public synchronized Builder withRetryOnExceptionList(final List<Class<? extends Exception>> exceptionClassList) {
      for (final Class<? extends Exception> exceptionClass : exceptionClassList) {
        if (exceptionClass != null &&
          runnable.retryOn.stream().noneMatch(k -> exceptionClass.equals(k))) {
          runnable.retryOn.add(exceptionClass);
        }
      }
      return this;
    }

    public synchronized Builder withFailOnException(final Class<? extends Exception> exceptionClass) {
      if (exceptionClass != null &&
        runnable.failOn.stream().noneMatch(k -> exceptionClass.equals(k))) {
        runnable.failOn.add(exceptionClass);
      }
      return this;
    }

    public synchronized Builder withFailOnExceptionList(final List<Class<?
      extends Exception>> exceptionClassList) {
      for (final Class<? extends Exception> exceptionClass : exceptionClassList) {
        if (exceptionClass != null &&
          runnable.failOn.stream().noneMatch(k -> exceptionClass.equals(k))) {
          runnable.failOn.add(exceptionClass);
        }
      }
      return this;
    }

    public Builder withInitialDelay(long initialDelayInSeconds) {
      runnable.initialDelayInSeconds = initialDelayInSeconds;
      return this;
    }

    public Builder withMaxRetryDelay(long maxRetryDelayInSeconds) {
      runnable.maxRetryDelayInSeconds = maxRetryDelayInSeconds;
      return this;
    }

    public Builder withBackoff(double backoff) {
      runnable.backOff = backoff;
      return this;
    }

    public Builder withMaxJitterValue(int maxJitterInSeconds) {
      runnable.maxJitterInSeconds = maxJitterInSeconds;
      return this;
    }
  }
}


text:
/**
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
 */
package net.sourceforge.pmd;

public class RuleSetNotFoundException extends Exception {
    public RuleSetNotFoundException(String msg) {
        super(msg);
    }
}


text:
package org.jclouds.cloudstack.features;

import static org.jclouds.reflect.Reflection2.method;

import java.io.IOException;

import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
import org.jclouds.cloudstack.internal.BaseCloudStackApiTest;
import org.jclouds.cloudstack.options.CreateVMGroupOptions;
import org.jclouds.cloudstack.options.ListVMGroupsOptions;
import org.jclouds.cloudstack.options.UpdateVMGroupOptions;
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;

import com.google.common.base.Functions;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
 * Tests behavior of {@code VMGroupApi}
 */
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "VMGroupApiTest")
public class VMGroupApiTest extends BaseCloudStackApiTest<VMGroupApi> {

   public void testListVMGroups() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(VMGroupApi.class, "listInstanceGroups", ListVMGroupsOptions[].class);
      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());

      assertRequestLineEquals(httpRequest,
         "GET http://localhost:8080/client/api?response=json&command=listInstanceGroups&listAll=true HTTP/1.1");
      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
      assertPayloadEquals(httpRequest, null, null, false);

      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
      assertSaxResponseParserClassEquals(method, null);
      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);

      checkFilters(httpRequest);

   }

   public void testListVMGroupsOptions() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(VMGroupApi.class, "listInstanceGroups", ListVMGroupsOptions[].class);
      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListVMGroupsOptions.Builder.account("fred")
         .domainId("5").id("6")));

      assertRequestLineEquals(
         httpRequest,
         "GET http://localhost:8080/client/api?response=json&command=listInstanceGroups&listAll=true&account=fred&domainid=5&id=6 HTTP/1.1");
      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
      assertPayloadEquals(httpRequest, null, null, false);

      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
      assertSaxResponseParserClassEquals(method, null);
      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);

      checkFilters(httpRequest);

   }

   public void testGetVMGroup() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(VMGroupApi.class, "getInstanceGroup", String.class);
      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));

      assertRequestLineEquals(httpRequest,
         "GET http://localhost:8080/client/api?response=json&command=listInstanceGroups&listAll=true&id=5 HTTP/1.1");
      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
      assertPayloadEquals(httpRequest, null, null, false);

      assertResponseParserClassEquals(method, httpRequest,
         Functions.compose(IdentityFunction.INSTANCE, IdentityFunction.INSTANCE).getClass());
      assertSaxResponseParserClassEquals(method, null);
      assertFallbackClassEquals(method, NullOnNotFoundOr404.class);

      checkFilters(httpRequest);

   }

   public void testCreateVMGroup() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(VMGroupApi.class, "createInstanceGroup", String.class, CreateVMGroupOptions[].class);
      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("goo"));

      assertRequestLineEquals(httpRequest,
         "GET http://localhost:8080/client/api?response=json&command=createInstanceGroup&name=goo HTTP/1.1");
      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
      assertPayloadEquals(httpRequest, null, null, false);

      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
      assertSaxResponseParserClassEquals(method, null);
      assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);

      checkFilters(httpRequest);

   }

   public void testCreateVMGroupOptions() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(VMGroupApi.class, "createInstanceGroup", String.class, CreateVMGroupOptions[].class);
      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("goo", CreateVMGroupOptions.Builder.account("foo").domainId("42")));

      assertRequestLineEquals(httpRequest,
         "GET http://localhost:8080/client/api?response=json&command=createInstanceGroup&name=goo&account=foo&domainid=42 HTTP/1.1");
      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
      assertPayloadEquals(httpRequest, null, null, false);

      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
      assertSaxResponseParserClassEquals(method, null);
      assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);

      checkFilters(httpRequest);

   }

   public void testUpdateVMGroup() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(VMGroupApi.class, "updateInstanceGroup", String.class, UpdateVMGroupOptions[].class);
      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5, UpdateVMGroupOptions.Builder.name("fred")));

      assertRequestLineEquals(httpRequest,
         "GET http://localhost:8080/client/api?response=json&command=updateInstanceGroup&id=5&name=fred HTTP/1.1");
      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
      assertPayloadEquals(httpRequest, null, null, false);

      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
      assertSaxResponseParserClassEquals(method, null);
      assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);

      checkFilters(httpRequest);

   }

   public void testDeleteVMGroup() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(VMGroupApi.class, "deleteInstanceGroup", String.class);
      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));

      assertRequestLineEquals(httpRequest,
         "GET http://localhost:8080/client/api?response=json&command=deleteInstanceGroup&id=5 HTTP/1.1");
      assertNonPayloadHeadersEqual(httpRequest, "");
      assertPayloadEquals(httpRequest, null, null, false);

      assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
      assertSaxResponseParserClassEquals(method, null);
      assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);

      checkFilters(httpRequest);

   }
}


text:
"""
    test_config.py Copyright © 2015 by Stefan Lehmann

    Test assignment of hooks.

"""
import sys
import pytest

from PyQt5.QtWidgets import QLineEdit, QApplication
from pyqtconfig import ConfigManager
from pyqtconfig.config import _get_QLineEdit, _set_QLineEdit, _event_QLineEdit

app = QApplication(sys.argv)

def test_hook_direct():
    widget = QLineEdit()
    config = ConfigManager()
    assert config._get_hook(widget) == QLineEdit

def test_hook_inherited():
    class MyLineEdit(QLineEdit):
        pass

    widget = MyLineEdit()
    config = ConfigManager()
    assert config._get_hook(widget) == QLineEdit

def test_hook_inherited_direct():
    class MyLineEdit(QLineEdit):
        pass

    widget = MyLineEdit()
    config = ConfigManager()
    config.add_hooks(MyLineEdit, (_get_QLineEdit, _set_QLineEdit, _event_QLineEdit))
    assert config._get_hook(widget) == MyLineEdit

def test_no_hook():
    class MyTestClass:
        pass
    o = MyTestClass()
    config = ConfigManager()
    with pytest.raises(TypeError) as e:
        assert config._get_hook(o)
    assert "No handler-functions available for this" in str(e)


text:
@interface ROPhotoCollectionViewCell ()

@property (nonatomic, assign) BOOL didUpdateConstraints;

@property (nonatomic, strong) NSMutableArray *mainConstraints;

@end

@implementation ROPhotoCollectionViewCell

- (id)initWithFrame:(CGRect)frame {

    self = [super initWithFrame:frame];
    if (self) {

        [self setup];
    }
    return self;
}

- (void)setSelected:(BOOL)selected {

    id view = [self superview];

    while (view && [view isKindOfClass:[UICollectionView class]] == NO) {
        view = [view superview];
    }

    UICollectionView *collection = (UICollectionView *)view;

    [super setSelected:selected];

    [self setUserInteractionEnabled:YES];

    if ([collection allowsMultipleSelection]) {

        self.selectedImageView.hidden = !selected;
    }
}

#pragma mark - Private methods

- (void)updateConstraints {

    if (!_didUpdateConstraints) {
        _didUpdateConstraints = YES;
        [self setupConstraints];
    }
    [super updateConstraints];
}

#pragma mark - Properties init

- (UIImageView *)photoImageView {

    if (!_photoImageView) {

        _photoImageView = [UIImageView new];
        _photoImageView.clipsToBounds = YES;
        _photoImageView.contentMode = UIViewContentModeScaleAspectFill;
    }
    return _photoImageView;
}

- (UIImageView *)selectedImageView {

    if (!_selectedImageView) {

        _selectedImageView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"check"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]];
        _selectedImageView.hidden = YES;
        _selectedImageView.clipsToBounds = YES;
        _selectedImageView.contentMode = UIViewContentModeCenter;
        _selectedImageView.layer.cornerRadius = 10;
        _selectedImageView.tintColor = [[ROStyle sharedInstance] applicationBarTextColor];
        _selectedImageView.backgroundColor = [[ROStyle sharedInstance] applicationBarBackgroundColor];
    }
    return _selectedImageView;
}

- (NSMutableArray *)mainConstraints {

    if (!_mainConstraints) {

        _mainConstraints = [NSMutableArray new];
    }
    return _mainConstraints;
}

#pragma mark - Public methods

- (void)setup {

    self.backgroundView = nil;
    self.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.photoImageView];
    [self.contentView addSubview:self.selectedImageView];

    UIView *selectecedView = [[UIView alloc] init];
    selectecedView.backgroundColor = [[ROStyle sharedInstance] selectedColor];
    self.selectedBackgroundView = selectecedView;

    [self updateConstraints];
}

- (void)setupConstraints {

    [self.contentView removeConstraints:self.mainConstraints];
    [self.mainConstraints removeAllObjects];

    self.photoImageView.translatesAutoresizingMaskIntoConstraints = NO;
    self.selectedImageView.translatesAutoresizingMaskIntoConstraints = NO;

    NSDictionary *viewsBindings = @{
                                    @"photoImageView"       : self.photoImageView,
                                    @"selectedImageView"    : self.selectedImageView
                                    };

    NSDictionary *metrics = @{
                              @"margin"         : @0,
                              @"marginSelected" : @8,
                              @"checkSize"      : @20
                              };

    [self.mainConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-margin-[photoImageView]-margin-|"
                                                                                options:NSLayoutFormatDirectionLeadingToTrailing
                                                                                metrics:metrics
                                                                                views:viewsBindings]];

    [self.mainConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-margin-[photoImageView]-margin-|"
                                                                                options:NSLayoutFormatDirectionLeadingToTrailing
                                                                                metrics:metrics
                                                                                views:viewsBindings]];

    [self.mainConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[selectedImageView(checkSize)]-marginSelected-|"
                                                                                options:NSLayoutFormatDirectionLeadingToTrailing
                                                                                metrics:metrics
                                                                                views:viewsBindings]];

    [self.mainConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectedImageView(checkSize)]-marginSelected-|"
                                                                                options:NSLayoutFormatDirectionLeadingToTrailing
                                                                                metrics:metrics
                                                                                views:viewsBindings]];
    [self.contentView addConstraints:self.mainConstraints];

}

@end