text:
package com.skycaster.geomapper.models;

import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 * Created by 廖华凯 on 2017/8/21.
 */

public class NetWorkStateModel {

    private ConnectivityManager mConnectivityManager;
    private NetWorkStateModel.Callback mCallback;
    private NetworkStateChangeReceiver mNetworkStateChangeReceiver;

    public NetWorkStateModel(Context context) {
        mConnectivityManager= (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    }

    public boolean checkIfNetworkAvailable(){
        NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo();
        if(networkInfo==null){
            return false;
        }
        return networkInfo.isAvailable();
    }

    public NetWorkType getMostFavorableNetworkType(){
        if(!checkIfNetworkAvailable()){
            return NetWorkType.NET_WORK_TYPE_NO_NETWORK;
        }
        NetworkInfo wifiNetwork = mConnectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
        if(wifiNetwork!=null&&wifiNetwork.isAvailable()){
            return NetWorkType.NET_WORK_TYPE_WIFI;
        }

        NetworkInfo mobileNetWork = mConnectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
        if(mobileNetWork!=null&&mobileNetWork.isAvailable()){
            return NetWorkType.NET_WORK_TYPE_MOBILE;
        }
        return NetWorkType.NET_WORK_TYPE_NO_NETWORK;
    }

    public void configWifiSetting(Context context){
        Intent intent = null;
        /**
         * 判断手机系统的版本!如果API大于10 就是3.0+
         * 因为3.0以上的版本的设置和3.0以下的设置不一样,调用的方法不同
         */
        if (android.os.Build.VERSION.SDK_INT > 10) {
            intent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS);
        } else {
            intent = new Intent();
            ComponentName component = new ComponentName(
                    "com.android.settings",
                    "com.android.settings.WirelessSettings");
            intent.setComponent(component);
            intent.setAction("android.intent.action.VIEW");
        }
        context.startActivity(intent);
    }

    public enum NetWorkType{
        NET_WORK_TYPE_WIFI,NET_WORK_TYPE_MOBILE,NET_WORK_TYPE_NO_NETWORK
    }

    public void registerNetworkStateReceiver(Context context,Callback callback){
        mCallback=callback;
        mNetworkStateChangeReceiver=new NetworkStateChangeReceiver();
        IntentFilter intentFilter=new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
        context.registerReceiver(mNetworkStateChangeReceiver,intentFilter);
    }

    public void unRegisterNetworkStateReceiver(Context context){
        if(mNetworkStateChangeReceiver!=null){
            context.unregisterReceiver(mNetworkStateChangeReceiver);
            mNetworkStateChangeReceiver=null;
            mCallback=null;
        }
    }

    public class NetworkStateChangeReceiver extends BroadcastReceiver{

        @Override
        public void onReceive(Context context, Intent intent) {
            if(mConnectivityManager!=null&&mCallback!=null){
                NetWorkType netWorkType = getMostFavorableNetworkType();
                if(netWorkType==NetWorkType.NET_WORK_TYPE_NO_NETWORK){
                    mCallback.onNetworkDisconnected();
                }else {
                    mCallback.onNetworkConnected();
                }
            }
        }
    }

    public interface Callback{
        void onNetworkDisconnected();
        void onNetworkConnected();
    }

}


text:
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import Ember from 'ember';

moduleForComponent('supplementary-file-browser', 'Integration | Component | supplementary file browser', {
    integration: true
});

test('it renders', function(assert) {
    // Set any properties with this.set('myProperty', 'value');
    // Handle any actions with this.on('myAction', function(val) { ... });

    // Construct a fake preprint object to satisfy browser needs
    let providerFiles = () => Ember.RSVP.resolve(Ember.ArrayProxy.create({
        content: Ember.A(),
        meta: {
            pagination: {
                total: 1
            }
        }}));
    let providersQuery =  Ember.RSVP.resolve(Ember.A([{
            name: 'osfstorage',
            query: providerFiles
    }]));
    let preprint = Ember.Object.create({
        files: providersQuery
    });

    this.set('preprint', preprint);

    this.render(hbs`{{supplementary-file-browser preprint=preprint}}`);

    assert.equal(this.$().text().trim(), '');

    //  this.on('changeFile', function() {});
});

//   {{supplementary-file-browser preprint=model projectURL=model.links.html chooseFile=(action 'chooseFile')}}

redpajama_set_name: RedPajamaGithub


text:
const EventYoshi   = require('..');
const EventEmitter = require('events').EventEmitter;
const assert       = require('assert');
const spy          = require('sinon').spy;

describe('Add an emitter and listen for an event', () => {
  it('Emits event to eventyoshi', () => {
    const ee1 = new EventEmitter();
    const yoshi = new EventYoshi().add(ee1);

    let lastFoo, lastFooChild;
    const foo = (s) => {
      lastFoo = s;
      lastFooChild = yoshi.child;
    };
    yoshi.on('foo', foo);

    let lastCat, lastCatChild;
    const cat = (s) => {
      lastCat = s;
      lastCatChild = yoshi.child;
    };
    yoshi.on('cat', cat);

    ee1.emit('foo', 'bar');
    assert.equal(lastFoo, 'bar');
    assert.equal(lastFooChild, ee1);

    ee1.emit('cat', 'doggy');
    assert.equal(lastCat, 'doggy');
    assert.equal(lastCatChild, ee1);
  });

  it('Does not emit events not listened to', () => {
    const ee1 = new EventEmitter();
    const yoshi = new EventYoshi().add(ee1);
    const foo = spy();
    yoshi.on('foo', foo);
    ee1.emit('nope', 'yes');
    assert.ok(foo.notCalled);
  });

  describe('Remove listener', () => {
    it('Does not emit for those events anymore', () => {
      const ee1 = new EventEmitter();
      const yoshi = new EventYoshi().add(ee1);
      const foo = spy();
      yoshi.on('foo', foo);
      ee1.emit('foo', 'bar2');
      assert.ok(foo.calledWith('bar2'));
      yoshi.removeListener('foo', foo);
      ee1.emit('foo', 'bar3');
      assert.ok(foo.calledWith('bar2'));
      assert.equal(foo.callCount, 1);
    });

    it('Still emits other listened to events', () => {
      const ee1 = new EventEmitter();
      const yoshi = new EventYoshi().add(ee1);
      const foo = spy();
      const cat = spy();
      yoshi.addListener('foo', foo);
      yoshi.addListener('cat', cat);
      yoshi.off('foo', foo);
      ee1.emit('cat', 'dog');
      assert.ok(cat.calledWith('dog'));
    });
  });

  describe('Remove event emitter', () => {
    it('Does not route events to yoshi anymore', () => {
      const ee1 = new EventEmitter();
      const yoshi = new EventYoshi().add(ee1);
      const cat = spy();
      yoshi.on('cat', cat);
      yoshi.remove(ee1);
      ee1.emit('cat', 'dog4');
      assert.ok(cat.notCalled);
    });

    it('Still routes events from other event emitters', () => {
      const ee1 = new EventEmitter();
      const ee2 = new EventEmitter();
      const yoshi = new EventYoshi().add(ee1).add(ee2);
      const cat = spy();
      yoshi.on('cat', cat);
      yoshi.remove(ee1);
      ee2.emit('cat', 'dog4');
      assert.ok(cat.calledWith('dog4'));
    });
  });
});

describe('Listen first, then add emitter', () => {
  it('Emits event to eventyoshi', () => {
    const ee1   = new EventEmitter();
    const yoshi = new EventYoshi();

    let lastFoo, lastFooChild;
    const foo = (s) => {
      lastFoo = s;
      lastFooChild = yoshi.child;
    };
    yoshi.on('foo', foo);

    let lastCat, lastCatChild;
    const cat = (s) => {
      lastCat = s;
      lastCatChild = yoshi.child;
    };
    yoshi.on('cat', cat);

    yoshi.add(ee1);

    ee1.emit('foo', 'bar');
    assert.equal(lastFoo, 'bar');
    assert.equal(lastFooChild, ee1);

    ee1.emit('cat', 'doggy');
    assert.equal(lastCat, 'doggy');
    assert.equal(lastCatChild, ee1);
  });
});

