text:
package org.jsimpledb.kv.sql;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * {@link SQLKVDatabase} transaction.
 */
class MySQLKVTransaction extends SQLKVTransaction {

    MySQLKVTransaction(SQLKVDatabase database, Connection connection) throws SQLException {
        super(database, connection);
    }

    @Override
    public void setTimeout(long timeout) {
        super.setTimeout(timeout);
        try {
            final Statement statement = this.connection.createStatement();
            statement.execute("SET innodb_lock_wait_timeout = " + (timeout + 999) / 1000);
            statement.close();
        } catch (SQLException e) {
            throw this.handleException(e);
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
var appRemote
,assert = require('assert')
,spawn = require('child_process').spawn
,exec = require('child_process').exec
,should = require('should')
,config = require('./fixtures/config')
,async = require('async')
,appLocal
,appRemote
,siprequest ;

describe('accept invites', function() {
    this.timeout(4000) ;
    before(function(done){
       appRemote = require('../../examples/uas-success/app') ;
        appRemote.on('connect', function() {
            appLocal = require('../..')() ;
            siprequest = appLocal.siprequest
            appLocal.connect(config.connect_opts, function(err){
                done() ;
            });
        }) ;
    }) ;
    after(function(done){
        appLocal.disconnect() ;
        appRemote.disconnect() ;
        done() ;
    }) ;

    it('must be able to connect simple uac - uas call', function(done) {
        this.timeout(5000) ;
        async.parallel([
            function local( callback ){
                siprequest(config.request_uri, {
                    body: config.sdp
                }, function( err, req, res ) {
                    res.ack() ;

                    should.not.exist(err) ;
                    res.should.have.property('statusCode',200);
                    res.should.have.property('body') ;
                    res.headers['content-type'].should.have.property('type','application/sdp') ;
                    res.headers.should.have.property('content-length') ;

                    setTimeout( function() {
                        siprequest.bye({headers:{'call-id': res.get('call-id')}}, function() {
                            callback() ;
                        }) ;
                    }, 100);
                }) ;
            }
            ,function remote( callback ) {
                appRemote.bye(function(req,res){
                    res.send(200) ;
                    callback();
                }) ;
            }
            ]
            ,function() {
                appLocal.idle.should.be.true ;
                appRemote.idle.should.be.true ;
                done() ;
            }
         ) ;
    }) ;
}) ;


text:
package leap.web.format;

import leap.core.AppException;

public class InvalidFormatContentException extends AppException {

	private static final long serialVersionUID = 4068516922508729605L;

	public InvalidFormatContentException() {
	}

	public InvalidFormatContentException(String message) {
		super(message);
	}

	public InvalidFormatContentException(Throwable cause) {
		super(cause);
	}

	public InvalidFormatContentException(String message, Throwable cause) {
		super(message, cause);
	}

}


text:
package de.hub.emffrag.model.emffrag.provider;

import de.hub.emffrag.model.emffrag.util.EmfFragAdapterFactory;

import java.util.ArrayList;
import java.util.Collection;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;

import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemColorProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;

/**
 * This is the factory that is used to provide the interfaces needed to support Viewers.
 * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
 * The adapters also support Eclipse property sheets.
 * Note that most of the adapters are shared among multiple instances.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class EmfFragItemProviderAdapterFactory extends EmfFragAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
	/**
	 * This keeps track of the root adapter factory that delegates to this adapter factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComposedAdapterFactory parentAdapterFactory;

	/**
	 * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IChangeNotifier changeNotifier = new ChangeNotifier();

	/**
	 * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Collection<Object> supportedTypes = new ArrayList<Object>();

	/**
	 * This constructs an instance.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EmfFragItemProviderAdapterFactory() {
		supportedTypes.add(IEditingDomainItemProvider.class);
		supportedTypes.add(IStructuredItemContentProvider.class);
		supportedTypes.add(ITreeItemContentProvider.class);
		supportedTypes.add(IItemLabelProvider.class);
		supportedTypes.add(IItemPropertySource.class);
		supportedTypes.add(IItemColorProvider.class);
	}

	/**
	 * This keeps track of the one adapter used for all {@link de.hub.emffrag.model.emffrag.IndexedMap} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IndexedMapItemProvider indexedMapItemProvider;

	/**
	 * This creates an adapter for a {@link de.hub.emffrag.model.emffrag.IndexedMap}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createIndexedMapAdapter() {
		if (indexedMapItemProvider == null) {
			indexedMapItemProvider = new IndexedMapItemProvider(this);
		}

		return indexedMapItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link de.hub.emffrag.model.emffrag.IndexedList} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IndexedListItemProvider indexedListItemProvider;

	/**
	 * This creates an adapter for a {@link de.hub.emffrag.model.emffrag.IndexedList}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createIndexedListAdapter() {
		if (indexedListItemProvider == null) {
			indexedListItemProvider = new IndexedListItemProvider(this);
		}

		return indexedListItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link de.hub.emffrag.model.emffrag.ContainmentIndexedMap} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ContainmentIndexedMapItemProvider containmentIndexedMapItemProvider;

	/**
	 * This creates an adapter for a {@link de.hub.emffrag.model.emffrag.ContainmentIndexedMap}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createContainmentIndexedMapAdapter() {
		if (containmentIndexedMapItemProvider == null) {
			containmentIndexedMapItemProvider = new ContainmentIndexedMapItemProvider(this);
		}

		return containmentIndexedMapItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link de.hub.emffrag.model.emffrag.Root} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RootItemProvider rootItemProvider;

	/**
	 * This creates an adapter for a {@link de.hub.emffrag.model.emffrag.Root}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createRootAdapter() {
		if (rootItemProvider == null) {
			rootItemProvider = new RootItemProvider(this);
		}

		return rootItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link de.hub.emffrag.model.emffrag.Statistics} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected StatisticsItemProvider statisticsItemProvider;

	/**
	 * This creates an adapter for a {@link de.hub.emffrag.model.emffrag.Statistics}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createStatisticsAdapter() {
		if (statisticsItemProvider == null) {
			statisticsItemProvider = new StatisticsItemProvider(this);
		}

		return statisticsItemProvider;
	}

	/**
	 * This returns the root adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComposeableAdapterFactory getRootAdapterFactory() {
		return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
	}

	/**
	 * This sets the composed adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
		this.parentAdapterFactory = parentAdapterFactory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean isFactoryForType(Object type) {
		return supportedTypes.contains(type) || super.isFactoryForType(type);
	}

	/**
	 * This implementation substitutes the factory itself as the key for the adapter.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter adapt(Notifier notifier, Object type) {
		return super.adapt(notifier, this);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object adapt(Object object, Object type) {
		if (isFactoryForType(type)) {
			Object adapter = super.adapt(object, type);
			if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) {
				return adapter;
			}
		}

		return null;
	}

	/**
	 * This adds a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void addListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.addListener(notifyChangedListener);
	}

	/**
	 * This removes a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void removeListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.removeListener(notifyChangedListener);
	}

	/**
	 * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void fireNotifyChanged(Notification notification) {
		changeNotifier.fireNotifyChanged(notification);

		if (parentAdapterFactory != null) {
			parentAdapterFactory.fireNotifyChanged(notification);
		}
	}

	/**
	 * This disposes all of the item providers created by this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void dispose() {
		if (indexedMapItemProvider != null) indexedMapItemProvider.dispose();
		if (indexedListItemProvider != null) indexedListItemProvider.dispose();
		if (containmentIndexedMapItemProvider != null) containmentIndexedMapItemProvider.dispose();
		if (rootItemProvider != null) rootItemProvider.dispose();
		if (statisticsItemProvider != null) statisticsItemProvider.dispose();
	}

}


text:
package java.lang;

public class ClassCircularityError
  extends LinkageError{
  // Constructors

  public ClassCircularityError(){
    super();
  }
  public ClassCircularityError(String arg1){
    super();
  }
}


text: ember install ember-leaflet-draw


text:
using System.Linq;

namespace System.Windows
{
    /// <summary>
    ///     Specifies on which thread a <see cref="CompositePresentationEvent{TPayload}" /> subscriber will be called.
    /// </summary>
    public enum ThreadOption
    {
        /// <summary>
        ///     The call is done on the same thread on which the <see cref="CompositePresentationEvent{TPayload}" /> was published.
        /// </summary>
        PublisherThread,

        /// <summary>
        ///     The call is done on the UI thread.
        /// </summary>
        UIThread,

        /// <summary>
        ///     The call is done asynchronously on a background thread.
        /// </summary>
        BackgroundThread
    }

    /// <summary>
    ///     Defines a class that manages publication and subscription to events.
    /// </summary>
    /// <typeparam name="TPayload">The type of message that will be passed to the subscribers.</typeparam>
    public class CompositePresentationEvent<TPayload> : EventBase
    {
        #region Public Methods

        /// <summary>
        ///     Returns <see langword="true" /> if there is a subscriber matching <seealso cref="Action{TPayload}" />.
        /// </summary>
        /// <param name="subscriber">The <see cref="Action{TPayload}" /> used when subscribing to the event.</param>
        /// <returns>
        ///     <see langword="true" /> if there is an <seealso cref="Action{TPayload}" /> that matches; otherwise
        ///     <see langword="false" />.
        /// </returns>
        public virtual bool Contains(Action<TPayload> subscriber)
        {
            IEventSubscription eventSubscription;
            lock (Subscriptions)
            {
                eventSubscription = Subscriptions.Cast<EventSubscription<TPayload>>().FirstOrDefault(evt => evt.Action == subscriber);
            }
            return eventSubscription != null;
        }

        /// <summary>
        ///     Publishes the <see cref="CompositePresentationEvent{TPayload}" />.
        /// </summary>
        /// <param name="payload">Message to pass to the subscribers.</param>
        public virtual void Publish(TPayload payload)
        {
            base.InternalPublish(payload);
        }

        /// <summary>
        ///     Subscribes a delegate to an event that will be published on the <see cref="ThreadOption.PublisherThread" />.
        ///     <see cref="CompositePresentationEvent{TPayload}" /> will maintain a <seealso cref="WeakReference" /> to the target
        ///     of the supplied <paramref name="action" /> delegate.
        /// </summary>
        /// <param name="action">The delegate that gets executed when the event is published.</param>
        /// <returns>A <see cref="SubscriptionToken" /> that uniquely identifies the added subscription.</returns>
        /// <remarks>
        ///     The CompositePresentationEvent collection is thread-safe.
        /// </remarks>
        public SubscriptionToken Subscribe(Action<TPayload> action)
        {
            return Subscribe(action, ThreadOption.PublisherThread);
        }

        /// <summary>
        ///     Subscribes a delegate to an event.
        ///     CompositePresentationEvent will maintain a <seealso cref="WeakReference" /> to the Target of the supplied
        ///     <paramref name="action" /> delegate.
        /// </summary>
        /// <param name="action">The delegate that gets executed when the event is raised.</param>
        /// <param name="threadOption">Specifies on which thread to receive the delegate callback.</param>
        /// <returns>A <see cref="SubscriptionToken" /> that uniquely identifies the added subscription.</returns>
        /// <remarks>
        ///     The CompositePresentationEvent collection is thread-safe.
        /// </remarks>
        public SubscriptionToken Subscribe(Action<TPayload> action, ThreadOption threadOption)
        {
            return Subscribe(action, threadOption, false);
        }

        /// <summary>
        ///     Subscribes a delegate to an event that will be published on the <see cref="ThreadOption.PublisherThread" />.
        /// </summary>
        /// <param name="action">The delegate that gets executed when the event is published.</param>
        /// <param name="keepSubscriberReferenceAlive">
        ///     When <see langword="true" />, the
        ///     <seealso cref="CompositePresentationEvent{TPayload}" /> keeps a reference to the subscriber so it does not get
        ///     garbage collected.
        /// </param>
        /// <returns>A <see cref="SubscriptionToken" /> that uniquely identifies the added subscription.</returns>
        /// <remarks>
        ///     If <paramref name="keepSubscriberReferenceAlive" /> is set to <see langword="false" />,
        ///     <see cref="CompositePresentationEvent{TPayload}" /> will maintain a <seealso cref="WeakReference" /> to the Target
        ///     of the supplied <paramref name="action" /> delegate.
        ///     If not using a WeakReference (<paramref name="keepSubscriberReferenceAlive" /> is <see langword="true" />), the
        ///     user must explicitly call Unsubscribe for the event when disposing the subscriber in order to avoid memory leaks or
        ///     unexepcted behavior.
        ///     <para />
        ///     The CompositePresentationEvent collection is thread-safe.
        /// </remarks>
        public SubscriptionToken Subscribe(Action<TPayload> action, bool keepSubscriberReferenceAlive)
        {
            return Subscribe(action, ThreadOption.PublisherThread, keepSubscriberReferenceAlive);
        }

        /// <summary>
        ///     Subscribes a delegate to an event.
        /// </summary>
        /// <param name="action">The delegate that gets executed when the event is published.</param>
        /// <param name="threadOption">Specifies on which thread to receive the delegate callback.</param>
        /// <param name="keepSubscriberReferenceAlive">
        ///     When <see langword="true" />, the
        ///     <seealso cref="CompositePresentationEvent{TPayload}" /> keeps a reference to the subscriber so it does not get
        ///     garbage collected.
        /// </param>
        /// <returns>A <see cref="SubscriptionToken" /> that uniquely identifies the added subscription.</returns>
        /// <remarks>
        ///     If <paramref name="keepSubscriberReferenceAlive" /> is set to <see langword="false" />,
        ///     <see cref="CompositePresentationEvent{TPayload}" /> will maintain a <seealso cref="WeakReference" /> to the Target
        ///     of the supplied <paramref name="action" /> delegate.
        ///     If not using a WeakReference (<paramref name="keepSubscriberReferenceAlive" /> is <see langword="true" />), the
        ///     user must explicitly call Unsubscribe for the event when disposing the subscriber in order to avoid memory leaks or
        ///     unexepcted behavior.
        ///     <para />
        ///     The CompositePresentationEvent collection is thread-safe.
        /// </remarks>
        public SubscriptionToken Subscribe(Action<TPayload> action, ThreadOption threadOption, bool keepSubscriberReferenceAlive)
        {
            return Subscribe(action, threadOption, keepSubscriberReferenceAlive, null);
        }

        /// <summary>
        ///     Subscribes a delegate to an event.
        /// </summary>
        /// <param name="action">The delegate that gets executed when the event is published.</param>
        /// <param name="threadOption">Specifies on which thread to receive the delegate callback.</param>
        /// <param name="keepSubscriberReferenceAlive">
        ///     When <see langword="true" />, the
        ///     <seealso cref="CompositePresentationEvent{TPayload}" /> keeps a reference to the subscriber so it does not get
        ///     garbage collected.
        /// </param>
        /// <param name="filter">Filter to evaluate if the subscriber should receive the event.</param>
        /// <returns>A <see cref="SubscriptionToken" /> that uniquely identifies the added subscription.</returns>
        /// <remarks>
        ///     If <paramref name="keepSubscriberReferenceAlive" /> is set to <see langword="false" />,
        ///     <see cref="CompositePresentationEvent{TPayload}" /> will maintain a <seealso cref="WeakReference" /> to the Target
        ///     of the supplied <paramref name="action" /> delegate.
        ///     If not using a WeakReference (<paramref name="keepSubscriberReferenceAlive" /> is <see langword="true" />), the
        ///     user must explicitly call Unsubscribe for the event when disposing the subscriber in order to avoid memory leaks or
        ///     unexepcted behavior.
        ///     The CompositePresentationEvent collection is thread-safe.
        /// </remarks>
        public virtual SubscriptionToken Subscribe(Action<TPayload> action, ThreadOption threadOption, bool keepSubscriberReferenceAlive, Predicate<TPayload> filter)
        {
            IDelegateReference actionReference = new DelegateReference(action, keepSubscriberReferenceAlive);

            IDelegateReference filterReference;
            if (filter != null)
            {
                filterReference = new DelegateReference(filter, keepSubscriberReferenceAlive);
            }
            else
            {
                filterReference = new DelegateReference(new Predicate<TPayload>(delegate { return true; }), true);
            }

            EventSubscription<TPayload> subscription;
            switch (threadOption)
            {
                case ThreadOption.BackgroundThread:
                    subscription = new BackgroundEventSubscription<TPayload>(actionReference, filterReference);
                    break;
                case ThreadOption.UIThread:
                    subscription = new DispatcherEventSubscription<TPayload>(actionReference, filterReference, SynchronizationContext);
                    break;
                default:
                    subscription = new EventSubscription<TPayload>(actionReference, filterReference);
                    break;
            }

            return base.InternalSubscribe(subscription);
        }

        /// <summary>
        ///     Removes the first subscriber matching <seealso cref="Action{TPayload}" /> from the subscribers' list.
        /// </summary>
        /// <param name="subscriber">The <see cref="Action{TPayload}" /> used when subscribing to the event.</param>
        public virtual void Unsubscribe(Action<TPayload> subscriber)
        {
            lock (Subscriptions)
            {
                IEventSubscription eventSubscription = Subscriptions.Cast<EventSubscription<TPayload>>().FirstOrDefault(evt => evt.Action == subscriber);
                if (eventSubscription != null)
                {
                    Subscriptions.Remove(eventSubscription);
                }
            }
        }

        #endregion
    }
}


text:
import { Column, Entity, PrimaryGeneratedColumn } from "../../../../src/index"

@Entity()
export class User {
    @PrimaryGeneratedColumn()
    id: number

    @Column()
    name: string
}


text:
import scala.io.Source

object FunctionOrNot extends App {
  val lines = Source.stdin.getLines().toList
  val tests = lines.head.toInt
  val parts = lines.tail.partition(!_.contains(" "))
  val counts = parts._1.map(_.toInt)
  val pairs = parts._2.map(_.split(" ")).map(arr => Tuple2(arr(0).toInt, arr(1).toInt))
  var start = 0
  counts.foreach {
    i => {
      val p = pairs.slice(start, start + i)
      start = start + i
      println(if(isFunction(p)) "YES" else "NO")
    }
  }

  def isFunction(rel: List[(Int, Int)]): Boolean = {
    val groupByX = rel.groupBy(_._1)
    val filteredMoreThanOne =
      groupByX.filter(p => p._2.size > 1)
    filteredMoreThanOne.forall(_._2.map(_._2).distinct == 1)
  }
}


text:
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util;

import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * Utility wrappers for accessing system properties.
 *
 * @see com.intellij.openapi.util.SystemInfo
 */
public final class SystemProperties {
  private SystemProperties() { }

  public static @NotNull String getUserHome() {
    return System.getProperty("user.home");
  }

  public static @NotNull String getUserName() {
    return System.getProperty("user.name");
  }

  public static @NotNull String getJavaHome() {
    return System.getProperty("java.home");
  }

  /**
   * Returns a value of the given property as an integer, or {@code defaultValue} if the property is not specified or malformed.
   */
  public static int getIntProperty(@NotNull String key, int defaultValue) {
    String value = System.getProperty(key);
    if (value != null) {
      try { return Integer.parseInt(value); }
      catch (NumberFormatException ignored) { }
    }
    return defaultValue;
  }

  /**
   * Returns a value of the given property as a long, or {@code defaultValue} if the property is not specified or malformed.
   */
  public static long getLongProperty(@NotNull String key, long defaultValue) {
    String value = System.getProperty(key);
    if (value != null) {
      try { return Long.parseLong(value); }
      catch (NumberFormatException ignored) { }
    }
    return defaultValue;
  }

  /**
   * Returns a value of the given property as a float, or {@code defaultValue} if the property is not specified or malformed.
   */
  public static float getFloatProperty(@NotNull String key, float defaultValue) {
    String value = System.getProperty(key);
    if (value != null) {
      try { return Float.parseFloat(value); }
      catch (NumberFormatException ignored) { }
    }
    return defaultValue;
  }

  /**
   * Returns a value of the given property as a boolean, or {@code defaultValue} if the property is not specified or malformed.
   */
  public static boolean getBooleanProperty(@NotNull String key, boolean defaultValue) {
    String value = System.getProperty(key);
    return value != null ? Boolean.parseBoolean(value) : defaultValue;
  }

  /**
   * Sets (or clears, when the {@code value} is {@code null}) the given property, and returns a previous value.
   */
  public static @Nullable String setProperty(@NotNull String key, @Nullable String value) {
    return value != null ? System.setProperty(key, value) : System.clearProperty(key);
  }

  //<editor-fold desc="Deprecated stuff.">
  /** @deprecated please use {@link Boolean#getBoolean(String)} or {@link #getBooleanProperty(String, boolean)} instead */
  @Deprecated
  @ApiStatus.ScheduledForRemoval
  public static boolean is(String key) {
    return getBooleanProperty(key, false);
  }

  /** @deprecated please use {@link System#lineSeparator()} instead */
  @Deprecated
  @ApiStatus.ScheduledForRemoval
  public static String getLineSeparator() {
    return System.lineSeparator();
  }

  //</editor-fold>
}


text:
namespace ZhAsoiafWiki.Plus.Models
{
    public class Article
    {
        public int Id { get; set; }

        public int Namespace { get; set; }

        public string Title { get; set; }

        public string Abstract { get; set; }

        public string Uri { get; set; }

        public string ImageUri { get; set; }

        public int ImageWidth { get; set; }

        public int ImageHeight { get; set; }
    }
}


text:
var cpuGauge,
	memoryGauge,
	CPU_THRESHOLD = 50,
	MEM_THRESHOLD = 80,
	MAX_CPU_UTILIZATION = 100,
	STROKE_COLOR = '#E0E0E0',
	SAFE_COLOR = '#5596E6',
	DANGER_COLOR = '#FF5050';

// Initializes the gauge meter
function initGauge(isMem, gauge, initialVal, maxVal, gaugeElement, gaugeTextElement) {
	// If memory gauge
	if (isMem) {
		// If value is under threshold, set gauge color to green. Otherwise, set to red
		if (initialVal < MEM_THRESHOLD)
			newColor = SAFE_COLOR;
		else
			newColor = DANGER_COLOR;
	}
		// If CPU gauge
	else {
		// If value is under threshold, set gauge color to green. Otherwise, set to red
		if (initialVal < CPU_THRESHOLD)
			newColor = SAFE_COLOR;
		else
			newColor = DANGER_COLOR;
	}

	var initialOptions = {
		lines: 20, // The number of lines to draw
		angle: 0, // The angle of the ends of the gauge
		lineWidth: 0.45, // The thickness of the lines that make up the gauge semi-circle
		pointer: {
			length: .85, // The length of the pointer
			strokeWidth: 0.025, // The width of the pointer
			color: 'black'
		},
		limitMax: 'true',   // If true, the pointer will not go past the end of the gauge
		colorStart: newColor, // Color of the outer gauge
		colorStop: newColor, // Color of the inner gauge
		strokeColor: STROKE_COLOR,   // Color of the pointer
		generateGradient: true
	}
	gauge = new Gauge(document.getElementById(gaugeElement)).setOptions(initialOptions);
	gauge.setTextField(document.getElementById(gaugeTextElement));
	gauge.maxValue = maxVal;
	gauge.animationSpeed = 32;
	gauge.set(initialVal);
	return gauge;
};

// Update gauge values
function updateGauge(checkMem, gauge, curVal) {
	gauge.set(curVal);

	var newColor;
	// If memory gauge
	if (checkMem) {
		// If value is under threshold, set gauge color to green. Otherwise, set to red
		if (curVal < MEM_THRESHOLD)
			newColor = SAFE_COLOR;
		else
			newColor = DANGER_COLOR;
	}
		// If CPU gauge
	else {
		// If value is under threshold, set gauge color to green. Otherwise, set to red
		if (curVal < CPU_THRESHOLD)
			newColor = SAFE_COLOR;
		else
			newColor = DANGER_COLOR;
	}

	// Set updated options for gauge
	var updatedOptions = {
		lines: 20,
		angle: 0,
		lineWidth: 0.45,
		pointer: {
			length: .85,
			strokeWidth: 0.025,
			color: 'black'
		},
		limitMax: 'true',
		colorStart: newColor,
		colorStop: newColor,
		strokeColor: STROKE_COLOR,
		generateGradient: true
	}

	gauge.setOptions(updatedOptions);

	return gauge;
}

// Defines the prototype for the gauge options
var optionsPrototype = {
	lines: 20, // The number of lines to draw
	angle: 0, // The length of each line
	lineWidth: 0.45, // The line thickness
	pointer: {
		length: .85, // The radius of the inner circle
		strokeWidth: 0.025, // The rotation offset
		color: 'black' // Fill color
	},
	limitMax: 'true',   // If true, the pointer will not go past the end of the gauge
	colorStart: SAFE_COLOR,   // Colors
	colorStop: SAFE_COLOR,    // just experiment with them
	strokeColor: STROKE_COLOR,   // to see which ones work best for you
	generateGradient: true
}

// Options object constructor
function Options (){}
Options.prototype = optionsPrototype;

// Executes when the web page loads
$(function() {
	// Set the initial CPU and memory gauge parameters
	cpuGauge = initGauge(false, cpuGauge, initialCpuUsage, MAX_CPU_UTILIZATION, "canvas-gauge-1", "gauge-1-textfield");
	memoryGauge = initGauge(true, memoryGauge, initialUsedMem, totalMem, "canvas-gauge-2", "gauge-2-textfield");
});


text:
$(function() {
    $('.page-scroll a').bind('click', function(event) {
        var $anchor = $(this);
        $('html, body').stop().animate({
            scrollTop: $($anchor.attr('href')).offset().top
        }, 1500, 'easeInOutExpo');
        event.preventDefault();
    });
});

// Highlight the top nav as scrolling occurs
$('body').scrollspy({
    target: '.navbar-fixed-top'
})

// Closes the Responsive Menu on Menu Item Click
$('.navbar-collapse ul li a').click(function() {
    $('.navbar-toggle:visible').click();
});

//make button disappear when you click it to view more older items.
$('#showOld').click(function() {
    $('#showOld').hide();
    window.setTimeout( function() {
        $('#oldRow').removeClass('extraPadding')
    }, 500);
});


text:
/*
 * Displays linux /proc/pid/stat in human-readable format
 *
 * Build: gcc -o procstat procstat.c
 * Usage: procstat pid
 *        cat /proc/pid/stat | procstat
 *
 * Homepage: http://www.brokestream.com/procstat.html
 * Version : 2009-03-05
 *
 * Ivan Tikhonov, http://www.brokestream.com, kefeer@netangels.ru
 *
 * 2007-09-19 changed HZ=100 error to warning
 *
 * 2009-03-05 tickspersec are taken from sysconf (Sabuj Pattanayek)
 *
 */

/* Copyright (C) 2009 Ivan Tikhonov

  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.

  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

  Ivan Tikhonov, kefeer@brokestream.com

*/

#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <linux/limits.h>
#include <sys/times.h>

#define DEBUG

#ifdef DEBUG
#define printf_debug(fmt, args...)    printf(fmt, ## args);fflush(stdout)
#else
#define printf_debug(fmt, args...)    /* Don't do anything in release builds */
#endif

typedef long long int num;

num pid;
char tcomm[PATH_MAX];
char state;

num ppid;
num pgid;
num sid;
num tty_nr;
num tty_pgrp;

num flags;
num min_flt;
num cmin_flt;
num maj_flt;
num cmaj_flt;
num utime;
num stimev;

num cutime;
num cstime;
num priority;
num nicev;
num num_threads;
num it_real_value;

unsigned long long start_time;

num vsize;
num rss;
num rsslim;
num start_code;
num end_code;
num start_stack;
num esp;
num eip;

num pending;
num blocked;
num sigign;
num sigcatch;
num wchan;
num zero1;
num zero2;
num exit_signal;
num cpu;
num rt_priority;
num policy;

long tickspersec;

FILE *input;

void readone(num *x) { fscanf(input, "%lld ", x); }
void readunsigned(unsigned long long *x) { fscanf(input, "%llu ", x); }
void readstr(char *x) {  fscanf(input, "%s ", x);}
void readchar(char *x) {  fscanf(input, "%c ", x);}

void printone(char *name, num x) {  printf("%20s: %lld\n", name, x);}
void printonex(char *name, num x) {  printf("%20s: %016llx\n", name, x);}
void printunsigned(char *name, unsigned long long x) {  printf("%20s: %llu\n", name, x);}
void printchar(char *name, char x) {  printf("%20s: %c\n", name, x);}
void printstr(char *name, char *x) {  printf("%20s: %s\n", name, x);}
void printtime(char *name, num x) {  printf("%20s: %f\n", name, (((double)x) / tickspersec));}

int gettimesinceboot() {
  FILE *procuptime;
  int sec, ssec;

  procuptime = fopen("/proc/uptime", "r");
  fscanf(procuptime, "%d.%ds", &sec, &ssec);
  fclose(procuptime);
  return (sec*tickspersec)+ssec;
}

void printtimediff(char *name, num x) {
  int sinceboot = gettimesinceboot();
  int running = sinceboot - x;
  time_t rt = time(NULL) - (running / tickspersec);
  char buf[1024];

  strftime(buf, sizeof(buf), "%m.%d %H:%M", localtime(&rt));
  printf("%20s: %s (%u.%us)\n", name, buf, running / tickspersec, running % tickspersec);
}

int getprocstatself(unsigned char printoutput) {
  printf_debug( "getprocstatself: start\n");

  printf_debug( "getprocstatself: tickspersec\n");
  tickspersec = sysconf(_SC_CLK_TCK);

  printf_debug( "getprocstatself: fopen\n");
  input = fopen("/proc/self/stat", "r");

  if(!input) {
    perror("open");
    return 1;
  }

  printf_debug( "getprocstatself: start reading\n");
  readone(&pid);
  readstr(tcomm);
  readchar(&state);
  readone(&ppid);
  readone(&pgid);
  readone(&sid);
  readone(&tty_nr);
  readone(&tty_pgrp);
  readone(&flags);
  readone(&min_flt);
  readone(&cmin_flt);
  readone(&maj_flt);
  readone(&cmaj_flt);
  readone(&utime);
  readone(&stimev);
  readone(&cutime);
  readone(&cstime);
  readone(&priority);
  readone(&nicev);
  readone(&num_threads);
  readone(&it_real_value);
  readunsigned(&start_time);
  readone(&vsize);
  readone(&rss);
  readone(&rsslim);
  readone(&start_code);
  readone(&end_code);
  readone(&start_stack);
  readone(&esp);
  readone(&eip);
  readone(&pending);
  readone(&blocked);
  readone(&sigign);
  readone(&sigcatch);
  readone(&wchan);
  readone(&zero1);
  readone(&zero2);
  readone(&exit_signal);
  readone(&cpu);
  readone(&rt_priority);
  readone(&policy);
  printf_debug( "getprocstatself: end reading\n");

  if (printoutput==1)
  {

    printone("pid", pid);
    printstr("tcomm", tcomm);
    printchar("state", state);
    printone("ppid", ppid);
    printone("pgid", pgid);
    printone("sid", sid);
    printone("tty_nr", tty_nr);
    printone("tty_pgrp", tty_pgrp);
    printone("flags", flags);
    printone("min_flt", min_flt);
    printone("cmin_flt", cmin_flt);
    printone("maj_flt", maj_flt);
    printone("cmaj_flt", cmaj_flt);
    printtime("utime", utime);
    printtime("stime", stimev);
    printtime("cutime", cutime);
    printtime("cstime", cstime);
    printone("priority", priority);
    printone("nice", nicev);
    printone("num_threads", num_threads);
    printtime("it_real_value", it_real_value);
    printtimediff("start_time", start_time);
    printone("vsize", vsize);
    printone("rss", rss);
    printone("rsslim", rsslim);
    printone("start_code", start_code);
    printone("end_code", end_code);
    printone("start_stack", start_stack);
    printone("esp", esp);
    printone("eip", eip);
    printonex("pending", pending);
    printonex("blocked", blocked);
    printonex("sigign", sigign);
    printonex("sigcatch", sigcatch);
    printone("wchan", wchan);
    printone("zero1", zero1);
    printone("zero2", zero2);
    printonex("exit_signal", exit_signal);
    printone("cpu", cpu);
    printone("rt_priority", rt_priority);
    printone("policy", policy);
  }
  fclose(input);
  return 0;
}

int getprocmemsize( double *vm_usage, double *resident_set )
{
	printf_debug( "getprocmemsize: start\n");
	if ( getprocstatself(0) == 0)
	{
		printf_debug( "getprocmemsize: start calc\n");
		long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024;
		*vm_usage = vsize / 1024.0;
		*resident_set = rss * page_size_kb;
		printf_debug( "getprocmemsize: end calc\n");
		return 0;
	}
	else return 1;
}


text:
<?php

namespace Nckg\Demotivator;

use ColorThief\ColorThief;
use Intervention\Image\Image;
use Intervention\Image\ImageManager;

class Demotivator
{
    /**
     * @var ImageManager
     */
    private $imageManager;
    /**
     * @var Collection
     */
    private $fontCollection;

    /**
     * ImageGenerator constructor.
     *
     * @param Collection $fontCollection
     * @param ImageManager $imageManager
     */
    public function __construct(Collection $fontCollection, ImageManager $imageManager)
    {
        $this->imageManager = $imageManager;
        $this->fontCollection = $fontCollection;
    }

    /**
     * Creates a new image with a centered quote
     *
     * @param $quote
     * @return \Intervention\Image\Image
     */
    public function make($quote)
    {
        // Fetch a new image. If the image doesn't match the requirements we will do it again
        do {
            $image = $this->getBackgroundImage();
        } while ($image->width() < 800 or $image->height() < 800);

        // Normalize
        $this->normalizeBackground($image);

        // Insert text in background image
        $textGenerator = new QuoteToImage($this->imageManager, $this->fontCollection);
        $textGenerator->setFontColour($this->getFontColor($image));
        $image->insert($textGenerator->make($quote), 'center');

        return $image;
    }

    /**
     * Fetches a new image from a specific source
     *
     * @return \Intervention\Image\Image
     */
    protected function getBackgroundImage()
    {
        return (new ImageFetcher($this->imageManager))->fetch();
    }

    /**
     * Normalizes the background image to a nice square image
     *
     * @param Image $image
     */
    protected function normalizeBackground(Image $image)
    {
        // If the image isn't a rectangle we will crop it to the best size possible
        if ($image->width() != $image->height()) {
            $size = ($image->width() > $image->height()) ? $image->height() : $image->width();
            $image->crop($size, $size);
        }

        // Resize to 1080 but don't upscale the image
        $image->resize(1080, 1080, function ($constraint) {
            $constraint->upsize();
        });
    }

    /**
     * @param $image
     * @return string
     */
    protected function getFontColor($image)
    {
        // Get the dominant color from the image
        $fontColor = '#ffffff';
        $dominantColor = ColorThief::getColor($image->getCore());

        // Calculate percieved brightness
        $contrast = sqrt(
            $dominantColor[0] * $dominantColor[0] * .241 +
            $dominantColor[1] * $dominantColor[1] * .691 +
            $dominantColor[2] * $dominantColor[2] * .068
        );

        if ($contrast > 130) {
            //bright color, use dark font
            $fontColor = '#111111';
        }

        return $fontColor;
    }
}


text:
module GodaddyApi
  class Server < Base
    attribute :serverId
    attribute :image
    attribute :spec
    attribute :privateIp
    attribute :username
    attribute :password
    attribute :publicIp
    attribute :status
    attribute :taskState
    attribute :key
    attribute :hostname
    attribute :backups
    attribute :bootScript
  end
end


text:
<?php

namespace Zend\Validator;

use Traversable;
use Zend\Stdlib\ArrayUtils;

class Between extends AbstractValidator
{
    const NOT_BETWEEN        = 'notBetween';
    const NOT_BETWEEN_STRICT = 'notBetweenStrict';
    const VALUE_NOT_NUMERIC  = 'valueNotNumeric';
    const VALUE_NOT_STRING   = 'valueNotString';

    /**
     * Retain if min and max are numeric values. Allow to not compare string and numeric types
     *
     * @var boolean
     */
    private $numeric;

    /**
     * Validation failure message template definitions
     *
     * @var array
     */
    protected $messageTemplates = [
        self::NOT_BETWEEN        => "The input is not between '%min%' and '%max%', inclusively",
        self::NOT_BETWEEN_STRICT => "The input is not strictly between '%min%' and '%max%'",
        self::VALUE_NOT_NUMERIC  => "The min ('%min%') and max ('%max%') values are numeric, but the input is not",
        self::VALUE_NOT_STRING   => "The min ('%min%') and max ('%max%') values are non-numeric strings, "
        .    "but the input is not a string",
    ];

    /**
     * Additional variables available for validation failure messages
     *
     * @var array
     */
    protected $messageVariables = [
        'min' => ['options' => 'min'],
        'max' => ['options' => 'max'],
    ];

    /**
     * Options for the between validator
     *
     * @var array
     */
    protected $options = [
        'inclusive' => true,  // Whether to do inclusive comparisons, allowing equivalence to min and/or max
        'min'       => 0,
        'max'       => PHP_INT_MAX,
    ];

    /**
     * Sets validator options
     * Accepts the following option keys:
     *   'min' => scalar, minimum border
     *   'max' => scalar, maximum border
     *   'inclusive' => boolean, inclusive border values
     *
     * @param  array|Traversable $options
     *
     * @throws Exception\InvalidArgumentException
     */
    public function __construct($options = null)
    {
        if ($options instanceof Traversable) {
            $options = ArrayUtils::iteratorToArray($options);
        }
        if (! is_array($options)) {
            $options = func_get_args();
            $temp['min'] = array_shift($options);
            if (! empty($options)) {
                $temp['max'] = array_shift($options);
            }

            if (! empty($options)) {
                $temp['inclusive'] = array_shift($options);
            }

            $options = $temp;
        }

        if (count($options) !== 2
            && (! array_key_exists('min', $options) || ! array_key_exists('max', $options))
        ) {
            throw new Exception\InvalidArgumentException("Missing option: 'min' and 'max' have to be given");
        }

        if (is_numeric($options['min']) && is_numeric($options['max'])) {
            $this->numeric = true;
        } elseif (is_string($options['min']) && is_string($options['max'])) {
            $this->numeric = false;
        } else {
            throw new Exception\InvalidArgumentException(
                "Invalid options: 'min' and 'max' should be of the same scalar type"
            );
        }

        parent::__construct($options);
    }

    /**
     * Returns the min option
     *
     * @return mixed
     */
    public function getMin()
    {
        return $this->options['min'];
    }

    /**
     * Sets the min option
     *
     * @param  mixed $min
     * @return Between Provides a fluent interface
     */
    public function setMin($min)
    {
        $this->options['min'] = $min;
        return $this;
    }

    /**
     * Returns the max option
     *
     * @return mixed
     */
    public function getMax()
    {
        return $this->options['max'];
    }

    /**
     * Sets the max option
     *
     * @param  mixed $max
     * @return Between Provides a fluent interface
     */
    public function setMax($max)
    {
        $this->options['max'] = $max;
        return $this;
    }

    /**
     * Returns the inclusive option
     *
     * @return bool
     */
    public function getInclusive()
    {
        return $this->options['inclusive'];
    }

    /**
     * Sets the inclusive option
     *
     * @param  bool $inclusive
     * @return Between Provides a fluent interface
     */
    public function setInclusive($inclusive)
    {
        $this->options['inclusive'] = $inclusive;
        return $this;
    }

    /**
     * Returns true if and only if $value is between min and max options, inclusively
     * if inclusive option is true.
     *
     * @param  mixed $value
     * @return bool
     */
    public function isValid($value)
    {
        $this->setValue($value);

        if ($this->numeric && ! is_numeric($value)) {
            $this->error(self::VALUE_NOT_NUMERIC);
            return false;
        }
        if (! $this->numeric && ! is_string($value)) {
            $this->error(self::VALUE_NOT_STRING);
            return false;
        }

        if ($this->getInclusive()) {
            if ($this->getMin() > $value || $value > $this->getMax()) {
                $this->error(self::NOT_BETWEEN);
                return false;
            }
        } else {
            if ($this->getMin() >= $value || $value >= $this->getMax()) {
                $this->error(self::NOT_BETWEEN_STRICT);
                return false;
            }
        }

        return true;
    }
}


text:
"""
    config
    ~~~~~~

    Implements config

    :author:    Feei <feei@feei.cn>
    :homepage:  https://github.com/wufeifei/cobra
    :license:   MIT, see LICENSE for more details.
    :copyright: Copyright (c) 2017 Feei. All rights reserved
"""
import os
import traceback
from .log import logger

try:
    from configparser import ConfigParser
except ImportError:
    from ConfigParser import ConfigParser

project_directory = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))

code_path = '/tmp/cobra'
if os.path.isdir(code_path) is not True:
    os.mkdir(code_path)

running_path = os.path.join(code_path, 'running')
if os.path.isdir(running_path) is not True:
    os.mkdir(running_path)

package_path = os.path.join(code_path, 'package')
if os.path.isdir(package_path) is not True:
    os.mkdir(package_path)

source_path = os.path.join(code_path, 'git')
if os.path.isdir(source_path) is not True:
    os.mkdir(source_path)

issue_path = os.path.join(code_path, 'issue')
if os.path.isdir(issue_path) is not True:
    os.mkdir(issue_path)

export_path = os.path.join(code_path, 'export')
if not os.path.exists(export_path):
    os.mkdir(export_path)

issue_history_path = os.path.join(issue_path, 'history')
cobra_main = os.path.join(project_directory, 'cobra.py')
core_path = os.path.join(project_directory, 'cobra')
tests_path = os.path.join(project_directory, 'tests')
examples_path = os.path.join(tests_path, 'examples')
rules_path = os.path.join(project_directory, 'rules')
config_path = os.path.join(project_directory, 'config')
rule_path = os.path.join(project_directory, 'rule.cobra')

class Config(object):
    def __init__(self, level1=None, level2=None):
        self.level1 = level1
        self.level2 = level2
        if level1 is None and level2 is None:
            return
        config = ConfigParser()

