text:
package org.apache.airavata.gfac.local.provider.impl;

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

import org.apache.airavata.gfac.Constants;
import org.apache.airavata.gfac.GFacException;
import org.apache.airavata.gfac.core.context.JobExecutionContext;
import org.apache.airavata.gfac.core.notification.events.StartExecutionEvent;
import org.apache.airavata.gfac.core.provider.AbstractProvider;
import org.apache.airavata.gfac.core.provider.GFacProviderException;
import org.apache.airavata.gfac.core.provider.utils.ProviderUtils;
import org.apache.airavata.gfac.core.utils.GFacUtils;
import org.apache.airavata.gfac.core.utils.OutputUtils;
import org.apache.airavata.gfac.local.utils.InputStreamToFileWriter;
import org.apache.airavata.gfac.local.utils.InputUtils;
import org.apache.airavata.model.messaging.event.JobIdentifier;
import org.apache.airavata.model.messaging.event.JobStatusChangeEvent;
import org.apache.airavata.model.messaging.event.TaskIdentifier;
import org.apache.airavata.model.messaging.event.TaskOutputChangeEvent;
import org.apache.airavata.model.workspace.experiment.DataObjectType;
import org.apache.airavata.model.workspace.experiment.JobDetails;
import org.apache.airavata.model.workspace.experiment.JobState;
import org.apache.airavata.model.workspace.experiment.TaskDetails;
import org.apache.airavata.registry.cpi.ChildDataType;
import org.apache.airavata.registry.cpi.RegistryModelType;
import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
import org.apache.airavata.schemas.gfac.NameValuePairType;
import org.apache.xmlbeans.XmlException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import sun.reflect.generics.reflectiveObjects.NotImplementedException;

public class LocalProvider extends AbstractProvider {
    private static final Logger log = LoggerFactory.getLogger(LocalProvider.class);
    private ProcessBuilder builder;
    private List<String> cmdList;
    private String jobId;

    public static class LocalProviderJobData{
    	private String applicationName;
    	private List<String> inputParameters;
    	private String workingDir;
    	private String inputDir;
    	private String outputDir;
		public String getApplicationName() {
			return applicationName;
		}
		public void setApplicationName(String applicationName) {
			this.applicationName = applicationName;
		}
		public List<String> getInputParameters() {
			return inputParameters;
		}
		public void setInputParameters(List<String> inputParameters) {
			this.inputParameters = inputParameters;
		}
		public String getWorkingDir() {
			return workingDir;
		}
		public void setWorkingDir(String workingDir) {
			this.workingDir = workingDir;
		}
		public String getInputDir() {
			return inputDir;
		}
		public void setInputDir(String inputDir) {
			this.inputDir = inputDir;
		}
		public String getOutputDir() {
			return outputDir;
		}
		public void setOutputDir(String outputDir) {
			this.outputDir = outputDir;
		}
    }
    public LocalProvider(){
        cmdList = new ArrayList<String>();
    }

    public void initialize(JobExecutionContext jobExecutionContext) throws GFacProviderException,GFacException {
    	super.initialize(jobExecutionContext);
        ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().
                getApplicationDeploymentDescription().getType();

        buildCommand(app.getExecutableLocation(), ProviderUtils.getInputParameters(jobExecutionContext));
        initProcessBuilder(app);

        // extra environment variables
        builder.environment().put(Constants.INPUT_DATA_DIR_VAR_NAME, app.getInputDataDirectory());
        builder.environment().put(Constants.OUTPUT_DATA_DIR_VAR_NAME, app.getOutputDataDirectory());

        // set working directory
        builder.directory(new File(app.getStaticWorkingDirectory()));

        // log info
        log.info("Command = " + InputUtils.buildCommand(cmdList));
        log.info("Working dir = " + builder.directory());
        for (String key : builder.environment().keySet()) {
            log.info("Env[" + key + "] = " + builder.environment().get(key));
        }
    }