describe('Listen for `newListener` event', () => {
  describe('Add a new listener to yoshi', () => {
    it('Calls listener', () => {
      const ee1 = new EventEmitter();
      const yoshi = new EventYoshi().add(ee1);

      let lastEmitter, lastEvent, lastListener;
      yoshi.on('newListener', (event, listener) => {
        lastEmitter = yoshi.child;
        lastEvent = event;
        lastListener = listener;
      });

      const f = () => {};
      yoshi.on('what', f);
      assert.equal(lastEmitter, yoshi);
      assert.equal(lastEvent, 'what');
      assert.equal(lastListener, f);
    });
  });

  describe('Add a new listener to event emitter', () => {
    it('Does not call listener', () => {
      const ee1 = new EventEmitter();
      const yoshi = new EventYoshi().add(ee1);
      const f = spy();
      yoshi.on('newListener', f);
      ee1.on('butt', () => {});
      assert.ok(f.notCalled);
    });
  });

  describe('Remove `newListener` listener', () => {
    it('Does not call listener anymore', () => {
      const ee1 = new EventEmitter();
      const yoshi = new EventYoshi().add(ee1);
      const f = spy();
      yoshi.on('newListener', f);
      yoshi.removeListener('newListener', f);
      yoshi.on('nothing', () => {});
      assert.ok(f.notCalled);
    });
  });
});

describe('Listener for `newChildListener` event', () => {
  describe('Add listener to yoshi', () => {
    it('Does not emit `newChildListener`', () => {
      const ee1 = new EventEmitter();
      const ee2 = new EventEmitter();
      const yoshi = new EventYoshi().add(ee1).add(ee2);
      const f = spy();
      yoshi.on('newChildListener', f);
      yoshi.on('foo', () => {});
      assert.ok(f.notCalled);
    });
  });

  describe('Add listener to child event emitter', () => {
    it('Emits `newChildListener`', () => {
      const ee1 = new EventEmitter();
      const ee2 = new EventEmitter();
      const yoshi = new EventYoshi().add(ee1).add(ee2);

      let lastEmitter, lastEvent, lastListener;
      yoshi.on('newChildListener', (event, listener) => {
        lastEmitter = yoshi.child;
        lastEvent = event;
        lastListener = listener;
      });

      const f = () => {};
      ee1.on('bar', f);
      assert.equal(lastEmitter, ee1);
      assert.equal(lastEvent, 'bar');
      assert.equal(lastListener, f);
    });
  });

  describe('Remove `newChildListener` listener', () => {
    it('Does not call listener anymore', () => {
      const ee1 = new EventEmitter();
      const yoshi = new EventYoshi().add(ee1);
      const f = spy();
      yoshi.on('newChildListener', f);
      yoshi.removeAllListeners('newChildListener', f);
      yoshi.on('nothing', () => {});
      assert.ok(f.notCalled);
    });
  });
});

describe('Listen for `removeListener` event', () => {
  describe('Remove a listener from yoshi', () => {
    it('Calls listener', () => {
      const ee1 = new EventEmitter();
      const yoshi = new EventYoshi().add(ee1);

      let lastEmitter, lastEvent, lastListener;
      yoshi.on('removeListener', (event, listener) => {
        lastEmitter = yoshi.child;
        lastEvent = event;
        lastListener = listener;
      });

      const f = () => {};
      yoshi.on('what', f);
      yoshi.off('what', f);
      assert.equal(lastEmitter, yoshi);
      assert.equal(lastEvent, 'what');
      assert.equal(lastListener, f);
    });
  });

  describe('Remove a listener from event emitter', () => {
    it('Does not call listener', () => {
      const ee1 = new EventEmitter();
      const yoshi = new EventYoshi().add(ee1);
      const f = spy();
      yoshi.on('removeListener', f);
      ee1.on('butt', () => {});
      ee1.removeListener('butt', () => {});
      assert.ok(f.notCalled);
    });
  });
});

describe('Listener for `removeChildListener` event', () => {
  describe('Remove listener from yoshi', () => {
    it('Does not emit `removeChildListener`', () => {
      const ee1 = new EventEmitter();
      const ee2 = new EventEmitter();
      const yoshi = new EventYoshi().add(ee1).add(ee2);
      const f = spy();
      yoshi.on('removeChildListener', f);
      yoshi.on('foo', () => {});
      yoshi.off('foo', () => {});
      assert.ok(f.notCalled);
    });
  });

  describe('Remove listener from child event emitter', () => {
    it('Emits `removeChildListener`', () => {
      const ee1 = new EventEmitter();
      const ee2 = new EventEmitter();
      const yoshi = new EventYoshi().add(ee1).add(ee2);

      let lastEmitter, lastEvent, lastListener;
      yoshi.on('removeChildListener', (event, listener) => {
        lastEmitter = yoshi.child;
        lastEvent = event;
        lastListener = listener;
      });

      const f = () => {};
      ee1.on('bar', f);
      ee1.removeListener('bar', f);
      assert.equal(lastEmitter, ee1);
      assert.equal(lastEvent, 'bar');
      assert.equal(lastListener, f);
    });
  });
});

describe('Listen once', () => {
  it('Calls listener just once', () => {
    const ee1 = new EventEmitter();
    const yoshi = new EventYoshi().add(ee1);
    const f = spy();
    yoshi.once('soap', f);
    ee1.emit('soap', 'a');
    ee1.emit('soap', 'b');
    ee1.emit('soap', 'c');
    assert.equal(f.callCount, 1);
    assert.ok(f.calledWith('a'));
  });

  describe('Remove listener before emitting', () => {
    it('Does not call listener when emitted', () => {
      const ee1 = new EventEmitter();
      const yoshi = new EventYoshi().add(ee1);
      const f = spy();
      yoshi.once('bar', f);
      yoshi.removeListener('bar', f);
      ee1.emit('bar', 1);
      assert.ok(f.notCalled);
    });
  });
});

describe('Emit on eventyoshi', () => {
  it('Emits for both eventyoshi and child event emitters', () => {
    const ee1 = new EventEmitter();
    const yoshi = new EventYoshi().add(ee1);
    const parent = spy();
    const child = spy();
    yoshi.on('a', parent);
    ee1.on('a', child);
    yoshi.emit('a', 'b');
    assert.ok(parent.called);
    assert.ok(child.called);
  });

  it('Does not emit for child after removing', () => {
    const ee1 = new EventEmitter();
    const yoshi = new EventYoshi().add(ee1);
    const parent = spy();
    const child = spy();
    yoshi.on('a', parent);
    ee1.on('a', child);
    yoshi.remove(ee1);
    yoshi.emit('a', 'b');
    assert.ok(parent.called);
    assert.ok(child.notCalled);
  });
});

describe('Listen for an event more than once', () => {
  it('Should emit event once per listener when emitted', (done) => {
    const yoshi = new EventYoshi();
    yoshi.add(new EventEmitter());
    yoshi.add(new EventEmitter());
    yoshi.setMaxListeners(3);
    const b = () => {};
    yoshi.on('foo', () => {});
    yoshi.on('foo', b);
    yoshi.removeListener('foo', b);
    yoshi.on('foo', done);
    yoshi.emit('foo');
  });
});

describe('Proxy a custom function', () => {
  it('Calls proxied child functions', () => {
    const ee1 = new EventEmitter();
    const ee2 = new EventEmitter();
    const yoshi = new EventYoshi()
      .add(ee1)
      .add(ee2);

    yoshi.proxy('foo', 'bar');

    let ee1foo, ee2foo;
    ee1.foo = () => {
      ee1foo = true;
      return 'a';
    };

    ee2.foo = (a, b) => {
      ee2foo = a + b;
      return 'b';
    };

    ee2.bar = (a) => {
      return a;
    };

    assert.deepEqual(yoshi.foo(2, 3), ['a', 'b']);
    assert.equal(ee1foo, true);
    assert.equal(ee2foo, 5);

    assert.equal(yoshi.bar('hello'), 'hello');
  });
});