        config.read(config_path)
        value = None
        try:
            value = config.get(level1, level2)
        except Exception as e:
            traceback.print_exc()
            logger.critical("./configs file configure failed. {u}\nError: {e}".format(u='https://wufeifei.github.io/cobra/config', e=e.message))
        self.value = value

    @staticmethod
    def copy(source, destination):
        if os.path.isfile(destination) is not True:
            logger.info('Not set configuration, setting....')
            with open(source) as f:
                content = f.readlines()
            with open(destination, 'w+') as f:
                f.writelines(content)
            logger.info('Config file set success(~/.cobra/{source})'.format(source=source))
        else:
            return

class Vulnerabilities(object):
    def __init__(self, key):
        self.key = key

    def status_description(self):
        status = {
            0: 'Not fixed',
            1: 'Not fixed(Push third-party)',
            2: 'Fixed'
        }
        if self.key in status:
            return status[self.key]
        else:
            return False

    def repair_description(self):
        repair = {
            0: 'Initialize',
            1: 'Fixed',
            4000: 'File not exist',
            4001: 'Special file',
            4002: 'Whitelist',
            4003: 'Test file',
            4004: 'Annotation',
            4005: 'Modify code',
            4006: 'Empty code',
            4007: 'Const file',
            4008: 'Third-party'
        }
        if self.key in repair:
            return repair[self.key]
        else:
            return False