    public void execute(JobExecutionContext jobExecutionContext) throws GFacProviderException {
        jobExecutionContext.getNotifier().publish(new StartExecutionEvent());
         ApplicationDeploymentDescriptionType app = jobExecutionContext.
                 getApplicationContext().getApplicationDeploymentDescription().getType();
        JobDetails jobDetails = new JobDetails();
        try {
        	jobId = jobExecutionContext.getTaskData().getTaskID();
            jobDetails.setJobID(jobId);
            jobDetails.setJobDescription(app.toString());
            jobExecutionContext.setJobDetails(jobDetails);
            jobDetails.setJobDescription(app.toString());
            GFacUtils.saveJobStatus(jobExecutionContext,jobDetails, JobState.SETUP);
        	// running cmd
            Process process = builder.start();

            Thread standardOutWriter = new InputStreamToFileWriter(process.getInputStream(), app.getStandardOutput());
            Thread standardErrorWriter = new InputStreamToFileWriter(process.getErrorStream(), app.getStandardError());

            // start output threads
            standardOutWriter.setDaemon(true);
            standardErrorWriter.setDaemon(true);
            standardOutWriter.start();
            standardErrorWriter.start();

            int returnValue = process.waitFor();

            // make sure other two threads are done
            standardOutWriter.join();
            standardErrorWriter.join();

            /*
             * check return value. usually not very helpful to draw conclusions based on return values so don't bother.
             * just provide warning in the log messages
             */
            if (returnValue != 0) {
                log.error("Process finished with non zero return value. Process may have failed");
            } else {
                log.info("Process finished with return value of zero.");
            }

            StringBuffer buf = new StringBuffer();
            buf.append("Executed ").append(InputUtils.buildCommand(cmdList))
                    .append(" on the localHost, working directory = ").append(app.getStaticWorkingDirectory())
                    .append(" tempDirectory = ").append(app.getScratchWorkingDirectory()).append(" With the status ")
                    .append(String.valueOf(returnValue));
            log.info(buf.toString());

            // updating the job status to complete because there's nothing to monitor in local jobs
//            MonitorID monitorID = createMonitorID(jobExecutionContext);
            JobIdentifier jobIdentity = new JobIdentifier(jobExecutionContext.getJobDetails().getJobID(),
                    jobExecutionContext.getTaskData().getTaskID(),
                    jobExecutionContext.getWorkflowNodeDetails().getNodeInstanceId(),
                    jobExecutionContext.getExperimentID(),
                    jobExecutionContext.getGatewayID());
            this.getMonitorPublisher().publish(new JobStatusChangeEvent(JobState.COMPLETE, jobIdentity));
        } catch (IOException io) {
            throw new GFacProviderException(io.getMessage(), io);
        } catch (InterruptedException e) {
            throw new GFacProviderException(e.getMessage(), e);
        }catch (GFacException e) {
            throw new GFacProviderException(e.getMessage(), e);
        }
    }

//	private MonitorID createMonitorID(JobExecutionContext jobExecutionContext) {
//		MonitorID monitorID = new MonitorID(jobExecutionContext.getApplicationContext().getHostDescription(), jobId,
//		        jobExecutionContext.getTaskData().getTaskID(),
//		        jobExecutionContext.getWorkflowNodeDetails().getNodeInstanceId(), jobExecutionContext.getExperimentID(),
//		        jobExecutionContext.getExperiment().getUserName(),jobId);
//		return monitorID;
//	}

//	private void saveApplicationJob(JobExecutionContext jobExecutionContext)
//			throws GFacProviderException {
//		ApplicationDeploymentDescriptionType app = jobExecutionContext.
//                getApplicationContext().getApplicationDeploymentDescription().getType();
//		ApplicationJob appJob = GFacUtils.createApplicationJob(jobExecutionContext);
//		appJob.setJobId(jobId);
//		LocalProviderJobData data = new LocalProviderJobData();
//		data.setApplicationName(app.getExecutableLocation());
//		data.setInputDir(app.getInputDataDirectory());
//		data.setOutputDir(app.getOutputDataDirectory());
//		data.setWorkingDir(builder.directory().toString());
//		data.setInputParameters(ProviderUtils.getInputParameters(jobExecutionContext));
//		ByteArrayOutputStream stream = new ByteArrayOutputStream();
//		JAXB.marshal(data, stream);
//		appJob.setJobData(stream.toString());
//		appJob.setSubmittedTime(Calendar.getInstance().getTime());
//		appJob.setStatus(ApplicationJobStatus.SUBMITTED);
//		appJob.setStatusUpdateTime(appJob.getSubmittedTime());
//		GFacUtils.recordApplicationJob(jobExecutionContext, appJob);
//	}