describe('Add the same emitter twice', () => {
  it('Emits event only once', () => {
    const ee1 = new EventEmitter();
    const yoshi = new EventYoshi().add(ee1).add(ee1);
    const f = spy();
    yoshi.on('hello', f);
    yoshi.emit('hello', 'to u');
    yoshi.remove(ee1).remove(ee1);
    assert.ok(f.calledOnce);
  });
});

describe('Remove all events from yoshi', () => {
  it('Does not emit event anymore from child emitters', () => {
    const ee1 = new EventEmitter();
    const yoshi = new EventYoshi().add(ee1);
    const parent = spy();
    yoshi.on('foo', parent);
    yoshi.removeAllListeners('foo');
    yoshi.removeAllListeners('bar');
    ee1.emit('foo', 42);
    assert.ok(parent.notCalled);
  });

  it('Still emits events to children', () => {
    const ee1 = new EventEmitter();
    const yoshi = new EventYoshi().add(ee1);
    const parent = spy();
    const child = spy();
    yoshi.on('foo', parent);
    ee1.on('foo', child);
    yoshi.removeAllListeners();
    ee1.emit('foo', 42);
    assert.ok(parent.notCalled);
    assert.ok(child.called);
  });
});

describe('Use `EventEmitter#prependListener()`', () => {
  it('Emits listeners in correct order', () => {
    const ee1 = new EventEmitter();
    const yoshi = new EventYoshi().add(ee1);
    const a = spy();
    const b = spy();
    yoshi.prependListener('heart', b);
    yoshi.prependListener('heart', a);
    ee1.emit('heart');
    assert.ok(a.called);
    assert.ok(b.called);
    assert.ok(a.calledBefore(b));
  });
});

describe('Use `EventEmitter#prependOnceListener()`', () => {
  it('Emits listeners in correct order', () => {
    const ee1 = new EventEmitter();
    const yoshi = new EventYoshi().add(ee1);
    const a = spy();
    const b = spy();
    yoshi.prependOnceListener('heart', b);
    yoshi.prependOnceListener('heart', a);
    ee1.emit('heart');
    assert.ok(a.called);
    assert.ok(b.called);
    assert.ok(a.calledBefore(b));
  });
});


text:
import FinchReactCore from 'finch-react-core';
let {Theme} = FinchReactCore;

Theme.register({
  "starter": true
});


text:
  <board-header [color]="hColor" [title]="hTitle"></board-header>

{{item.title}}

  <case-list [list]="curCaseList"></case-list>

    <button routerLink="/case-center">查看更多案例</button>


text:
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;

namespace FastProxy.Definitions
{
    /// <summary>
    /// Builder that allows to create new intrumentation before the interceptor is be about to invoke
    /// </summary>
    public interface IBeforeInvokeInterceptor
    {
        /// <summary>
        /// Create new intrumentation execution bofore interceptor is be about to invoke
        /// </summary>
        /// <param name="typeBuilder">Type builder for proxy instance</param>
        /// <param name="sealedTypeDecorator">Sealed types cannot be inherited. Thats why we create new decorator that allow us to access the implemenation</param>
        /// <param name="interceptorDecorator">Instance of Type IInterceptor that we access</param>
        /// <param name="methodInfo">Current Method Information</param>
        /// <param name="postInvoke">could be used to add new post invoke instrumentation, before the value will be returned</param>
        void Execute(
            TypeBuilder typeBuilder,
            FieldBuilder sealedTypeDecorator,
            FieldBuilder interceptorDecorator,
            MethodInfo methodInfo,
            IList<IAfterInvokeInterceptor> postInvoke);
    }
}


text:
typedef void(^AsyncDataLoaderBlock)(NSData *data, NSError *error);

@interface AsyncDataLoader : NSObject

@property (assign, nonatomic, readonly) BOOL loading;

- (void) dataFromURL: (NSURL *) url block: (AsyncDataLoaderBlock) block;

@end


text:
'use strict';

/**
 * @module code-project/handler/cassess-login-action
 */

/**
 * Stores CAssess Login information
 * @param {Request} request - Hapi request
 * @param {Reply} reply - Hapi Reply
 * @returns {Null} responds with HTML page
 */
function cassessLoginAction (request, reply) {
    const {prefix} = request.route.realm.modifiers.route;

    request
        .yar
        .set({
            'cassess-password': request.payload.password,
            'cassess-username': request.payload.username
        });

    reply().redirect(`${prefix}/recipe/code-project/confirm`);
}

module.exports = cassessLoginAction;


text:
#include "Rendering/Material.hpp"

#include "Coding/MemoryDecoder.hpp"
#include "Coding/MemoryEncoder.hpp"

#include "gtest/gtest.h"

using namespace crimild;

TEST( MaterialTest, construction )
{
    auto material = crimild::alloc< Material >();

    EXPECT_EQ( ( ColorRGBA { 0.0f, 0.0f, 0.0f, 1.0f } ), material->getAmbient() );
    EXPECT_EQ( ( ColorRGBA { 1.0f, 1.0f, 1.0f, 1.0f } ), material->getDiffuse() );
    EXPECT_EQ( ( ColorRGBA { 1.0f, 1.0f, 1.0f, 1.0f } ), material->getSpecular() );
    EXPECT_EQ( 50.0f, material->getShininess() );

    EXPECT_EQ( nullptr, material->getColorMap() );
    EXPECT_EQ( nullptr, material->getProgram() );
}

TEST( MaterialTest, setProgram )
{
    auto material = crimild::alloc< Material >();

    auto program = crimild::alloc< ShaderProgram >();
    material->setProgram( program );

    ASSERT_EQ( crimild::get_ptr( program ), material->getProgram() );
}

TEST( MaterialTest, setColorMap )
{
    auto material = crimild::alloc< Material >();

    auto image = crimild::alloc< Image >( 0, 0, 0, nullptr );
    auto texture = crimild::alloc< Texture >( image );
    material->setColorMap( texture );

    ASSERT_EQ( crimild::get_ptr( texture ), material->getColorMap() );
}


text:
id: V-38476
status: implemented
tag: package
---

The security role verifies that the GPG keys that correspond to each supported
Linux distribution are installed on each host. If the GPG keys are not found,
or if they differ from the list of trusted GPG keys, the playbook execution
will stop.

Deployers can skip this task (and avoid this failure) by using ``--skip-tags
V-38476`` when they are applying the security role.


text:
from django.conf.urls import url
# from polls.apps.poll.views import user_polls, poll, add_completion_of_poll, set_user_answer, new_poll, add_poll
from polls.apps.poll.views import add_completion_of_poll, add_poll
from . import views
from django.views.generic import TemplateView

urlpatterns = [
    # Опросы пользователя
    url(r'user_polls/(?P<user_id>\d+)/$', views.PollListView.as_view(), name='user_polls'),

    # Опрос
    url(r'poll/(?P<pk>\d+)/$', views.PollDetailView.as_view(), name='poll'),

    # Обработка завершения прохождения опрса
    url(r'poll/(?P<poll_id>\d+)/add_completion_of_poll/$', add_completion_of_poll, name='add_completion_of_poll'),

    # Обработка ответа пользователя
    url(r'set_user_answer/$', views.PollDetailView.as_view(), name='set_user_answer'),

    # Загрузка пустой страницы для создания опроса
    url(r'new_poll/$', TemplateView.as_view(template_name='create_poll.html'), name='new_poll'),

    # Сохранение опроса в базу
    url(r'add_poll/$', add_poll, name='add_poll'),

    url(r'(?P<slug>\w+)/$', views.PollDetailView.as_view(), name='poll_with_slug'),
]