    def level_description(self):
        level = {
            0: 'Undefined',
            1: 'Low',
            2: 'Medium',
            3: 'High',
        }
        if self.key in level:
            return level[self.key]
        else:
            return False


text: document.getElementById(test).textContent = message;


text:
from contextlib import contextmanager

# Enthought library imports.
from pyface.tasks.i_dock_pane import IDockPane, MDockPane
from traits.api import Bool, on_trait_change, Property, provides, Tuple

# System library imports.
from pyface.qt import QtCore, QtGui

# Local imports.
from .task_pane import TaskPane
from .util import set_focus

# Constants.
AREA_MAP = { 'left'   : QtCore.Qt.LeftDockWidgetArea,
             'right'  : QtCore.Qt.RightDockWidgetArea,
             'top'    : QtCore.Qt.TopDockWidgetArea,
             'bottom' : QtCore.Qt.BottomDockWidgetArea }
INVERSE_AREA_MAP = dict((int(v), k) for k, v in AREA_MAP.iteritems())

@provides(IDockPane)
class DockPane(TaskPane, MDockPane):
    """ The toolkit-specific implementation of a DockPane.

    See the IDockPane interface for API documentation.
    """

    #### 'IDockPane' interface ################################################

    size = Property(Tuple)

    #### Protected traits #####################################################