    public void dispose(JobExecutionContext jobExecutionContext) throws GFacProviderException {
        ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();

        try {
        	List<DataObjectType> outputArray = new ArrayList<DataObjectType>();
            String stdOutStr = GFacUtils.readFileToString(app.getStandardOutput());
            String stdErrStr = GFacUtils.readFileToString(app.getStandardError());
			Map<String, Object> output = jobExecutionContext.getOutMessageContext().getParameters();
            OutputUtils.fillOutputFromStdout(output, stdOutStr, stdErrStr, outputArray);
            TaskDetails taskDetails = (TaskDetails)registry.get(RegistryModelType.TASK_DETAIL, jobExecutionContext.getTaskData().getTaskID());
            if (taskDetails != null){
                taskDetails.setApplicationOutputs(outputArray);
                registry.update(RegistryModelType.TASK_DETAIL, taskDetails, taskDetails.getTaskID());
            }
            registry.add(ChildDataType.EXPERIMENT_OUTPUT, outputArray, jobExecutionContext.getExperimentID());
            TaskIdentifier taskIdentity = new TaskIdentifier(jobExecutionContext.getTaskData().getTaskID(),
                    jobExecutionContext.getWorkflowNodeDetails().getNodeInstanceId(),
                    jobExecutionContext.getExperimentID(),
                    jobExecutionContext.getGatewayID());
            getMonitorPublisher().publish(new TaskOutputChangeEvent(outputArray, taskIdentity));
        } catch (XmlException e) {
            throw new GFacProviderException("Cannot read output:" + e.getMessage(), e);
        } catch (IOException io) {
            throw new GFacProviderException(io.getMessage(), io);
        } catch (Exception e){
        	throw new GFacProviderException("Error in retrieving results",e);
        }
    }

    public void cancelJob(JobExecutionContext jobExecutionContext) throws GFacException {
        throw new NotImplementedException();
    }

    private void buildCommand(String executable, List<String> inputParameterList){
        cmdList.add(executable);
        cmdList.addAll(inputParameterList);
    }

    private void initProcessBuilder(ApplicationDeploymentDescriptionType app){
        builder = new ProcessBuilder(cmdList);

        NameValuePairType[] env = app.getApplicationEnvironmentArray();

        if(env != null && env.length > 0){
            Map<String,String> builderEnv = builder.environment();
            for (NameValuePairType entry : env) {
                builderEnv.put(entry.getName(), entry.getValue());
            }
        }
    }

    public void initProperties(Map<String, String> properties) throws GFacProviderException, GFacException {

    }
}


text:
'use strict';

angular.module('mean.system').factory('Users', ['$resource', function($resource) {
    return $resource('users/:userId', {
        userId: '@_id'
    }, {
        update: {
            method: 'PUT'
        }
    });
}]);

redpajama_set_name: RedPajamaGithub


text:
require 'rails_helper'