text:
import { Page } from 'puppeteer';
import { PREVIEW_IFRAME } from '../consts/query-selectors';
import { IElementValues, ITestExpectations } from '../consts/tests.interface';
import { INTERACTION_INTERVAL } from '../configs/timing.configs';
import { getElementPropertiesData } from '../utils/project.utils';
import * as preview from '../ui-utils/preview.utils';
import * as cd from 'cd-interfaces';

const verifyBoardName = async (boardName: string, page: Page) => {
  const currentBoardName = await preview.getCurrentBoardName(page);
  await expect(currentBoardName).toEqual(boardName, 'mismatching navigated-to board name');
};

const verifyExistsInQuery = async (queries: string[], page: Page, shouldExist: boolean) => {
  const frame = await previewFrame(page);
  if (!frame) return;
  for (const query of queries) {
    const element = await frame.$(query);
    if (shouldExist) {
      await expect(element).toBeDefined(true);
    } else {
      await expect(element).toBeNull(true);
    }
  }

  await page.waitForTimeout(INTERACTION_INTERVAL);
};

const verifyModalName = async (modalName: string, page: Page) => {
  const dataForModel = await findDataForBoardName(modalName, page);
  const selector = 'cd-outlet-modal div.inner-root';
  const frame = await previewFrame(page);
  if (!frame) return;
  const modalId = await frame.evaluate(
    (sel) => (document.querySelector(sel) as HTMLElement).dataset?.id,
    selector
  );

  await expect(modalId).toEqual(dataForModel.id);
};

/** Is there a portal (inner-root) that is pointed at a specific board */
const verifyPortal = async (portalName: string, page: Page) => {
  const dataForModel = await findDataForBoardName(portalName, page);
  await expect(dataForModel).toBeDefined(true);
  const selector = `div.inner-root[data-id="${dataForModel.id}"]`;
  const frame = await previewFrame(page);
  if (!frame) return;
  const portalPointer = await frame.evaluate(
    (sel) => (document.querySelector(sel) as HTMLElement) !== undefined,
    selector
  );
  await expect(portalPointer).toBeDefined(true);
};

const verifyElementValues = async (values: IElementValues[], page: Page) => {
  for (const value of values) {
    if (value.styles) {
      const styles = Object.keys(value.styles);
      const elemStyle = await preview.getElementStyles(page, value.elementIndices, styles);
      expect(elemStyle).toEqual(value.styles, 'mismatching element styles');
    }
    if (value.inputs) {
      throw new Error('Verifying inputs not implemented yet in E2E');
    }
  }
};

const verifySymbolChildValues = async (values: IElementValues[], page: Page) => {
  for (const value of values) {
    if (value.styles && value.symbolName) {
      const styles = Object.keys(value.styles);
      const elemStyles = await preview.getSymbolChildstyles(
        page,
        value.symbolName,
        value.elementIndices,
        styles
      );

      expect(elemStyles).toEqual(value.styles, 'mismatching element styles');
    }

    if (value.inputs) {
      throw new Error('Verifying inputs not implemented yet in E2E');
    }
  }
};

export const interactionsValidator = async (
  expected: ITestExpectations | undefined,
  page: Page
) => {
  if (!expected) return;

  await page.waitForTimeout(INTERACTION_INTERVAL * 2);

  if (expected.boardName) {
    await verifyBoardName(expected.boardName, page);
  }

  if (expected.boardShouldNotHaveElementsInQuery) {
    await verifyExistsInQuery(expected.boardShouldNotHaveElementsInQuery, page, false);
  }

  if (expected.boardHasElementsInQuery) {
    await verifyExistsInQuery(expected.boardHasElementsInQuery, page, true);
  }

  if (expected.modalName) {
    await verifyModalName(expected.modalName, page);
  }

  if (expected.portalPointedAtBoard) {
    await verifyPortal(expected.portalPointedAtBoard, page);
  }

  if (expected.elementValues) {
    await verifyElementValues(expected.elementValues, page);
  }

  if (expected.symbolElementValues) {
    await verifySymbolChildValues(expected.symbolElementValues, page);
  }
};

const findDataForBoardName = async (boardName: string, page: Page) => {
  const data = await getElementPropertiesData(page);
  return Object.values(data).find(
    (item) => (item as cd.IRootElementProperties).name === boardName
  ) as cd.IRootElementProperties;
};

const previewFrame = async (page: Page) => {
  const iframe = await page.waitForSelector(PREVIEW_IFRAME);
  return await iframe.contentFrame();
};


text:
package test.java.ecplugins.puppet;

import java.io.FileReader;
import java.io.BufferedReader;
import java.util.HashMap;
import java.util.Iterator;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;

public class ConfigurationsParser {
    /*
       Actions hashmap will have key as the procedure to run and value as
       a list of various instances of procedure run with different arguments set.
       */
    public static HashMap<String, HashMap<String, HashMap<String, String>>> actions = new HashMap<String, HashMap<String, HashMap<String, String>>>();

