data is ascending array of hashes with format: {time: epochtime, value: myvalue}
185079
def his_write(data)
      query =
        ["ver:\"#{haystack_project.haystack_version}\" id:@#{self.haystack_point_id}",'ts,val'] + data.map{ |d| "#{d[:time]},#{d[:value]}"}

      res = connection.post('hisWrite') do |req|
        req.headers['Content-Type'] = 'text/plain'
        req.body = query.join("\n")
      end

      JSON.parse(res.body)['meta']['ok'].present?
    end
1346454
def recursive_to_hash(*values)
      if values.size == 1
        value = values.first
        case value
        when String, Numeric, Symbol, TrueClass, FalseClass, NilClass, Time
          value
        when Hash
          value.inject({}) { |h, (k, v)| h.update k => recursive_to_hash(v) }
        when Array
          value.map { |v| recursive_to_hash v }
        else
          value.to_hash
        end
      else
        values.all? { |v| Type! v, Hash, NilClass }
        recursive_to_hash(values.compact.reduce { |h, v| h.merge v })
      end
    end
603
function BlockRecord(hash, height, time) {
  if (!(this instanceof BlockRecord))
    return new BlockRecord(hash, height, time);

  this.hash = hash || encoding.NULL_HASH;
  this.height = height != null ? height : -1;
  this.time = time || 0;
  this.hashes = [];
  this.index = new Set();
}
1006428
function iteratorToArray(iterator) {
        var data,
            result = [];

        while (!(data = iterator.next()).done) {
            result.push(data.value);
        }
        return result;
    }
264727
function getOrderIndependentHash(object, orderIndependent, pathCache, valueCache) {
    orderIndependent = getFunctionOption(orderIndependent);
    pathCache = pathCache || [];
    valueCache = valueCache || [];

    var accum = 0;
    var accumList = [];
    var type = realTypeOf(object);
    var i;

    if (type === 'array' || type === 'object') {
      if ((i = valueCache.indexOf(object)) !== -1) {
        return hashThisString(pathCache.slice(i).join(','));
      }
    }

    if (type === 'array') {
      var arrayString;
      if (orderIndependent(pathCache)) {
        for (i = 0; i < object.length; ++i) {
          accum += getOrderIndependentHash(object[i], orderIndependent, pathCache.concat(0), valueCache.concat([object]));
        }
        arrayString = '[type: array, hash: ' + accum + ']';
      } else {
        for (i = 0; i < object.length; ++i) {
          accumList.push(getOrderIndependentHash(object[i], orderIndependent, pathCache.concat(i), valueCache.concat([object])));
        }
        arrayString = '[type: array, hash: ' + accumList.join(', ') + ']';
      }
      return hashThisString(arrayString);
    }

    if (type === 'object') {
      var keyValueString;
      var objectString;
      var key;
      if (orderIndependent(pathCache) !== false) {
        for (key in object) {
          if (object.hasOwnProperty(key)) {
            keyValueString = 'key: ' + key + ', value hash: ' + getOrderIndependentHash(object[key], orderIndependent, pathCache.concat(key), valueCache.concat(object));
            accum += hashThisString(keyValueString);
          }
        }
        objectString = '[type: object, hash: ' + accum + ']';
      } else {
        for (key in object) {
          if (object.hasOwnProperty(key)) {
            keyValueString = 'key: ' + key + ', value hash: ' + getOrderIndependentHash(object[key], orderIndependent, pathCache.concat(key), valueCache.concat(object));
            accumList.push(hashThisString(keyValueString));
          }
        }
        objectString = '[type: object, hash: ' + accumList.join(', ') + ']';
      }
      return hashThisString(objectString);
    }

    // Non object, non array...should be good?
    var stringToHash = '[ type: ' + type + ' ; value: ' + object + ']';
    return hashThisString(stringToHash);
  }
206599
def map_sorted(hash)
      hash.keys
          .sort_by(&:to_sym)
          .map { |k| yield k, hash[k] }
    end