RSpec.describe CrewMember, :type => :model do

  let(:test_crew) { create(:crew_member) }

  before(:each) do
    ServiceVehicle.destroy_all
  end

  #-----------------------------------------------------------------------------
  # Associations and Validations
  #-----------------------------------------------------------------------------
  describe 'associations' do
    it 'has a service vehicle' do
      expect(test_crew).to belong_to(:service_vehicle)
    end
    it 'is a user' do
      expect(test_crew).to belong_to(:user)
    end
  end
  describe 'validations' do
    it 'must have a service vehicle' do
      test_crew.service_vehicle = nil

      expect(test_crew.valid?).to be false
    end
    it 'must have an user' do
      test_crew.user = nil

      expect(test_crew.valid?).to be false
    end
  end

  describe 'scope' do
    it 'supervisors' do
      test_supervisor = create(:crew_member, :supervisor => true)
      test_crew = create(:crew_member, :supervisor => false)
      expect(CrewMember.supervisors).to include(test_supervisor)
      expect(CrewMember.supervisors).not_to include(test_crew)
    end
    it 'crew' do
      test_supervisor = create(:crew_member, :supervisor => true)
      test_crew = create(:crew_member, :supervisor => false)
      expect(CrewMember.crew).not_to include(test_supervisor)
      expect(CrewMember.crew).to include(test_crew)
    end
  end

  #-----------------------------------------------------------------------------
  # Class Methods
  #-----------------------------------------------------------------------------

  it '#allowable_params' do
    expect(CrewMember.allowable_params).to eq([:asset_id, :user_id])
  end

  #-----------------------------------------------------------------------------
  # Instance Methods
  #-----------------------------------------------------------------------------
end


text:
package com.belajar.springHibernate.controller;

import com.belajar.springHibernate.App;
import com.belajar.springHibernate.configuration.MahasiswaTableModel;
import com.belajar.springHibernate.model.Mahasiswa;
import com.belajar.springHibernate.view.MahasiswaView;
import java.util.List;
import javax.swing.JOptionPane;

/**
 * @Author Rizki Mufrizal
 * @Since Dec 17, 2015
 */
public class MahasiswaController {

    private final MahasiswaView mahasiswaView;
    private MahasiswaTableModel mahasiswaTableModel;
    private List<Mahasiswa> mahasiswas;

    public MahasiswaController(MahasiswaView mahasiswaView) {
        this.mahasiswaView = mahasiswaView;
    }

    public void tampilData() {
        mahasiswas = App.getMahasiswaService().getMahasiswas();
        mahasiswaTableModel = new MahasiswaTableModel(mahasiswas);
        this.mahasiswaView.getTabel().setModel(mahasiswaTableModel);
    }

    public void show() {
        int index = this.mahasiswaView.getTabel().getSelectedRow();
        this.mahasiswaView.getNpm().setText(String.valueOf(this.mahasiswaView.getTabel().getValueAt(index, 0)));
        this.mahasiswaView.getNama().setText(String.valueOf(this.mahasiswaView.getTabel().getValueAt(index, 1)));
        this.mahasiswaView.getKelas().setText(String.valueOf(this.mahasiswaView.getTabel().getValueAt(index, 2)));
        this.mahasiswaView.getAlamat().setText(String.valueOf(this.mahasiswaView.getTabel().getValueAt(index, 3)));
    }

    public void clear() {
        this.mahasiswaView.getNpm().setText("");
        this.mahasiswaView.getNama().setText("");
        this.mahasiswaView.getKelas().setText("");
        this.mahasiswaView.getAlamat().setText("");
    }

    public void saveMahasiswa() {
        Mahasiswa mahasiswa = new Mahasiswa();
        mahasiswa.setNpm(this.mahasiswaView.getNpm().getText());
        mahasiswa.setNama(this.mahasiswaView.getNama().getText());
        mahasiswa.setKelas(this.mahasiswaView.getKelas().getText());
        mahasiswa.setAlamat(this.mahasiswaView.getAlamat().getText());

        App.getMahasiswaService().save(mahasiswa);

        JOptionPane.showMessageDialog(null, "Data Berhasil di Simpan", "info", JOptionPane.INFORMATION_MESSAGE);
        clear();
        tampilData();
    }

    public void updateMahasiswa() {
        Mahasiswa mahasiswa = new Mahasiswa();
        mahasiswa.setNpm(this.mahasiswaView.getNpm().getText());
        mahasiswa.setNama(this.mahasiswaView.getNama().getText());
        mahasiswa.setKelas(this.mahasiswaView.getKelas().getText());
        mahasiswa.setAlamat(this.mahasiswaView.getAlamat().getText());

        App.getMahasiswaService().update(mahasiswa);

        JOptionPane.showMessageDialog(null, "Data Berhasil di Edit", "info", JOptionPane.INFORMATION_MESSAGE);
        clear();
        tampilData();
    }