    _receiving = Bool(False)

    ###########################################################################
    # 'ITaskPane' interface.
    ###########################################################################

    def create(self, parent):
        """ Create and set the dock widget that contains the pane contents.
        """
        self.control = control = QtGui.QDockWidget(parent)

        # Set the widget's object name. This important for QMainWindow state
        # saving. Use the task ID and the pane ID to avoid collisions when a
        # pane is present in multiple tasks attached to the same window.
        control.setObjectName(self.task.id + ':' + self.id)

        # Configure the dock widget according to the DockPane settings.
        self._set_dock_features()
        self._set_dock_title()
        self._set_floating()
        self._set_visible()

        # Connect signal handlers for updating DockPane traits.
        control.dockLocationChanged.connect(self._receive_dock_area)
        control.topLevelChanged.connect(self._receive_floating)
        control.visibilityChanged.connect(self._receive_visible)

        # Add the pane contents to the dock widget.
        contents = self.create_contents(control)
        control.setWidget(contents)

        # For some reason the QDockWidget doesn't respect the minimum size
        # of its widgets
        contents_minsize = contents.minimumSize()
        style = control.style()
        contents_minsize.setHeight(contents_minsize.height()
            + style.pixelMetric(style.PM_DockWidgetHandleExtent))
        control.setMinimumSize(contents_minsize)

        # Hide the control by default. Otherwise, the widget will visible in its
        # parent immediately!
        control.hide()

    def set_focus(self):
        """ Gives focus to the control that represents the pane.
        """
        if self.control is not None:
            set_focus(self.control.widget())

    ###########################################################################
    # 'IDockPane' interface.
    ###########################################################################

    def create_contents(self, parent):
        """ Create and return the toolkit-specific contents of the dock pane.
        """
        return QtGui.QWidget(parent)

    ###########################################################################
    # Protected interface.
    ###########################################################################

    @contextmanager
    def _signal_context(self):
        """ Defines a context appropriate for Qt signal callbacks. Necessary to
            prevent feedback between Traits and Qt event handlers.
        """
        original = self._receiving
        self._receiving = True
        yield
        self._receiving = original

    #### Trait property getters/setters #######################################

    def _get_size(self):
        if self.control is not None:
            return (self.control.width(), self.control.height())
        return (-1, -1)

    #### Trait change handlers ################################################

    @on_trait_change('dock_area')
    def _set_dock_area(self):
        if self.control is not None and not self._receiving:
            # Only attempt to adjust the area if the task is active.
            main_window = self.task.window.control
            if main_window and self.task == self.task.window.active_task:
                # Qt will automatically remove the dock widget from its previous
                # area, if it had one.
                main_window.addDockWidget(AREA_MAP[self.dock_area],
                                          self.control)