    public static void configurationParser() {
        try {
            HashMap<String, HashMap<String, String>> runs;
            HashMap<String, String> runProperties;
            BufferedReader reader = new BufferedReader(new FileReader(System.getProperty("user.dir") + "/src/test/java/ecplugins/puppet/Configurations.json"));
            String line = null, configuration = "";
            while ((line = reader.readLine()) != null) {
                if (line.contains("*/"))
                {
                    break;
                }
            }
            while ((line = reader.readLine()) != null) {
                configuration += line;
            }
            reader.close();
            JSONParser jsonParser = new JSONParser();
            JSONObject actionObject = (JSONObject) jsonParser.parse(configuration.toString());

            Iterator<?> keyAction = actionObject.keySet().iterator();
            while (keyAction.hasNext()) {
                String actionKey = (String) keyAction.next();
                if (actionObject.get(actionKey) instanceof JSONArray) {
                    JSONArray runsArray = (JSONArray) actionObject
                        .get(actionKey);
                    runs = new HashMap<String, HashMap<String, String>>();
                    for (int i = 0; i < runsArray.size(); i++) {
                        JSONObject propertiesObject = (JSONObject) runsArray
                            .get(i);

                        Iterator<?> keyProperties = propertiesObject
                            .keySet().iterator();
                        runProperties = new HashMap<String, String>();
                        while (keyProperties.hasNext()) {
                            String propertiesKey = (String) keyProperties.next();
                            runProperties.put(propertiesKey,
                                    (String) propertiesObject
                                    .get(propertiesKey));
                        }
                        runs.put("run" + i, runProperties);
                    }
                actions.put(actionKey, runs);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


text:
package org.bp.lab.simpleblog.web;

import java.security.Principal;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AppRestController {

	@GetMapping(value="/user")
	public Principal user(Principal user){
		return user;
	}

}


text:
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.gbif.doi.metadata.datacite;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.StringJoiner;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue;

import com.kscs.util.jaxb.Buildable;
import com.kscs.util.jaxb.PropertyTree;
import com.kscs.util.jaxb.PropertyTreeUse;

/**
 * Uniquely identifies an affiliation, according to various identifier schemes.
 *
 *
Java class for affiliation complex type.
 *
 *
The following schema fragment specifies the expected content contained within this class.
 *
 *

 * <complexType name="affiliation">
 *   <simpleContent>
 *     <extension base="<http://datacite.org/schema/kernel-4>nonemptycontentStringType">
 *       <attribute name="affiliationIdentifier" type="{http://www.w3.org/2001/XMLSchema}anySimpleType" />
 *       <attribute name="affiliationIdentifierScheme" type="{http://www.w3.org/2001/XMLSchema}anySimpleType" />
 *       <attribute name="schemeURI" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
 *     </extension>
 *   </simpleContent>
 * </complexType>
 *

 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(
    name = "affiliation",
    propOrder = {"value"})
public class Affiliation {

  @XmlValue protected String value;

  @XmlAttribute(name = "affiliationIdentifier")
  @XmlSchemaType(name = "anySimpleType")
  protected String affiliationIdentifier;

  @XmlAttribute(name = "affiliationIdentifierScheme")
  @XmlSchemaType(name = "anySimpleType")
  protected String affiliationIdentifierScheme;

  @XmlAttribute(name = "schemeURI")
  @XmlSchemaType(name = "anyURI")
  protected String schemeURI;

  /**
   * Gets the value of the value property.
   *
   * @return possible object is {@link String }
   */
  public String getValue() {
    return value;
  }

  /**
   * Sets the value of the value property.
   *
   * @param value allowed object is {@link String }
   */
  public void setValue(String value) {
    this.value = value;
  }

  /**
   * Gets the value of the affiliationIdentifier property.
   *
   * @return possible object is {@link String }
   */
  public String getAffiliationIdentifier() {
    return affiliationIdentifier;
  }

  /**
   * Sets the value of the affiliationIdentifier property.
   *
   * @param value allowed object is {@link String }
   */
  public void setAffiliationIdentifier(String value) {
    this.affiliationIdentifier = value;
  }

  /**
   * Gets the value of the affiliationIdentifierScheme property.
   *
   * @return possible object is {@link String }
   */
  public String getAffiliationIdentifierScheme() {
    return affiliationIdentifierScheme;
  }

  /**
   * Sets the value of the affiliationIdentifierScheme property.
   *
   * @param value allowed object is {@link String }
   */
  public void setAffiliationIdentifierScheme(String value) {
    this.affiliationIdentifierScheme = value;
  }

  /**
   * Gets the value of the schemeURI property.
   *
   * @return possible object is {@link String }
   */
  public String getSchemeURI() {
    return schemeURI;
  }

  /**
   * Sets the value of the schemeURI property.
   *
   * @param value allowed object is {@link String }
   */
  public void setSchemeURI(String value) {
    this.schemeURI = value;
  }

  /**
   * Copies all state of this object to a builder. This method is used by the {@link #copyOf} method
   * and should not be called directly by client code.
   *
   * @param _other A builder instance to which the state of this object will be copied.
   */
  public <_B> void copyTo(final Affiliation.Builder<_B> _other) {
    _other.value = this.value;
    _other.affiliationIdentifier = this.affiliationIdentifier;
    _other.affiliationIdentifierScheme = this.affiliationIdentifierScheme;
    _other.schemeURI = this.schemeURI;
  }

  public <_B> Affiliation.Builder<_B> newCopyBuilder(final _B _parentBuilder) {
    return new Affiliation.Builder<_B>(_parentBuilder, this, true);
  }

  public Affiliation.Builder<Void> newCopyBuilder() {
    return newCopyBuilder(null);
  }

  public static Affiliation.Builder<Void> builder() {
    return new Affiliation.Builder<Void>(null, null, false);
  }

  public static <_B> Affiliation.Builder<_B> copyOf(final Affiliation _other) {
    final Affiliation.Builder<_B> _newBuilder = new Affiliation.Builder<_B>(null, null, false);
    _other.copyTo(_newBuilder);
    return _newBuilder;
  }

  /**
   * Copies all state of this object to a builder. This method is used by the {@link #copyOf} method
   * and should not be called directly by client code.
   *
   * @param _other A builder instance to which the state of this object will be copied.
   */
  public <_B> void copyTo(
      final Affiliation.Builder<_B> _other,
      final PropertyTree _propertyTree,
      final PropertyTreeUse _propertyTreeUse) {
    final PropertyTree valuePropertyTree =
        ((_propertyTree == null) ? null : _propertyTree.get("value"));
    if (((_propertyTreeUse == PropertyTreeUse.INCLUDE)
        ? (valuePropertyTree != null)
        : ((valuePropertyTree == null) || (!valuePropertyTree.isLeaf())))) {
      _other.value = this.value;
    }
    final PropertyTree affiliationIdentifierPropertyTree =
        ((_propertyTree == null) ? null : _propertyTree.get("affiliationIdentifier"));
    if (((_propertyTreeUse == PropertyTreeUse.INCLUDE)
        ? (affiliationIdentifierPropertyTree != null)
        : ((affiliationIdentifierPropertyTree == null)
            || (!affiliationIdentifierPropertyTree.isLeaf())))) {
      _other.affiliationIdentifier = this.affiliationIdentifier;
    }
    final PropertyTree affiliationIdentifierSchemePropertyTree =
        ((_propertyTree == null) ? null : _propertyTree.get("affiliationIdentifierScheme"));
    if (((_propertyTreeUse == PropertyTreeUse.INCLUDE)
        ? (affiliationIdentifierSchemePropertyTree != null)
        : ((affiliationIdentifierSchemePropertyTree == null)
            || (!affiliationIdentifierSchemePropertyTree.isLeaf())))) {
      _other.affiliationIdentifierScheme = this.affiliationIdentifierScheme;
    }
    final PropertyTree schemeURIPropertyTree =
        ((_propertyTree == null) ? null : _propertyTree.get("schemeURI"));
    if (((_propertyTreeUse == PropertyTreeUse.INCLUDE)
        ? (schemeURIPropertyTree != null)
        : ((schemeURIPropertyTree == null) || (!schemeURIPropertyTree.isLeaf())))) {
      _other.schemeURI = this.schemeURI;
    }
  }

  public <_B> Affiliation.Builder<_B> newCopyBuilder(
      final _B _parentBuilder,
      final PropertyTree _propertyTree,
      final PropertyTreeUse _propertyTreeUse) {
    return new Affiliation.Builder<_B>(_parentBuilder, this, true, _propertyTree, _propertyTreeUse);
  }

  public Affiliation.Builder<Void> newCopyBuilder(
      final PropertyTree _propertyTree, final PropertyTreeUse _propertyTreeUse) {
    return newCopyBuilder(null, _propertyTree, _propertyTreeUse);
  }

  public static <_B> Affiliation.Builder<_B> copyOf(
      final Affiliation _other,
      final PropertyTree _propertyTree,
      final PropertyTreeUse _propertyTreeUse) {
    final Affiliation.Builder<_B> _newBuilder = new Affiliation.Builder<_B>(null, null, false);
    _other.copyTo(_newBuilder, _propertyTree, _propertyTreeUse);
    return _newBuilder;
  }

  public static Affiliation.Builder<Void> copyExcept(
      final Affiliation _other, final PropertyTree _propertyTree) {
    return copyOf(_other, _propertyTree, PropertyTreeUse.EXCLUDE);
  }

  public static Affiliation.Builder<Void> copyOnly(
      final Affiliation _other, final PropertyTree _propertyTree) {
    return copyOf(_other, _propertyTree, PropertyTreeUse.INCLUDE);
  }

  @Override
  public String toString() {
    return new StringJoiner(", ", Affiliation.class.getSimpleName() + "[", "]")
        .add("value='" + value + "'")
        .add("affiliationIdentifier='" + affiliationIdentifier + "'")
        .add("affiliationIdentifierScheme='" + affiliationIdentifierScheme + "'")
        .add("schemeURI='" + schemeURI + "'")
        .toString();
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Affiliation that = (Affiliation) o;

    return Objects.equals(value, that.value)
        && Objects.equals(affiliationIdentifier, that.affiliationIdentifier)
        && Objects.equals(affiliationIdentifierScheme, that.affiliationIdentifierScheme)
        && Objects.equals(schemeURI, that.schemeURI);
  }

  @Override
  public int hashCode() {
    return Objects.hash(value, affiliationIdentifier, affiliationIdentifierScheme, schemeURI);
  }

  public static class Builder<_B> implements Buildable {

    protected final _B _parentBuilder;
    protected final Affiliation _storedValue;
    private String value;
    private String affiliationIdentifier;
    private String affiliationIdentifierScheme;
    private String schemeURI;

    public Builder(final _B _parentBuilder, final Affiliation _other, final boolean _copy) {
      this._parentBuilder = _parentBuilder;
      if (_other != null) {
        if (_copy) {
          _storedValue = null;
          this.value = _other.value;
          this.affiliationIdentifier = _other.affiliationIdentifier;
          this.affiliationIdentifierScheme = _other.affiliationIdentifierScheme;
          this.schemeURI = _other.schemeURI;
        } else {
          _storedValue = _other;
        }
      } else {
        _storedValue = null;
      }
    }

    public Builder(
        final _B _parentBuilder,
        final Affiliation _other,
        final boolean _copy,
        final PropertyTree _propertyTree,
        final PropertyTreeUse _propertyTreeUse) {
      this._parentBuilder = _parentBuilder;
      if (_other != null) {
        if (_copy) {
          _storedValue = null;
          final PropertyTree valuePropertyTree =
              ((_propertyTree == null) ? null : _propertyTree.get("value"));
          if (((_propertyTreeUse == PropertyTreeUse.INCLUDE)
              ? (valuePropertyTree != null)
              : ((valuePropertyTree == null) || (!valuePropertyTree.isLeaf())))) {
            this.value = _other.value;
          }
          final PropertyTree affiliationIdentifierPropertyTree =
              ((_propertyTree == null) ? null : _propertyTree.get("affiliationIdentifier"));
          if (((_propertyTreeUse == PropertyTreeUse.INCLUDE)
              ? (affiliationIdentifierPropertyTree != null)
              : ((affiliationIdentifierPropertyTree == null)
                  || (!affiliationIdentifierPropertyTree.isLeaf())))) {
            this.affiliationIdentifier = _other.affiliationIdentifier;
          }
          final PropertyTree affiliationIdentifierSchemePropertyTree =
              ((_propertyTree == null) ? null : _propertyTree.get("affiliationIdentifierScheme"));
          if (((_propertyTreeUse == PropertyTreeUse.INCLUDE)
              ? (affiliationIdentifierSchemePropertyTree != null)
              : ((affiliationIdentifierSchemePropertyTree == null)
                  || (!affiliationIdentifierSchemePropertyTree.isLeaf())))) {
            this.affiliationIdentifierScheme = _other.affiliationIdentifierScheme;
          }
          final PropertyTree schemeURIPropertyTree =
              ((_propertyTree == null) ? null : _propertyTree.get("schemeURI"));
          if (((_propertyTreeUse == PropertyTreeUse.INCLUDE)
              ? (schemeURIPropertyTree != null)
              : ((schemeURIPropertyTree == null) || (!schemeURIPropertyTree.isLeaf())))) {
            this.schemeURI = _other.schemeURI;
          }
        } else {
          _storedValue = _other;
        }
      } else {
        _storedValue = null;
      }
    }

    public _B end() {
      return this._parentBuilder;
    }

    protected <_P extends Affiliation> _P init(final _P _product) {
      _product.value = this.value;
      _product.affiliationIdentifier = this.affiliationIdentifier;
      _product.affiliationIdentifierScheme = this.affiliationIdentifierScheme;
      _product.schemeURI = this.schemeURI;
      return _product;
    }

    /**
     * Sets the new value of "value" (any previous value will be replaced)
     *
     * @param value New value of the "value" property.
     */
    public Affiliation.Builder<_B> withValue(final String value) {
      this.value = value;
      return this;
    }

    /**
     * Sets the new value of "affiliationIdentifier" (any previous value will be replaced)
     *
     * @param affiliationIdentifier New value of the "affiliationIdentifier" property.
     */
    public Affiliation.Builder<_B> withAffiliationIdentifier(final String affiliationIdentifier) {
      this.affiliationIdentifier = affiliationIdentifier;
      return this;
    }

    /**
     * Sets the new value of "affiliationIdentifierScheme" (any previous value will be replaced)
     *
     * @param affiliationIdentifierScheme New value of the "affiliationIdentifierScheme" property.
     */
    public Affiliation.Builder<_B> withAffiliationIdentifierScheme(
        final String affiliationIdentifierScheme) {
      this.affiliationIdentifierScheme = affiliationIdentifierScheme;
      return this;
    }

    /**
     * Sets the new value of "schemeURI" (any previous value will be replaced)
     *
     * @param schemeURI New value of the "schemeURI" property.
     */
    public Affiliation.Builder<_B> withSchemeURI(final String schemeURI) {
      this.schemeURI = schemeURI;
      return this;
    }

    @Override
    public Affiliation build() {
      if (_storedValue == null) {
        return this.init(new Affiliation());
      } else {
        return ((Affiliation) _storedValue);
      }
    }

    public Affiliation.Builder<_B> copyOf(final Affiliation _other) {
      _other.copyTo(this);
      return this;
    }

    public Affiliation.Builder<_B> copyOf(final Affiliation.Builder _other) {
      return copyOf(_other.build());
    }
  }

  public static class Select extends Affiliation.Selector<Affiliation.Select, Void> {

    Select() {
      super(null, null, null);
    }

    public static Affiliation.Select _root() {
      return new Affiliation.Select();
    }
  }

  public static class Selector<TRoot extends com.kscs.util.jaxb.Selector<TRoot, ?>, TParent>
      extends com.kscs.util.jaxb.Selector<TRoot, TParent> {

    private com.kscs.util.jaxb.Selector<TRoot, Affiliation.Selector<TRoot, TParent>> value = null;
    private com.kscs.util.jaxb.Selector<TRoot, Affiliation.Selector<TRoot, TParent>>
        affiliationIdentifier = null;
    private com.kscs.util.jaxb.Selector<TRoot, Affiliation.Selector<TRoot, TParent>>
        affiliationIdentifierScheme = null;
    private com.kscs.util.jaxb.Selector<TRoot, Affiliation.Selector<TRoot, TParent>> schemeURI =
        null;

    public Selector(final TRoot root, final TParent parent, final String propertyName) {
      super(root, parent, propertyName);
    }

    @Override
    public Map<String, PropertyTree> buildChildren() {
      final Map<String, PropertyTree> products = new HashMap<String, PropertyTree>();
      products.putAll(super.buildChildren());
      if (this.value != null) {
        products.put("value", this.value.init());
      }
      if (this.affiliationIdentifier != null) {
        products.put("affiliationIdentifier", this.affiliationIdentifier.init());
      }
      if (this.affiliationIdentifierScheme != null) {
        products.put("affiliationIdentifierScheme", this.affiliationIdentifierScheme.init());
      }
      if (this.schemeURI != null) {
        products.put("schemeURI", this.schemeURI.init());
      }
      return products;
    }

    public com.kscs.util.jaxb.Selector<TRoot, Affiliation.Selector<TRoot, TParent>> value() {
      return ((this.value == null)
          ? this.value =
              new com.kscs.util.jaxb.Selector<TRoot, Affiliation.Selector<TRoot, TParent>>(
                  this._root, this, "value")
          : this.value);
    }

    public com.kscs.util.jaxb.Selector<TRoot, Affiliation.Selector<TRoot, TParent>>
        affiliationIdentifier() {
      return ((this.affiliationIdentifier == null)
          ? this.affiliationIdentifier =
              new com.kscs.util.jaxb.Selector<TRoot, Affiliation.Selector<TRoot, TParent>>(
                  this._root, this, "affiliationIdentifier")
          : this.affiliationIdentifier);
    }

    public com.kscs.util.jaxb.Selector<TRoot, Affiliation.Selector<TRoot, TParent>>
        affiliationIdentifierScheme() {
      return ((this.affiliationIdentifierScheme == null)
          ? this.affiliationIdentifierScheme =
              new com.kscs.util.jaxb.Selector<TRoot, Affiliation.Selector<TRoot, TParent>>(
                  this._root, this, "affiliationIdentifierScheme")
          : this.affiliationIdentifierScheme);
    }

    public com.kscs.util.jaxb.Selector<TRoot, Affiliation.Selector<TRoot, TParent>> schemeURI() {
      return ((this.schemeURI == null)
          ? this.schemeURI =
              new com.kscs.util.jaxb.Selector<TRoot, Affiliation.Selector<TRoot, TParent>>(
                  this._root, this, "schemeURI")
          : this.schemeURI);
    }
  }
}


text:
import extensions = require('binaryextensions');

extensions; // $ExpectType string[]


text:
<!--
  ~ Copyright (C) Scott Cranton, Jakub Korab, and Christian Posta
  ~ https://github.com/CamelCookbook
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~    http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

  <display-name>My Web Application</display-name>

  <!-- location of spring xml files -->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:META-INF/spring/*.xml</param-value>
  </context-param>

  <!-- the listener that kick-starts Spring -->
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

  <!-- Camel servlet -->
  <servlet>
    <servlet-name>CamelServlet</servlet-name>
    <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <!-- Camel servlet mapping -->
  <servlet-mapping>
    <servlet-name>CamelServlet</servlet-name>
    <url-pattern>/camel/*</url-pattern>
  </servlet-mapping>

</web-app>


text:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.sydsoft.libsdb.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Rikd
 */
public abstract class DB {
	private static Logger		Log			= Logger.getLogger(DB.class.getSimpleName());

	/** DatenbankName */
	protected String			dbName;
	/** anfang der VerbindungsURL z.B.:"jdbc:mysql:"(bei MySQL) */
	protected String			connUrl;
	/** ende der VerbindungsURL z.B.:";DriverID=22}"(bei Access) */
	protected String			connUrlClose;
	/** Verbindung zur Datenbank */
	protected Connection		connect;
	/** Beinhaltet die SQL abfrage */
	protected Statement			command;
	/** Beinhaltet die Rückgabe der Daten */
	protected ResultSet			data;
	/** beinhaltet die Metadaten der zurückgegebenen Daten */
	protected ResultSetMetaData	resm;
	/**
	 * Properties datei die Bei datenbanken mitgegeben wird die kein namen und
	 * passwort benötigen in ihr kann z.B.: der "charSet" stehen mit "UTF-8"
	 */
	protected Properties		connProps	= new Properties();
	/** zugriffstreiber zum Initialisieren standartmäßig bei jeder Tochterklasse */
	protected String			driver;

	/**
	 *
	 * Konstruktor der eine Zeichenkette mit dem Pfad und Dateinamen der
	 * Datenbank annimmt
	 *
	 * @param dbName
	 *            Pfad zur Datei mit Dateinamen
	 */
	public DB(String dbName) {
		this.dbName = dbName;
		connProps.put("charSet", "UTF-8");
	}

	/**
	 *
	 * Konstruktor der eine Zeichenkette mit dem Pfad und Dateinamen der
	 * Datenbank annimmt
	 *
	 * @param dbName
	 *            Pfad zur Datei mit Dateinamen
	 * @param props
	 */
	public DB(String dbName, Properties props) {
		this.dbName = dbName;
		connProps = props;
		connProps.put("charSet", "UTF-8");
	}

	/** Standardkonstruktor */
	public DB() {}

	/**
	 * baut eine Verbindung zu Datenbank auf
	 *
	 * @return Wahrheitswert ob das verbinden erfolgreich war
	 */
	public boolean createConnection() {
		long startTime = System.currentTimeMillis();
		boolean isconnected = false;
		try {
			if (connect == null || !connect.isValid(0)) {
				Class.forName(driver).newInstance();
				connect = DriverManager.getConnection(connUrl + dbName + connUrlClose, connProps);
				createCommand();
			}
			isconnected = true;
			System.out.println("Connection opened. Duration: " + (System.currentTimeMillis() - startTime) + " ms");
		} catch (Exception e) {
			Log.log(Level.SEVERE, "couldn't open Database: " + connUrl + dbName + connUrlClose, e);
		}
		return isconnected;
	}

	protected boolean createCommand() {
		try {
			command = connect.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
			return true;
		} catch (SQLException e) {
			Log.log(Level.SEVERE, e.getSQLState(), e);
			return false;
		}
	}

	/**
	 * schließt die Verbindung zur Datenbank, wenn eine Verbindung besteht.
	 * Ansonsten passiert nichts.
	 */
	public void closeConnection() {
		if (connect == null) { return; // Verbindung wurde nicht erzeugt
		}
		try {
			connect.close();
		} catch (SQLException e) {
			Log.log(Level.SEVERE, "couldn't close Database.", e);
		}
	}

	/**
	 * Methode die für SQL-Abfragen, die ein Ergebnis zurückliefern bestimmt ist
	 * (z.B. Select)
	 *
	 * @param sql
	 *            SQL-Abfrage
	 * @return Das ergebnis der Abfrage als Resultset.
	 */
	public ResultSet sqlQuery(String sql) {
		// long startTime = System.currentTimeMillis();
		try {
			data = command.executeQuery(sql);
		} catch (SQLException e) {
			Log.log(Level.SEVERE, "couldn't execute command:" + sql, e);
		}
		// System.out.println("sqlQuery duration: "+(System.currentTimeMillis()
		// - startTime));
		return data;
	}

	/**
	 * Methode zum ausführen von SQL-Befehlen bei denen kein Antwort zu erwarten
	 * ist
	 *
	 * @param sql
	 *            SQL-Befehl
	 * @return Wahrheitswert ob der Befehl erfolgreich war.
	 */
	public boolean sqlCommand(String sql) {
		try {
			return command.execute(sql);
		} catch (SQLException e) {
			Log.log(Level.SEVERE, "couldn't execute command:" + sql, e);
			return false;
		}
	}

	/**
	 * Methode die die MetaDaten der Letzten abfrage zurückgibt.
	 *
	 * @return Metadaten der Letzten SQL-Abfrage, wenn vorhanden ansonsten null.
	 */
	public ResultSetMetaData dbInfo() {
		if (data == null) { return null; }
		try {
			resm = data.getMetaData();
		} catch (SQLException e) {
			Log.log(Level.SEVERE, "couldn't get MetaData", e);
		}
		return resm;
	}

	/**
	 * ???
	 */
	public void update() {
		try {
			data.updateRow();
		} catch (SQLException e) {
			Log.log(Level.SEVERE, "couldn't update Row", e);
		}
	}

	/**
	 * setter für den zugriff zum nachträglichen ändern
	 *
	 * @param connUrl
	 *            neue zugriffsURL z.B.: "//localhost:3306/myDB"
	 */
	public void setConnUrl(String connUrl) {
		this.connUrl = connUrl;
	}

}


text:
.. blogpost::
    :title: GPU and pycuda or pyopencl on Windows
    :keywords: Windows, pycuda
    :date: 2017-01-14
    :categories: module

    `pycuda <https://developer.nvidia.com/pycuda>`_
    is a python module implemented to use GPU.
    On Windows, the best way to install it is to get it
    from `Unofficial Windows Binaries for Python Extension Packages <http://www.lfd.uci.edu/~gohlke/pythonlibs/>`_.
    The module requires `Visual Studio Community Edition <https://www.visualstudio.com/vs/community/>`_ and
    `CUDA Toolkit <https://developer.nvidia.com/accelerated-computing-toolkit>`_.
    Once it is done, you can try the following program to test
    your installation:

    ::

        from pycuda.compiler import SourceModule
        mod = SourceModule("""
        __global__ void multiply_them(float *dest, float *a, float *b)
        {
          const int i = threadIdx.x;
          dest[i] = a[i] * b[i];
        }
        """)

        multiply_them = mod.get_function("multiply_them")

        a = numpy.random.randn(400).astype(numpy.float32)
        b = numpy.random.randn(400).astype(numpy.float32)

        dest = numpy.zeros_like(a)
        multiply_them(
                drv.Out(dest), drv.In(a), drv.In(b),
                block=(400,1,1), grid=(1,1))

        print(dest-a*b)

    If it fails due to the following error:

    ::

        ImportError: DLL load failed: Le module spécifié est introuvable.

    It probably means the DLL ``nvcuda.dll`` is missing.
    You can use `dependency walker <http://www.dependencywalker.com/>`_
    to look at the DLL dependencies for a specific DLL (files *.dll
    or *.pyd if they are compiled with Python).
    In that case, this means the drivers for the graphics card is missing.
    You first need to check your card. If you realise your card is not
    NVidia, you can stop: pycuda only works with a NVidia card.
    Mine is a *Intel Graphics 4000* and I downloaded the drivers from this location:
    `Intel® Graphics Driver for Windows® 10 and Windows 7*/8.1* [15.33] <https://downloadcenter.intel.com/download/25977/Intel-Graphics-Driver-for-Windows-10-and-Windows-7-8-1-15-33-?product=81499>`_.
    In that case, you will need to switch to
    `pyopencl <https://documen.tician.de/pyopencl/>`_.
    You can still get it from
    `Unofficial Windows Binaries for Python Extension Packages <http://www.lfd.uci.edu/~gohlke/pythonlibs/>`_.

    .. https://software.intel.com/en-us/articles/opencl-drivers#win64.

    Finally, you should get the same OpenCL library used to compile
    *pyopencl* which `Intel OpenCL <https://software.intel.com/en-us/intel-opencl>`_.
    You might also need
    `Windows 10 SDK <Khttps://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk>`_.
    Finally, you need to choose the backend for *pyopencl*:

    ::

        import pyopencl as cl
        ctx = cl.create_some_context()

    Follow the questions and choose the graphics card as the backend.
    Setup the following environment variable to skip the questions next time:

    ::

        import os
        os.environ["PYOPENCL_CTX"] = '0:1'

    **theano**

    If you want to use `theano <http://deeplearning.net/software/theano/>`_ on GPU,
    you need `TDM-GCC 64bit <http://tdm-gcc.tdragon.net/>`_ but
    `theano <http://deeplearning.net/software/theano/>`_ only
    supports NVidia cards. The documentation
    tells it will support *opencl* soon:
    `GpuArray Backend <http://deeplearning.net/software/theano/tutorial/using_gpu.html#gpuarray>`_.


text: Check all your PRs at one place


text:
<?php
/**
 * Created by PhpStorm.
 * User: janhuang
 * Date: 15/2/7
 * Time: 上午1:59
 * Github: https://www.github.com/janhuang
 * Coding: https://www.coding.net/janhuang
 * SegmentFault: http://segmentfault.com/u/janhuang
 * Blog: http://segmentfault.com/blog/janhuang
 * Gmail: bboyjanhuang@gmail.com
 */

use \FastD\Framework\Kernel\AppKernel;

class Application extends AppKernel
{
    /**
     * Register project bundles into the kernel.
     *
     * @return array
     */
    public function registerBundles()
    {
        return array(
        );
    }

    /**
     * Register custom kernel plugins.
     * Must return array.
     * examples:
     *  return array(
     *      "Monolog\\Logger"
     *  )
     *
     * @return array
     */
    public function registerService(\FastD\Container\Container $container){return [];}

    /**
     * @return array
     */
    public function registerConfigVariable(){return [];}

    /**
     * Register application configuration
     *
     * @param \FastD\Config\Config
     * @return void
     */
    public function registerConfiguration(\FastD\Config\Config $config){}

    /**
     * Register application configuration dynamic variable.
     *
     * @param \FastD\Config\Config $config
     * @return void
     */
    public function registerConfigurationVariable(\FastD\Config\Config $config)
    {
        // TODO: Implement registerConfigurationVariable() method.
    }
}


text:
# clearing the console window
cls

# REST requests to collect data from the web

# defining the RESTful URL where we want to fetch our data from
$urlString = "http://pokeapi.co/api/v2/pokemon/"

# To keep things simple, we create a list of params we want to fetch data for
# In this case we need to provide IDs to fetch Pokemon information
$urlParams = "1","16" # 1 - Bulbasaur, 16 - Pidgey

# We create an empty list to store the URLS we want to fetch data off
$urlRequestStrings = @()

# Looping through the $urlParams to create all request URLs we want to fetch data from
$urlParams | % {
    $urlRequestStrings += $($urlString + $_)
}

# The actual REST (GET) request.
# In this case the request returns json formatted data
# that we can easily work with in Powershell
# as Powershell automatically converts the response into a psObject
if (!$xml) {
    $xml = Invoke-RestMethod -Uri $urlRequestStrings[1] -Method Get
}
# Now that we got our xml response (-psObject) we can iterate through
# all of it's parameters to get what we need
# In this case the xml response is rather complex but you should get an idea

#(We limit the output to 3 elements as it's quite some data...)

write-host "Pokemon name: $($xml.name)"
write-host "learnable moves:"

foreach ($i in 0..2) {
    write-host
    write-host "Move name: $($xml.moves[$i].move.name)"
    write-host "Version group: $($xml.moves[$i].version_group_details.version_group.name)"
    write-host "learn method: $($xml.moves[$i].version_group_details.move_learn_method.name)"
    write-host "learned at: $($xml.moves[$i].version_group_details.level_learned_at)"
}

# Just for the sake of it, we can of course iterate over the entire response
# to get all the information by calling the following function
function getAllData() {
    $xml.moves | % {
        write-host
        write-host "Move name: $($_.move.name)"
        write-host "Version group: $($_.version_group_details.version_group.name)"
        write-host "learn method: $($_.version_group_details.move_learn_method.name)"
        write-host "learned at: $($_.version_group_details.level_learned_at)"
    }
}

# Remove the comment (#) below to get all data
# getAllData


text:
package com.ibm.spark.boot.layer

import com.ibm.spark.boot.KernelBootstrap
import com.ibm.spark.interpreter.Interpreter
import com.ibm.spark.utils.LogLike

/**
 * Represents the hook (interrupt/shutdown) initialization. All JVM-related
 * hooks should be constructed here.
 */
trait HookInitialization {
  /**
   * Initializes and registers all hooks.
   *
   * @param interpreter The main interpreter
   */
  def initializeHooks(interpreter: Interpreter): Unit
}

/**
 * Represents the standard implementation of HookInitialization.
 */
trait StandardHookInitialization extends HookInitialization {
  this: KernelBootstrap with LogLike =>

  /**
   * Initializes and registers all hooks.
   *
   * @param interpreter The main interpreter
   */
  def initializeHooks(interpreter: Interpreter): Unit = {
    registerInterruptHook(interpreter)
    registerShutdownHook()
  }

  private def registerInterruptHook(interpreter: Interpreter): Unit = {
    val self = this

    import sun.misc.{Signal, SignalHandler}

    // TODO: Signals are not a good way to handle this since JVM only has the
    // proprietary sun API that is not necessarily available on all platforms
    Signal.handle(new Signal("INT"), new SignalHandler() {
      private val MaxSignalTime: Long = 3000 // 3 seconds
      var lastSignalReceived: Long    = 0

      def handle(sig: Signal) = {
        val currentTime = System.currentTimeMillis()
        if (currentTime - lastSignalReceived > MaxSignalTime) {
          logger.info("Resetting code execution!")
          interpreter.interrupt()

          // TODO: Cancel group representing current code execution
          //sparkContext.cancelJobGroup()

          logger.info("Enter Ctrl-C twice to shutdown!")
          lastSignalReceived = currentTime
        } else {
          logger.info("Shutting down kernel")
          self.shutdown()
        }
      }
    })
  }

  private def registerShutdownHook(): Unit = {
    logger.debug("Registering shutdown hook")
    val self = this
    val mainThread = Thread.currentThread()
    Runtime.getRuntime.addShutdownHook(new Thread() {
      override def run() = {
        logger.info("Shutting down kernel")
        self.shutdown()
        // TODO: Check if you can magically access the spark context to stop it
        // TODO: inside a different thread
        if (mainThread.isAlive) mainThread.join()
      }
    })
  }
}