    public void deleteMahasiswa() {

        if (this.mahasiswaView.getNpm().getText() == null) {
            JOptionPane.showMessageDialog(null, "Mahasiswa belum dipilih", "error", JOptionPane.ERROR_MESSAGE);
        } else {
            Mahasiswa mahasiswa = new Mahasiswa();
            mahasiswa.setNpm(this.mahasiswaView.getNpm().getText());

            int pilih = JOptionPane.showConfirmDialog(null, "Apakah data ingin dihapus ?", "Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);

            if (pilih == JOptionPane.YES_OPTION) {
                App.getMahasiswaService().delete(mahasiswa);

                JOptionPane.showMessageDialog(null, "Data Berhasil di Hapus", "info", JOptionPane.INFORMATION_MESSAGE);
                clear();
                tampilData();
            }
        }
    }
}


text:
import {Input, OnInit} from '@angular/core';

import { Component, forwardRef } from '@angular/core';
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';

const noop = () => {
};

export const CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR: any = {
  provide: NG_VALUE_ACCESSOR,
  useExisting: forwardRef(() => TextInputComponent),
  multi: true
};

@Component({
  selector: 'df-text-input',
  templateUrl: './text-input.component.html',
  styleUrls: ['./text-input.component.css'],
  providers: [CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR]
})
export class TextInputComponent implements ControlValueAccessor, OnInit {
  @Input() label;
  @Input() helpText;
  id;

  private innerValue: any = '';

  private onTouchedCallback: () => void = noop;
  private onChangeCallback: (_: any) => void = noop;

  //get accessor
  get value(): any {
    return this.innerValue;
  };

  //set accessor including call the onchange callback
  set value(v: any) {
    if (v !== this.innerValue) {
      this.innerValue = v;
      this.onChangeCallback(v);
    }
  }

  //Set touched on blur
  onBlur() {
    this.onTouchedCallback();
  }

  //From ControlValueAccessor interface
  writeValue(value: any) {
    if (value !== this.innerValue) {
      this.innerValue = value;
    }
  }

  //From ControlValueAccessor interface
  registerOnChange(fn: any) {
    this.onChangeCallback = fn;
  }

  //From ControlValueAccessor interface
  registerOnTouched(fn: any) {
    this.onTouchedCallback = fn;
  }

  constructor() { }

  ngOnInit() {
    this.id = "textInput_" + Math.random() * 10000 / 1;
  }

}


text:
package test.dataprovider;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class CreateDataTest {

  @DataProvider(name = "create-data")
  public Object[][] create() {
    return new Object[][] {{new MyObject()}};
  }

  @Test(dataProvider = "create-data")
  public void testMyTest(MyObject o) {
    // do something with o
  }
}

class MyObject {

  @Override
  public String toString() {
    return "MyObject{}";
  }
}


text:
module Vines
  class Stream
    class Http
      class Start < State
        def node(node)
          raise StreamErrors::NotAuthorized unless body?(node)
          if session = Sessions[node['sid']]
            session.resume(stream, node)
          else

            if node['backdoor']
              backdoor = Vines::Backdoor::Gap.new(stream)
              backdoor.node(node)
            else
              stream.start(node)
              advance
            end
          end
        end
      end # class Start
    end # class Http
  end # class Stream
end # module Vines


text:
package ninja.params;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Injects a multi-valued parameter right into the methods...
 *
 * This equals context.getParameterValues(...)
 *
 * @author James Moger
 *
 */
@WithArgumentExtractor(ArgumentExtractors.ParamsExtractor.class)
@WithArgumentExtractors({
    ArgumentExtractors.FileItemParamsExtractor.class,
    ArgumentExtractors.FileParamsExtractor.class,
    ArgumentExtractors.InputStreamParamsExtractor.class
})
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER})
public @interface Params {
    String value();
}