    @on_trait_change('closable', 'floatable', 'movable')
    def _set_dock_features(self):
        if self.control is not None:
            features = QtGui.QDockWidget.NoDockWidgetFeatures
            if self.closable:
                features |= QtGui.QDockWidget.DockWidgetClosable
            if self.floatable:
                features |= QtGui.QDockWidget.DockWidgetFloatable
            if self.movable:
                features |= QtGui.QDockWidget.DockWidgetMovable
            self.control.setFeatures(features)

    @on_trait_change('name')
    def _set_dock_title(self):
        if self.control is not None:
            self.control.setWindowTitle(self.name)

    @on_trait_change('floating')
    def _set_floating(self):
        if self.control is not None and not self._receiving:
            self.control.setFloating(self.floating)

    @on_trait_change('visible')
    def _set_visible(self):
        if self.control is not None and not self._receiving:
            self.control.setVisible(self.visible)

    #### Signal handlers ######################################################

    def _receive_dock_area(self, area):
        with self._signal_context():
            self.dock_area = INVERSE_AREA_MAP[int(area)]

    def _receive_floating(self, floating):
        with self._signal_context():
            self.floating = floating

    def _receive_visible(self):
        with self._signal_context():
            if self.control is not None:
                self.visible = self.control.isVisible()


text:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace word_selecter
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
    }
}


text:
package org.drools.compiler.lang.api;

import org.drools.compiler.lang.descr.UnitDescr;

public interface UnitDescrBuilder
        extends
        DescrBuilder<PackageDescrBuilder, UnitDescr> {

    /**
     * Sets the unit target
     *
     * @param target the unit class
     * @return itself
     */
    UnitDescrBuilder target( String target );
}


text:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="Hello">Hello World, Click Me!</string>
    <string name="ApplicationName">$projectname$</string>
</resources>


text:
![0 stars](../../images/ic_star_border_black_18dp_1x.png)![0 stars](../../images/ic_star_border_black_18dp_1x.png)![0 stars](../../images/ic_star_border_black_18dp_1x.png)![0 stars](../../images/ic_star_border_black_18dp_1x.png)![0 stars](../../images/ic_star_border_black_18dp_1x.png) 0

To use the Internet Trivia skill, try saying...

* *Alexa launch Internet Trivia*

* *Repeat*

* *Help*

Try and answer all of these Internet Trivia answers correctly. See if your friend can do better!

***

### Skill Details

* **Invocation Name:** internet trivia
* **Category:** null
* **ID:** amzn1.ask.skill.873f4156-6972-40ed-9a6e-2e73cc9bf251
* **ASIN:** B01LYZ3VUZ
* **Author:** Nerelas
* **Release Date:** October 5, 2016 @ 00:12:42
* **In-App Purchasing:** No


text:
class NavigationDrawerScreen < DroidEndomondo

  element(:history_button) { "RobotoTextView text:'History'" }

  trait(:trait) { history_button }

  action(:touch_history_button) { touch(history_button) }

end


text:
Go-Shredder is a package which helps you to split a file, or a byte array into chunks. You wan also encrypt the content with GnuPG or AES encryption.