251488
function headerReduce(headers, format) {
    var minmtime = new Date('Sun, 23 Feb 2014 18:00:00 UTC');
    var composed = {};

    composed['Cache-Control'] = 'max-age=3600';

    switch (format) {
    case 'vector.pbf':
        composed['Content-Type'] = 'application/x-protobuf';
        composed['Content-Encoding'] = 'deflate';
        break;
    case 'jpeg':
        composed['Content-Type'] = 'image/jpeg';
        break;
    case 'png':
        composed['Content-Type'] = 'image/png';
        break;
    }

    var times = headers.reduce(function(memo, h) {
        if (!h) return memo;
        for (var k in h) if (k.toLowerCase() === 'last-modified') {
            memo.push(new Date(h[k]));
            return memo;
        }
        return memo;
    }, []);
    if (!times.length) {
        times.push(new Date());
    } else {
        times.push(minmtime);
    }
    composed['Last-Modified'] = (new Date(Math.max.apply(Math, times))).toUTCString();

    var etag = headers.reduce(function(memo, h) {
        if (!h) return memo;
        for (var k in h) if (k.toLowerCase() === 'etag') {
            memo.push(h[k]);
            return memo;
        }
        return memo;
    }, []);
    if (!etag.length) {
        composed['ETag'] = '"' + crypto.createHash('md5').update(composed['Last-Modified']).digest('hex') + '"';
    } else {
        composed['ETag'] = etag.length === 1 ? etag[0] : '"' + crypto.createHash('md5').update(etag.join(',')).digest('hex') + '"';
    }

    return composed;
}
780341
def _deserialize(type, value)
      case type.to_sym
      when :DateTime
        DateTime.parse(value)
      when :Date
        Date.parse(value)
      when :String
        value.to_s
      when :Integer
        value.to_i
      when :Float
        value.to_f
      when :BOOLEAN
        if value.to_s =~ /\A(true|t|yes|y|1)\z/i
          true
        else
          false
        end
      when :Object
        # generic object (usually a Hash), return directly
        value
      when /\AArray<(?<inner_type>.+)>\z/
        inner_type = Regexp.last_match[:inner_type]
        value.map { |v| _deserialize(inner_type, v) }
      when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
        k_type = Regexp.last_match[:k_type]
        v_type = Regexp.last_match[:v_type]
        {}.tap do |hash|
          value.each do |k, v|
            hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
          end
        end
      else # model
        temp_model = TelestreamCloud::Qc.const_get(type).new
        temp_model.build_from_hash(value)
      end
    end
446104
def serializable_hash(*options)
      super.collect do |key, value|
        if attribute_def = self.class.attr_json_registry[key.to_sym]
          key = attribute_def.store_key
          if value.kind_of?(Time) || value.kind_of?(DateTime)
            value = value.utc.change(usec: 0)
          end

          value = attribute_def.serialize(value)
        end
        # Do we need unknown key handling here? Apparently not?
        [key, value]
      end.to_h
    end
1239763
def to_array(self):
        
        values = numpy.empty(13, dtype=float)
        values[:6] = self.firstdate.to_array()
        values[6:12] = self.lastdate.to_array()
        values[12] = self.stepsize.seconds
        return values
47481
function hashJson(data, algorithm) {
    return Q.Promise(function (resolve, reject) {
        try {
            resolve(hashJsonSync(data, algorithm));
        }
        catch (error) {
            reject(error);
        }
    });
}
815206
function (names) {
        this.names = Object.keys(names); // store the keys
        this.hash = util.map(names, function (value) { // store values for corresponding keys
            return parseInt(value, 10);
        });
    }
753854
def to_h
      @raw.reduce(Hash.new(0)) do |acc, elem|
        acc.merge(elem.date => elem.score)
      end
    end
1227163
function toArray(id, time) {
  var o = [
    id,
    Math.round(this._now / 1000),
    time,
    this._cmd];
  return o;
}
221373
def stringify( hash )

            keys = @sorted ? hash.keys.sort : hash.keys
            vals = keys.map{ |key|
                val = ''
                if hash[key].kind_of?( Array ) 
                    val = rotate( hash[key] )
                elsif hash[key].kind_of?( Hash )
                    val = @sorted ? hash[key].keys.sort[0] : hash[key].keys[0]
                else
                    val = hash[key]
                end
                "#{key}: #{val}"
            }
            return vals.join( '; ' ) + (vals.length ? ';' : '')

        end
1253602
function ( data ) {
	    	if ( !data ) return data;
	    	if ( typeof data !== 'object' ) return data;
	    	if ( 'entrySet' in data && typeof data.entrySet === 'function' ) {
	    		//var allowed_long_keys = ['utc_timestamp', 'duration', 'type', 'token'];
	    		var set = data.entrySet();
	    		if ( !set ) return data;
	    		var obj = {};
	    		var iter = set.iterator();
	    		while ( iter.hasNext() ) {
					var entry = iter.next();
					var val = entry.getValue();
					if ( val && typeof val === 'object' && 
						 'entrySet' in val && 
						 typeof val.entrySet === 'function' ) val = convertData(val);
					var key = entry.getKey();
					if ( !key ) {
						throw( "Field key is not valid: " + key );
					}
					obj[entry.getKey()] = val;
				}
				return obj;
	    	} else {
	    		if ( 'utc_timestamp' in data ) data.utc_timestamp = jsDateToTs(data.utc_timestamp);
	    		if ( 'created_at' in data )    data.created_at 	  = jsDateToTs(data.created_at);
	    	}
	    	return data;
	    }
31477
def to_h
      hash = {}
      @data.each_pair do |key, value|
        hash[key] = value.to_h
      end
      
      hash      
    end