[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/fsamin/go-shredder) [![Build Status](https://travis-ci.org/fsamin/go-shredder.svg?branch=master)](https://travis-ci.org/fsamin/go-shredder) [![Go Report Card](https://goreportcard.com/badge/github.com/fsamin/go-shredder)](https://goreportcard.com/report/github.com/fsamin/go-shredder)

## Sample usages

Shred a file, reassemble the chunks and print the file content.

```golang
    chunks, err := ShredFile("main.go", &Opts{
        ChunkSize: 100,
    })
    if err != nil {
        panic(err)
    }

    content, err := Reassemble(chunks, &Opts{
        ChunkSize: 100,
    })
    if err != nil {
        panic(err)
    }

    fmt.Println(content.String())
```

## With Gnu-PG encryption

Shred a file with GPG encryption. You just need the public key to encrypt.

```golang
    chunks, err := ShredFile("main.go", &Opts{
        GPGEncryption: &GPGEncryption{
                PublicKey:  []byte(publicKey),
            },
        ChunkSize: 100,
    })
    if err != nil {
        panic(err)
    }
```

Reassemble the file; so you need private key and the passphrase.

```golang
    content, err := Reassemble(chunks, &Opts{
        GPGEncryption: &GPGEncryption{
            PrivateKey: []byte(privateKey),
            Passphrase: []byte("password"),
        },
        ChunkSize: 100,
    })
    if err != nil {
        panic(err)
    }
    fmt.Println(content.String())
```

## With AES encryption

Shred a file with AES encryption.

```golang
    chunks, err := ShredFile("main.go", &Opts{
        AESEncryption:  &AESEncryption{
            key: []byte("a very very very very secret key"), //32 bytes long key
        },
        ChunkSize: 100,
    })
    if err != nil {
        panic(err)
    }
```

Reassemble the file

```golang
    content, err := Reassemble(chunks, &Opts{
        AESEncryption:  &AESEncryption{
            key: []byte("a very very very very secret key"), //32 bytes long key
        },
        ChunkSize: 100,
    })
    if err != nil {
        panic(err)
    }
    fmt.Println(content.String())
```


text:
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
 *  Main authors:
 *     Christian Schulte <schulte@gecode.org>
 *
 *  Copyright:
 *     Christian Schulte, 2005
 *
 *  Last modified:
 *     $Date: 2010-07-16 10:51:05 +0200 (Fri, 16 Jul 2010) $ by $Author: tack $
 *     $Revision: 11208 $
 *
 *  This file is part of Gecode, the generic constraint
 *  development environment:
 *     http://www.gecode.org
 *
 *  Permission is hereby granted, free of charge, to any person obtaining
 *  a copy of this software and associated documentation files (the
 *  "Software"), to deal in the Software without restriction, including
 *  without limitation the rights to use, copy, modify, merge, publish,
 *  distribute, sublicense, and/or sell copies of the Software, and to
 *  permit persons to whom the Software is furnished to do so, subject to
 *  the following conditions:
 *
 *  The above copyright notice and this permission notice shall be
 *  included in all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */

#include <gecode/minimodel.hh>

namespace Gecode {

  /*
   * Construction of linear relations
   *
   */
  LinRel
  operator ==(int l, const IntVar& r) {
    return LinRel(l,IRT_EQ,r);
  }
  LinRel
  operator ==(int l, const BoolVar& r) {
    return LinRel(l,IRT_EQ,r);
  }
  LinRel
  operator ==(int l, const LinExpr& r) {
    return LinRel(l,IRT_EQ,r);
  }
  LinRel
  operator ==(const IntVar& l, int r) {
    return LinRel(l,IRT_EQ,r);
  }
  LinRel
  operator ==(const BoolVar& l, int r) {
    return LinRel(l,IRT_EQ,r);
  }
  LinRel
  operator ==(const LinExpr& l, int r) {
    return LinRel(l,IRT_EQ,r);
  }
  LinRel
  operator ==(const IntVar& l, const IntVar& r) {
    return LinRel(l,IRT_EQ,r);
  }
  LinRel
  operator ==(const IntVar& l, const BoolVar& r) {
    return LinRel(l,IRT_EQ,r);
  }
  LinRel
  operator ==(const BoolVar& l, const IntVar& r) {
    return LinRel(l,IRT_EQ,r);
  }
  LinRel
  operator ==(const BoolVar& l, const BoolVar& r) {
    return LinRel(l,IRT_EQ,r);
  }
  LinRel
  operator ==(const IntVar& l, const LinExpr& r) {
    return LinRel(l,IRT_EQ,r);
  }
  LinRel
  operator ==(const BoolVar& l, const LinExpr& r) {
    return LinRel(l,IRT_EQ,r);
  }
  LinRel
  operator ==(const LinExpr& l, const IntVar& r) {
    return LinRel(l,IRT_EQ,r);
  }
  LinRel
  operator ==(const LinExpr& l, const BoolVar& r) {
    return LinRel(l,IRT_EQ,r);
  }
  LinRel
  operator ==(const LinExpr& l, const LinExpr& r) {
    return LinRel(l,IRT_EQ,r);
  }

  LinRel
  operator !=(int l, const IntVar& r) {
    return LinRel(l,IRT_NQ,r);
  }
  LinRel
  operator !=(int l, const BoolVar& r) {
    return LinRel(l,IRT_NQ,r);
  }
  LinRel
  operator !=(int l, const LinExpr& r) {
    return LinRel(l,IRT_NQ,r);
  }
  LinRel
  operator !=(const IntVar& l, int r) {
    return LinRel(l,IRT_NQ,r);
  }
  LinRel
  operator !=(const BoolVar& l, int r) {
    return LinRel(l,IRT_NQ,r);
  }
  LinRel
  operator !=(const LinExpr& l, int r) {
    return LinRel(l,IRT_NQ,r);
  }
  LinRel
  operator !=(const IntVar& l, const IntVar& r) {
    return LinRel(l,IRT_NQ,r);
  }
  LinRel
  operator !=(const IntVar& l, const BoolVar& r) {
    return LinRel(l,IRT_NQ,r);
  }
  LinRel
  operator !=(const BoolVar& l, const IntVar& r) {
    return LinRel(l,IRT_NQ,r);
  }
  LinRel
  operator !=(const BoolVar& l, const BoolVar& r) {
    return LinRel(l,IRT_NQ,r);
  }
  LinRel
  operator !=(const IntVar& l, const LinExpr& r) {
    return LinRel(l,IRT_NQ,r);
  }
  LinRel
  operator !=(const BoolVar& l, const LinExpr& r) {
    return LinRel(l,IRT_NQ,r);
  }
  LinRel
  operator !=(const LinExpr& l, const IntVar& r) {
    return LinRel(l,IRT_NQ,r);
  }
  LinRel
  operator !=(const LinExpr& l, const BoolVar& r) {
    return LinRel(l,IRT_NQ,r);
  }
  LinRel
  operator !=(const LinExpr& l, const LinExpr& r) {
    return LinRel(l,IRT_NQ,r);
  }

  LinRel
  operator <(int l, const IntVar& r) {
    return LinRel(l,IRT_LE,r);
  }
  LinRel
  operator <(int l, const BoolVar& r) {
    return LinRel(l,IRT_LE,r);
  }
  LinRel
  operator <(int l, const LinExpr& r) {
    return LinRel(l,IRT_LE,r);
  }
  LinRel
  operator <(const IntVar& l, int r) {
    return LinRel(l,IRT_LE,r);
  }
  LinRel
  operator <(const BoolVar& l, int r) {
    return LinRel(l,IRT_LE,r);
  }
  LinRel
  operator <(const LinExpr& l, int r) {
    return LinRel(l,IRT_LE,r);
  }
  LinRel
  operator <(const IntVar& l, const IntVar& r) {
    return LinRel(l,IRT_LE,r);
  }
  LinRel
  operator <(const IntVar& l, const BoolVar& r) {
    return LinRel(l,IRT_LE,r);
  }
  LinRel
  operator <(const BoolVar& l, const IntVar& r) {
    return LinRel(l,IRT_LE,r);
  }
  LinRel
  operator <(const BoolVar& l, const BoolVar& r) {
    return LinRel(l,IRT_LE,r);
  }
  LinRel
  operator <(const IntVar& l, const LinExpr& r) {
    return LinRel(l,IRT_LE,r);
  }
  LinRel
  operator <(const BoolVar& l, const LinExpr& r) {
    return LinRel(l,IRT_LE,r);
  }
  LinRel
  operator <(const LinExpr& l, const IntVar& r) {
    return LinRel(l,IRT_LE,r);
  }
  LinRel
  operator <(const LinExpr& l, const BoolVar& r) {
    return LinRel(l,IRT_LE,r);
  }
  LinRel
  operator <(const LinExpr& l, const LinExpr& r) {
    return LinRel(l,IRT_LE,r);
  }

  LinRel
  operator <=(int l, const IntVar& r) {
    return LinRel(l,IRT_LQ,r);
  }
  LinRel
  operator <=(int l, const BoolVar& r) {
    return LinRel(l,IRT_LQ,r);
  }
  LinRel
  operator <=(int l, const LinExpr& r) {
    return LinRel(l,IRT_LQ,r);
  }
  LinRel
  operator <=(const IntVar& l, int r) {
    return LinRel(l,IRT_LQ,r);
  }
  LinRel
  operator <=(const BoolVar& l, int r) {
    return LinRel(l,IRT_LQ,r);
  }
  LinRel
  operator <=(const LinExpr& l, int r) {
    return LinRel(l,IRT_LQ,r);
  }
  LinRel
  operator <=(const IntVar& l, const IntVar& r) {
    return LinRel(l,IRT_LQ,r);
  }
  LinRel
  operator <=(const IntVar& l, const BoolVar& r) {
    return LinRel(l,IRT_LQ,r);
  }
  LinRel
  operator <=(const BoolVar& l, const IntVar& r) {
    return LinRel(l,IRT_LQ,r);
  }
  LinRel
  operator <=(const BoolVar& l, const BoolVar& r) {
    return LinRel(l,IRT_LQ,r);
  }
  LinRel
  operator <=(const IntVar& l, const LinExpr& r) {
    return LinRel(l,IRT_LQ,r);
  }
  LinRel
  operator <=(const BoolVar& l, const LinExpr& r) {
    return LinRel(l,IRT_LQ,r);
  }
  LinRel
  operator <=(const LinExpr& l, const IntVar& r) {
    return LinRel(l,IRT_LQ,r);
  }
  LinRel
  operator <=(const LinExpr& l, const BoolVar& r) {
    return LinRel(l,IRT_LQ,r);
  }
  LinRel
  operator <=(const LinExpr& l, const LinExpr& r) {
    return LinRel(l,IRT_LQ,r);
  }

  LinRel
  operator >(int l, const IntVar& r) {
    return LinRel(l,IRT_GR,r);
  }
  LinRel
  operator >(int l, const BoolVar& r) {
    return LinRel(l,IRT_GR,r);
  }
  LinRel
  operator >(int l, const LinExpr& r) {
    return LinRel(l,IRT_GR,r);
  }
  LinRel
  operator >(const IntVar& l, int r) {
    return LinRel(l,IRT_GR,r);
  }
  LinRel
  operator >(const BoolVar& l, int r) {
    return LinRel(l,IRT_GR,r);
  }
  LinRel
  operator >(const LinExpr& l, int r) {
    return LinRel(l,IRT_GR,r);
  }
  LinRel
  operator >(const IntVar& l, const IntVar& r) {
    return LinRel(l,IRT_GR,r);
  }
  LinRel
  operator >(const IntVar& l, const BoolVar& r) {
    return LinRel(l,IRT_GR,r);
  }
  LinRel
  operator >(const BoolVar& l, const IntVar& r) {
    return LinRel(l,IRT_GR,r);
  }
  LinRel
  operator >(const BoolVar& l, const BoolVar& r) {
    return LinRel(l,IRT_GR,r);
  }
  LinRel
  operator >(const IntVar& l, const LinExpr& r) {
    return LinRel(l,IRT_GR,r);
  }
  LinRel
  operator >(const BoolVar& l, const LinExpr& r) {
    return LinRel(l,IRT_GR,r);
  }
  LinRel
  operator >(const LinExpr& l, const IntVar& r) {
    return LinRel(l,IRT_GR,r);
  }
  LinRel
  operator >(const LinExpr& l, const BoolVar& r) {
    return LinRel(l,IRT_GR,r);
  }
  LinRel
  operator >(const LinExpr& l, const LinExpr& r) {
    return LinRel(l,IRT_GR,r);
  }

  LinRel
  operator >=(int l, const IntVar& r) {
    return LinRel(l,IRT_GQ,r);
  }
  LinRel
  operator >=(int l, const BoolVar& r) {
    return LinRel(l,IRT_GQ,r);
  }
  LinRel
  operator >=(int l, const LinExpr& r) {
    return LinRel(l,IRT_GQ,r);
  }
  LinRel
  operator >=(const IntVar& l, int r) {
    return LinRel(l,IRT_GQ,r);
  }
  LinRel
  operator >=(const BoolVar& l, int r) {
    return LinRel(l,IRT_GQ,r);
  }
  LinRel
  operator >=(const LinExpr& l, int r) {
    return LinRel(l,IRT_GQ,r);
  }
  LinRel
  operator >=(const IntVar& l, const IntVar& r) {
    return LinRel(l,IRT_GQ,r);
  }
  LinRel
  operator >=(const IntVar& l, const BoolVar& r) {
    return LinRel(l,IRT_GQ,r);
  }
  LinRel
  operator >=(const BoolVar& l, const IntVar& r) {
    return LinRel(l,IRT_GQ,r);
  }
  LinRel
  operator >=(const BoolVar& l, const BoolVar& r) {
    return LinRel(l,IRT_GQ,r);
  }
  LinRel
  operator >=(const IntVar& l, const LinExpr& r) {
    return LinRel(l,IRT_GQ,r);
  }
  LinRel
  operator >=(const BoolVar& l, const LinExpr& r) {
    return LinRel(l,IRT_GQ,r);
  }
  LinRel
  operator >=(const LinExpr& l, const IntVar& r) {
    return LinRel(l,IRT_GQ,r);
  }
  LinRel
  operator >=(const LinExpr& l, const BoolVar& r) {
    return LinRel(l,IRT_GQ,r);
  }
  LinRel
  operator >=(const LinExpr& l, const LinExpr& r) {
    return LinRel(l,IRT_GQ,r);
  }

}

// STATISTICS: minimodel-any


text:
/*
 * INCLUDES
 */
#include "bcomdef.h"
#include "OSAL.h"
#include "linkdb.h"
#include "att.h"
#include "gatt.h"
#include "gatt_uuid.h"
#include "gatt_profile_uuid.h"
#include "gattservapp.h"
#include "gapbondmgr.h"
#include "cgmservice.h"

/*
 * MACROS
 */

/*
 * CONSTANTS
 */
// Position of glucose measurement value in attribute array
/// \addtogroup gattgrp
/// \@{
#define CGM_MEAS_VALUE_POS                     2		///<The position of the value of the CGM measurement charateristic in the attribute array
#define CGM_MEAS_CONFIG_POS                    3		///<The position of the Client Configuration of the CGM measurement charateristic in the attribute array
#define CGM_FEATURE_VALUE_POS                  5		///<The position of the value of the CGM feature charateristic in the attribute array
#define CGM_STATUS_VALUE_POS                   7		///<The position of the value of the CGM status charateristic in the attribute array
#define CGM_SESSION_START_TIME_VALUE_POS       9		///<The position of the value of the session start time  charateristic in the attribute array
#define CGM_SESSION_RUN_TIME_VALUE_POS         11		///<The position of the value of the session run time charateristic in the attribute array
#define CGM_RACP_VALUE_POS                     13		///<The position of the value of the RACP charateristic in the attribute array
#define CGM_RACP_CONFIG_POS                    14   		///<The position of the Client Configuration of the RACP charateristic in the attribute array
#define CGM_CGM_OPCP_VALUE_POS                 16   		///<The position of the value of the CGM Specific Operation Control Point (OPCP) charateristic in the attribute array
#define CGM_CGM_OPCP_CONFIG_POS                17		///<The position of the Client Configuration of the CGM Specific Operation Control Point OPCP) charateristic in the attribute array
/// \@}

/*
 * TYPEDEFS
 */

/*
 * GLOBAL VARIABLES
 */
///\addtogroup gattgrp
///\@{
CONST uint8 CGMServiceUUID[ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_SERV_UUID), HI_UINT16(CGM_SERV_UUID)};///< CGM service UUID Stored as a constant variable
CONST uint8 CGMMeasUUID[ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_MEAS_UUID), HI_UINT16(CGM_MEAS_UUID)};///< CGM Measurement characteristic UUID stored as a constant variable
CONST uint8 CGMFeatureUUID[ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_FEATURE_UUID), HI_UINT16(CGM_FEATURE_UUID)};///< CGM Feature UUID stored as a constant
CONST uint8 CGMStatusUUID[ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_STATUS_UUID), HI_UINT16(CGM_STATUS_UUID)};///< CGM Status UUID stored as a constant
CONST uint8 CGMSessionStartTimeUUID[ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_SES_START_TIME_UUID), HI_UINT16(CGM_SES_START_TIME_UUID)};///<CGM Session Start stored as a constant
CONST uint8 CGMSessionRunTimeUUID[ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_SES_RUN_TIME_UUID), HI_UINT16(CGM_SES_RUN_TIME_UUID)};///<CGM Session Run stored as a constant
CONST uint8 recordControlPointUUID[ATT_BT_UUID_SIZE] = {LO_UINT16(REC_ACCESS_CTRL_PT_UUID), HI_UINT16(REC_ACCESS_CTRL_PT_UUID)};///<Record Control Point stored as a constant
CONST uint8 CGMSpecificOpsControlPointUUID[ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_SPEC_OPS_CTRL_PT_UUID), HI_UINT16(CGM_SPEC_OPS_CTRL_PT_UUID)};///<CGM Specific Ops Control Point stored as a constant
///@}

/*
 * EXTERNAL VARIABLES
 */

/*
 * EXTERNAL FUNCTIONS
 */

/*
 * LOCAL VARIABLES
 */
static CGMServiceCB_t CGMServiceCB;		///< The variable to register the CGM service callback function @ingroup gattgrp
static bool	      cgmMeasDBSendInProgress;	///< An variable to indicate whether the RACP transmission is in progress. @ingroup racpgrp

/*
 * Profile Attributes - variables
 */

// CGM Service attribute
static CONST gattAttrType_t CGMService = {ATT_BT_UUID_SIZE, CGMServiceUUID };		///< CGM GATT service declaration data structure
// CGM meaaurement Characteristic
static uint8 CGMMeasProps = GATT_PROP_NOTIFY;						///< Variable storing the CGM Measurement Characteristic property
static gattCharCfg_t CGMMeasConfig[GATT_MAX_NUM_CONN];					///< Variable for storing the client configuration for CGM Measurement Characteristic
static uint8 CGMMeassurementDummy=0;							///< This is a dummy variable to register the CGM Measurement characteristic to the ATT server. The actual variable for receiving the CGM measurement is defined in cgm.c
// CGM feature
static uint8  CGMFeatureProps = GATT_PROP_READ;						///< Variable storing the CGM Feature Characteristic property
static uint8  CGMFeatureDummy = 0;							///< This is a dummy variable to register the CGM Feature characteristic to the ATT server. The actual variable for receiving the CGM feature value is defined in cgm.c
// CGM Status
static uint8  CGMStatusProps = GATT_PROP_READ;						///< Variable storing the CGM Status Characteristic property
static uint8  CGMStatusDummy=0;								///< This is a dummy variable to register the CGM Status characteristic to the ATT server. The actual variable for receiving the CGM measurement is defined in cgm.c
// CGM Session Start Time
static uint8  CGMSessionStartTimeProps = GATT_PROP_WRITE|GATT_PROP_READ;		///< Variable storing the CGM Start Time Characteristic property
static uint8  CGMSessionStartTimeDummy=0;						///< This is a dummy variable to register the CGM Start Time characteristic to the ATT server. The actual variable for receiving the CGM measurement is defined in cgm.c
// CGM Session Run Time
static uint8 CGMSessionRunTimeProps = GATT_PROP_READ;					///< Variable storing the CGM Run Time Characteristic property
static uint16  CGMSessionRunTimeDummy=2; 						///< This is a dummy variable to register the CGM Run time characteristic to the ATT server. The actual variable for receiving the CGM measurement is defined in cgm.c
// Record Access Control Point RACP
static uint8 CGMRacpProps = GATT_PROP_WRITE|GATT_PROP_INDICATE;				///< Variable storing the CGM RACP Characteristic property
static gattCharCfg_t    CGMRacpConfig[GATT_MAX_NUM_CONN];				///< Variable for storing the client configuration for RACP Characteristic
static uint8 CGMRacpDummy=0;								///< This is a dummy variable to register the CGM RACP characteristic to the ATT server. The actual variable for receiving the CGM measurement is defined in cgm.c
// CGM Specific Control Point
static uint8 CGMControlProps = GATT_PROP_WRITE|GATT_PROP_INDICATE;			///< Variable storing the CGM OPCP Characteristic property
static gattCharCfg_t    CGMControlConfig[GATT_MAX_NUM_CONN];				///< Variable for storing the client configuration OPCP Characteristic
static uint8 CGMControlDummy=0;								///< This is a dummy variable to register the CGM OPCP characteristic to the ATT server. The actual variable for receiving the CGM measurement is defined in cgm.c

/*
/ Profile Attributes - Table
*/

/// This variable is used to define the attributes of the CGM service
/// \ingroup gattgrp
static gattAttribute_t CGMAttrTbl[] =
{
  {
    { ATT_BT_UUID_SIZE, primaryServiceUUID }, ///< type */
    GATT_PERMIT_READ,                         ///< permissions */
    0,                                        ///< handle */
    (uint8 *)&CGMService                      ///< pValue */
  }///<CGM Service
  ,
    // CGM MEASUREMENT Charaacteristic

    /// 1. Characteristic Declaration
    {
      { ATT_BT_UUID_SIZE, characterUUID },
      GATT_PERMIT_READ,
      0,
      &CGMMeasProps
    },

    /// 2. Characteristic Value
    {
      { ATT_BT_UUID_SIZE, CGMMeasUUID },
      0,
      0,
      &CGMMeassurementDummy
    },

    /// 3.Characteristic Configuration
    {
      { ATT_BT_UUID_SIZE, clientCharCfgUUID },
      GATT_PERMIT_READ | GATT_PERMIT_WRITE,
      0,
      (uint8 *)&CGMMeasConfig
    },

    // CGM Feature

    /// 4.Characteristic Declaration
    {
      { ATT_BT_UUID_SIZE, characterUUID },
      GATT_PERMIT_READ,
      0,
      &CGMFeatureProps
    },

    /// 5.Characteristic Value
    {
      { ATT_BT_UUID_SIZE, CGMFeatureUUID },
      GATT_PERMIT_READ | GATT_PERMIT_READ,
      0,
      &CGMFeatureDummy
    },

    // CGM STATUS

    /// 6.Characteristic Declaration
    {
      { ATT_BT_UUID_SIZE, characterUUID },
      GATT_PERMIT_READ,
      0,
      &CGMStatusProps
    },

    /// 7.Characteristic Value
    {
      { ATT_BT_UUID_SIZE, CGMStatusUUID },
      GATT_PERMIT_READ | GATT_PERMIT_READ,
      0,
      &CGMStatusDummy
    },

    // CGM Session Start Time

    /// 8.Characteristic Declaration
    {
      { ATT_BT_UUID_SIZE, characterUUID },
      GATT_PERMIT_READ,
      0,
      (uint8*)&CGMSessionStartTimeProps
    },

    /// 9.Characteristic Value
    {
      { ATT_BT_UUID_SIZE, CGMSessionStartTimeUUID },
      GATT_PERMIT_READ |GATT_PERMIT_WRITE,
      0,
      &CGMSessionStartTimeDummy
    },

    // CGM Session Run Time

    /// 10.Characteristic Declaration
    {
      { ATT_BT_UUID_SIZE, characterUUID },
      GATT_PERMIT_READ,
      0,
      &CGMSessionRunTimeProps
    },

    /// 11.Characteristic Value
    {
      { ATT_BT_UUID_SIZE, CGMSessionRunTimeUUID },
      GATT_PERMIT_READ,
      0,
      (uint8 *)&CGMSessionRunTimeDummy
    },

    // RACP Charateristic

    /// 12.Characteristic Declaration
    {
      { ATT_BT_UUID_SIZE, characterUUID },
      GATT_PERMIT_READ,
      0,
      &CGMRacpProps
    },

    /// 13.Characteristic Value
    {
      { ATT_BT_UUID_SIZE, recordControlPointUUID },
      GATT_PERMIT_READ |GATT_PERMIT_WRITE,
      0,
      &CGMRacpDummy
    },
    /// 14.Characteristic Configuration
    {
      { ATT_BT_UUID_SIZE, clientCharCfgUUID },
      GATT_PERMIT_READ |GATT_PERMIT_WRITE,
      0,
      (uint8 *)&CGMRacpConfig
    },

    // CGM Specific Operation Control Point Charateristic

    /// 15.Characteristic Declaration
    {
      { ATT_BT_UUID_SIZE, characterUUID },
      GATT_PERMIT_READ,
      0,
      &CGMControlProps
    },

    /// 16.Characteristic Value
    {
      { ATT_BT_UUID_SIZE, CGMSpecificOpsControlPointUUID },
      GATT_PERMIT_READ |GATT_PERMIT_WRITE,
      0,
      &CGMControlDummy
    },

    /// 17.Characteristic Configuration
    {
      { ATT_BT_UUID_SIZE, clientCharCfgUUID },
      GATT_PERMIT_READ |GATT_PERMIT_WRITE,
      0,
      (uint8 *)&CGMControlConfig
    }

};

/*
 * LOCAL FUNCTIONS
 */
static uint8 CGM_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
static bStatus_t CGM_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,uint8 *pValue, uint8 len, uint16 offset );
static void CGM_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
bStatus_t CGM_RACPIndicate( uint16 connHandle, attHandleValueInd_t *pInd, uint8 taskId );

/*
 * PROFILE CALLBACKS
 */
/// Service Callbacks
/// \ingroup gattgrp
CONST gattServiceCBs_t  CGMCBs =
{
  CGM_ReadAttrCB,   ///< Read callback function pointer
  CGM_WriteAttrCB,  ///< Write callback function pointer
  NULL              ///< Authorization callback function pointer
};

/*
 * PUBLIC FUNCTIONS
 */

/**
   @ingroup gattgrp
 * @brief   Initializes the CGM service by registering
 *          GATT attributes with the GATT server.
 * @param   services - services to add. This is a bit map and can
 * 	    contain more than one service.
 * @return  Success or Failure
 */
bStatus_t CGM_AddService( uint32 services )
{
  uint8 status = SUCCESS;
  // Initialize Client Characteristic Configuration attributes
  GATTServApp_InitCharCfg( INVALID_CONNHANDLE, CGMMeasConfig );
  GATTServApp_InitCharCfg( INVALID_CONNHANDLE, CGMRacpConfig );
  GATTServApp_InitCharCfg( INVALID_CONNHANDLE, CGMControlConfig );
  // Register with Link DB to receive link status change callback
  VOID linkDB_Register( CGM_HandleConnStatusCB );
  if ( services & CGM_SERVICE )
  {
    // Register GATT attribute list and CBs with GATT Server App
    status = GATTServApp_RegisterService( CGMAttrTbl, GATT_NUM_ATTRS( CGMAttrTbl ),&CGMCBs );
  }
  return ( status );
}

/**
   @ingroup gattgrp
 * @brief   Register a callback function with the CGM Service.
 * @param   pfnServiceCB - Callback function.
 * @return  None.*/
extern void CGM_Register( CGMServiceCB_t pfnServiceCB)
{
  CGMServiceCB = pfnServiceCB;
}

/**
   @ingroup glucosemeasgrp
 * @brief       Send a CGM measurement via the CGM measurement notification
 * @param       connHandle - connection handle
 * @param       pNoti - pointer to notification structure
 * @param	taskId - the task id of the CGM application
 * @return      Success or Failure
 */
bStatus_t CGM_MeasSend( uint16 connHandle, attHandleValueNoti_t *pNoti, uint8 taskId )
{
  uint16 value = GATTServApp_ReadCharCfg( connHandle, CGMMeasConfig );
  // Check if the notification property is enabled for the CGM measurement characteristic
  if ( value & GATT_CLIENT_CFG_NOTIFY )
  {
    // Set the handle. Set the CGM measurement characteristic value as the target to push the notification.
    pNoti->handle = CGMAttrTbl[CGM_MEAS_VALUE_POS].handle;
    // Send the Notiication
    return GATT_Notification( connHandle, pNoti, FALSE );
  }
  return bleNotReady;
}

/**
   @ingroup cgmcpgrp
 * @fn          CGM_CtlPntIndicate
 * @brief       Send an indication containing a control point
 *              message.
 * @param       connHandle - connection handle
 * @param       pInd - pointer to indication structure
 * @param	taskid - the task id of the CGM application
 * @return      Success or Failure
 */
bStatus_t CGM_CtlPntIndicate( uint16 connHandle, attHandleValueInd_t *pInd, uint8 taskId )
{
  uint16 value = GATTServApp_ReadCharCfg( connHandle, CGMControlConfig );
  // Check if the indication is enabled for the CGM specific operation control point
  if ( value & GATT_CLIENT_CFG_INDICATE )
  {
    // Set the handle. Set the CGM specific operation control point as the target to push the indication.
    pInd->handle = CGMAttrTbl[CGM_CGM_OPCP_VALUE_POS].handle;
    // Send the Indication
    return GATT_Indication( connHandle, pInd, FALSE, taskId );
  }
  return bleNotReady;
}

/**
   @ingroup racpgrp
 * @brief       Send an indication to the RACP characteristic.
 * @param       connHandle - connection handle
 * @param       pInd - pointer to indication structure
 * @param	taskId - the task id of the CGM application
 * @return      Success or Failure*/
bStatus_t CGM_RACPIndicate( uint16 connHandle, attHandleValueInd_t *pInd, uint8 taskId )
{
  uint16 value = GATTServApp_ReadCharCfg( connHandle, CGMRacpConfig );
  // Check if the RACP characteristic has indication enabled.
  if ( value & GATT_CLIENT_CFG_INDICATE )
  {
    // Set the handle. Set the RACP characteristic as the target to push the indication.
    pInd->handle = CGMAttrTbl[CGM_RACP_VALUE_POS].handle;
    // Send the Indication
    return GATT_Indication( connHandle, pInd, FALSE, taskId );
  }
  return bleNotReady;
}

/**
   @ingroup gattgrp
 * @brief       The callback function when an attribute is being read by a collector.
 * @param       connHandle - connection message was received on
 * @param       pAttr - pointer to attribute
 * @param       pValue - pointer to data to be read
 * @param       pLen - length of data to be read
 * @param       offset - offset of the first octet to be read
 * @param       maxLen - maximum length of data to be read
 * @return      Success or Failure
 */
static uint8 CGM_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
                            uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
{
  bStatus_t status = SUCCESS;
  // Make sure it's not a blob operation (no attributes in the profile are long)
  if ( offset > 0 )
  {
    return ( ATT_ERR_ATTR_NOT_LONG );
  }
  if ( pAttr->type.len == ATT_BT_UUID_SIZE )
  {
    //get the 16-bit UUID of the attribute being read
    uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
    switch ( uuid )
    {
      // No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
      // gattserverapp handles those types for reads
      // The rest of the cases deal with CGM service specific characteristic read.
      case CGM_FEATURE_UUID:
        *pLen = CGM_CHAR_VAL_SIZE_FEATURE;
         (*CGMServiceCB)(CGM_FEATURE_READ_REQUEST, pValue, pLen, (uint8 *)&status );
      break;
     case CGM_STATUS_UUID:
        *pLen = CGM_CHAR_VAL_SIZE_STATUS;
         (*CGMServiceCB)(CGM_STATUS_READ_REQUEST, pValue, pLen,(uint8 *)&status);
         break;
      case CGM_SES_START_TIME_UUID:
        *pLen = CGM_CHAR_VAL_SIZE_START_TIME;
        (*CGMServiceCB)(CGM_START_TIME_READ_REQUEST, pValue, pLen,(uint8 *)&status);
      break;
      case CGM_SES_RUN_TIME_UUID:
        *pLen = CGM_CHAR_VAL_SIZE_RUN_TIME;
        (*CGMServiceCB)(CGM_RUN_TIME_READ_REQUEST, pValue, pLen,(uint8 *)&status);
      break;
      default:
        // Should never get here! (characteristics 3 and 4 do not have read permissions)
        *pLen = 0;
        status = ATT_ERR_ATTR_NOT_FOUND;
        break;
    }
  }
  return ( status );
}

/**
   @ingroup gattgrp
 * @brief   The CGM service layer callback function when an attribute is being written to by the collector.
 * @param   connHandle - connection message was received on
 * @param   pAttr - pointer to attribute
 * @param   pValue - pointer to data to be written
 * @param   len - length of data
 * @param   offset - offset of the first octet to be written
 * @return  Success or Failure
 */
static bStatus_t CGM_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
                                 uint8 *pValue, uint8 len, uint16 offset )
{
  bStatus_t status = SUCCESS;
  // Make sure it's not a blob operation (no attributes in the profile are long)
  if ( offset > 0 )
  {
    return ( ATT_ERR_ATTR_NOT_LONG );
  }
  uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
  switch ( uuid )
  {
  //When the Client Characteristic Configuration is being written to.
  case  GATT_CLIENT_CHAR_CFG_UUID:
      // Notifications
      if ((pAttr->handle == CGMAttrTbl[CGM_MEAS_CONFIG_POS].handle)) //Currently in CGM service, only measurement supports notification
      {
	//Change the GATT server variable for the CCC
        status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len, offset, GATT_CLIENT_CFG_NOTIFY );
        if ( status == SUCCESS )
        {
          uint16 charCfg = BUILD_UINT16( pValue[0], pValue[1] );
          if(pAttr->handle == CGMAttrTbl[CGM_MEAS_CONFIG_POS].handle)
          {
	    //Invoke the service callback to perform additional tasks in response to the change of CCC. These tasks can be defined in the application layer in cgm.c
            (*CGMServiceCB)((charCfg == 0) ? CGM_MEAS_NTF_DISABLED : CGM_MEAS_NTF_ENABLED, NULL, NULL,(uint8 *)&status);
          }
        }
      }
      // Indications for RACP Characteristic
      else if ( pAttr->handle == CGMAttrTbl[CGM_RACP_CONFIG_POS].handle ||
              pAttr->handle == CGMAttrTbl[CGM_CGM_OPCP_CONFIG_POS ].handle ) //Currently in CGM service, RACP and OPCP support indication.
      {
	//Change the GATT server variable for CCC
        status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
                                                 offset, GATT_CLIENT_CFG_INDICATE );
        if ( status == SUCCESS )
        {
            uint16 charCfg = BUILD_UINT16( pValue[0], pValue[1] );
	    if(pAttr->handle == CGMAttrTbl[CGM_CGM_OPCP_CONFIG_POS].handle)
	    {
	    //Invoke the service callback to perform additional tasks in response to the change of CCC. These tasks can be defined in the application layer in cgm.c
            (*CGMServiceCB)((charCfg == 0) ? CGM_CTL_PNT_IND_DISABLED :
                                                 CGM_CTL_PNT_IND_ENABLED, NULL, NULL,(uint8 *)&status);
	    }
	    else if (pAttr->handle == CGMAttrTbl[CGM_RACP_CONFIG_POS].handle)
	    {
	    //Invoke the service callback to perform additional tasks in response to the change of CCC. These tasks can be defined in the application layer in cgm.c
            	(*CGMServiceCB)((charCfg == 0) ? CGM_RACP_IND_DISABLED :
                                                 CGM_RACP_IND_ENABLED, NULL, NULL,(uint8 *)&status);
	    }
        }
      }
      else
      {
        status = ATT_ERR_INVALID_VALUE;
      }
    break;

  case CGM_SES_START_TIME_UUID:
	    //Invoke the service callback to perform tasks in response to value written to start time. These tasks can be defined in the application layer in cgm.c
       (*CGMServiceCB)(CGM_START_TIME_WRITE_REQUEST, pValue, &len, (uint8 *)&status);
    break;

  case CGM_SPEC_OPS_CTRL_PT_UUID: //if CGM specific control point is written
      if(len >= CGM_CTL_PNT_MIN_SIZE  && len <= CGM_CTL_PNT_MAX_SIZE)
      {
	//Invoke the service callback to perform tasks in response to value written to OPCP. These tasks can be defined in the application layer in cgm.c
        (*CGMServiceCB)(CGM_CTL_PNT_CMD, pValue, &len, (uint8 *)&status); //call back to APP2SERV to process the command received.
      }
      else
      {
        status = ATT_ERR_INVALID_VALUE_SIZE;
      }
      break;

    //If RACP is written to
  case REC_ACCESS_CTRL_PT_UUID:
      if(len>=CGM_RACP_MIN_SIZE && len<= CGM_RACP_MAX_SIZE)
      {
	      uint8 opcode = pValue[0];
	      //If transfer in progress
	      if (opcode != CTL_PNT_OP_ABORT && cgmMeasDBSendInProgress)
	      {
		      status = CGM_ERR_IN_PROGRESS;
	      }
	      else if ( opcode == CTL_PNT_OP_REQ &&
			      !( GATTServApp_ReadCharCfg( connHandle, CGMRacpConfig) & GATT_CLIENT_CFG_INDICATE))
	      {
		      status = CGM_ERR_CCC_CONFIG;
	      }
	      else if ( opcode == CTL_PNT_OP_REQ &&
			      !( GATTServApp_ReadCharCfg( connHandle, CGMMeasConfig) & GATT_CLIENT_CFG_NOTIFY))
	      {
		      status = CGM_ERR_CCC_CONFIG;
	      }
	      else
	      {
	    		//Invoke the service callback to perform tasks in response to value written to RACP. These tasks can be defined in the application layer in cgm.c
	      	      (*CGMServiceCB)(CGM_RACP_CTL_PNT_CMD,pValue,&len, (uint8 *) &status);
	      }
      }
      else
      {
	      status = ATT_ERR_INVALID_VALUE_SIZE;
      }
      break;
  default:
      status = ATT_ERR_ATTR_NOT_FOUND;
      break;
  }
  return ( status );
}

/**
   @ingroup accessgrp
 * @brief       Simple Profile link status change handler function.
 * @param       connHandle - connection handle
 * @param       changeType - type of change
 * @return      none
 */
static void CGM_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
{
  // Make sure this is not loopback connection
  if ( connHandle != LOOPBACK_CONNHANDLE )
  {
    // Reset Client Char Config if connection has dropped
    if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED )      ||
         ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
           ( !linkDB_Up( connHandle ) ) ) )
    {
      GATTServApp_InitCharCfg( connHandle, CGMControlConfig );
      GATTServApp_InitCharCfg( connHandle, CGMRacpConfig );
      GATTServApp_InitCharCfg( connHandle, CGMMeasConfig );
    }
  }
}

/**
   @ingroup racpgrp
 * @brief       Set the state of the CGM database transmission indicator
 * @param       input -
 * @return      none
 */
bool CGM_SetSendState(bool input)
{
	cgmMeasDBSendInProgress=input;
	return cgmMeasDBSendInProgress;
}


text:
`selenium` - Selenium Client For Go

# About
This is a [Selenium][selenium] client for [Go][go].
Currently it supports only the remote WebDriver client, so you'll need a
[selenium server][server] running.

[selenium]: http://seleniumhq.org/
[go]: http://golang.org/
[server]: http://seleniumhq.org/download/

# Installing
Run

    go get bitbucket.org/tebeka/selenium

# Docs
Docs are at [godoc.org][godoc].

[godoc]: http://godoc.org/bitbucket.org/tebeka/selenium

## AppEngine

`GetHTTPClient` exposes the HTTP client used by the driver. You can access it to
add the request context.

    func myRequestHandler(w http.ResponseWriter, r *http.Request) {
        selenium.GetHTTPClient().Transport = &urlfetch.Transport{
            Context:  appengine.NewContext(r),
            Deadline: 30 * time.Second,
        }
        ...
    }

Thanks to [bthomson](https://bitbucket.org/tebeka/selenium/issue/8) for this
one.

# Changes
See [here][changelog].

[changelog]: ChangeLog

# TODO
* Support Firefox profiles
* Finish full [Selenium API][api].
* More testing
* [Selenium 1][sel1] client
* Our own server for testing (getting out takes too much time)
* [SauceLabs][sauce] integration

[api]: http://code.google.com/p/selenium/wiki/JsonWireProtocol
[sel1]: http://wiki.openqa.org/display/SRC/Specifications+for+Selenium+Remote+Control+Client+Driver+Protocol
[sauce]: http://saucelabs.com/docs/quickstart

# Hacking

* You'll need a Selenium server to run the tests, run `selenium.sh download` to
  get it and `selenium.sh start` to run it.
* Test with `./run-tests.sh`.
* I (Miki) work on `dev` branch since `go get` pull from default.

# License
[MIT][mit]

[mit]: https://bitbucket.org/tebeka/selenium/src/tip/LICENSE.txt


text:
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/devtools/artifactregistry/v1/artifact.proto

package com.google.devtools.artifactregistry.v1;

public interface ListDockerImagesRequestOrBuilder
    extends
    // @@protoc_insertion_point(interface_extends:google.devtools.artifactregistry.v1.ListDockerImagesRequest)
    com.google.protobuf.MessageOrBuilder {

  /**
   *
   *
   *

   * Required. The name of the parent resource whose docker images will be listed.
   *

   *
   * string parent = 1 [(.google.api.field_behavior) = REQUIRED];
   *
   * @return The parent.
   */
  java.lang.String getParent();
  /**
   *
   *
   *

   * Required. The name of the parent resource whose docker images will be listed.
   *

   *
   * string parent = 1 [(.google.api.field_behavior) = REQUIRED];
   *
   * @return The bytes for parent.
   */
  com.google.protobuf.ByteString getParentBytes();

  /**
   *
   *
   *

   * The maximum number of artifacts to return.
   *

   *
   * int32 page_size = 2;
   *
   * @return The pageSize.
   */
  int getPageSize();

  /**
   *
   *
   *

   * The next_page_token value returned from a previous list request, if any.
   *

   *
   * string page_token = 3;
   *
   * @return The pageToken.
   */
  java.lang.String getPageToken();
  /**
   *
   *
   *

   * The next_page_token value returned from a previous list request, if any.
   *

   *
   * string page_token = 3;
   *
   * @return The bytes for pageToken.
   */
  com.google.protobuf.ByteString getPageTokenBytes();
}


text:
"use strict";

var crypto = require("crypto");
var EventEmitter = require("eventemitter2").EventEmitter2;
var util = require("util");

var ONSBaseClient = function(id, accessKey, secretKey, options) {
    EventEmitter.call(this);

    Object.defineProperties(this, {
        options: {
            enumerable: false,
            writable: false,
            configurable: false,
            value: options || {}
        },

        accessKey: {
            enumerable: false,
            writable: false,
            configurable: false,
            value: accessKey
        },

        secretKey: {
            enumerable: false,
            writable: false,
            configurable: false,
            value: secretKey
        },

        id: {
            enumerable: true,
            writable: false,
            configurable: false,
            value: id
        },

        domain: {
            enumerable: true,
            writable: false,
            configurable: false,
            value: (options || {}).httpDomain || "publictest-rest.ons.aliyun.com"
        }
    });
};

util.inherits(ONSBaseClient, EventEmitter);

ONSBaseClient.prototype.start = function(callback) {
    return process.nextTick(callback);
};

ONSBaseClient.prototype.stop = function(callback) {
    return process.nextTick(callback);
};

ONSBaseClient.prototype.init = function(callback) {
    return process.nextTick(callback);
}

ONSBaseClient.prototype.calcSignature = function(str) {
    return crypto.createHmac("sha1", this.secretKey).update(str).digest().toString("base64");
};

module.exports = ONSBaseClient;