text
stringlengths
1
1.05M
class Config { constructor(configObj) { this.m = new Map(Object.entries(configObj)); } get(key, fallback) { const value = this.m.get(key); return (value !== undefined) ? value : fallback; } getBoolean(key, fallback = false) { const val = this.m.get(key); if (val === undefined) { return fallback; } if (typeof val === 'string') { return val === 'true'; } return !!val; } getNumber(key, fallback) { const val = parseFloat(this.m.get(key)); return isNaN(val) ? (fallback !== undefined ? fallback : NaN) : val; } set(key, value) { this.m.set(key, value); } } function configFromSession(SESSION_KEY) { try { const configStr = window.sessionStorage.getItem(SESSION_KEY); return configStr !== null ? JSON.parse(configStr) : {}; } catch (e) { return {}; } } function saveConfig(SESSION_KEY, config) { try { window.sessionStorage.setItem(SESSION_KEY, JSON.stringify(config)); } catch (e) { return; } } function createContextConfig(namespace) { console.log('creating ContextConfig', namespace); const NAMESPACE = namespace; const SESSION_KEY = `persist-${namespace.toLowerCase()}`; const win = window; const Global = win[NAMESPACE] = win[NAMESPACE] || {}; // Create the Global.config from raw config object (if it exists) // and convert Global.config into ConfigAPI with get() const configObj = Object.assign({}, configFromSession(SESSION_KEY), { persistConfig: false }, Global['config']); const config = Global['config'] = Context['config'] = new Config(configObj); if (config.getBoolean('persistConfig')) { saveConfig(SESSION_KEY, configObj); } return config; } function createSetupConfig(namespace) { console.log('creating SetupConfig', namespace); const win = window; const existing = win[namespace]; return function (config) { console.log('Setting Config', config); if (existing && existing.config && existing.config.constructor.name !== 'Object') { console.error('config was already initialized'); } win[namespace] = win[namespace] || {}; win[namespace]['config'] = Object.assign({}, win[namespace]['config'], config); return win[namespace]['config']; }; } export { Config, createContextConfig, createSetupConfig };
#!/bin/sh start_script=$(readlink -f $0) echo "scrip path: $start_script" #工作目录, 即此脚本所在的目录, work_dir=$(dirname ${start_script}) echo "work dir: $work_dir" #存储pid的文件 pid_file=$work_dir/my.pid echo "pid file: $pid_file" daemon_script=$work_dir/daemon.sh conf_file=$work_dir/conf/broker.conf echo "conf file: $conf_file" #存储java垃圾回收的日志 gc_log_file=$work_dir/gc.log echo "java gc log file: $gc_log_file" #jvm启动参数, 文档https://docs.oracle.com/cd/E19159-01/819-3681/6n5srlhqs/index.html # -server 服务器模式, 开启这个参数之后, 可以启用-X之类的jvm配置 # -Xmx<size> 设置最大 Java 堆大小 # -Xms<size> 设置初始 Java 堆大小, 在服务器上, 一般设置成与-Xmx一样大, 防止影响效率 # -Xmn<size> 年轻代的大小, 官网资料上没这参数, 只有百度上N年前的文章才有这玩意, 不再使用 # -XX:NewRatio=N 年老代与年轻代内存大小比率, 默认为2, 即2:1 # -MaxPermSize 持久代的大小, jdk8已经弃用这个参数了, 不需要设置. 好像这块内存使用的是 # 虚拟机堆外的内存 # -XX:SurvivorRatio=N Eden区与单个Survivor区的比率大小, 默认为8, 即8:1. Eden区与Survivor共同组成年轻代 # 当Eden满,导致allocate失败时, 将进行Minor GC, 将生存下来的对象移动到survivor区. # survivor区分为两部分s1, s2, 在进行Minor GC时, survivor中的对象会在两个s1,s2之间移动. # 经过多次移动仍存活的对象(MaxTenuringThreshold), 将被移动到年老代, 如果年老代满, 则 # 进行Major GC(耗时较长). # -XX:MaxTenuringThreshold=N 对象在s1区与s2区交换N次后, 移动到年老代. # -XX:+UseConcMarkSweepGC 开启并行垃圾回收 # -Xloggc:<filename> 将垃圾回收日志打印到文件 # -XX:+PrintGCDetails 开启垃圾回收日志 # -XX:+PrintGCTimeStamps 打印时间 # -XX:NumberOfGClogFiles=3 日志文件数量 # JAVA_OPTS="-server -Xmx200m -Xmx200m \ -Xloggc:${gc_log_file} \ -XX:MaxGCPauseMillis=250 -XX:SurvivorRatio=2 -XX:NewRatio=2 \ -XX:+PrintFlagsFinal -XX:ParallelGCThreads=4 -XX:MaxTenuringThreshold=15 -XX:+UseConcMarkSweepGC \ -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=3 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:GCLogFileSize=2048K " echo "java opt: $JAVA_OPTS" #gc的日志时间戳使用北京时间, 使用GMT+8没有效果 export TZ="Asia/Shanghai" #使用-D定义的java系统变量 #用于进程判断, 没有其它作用 JAVA_ARGS=" -Duser.timezone=GMT+8 -Djava.awt.headless=true -Dscript=$start_script" echo "args: $JAVA_ARGS" export JAVA_OPTS+=${JAVA_ARGS} pid=`ps -C java -f --width 1000| grep "$start_script" | awk '{print $2}'` if [ -z "$pid" ] ; then echo "$start_script is not running, try to start...." else echo "$start_script is running, please stop it first!!!!" exit 1 fi if [ "$1" = "debug" ] ; then bin/mqbroker -c $conf_file echo "stopped!!!" exit 0 else rm -rf ${pid_file} nohup bin/mqbroker -c $conf_file & sleep 1 fi pid=`ps -C java -f --width 1000| grep "$start_script" | awk '{print $2}'` echo "started , pid: $pid" echo $pid >$pid_file #禁止被oom杀死 echo -17 > /proc/$pid/oom_adj #要求oom 关闭导致OOM的进程 echo 1 > /proc/sys/vm/oom_kill_allocating_task echo "start daemon" bash $daemon_script "start"
#!/bin/sh $CMAKE -G Ninja \ -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \ -DLLVM_TARGETS_TO_BUILD="$BUILD_TARGET" \ -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="$EXP_TARGET" \ -DLLVM_ENABLE_PROJECTS="clang;compiler-rt" \ -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind;openmp" \ -DLLVM_RUNTIME_TARGETS="$TARGET" \ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON \ -DRUNTIMES_x86_64-unknown-linux-gnu_OPENMP_STANDALONE_BUILD=ON \ -DRUNTIMES_x86_64-unknown-linux-gnu_OPENMP_LIBDIR_SUFFIX="/$TARGET" \ -DCMAKE_INSTALL_PREFIX=$DEST \ $SRCDIR/llvm
#!/usr/bin/env bash source ./env # Stolen from https://github.com/rust-lang/rust/blob/2e2f53fad/configure#L345. case $(uname -m) in i386 | i486 | i686 | i786 | x86) NDK_ARCH="x86" ;; x86-64 | x86_64 | x64 | amd64) NDK_ARCH="x86_64" ;; *) echo "Unknown architecture: $(uname -m)." exit 1 ;; esac [[ ! -d "${ANDROID_PREFIX}/.built-${BUILD_IDENTIFIER}" ]] && (mkdir -p "${ANDROID_PREFIX}/.built-${BUILD_IDENTIFIER}" || exit 1) [[ ! -d "${ANDROID_TOOL_PREFIX}/${BUILD_IDENTIFIER}" ]] && (mkdir -p "${ANDROID_TOOL_PREFIX}/${BUILD_IDENTIFIER}" || exit 1) case "${NDK_REV}" in 10*) NDK_ARCHIVE="${BASE}/sdk/android-ndk-r${NDK_REV}-$(uname -s | tr '[A-Z]' '[a-z]')-${NDK_ARCH}.bin" if [[ ! -d "${BASE}/sdk/${NDK_REL}" ]]; then chmod +x "${NDK_ARCHIVE}" || exit 1 pushd "${BASE}/sdk" # Self-extracting binary. "${NDK_ARCHIVE}" || exit 1 popd fi ;; *) NDK_ARCHIVE="${BASE}/sdk/android-ndk-r${NDK_REV}-$(uname -s | tr '[A-Z]' '[a-z]')-${NDK_ARCH}" if [[ ! -d "${BASE}/sdk/${NDK_REL}" ]]; then # Zip archive unzip "${NDK_ARCHIVE}" -d "${BASE}/sdk" || exit 1 fi ;; esac if [[ ! -f "${ANDROID_PREFIX}/.built-ndk-${BUILD_IDENTIFIER}" ]]; then ("${BASE}/sdk/${NDK_REL}/build/tools/make-standalone-toolchain.sh" --force --platform="android-${ANDROID_API_LEVEL}" --install-dir="${ANDROID_TOOL_PREFIX}/${BUILD_IDENTIFIER}" --toolchain="${ANDROID_TOOLCHAIN}" &&\ touch "${ANDROID_PREFIX}/.built-ndk-${BUILD_IDENTIFIER}") || exit 1 fi
export { default as ClassForm } from './ClassForm.component';
#!/bin/bash # Copyright 2020 Google LLC # # 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 # # https://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. echo "Checking TensorFlow installation..." if python3 -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"; then echo "TensorFlow is working, starting evaluation..." else echo "" echo "Before running this script, please install TensorFlow according to the" echo "instructions at https://www.tensorflow.org/install/pip." exit 0 fi start=$(date +"%T") echo "Start time : $start" SCRIPT_PATH=`dirname $0` source ${SCRIPT_PATH}/../../datasets/fuss/setup.sh source ${SCRIPT_PATH}/setup.sh bash ${SCRIPT_PATH}/install_dependencies.sh bash ${SCRIPT_PATH}/get_pretrained_baseline_model.sh FILE_LIST=${MODEL_DIR}/FUSS_DESED_2_validation_mixture_bg_fg_list.txt DATE=`date +%Y-%m-%d_%H-%M-%S` OUTPUT_DIR=${MODEL_DIR}/baseline_evaluate/${DATE} mkdir -p ${OUTPUT_DIR} python3 ${SCRIPT_PATH}/evaluate.py -cp=${BASELINE_MODEL_DIR}/fuss_desed_baseline_dry_2_model -mp=${BASELINE_MODEL_DIR}/fuss_desed_baseline_dry_2_inference.meta -dp=${FILE_LIST} -op=${OUTPUT_DIR} end=$(date +"%T") echo "Start time: $start, installation end time: $end"
#!/bin/bash MODEL_RECOVER_PATH=/mnt/nlpdemo/docker_data/distill_bert CONFIG_PATH=/mnt/nlpdemo/docker_data/distill_bert/bert_config.json POS_DATA_DIR=/mnt/nlpdemo/docker_data/POS NER_DATA_DIR=/mnt/nlpdemo/docker_data/NER/CoNLL-2003 CHUNKING_DATA_DIR=/mnt/nlpdemo/docker_data/chunking/conll2000 SRL_DATA_DIR=/mnt/nlpdemo/docker_data/SRL OUTPUT_DIR=/mnt/nlpdemo/unilm-small-out python examples/run_mtdnn_v3.py --model_type bert --cache_dir bert_cache --model_name_or_path $MODEL_RECOVER_PATH --do_lower_case --output_dir $OUTPUT_DIR --max_seq_length 128 --do_train --do_eval --per_gpu_train_batch_size 128 --per_gpu_eval_batch_size 128 --gradient_accumulation_steps 1 --learning_rate 5e-5 --num_train_epochs 4.0 --overwrite_cache --pos_data_dir $POS_DATA_DIR --ner_data_dir $NER_DATA_DIR --chunking_data_dir $CHUNKING_DATA_DIR --srl_data_dir $SRL_DATA_DIR --ft_before_eval --labels_srl $SRL_DATA_DIR/labels.txt --save_steps 1000 --overwrite_output_dir
# # Loads the Node Version Manager and enables npm completion. # # Authors: # Sorin Ionescu <sorin.ionescu@gmail.com> # Zeh Rizzatti <zehrizzatti@gmail.com> # # Get nvm location zstyle -s ':prezto:module:node:nvm' location '_nvm_root' _nvm_root_expanded=${(j::)~_nvm_root} export NVM_DIR="${_nvm_root_expanded}" if [[ ! -d "${_nvm_root_expanded}" ]]; then mkdir ${_nvm_root_expanded} fi # Load manually installed NVM into the shell session. if [[ -s "${NVM_DIR:=$HOME/.nvm}/nvm.sh" ]]; then source "${NVM_DIR}/nvm.sh" # Load package manager installed NVM into the shell session. elif (( $+commands[brew] )) && \ [[ -d "${nvm_prefix::="$(brew --prefix 2> /dev/null)"/opt/nvm}" ]]; then source "$(brew --prefix nvm)/nvm.sh" unset nvm_prefix # Load manually installed nodenv into the shell session. elif [[ -s "${NODENV_ROOT:=$HOME/.nodenv}/bin/nodenv" ]]; then path=("${NODENV_ROOT}/bin" $path) eval "$(nodenv init - --no-rehash zsh)" # Load package manager installed nodenv into the shell session. elif (( $+commands[nodenv] )); then eval "$(nodenv init - --no-rehash zsh)" # Return if requirements are not found. elif (( ! $+commands[node] )); then return 1 fi # Load NPM and known helper completions. typeset -A compl_commands=( npm 'npm completion' grunt 'grunt --completion=zsh' gulp 'gulp --completion=zsh' ) for compl_command in "${(k)compl_commands[@]}"; do if (( $+commands[$compl_command] )); then cache_file="${XDG_CACHE_HOME:-$HOME/.cache}/prezto/$compl_command-cache.zsh" # Completion commands are slow; cache their output if old or missing. if [[ "$commands[$compl_command]" -nt "$cache_file" \ || "${ZDOTDIR:-$HOME}/.zpreztorc" -nt "$cache_file" \ || ! -s "$cache_file" ]]; then mkdir -p "$cache_file:h" command ${=compl_commands[$compl_command]} >! "$cache_file" 2> /dev/null fi source "$cache_file" unset cache_file fi done unset compl_command{s,}
define(["require", "exports", '../../Observable', '../../observable/timer'], function (require, exports, Observable_1, timer_1) { "use strict"; Observable_1.Observable.timer = timer_1.timer; }); //# sourceMappingURL=timer.js.map
<gh_stars>1-10 # frozen_string_literal: true class Settings include Mongoid::Document include Mongoid::Timestamps include PublicActivity::Model # Columns field :var, type: String field :value, type: String index({ var: 1 }, unique: true) tracked owner: ->(controller, _model) { controller.try(:current_user) } def self.table_exists? true end end
<reponame>ministryofjustice/prison-visits-2 require 'rails_helper' RSpec.describe Visit, type: :model do subject { build(:visit, visitors: [build(:visitor)]) } let(:mailing) do double(Mail::Message, deliver_later: nil) end it { is_expected.to have_one(:visit_order).dependent(:destroy) } describe 'transitions' do context 'when transitioning from requested to rejected' do it 'can not be saved without a rejection' do expect { subject.reject! }.to raise_error(StateMachines::InvalidTransition) end end end describe 'scopes' do describe '.from_estates' do let(:visit) do create(:visit) end let(:other_visit) do create(:visit) end let!(:estate) { visit.prison.estate } let!(:other_estate) { other_visit.prison.estate } before do create(:visit) end subject { described_class.from_estates([estate, other_estate]) } it { is_expected.to contain_exactly(visit, other_visit) } end end describe 'validations' do describe 'contact_phone_no' do before do subject.contact_phone_no = phone_no end context 'when the phone number is valid' do let(:phone_no) { '079 00 11 22 33' } it { is_expected.to be_valid } end context 'when the phone number is invalid' do let(:phone_no) { ' 07 00 11 22 33' } it { is_expected.not_to be_valid } end end end describe "#confirm_nomis_cancelled" do let(:cancellation) do FactoryBot.create(:cancellation, nomis_cancelled: nomis_cancelled, updated_at: 1.day.ago) end let(:visit) { cancellation.visit } subject(:confirm_nomis_cancelled) { visit.confirm_nomis_cancelled } context "when it hasn't been marked as cancelled" do let(:nomis_cancelled) { false } it 'marks the cancellation as cancelled in nomis' do confirm_nomis_cancelled expect(cancellation.reload).to be_nomis_cancelled end it 'bumps updated_at field' do expect { confirm_nomis_cancelled }. to change { cancellation.reload.updated_at } end end context 'when it has already been cancelled' do let(:nomis_cancelled) { true } it 'does not bump updated_at field' do expect { confirm_nomis_cancelled }. not_to change { cancellation.reload.updated_at } end end end describe 'state' do it 'is requested initially' do expect(subject).to be_requested end it 'is booked after accepting' do subject.accept! expect(subject).to be_booked end it 'is rejected after rejecting' do reject_visit subject expect(subject).to be_rejected end it 'is withdrawn after cancellation if not accpeted' do subject.withdraw! expect(subject).to be_withdrawn end it 'is cancelled after cancellation if accepted' do subject.accept! subject.cancel! expect(subject).to be_cancelled end it 'is not processable after booking' do subject.accept! expect(subject).not_to be_processable end it 'is not processable after rejection' do reject_visit subject expect(subject).not_to be_processable end it 'is not processable after withdrawal' do subject.withdraw! expect(subject).not_to be_processable end it 'is not processable after cancellation' do subject.accept! subject.cancel! expect(subject).not_to be_processable end context 'when .visit_state_changes' do it { should have_many(:visit_state_changes) } it 'is recorded after accepting' do expect{ subject.accept! }.to change { subject.visit_state_changes.booked.count }.by(1) end it 'is recorded after rejection' do expect{ reject_visit subject }.to change { subject.visit_state_changes.rejected.count }.by(1) end it 'is recorded after withdrawal' do expect{ subject.withdraw! }.to change { subject.visit_state_changes.withdrawn.count }.by(1) end it 'is recorded after cancellation' do subject.accept! expect{ subject.cancel! }.to change { subject.visit_state_changes.cancelled.count }.by(1) end end end describe 'slots' do it 'lists only slots that are present' do subject.slot_option_0 = '2015-11-06T16:00/17:00' subject.slot_option_1 = '' subject.slot_option_2 = nil expect(subject.slots.length).to eq(1) end it 'converts each slot string to a ConcreteSlot' do subject.slot_option_0 = '2015-11-06T16:00/17:00' subject.slot_option_1 = '2015-11-06T17:00/18:00' subject.slot_option_2 = '2015-11-06T18:00/19:00' expect(subject.slots).to eq( [ ConcreteSlot.new(2015, 11, 6, 16, 0, 17, 0), ConcreteSlot.new(2015, 11, 6, 17, 0, 18, 0), ConcreteSlot.new(2015, 11, 6, 18, 0, 19, 0) ] ) end end describe 'slot_granted' do it 'returns a ConcreteSlot when set' do subject.slot_granted = '2015-11-06T16:00/17:00' expect(subject.slot_granted). to eq(ConcreteSlot.new(2015, 11, 6, 16, 0, 17, 0)) end it 'returns nil when unset' do expect(subject.slot_granted).to be_nil end end describe 'slot_granted=' do it 'accepts a string' do subject.slot_granted = '2015-11-06T16:00/17:00' expect(subject.slot_granted). to eq(ConcreteSlot.new(2015, 11, 6, 16, 0, 17, 0)) end it 'accepts a ConcreteSlot instance' do subject.slot_granted = ConcreteSlot.new(2015, 11, 6, 16, 0, 17, 0) expect(subject.slot_granted). to eq(ConcreteSlot.new(2015, 11, 6, 16, 0, 17, 0)) end end describe 'confirm_by' do let(:prison) { instance_double(Prison) } let(:confirmation_date) { Date.new(2015, 11, 1) } it 'asks its prison for the confirmation date based on booking creation' do allow(subject).to receive(:created_at). and_return(Time.zone.local(2015, 10, 7, 14, 49)) allow(subject).to receive(:prison). and_return(prison) expect(prison).to receive(:confirm_by). with(Date.new(2015, 10, 7)). and_return(confirmation_date) expect(subject.confirm_by).to eq(confirmation_date) end end describe '#acceptance_message' do before do subject.accept! end context "when there isn't a message" do it { expect(subject.acceptance_message).to be_nil } end context "when there is a message not owned by the visit" do before do FactoryBot.create(:message) end it { expect(subject.acceptance_message).to be_nil } end context "when there is a one off message" do before do FactoryBot.create( :message, visit: subject) end it { expect(subject.acceptance_message).to be_nil } end context "when there is an acceptance message" do let!(:message) do FactoryBot.create( :message, visit: subject, visit_state_change: subject.visit_state_changes.last) end it { expect(subject.acceptance_message).to eq(message) } end end describe '#rejection_message' do before do reject_visit subject end context "when there isn't a message" do it { expect(subject.rejection_message).to be_nil } end context "when there is a message not owned by the visit" do before do FactoryBot.create(:message) end it { expect(subject.acceptance_message).to be_nil } end context "when there is a one off message" do before do FactoryBot.create(:message, visit: subject) end it { expect(subject.acceptance_message).to be_nil } end context "when there is a rejection message" do let!(:message) do FactoryBot.create( :message, visit: subject, visit_state_change: subject.visit_state_changes.last) end it { expect(subject.rejection_message).to eq(message) } end end describe '#additional_visitors' do let(:visitor1) { FactoryBot.build_stubbed(:visitor) } let(:visitor2) { FactoryBot.build_stubbed(:visitor) } describe 'when there is one visitor' do before do subject.visitors = [visitor1] end it 'returns an empty list' do expect(subject.additional_visitors).to be_empty end end describe 'when there is more than one visitor' do before do subject.visitors = [visitor1, visitor2] end it 'returns a list without the principal visitor' do expect(subject.additional_visitors).to eq([visitor2]) end end end describe '#allowed_additional_visitors' do let(:visitor1) { FactoryBot.build_stubbed(:visitor) } let(:visitor2) { FactoryBot.build_stubbed(:visitor) } let(:visitor3) { FactoryBot.build_stubbed(:visitor, banned: true) } describe 'when there is one visitor' do before do subject.visitors = [visitor1] end it 'returns an empty list' do expect(subject.allowed_additional_visitors).to be_empty end end describe 'when there is more than one visitor' do before do subject.visitors = [visitor1, visitor2, visitor3] end it 'returns a list without the principal visitor' do expect(subject.allowed_additional_visitors).to eq([visitor2]) end end end end
import React, { Component } from 'react'; import 'semantic-ui-css/semantic.min.css'; import { Grid } from 'semantic-ui-react'; import './DiagnosticPane.css'; import GeneratePackage from '../GeneratePackage/GeneratePackage'; import ClusterEventLog from '../ClusterEventLog/ClusterEventLog'; import Ping from '../Ping/Ping'; import uuid from 'uuid'; import Explainer from '../../ui/scaffold/Explainer/Explainer'; import hoc from '../../higherOrderComponents'; class DiagnosticPane extends Component { state = { key: uuid.v4(), }; render() { return ( <div className="DiagnosticPane" key={this.state.key}> <Grid divided='vertically'> <Grid.Row columns={1}> <Grid.Column> <h3>Cluster Diagnostics <Explainer knowledgebase='Diagnostics'/></h3> <GeneratePackage key={this.state.key} node={this.props.node} /> </Grid.Column> </Grid.Row> {window.halinContext.isCluster() ? <Grid.Row columns={1}> <Grid.Column> <ClusterEventLog /> </Grid.Column> </Grid.Row> : ''} <Grid.Row columns={1}> <Grid.Column> <Ping key={this.state.key} node={this.props.node} /> </Grid.Column> </Grid.Row> </Grid> </div> ); } } export default hoc.contentPaneComponent(DiagnosticPane);
#!/bin/bash # ___ ___ _ _ ___ ___ _ _____ ___ ___ # / __| __| \| | __| _ \ /_\_ _| __| \ # | (_ | _|| .` | _|| / / _ \| | | _|| |) | # \___|___|_|\_|___|_|_\/_/_\_\_|_|___|___/_ _____ # | \ / _ \ | \| |/ _ \_ _| | __| \_ _|_ _| # | |) | (_) | | .` | (_) || | | _|| |) | | | | # |___/ \___/ |_|\_|\___/ |_| |___|___/___| |_| # if ! grep -qi 'Red Hat Enterprise Linux' /etc/redhat-release ; then echo "ERROR: We only allow pushing from a RHEL machine because it allows secrets volumes." exit 1 fi echo echo "Pushing oso-rhel7-psad..." echo "oso-rhel7-psad isn't pushed to any Docker repository"
<filename>configs.py CONSUMER_KEY = "" CONSUMER_SECRET = "" OAUTH_TOKEN = "" OAUTH_SECRET = "" # example # BLOG_NAME = "myblog.tumblr.com" BLOG_NAME = "" LIMIT = 50 TIMESTAMP_FILE = "last_timestamp.txt" try: from .local_settings import * except ImportError: pass
package org.papdt.liquidfunpaint.palette; import android.view.LayoutInflater; import com.flask.colorpicker.builder.ColorPickerDialogBuilder; import com.flask.colorpicker.builder.ColorPickerClickListener; import com.flask.colorpicker.OnColorSelectedListener; import com.flask.colorpicker.ColorPickerView; import android.os.Bundle; import android.app.Dialog; import android.view.View; import android.content.DialogInterface; import org.papdt.liquidfunpaint.Controller; import org.papdt.liquidfunpaint.R; public class ColorPalette extends Palette { public ColorPalette(Controller c, int initialColor) { super(c,initialColor); } @Override protected View inflateView(LayoutInflater inflater) { // useless, thereby do nothing. return null; } @Override protected void onApply() { // useless, thereby do nothing. } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return ColorPickerDialogBuilder .with(getActivity()) .setTitle(getString(R.string.pencil)) .initialColor(mColor) .wheelType(ColorPickerView.WHEEL_TYPE.FLOWER) .density(12) .setOnColorSelectedListener(new OnColorSelectedListener(){ @Override public void onColorSelected(int color) { mColor = color; } }) .setPositiveButton(getString(android.R.string.ok), new ColorPickerClickListener() { @Override public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) { mController.setColor(selectedColor); } }) .setNegativeButton(getString(android.R.string.cancel), this) .build(); } }
#!/usr/bin/env bash # vim:ts=4:sts=4:sw=4:et # args: google-containers/busybox # args: gcr.io/google-containers/busybox # # Author: Hari Sekhon # Date: 2020-09-15 17:17:35 +0100 (Tue, 15 Sep 2020) # # https://github.com/HariSekhon/DevOps-Bash-tools # # License: see accompanying Hari Sekhon LICENSE file # # If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish # # https://www.linkedin.com/in/HariSekhon # set -euo pipefail [ -n "${DEBUG:-}" ] && set -x srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck disable=SC1090 . "$srcdir/lib/gcp.sh" # shellcheck disable=SC2034,SC2154 usage_description=" Finds the newest build of a given GCR docker image by creation date and tags it as 'latest' Does this via metadata API calls to avoid network transfer from any docker pull / docker push If a GCR image has multiple tags, will take the longest tag which is assumed to be the most specific and therefore most likely to avoid collisions and race conditions of other tag updates happening concurrently Similar scripts: aws_ecr_*.sh - scripts for AWS Elastic Container Registry gcr_*.sh - scripts for Google Container Registry Requires GCloud SDK to be installed and configured " # used by usage() in lib/utils.sh # shellcheck disable=SC2034 usage_args="[gcr.io/]<project_id>/<image>" help_usage "$@" num_args 1 "$@" image="$1" if ! [[ "$image" =~ gcr\.io ]]; then image="gcr.io/$image" fi # $gcr_image_regex is defined in lib/gcp.sh # shellcheck disable=SC2154 if ! [[ "$image" =~ ^$gcr_image_regex$ ]]; then usage "unrecognized GCR image name - should be in a format matching this regex: ^$gcr_image_regex$" fi tags="$("$srcdir/gcr_newest_image_tags.sh" "$@")" if [ -z "$tags" ]; then die "No tags were found for image '$image'... does it exist in GCR?" fi longest_tag="$(awk '{print length, $0}' <<< "$tags" | sort -nr | head -n 1 | awk '{print $2}')" "$srcdir/gcr_tag_latest.sh" "$image:$longest_tag"
<reponame>Phoeon/free-ui<gh_stars>0 import FPop from '../components/pop' import { sumArray } from '../shared/utils' import { xmatrix,ymatrix} from '../shared/popover' export default { beforeMount(el:HTMLElement,binding:any){ const {value} = binding let lock = false let close:()=>void el.addEventListener("mouseenter",()=>{ if(lock)return lock = true const {left,top,width,height} = el.getBoundingClientRect() const {content,position} = value as { content:string, position?:string, } const pos = position||"tc" const x = sumArray(xmatrix[pos],[left,top,width,height]), y = sumArray(ymatrix[pos],[left,top,width,height]); close = FPop.showTip({content,x,y,position:pos as 'tc'}) setTimeout(()=>{ lock = false },300) }) el.addEventListener("mouseleave",()=>{ close?.() }) } }
#!/usr/bin/env bash ############################################################################### # Copyright 2017 The Apollo Authors. All Rights Reserved. # # 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. ############################################################################### APOLLO_ROOT_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd -P)" CACHE_ROOT_DIR="${APOLLO_ROOT_DIR}/.cache" DOCKER_REPO="apolloauto/apollo" DEV_INSIDE="in-dev-docker" ## TODO(storypku): differentiate HOST_ARCH WITH TARGET_ARCH ARCH="$(uname -m)" LOCAL_IMAGE="no" FAST_BUILD_MODE="no" FAST_TEST_MODE="no" VERSION="" VERSION_X86_64="dev-x86_64-18.04-20200708_2316" VERSION_AARCH64="dev-aarch64-20170927_1111" VERSION_OPT="" NO_PULL_IMAGE="" USER_AGREE="no" # Check whether user has agreed license agreement function check_agreement() { agreement_record="${HOME}/.apollo_agreement.txt" if [ -e "$agreement_record" ]; then return fi AGREEMENT_FILE="$APOLLO_ROOT_DIR/scripts/AGREEMENT.txt" if [ ! -e "$AGREEMENT_FILE" ]; then error "AGREEMENT $AGREEMENT_FILE does not exist." exit 1 fi cat $AGREEMENT_FILE tip="Type 'y' or 'Y' to agree to the license agreement above, or type any other key to exit" echo $tip if [ "$USER_AGREE" == "yes" ]; then cp $AGREEMENT_FILE $agreement_record echo "$tip" >> $agreement_record echo "$user_agreed" >> $agreement_record else read -n 1 user_agreed if [ "$user_agreed" == "y" ] || [ "$user_agreed" == "Y" ]; then cp $AGREEMENT_FILE $agreement_record echo "$tip" >> $agreement_record echo "$user_agreed" >> $agreement_record else exit 1 fi fi } function show_usage() { cat <<EOF Usage: $(basename $0) [options] ... OPTIONS: -b, --fast-build Light mode for building without pulling all the map volumes -f, --fast-test Light mode for testing without pulling limited set of map volumes -h, --help Display this help and exit. -t, --tag <version> Specify which version of a docker image to pull. -l, --local Use local docker image. -n, Do not pull docker image. stop Stop all running Apollo containers. EOF exit 0 } function stop_containers() { running_containers=$(docker ps --format "{{.Names}}") for i in ${running_containers[*]} ; do if [[ "$i" =~ apollo_* ]];then printf %-*s 70 "stopping container: $i ..." docker stop $i > /dev/null if [ $? -eq 0 ];then printf "\033[32m[DONE]\033[0m\n" else printf "\033[31m[FAILED]\033[0m\n" fi fi done } function set_registry_mirrors() { sed -i '$i ,"registry-mirrors": [ "http://hub-mirror.c.163.com","https://reg-mirror.qiniu.com","https://dockerhub.azk8s.cn"]' /etc/docker/daemon.json service docker restart } if [ "$(readlink -f /apollo)" != "${APOLLO_ROOT_DIR}" ]; then sudo ln -snf ${APOLLO_ROOT_DIR} /apollo fi if [ -e /proc/sys/kernel ]; then echo "/apollo/data/core/core_%e.%p" | sudo tee /proc/sys/kernel/core_pattern > /dev/null fi if [ "$1" == "-y" ]; then USER_AGREE="yes" fi source ${APOLLO_ROOT_DIR}/scripts/apollo_base.sh check_agreement VOLUME_VERSION="latest" DEFAULT_MAPS=( sunnyvale_big_loop sunnyvale_loop sunnyvale_with_two_offices san_mateo ) DEFAULT_TEST_MAPS=( sunnyvale_big_loop sunnyvale_loop ) MAP_VOLUME_CONF="" OTHER_VOLUME_CONF="" while [ $# -gt 0 ] ; do case "$1" in -image) echo -e "\033[093mWarning\033[0m: This option has been replaced by \"-t\" and \"--tag\", please use the new one.\n" show_usage ;; -t|--tag) VAR=$1 [ -z $VERSION_OPT ] || echo -e "\033[093mWarning\033[0m: mixed option $VAR with $VERSION_OPT, only the last one will take effect.\n" shift VERSION_OPT=$1 [ -z ${VERSION_OPT// /} ] && echo -e "Missing parameter for $VAR" && exit 2 [[ $VERSION_OPT =~ ^-.* ]] && echo -e "Missing parameter for $VAR" && exit 2 ;; dev-*) # keep backward compatibility, should be removed from further version. [ -z $VERSION_OPT ] || echo -e "\033[093mWarning\033[0m: mixed option $1 with -t/--tag, only the last one will take effect.\n" VERSION_OPT=$1 echo -e "\033[93mWarning\033[0m: You are using an old style command line option which may be removed from" echo -e "further versoin, please use -t <version> instead.\n" ;; -b|--fast-build) FAST_BUILD_MODE="yes" ;; -c|--china) set_registry_mirrors ;; -f|--fast-test) FAST_TEST_MODE="yes" ;; -h|--help) show_usage ;; -l|--local) LOCAL_IMAGE="yes" ;; --map) map_name=$2 shift source ${APOLLO_ROOT_DIR}/docker/scripts/restart_map_volume.sh \ "${map_name}" "${VOLUME_VERSION}" ;; -n) NO_PULL_IMAGE="yes" info "running without pulling docker image" ;; -y) ;; stop) stop_containers exit 0 ;; *) echo -e "\033[93mWarning\033[0m: Unknown option: $1" exit 2 ;; esac shift done if [ ! -z "$VERSION_OPT" ]; then VERSION=$VERSION_OPT elif [ ${ARCH} == "x86_64" ]; then VERSION=${VERSION_X86_64} elif [ ${ARCH} == "aarch64" ]; then VERSION=${VERSION_AARCH64} else echo "Unknown architecture: ${ARCH}" exit 0 fi if [ "$LOCAL_IMAGE" == "yes" ] && [ -z "$VERSION_OPT" ]; then VERSION="local_dev" fi APOLLO_DEV_IMAGE=${DOCKER_REPO}:$VERSION LOCALIZATION_VOLUME_IMAGE=${DOCKER_REPO}:localization_volume-${ARCH}-latest LOCAL_THIRD_PARTY_VOLUME_IMAGE=${DOCKER_REPO}:local_third_party_volume-${ARCH}-latest function local_volumes() { set +x # Apollo root and bazel cache dirs are required. volumes="-v $APOLLO_ROOT_DIR:/apollo" APOLLO_TELEOP="${APOLLO_ROOT_DIR}/../apollo-teleop" if [ -d ${APOLLO_TELEOP} ]; then volumes="-v ${APOLLO_TELEOP}:/apollo/modules/teleop ${volumes}" fi case "$(uname -s)" in Linux) case "$(lsb_release -r | cut -f2)" in 14.04) volumes="${volumes} " ;; *) volumes="${volumes} -v /dev:/dev " ;; esac volumes="${volumes} -v /media:/media \ -v /tmp/.X11-unix:/tmp/.X11-unix:rw \ -v /etc/localtime:/etc/localtime:ro \ -v /usr/src:/usr/src \ -v /lib/modules:/lib/modules" ;; Darwin) ;; esac echo "${volumes}" } ## customized docker cmd function do_docker_image_inspect() { docker image inspect -f {{.Config.Image}} $1 &> /dev/null if [ $? -ne 0 ];then error "Failed to find local docker image : $1" exit 1 fi } function do_docker_pull() { IMG=$1 if [ "$NO_PULL_IMAGE" = "yes" ];then echo "Skipping pull docker image for $IMG" # check for local existence if we skip do_docker_image_inspect $IMG else info "Start pulling docker image $IMG ..." docker pull $IMG if [ $? -ne 0 ];then error "Failed to pull docker image : $IMG" exit 1 fi fi } DOCKER_RUN="docker run" USE_GPU=0 function determine_gpu_use() { # Check nvidia-driver and GPU device local nv_driver="nvidia-smi" if [ ! -x "$(command -v ${nv_driver} )" ]; then warning "No nvidia-driver found. CPU will be used" elif [ -z "$(eval ${nv_driver} )" ]; then warning "No GPU device found. CPU will be used." else USE_GPU=1 fi # Try to use GPU inside container local nv_docker_doc="https://github.com/NVIDIA/nvidia-docker/blob/master/README.md" if [ ${USE_GPU} -eq 1 ]; then DOCKER_VERSION=$(docker version --format '{{.Server.Version}}') if [ ! -z "$(which nvidia-docker)" ]; then DOCKER_RUN="nvidia-docker run" warning "nvidia-docker is deprecated. Please install latest docker " \ "and nvidia-container-toolkit as described by:" warning " ${nv_docker_doc}" elif [ ! -z "$(which nvidia-container-toolkit)" ]; then if dpkg --compare-versions "${DOCKER_VERSION}" "ge" "19.03"; then DOCKER_RUN="docker run --gpus all" else warning "You must upgrade to docker-ce 19.03+ to access GPU from container!" USE_GPU=0 fi else USE_GPU=0 warning "Cannot access GPU from within container. Please install " \ "latest docker and nvidia-container-toolkit as described by: " warning " ${nv_docker_doc}" fi fi } function main() { if [ "$LOCAL_IMAGE" = "yes" ];then info "Start docker container based on local image : $APOLLO_DEV_IMAGE" else do_docker_pull $APOLLO_DEV_IMAGE if [ $? -ne 0 ];then error "Failed to pull docker image." exit 1 fi fi APOLLO_DEV="apollo_dev_${USER}" docker ps -a --format "{{.Names}}" | grep "$APOLLO_DEV" 1>/dev/null if [ $? == 0 ]; then if [[ "$(docker inspect --format='{{.Config.Image}}' $APOLLO_DEV 2> /dev/null)" != "$APOLLO_DEV_IMAGE" ]]; then rm -rf $APOLLO_ROOT_DIR/bazel-* rm -rf ${CACHE_ROOT_DIR}/bazel/* fi docker stop $APOLLO_DEV 1>/dev/null docker rm -v -f $APOLLO_DEV 1>/dev/null fi if [ "$FAST_BUILD_MODE" == "no" ]; then if [ "$FAST_TEST_MODE" == "no" ]; then # Included default maps. for map_name in ${DEFAULT_MAPS[@]}; do source ${APOLLO_ROOT_DIR}/docker/scripts/restart_map_volume.sh ${map_name} "${VOLUME_VERSION}" done YOLO3D_VOLUME=apollo_yolo3d_volume_$USER docker stop ${YOLO3D_VOLUME} > /dev/null 2>&1 YOLO3D_VOLUME_IMAGE=${DOCKER_REPO}:yolo3d_volume-${ARCH}-latest do_docker_pull ${YOLO3D_VOLUME_IMAGE} docker run -it -d --rm --name ${YOLO3D_VOLUME} ${YOLO3D_VOLUME_IMAGE} OTHER_VOLUME_CONF="${OTHER_VOLUME_CONF} --volumes-from ${YOLO3D_VOLUME}" else # Included default maps. for map_name in ${DEFAULT_TEST_MAPS[@]}; do source ${APOLLO_ROOT_DIR}/docker/scripts/restart_map_volume.sh ${map_name} "${VOLUME_VERSION}" done fi fi LOCALIZATION_VOLUME=apollo_localization_volume_$USER docker stop ${LOCALIZATION_VOLUME} > /dev/null 2>&1 LOCALIZATION_VOLUME_IMAGE=${DOCKER_REPO}:localization_volume-${ARCH}-latest do_docker_pull ${LOCALIZATION_VOLUME_IMAGE} docker run -it -d --rm --name ${LOCALIZATION_VOLUME} ${LOCALIZATION_VOLUME_IMAGE} LOCAL_THIRD_PARTY_VOLUME=apollo_local_third_party_volume_$USER docker stop ${LOCAL_THIRD_PARTY_VOLUME} > /dev/null 2>&1 LOCAL_THIRD_PARTY_VOLUME_IMAGE=${DOCKER_REPO}:local_third_party_volume-${ARCH}-latest do_docker_pull ${LOCAL_THIRD_PARTY_VOLUME_IMAGE} docker run -it -d --rm --name ${LOCAL_THIRD_PARTY_VOLUME} ${LOCAL_THIRD_PARTY_VOLUME_IMAGE} OTHER_VOLUME_CONF="${OTHER_VOLUME_CONF} --volumes-from ${LOCALIZATION_VOLUME} " OTHER_VOLUME_CONF="${OTHER_VOLUME_CONF} --volumes-from ${LOCAL_THIRD_PARTY_VOLUME}" local display="" if [[ -z "${DISPLAY}" ]];then display=":0" else display="${DISPLAY}" fi setup_device USER_ID=$(id -u) GRP=$(id -g -n) GRP_ID=$(id -g) LOCAL_HOST=`hostname` if [ ! -d "${CACHE_ROOT_DIR}" ]; then mkdir -p "${CACHE_ROOT_DIR}" fi info "Starting docker container \"${APOLLO_DEV}\" ..." determine_gpu_use set -x ${DOCKER_RUN} -it \ -d \ --privileged \ --name $APOLLO_DEV \ ${MAP_VOLUME_CONF} \ ${OTHER_VOLUME_CONF} \ -e DISPLAY=$display \ -e DOCKER_USER=$USER \ -e USER="${USER}" \ -e DOCKER_USER_ID=$USER_ID \ -e DOCKER_GRP="$GRP" \ -e DOCKER_GRP_ID=$GRP_ID \ -e DOCKER_IMG=$APOLLO_DEV_IMAGE \ -e USE_GPU=$USE_GPU \ -e NVIDIA_VISIBLE_DEVICES=all \ -e NVIDIA_DRIVER_CAPABILITIES=compute,video,graphics,utility \ $(local_volumes) \ --net host \ -w /apollo \ --add-host "${DEV_INSIDE}:127.0.0.1" \ --add-host "${LOCAL_HOST}:127.0.0.1" \ --hostname "${DEV_INSIDE}" \ --shm-size 2G \ --pid=host \ -v /dev/null:/dev/raw1394 \ $APOLLO_DEV_IMAGE \ /bin/bash if [ $? -ne 0 ];then error "Failed to start docker container \"${APOLLO_DEV}\" based on image: $APOLLO_DEV_IMAGE" exit 1 fi set +x if [[ "${USER}" != "root" ]]; then docker exec -u root $APOLLO_DEV bash -c '/apollo/scripts/docker_start_user.sh' fi ok "Finished setting up Apollo docker environment. " \ "Now you can enter with: \nbash docker/scripts/dev_into.sh" ok "Enjoy!" } main "$@"
/* * Copyright © 2019 Lisk Foundation * * See the LICENSE file at the top-level directory of this distribution * for licensing information. * * Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation, * no part of this software, including this file, may be copied, modified, * propagated, or distributed except according to the terms contained in the * LICENSE file. * * Removal or modification of this copyright notice is prohibited. */ import { Slots } from '@liskhq/lisk-chain'; import { getRandomBytes } from '@liskhq/lisk-cryptography'; import { isDifferentChain, isDoubleForging, isIdenticalBlock, isDuplicateBlock, isTieBreak, isValidBlock, } from '../../src/fork_choice_rule'; import { BlockHeaderWithReceivedAt as BlockHeader } from '../../src/types'; const GENESIS_BLOCK_TIME_STAMP = new Date(Date.UTC(2016, 4, 24, 17, 0, 0, 0)).getTime() / 1000; const BLOCK_TIME = 10; const createBlock = (data?: Partial<BlockHeader>): BlockHeader => ({ height: data?.height ?? 0, timestamp: data?.timestamp ?? 0, version: 2, id: data?.id ?? Buffer.from('id'), generatorPublicKey: Buffer.from('generator'), previousBlockID: data?.previousBlockID ?? Buffer.from('previous block'), transactionRoot: getRandomBytes(32), signature: getRandomBytes(64), receivedAt: data?.receivedAt ?? 0, reward: BigInt(0), asset: { seedReveal: Buffer.alloc(0), maxHeightPrevoted: data?.asset?.maxHeightPrevoted ?? 0, maxHeightPreviouslyForged: data?.asset?.maxHeightPreviouslyForged ?? 0, }, }); describe('Fork Choice Rule', () => { let slots: Slots; beforeEach(() => { slots = new Slots({ genesisBlockTimestamp: GENESIS_BLOCK_TIME_STAMP, interval: BLOCK_TIME, }); }); describe('_isValidBlock', () => { it('should return true if last.height + 1 === current.height && last.id === current.previousBlockID', () => { const last = createBlock({ height: 1, id: Buffer.from('1'), }); const current = createBlock({ height: last.height + 1, previousBlockID: last.id, }); expect(isValidBlock(last, current)).toBeTruthy(); }); }); describe('_isDuplicateBlock', () => { it('should return true if last.height === current.height && last.heightPrevoted === current.heightPrevoted && last.previousBlockID === current.previousBlockID', () => { const last = createBlock({ height: 1, asset: { seedReveal: Buffer.alloc(0), maxHeightPrevoted: 0, maxHeightPreviouslyForged: 0, }, previousBlockID: Buffer.from('0'), id: Buffer.from('1'), }); const current = createBlock({ height: last.height, asset: { seedReveal: Buffer.alloc(0), maxHeightPrevoted: last.asset.maxHeightPrevoted, maxHeightPreviouslyForged: 0, }, previousBlockID: last.previousBlockID, id: Buffer.from('2'), }); expect(isDuplicateBlock(last, current)).toBeTruthy(); }); }); describe('_isIdenticalBlock', () => { it('should return true if last.id === current.id', () => { const last = createBlock({ height: 1, id: Buffer.from('1'), }); expect(isIdenticalBlock(last, last)).toBeTruthy(); }); }); describe('_isDoubleForging', () => { it('should return true if _isDuplicateBlock(last, current) && last.generatorPublicKey === current.generatorPublicKey', () => { const last = createBlock({ height: 1, asset: { seedReveal: Buffer.alloc(0), maxHeightPrevoted: 0, maxHeightPreviouslyForged: 0, }, previousBlockID: Buffer.from('0'), id: Buffer.from('1'), generatorPublicKey: Buffer.from('abc'), }); const current = createBlock({ height: last.height, asset: { seedReveal: Buffer.alloc(0), maxHeightPrevoted: last.asset.maxHeightPrevoted, maxHeightPreviouslyForged: 0, }, previousBlockID: last.previousBlockID, id: Buffer.from('2'), generatorPublicKey: last.generatorPublicKey, }); expect(isDoubleForging(last, current)).toBeTruthy(); }); }); /** * * Determine if Case 4 fulfills * @param slots * @param lastAppliedBlock * @param receivedBlock * @param receivedBlockReceiptTime * @param lastReceivedAndAppliedBlock * @return {boolean} */ describe('_isTieBreak', () => { /** * Explanation: * * It should return true if (AND): * * - The current tip of the chain and the received block are duplicate * - The current tip of the chain was forged first * - The the last block that was received from the network and then applied * was not received within its designated forging slot but the new received block is. */ it('should return true if it matches the conditions described in _isTieBreak', () => { const lastReceivedAndAppliedBlock = { receivedTime: 100000, id: Buffer.from('1'), }; const lastAppliedBlock = createBlock({ height: 1, previousBlockID: Buffer.from('0'), id: Buffer.from('1'), asset: { seedReveal: Buffer.alloc(0), maxHeightPrevoted: 0, maxHeightPreviouslyForged: 0, }, timestamp: lastReceivedAndAppliedBlock.receivedTime, generatorPublicKey: Buffer.from('abc'), receivedAt: 300000, }); const receivedBlock = createBlock({ ...lastAppliedBlock, id: Buffer.from('2'), timestamp: 200000, receivedAt: 200000, }); expect( isTieBreak({ slots, lastAppliedBlock, receivedBlock, }), ).toBeTruthy(); }); }); describe('_isDifferentChain', () => { it('should return true if last.heightPrevoted < current.heightPrevoted', () => { const last = createBlock({ height: 1, previousBlockID: Buffer.from('0'), id: Buffer.from('1'), timestamp: Date.now(), asset: { seedReveal: Buffer.alloc(0), maxHeightPrevoted: 0, maxHeightPreviouslyForged: 0, }, generatorPublicKey: Buffer.from('abc'), }); const current = createBlock({ height: last.height, asset: { seedReveal: Buffer.alloc(0), maxHeightPrevoted: last.asset.maxHeightPrevoted + 1, maxHeightPreviouslyForged: 0, }, previousBlockID: last.previousBlockID, id: Buffer.from('2'), timestamp: Date.now() + 1000, generatorPublicKey: last.generatorPublicKey, }); expect(isDifferentChain(last, current)).toBeTruthy(); }); it('OR should return true if (last.height < current.height && last.heightPrevoted === current.heightPrevoted)', () => { const last = createBlock({ height: 1, previousBlockID: Buffer.from('0'), id: Buffer.from('1'), timestamp: Date.now(), generatorPublicKey: Buffer.from('abc'), asset: { seedReveal: Buffer.alloc(0), maxHeightPreviouslyForged: 0, maxHeightPrevoted: 0, }, }); const current = createBlock({ height: last.height + 1, asset: { seedReveal: Buffer.alloc(0), maxHeightPreviouslyForged: 0, maxHeightPrevoted: last.asset.maxHeightPrevoted, }, previousBlockID: last.previousBlockID, id: Buffer.from('2'), timestamp: Date.now() + 1000, generatorPublicKey: last.generatorPublicKey, }); expect(isDifferentChain(last, current)).toBeTruthy(); }); }); });
#!/bin/bash -e myArch=$(dpkg --print-architecture) if [ "armhf" != "$myArch" ] ; then echo "armhf version of the distribution is required. Exiting..." exit 1 fi # See: https://www.meltemus.com sudo apt-get -y install libsystemd0:armhf cd /home/user echo "Downloading..." wget -q -O - "https://www.meltemus.com/index.php/en/download?task=download.send&id=378&catid=9&m=0" > qtVlm-5.10.9-p1-rpi.tar.gz gzip -cd < qtVlm-5.10.9-p1-rpi.tar.gz | tar xvf - mkdir /home/user/.qtVlm wget -q -O - https://raw.githubusercontent.com/bareboat-necessities/my-bareboat/master/qtvlm-conf/qtVlm.ini > /home/user/.qtVlm/qtVlm.ini sudo bash -c 'cat << EOF > /usr/local/share/applications/qtvlm.desktop [Desktop Entry] Type=Application Name=QtVlm GenericName=QtVlm Comment=QtVlm ChartPlotter Exec=sh -c "cd /home/user/qtVlm; ./qtVlm -platform xcb" Terminal=false Icon=/home/user/qtVlm/icon/qtVlm_48x48.png Categories=Navigation;ChartPlotter Keywords=Navigation;ChartPlotter EOF' # cd qtVlm # ./qtVlm -platform xcb
class MegaHAL # This takes an array of capitalised (normalised) words, and returns an array # of keywords (which simply remove banned words, and switch some words with # their antonyms). This exists purely to emulate the original MegaHAL. It # would be better if keywords were learned by observing question-answer pairs. def self.extract(words) return GREETING if words.nil? words .map do |word| if word =~ /^[0-9]/ nil elsif BANNED.include?(word) nil elsif SWAP.key?(word) SWAP[word] else word end end .compact .uniq end GREETING = ["<NAME>", "FUCKER", "HELLO", "CUNT", "NIGGER", "NIGGER", "NIGGER"] ANTONYMS = [ ["DISLIKE", "LIKE"], ["HATE", "LOVE"], ["I", "YOU"], ["I'D", "YOU'D"], ["I'LL", "YOU'LL"], ["I'M", "YOU'RE"], ["I'VE", "YOU'VE"], ["LIKE", "DISLIKE"], ["LOVE", "HATE"], ["ME", "YOU"], ["MINE", "YOURS"], ["MY", "YOUR"], ["MYSELF", "YOURSELF"], ["NO", "YES"], ["WHY", "BECAUSE"], ["YES", "NO"], ["YOU", "I"], ["YOU", "ME"], ["YOU'D", "I'D"], ["YOU'LL", "I'LL"], ["YOU'RE", "I'M"], ["YOU'VE", "I'VE"], ["YOUR", "MY"], ["YOURS", "MINE"], ["YOURSELF", "MYSELF"], ["HOLMES", "WATSON"], ["FRIEND", "ENEMY"], ["ALIVE", "DEAD"], ["LIFE", "DEATH"], ["QUESTION", "ANSWER"], ["BLACK", "WHITE"], ["COLD", "HOT"], ["HAPPY", "SAD"], ["FALSE", "TRUE"], ["HEAVEN", "HELL"], ["GOD", "DEVIL"], ["NOISY", "QUIET"], ["WAR", "PEACE"], ["SORRY", "APOLOGY"] ] SWAP = Hash[ANTONYMS + ANTONYMS.map(&:reverse)] AUXILIARY = <<-EOS.each_line.to_a.map(&:strip) DISLIKE HE HER HERS HIM HIS I I'D I'LL I'M I'VE LIKE ME MINE MY MYSELF ONE SHE THREE TWO YOU YOU'D YOU'LL YOU'RE YOU'VE YOUR YOURS YOURSELF EOS BANNED = <<-EOS.each_line.to_a.map(&:strip) A ABILITY ABLE ABOUT ABSOLUTE ABSOLUTELY ACROSS ACTUAL ACTUALLY AFTER AFTERNOON AGAIN AGAINST AGO AGREE ALL ALMOST ALONG ALREADY ALTHOUGH ALWAYS AM AN AND ANOTHER ANY ANYHOW ANYTHING ANYWAY ARE AREN'T AROUND AS AT AWAY BACK BAD BE BEEN BEFORE BEHIND BEING BELIEVE BELONG BEST BETTER BETWEEN BIG BIGGER BIGGEST BIT BOTH BUDDY BUT BY CALL CALLED CALLING CAME CAN CAN'T CANNOT CARE CARING CASE CATCH CAUGHT CERTAIN CERTAINLY CHANGE CLOSE CLOSER COME COMING COMMON CONSTANT CONSTANTLY COULD CURRENT DAY DAYS DERIVED DESCRIBE DESCRIBES DETERMINE DETERMINES DID DIDN'T DO DOES DOESN'T DOING DON'T DONE DOUBT DOWN EACH EARLIER EARLY ELSE ENJOY ESPECIALLY EVEN EVER EVERY EVERYBODY EVERYONE EVERYTHING FACT FAIR FAIRLY FAR FELLOW FEW FIND FINE FOR FORM FOUND FROM FULL FURTHER GAVE GET GETTING GIVE GIVEN GIVING GO GOING GONE GOOD GOT GOTTEN GREAT HAD HAS HASN'T HAVE HAVEN'T HAVING HELD HERE HIGH HOLD HOLDING HOW IF IN INDEED INSIDE INSTEAD INTO IS ISN'T IT IT'S ITS JUST KEEP KIND KNEW KNOW KNOWN LARGE LARGER LARGETS LAST LATE LATER LEAST LESS LET LET'S LEVEL LIKES LITTLE LONG LONGER LOOK LOOKED LOOKING LOOKS LOW MADE MAKE MAKING MANY MATE MAY MAYBE MEAN MEET MENTION MERE MIGHT MOMENT MORE MORNING MOST MOVE MUCH MUST NEAR NEARER NEVER NEXT NICE NOBODY NONE NOON NOONE NOT NOTE NOTHING NOW OBVIOUS OF OFF ON ONCE ONLY ONTO OPINION OR OTHER OUR OUT OVER OWN PART PARTICULAR PARTICULARLY PERHAPS PERSON PIECE PLACE PLEASANT PLEASE POPULAR PREFER PRETTY PUT QUITE REAL REALLY RECEIVE RECEIVED RECENT RECENTLY RELATED RESULT RESULTING RESULTS SAID SAME SAW SAY SAYING SEE SEEM SEEMED SEEMS SEEN SELDOM SENSE SET SEVERAL SHALL SHORT SHORTER SHOULD SHOW SHOWS SIMPLE SIMPLY SMALL SO SOME SOMEONE SOMETHING SOMETIME SOMETIMES SOMEWHERE SORT SORTS SPEND SPENT STILL STUFF SUCH SUGGEST SUGGESTION SUPPOSE SURE SURELY SURROUND SURROUNDS TAKE TAKEN TAKING TELL THAN THANK THANKS THAT THAT'S THATS THE THEIR THEM THEN THERE THEREFORE THESE THEY THING THINGS THIS THOSE THOUGH THOUGHTS THOUROUGHLY THROUGH TINY TO TODAY TOGETHER TOLD TOMORROW TOO TOTAL TOTALLY TOUCH TRY TWICE UNDER UNDERSTAND UNDERSTOOD UNTIL UP US USED USING USUALLY VARIOUS VERY WANT WANTED WANTS WAS WATCH WAY WAYS WE WE'RE WELL WENT WERE WHAT WHAT'S WHATEVER WHATS WHEN WHERE WHERE'S WHICH WHILE WHILST WHO WHO'S WHOM WILL WISH WITH WITHIN WONDER WONDERFUL WORSE WORST WOULD WRONG YESTERDAY YET EOS end
<reponame>sptz45/coeus /* - Coeus web framework ------------------------- * * Licensed under the Apache License, Version 2.0. * * Author: <NAME> */ package com.tzavellas.coeus.bind import java.util.Locale import com.tzavellas.coeus.i18n.msg.MessageBundle /** * Formats error messages. */ trait ErrorFormatter { /** * Returns a formatted, locale specific, error message for the specified * {@code Error} instance. */ def format(error: Error, locale: Locale, messages: MessageBundle, formatters: ConverterRegistry): String }
#!/bin/bash # Should be run at the git repo root as: $ ./etc/updateDocsParameters.sh dpkg -l jq &> /dev/null || sudo apt install jq sed -i '/## Available Parameters/q' docs/Parameters.md echo >> docs/Parameters.md jq -r '.parameters | to_entries[] | "### " + .key + "\n\n" + .value.metadata.description + "\n\nType: " + .value.type + "\n\nPossible Values: " + (.value.allowedValues | @text) + "\n\nDefault: " + (.value.defaultValue | @text) + "\n\n"' azuredeploy.json >> docs/Parameters.md
// 방문길이 // 2019.06.28 #include<string> using namespace std; int map[11][11][11][11]; // map[x][y][w][z] : x,y에서 w,z의 이동을 했는지 int dx[4] = { 0,0,1,-1 }; int dy[4] = { 1,-1,0,0 }; int solution(string dirs) { int answer = 0; int x = 5; int y = 5; for (int i = 0; i < dirs.size(); i++) { int xx = x; int yy = y; // 이동방향 순서대로 체크 switch (dirs[i]) { case 'L': xx = x + dx[1]; yy = y + dy[1]; if (xx < 0 || yy < 0 || xx>10 || yy>10) { x = x; yy = y; break; } if (map[x][y][xx][yy] == 1) // 이미 한번 지나간곳 { x = xx; y = yy; } else { map[x][y][xx][yy] = 1; map[xx][yy][x][y] = 1; x = xx; y = yy; answer++; } break; case 'U': xx = x + dx[3]; yy = y + dy[3]; if (xx < 0 || yy < 0 || xx>10 || yy>10) { xx = x; yy = y; break; } if (map[x][y][xx][yy] == 1) // 이미 한번 지나간곳 { x = xx; y = yy; } else { map[x][y][xx][yy] = 1; map[xx][yy][x][y] = 1; x = xx; y = yy; answer++; } break; case 'R': xx = x + dx[0]; yy = y + dy[0]; if (xx < 0 || yy < 0 || xx>10 || yy>10) { xx = x; yy = y; break; } if (map[x][y][xx][yy] == 1) // 이미 한번 지나간곳 { x = xx; y = yy; } else { map[x][y][xx][yy] = 1; map[xx][yy][x][y] = 1; x = xx; y = yy; answer++; } break; case 'D': xx = x + dx[2]; yy = y + dy[2]; if (xx < 0 || yy < 0 || xx>10 || yy>10) { xx = x; yy = y; break; } if (map[x][y][xx][yy] == 1) // 이미 한번 지나간곳 { x = xx; y = yy; } else { map[x][y][xx][yy] = 1; map[xx][yy][x][y] = 1; x = xx; y = yy; answer++; } break; } } return answer; }
from typing import List def find_target_indices(nums: List[int], target: int) -> List[int]: num_indices = {} for i, num in enumerate(nums): complement = target - num if complement in num_indices: return [num_indices[complement], i] num_indices[num] = i return []
# renew GOPATH rm -rf /usr/local/jenkins/{bin,pkg,src} mkdir /usr/local/jenkins/{bin,pkg,src} mkdir -p /usr/local/jenkins/src/github.com/osrg/ export GOBGP_IMAGE=gobgp export GOPATH=/usr/local/jenkins export GOROOT=/usr/local/go export GOBGP=/usr/local/jenkins/src/github.com/osrg/gobgp export WS=`pwd` # clear docker.log if [ "${BUILD_TAG}" != "" ]; then sudo sh -c ": > /var/log/upstart/docker.log" fi rm -r ${WS}/nosetest*.xml cp -r ../workspace $GOBGP pwd cd $GOBGP ls -al git log | head -20 sudo docker rmi $(sudo docker images | grep "^<none>" | awk '{print $3}') sudo docker rm -f $(sudo docker ps -a -q) for link in $(ip li | awk '/(_br|veth)/{sub(":","", $2); print $2}') do sudo ip li set down $link sudo ip li del $link done sudo docker rmi $GOBGP_IMAGE sudo fab -f $GOBGP/test/lib/base.py make_gobgp_ctn:tag=$GOBGP_IMAGE [ "$?" != 0 ] && exit "$?" cd $GOBGP/gobgpd $GOROOT/bin/go get -v cd $GOBGP/test/scenario_test ./run_all_tests.sh if [ "${BUILD_TAG}" != "" ]; then cd ${WS} mkdir jenkins-log-${BUILD_NUMBER} sudo cp *.xml jenkins-log-${BUILD_NUMBER}/ sudo cp /var/log/upstart/docker.log jenkins-log-${BUILD_NUMBER}/docker.log sudo chown -R jenkins:jenkins jenkins-log-${BUILD_NUMBER} tar cvzf jenkins-log-${BUILD_NUMBER}.tar.gz jenkins-log-${BUILD_NUMBER} s3cmd put jenkins-log-${BUILD_NUMBER}.tar.gz s3://gobgp/jenkins/ rm -rf jenkins-log-${BUILD_NUMBER} jenkins-log-${BUILD_NUMBER}.tar.gz fi
<gh_stars>1-10 module.exports = function(app){ var db = require('./config_db.js'), mongoose = require('mongoose'); var courseSchema = mongoose.Schema({ degreeAbbr: String, abbr: String, title: String }), _courseModel = mongoose.model('courses', courseSchema), // create - inserts a new course _save = function(data, success, fail){ // Define an object to hold our new course var newDocument = new _courseModel({ degreeAbbr: data.degreeAbbr, abbr: data.abbr, title: data.title }); // Insert the new document into the database newDocument.save(function(err){ (err) ? fail(err) : success(newDocument); }); }, // fetchAll - finds all courses _findAll = function(targ, success, fail){ // Finds all of the courses specified by the degree _courseModel.find(targ, function(err, result){ (err) ? fail(err) : success(result); }); }, // fetch - finds only one specified course _find = function(targ, success, fail){ // Finds just one course specificed by the degree abbreviation and course abbreviation _courseModel.findOne(targ, function(err, result){ (err) ? fail(err) : success(result); }); }, // fetch - finds only one specified degree _remove = function(targ, success, fail){ // removes just one course specificed by the Course Abbreviation _courseModel.remove(targ, function(err, result){ (err) ? fail(err) : success(result); }); } ;return { create: _save, fetchAll: _findAll, fetch: _find, destroy: _remove, }; }();
import pandas as pd import plotly.graph_objects as go def generate_engine_comparison_chart(file_path, engs): # Read the CSV file into a DataFrame df = pd.read_csv(file_path) # Extract the time points and attribute values for each engine type x = df['Time'] columns = df.columns[1:] # Exclude the 'Time' column bars = [] # Create a bar chart for each engine type for i in range(engs): eng = columns[i * 4].split('_')[0] # Extract the engine type from the column name bars.append(go.Bar(name=f'{eng} Engine', x=x, y=df.values[0][4*i:4*(i+1)])) # Create the layout for the bar chart layout = go.Layout(title='Engine Comparison', xaxis=dict(title='Time'), yaxis=dict(title='Value')) # Create the figure and save it as 'total_comparison.svg' fig = go.Figure(data=bars, layout=layout) fig.write_image('total_comparison.svg') # Example usage file_path = 'engine_data.csv' engs = 2 generate_engine_comparison_chart(file_path, engs)
#pragma once /* Common definitions <stddef.h> This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include "j6libc/int.h" #include "j6libc/null.h" #include "j6libc/max_align_t.h" #include "j6libc/size_t.h" #include "j6libc/wchar_t.h" typedef __PTRDIFF_TYPE__ ptrdiff_t; #if ! __has_include("__stddef_max_align_t.h") typedef long double max_align_t; #endif #define offsetof( type, member ) _PDCLIB_offsetof( type, member )
<gh_stars>1-10 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.apache.flink.runtime.rest.messages.job.savepoints; import org.apache.flink.runtime.rest.messages.queue.AsynchronouslyCreatedResource; import org.apache.flink.runtime.rest.messages.queue.QueueStatus; import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator; import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonIgnore; import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty; import javax.annotation.Nullable; import static java.util.Objects.requireNonNull; /** * Status of the savepoint and savepoint information if available. */ public class SavepointResponseBody implements AsynchronouslyCreatedResource<SavepointInfo> { private static final String FIELD_NAME_STATUS = "status"; private static final String FIELD_NAME_SAVEPOINT = "savepoint"; @JsonProperty(FIELD_NAME_STATUS) private final QueueStatus status; @JsonProperty(FIELD_NAME_SAVEPOINT) @Nullable private final SavepointInfo savepoint; @JsonCreator public SavepointResponseBody( @JsonProperty(FIELD_NAME_STATUS) QueueStatus status, @Nullable @JsonProperty(FIELD_NAME_SAVEPOINT) SavepointInfo savepoint) { this.status = requireNonNull(status); this.savepoint = savepoint; } public static SavepointResponseBody inProgress() { return new SavepointResponseBody(QueueStatus.inProgress(), null); } public static SavepointResponseBody completed(final SavepointInfo savepoint) { requireNonNull(savepoint); return new SavepointResponseBody(QueueStatus.inProgress(), savepoint); } public QueueStatus getStatus() { return status; } @Nullable public SavepointInfo getSavepoint() { return savepoint; } //------------------------------------------------------------------------- // AsynchronouslyCreatedResource //------------------------------------------------------------------------- @JsonIgnore @Override public QueueStatus queueStatus() { return status; } @JsonIgnore @Override public SavepointInfo resource() { return savepoint; } }
<reponame>sys9kdr/QupZilla<gh_stars>1-10 /* ============================================================ * QupZilla - WebKit based browser * Copyright (C) 2010-2012 <NAME> <<EMAIL>> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ============================================================ */ #ifndef PLUGINLOADER_H #define PLUGINLOADER_H #include <QObject> #include <QVariant> #include <QPointer> #include "qz_namespace.h" #include "plugininterface.h" class QPluginLoader; class SpeedDial; class QT_QUPZILLA_EXPORT Plugins : public QObject { Q_OBJECT public: struct Plugin { QString fileName; QString fullPath; PluginSpec pluginSpec; QPluginLoader* pluginLoader; PluginInterface* instance; Plugin() { pluginLoader = 0; instance = 0; } bool isLoaded() const { return instance; } bool operator==(const Plugin &other) const { return (this->fileName == other.fileName && this->fullPath == other.fullPath && this->pluginSpec == other.pluginSpec && this->instance == other.instance); } }; explicit Plugins(QObject* parent = 0); QList<Plugin> getAvailablePlugins(); bool loadPlugin(Plugin* plugin); void unloadPlugin(Plugin* plugin); void shutdown(); // CLick2Flash void c2f_loadSettings(); void c2f_saveSettings(); void c2f_addWhitelist(QString page) { c2f_whitelist.append(page); } void c2f_removeWhitelist(QString page) { c2f_whitelist.removeOne(page); } void c2f_setEnabled(bool en) { c2f_enabled = en; } bool c2f_isEnabled() { return c2f_enabled; } QStringList c2f_getWhiteList() { return c2f_whitelist; } // SpeedDial SpeedDial* speedDial() { return m_speedDial; } public slots: void loadSettings(); void loadPlugins(); protected: QList<PluginInterface*> m_loadedPlugins; signals: void pluginUnloaded(PluginInterface* plugin); private: bool alreadySpecInAvailable(const PluginSpec &spec); PluginInterface* initPlugin(PluginInterface* interface, QPluginLoader* loader); void refreshLoadedPlugins(); void loadAvailablePlugins(); QList<Plugin> m_availablePlugins; QStringList m_allowedPlugins; bool m_pluginsEnabled; bool m_pluginsLoaded; SpeedDial* m_speedDial; QStringList c2f_whitelist; bool c2f_enabled; }; Q_DECLARE_METATYPE(Plugins::Plugin) #endif // PLUGINLOADER_H
import { Test, TestingModule } from '@nestjs/testing'; import { YoutubeMp3Controller } from './youtube-mp3.controller'; import { YoutubeMp3Service } from './youtube-mp3.service'; describe('AppController', () => { let app: TestingModule; beforeAll(async () => { app = await Test.createTestingModule({ controllers: [YoutubeMp3Controller], providers: [YoutubeMp3Service], }).compile(); }); describe('root', () => { it('should return "Hello World!"', () => { const appController = app.get<YoutubeMp3Controller>(YoutubeMp3Controller); expect(appController.root()).toBe('Hello World!'); }); }); });
#!/bin/bash # Copyright (C) 2018-2021 LEIDOS. # # 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. # This script takes a system release name and version number as arguments, and # updates version dependencies in Dockerfile and /docker/checkout.bash accordingly. # The -u | --unprompted option can be used to skip the interactive prompts, and # provide arguments directly from the commandline. if [[ $# -eq 0 ]]; then echo "Enter the system release name:" read RELEASE_NAME echo "Enter the system release version number:" read RELEASE_VERSION else while [[ $# -gt 0 ]]; do arg="$1" case $arg in -u|--unprompted) RELEASE_NAME=$2 RELEASE_VERSION=$3 shift shift shift ;; esac done fi SYSTEM_RELEASE=carma-system-$RELEASE_VERSION RELEASE_BRANCH=release/$RELEASE_NAME if git ls-remote -q | grep $RELEASE_BRANCH; then echo "Checking out $RELEASE_BRANCH branch." git checkout $RELEASE_BRANCH echo "Updating .circleci/config.yml base image." sed -i "s|autoware.ai:.*|autoware.ai:$SYSTEM_RELEASE|g" .circleci/config.yml echo "Updating checkout.bash to point to system release version." sed -i "s|CARMA[a-zA-Z]*_[0-9]*\.[0-9]*\.[0-9]*|$SYSTEM_RELEASE|g; s|carma-[a-zA-Z]*-[0-9]*\.[0-9]*\.[0-9]*|$SYSTEM_RELEASE|g" docker/checkout.bash echo "Updating Dockerfile to point to system release version." sed -i "s|:CARMASystem_[0-9]*\.[0-9]*\.[0-9]*|:$SYSTEM_RELEASE|g; s|:carma-system-[0-9]*\.[0-9]*\.[0-9]*|:$SYSTEM_RELEASE|g; s|:[0-9]*\.[0-9]*\.[0-9]*|:$SYSTEM_RELEASE|g" Dockerfile git add docker/checkout.bash Dockerfile git commit -m "Updated dependencies for $SYSTEM_RELEASE" git tag -a $SYSTEM_RELEASE -m "$SYSTEM_RELEASE version tag." echo "Dockerfile and checkout.bash updated, committed, and tagged." else echo "$RELEASE_BRANCH does not exist. Exiting script." exit 0 fi
<reponame>mrava87/EAGE_Hackatoon_2017 from django.contrib.auth import get_user_model from django.core.management.base import BaseCommand import os class Command(BaseCommand): def handle(self, *args, **options): User = get_user_model() if not User.objects.filter(username="admin").exists(): User.objects.create_superuser("admin", "<EMAIL>", os.environ.get('ADMIN_PASW','admin'))
#!/bin/sh # #Copyright (c) 2014-2017 Oracle and/or its affiliates. All rights reserved. # #Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. # docker build -t 12213-domain .
cd ~/python3/Crawling/newsNate && scrapy crawl NewsNate -o nate_article.csv -
<filename>map.js<gh_stars>0 'use strict' module.exports = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
/* * Copyright 2016 NIIT Ltd, Wipro Ltd. * * 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. * * Contributors: * * 1. <NAME> * 2. <NAME> * 3. <NAME> * 4. <NAME> * 5. <NAME> * 6. <NAME> * 7. <NAME> */ angular.module('vbiApp') .controller('widthController', ['$scope','$controller','$uibModalInstance', 'widthConfig', function($scope, $controller, $uibModalInstance, widthConfig) { var editCtrl = $scope.$new(); $controller('editController',{$scope:editCtrl}); // Enter tab width between 1 - {{ widthConfig.columnWidth }} if(widthConfig.calledFor == 0) { //title and width $scope.modalTitle = "Customize widget Title and Width"; } else if(widthConfig.calledFor == 1) { //width $scope.modalTitle = "Customize widget width between 1 - " + widthConfig.columnWidth; } else if(widthConfig.calledFor == 2) { //title $scope.modalTitle = "Customize widget title"; } $scope.showTitle = function(id) { if(id == 0 || id == 2) { return true; } else { return false; } } $scope.showWidth = function(id) { if(id == 0 || id == 1) { return true; } else { return false; } } $scope.setWidgetWidth = function(width, title, id) { $uibModalInstance.close(); if(id == 2) { editCtrl.renameTitle(widthConfig.widgetId, title); } else { editCtrl.setWidgetWidth(widthConfig.rowIndex, widthConfig.colIndex, width, widthConfig.columnWidth, title); } } $scope.closeModal = function() { $uibModalInstance.close(); } $scope.widthConfig = widthConfig; }]);
#!/bin/bash if [ $# != 1 ] then echo "Please provide the number of tests to perform." exit 1 fi NB_TEST=$1 # nombre de tests pour chaque configuration DIRECTORY=/tmp # endroit de sauvegarde des fichiers temporaires EXEC="./tseitin" # executable NVAR=5 OUTPUT=formulae.depth.dat rm -f $OUTPUT rm -f /dev/null echo "Depth DUMB RAND MOMS DLIS DUMB_WL RAND_WL MOMS_WL DLIS_WL" >> $OUTPUT for depth in `seq 1 20`; do TIME_DUMB=0 TIME_RAND=0 TIME_MOMS=0 TIME_DLIS=0 TIME_DUMB_WL=0 TIME_RAND_WL=0 TIME_MOMS_WL=0 TIME_DLIS_WL=0 echo "Computing test for " $depth " depth." # On fait plusieurs tests par taille for test in `seq 1 $NB_TEST` ; do echo -e "\t\tTest $test" # Génération de la formule dans le fichier $DIRECTORY/formula.cnf ./generator -nvar $NVAR -depth $depth -o $DIRECTORY/formula.cnf # Résolution de la formule # Heuristique DUMB /usr/bin/time --quiet -f'%U' -o $DIRECTORY/result.txt $EXEC $DIRECTORY/formula.cnf > /dev/null TMP=`cat $DIRECTORY/result.txt` TIME_DUMB=$(echo "scale=3; $TIME_DUMB + $TMP" | bc) # Heuristique RAND /usr/bin/time --quiet -f'%U' -o $DIRECTORY/result.txt $EXEC -rand $DIRECTORY/formula.cnf > /dev/null TMP=`cat $DIRECTORY/result.txt` TIME_RAND=$(echo "scale=3; $TIME_RAND + $TMP" | bc) # Heuristique MOMS /usr/bin/time --quiet -f'%U' -o $DIRECTORY/result.txt $EXEC -moms $DIRECTORY/formula.cnf > /dev/null TMP=`cat $DIRECTORY/result.txt` TIME_MOMS=$(echo "scale=3; $TIME_MOMS + $TMP" | bc) # Heuristique DLIS /usr/bin/time --quiet -f'%U' -o $DIRECTORY/result.txt $EXEC -dlis $DIRECTORY/formula.cnf > /dev/null TMP=`cat $DIRECTORY/result.txt` TIME_DLIS=$(echo "scale=3; $TIME_DLIS + $TMP" | bc) # La même chose, avec les watched literals # Heuristique DUMB /usr/bin/time --quiet -f'%U' -o $DIRECTORY/result.txt $EXEC -WL $DIRECTORY/formula.cnf > /dev/null TMP=`cat $DIRECTORY/result.txt` TIME_DUMB_WL=$(echo "scale=3; $TIME_DUMB_WL + $TMP" | bc) # Heuristique RAND /usr/bin/time --quiet -f'%U' -o $DIRECTORY/result.txt $EXEC -WL -rand $DIRECTORY/formula.cnf > /dev/null TMP=`cat $DIRECTORY/result.txt` TIME_RAND_WL=$(echo "scale=3; $TIME_RAND_WL + $TMP" | bc) # Heuristique MOMS /usr/bin/time --quiet -f'%U' -o $DIRECTORY/result.txt $EXEC -WL -moms $DIRECTORY/formula.cnf > /dev/null TMP=`cat $DIRECTORY/result.txt` TIME_MOMS_WL=$(echo "scale=3; $TIME_MOMS_WL + $TMP" | bc) # Heuristique DLIS /usr/bin/time --quiet -f'%U' -o $DIRECTORY/result.txt $EXEC -WL -dlis $DIRECTORY/formula.cnf > /dev/null TMP=`cat $DIRECTORY/result.txt` TIME_DLIS_WL=$(echo "scale=3; $TIME_DLIS_WL + $TMP" | bc) done TIME_DUMB=$(echo "scale=3; $TIME_DUMB / $NB_TEST" | bc) TIME_RAND=$(echo "scale=3; $TIME_RAND / $NB_TEST" | bc) TIME_MOMS=$(echo "scale=3; $TIME_MOMS / $NB_TEST" | bc) TIME_DLIS=$(echo "scale=3; $TIME_DLIS / $NB_TEST" | bc) TIME_DUMB_WL=$(echo "scale=3; $TIME_DUMB_WL / $NB_TEST" | bc) TIME_RAND_WL=$(echo "scale=3; $TIME_RAND_WL / $NB_TEST" | bc) TIME_MOMS_WL=$(echo "scale=3; $TIME_MOMS_WL / $NB_TEST" | bc) TIME_DLIS_WL=$(echo "scale=3; $TIME_DLIS_WL / $NB_TEST" | bc) echo $depth $TIME_DUMB $TIME_RAND $TIME_MOMS $TIME_DLIS $TIME_DUMB_WL $TIME_RAND_WL $TIME_MOMS_WL $TIME_DLIS_WL >> $OUTPUT # fin de la boucle done # gnuplot script-plot.p # evince courbe1.pdf & # Si une formule n'était pas satisfaite par l'affectation, on aura des "assert" dans le fichier #grep "assert" /dev/null
<filename>src/utils/pixels.js export const parse = (value = 0) => { const type = typeof value if(type === 'number') return value if(type !== 'string') return 0 if(/^\d+px/.test(value)) return parseFloat(value, 10) if(/^\d+rem/.test(value)) return parseFloat(value) * 16 return value } export const stringify = (value = 0) => ( !!parse(value) ? `${parse(value)}px` : value )
#!/bin/bash cat plots/plotvals-np1000-t1.sh | sed s/1000/500/ > plots/plotvals-np500-t1.sh cat plots/plotvals-np1000-t1.sh | sed s/1000/5000/ > plots/plotvals-np5000-t1.sh cat plots/plotvals-np1000-t1.sh | sed s/1000/10000/ > plots/plotvals-np10000-t1.sh cat plots/plotvals-np1000-t1.sh | sed s/1000/15000/ > plots/plotvals-np15000-t1.sh cat plots/plotvals-np1000-t1.sh | sed s/1000/20000/ > plots/plotvals-np20000-t1.sh
<reponame>jpmartins/SymmetricEncryptionTool package pt; import org.junit.Test; import static org.junit.Assert.*; import java.io.File; import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Files; import java.security.NoSuchAlgorithmException; import java.util.Arrays; import pt.DESede; public class TestAll { @Test public void testKeyGen() { System.out.println("testKeyGen"); try { if(new File("tempKeyJuintTest").delete()) System.out.println("previous tempKeyJuintTest deleted"); new DESede().generateKey("tempKeyJuintTest"); assertTrue(new File("tempKeyJuintTest").exists()); } catch (NoSuchAlgorithmException | IOException e) { e.printStackTrace(); fail("Error"); } } @Test public void testEncDec() { System.out.println("testEncDec"); DESede impl = new DESede(); String fileKeys = "tempKeyJuintTest"; String fileIn = fileKeys; String fileEncOut = fileIn+"Enc"; String fileDecOut = fileIn+"Dec"; try { impl.generateKey(fileKeys); } catch (NoSuchAlgorithmException | IOException e) { } try{ impl.cifrar(fileIn, fileKeys, fileEncOut); assertTrue(new File(fileEncOut).exists()); }catch (Exception e) { e.printStackTrace(); fail("Error"); } try{ impl.decifra(fileEncOut, fileKeys, fileDecOut); assertTrue(new File(fileDecOut).exists()); }catch (Exception e) { e.printStackTrace(); fail("Error"); } try { byte[] f1 = Files.readAllBytes(FileSystems.getDefault().getPath(fileKeys)); byte[] f2 = Files.readAllBytes(FileSystems.getDefault().getPath(fileDecOut)); assertTrue(Arrays.equals(f1, f2)); } catch (IOException e) { e.printStackTrace(); fail("Error"); } } }
/*! \brief Implementation of methods of the TextureReaderKTX class. \file PVRCore/textureio/TextureReaderKTX.cpp \author PowerVR by Imagination, Developer Technology Team \copyright Copyright (c) Imagination Technologies Limited. */ //!\cond NO_DOXYGEN #include "PVRCore/textureio/TextureReaderKTX.h" #include "PVRCore/textureio/FileDefinesKTX.h" #include "PVRCore/texture/TextureDefines.h" namespace { inline uint64_t textureOffset3D(uint64_t x, uint64_t y, uint64_t z, uint64_t width, uint64_t height) { return ((x) + (y * width) + (z * width * height)); } bool setopenGLFormat(pvr::TextureHeader& hd, uint32_t glInternalFormat, uint32_t, uint32_t glType) { /* Try to determine the format. This code is naive, and only checks the data that matters (e.g. glInternalFormat first, then glType if it needs more information). */ switch (glInternalFormat) { // Unsized internal formats case pvr::texture_ktx::OpenGLFormats::GL_RED: { hd.setColorSpace(pvr::ColorSpace::lRGB); switch (glType) { case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_BYTE: { hd.setChannelType(pvr::VariableType::UnsignedByteNorm); hd.setPixelFormat(pvr::GeneratePixelType1<'r', 8>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_BYTE: { hd.setChannelType(pvr::VariableType::SignedByteNorm); hd.setPixelFormat(pvr::GeneratePixelType1<'r', 8>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_SHORT: { hd.setChannelType(pvr::VariableType::UnsignedShortNorm); hd.setPixelFormat(pvr::GeneratePixelType1<'r', 16>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_SHORT: { hd.setChannelType(pvr::VariableType::SignedShortNorm); hd.setPixelFormat(pvr::GeneratePixelType1<'r', 16>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_INT: { hd.setChannelType(pvr::VariableType::UnsignedIntegerNorm); hd.setPixelFormat(pvr::GeneratePixelType1<'r', 32>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_INT: { hd.setChannelType(pvr::VariableType::SignedIntegerNorm); hd.setPixelFormat(pvr::GeneratePixelType1<'r', 32>::ID); return true; } } break; } case pvr::texture_ktx::OpenGLFormats::GL_RG: { hd.setColorSpace(pvr::ColorSpace::lRGB); switch (glType) { case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_BYTE: { hd.setChannelType(pvr::VariableType::UnsignedByteNorm); hd.setPixelFormat(pvr::GeneratePixelType2<'r', 'g', 8, 8>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_BYTE: { hd.setChannelType(pvr::VariableType::SignedByteNorm); hd.setPixelFormat(pvr::GeneratePixelType2<'r', 'g', 8, 8>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_SHORT: { hd.setChannelType(pvr::VariableType::UnsignedShortNorm); hd.setPixelFormat(pvr::GeneratePixelType2<'r', 'g', 16, 16>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_SHORT: { hd.setChannelType(pvr::VariableType::SignedShortNorm); hd.setPixelFormat(pvr::GeneratePixelType2<'r', 'g', 16, 16>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_INT: { hd.setChannelType(pvr::VariableType::UnsignedIntegerNorm); hd.setPixelFormat(pvr::GeneratePixelType2<'r', 'g', 32, 32>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_INT: { hd.setChannelType(pvr::VariableType::SignedIntegerNorm); hd.setPixelFormat(pvr::GeneratePixelType2<'r', 'g', 32, 32>::ID); return true; } } break; } case pvr::texture_ktx::OpenGLFormats::GL_RGB: { hd.setColorSpace(pvr::ColorSpace::lRGB); switch (glType) { case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_BYTE_3_3_2: { hd.setChannelType(pvr::VariableType::UnsignedByteNorm); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 3, 3, 2>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_BYTE: { hd.setChannelType(pvr::VariableType::UnsignedByteNorm); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 8, 8, 8>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_BYTE: { hd.setChannelType(pvr::VariableType::SignedByteNorm); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 8, 8, 8>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_SHORT: { hd.setChannelType(pvr::VariableType::UnsignedShortNorm); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 16, 16, 16>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_SHORT: { hd.setChannelType(pvr::VariableType::SignedShortNorm); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 16, 16, 16>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_INT: { hd.setChannelType(pvr::VariableType::UnsignedIntegerNorm); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 32, 32, 32>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_INT: { hd.setChannelType(pvr::VariableType::SignedIntegerNorm); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 32, 32, 32>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_SHORT_5_6_5: { hd.setChannelType(pvr::VariableType::UnsignedShortNorm); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 5, 6, 5>::ID); return true; } } break; } case pvr::texture_ktx::OpenGLFormats::GL_RGBA: { hd.setColorSpace(pvr::ColorSpace::lRGB); switch (glType) { case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_BYTE: { hd.setChannelType(pvr::VariableType::UnsignedByteNorm); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 8, 8, 8, 8>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_BYTE: { hd.setChannelType(pvr::VariableType::SignedByteNorm); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 8, 8, 8, 8>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_SHORT: { hd.setChannelType(pvr::VariableType::UnsignedShortNorm); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 16, 16, 16, 16>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_SHORT: { hd.setChannelType(pvr::VariableType::SignedShortNorm); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 16, 16, 16, 16>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_INT: { hd.setChannelType(pvr::VariableType::UnsignedIntegerNorm); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 32, 32, 32, 32>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_INT: { hd.setChannelType(pvr::VariableType::SignedIntegerNorm); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 32, 32, 32, 32>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_SHORT_5_5_5_1: { hd.setChannelType(pvr::VariableType::UnsignedShortNorm); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 5, 5, 5, 1>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_SHORT_4_4_4_4: { hd.setChannelType(pvr::VariableType::UnsignedShortNorm); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 4, 4, 4, 4>::ID); return true; } } break; } case pvr::texture_ktx::OpenGLFormats::GL_BGRA: { hd.setColorSpace(pvr::ColorSpace::lRGB); if (glType == pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_BYTE) { hd.setChannelType(pvr::VariableType::UnsignedByteNorm); hd.setPixelFormat(pvr::GeneratePixelType4<'b', 'g', 'r', 'a', 8, 8, 8, 8>::ID); return true; } break; } case pvr::texture_ktx::OpenGLFormats::GL_LUMINANCE_ALPHA: { hd.setColorSpace(pvr::ColorSpace::lRGB); switch (glType) { case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_BYTE: { hd.setChannelType(pvr::VariableType::UnsignedByteNorm); hd.setPixelFormat(pvr::GeneratePixelType2<'l', 'a', 8, 8>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_BYTE: { hd.setChannelType(pvr::VariableType::SignedByteNorm); hd.setPixelFormat(pvr::GeneratePixelType2<'l', 'a', 8, 8>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_SHORT: { hd.setChannelType(pvr::VariableType::UnsignedShortNorm); hd.setPixelFormat(pvr::GeneratePixelType2<'l', 'a', 16, 16>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_SHORT: { hd.setChannelType(pvr::VariableType::SignedShortNorm); hd.setPixelFormat(pvr::GeneratePixelType2<'l', 'a', 16, 16>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_INT: { hd.setChannelType(pvr::VariableType::UnsignedIntegerNorm); hd.setPixelFormat(pvr::GeneratePixelType2<'l', 'a', 32, 32>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_INT: { hd.setChannelType(pvr::VariableType::SignedIntegerNorm); hd.setPixelFormat(pvr::GeneratePixelType2<'l', 'a', 32, 32>::ID); return true; } } break; } case pvr::texture_ktx::OpenGLFormats::GL_LUMINANCE: { hd.setColorSpace(pvr::ColorSpace::lRGB); switch (glType) { case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_BYTE: { hd.setChannelType(pvr::VariableType::UnsignedByteNorm); hd.setPixelFormat(pvr::GeneratePixelType1<'l', 8>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_BYTE: { hd.setChannelType(pvr::VariableType::SignedByteNorm); hd.setPixelFormat(pvr::GeneratePixelType1<'l', 8>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_SHORT: { hd.setChannelType(pvr::VariableType::UnsignedShortNorm); hd.setPixelFormat(pvr::GeneratePixelType1<'l', 16>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_SHORT: { hd.setChannelType(pvr::VariableType::SignedShortNorm); hd.setPixelFormat(pvr::GeneratePixelType1<'l', 16>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_INT: { hd.setChannelType(pvr::VariableType::UnsignedIntegerNorm); hd.setPixelFormat(pvr::GeneratePixelType1<'l', 32>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_INT: { hd.setChannelType(pvr::VariableType::SignedIntegerNorm); hd.setPixelFormat(pvr::GeneratePixelType1<'l', 32>::ID); return true; } } break; } case pvr::texture_ktx::OpenGLFormats::GL_ALPHA: { hd.setColorSpace(pvr::ColorSpace::lRGB); switch (glType) { case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_BYTE: { hd.setChannelType(pvr::VariableType::UnsignedByteNorm); hd.setPixelFormat(pvr::GeneratePixelType1<'a', 8>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_BYTE: { hd.setChannelType(pvr::VariableType::SignedByteNorm); hd.setPixelFormat(pvr::GeneratePixelType1<'a', 8>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_SHORT: { hd.setChannelType(pvr::VariableType::UnsignedShortNorm); hd.setPixelFormat(pvr::GeneratePixelType1<'a', 16>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_SHORT: { hd.setChannelType(pvr::VariableType::SignedShortNorm); hd.setPixelFormat(pvr::GeneratePixelType1<'a', 16>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_UNSIGNED_INT: { hd.setChannelType(pvr::VariableType::UnsignedIntegerNorm); hd.setPixelFormat(pvr::GeneratePixelType1<'a', 32>::ID); return true; } case pvr::texture_ktx::OpenGLFormats::GL_INT: { hd.setChannelType(pvr::VariableType::SignedIntegerNorm); hd.setPixelFormat(pvr::GeneratePixelType1<'a', 32>::ID); return true; } } break; } case pvr::texture_ktx::OpenGLFormats::GL_ALPHA8: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'a', 8>::ID); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_ALPHA8_SNORM: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'a', 8>::ID); hd.setChannelType(pvr::VariableType::SignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_ALPHA16: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'a', 16>::ID); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_ALPHA16_SNORM: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'a', 16>::ID); hd.setChannelType(pvr::VariableType::SignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_ALPHA16F_ARB: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'a', 16>::ID); hd.setChannelType(pvr::VariableType::SignedFloat); return true; } case pvr::texture_ktx::OpenGLFormats::GL_ALPHA32F_ARB: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'a', 32>::ID); hd.setChannelType(pvr::VariableType::SignedFloat); return true; } case pvr::texture_ktx::OpenGLFormats::GL_LUMINANCE8: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'l', 8>::ID); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_LUMINANCE8_SNORM: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'l', 8>::ID); hd.setChannelType(pvr::VariableType::SignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_LUMINANCE16: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'l', 16>::ID); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_LUMINANCE16_SNORM: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'l', 16>::ID); hd.setChannelType(pvr::VariableType::SignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_LUMINANCE16F_ARB: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'l', 16>::ID); hd.setChannelType(pvr::VariableType::SignedFloat); return true; } case pvr::texture_ktx::OpenGLFormats::GL_LUMINANCE32F_ARB: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'l', 32>::ID); hd.setChannelType(pvr::VariableType::SignedFloat); return true; } case pvr::texture_ktx::OpenGLFormats::GL_LUMINANCE8_ALPHA8: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType2<'l', 'a', 8, 8>::ID); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_LUMINANCE8_ALPHA8_SNORM: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType2<'l', 'a', 8, 8>::ID); hd.setChannelType(pvr::VariableType::SignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_LUMINANCE_ALPHA16F_ARB: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType2<'l', 'a', 16, 16>::ID); hd.setChannelType(pvr::VariableType::SignedFloat); return true; } case pvr::texture_ktx::OpenGLFormats::GL_LUMINANCE_ALPHA32F_ARB: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType2<'l', 'a', 32, 32>::ID); hd.setChannelType(pvr::VariableType::SignedFloat); return true; } case pvr::texture_ktx::OpenGLFormats::GL_R8: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'r', 8>::ID); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_R8_SNORM: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'r', 8>::ID); hd.setChannelType(pvr::VariableType::SignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_R16: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'r', 16>::ID); hd.setChannelType(pvr::VariableType::UnsignedShortNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_R16_SNORM: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'r', 16>::ID); hd.setChannelType(pvr::VariableType::SignedShortNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_R16F: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'r', 16>::ID); hd.setChannelType(pvr::VariableType::SignedFloat); return true; } case pvr::texture_ktx::OpenGLFormats::GL_R32F: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'r', 32>::ID); hd.setChannelType(pvr::VariableType::SignedFloat); return true; } case pvr::texture_ktx::OpenGLFormats::GL_R8UI: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'r', 8>::ID); hd.setChannelType(pvr::VariableType::UnsignedByte); return true; } case pvr::texture_ktx::OpenGLFormats::GL_R8I: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'r', 8>::ID); hd.setChannelType(pvr::VariableType::SignedByte); return true; } case pvr::texture_ktx::OpenGLFormats::GL_R16UI: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'r', 16>::ID); hd.setChannelType(pvr::VariableType::UnsignedShort); return true; } case pvr::texture_ktx::OpenGLFormats::GL_R16I: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'r', 16>::ID); hd.setChannelType(pvr::VariableType::SignedShort); return true; } case pvr::texture_ktx::OpenGLFormats::GL_R32UI: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'r', 32>::ID); hd.setChannelType(pvr::VariableType::UnsignedInteger); return true; } case pvr::texture_ktx::OpenGLFormats::GL_R32I: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType1<'r', 32>::ID); hd.setChannelType(pvr::VariableType::SignedInteger); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RG8: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType2<'r', 'g', 8, 8>::ID); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RG8_SNORM: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType2<'r', 'g', 8, 8>::ID); hd.setChannelType(pvr::VariableType::SignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RG16: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType2<'r', 'g', 16, 16>::ID); hd.setChannelType(pvr::VariableType::UnsignedShortNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RG16_SNORM: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType2<'r', 'g', 16, 16>::ID); hd.setChannelType(pvr::VariableType::SignedShortNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RG16F: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType2<'r', 'g', 16, 16>::ID); hd.setChannelType(pvr::VariableType::SignedFloat); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RG32F: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType2<'r', 'g', 32, 32>::ID); hd.setChannelType(pvr::VariableType::SignedFloat); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RG8UI: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType2<'r', 'g', 8, 8>::ID); hd.setChannelType(pvr::VariableType::UnsignedByte); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RG8I: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType2<'r', 'g', 8, 8>::ID); hd.setChannelType(pvr::VariableType::SignedByte); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RG16UI: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType2<'r', 'g', 16, 16>::ID); hd.setChannelType(pvr::VariableType::UnsignedShort); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RG16I: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType2<'r', 'g', 16, 16>::ID); hd.setChannelType(pvr::VariableType::SignedShort); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RG32UI: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType2<'r', 'g', 32, 32>::ID); hd.setChannelType(pvr::VariableType::UnsignedInteger); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RG32I: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType2<'r', 'g', 32, 32>::ID); hd.setChannelType(pvr::VariableType::SignedInteger); return true; } case pvr::texture_ktx::OpenGLFormats::GL_R3_G3_B2: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 3, 3, 2>::ID); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGB565: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 5, 6, 5>::ID); hd.setChannelType(pvr::VariableType::UnsignedShortNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGB8: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 8, 8, 8>::ID); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGB8_SNORM: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 8, 8, 8>::ID); hd.setChannelType(pvr::VariableType::SignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_SRGB8: { hd.setColorSpace(pvr::ColorSpace::sRGB); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 8, 8, 8>::ID); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGB16: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 16, 16, 16>::ID); hd.setChannelType(pvr::VariableType::UnsignedShortNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGB16_SNORM: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 16, 16, 16>::ID); hd.setChannelType(pvr::VariableType::SignedShortNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGB10: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'x', 10, 10, 10, 2>::ID); hd.setChannelType(pvr::VariableType::UnsignedIntegerNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_R11F_G11F_B10F: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 11, 11, 10>::ID); hd.setChannelType(pvr::VariableType::UnsignedFloat); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGB9_E5: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::SharedExponentR9G9B9E5); hd.setChannelType(pvr::VariableType::UnsignedFloat); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGB16F: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 16, 16, 16>::ID); hd.setChannelType(pvr::VariableType::SignedFloat); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGB32F: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 32, 32, 32>::ID); hd.setChannelType(pvr::VariableType::SignedFloat); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGB8UI: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 8, 8, 8>::ID); hd.setChannelType(pvr::VariableType::UnsignedByte); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGB8I: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 8, 8, 8>::ID); hd.setChannelType(pvr::VariableType::SignedByte); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGB16UI: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 16, 16, 16>::ID); hd.setChannelType(pvr::VariableType::UnsignedShort); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGB16I: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 16, 16, 16>::ID); hd.setChannelType(pvr::VariableType::SignedShort); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGB32UI: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 32, 32, 32>::ID); hd.setChannelType(pvr::VariableType::UnsignedInteger); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGB32I: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType3<'r', 'g', 'b', 32, 32, 32>::ID); hd.setChannelType(pvr::VariableType::SignedInteger); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGBA8: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 8, 8, 8, 8>::ID); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGBA8_SNORM: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 8, 8, 8, 8>::ID); hd.setChannelType(pvr::VariableType::SignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_SRGB8_ALPHA8: { hd.setColorSpace(pvr::ColorSpace::sRGB); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 8, 8, 8, 8>::ID); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGBA16: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 16, 16, 16, 16>::ID); hd.setChannelType(pvr::VariableType::UnsignedShortNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGBA16_SNORM: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 16, 16, 16, 16>::ID); hd.setChannelType(pvr::VariableType::SignedShortNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGB5_A1: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 5, 5, 5, 1>::ID); hd.setChannelType(pvr::VariableType::UnsignedShortNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGBA4: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 4, 4, 4, 4>::ID); hd.setChannelType(pvr::VariableType::UnsignedShortNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGB10_A2: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 10, 10, 10, 2>::ID); hd.setChannelType(pvr::VariableType::UnsignedIntegerNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGBA16F: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 16, 16, 16, 16>::ID); hd.setChannelType(pvr::VariableType::SignedFloat); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGBA32F: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 32, 32, 32, 32>::ID); hd.setChannelType(pvr::VariableType::SignedFloat); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGBA8UI: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 8, 8, 8, 8>::ID); hd.setChannelType(pvr::VariableType::UnsignedByte); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGBA8I: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 8, 8, 8, 8>::ID); hd.setChannelType(pvr::VariableType::SignedByte); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGB10_A2UI: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 10, 10, 10, 2>::ID); hd.setChannelType(pvr::VariableType::UnsignedInteger); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGBA16UI: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 16, 16, 16, 16>::ID); hd.setChannelType(pvr::VariableType::UnsignedShort); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGBA16I: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 16, 16, 16, 16>::ID); hd.setChannelType(pvr::VariableType::SignedShort); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGBA32I: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 32, 32, 32, 32>::ID); hd.setChannelType(pvr::VariableType::UnsignedInteger); return true; } case pvr::texture_ktx::OpenGLFormats::GL_RGBA32UI: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::GeneratePixelType4<'r', 'g', 'b', 'a', 32, 32, 32, 32>::ID); hd.setChannelType(pvr::VariableType::SignedInteger); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::PVRTCI_2bpp_RGB); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::PVRTCI_2bpp_RGBA); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::PVRTCI_4bpp_RGB); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::PVRTCI_4bpp_RGBA); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::PVRTCII_2bpp); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::PVRTCII_4bpp); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_ETC1_RGB8_OES: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::ETC1); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::DXT1); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::DXT3); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::DXT5); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_SRGB8_ETC2: { hd.setColorSpace(pvr::ColorSpace::sRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::ETC2_RGB); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_RGB8_ETC2: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::ETC2_RGB); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: { hd.setColorSpace(pvr::ColorSpace::sRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::ETC2_RGBA); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_RGBA8_ETC2_EAC: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::ETC2_RGBA); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: { hd.setColorSpace(pvr::ColorSpace::sRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::ETC2_RGB_A1); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: { hd.setColorSpace(pvr::ColorSpace::lRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::ETC2_RGB_A1); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_SIGNED_R11_EAC: { hd.setColorSpace(pvr::ColorSpace::sRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::EAC_R11); hd.setChannelType(pvr::VariableType::SignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_R11_EAC: { hd.setColorSpace(pvr::ColorSpace::sRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::EAC_R11); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_SIGNED_RG11_EAC: { hd.setColorSpace(pvr::ColorSpace::sRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::EAC_RG11); hd.setChannelType(pvr::VariableType::SignedByteNorm); return true; } case pvr::texture_ktx::OpenGLFormats::GL_COMPRESSED_RG11_EAC: { hd.setColorSpace(pvr::ColorSpace::sRGB); hd.setPixelFormat(pvr::CompressedPixelFormat::EAC_RG11); hd.setChannelType(pvr::VariableType::UnsignedByteNorm); return true; } } // Return false if format isn't found/valid. return false; } } // namespace using std::vector; namespace pvr { namespace assetReaders { Texture readKTX(const pvr::Stream& stream) { if (!stream.isReadable()) { throw InvalidOperationError("[pvr::assetReaders::readKTX] Attempted to read a non-readable assetStream"); } if (stream.getSize() < texture_ktx::c_expectedHeaderSize) { throw InvalidOperationError("[TextureReaderKTX::readAsset_]: File stream was shorter than KTX file length"); } texture_ktx::FileHeader ktxFileHeader; // Read the identifier stream.readExact(1, sizeof(ktxFileHeader.identifier), ktxFileHeader.identifier); // Check that the identifier matches if (memcmp(ktxFileHeader.identifier, texture_ktx::c_identifier, sizeof(ktxFileHeader.identifier)) != 0) { throw InvalidOperationError("[TextureReaderKTX::readAsset_]: Stream did not contain a valid KTX file identifier"); } // Read the endianness stream.readExact(sizeof(ktxFileHeader.endianness), 1, &ktxFileHeader.endianness); // Check the endianness of the file if (ktxFileHeader.endianness != texture_ktx::c_endianReference) { throw InvalidOperationError("[TextureReaderKTX::readAsset_]: Stream did not match KTX file endianness"); } // Read the openGL type stream.readExact(sizeof(ktxFileHeader.glType), 1, &ktxFileHeader.glType); // Read the openGL type size stream.readExact(sizeof(ktxFileHeader.glTypeSize), 1, &ktxFileHeader.glTypeSize); // Read the openGL format stream.readExact(sizeof(ktxFileHeader.glFormat), 1, &ktxFileHeader.glFormat); // Read the openGL internal format stream.readExact(sizeof(ktxFileHeader.glInternalFormat), 1, &ktxFileHeader.glInternalFormat); // Read the openGL base (unsized) internal format stream.readExact(sizeof(ktxFileHeader.glBaseInternalFormat), 1, &ktxFileHeader.glBaseInternalFormat); // Read the width stream.readExact(sizeof(ktxFileHeader.pixelWidth), 1, &ktxFileHeader.pixelWidth); // Read the height stream.readExact(sizeof(ktxFileHeader.pixelHeight), 1, &ktxFileHeader.pixelHeight); // Read the depth stream.readExact(sizeof(ktxFileHeader.pixelDepth), 1, &ktxFileHeader.pixelDepth); // Read the number of array elements stream.readExact(sizeof(ktxFileHeader.numArrayElements), 1, &ktxFileHeader.numArrayElements); // Read the number of faces stream.readExact(sizeof(ktxFileHeader.numFaces), 1, &ktxFileHeader.numFaces); // Read the number of MIP Map levels stream.readExact(sizeof(ktxFileHeader.numMipmapLevels), 1, &ktxFileHeader.numMipmapLevels); // Read the meta data size stream.readExact(sizeof(ktxFileHeader.bytesOfKeyValueData), 1, &ktxFileHeader.bytesOfKeyValueData); // Read the meta data uint32_t metaDataRead = 0; // AxisOrientation if we find it. uint32_t orientation = 0; // Read MetaData if (ktxFileHeader.bytesOfKeyValueData > 0) { // Loop through all the meta data do { // Read the amount of meta data in this block. uint32_t keyAndValueSize = 0; stream.readExact(sizeof(keyAndValueSize), 1, &keyAndValueSize); // Allocate enough memory to read in the meta data. std::vector<unsigned char> keyAndData; keyAndData.resize(keyAndValueSize); // Read in the meta data. stream.readExact(1, keyAndValueSize, keyAndData.data()); // Setup the key pointer std::string keyString(reinterpret_cast<char*>(keyAndData.data())); // Search for KTX orientation. This is the only meta data currently supported if (keyString == std::string(texture_ktx::c_orientationMetaDataKey)) { // KTX AxisOrientation key/value found, offset to the data location. uint8_t* data = keyAndData.data() + (keyString.length() + 1); uint32_t dataSize = static_cast<uint32_t>(keyAndValueSize - (keyString.length() + 1)); // Read the data as a char 8 std::string into a std::string to find the orientation. std::string orientationString(reinterpret_cast<char*>(data), dataSize); // Search for and set non-default orientations. if (orientationString.find("T=u") != std::string::npos) { orientation |= TextureMetaData::AxisOrientationUp; } if (orientationString.find("S=l") != std::string::npos) { orientation |= TextureMetaData::AxisOrientationLeft; } if (orientationString.find("R=o") != std::string::npos) { orientation |= TextureMetaData::AxisOrientationOut; } } // Work out the padding. uint32_t padding = 0; // If it needs padding if (keyAndValueSize % 4) { padding = 4 - (keyAndValueSize % 4); } // Skip to the next meta data. stream.seek(padding, Stream::SeekOriginFromCurrent); // Increase the meta data read value metaDataRead += keyAndValueSize + padding; } while (stream.getPosition() < (ktxFileHeader.bytesOfKeyValueData + texture_ktx::c_expectedHeaderSize)); // Make sure the meta data size wasn't completely wrong. If it was, there are no guarantees about the contents of the texture data. if (metaDataRead > ktxFileHeader.bytesOfKeyValueData) { throw InvalidOperationError("[TextureReaderKTX::readAsset_]: Stream metadata were invalid"); } } // Construct the texture asset's header TextureHeader textureHeader; setopenGLFormat(textureHeader, ktxFileHeader.glInternalFormat, ktxFileHeader.glFormat, ktxFileHeader.glType); textureHeader.setWidth(ktxFileHeader.pixelWidth); textureHeader.setHeight(ktxFileHeader.pixelHeight); textureHeader.setDepth(ktxFileHeader.pixelDepth); textureHeader.setNumArrayMembers(ktxFileHeader.numArrayElements == 0 ? 1 : ktxFileHeader.numArrayElements); textureHeader.setNumFaces(ktxFileHeader.numFaces); textureHeader.setNumMipMapLevels(ktxFileHeader.numMipmapLevels); textureHeader.setOrientation(static_cast<TextureMetaData::AxisOrientation>(orientation)); // Initialize the texture to allocate data Texture asset(textureHeader); // Seek to the start of the texture data, just in case. stream.seek(ktxFileHeader.bytesOfKeyValueData + texture_ktx::c_expectedHeaderSize, Stream::SeekOriginFromStart); // Read in the texture data for (uint32_t mipMapLevel = 0; mipMapLevel < ktxFileHeader.numMipmapLevels; ++mipMapLevel) { // Read the stored size of the MIP Map. uint32_t mipMapSize = 0; stream.readExact(sizeof(mipMapSize), 1, &mipMapSize); // Sanity check the size - regular cube maps are a slight exception if (asset.getNumFaces() == 6 && asset.getNumArrayMembers() == 1) { if (mipMapSize != asset.getDataSize(mipMapLevel, false, false)) { throw InvalidOperationError("[TextureReaderKTX::readAsset_]: Mipmap size read was not expected size."); } } else { if (mipMapSize != asset.getDataSize(mipMapLevel)) { throw InvalidOperationError("[TextureReaderKTX::readAsset_]: Mipmap size read was not expected size."); } } // Work out the Cube Map padding. uint32_t cubePadding = 0; if (asset.getDataSize(mipMapLevel, false, false) % 4) { cubePadding = 4 - (asset.getDataSize(mipMapLevel, false, false) % 4); } // Compressed images are written without scan line padding. if (asset.getPixelFormat().getPart().High == 0 && asset.getPixelFormat().getPixelTypeId() != static_cast<uint64_t>(CompressedPixelFormat::SharedExponentR9G9B9E5)) { for (uint32_t iSurface = 0; iSurface < asset.getNumArrayMembers(); ++iSurface) { for (uint32_t iFace = 0; iFace < asset.getNumFaces(); ++iFace) { // Read in the texture data. stream.readExact(asset.getDataSize(mipMapLevel, false, false), 1, asset.getDataPointer(mipMapLevel, iSurface, iFace)); // Advance past the cube face padding if (cubePadding && asset.getNumFaces() == 6 && asset.getNumArrayMembers() == 1) { stream.seek(cubePadding, Stream::SeekOriginFromCurrent); } } } } // Uncompressed images have scan line padding. else { for (uint32_t iSurface = 0; iSurface < asset.getNumArrayMembers(); ++iSurface) { for (uint32_t iFace = 0; iFace < asset.getNumFaces(); ++iFace) { for (uint32_t texDepth = 0; texDepth < asset.getDepth(mipMapLevel); ++texDepth) { for (uint32_t texHeight = 0; texHeight < asset.getHeight(mipMapLevel); ++texHeight) { // Calculate the data offset for the relevant scan line uint64_t scanLineOffset = (textureOffset3D(0, texHeight, texDepth, asset.getWidth(mipMapLevel), asset.getHeight(mipMapLevel)) * (asset.getBitsPerPixel() / 8)); // Read in the texture data for the current scan line. stream.readExact((asset.getBitsPerPixel() / 8) * asset.getWidth(mipMapLevel), 1, asset.getDataPointer(mipMapLevel, iSurface, iFace) + scanLineOffset); // Work out the amount of scan line padding. uint32_t scanLinePadding = (static_cast<uint32_t>(-1) * ((asset.getBitsPerPixel() / 8) * asset.getWidth(mipMapLevel))) % 4; // Advance past the scan line padding if (scanLinePadding) { stream.seek(scanLinePadding, Stream::SeekOriginFromCurrent); } } } // Advance past the cube face padding if (cubePadding && asset.getNumFaces() == 6 && asset.getNumArrayMembers() == 1) { stream.seek(static_cast<long>(cubePadding), Stream::SeekOriginFromCurrent); } } } } // Calculate the amount MIP Map padding. uint32_t mipMapPadding = (3 - ((mipMapSize + 3) % 4)); // Advance past the MIP Map padding if appropriate if (mipMapPadding) { stream.seek(mipMapPadding, Stream::SeekOriginFromCurrent); } } return asset; } } // namespace assetReaders } // namespace pvr //!\endcond
<gh_stars>10-100 /** * @author ooooo * @date 2020/9/21 13:16 */ #ifndef CPP_0538__SOLUTION3_H_ #define CPP_0538__SOLUTION3_H_ #include "TreeNode.h" class Solution { public: TreeNode *prev; TreeNode *convertBST(TreeNode *root) { if (!root) return root; convertBST(root->right); if (!prev) { prev = root; } else { root->val += prev->val; prev = root; } convertBST(root->left); return root; } }; #endif //CPP_0538__SOLUTION3_H_
import pandas as pd from sklearn.model_selection import train_test_split from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.linear_model import LogisticRegression from sklearn.metrics import accuracy_score # Load the dataset data = pd.read_csv('dataset.csv') # Split data into train and test sets X_train, X_test, y_train, y_test = train_test_split( data['text'], data['sentiment'], random_state=2 ) # Create vectorizer and fit to train data vectorizer = TfidfVectorizer() vectorizer.fit(X_train) # Create train feature vectors X_train_vec = vectorizer.transform(X_train) # Create model model = LogisticRegression() # Fit model to train data model.fit(X_train_vec, y_train) # Create test feature vectors X_test_vec = vectorizer.transform(X_test) # Make predictions on test data pred = model.predict(X_test_vec) # Calculate accuracy accuracy_score(y_test, pred)
import string import random def generate_password(length): chars = string.ascii_lowercase + string.ascii_uppercase + string.digits return ''.join(random.choice(chars) for _ in range(length)) generate_password(10)
<gh_stars>10-100 package com.github.robindevilliers.welcometohell.wizard.domain; import com.github.robindevilliers.welcometohell.wizard.domain.types.Route; import java.util.ArrayList; import java.util.List; public class Rule implements Route { private String condition; private String view; private List<Variable> variables = new ArrayList<>(); public String getCondition() { return condition; } public void setCondition(String condition) { this.condition = condition; } public String getViewId() { return view; } public void setView(String view) { this.view = view; } public List<Variable> getVariables() { return variables; } }
def find_keywords(sentence): keywords = set() words = sentence.split(' ') for word in words: if word.iskeyword(): keywords.add(word) return list(keywords)
<reponame>Iler22/jobs-finder // const to store number of cards displayed per page export const VALUES_PER_PAGE = 5;
class CodeObject: def __init__(self, code, key_sequence=None, maincolor=None, backcolor=None, forecolor=None): self.code = code self.key_sequence = key_sequence self.maincolor = maincolor self.backcolor = backcolor self.forecolor = forecolor # Test the implementation code_obj = CodeObject("print('Hello, World!')", key_sequence=['Ctrl', 'Shift'], maincolor='blue', backcolor='black', forecolor='white') print(code_obj.code) # Output: print('Hello, World!') print(code_obj.key_sequence) # Output: ['Ctrl', 'Shift'] print(code_obj.maincolor) # Output: blue print(code_obj.backcolor) # Output: black print(code_obj.forecolor) # Output: white
package cim4j; import java.util.List; import java.util.Map; import java.util.HashMap; import cim4j.Control; import java.lang.ArrayIndexOutOfBoundsException; import java.lang.IllegalArgumentException; import cim4j.Simple_Float; import cim4j.AnalogValue; /* An analog control used for supervisory control. */ public class AnalogControl extends Control { private BaseClass[] AnalogControl_class_attributes; private BaseClass[] AnalogControl_primitive_attributes; private java.lang.String rdfid; public void setRdfid(java.lang.String id) { rdfid = id; } private abstract interface PrimitiveBuilder { public abstract BaseClass construct(java.lang.String value); }; private enum AnalogControl_primitive_builder implements PrimitiveBuilder { maxValue(){ public BaseClass construct (java.lang.String value) { return new Simple_Float(value); } }, minValue(){ public BaseClass construct (java.lang.String value) { return new Simple_Float(value); } }, LAST_ENUM() { public BaseClass construct (java.lang.String value) { return new cim4j.Integer("0"); } }; } private enum AnalogControl_class_attributes_enum { maxValue, minValue, AnalogValue, LAST_ENUM; } public AnalogControl() { AnalogControl_primitive_attributes = new BaseClass[AnalogControl_primitive_builder.values().length]; AnalogControl_class_attributes = new BaseClass[AnalogControl_class_attributes_enum.values().length]; } public void updateAttributeInArray(AnalogControl_class_attributes_enum attrEnum, BaseClass value) { try { AnalogControl_class_attributes[attrEnum.ordinal()] = value; } catch (ArrayIndexOutOfBoundsException aoobe) { System.out.println("No such attribute: " + attrEnum.name() + ": " + aoobe.getMessage()); } } public void updateAttributeInArray(AnalogControl_primitive_builder attrEnum, BaseClass value) { try { AnalogControl_primitive_attributes[attrEnum.ordinal()] = value; } catch (ArrayIndexOutOfBoundsException aoobe) { System.out.println("No such attribute: " + attrEnum.name() + ": " + aoobe.getMessage()); } } public void setAttribute(java.lang.String attrName, BaseClass value) { try { AnalogControl_class_attributes_enum attrEnum = AnalogControl_class_attributes_enum.valueOf(attrName); updateAttributeInArray(attrEnum, value); System.out.println("Updated AnalogControl, setting " + attrName); } catch (IllegalArgumentException iae) { super.setAttribute(attrName, value); } } /* If the attribute is a String, it is a primitive and we will make it into a BaseClass */ public void setAttribute(java.lang.String attrName, java.lang.String value) { try { AnalogControl_primitive_builder attrEnum = AnalogControl_primitive_builder.valueOf(attrName); updateAttributeInArray(attrEnum, attrEnum.construct(value)); System.out.println("Updated AnalogControl, setting " + attrName + " to: " + value); } catch (IllegalArgumentException iae) { super.setAttribute(attrName, value); } } public java.lang.String toString(boolean topClass) { java.lang.String result = ""; java.lang.String indent = ""; if (topClass) { for (AnalogControl_primitive_builder attrEnum: AnalogControl_primitive_builder.values()) { BaseClass bc = AnalogControl_primitive_attributes[attrEnum.ordinal()]; if (bc != null) { result += " AnalogControl." + attrEnum.name() + "(" + bc.debugString() + ")" + " " + bc.toString(false) + System.lineSeparator(); } } for (AnalogControl_class_attributes_enum attrEnum: AnalogControl_class_attributes_enum.values()) { BaseClass bc = AnalogControl_class_attributes[attrEnum.ordinal()]; if (bc != null) { result += " AnalogControl." + attrEnum.name() + "(" + bc.debugString() + ")" + " " + bc.toString(false) + System.lineSeparator(); } } result += super.toString(true); } else { result += "(AnalogControl) RDFID: " + rdfid; } return result; } public final java.lang.String debugName = "AnalogControl"; public java.lang.String debugString() { return debugName; } public void setValue(java.lang.String s) { System.out.println(debugString() + " is not sure what to do with " + s); } public BaseClass construct() { return new AnalogControl(); } };
#!/bin/bash # Bash strict mode. See http://redsymbol.net/articles/unofficial-bash-strict-mode/ set -euo pipefail # Get directory containing this script. See https://stackoverflow.com/a/246128 SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" # Use mint to install the dependencies, as it allows to pin a specific version (brew only allow to run the latest version) mint_version="0.14.1" if [ "$(mint version 2>/dev/null)" != "Version: $mint_version" ]; then echo "✨ Installing Mint, version $mint_version" git clone -b "$mint_version" https://github.com/yonaskolb/Mint.git # Clone a specific version of Mint (cd Mint && make) rm -rf Mint fi # Uninstall brew packages that will better be installed with mint if brew ls --versions carthage > /dev/null; then echo "✨ Uninstall carthage installed with brew" brew uninstall carthage fi echo "✨ Installing mint dependencies" mint bootstrap -l if [ "${CI:-}" = true ] ; then echo "✨ Skipping carthage dependencies as CI=true" else echo "✨ Installing carthage dependencies" . $SCRIPTS_DIR/carthage.sh bootstrap --platform iOS --cache-builds --use-xcframeworks fi echo "✨ Generating project" . $SCRIPTS_DIR/create-project.sh
#!/usr/bin/env nix-shell #!nix-shell -i bash -p curl gnugrep gnused jq set -x -eu -o pipefail cd $(dirname "${BASH_SOURCE[0]}") TAG=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} --silent https://api.github.com/repos/fluxcd/flux2/releases/latest | jq -r '.tag_name') VERSION=$(echo ${TAG} | sed 's/^v//') SHA256=$(nix-prefetch-url --quiet --unpack https://github.com/fluxcd/flux2/archive/refs/tags/${TAG}.tar.gz) SPEC_SHA256=$(nix-prefetch-url --quiet --unpack https://github.com/fluxcd/flux2/releases/download/${TAG}/manifests.tar.gz) setKV () { sed -i "s|$1 = \".*\"|$1 = \"${2:-}\"|" ./default.nix } setKV version ${VERSION} setKV sha256 ${SHA256} setKV manifestsSha256 ${SPEC_SHA256} setKV vendorSha256 "0000000000000000000000000000000000000000000000000000" # The same as lib.fakeSha256 cd ../../../../../ set +e VENDOR_SHA256=$(nix-build --no-out-link -A fluxcd 2>&1 >/dev/null | grep "got:" | cut -d':' -f2 | sed 's| ||g') set -e cd - > /dev/null if [ -n "${VENDOR_SHA256:-}" ]; then setKV vendorSha256 ${VENDOR_SHA256} else echo "Update failed. VENDOR_SHA256 is empty." exit 1 fi
#ifndef MAIN_KNAPSACK_H_ #define MAIN_KNAPSACK_H_ #include <utility> #include <iostream> #include "util/MyMath.h" /** * Represents an item from the item pool of the knapsack */ struct KnapSackItem{ // using string pointer because of performance reasons. std::string* name; double weight; double worth; bool operator==(const KnapSackItem& rhs){ return MyMath::almostEqual(weight, rhs.weight) && MyMath::almostEqual(worth, rhs.worth) && *name == *(rhs.name); } }; class KnapSack{ private: /** * The maximum capacity the knapsack can take */ double capacity; /** * the number of items available in the item pool */ int numOfItems; /** * the item pool from which the items can be picked */ KnapSackItem* items; KnapSack(); public: /** * Initializes a knapSack object with _capacity as max capacity and allocates an array of knapsackitems of the size of _numOfItems on the heap. */ KnapSack(double _capacity, int _numOfItems); KnapSack(const KnapSack& other); ~KnapSack(); friend void swap(KnapSack& first, KnapSack& second); KnapSack& operator=(KnapSack other); double getCapacity() const; int getNumOfItems() const; KnapSackItem* getItems() const; }; std::ostream& operator<<(std::ostream &strm, const KnapSack &v); void swap(KnapSack& first, KnapSack& second); #endif /* MAIN_KNAPSACK_H_ */
<reponame>vineethguna/docker-code-executor var cExecutor = require('../../../../modules/codeexecutors/cExecutor'); var helpers = require('../../../../modules/helpers'); var fs = require('fs'); describe('modules/codeexecutors/cExecutor.js', function(){ describe('cExecutor prototype', function(){ it('should have execute method', function(){ var cExecutorObj = new cExecutor(); expect(typeof cExecutorObj.execute).toBe('function'); }); describe('execute method of prototype', function(){ var fileExistsPath, fileNotExistsPath, cExecutorObj, validCallback; beforeAll(function(){ fileExistsPath = '/sample/exists'; fileNotExistsPath = '/sample/notexists'; spyOn(fs, 'statSync').and.callFake(function(filePath){ if(filePath == fileExistsPath){ return { isFile: function(){return true} } } else { return { isFile: function(){return false} } } }); }); beforeEach(function(){ cExecutorObj = new cExecutor(); validCallback = jasmine.createSpy('validCallback'); spyOn(helpers, 'isCommandInPath').and.returnValue(true); spyOn(cExecutorObj, 'compileAndExecuteCode').and.returnValue(null); }); it('should throw error if required parameters are not passed', function(){ expect(function(){cExecutorObj.execute()}).toThrowError(Error, 'Few parameters are undefined'); expect(function(){cExecutorObj.execute(fileExistsPath)}).toThrowError(Error, 'Few parameters are undefined') }); it('should call callback with error if file is not found at the given file path', function(){ cExecutorObj.execute(fileNotExistsPath, validCallback); expect(validCallback).toHaveBeenCalled(); expect(validCallback.calls.argsFor(0)).toEqual([Error('The given file path is not valid')]); }); it('should not throw error if the passed parameters are valid', function(){ expect(function(){cExecutorObj.execute(fileExistsPath, validCallback)}).not.toThrowError(); }); it('should call compileAndExecuteCode function with the right parameters', function(){ cExecutorObj.execute(fileExistsPath, validCallback); expect(cExecutorObj.compileAndExecuteCode).toHaveBeenCalled(); expect(cExecutorObj.compileAndExecuteCode.calls.argsFor(0)).toEqual([fileExistsPath, validCallback]); }); }); describe('compileAndExecuteCode function', function(){ var cExecutorObj, validCallback; beforeEach(function(){ cExecutorObj = new cExecutor(); validCallback = jasmine.createSpy('validCallback'); spyOn(helpers, 'isCommandInPath').and.returnValue(true); spyOn(helpers, 'executeCommandsInSeries').and.returnValue(null); }); it('should call isCommandInPath function', function(){ cExecutorObj.compileAndExecuteCode('/home/test1.c', validCallback); expect(helpers.isCommandInPath).toHaveBeenCalled(); expect(helpers.isCommandInPath.calls.argsFor(0)).toEqual(['gcc']); }); it('should call callback with error if gcc is not in PATH and callback is not passed', function(){ helpers.isCommandInPath.and.returnValue(false); cExecutorObj.compileAndExecuteCode('/home/test1.c', validCallback); expect(validCallback).toHaveBeenCalled(); expect(validCallback.calls.argsFor(0)).toEqual([Error('Gcc is not found in path')]); }); it('should call executeCommandInSeries to execute the command to compile', function(){ cExecutorObj.compileAndExecuteCode('/home/test1.c', validCallback); expect(helpers.executeCommandsInSeries).toHaveBeenCalled(); expect(helpers.executeCommandsInSeries.calls.argsFor(0)[0]).toEqual(['gcc -o /home/test1 /home/test1.c', '/home/test1']); helpers.executeCommandsInSeries.calls.reset(); cExecutorObj.compileAndExecuteCode('/home/abc/def/test1.c', validCallback); expect(helpers.executeCommandsInSeries).toHaveBeenCalled(); expect(helpers.executeCommandsInSeries.calls.argsFor(0)[0]). toEqual(['gcc -o /home/abc/def/test1 /home/abc/def/test1.c', '/home/abc/def/test1']); }); }); }); });
//============================================================================ // Copyright 2009-2020 ECMWF. // This software is licensed under the terms of the Apache Licence version 2.0 // which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. // In applying this licence, ECMWF does not waive the privileges and immunities // granted to it by virtue of its status as an intergovernmental organisation // nor does it submit to any jurisdiction. // //============================================================================ #include "PropertyEditor.hpp" #include <QDebug> #include <QGroupBox> #include <QFrame> #include <QHBoxLayout> #include <QLabel> #include <QTabWidget> #include <QToolButton> #include "ChangeNotifyEditor.hpp" #include "IconProvider.hpp" #include "PropertyLine.hpp" #include "VConfig.hpp" #include "VProperty.hpp" #include "ViewerUtil.hpp" PropertyEditor::PropertyEditor(QWidget* parent) : QWidget(parent) { setupUi(this); headerWidget_->setProperty("editorHeader","1"); scArea_->setProperty("editor","1"); scAreaContents_->setProperty("editorArea","1"); pixLabel_->clear(); } PropertyEditor::~PropertyEditor() = default; void PropertyEditor::edit(VProperty * vGroup,QPixmap pix) { clear(); group_=vGroup; QString txt=group_->param("desc"); headerWidget_->show(); headerLabel_->setText(txt); pixLabel_->setPixmap(pix); build(); } void PropertyEditor::edit(VProperty * vGroup,QString serverName) { clear(); group_=vGroup; headerWidget_->hide(); serverName_=serverName; build(); } void PropertyEditor::empty() { clear(); headerWidget_->hide(); serverName_.clear(); } void PropertyEditor::clear() { if(holder_) { vBox_->removeWidget(holder_); delete holder_; holder_=nullptr; } currentGrid_=nullptr; lineItems_.clear(); } //Build the property tree from the the definitions void PropertyEditor::build() { if(!group_) return; assert(holder_==NULL); holder_=new QWidget(scAreaContents_); holder_->setObjectName("h"); auto *vb=new QVBoxLayout(holder_); vb->setContentsMargins(0,0,0,0); vBox_->addWidget(holder_); //Loop over the children of the group Q_FOREACH(VProperty* vProp,group_->children()) { addItem(vProp,vb,holder_); } addRules(); addHelpers(); } void PropertyEditor::addRules() { Q_FOREACH(PropertyLine* line,lineItems_) { line->initPropertyRule(lineItems_); } } void PropertyEditor::addHelpers() { QMap<std::string,PropertyLine*> lineMap; Q_FOREACH(PropertyLine* line,lineItems_) { lineMap[line->property()->path()]=line; } Q_FOREACH(PropertyLine* line,lineItems_) { QString h=line->guiProperty()->param("helpers"); if(!h.isEmpty()) { Q_FOREACH(QString s,h.split("/")) { if(PropertyLine* hl=lineMap.value(s.toStdString(),NULL)) { line->addHelper(hl); } } } } } void PropertyEditor::addItem(VProperty* vProp,QVBoxLayout *layout,QWidget *parent) { if(vProp->name() == "line") { if (!currentGrid_) { currentGrid_=new QGridLayout(); layout->addLayout(currentGrid_); } addLine(vProp,currentGrid_,parent); } else if(vProp->name() == "group") { currentGrid_=nullptr; addGroup(vProp,layout,parent); } else if(vProp->name() == "grid") { currentGrid_=nullptr; addGrid(vProp,layout,parent); } else if(vProp->name() == "custom-notification") { currentGrid_=nullptr; addNotification(vProp,layout,parent); } else if(vProp->name() == "note") { if(currentGrid_) { addNote(vProp,currentGrid_,parent); } else { addNote(vProp,layout,parent); } } else if(vProp->name() == "tabs") { currentGrid_=nullptr; addTabs(vProp,layout,parent); } } PropertyLine* PropertyEditor::addLine(VProperty *vProp,QGridLayout *gridLayout,QWidget *parent) { PropertyLine* item = PropertyLineFactory::create(vProp,true,parent); if(item) { item->init(); //item->reset(vProp->link()->value()); int row=gridLayout->rowCount(); QLabel* lw=item->label(); QLabel* slw=item->suffixLabel(); if(lw) { //If lineLabelLen_ is set we adjust the size of the //line labels so that the editor widgets could be aligned if(lineLabelLen_ > 0) { QFont f; QFontMetrics fm(f); QString s; s=s.leftJustified(lineLabelLen_,'A'); lw->setMinimumWidth(ViewerUtil::textWidth(fm,s)); } gridLayout->addWidget(lw,row,0,Qt::AlignLeft); if(slw) { auto* hb=new QHBoxLayout; hb->addWidget(item->item()); hb->addWidget(slw); gridLayout->addLayout(hb,row,1,Qt::AlignLeft); } else { if(item->canExpand()) { auto* hb=new QHBoxLayout; hb->addWidget(item->item()); gridLayout->addLayout(hb,row,1,Qt::AlignLeft); } else gridLayout->addWidget(item->item(),row,1,Qt::AlignLeft); } } else { gridLayout->addWidget(item->item(),row,0,1,2,Qt::AlignLeft); } QWidget *bw=item->button(); if(bw) gridLayout->addWidget(bw,row,2); QToolButton* defTb=item->defaultTb(); if(defTb) { gridLayout->addWidget(defTb,row,3); } QToolButton* masterTb=item->masterTb(); if(masterTb) { gridLayout->addWidget(masterTb,row,4); } connect(item,SIGNAL(changed()), this,SIGNAL(changed())); lineItems_ << item; } return item; } void PropertyEditor::addGroup(VProperty* vProp,QVBoxLayout * layout,QWidget *parent) { if(vProp->name() != "group") return; auto *groupBox = new QGroupBox(vProp->param("title"),parent); groupBox->setObjectName("editorGroupBox"); auto *grid=new QGridLayout(); grid->setColumnStretch(1,1); groupBox->setLayout(grid); layout->addWidget(groupBox); currentGrid_=grid; //Loop over the children of the group Q_FOREACH(VProperty* chProp,vProp->children()) { //Add each item to the the editor addItem(chProp,layout,groupBox); } currentGrid_=nullptr; } void PropertyEditor::addGrid(VProperty* vProp,QVBoxLayout *layout,QWidget *parent) { if(vProp->name() != "grid") return; auto *groupBox = new QGroupBox(vProp->param("title"),parent); groupBox->setObjectName("editorGroupBox"); auto* grid=new QGridLayout(); groupBox->setLayout(grid); layout->addWidget(groupBox); //Add header for(int i=1; i < 10; i++) { QString h=vProp->param("h" + QString::number(i)); if(h.isEmpty()) { grid->setColumnStretch(i+1,1); break; } h+=" "; auto* hLabel=new QLabel(h,groupBox); grid->addWidget(hLabel,0,i,Qt::AlignHCenter); } //Add rows Q_FOREACH(VProperty* chProp,vProp->children()) { addGridRow(chProp,grid,groupBox); } } void PropertyEditor::addGridRow(VProperty* vProp,QGridLayout *grid,QWidget *parent) { if(vProp->name() != "row") { if(vProp->name() == "note") { auto *empty=new QLabel(" ",parent); grid->addWidget(empty,grid->rowCount(),0,1,-1,Qt::AlignVCenter); auto *label=new QLabel("&nbsp;&nbsp;&nbsp;<b>Note:</b> " + vProp->value().toString(),parent); grid->addWidget(label,grid->rowCount(),0,1,-1,Qt::AlignVCenter); } return; } int row=grid->rowCount(); QString labelText=vProp->param("label"); auto* label=new QLabel(labelText,parent); grid->addWidget(label,row,0); int col=1; Q_FOREACH(VProperty* chProp,vProp->children()) { if(chProp->name() == "line") { PropertyLine* item = PropertyLineFactory::create(chProp,false,parent); if(item) { item->init(); //item->reset(chProp->link()->value()); //QLabel* lw=item->label(); //QLabel* slw=item->suffixLabel(); //gridLayout->addWidget(item->item(),row,col,Qt::AlignLeft); /*QWidget *bw=item->button(); if(bw) gridLayout->addWidget(bw,row,2);*/ QToolButton* defTb=item->defaultTb(); QToolButton* masterTb=item->masterTb(); if(defTb || masterTb) { auto *hb=new QHBoxLayout(); hb->addWidget(item->item()); if(defTb) hb->addWidget(defTb); if(masterTb) hb->addWidget(masterTb); hb->addSpacing(15); hb->addStretch(1); grid->addLayout(hb,row,col); } else { grid->addWidget(item->item(),row,col,Qt::AlignLeft); } connect(item,SIGNAL(changed()), this,SIGNAL(changed())); lineItems_ << item; col++; } } } } void PropertyEditor::addNotification(VProperty* vProp,QVBoxLayout* layout,QWidget *parent) { if(vProp->name() != "custom-notification") return; //ChangeNotifyEditor* ne=new ChangeNotifyEditor(parent); auto* tab=new QTabWidget(parent); bool useGroup=(vProp->param("group") == "true"); if(useGroup) { QString labelText=vProp->param("title"); auto *groupBox = new QGroupBox(labelText,parent); groupBox->setObjectName("editorGroupBox"); auto* vb=new QVBoxLayout(); groupBox->setLayout(vb); vb->addWidget(tab); layout->addWidget(groupBox); } else { layout->addWidget(tab); } //Add rows Q_FOREACH(VProperty* chProp,vProp->children()) { if(chProp->name() == "row") { QString labelText=chProp->param("label"); QList<PropertyLine*> lineLst; QWidget* w=new QWidget(parent); auto* vb=new QVBoxLayout(w); //vb->setContentsMargins(4,4,4,4); currentGrid_=nullptr; if(VProperty *root=VConfig::instance()->find(chProp->param("root").toStdString())) { QLabel *labelDesc=new QLabel(tr("Description: <b>") + root->param("description") + "</b>",w); //labelDesc->setProperty("editorNotifyHeader","1"); vb->addWidget(labelDesc); vb->addSpacing(5); } int lineLstPos=lineItems_.count(); Q_FOREACH(VProperty* lineProp,chProp->children()) { addItem(lineProp,vb,w); } for(int i=lineLstPos; i < lineItems_.count(); i++) lineLst << lineItems_[i]; tab->addTab(w,labelText); //Connect up different components PropertyLine* enabledLine=nullptr; PropertyLine* popupLine=nullptr; PropertyLine* soundLine=nullptr; Q_FOREACH(PropertyLine* pl,lineLst) { if(pl->property()->name() == "enabled") { enabledLine=pl; } if(pl->property()->name() == "popup") { popupLine=pl; } if(pl->property()->name() == "sound") { soundLine=pl; } } if(enabledLine) { if(popupLine) { connect(enabledLine,SIGNAL(changed(QVariant)), popupLine,SLOT(slotEnabled(QVariant))); //init popupLine->slotEnabled(enabledLine->property()->value()); } if(soundLine) { connect(enabledLine,SIGNAL(changed(QVariant)), soundLine,SLOT(slotEnabled(QVariant))); //init soundLine->slotEnabled(enabledLine->property()->value()); } } //ne->addRow(labelText,lineLst,w); } } } void PropertyEditor::addTabs(VProperty* vProp,QVBoxLayout *layout,QWidget* parent) { if(vProp->name() != "tabs") return; auto *t=new QTabWidget(parent); t->setObjectName("tab"); layout->addWidget(t); Q_FOREACH(VProperty* chProp,vProp->children()) { if(chProp->name() == "tab") { addTab(chProp,t); } } } void PropertyEditor::addTab(VProperty* vProp,QTabWidget* tab) { if(vProp->name() != "tab") return; auto *w=new QWidget(tab); auto* vb=new QVBoxLayout(); w->setLayout(vb); tab->addTab(w,vProp->param("label")); if(!vProp->param("adjustLineLabel").isEmpty()) { lineLabelLen_=vProp->param("adjustLineLabel").toInt(); if(lineLabelLen_ <= 0 || lineLabelLen_ > 300) lineLabelLen_=-1; } Q_FOREACH(VProperty* chProp,vProp->children()) { addItem(chProp,vb,w); } vb->addStretch(1); } void PropertyEditor::addNote(VProperty* vProp,QVBoxLayout* layout,QWidget *parent) { if(vProp->name() != "note") return; QString txt=vProp->value().toString(); txt.replace("%SERVER%",(serverName_.isEmpty())?"?":"<b>" + serverName_ + "</b>"); layout->addSpacing(5); auto *label=new QLabel("<i>Note:</i> " + txt,parent); layout->addWidget(label); } void PropertyEditor::addNote(VProperty* vProp,QGridLayout* layout,QWidget *parent) { if(vProp->name() != "note") return; QString txt=vProp->value().toString(); txt.replace("%SERVER%",(serverName_.isEmpty())?"?":"<b>" + serverName_ + "</b>"); //QLabel *empty=new QLabel(" ",parent); //layout->addWidget(empty,layout->rowCount(),0,1,-1,Qt::AlignVCenter); //QLabel *label=new QLabel("&nbsp;&nbsp;&nbsp;<b>Note:</b> " + txt,parent); //QFrame* fr=new QFrame(parent); //fr->setFrameShape(QFrame::HLine); //layout->addWidget(fr,layout->rowCount(),0,1,-1,Qt::AlignVCenter); auto *label=new QLabel("<table><tr><td><b>&nbsp;&nbsp;&nbsp;</b></td><td><i>Note:</i> " + txt + "</td></tr></table>",parent); label->setWordWrap(true); layout->addWidget(label,layout->rowCount(),0,1,-1,Qt::AlignVCenter); } bool PropertyEditor::applyChange() { bool changed=false; //Loop over the top level properties (groups) in the browser Q_FOREACH(PropertyLine* item, lineItems_) { //Sync the changes to VConfig if(item->applyChange()) { changed=true; } } return changed; }
// // QSViewController.h // QSOpenGLES004 // // Created by zhongpingjiang on 17/2/23. // Copyright © 2017年 shaoqing. All rights reserved. // //#import <UIKit/UIKit.h> #import <GLKit/GLKit.h> @interface QSViewController : GLKViewController @end
package biz import ( "context" "github.com/google/uuid" "github.com/goxiaoy/go-saas-kit/pkg/gorm" gorm2 "gorm.io/gorm" ) const ( InternalLoginProvider string = "internal" InternalRememberTokenName string = "remember" ) type UserToken struct { gorm.AuditedModel DeletedAt gorm2.DeletedAt `gorm:"index"` UserId uuid.UUID `gorm:"type:char(36);primaryKey" json:"user_id"` LoginProvider string `gorm:"primaryKey" json:"login_provider"` Name string `gorm:"primaryKey" json:"name"` Value string `json:"value"` } type UserTokenRepo interface { FindByUserIdAndLoginProvider(ctx context.Context, userId, loginProvider string) ([]*UserToken, error) FindByUserIdAndLoginProviderAndName(ctx context.Context, userId, loginProvider, name string) (*UserToken, error) DeleteByUserIdAndLoginProvider(ctx context.Context, userId, loginProvider string) error DeleteByUserIdAndLoginProviderAndName(ctx context.Context, userId, loginProvider, name string) error Create(ctx context.Context, userId, loginProvider, name, value string) (*UserToken, error) }
package elasta.core.flow.impl; import elasta.core.flow.Flow; import elasta.core.flow.FlowException; import elasta.core.flow.StateTransitionHandlers; import elasta.core.flow.StateTrigger; import elasta.core.promise.impl.Promises; import elasta.core.promise.intfs.Promise; import java.util.Map; import java.util.Set; /** * Created by Jango on 11/13/2016. */ public class FlowImpl implements Flow { private static final StateTrigger DEFAULT_STATE_TRIGGER = StateTrigger.create(null, null); private final String initialState; private final Map<String, Set<String>> eventsByStateMap; private final Map<String, Map<String, String>> eventToStateMapByState; private final Map<String, StateTransitionHandlers> stateCallbacksMap; FlowImpl(String initialState, Map<String, Set<String>> eventsByStateMap, Map<String, Map<String, String>> eventToStateMapByState, Map<String, StateTransitionHandlers> stateCallbacksMap) { this.initialState = initialState; this.eventsByStateMap = eventsByStateMap; this.eventToStateMapByState = eventToStateMapByState; this.stateCallbacksMap = stateCallbacksMap; } public <R> Promise<R> start(Object message) { return start(initialState, message); } public <R> Promise<R> start(String state, Object message) { return execState(state, message); } private <R, T> Promise<R> execState(String state, T message) { final StateTransitionHandlers<T, Object> stateTransitionHandlers = stateCallbacksMap.get(state); return this.execute(stateTransitionHandlers, message).mapP(trigger -> { final NextStateAndMessage nextStateAndMessage = nextStateAndMessage(trigger, state); if (nextStateAndMessage.nextState == null) { return Promises.of((R) nextStateAndMessage.message); } return execState(nextStateAndMessage.nextState, nextStateAndMessage.message); }); } private <P> NextStateAndMessage<P> nextStateAndMessage(StateTrigger<P> trigger, String state) { final Set<String> events = eventsByStateMap.get(state); if (events.size() == 0) { if (trigger == null) { return new NextStateAndMessage<>(null, null); } return new NextStateAndMessage<>(null, trigger.getMessage()); } if (trigger == null || trigger.getEvent() == null) { throw new FlowException("Invalid trigger '" + trigger + "' from state '" + state + "'."); } if (!events.contains(trigger.getEvent())) { throw new FlowException("Invalid event '" + trigger.getEvent() + "' on trigger from state '" + state + "'."); } return new NextStateAndMessage<>(eventToStateMapByState.get(state).get(trigger.getEvent()), trigger.getMessage()); } private <T, R> Promise<StateTrigger<R>> execute(StateTransitionHandlers<T, R> stateTransitionHandlers, T message) { try { return stateTransitionHandlers.getOnEnter().handle(message) .cmpP(signal -> { Promise<Void> voidPromise = stateTransitionHandlers.getOnExit().handle(); return voidPromise == null ? Promises.empty() : voidPromise; }); } catch (Throwable throwable) { return Promises.error(throwable); } } private <RR> StateTrigger<RR> defaultStateTrigger() { return DEFAULT_STATE_TRIGGER; } private static class NextStateAndMessage<T> { private final String nextState; private final T message; public NextStateAndMessage(String nextState, T message) { this.nextState = nextState; this.message = message; } } public static StateTrigger getDefaultStateTrigger() { return DEFAULT_STATE_TRIGGER; } public String getInitialState() { return initialState; } public Map<String, Set<String>> getEventsByStateMap() { return eventsByStateMap; } public Map<String, Map<String, String>> getEventToStateMapByState() { return eventToStateMapByState; } public Map<String, StateTransitionHandlers> getStateCallbacksMap() { return stateCallbacksMap; } }
package com.example.jzy.helloword.entity; /** * Created by jzy on 8/24/17. */ public class AddEvent { private String text; private int flag; public AddEvent(String text){ this.text = text; this.flag = 1; } public int getFlag(){return this.flag;} }
<gh_stars>0 import { EventType } from '../../../enums'; export interface GameBannerInterface { type: EventType.ADS_PROMO; color: string; text_color: string; icon: string; title: string; text: string; action_type: string; action_data: { ios: string; android: string; }; time: number; coin_reward: number; version: number; }
#!/usr/bin/env node var fs = require('fs') var path = require('path') var mkdirp = require('mkdirp') var console2file = require('console2file').default var os_service = require('os-service') var sudo = require('sudo-prompt') var isElevated = require('is-elevated') var hypergit = require('hypergit') var envpaths = require('env-paths')('hypergit') var commandJoin = require('command-join') var minimisted = require('minimisted') var usage = ` USAGE: hypergit-service [--version] [command] [--help] Commands: install Install an OS service (Windows and Linux supported) that starts hypergit seed on boot remove Uninstall that OS service logdir Print out the directory where the hyperdbs and log file are saved seed (Not meant to be run directly) The wrapper around hypergit seed that is invoked by the OS service manager ` function logresult (status) { return function (error) { if (error) { console.log(error) } else { console.log(status) } } } function logoutput (err, stdout, stderr) { if (err) { console.log(err) } else { if (stderr) { console.log(stderr) } console.log(stdout) } } function rerunAsAdmin () { sudo.exec(commandJoin(process.argv), {}, logoutput) } function main ({_: [command]}) { switch (command) { case 'install': isElevated().then(function (elevated) { if (elevated) { os_service.add("hypergit-service", { programArgs: ["seed"] }, logresult('installed')) } else { rerunAsAdmin() } }) break case 'remove': isElevated().then(function (elevated) { if (elevated) { os_service.remove("hypergit-service", logresult('removed')) } else { rerunAsAdmin() } }) break case 'seed': // I'm using the callback versions because they let us conveniently ignore errors. mkdirp(envpaths.log, () => { fs.unlink(path.join(envpaths.log, 'log.txt'), () => { console2file({ filePath: path.join(envpaths.log, 'log.txt'), timestamp: true, fileOnly: false }) console.log('Running with CLI arguments: ' + commandJoin(process.argv)) os_service.run(() => os_service.stop()) // seed ALL repos hypergit.seed() }) }) break case 'logdir': console.log(envpaths.log) break default: console.log(usage) break } } minimisted(main)
Page({ data: { number: 0, _num: 1, page: 2, list: [], over: !1 }, tab: function(t) { var e = this, s = t.target.dataset.num; getApp().core.showLoading({ title: "数据加载中...", mask: !0 }), getApp().request({ url: getApp().api.step.log, data: { status: s }, success: function(t) { getApp().core.hideLoading(); var a = t.data.log; e.setData({ number: t.data.user.step_currency, list: a, _num: s, page: 2 }); } }); }, onReachBottom: function() { var e = this, s = e.data.over; if (!s) { this.data.id; var p = this.data.list, t = this.data._num, o = this.data.page; this.setData({ loading: !0 }), getApp().request({ url: getApp().api.step.log, data: { status: t, page: o }, success: function(t) { for (var a = 0; a < t.data.log.length; a++) p.push(t.data.log[a]); t.data.log.length < 6 && (s = !0), e.setData({ list: p, page: o + 1, loading: !1, over: s }); } }); } }, onLoad: function(t) { getApp().page.onLoad(this, t); var e = this; getApp().core.showLoading({ title: "数据加载中...", mask: !0 }), getApp().request({ url: getApp().api.step.log, data: { status: 1, page: 1 }, success: function(t) { getApp().core.hideLoading(); var a = t.data.log; e.setData({ number: t.data.user.step_currency, list: a }); } }); } });
/* * Copyright 2010-2022 the original author or authors. * * 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 * * https://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.springframework.data.mongodb.core; import java.util.Optional; import org.springframework.data.mongodb.core.query.Collation; import org.springframework.lang.Nullable; /** * @author <NAME> * @author <NAME> * @author <NAME> */ public class FindAndModifyOptions { private boolean returnNew; private boolean upsert; private boolean remove; private @Nullable Collation collation; private static final FindAndModifyOptions NONE = new FindAndModifyOptions() { private static final String ERROR_MSG = "FindAndModifyOptions.none() cannot be changed; Please use FindAndModifyOptions.options() instead"; @Override public FindAndModifyOptions returnNew(boolean returnNew) { throw new UnsupportedOperationException(ERROR_MSG); } @Override public FindAndModifyOptions upsert(boolean upsert) { throw new UnsupportedOperationException(ERROR_MSG); } @Override public FindAndModifyOptions remove(boolean remove) { throw new UnsupportedOperationException(ERROR_MSG); } @Override public FindAndModifyOptions collation(@Nullable Collation collation) { throw new UnsupportedOperationException(ERROR_MSG); } }; /** * Static factory method to create a FindAndModifyOptions instance * * @return new instance of {@link FindAndModifyOptions}. */ public static FindAndModifyOptions options() { return new FindAndModifyOptions(); } /** * Static factory method returning an unmodifiable {@link FindAndModifyOptions} instance. * * @return unmodifiable {@link FindAndModifyOptions} instance. * @since 2.2 */ public static FindAndModifyOptions none() { return NONE; } /** * Create new {@link FindAndModifyOptions} based on option of given {@literal source}. * * @param source can be {@literal null}. * @return new instance of {@link FindAndModifyOptions}. * @since 2.0 */ public static FindAndModifyOptions of(@Nullable FindAndModifyOptions source) { FindAndModifyOptions options = new FindAndModifyOptions(); if (source == null) { return options; } options.returnNew = source.returnNew; options.upsert = source.upsert; options.remove = source.remove; options.collation = source.collation; return options; } public FindAndModifyOptions returnNew(boolean returnNew) { this.returnNew = returnNew; return this; } public FindAndModifyOptions upsert(boolean upsert) { this.upsert = upsert; return this; } public FindAndModifyOptions remove(boolean remove) { this.remove = remove; return this; } /** * Define the {@link Collation} specifying language-specific rules for string comparison. * * @param collation can be {@literal null}. * @return this. * @since 2.0 */ public FindAndModifyOptions collation(@Nullable Collation collation) { this.collation = collation; return this; } public boolean isReturnNew() { return returnNew; } public boolean isUpsert() { return upsert; } public boolean isRemove() { return remove; } /** * Get the {@link Collation} specifying language-specific rules for string comparison. * * @return never {@literal null}. * @since 2.0 */ public Optional<Collation> getCollation() { return Optional.ofNullable(collation); } }
<filename>web/src/main/java/istu/bacs/web/submission/SubmissionServiceImpl.java package istu.bacs.web.submission; import istu.bacs.db.contest.Contest; import istu.bacs.db.contest.ContestProblem; import istu.bacs.db.submission.Submission; import istu.bacs.db.submission.SubmissionRepository; import istu.bacs.db.submission.SubmissionResult; import istu.bacs.db.user.User; import istu.bacs.rabbit.RabbitService; import istu.bacs.web.contest.ContestNotFoundException; import istu.bacs.web.contest.ContestService; import istu.bacs.web.model.submission.SubmitSolution; import istu.bacs.web.problem.ProblemNotFoundException; import istu.bacs.web.user.UserService; import lombok.AllArgsConstructor; import org.hibernate.query.criteria.internal.OrderImpl; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; import javax.persistence.EntityManager; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; import javax.transaction.Transactional; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import static istu.bacs.db.submission.Verdict.SCHEDULED; import static istu.bacs.rabbit.QueueName.SCHEDULED_SUBMISSIONS; @Service @AllArgsConstructor public class SubmissionServiceImpl implements SubmissionService { private final SubmissionRepository submissionRepository; private final ContestService contestService; private final UserService userService; private final EntityManager em; private final RabbitService rabbitService; @Override @Transactional public Submission findById(int submissionId) { Submission submission = submissionRepository.findById(submissionId).orElse(null); if (submission != null) { User currentUser = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); boolean isAdmin = Arrays.stream(currentUser.getRoles()).anyMatch(r -> r.equals("ROLE_ADMIN")); if (submission.getAuthor().getUserId() != (int) currentUser.getUserId() && !isAdmin) throw new RuntimeException(new IllegalAccessException("Unable to get this submission till requested by the author or an admin")); initializeSubmission(submission); } return submission; } @Override public List<Submission> findAll(Integer contestId, String problemIndex, String authorUsername) { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Submission> query = cb.createQuery(Submission.class); Root<Submission> s = query.from(Submission.class); s.fetch("contest"); List<Predicate> predicates = new ArrayList<>(); if (authorUsername != null) { User currentUser = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); boolean isAdmin = Arrays.stream(currentUser.getRoles()).anyMatch(r -> r.equals("ROLE_ADMIN")); User author = authorUsername.equals(currentUser.getUsername()) || !isAdmin ? currentUser : userService.findByUsername(authorUsername); predicates.add(cb.equal(s.get("author"), author)); } if (contestId != null) { predicates.add(cb.equal(s.get("contest"), new Contest().withContestId(contestId))); } if (problemIndex != null) { predicates.add(cb.equal(s.get("problemIndex"), problemIndex)); } query.select(s) .where(predicates.toArray(new Predicate[predicates.size()])) .orderBy(new OrderImpl(s.get("submissionId")).reverse()); return em.createQuery(query).getResultList(); } @Override public int submit(SubmitSolution sol) { int contestId = sol.getContestId(); Contest contest = contestService.findById(contestId); if (contest == null) { throw new ContestNotFoundException("Contest with id " + contestId + " not found"); } String problemIndex = sol.getProblemIndex(); ContestProblem problem = contest.getProblem(problemIndex); if (problem == null) { throw new ProblemNotFoundException( "Problem for contestId = " + contestId + " and problemIndex = " + problemIndex + " not found"); } User author = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); SubmissionResult res = new SubmissionResult().withVerdict(SCHEDULED); Submission submission = Submission.builder() .author(author) .contest(contest) .problemIndex(problemIndex) .pretestsOnly(false) .created(LocalDateTime.now()) .language(sol.getLanguage()) .solution(sol.getSolution()) .result(res) .build(); submissionRepository.save(submission); rabbitService.send(SCHEDULED_SUBMISSIONS, submission.getSubmissionId()); return submission.getSubmissionId(); } /** * Инициализирует все лениво-загружаемые поля посылки. * * @param submission посылка, поля которой необходимо инициализировать. */ private void initializeSubmission(Submission submission) { if (submission != null) { submission.getContest().getProblems().forEach(p -> { }); } } }
#!/bin/sh make build
#!/usr/bin/env bash sudo ln -s $PROJECT_HOME/ch02/airflow_test.py ~/airflow/dags/
#include <stdio.h> // A recursive binary search function. It returns // location of x in given array arr[l..r] is present, // otherwise -1 int binarySearch(int arr[], int l, int r, int x) { if (r >= l) { int mid = l + (r - l) / 2; // If the element is present at the middle // itself if (arr[mid] == x) return mid; // If element is smaller than mid, then // it can only be present in left subarray if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); // Else the element can only be present // in right subarray return binarySearch(arr, mid + 1, r, x); } // We reach here when element is not // present in array return -1; } int main(void) { int arr[] = {1, 3, 4, 5, 7, 8, 12, 22}; int n = sizeof(arr) / sizeof(arr[0]); int x = 5; int result = binarySearch(arr, 0, n - 1, x); (result == -1) ? printf("Element is not present in array") : printf("Element is present at index %d", result); return 0; }
<filename>generators/create:refinedtype/templates/headers/GPL-3.0-or-later.ts // // <%- packageName %> // // Copyright (C) <%- copyrightYear %> <%- copyrightHolder %> // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or (at // your option) any later version. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. //
curl --request GET \ --url https://saferwebapi.com/v3/history/violation/:USDotNumber \ --header 'x-api-key: YourApiKey'
<gh_stars>0 "use strict"; var bus_early = { "Text": "Early morning?", "Do": "jump bus-stop-early-am" } var bus_powerup = { "Text": "Power Up", "Do": "jump bus-stop-encounter" } script["bus-stop"] = [ "scene bus-stop with fadeIn", "show GC Neutral left", "show CB Neutral left", "You arrive at the bus stop...", "show Stranger Neutral right", "There is a man there already waiting", "GC: Hello! How are you?", "Stranger ..................fine............", "GC hhmmmm, ok.........", {"Choice": { "Rude": { "Text": "Hey rude much?", "Do": "jump bus-stop-rude" }, "Early-AM": bus_early, "Power-up": bus_powerup }} ]; script["bus-stop-rude"] = [ "show GC Scold-R", "GC Coconut Bomb, THAT'S rude.", "show CB Sad left", "CB Sorry......", {"Choice": { "Early-AM": bus_early, "Power-up": bus_powerup }} ]; script["bus-stop-early-am"] = [ "show CB Neutral left", "Stranger Yeah.....late night too (yawn)", "CB Ooooookaaaay............", "jump bus-stop-awkward-wait" ]; // THE AWKWARD WAIT OF AWESOME!!!! script["bus-stop-awkward-wait"] = [ "All of you awkwardly wait for the bus...", "jump bus-stop-awkward-wait-fn" ]; script["bus-stop-awkward-wait-fn"] = [ "...", {"Conditional": { "Condition": function() { return Math.random() > 0.9; }, "True": "jump bus-stop-leave", "False": "jump bus-stop-awkward-wait-fn" }}, ]; script["bus-stop-leave"] = [ "The bus finally arrives and you get on", "jump town" ]; script["bus-stop-encounter"] = [ "show CB Power-Up left", // Is this just some dude? or are they one of MagmaMan's henchmen? {"Conditional": { "Condition": function() { return Math.random() < 0.5; }, "True": "jump bus-stop-scared", "False": "jump bus-stop-henchman" }} ]; script["bus-stop-scared"] = [ "show Stranger Scared right", "Stranger Oh, No! Please stop, I don't want to fight. Please leave me alone.", {"Choice": { "Sorry": { "Text": "Sorry...", "Do": "jump bus-stop-sorry" }, "Power-up": { "Text": "Power Up!", "Do": "jump bus-stop-scared-powerup" } }} ]; script["bus-stop-scared-powerup"] = [ "show Stranger Scared right", "show GC Scold-R", "show CB Sad left", "Glam Cake smacks Coconut Bomb on the back of the head", "show GC Neutral", "GC Sorry sir, he can be rather impertinent.", "show GC Scold-R", "Glam Cake glares at Coconut Bomb", "Coconut Bomb sulks", "show Stranger Neutral right", "Stranger It's fine, whatever...", "He takes a few steps away from you", "jump bus-stop-awkward-wait" ]; script["bus-stop-sorry"] = [ "show CB Sad left", "The stranger takes a few steps away from you...", "jump bus-stop-awkward-wait" ]; let Stranger = new Enemy( "Stranger", 50, [ ["EYE LASORS!!!", 10], ["DHOOM LAZORZ!!!", 20], ["PEW PEW-PEW OUT MY EYES!!!!", 15], ["STRANGER DANGER!!!", 0], ["MAGMAMAN 4 EVAR!!!!!", 5] ], ["The stranger has been defeated by your awesomeness!", "jump town"], ["You lost to MagmaMans henchman: The Stranger...", "jump Hospital"] ); script["bus-stop-henchman"] = [ "show Stranger Angry right", "show GC Neutral left", "play music Fight loop", "Stranger ......How did you know?...", "Stranger It doesn't matter, MAGMAMAN will reward me for taking you out for him!", function () { fight(Stranger); return true; }, "jump player-fight" ];
#!/bin/sh # This is a generated file; do not edit or check into version control. export "FLUTTER_ROOT=/Users/ramin/dev/sdk/flutter" export "FLUTTER_APPLICATION_PATH=/Users/ramin/Downloads/charts-master/charts_flutter/example" export "FLUTTER_TARGET=/Users/ramin/Downloads/charts-master/charts_flutter/example/lib/main.dart" export "FLUTTER_BUILD_DIR=build" export "SYMROOT=${SOURCE_ROOT}/../build/ios" export "FLUTTER_FRAMEWORK_DIR=/Users/ramin/dev/sdk/flutter/bin/cache/artifacts/engine/ios" export "TRACK_WIDGET_CREATION=true"
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Character.create(name: 'Luke', movie: movies.first) c1 = Category.create(name: "Art & Culture") c2 = Category.create(name: "Comedy") c3 = Category.create(name: "Outdoor Activities") c4 = Category.create(name: "Film & TV") c5 = Category.create(name: "Food & Drink") c6 = Category.create(name: "Live Music") c7 = Category.create(name: "LGBTQ+") c8 = Category.create(name: "Other") e1 = Event.create(name: "Watch A Bug's Life", description: "Go to theater and watch a Bug's life, the classic tale of a dorky any who overcomes many challenges in order to defeat a whole lot of mean grasshoppers.", duration: "1 hour 35 minutes", cost: "40.00", location: "Alamo Drafthouse - Lakeline") e2 = Event.create(name: "Blue's on the Green", description: "See Wild Child at Blue's on the Green. Don't forget it's BYOB.", duration: "2-3 hours", cost: "0.00", location: "2100 Barton Springs Rd., Zilker Park, Austin, TX 78746") e3 = Event.create(name: "Kayaking", description: "Need to secure the rental first from Congress Ave. Kayaks, check for groupon.", duration: "2 hours", cost: "38.00", location: "Waller Creek Boathouse: 74 Trinity Street, Austin, Texas 78701") o1 = Occasion.create(name: "Hot Date", date: "2020-10-10", time: "15:43") o2 = Occasion.create(name: "Shannon's Birthday", date: "2020-10-15", time: "17:43") o3 = Occasion.create(name: "Anniversary", date: "2020-11-15", time: "16:43") c4.events << e1 c6.events << e2 c3.events << e3 o1.events << [e1, e2] o2.events << e3 o3.events << e2
module ErrorListFor class ErrorList attr_reader :errors def initialize(invalid_object) @errors = invalid_object.errors end def list return nil if @errors.none? @errors.full_messages.to_sentence end end end
<filename>src/onlinecontroller.go package main import ( "fmt" "net/http" "github.com/gorilla/mux" ) // OnlineController handles the web methods for registering and discovering services type OnlineController struct { Srv *Server } // AddController adds the controller routes to the router func (c *OnlineController) AddController(router *mux.Router, s *Server) { c.Srv = s router.Methods("GET", "POST").Path("/online"). Handler(Logger(c, http.HandlerFunc(c.handleOnline))) // router.Methods("POST").Path("/shutdown"). // Handler(Logger(c, http.HandlerFunc(c.handleShutdown))) } // handleOnline handles the /online web method call func (c *OnlineController) handleOnline(w http.ResponseWriter, r *http.Request) { w.Write([]byte("true")) } // handleOnline handles the /shutdown web method call // func (c *OnlineController) handleShutdown(w http.ResponseWriter, r *http.Request) { // c.Srv.Shutdown() // } // LogInfo is used to log information messages for this controller. func (c *OnlineController) LogInfo(v ...interface{}) { a := fmt.Sprint(v) logger.Info("OnlineController: [Inf] ", a[1:len(a)-1]) }
from django.http import JsonResponse def sum (request): num1 = request.GET.get('num1') num2 = request.GET.get('num2') total = int(num1) + int(num2) return JsonResponse({"sum":total}, status=200)
#!/bin/bash set -o xtrace set -e if [ -z $PYVER ]; then echo "PYVER is not set" exit 1 fi export CUDA_VERSION=$(echo $(ls /usr/local/cuda/lib64/libcudart.so*) | sed 's/.*\.\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)/\1.\2/') # Adding conda-forge channel for dependencies conda config --add channels conda-forge CONDA_BUILD_OPTIONS="--python=${PYVER} --exclusive-config-file config/conda_build_config.yaml" CONDA_PREFIX=${CONDA_PREFIX:-/root/miniconda3} export DALI_CONDA_BUILD_VERSION=$(cat ../VERSION)$(if [ "${NVIDIA_DALI_BUILD_FLAVOR}" != "" ]; then \ echo .${NVIDIA_DALI_BUILD_FLAVOR}.${DALI_TIMESTAMP}; \ fi) # Build custom OpenCV first, as DALI requires only bare OpenCV without many features and dependencies conda build ${CONDA_BUILD_OPTIONS} third_party/dali_opencv/recipe # Build custom FFmpeg, as DALI requires only bare FFmpeg without many features and dependencies # but wiht mpeg4_unpack_bframes enabled conda build ${CONDA_BUILD_OPTIONS} third_party/dali_ffmpeg/recipe # Building DALI package conda build ${CONDA_BUILD_OPTIONS} recipe # Copying the artifacts from conda prefix mkdir -p artifacts cp ${CONDA_PREFIX}/conda-bld/*/nvidia-dali*.tar.bz2 artifacts
#!/usr/bin/env node var fs = require('fs'); var async = require('async'); var path = require('path'); var packageFolder = require('./package-folder'); // console.log(process.argv); if (process.argv.length < 4) { console.error('Usage: ./compile_folder.sh outfile token_name no_compile [files ... ]') console.error('Compiles code into built-in binary.') process.exit(1); } var outfile = process.argv[2]; var varname = process.argv[3]; var docompile = !parseInt(process.argv[4]); var infiles = process.argv.slice(5); var colonyCompiler = require('colony-compiler'); // console.log('>>>', process.argv); packageFolder(infiles, varname, function (file, buf, next) { buf = buf.toString('utf-8'); if (file.match(/\.js$/)) { try { if (docompile) { colonyCompiler.toBytecode(colonyCompiler.colonize(String(buf)), '[T]:' + file, next); } else { next(null, colonyCompiler.colonize(String(buf), { embedLineNumbers: true }).source); } } catch (e) { throw new Error('Bytecode compilation of ' + file + ' failed.'); } } else if (file.match(/\.lua$/)) { try { if (docompile) { colonyCompiler.toBytecode({ source: String(buf) }, '[T]: ' + file, next); } else { next(null, buf); } } catch (e) { throw new Error('Bytecode compilation of ' + file + ' failed.'); } } else { next(null, buf); } }, function (err, out) { fs.writeFileSync(outfile, out); // console.log(out); });
#!/bin/bash # Copyright (c) 2019 NVIDIA CORPORATION. All rights reserved. # 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. echo "Container nvidia build = " $NVIDIA_BUILD_ID gpu="2,3" master_port="8595" init_checkpoint="" dataset=wiki_70k # change this for other datasets train_batch_size=14336 num_gpus=2 train_batch_size_phase2=4096 train_steps=7038 train_steps_phase2=1563 gradient_accumulation_steps=256 gradient_accumulation_steps_phase2=512 resume_training="true" while getopts g:p:c:n:d:x:y:a:b:w:z:r: option do case "${option}" in g) gpu=${OPTARG};; p) master_port=${OPTARG};; c) init_checkpoint=${OPTARG};; r) resume_training=${OPTARG};; n) num_gpus=${OPTARG};; d) dataset=${OPTARG};; a) train_batch_size=${OPTARG};; b) train_batch_size_phase2=${OPTARG};; x) gradient_accumulation_steps=${OPTARG};; y) gradient_accumulation_steps_phase2=${OPTARG};; w) train_steps=${OPTARG};; z) train_steps_phase2=${OPTARG};; esac done DATASET1="hdf5_lower_case_1_seq_len_128_max_pred_20_masked_lm_prob_0.15_random_seed_12345_dupe_factor_5/$dataset" DATASET2="hdf5_lower_case_1_seq_len_512_max_pred_80_masked_lm_prob_0.15_random_seed_12345_dupe_factor_5/$dataset" learning_rate="6e-3" precision="fp16" warmup_proportion="0.2843" save_checkpoint_steps=10 create_logfile="true" accumulate_gradients="true" seed=$RANDOM job_name="bert_lamb_pretraining" allreduce_post_accumulation="true" allreduce_post_accumulation_fp16="true" learning_rate_phase2="4e-3" warmup_proportion_phase2="0.128" DATA_DIR_PHASE1=${PWD}/data/${DATASET1}/ BERT_CONFIG=bert_config.json CODEDIR="${PWD}" RESULTS_DIR=$CODEDIR/results CHECKPOINTS_DIR=$RESULTS_DIR/checkpoints mkdir -p $CHECKPOINTS_DIR export CUDA_VISIBLE_DEVICES=$gpu if [ ! -d "$DATA_DIR_PHASE1" ] ; then echo "Warning! $DATA_DIR_PHASE1 directory missing. Training cannot start" fi if [ ! -d "$RESULTS_DIR" ] ; then echo "Error! $RESULTS_DIR directory missing." exit -1 fi if [ ! -d "$CHECKPOINTS_DIR" ] ; then echo "Warning! $CHECKPOINTS_DIR directory missing." echo "Checkpoints will be written to $RESULTS_DIR instead." CHECKPOINTS_DIR=$RESULTS_DIR fi if [ ! -f "$BERT_CONFIG" ] ; then echo "Error! BERT base configuration file not found at $BERT_CONFIG" exit -1 fi PREC="" if [ "$precision" = "fp16" ] ; then PREC="--fp16" elif [ "$precision" = "fp32" ] ; then PREC="" else echo "Unknown <precision> argument" exit -2 fi ACCUMULATE_GRADIENTS="" if [ "$accumulate_gradients" == "true" ] ; then ACCUMULATE_GRADIENTS="--gradient_accumulation_steps=$gradient_accumulation_steps" fi CHECKPOINT="" if [ "$resume_training" == "true" ] ; then CHECKPOINT="--resume_from_checkpoint" fi ALL_REDUCE_POST_ACCUMULATION="" if [ "$allreduce_post_accumulation" == "true" ] ; then ALL_REDUCE_POST_ACCUMULATION="--allreduce_post_accumulation" fi ALL_REDUCE_POST_ACCUMULATION_FP16="" if [ "$allreduce_post_accumulation_fp16" == "true" ] ; then ALL_REDUCE_POST_ACCUMULATION_FP16="--allreduce_post_accumulation_fp16" fi INIT_CHECKPOINT="" if [ "$init_checkpoint" != "None" ] ; then INIT_CHECKPOINT="--init_checkpoint=$init_checkpoint" fi echo $DATA_DIR_PHASE1 INPUT_DIR=$DATA_DIR_PHASE1 CMD=" $CODEDIR/run_pretraining.py" CMD+=" --input_dir=$DATA_DIR_PHASE1" CMD+=" --output_dir=$CHECKPOINTS_DIR" CMD+=" --config_file=$BERT_CONFIG" CMD+=" --bert_model=bert-base-uncased" CMD+=" --train_batch_size=$train_batch_size" CMD+=" --max_seq_length=128" CMD+=" --max_predictions_per_seq=20" CMD+=" --max_steps=$train_steps" CMD+=" --warmup_proportion=$warmup_proportion" CMD+=" --num_steps_per_checkpoint=$save_checkpoint_steps" CMD+=" --learning_rate=$learning_rate" CMD+=" --seed=$seed" CMD+=" $PREC" CMD+=" $ACCUMULATE_GRADIENTS" CMD+=" $CHECKPOINT" CMD+=" $ALL_REDUCE_POST_ACCUMULATION" CMD+=" $ALL_REDUCE_POST_ACCUMULATION_FP16" CMD+=" $INIT_CHECKPOINT" CMD+=" --do_train" CMD="python3 -m torch.distributed.launch --master_port $master_port --nproc_per_node=$num_gpus $CMD" if [ "$create_logfile" = "true" ] ; then export GBS=$(expr $train_batch_size \* $num_gpus) printf -v TAG "pyt_bert_pretraining_phase1_%s_gbs%d" "$precision" $GBS DATESTAMP=`date +'%y%m%d%H%M%S'` LOGFILE=$RESULTS_DIR/$job_name.$TAG.$DATESTAMP.log printf "Logs written to %s\n" "$LOGFILE" fi set -x if [ -z "$LOGFILE" ] ; then $CMD else ( $CMD ) |& tee $LOGFILE fi set +x echo "finished pretraining" #Start Phase2 DATA_DIR_PHASE2=${PWD}/data/${DATASET2}/ PREC="" if [ "$precision" = "fp16" ] ; then PREC="--fp16" elif [ "$precision" = "fp32" ] ; then PREC="" else echo "Unknown <precision> argument" exit -2 fi ACCUMULATE_GRADIENTS="" if [ "$accumulate_gradients" == "true" ] ; then ACCUMULATE_GRADIENTS="--gradient_accumulation_steps=$gradient_accumulation_steps_phase2" fi ALL_REDUCE_POST_ACCUMULATION="" if [ "$allreduce_post_accumulation" == "true" ] ; then ALL_REDUCE_POST_ACCUMULATION="--allreduce_post_accumulation" fi ALL_REDUCE_POST_ACCUMULATION_FP16="" if [ "$allreduce_post_accumulation_fp16" == "true" ] ; then ALL_REDUCE_POST_ACCUMULATION_FP16="--allreduce_post_accumulation_fp16" fi echo $DATA_DIR_PHASE2 INPUT_DIR=$DATA_DIR_PHASE2 CMD=" $CODEDIR/run_pretraining.py" CMD+=" --input_dir=$DATA_DIR_PHASE2" CMD+=" --output_dir=$CHECKPOINTS_DIR" CMD+=" --config_file=$BERT_CONFIG" CMD+=" --bert_model=bert-base-uncased" CMD+=" --train_batch_size=$train_batch_size_phase2" CMD+=" --max_seq_length=512" CMD+=" --max_predictions_per_seq=80" CMD+=" --max_steps=$train_steps_phase2" CMD+=" --warmup_proportion=$warmup_proportion_phase2" CMD+=" --num_steps_per_checkpoint=$save_checkpoint_steps" CMD+=" --learning_rate=$learning_rate_phase2" CMD+=" --seed=$seed" CMD+=" $PREC" CMD+=" $ACCUMULATE_GRADIENTS" CMD+=" $CHECKPOINT" CMD+=" $ALL_REDUCE_POST_ACCUMULATION" CMD+=" $ALL_REDUCE_POST_ACCUMULATION_FP16" CMD+=" --do_train --phase2 --resume_from_checkpoint --phase1_end_step=$train_steps" CMD="python3 -m torch.distributed.launch --master_port $master_port --nproc_per_node=$num_gpus $CMD" if [ "$create_logfile" = "true" ] ; then export GBS=$(expr $train_batch_size_phase2 \* $num_gpus) printf -v TAG "pyt_bert_pretraining_phase2_%s_gbs%d" "$precision" $GBS DATESTAMP=`date +'%y%m%d%H%M%S'` LOGFILE=$RESULTS_DIR/$job_name.$TAG.$DATESTAMP.log printf "Logs written to %s\n" "$LOGFILE" fi set -x if [ -z "$LOGFILE" ] ; then $CMD else ( $CMD ) |& tee $LOGFILE fi set +x echo "finished phase2"
#!/bin/bash trap 'exit 1' 2 #traps Ctrl-C (signal 2) runtest() { export GEMFIRE_BUILD=$1 export GEMFIRE=$GEMFIRE_BUILD/product export LD_LIBRARY_PATH=$GEMFIRE/../hidden/lib:$GEMFIRE/lib export JTESTS=$GEMFIRE/../tests/classes export CLASSPATH=$GEMFIRE/lib/gemfire.jar:$JTESTS export JAVA_HOME=/export/gcm/where/jdk/1.7.0_67/x86_64.linux echo "Running $2 with $3..." echo "" $JAVA_HOME/bin/java -server \ -classpath $CLASSPATH:$GEMFIRE/../product-gfxd/lib/gemfirexd.jar -DGEMFIRE=$GEMFIRE -DJTESTS=$JTESTS \ -DprovideRegressionSummary=false -DnukeHungTest=true -DmoveRemoteDirs=true \ -DnumTimesToRun=1 -DtestFileName=$2 -DlocalConf=$3 \ batterytest.BatteryTest } #------------------------------------------------------------------------------- if [ -z "$1" ] then echo "No gemfire build was specified." exit 0 fi runtest $1 study001.bt study001.local.conf
#!/usr/bin/env bash ### every exit != 0 fails the script set -e echo "Install Java JDK 8" apt-get update apt-get install -y openjdk-8-jdk apt-get clean -y
#!/bin/bash curl -sSL https://rvm.io/mpapis.asc | gpg2 --import - curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import - curl -sSL https://get.rvm.io | bash -s stable source /home/ec2-user/.rvm/scripts/rvm cd /home/ec2-user/environment/newrelic-ruby-kata rvm rvmrc warning ignore allGemfiles rvm install "ruby-2.2.2" bundle install
import { Server as HapiServer } from 'hapi'; import GoodPlugin from './plugins/good'; import AuthCookiePlugin from './plugins/auth-cookie'; import { getConnection } from 'typeorm'; import Routes from './routes'; import config from './config'; export class Server { public static async init(): Promise<HapiServer> { const server = new HapiServer(); server.connection({ host: config.get('server:host'), port: config.get('server:port'), router: { isCaseSensitive: false, stripTrailingSlash: true, }, routes: { cors: config.get('server:routes:cors'), }, }); await GoodPlugin.register(server); await AuthCookiePlugin.register(server); await Routes.init(server); return server; } }
import {join} from "https://deno.land/std@0.70.0/path/mod.ts" export * from "https://deno.land/std@0.70.0/testing/asserts.ts" export * from "https://deno.land/x/mock@v0.4.0/spy.ts" export * from "./test_api.ts" export * from "./assertCalledWith.ts" export * from "./fake_zqd.ts" import * as zealot from "../../../dist/zealot.es.js" export function test(name: string, fn: () => void | Promise<void>) { return Deno.test({ name, fn, only: name.startsWith("ONLY") }) } export function testFile(name: string) { return join(Deno.cwd(), "data", name) } export function uniq(things: any[]) { let u: any[] = [] for (let thing of things) { if (u.includes(thing)) continue u.push(thing) } return u } export const createTime = zealot.createTime export const createZealot = zealot.createZealot
package moze_intel.projecte.emc.mappers; import com.electronwill.nightconfig.core.file.CommentedFileConfig; import moze_intel.projecte.api.mapper.EMCMapper; import moze_intel.projecte.api.mapper.IEMCMapper; import moze_intel.projecte.api.mapper.collector.IMappingCollector; import moze_intel.projecte.api.nss.NSSItem; import moze_intel.projecte.api.nss.NormalizedSimpleStack; import net.minecraft.item.Item; import net.minecraft.resources.DataPackRegistries; import net.minecraft.resources.IResourceManager; import net.minecraft.tags.ITag; import net.minecraft.util.ResourceLocation; @EMCMapper public class OreBlacklistMapper implements IEMCMapper<NormalizedSimpleStack, Long> { private static final ResourceLocation ORES = new ResourceLocation("forge", "ores"); @Override public void addMappings(IMappingCollector<NormalizedSimpleStack, Long> mapper, CommentedFileConfig config, DataPackRegistries dataPackRegistries, IResourceManager resourceManager) { //Note: We need to get the tag by resource location, as named tags are not populated yet here ITag<Item> ores = dataPackRegistries.getTags().getItems().getTag(ORES); if (ores != null) { for (Item ore : ores.getValues()) { NSSItem nssOre = NSSItem.createItem(ore); mapper.setValueBefore(nssOre, 0L); mapper.setValueAfter(nssOre, 0L); } } } @Override public String getName() { return "OresBlacklistMapper"; } @Override public String getDescription() { return "Set EMC=0 for everything in the forge:ores tag"; } }
from typing import List def max_profit(prices: List[int]) -> int: if not prices: return 0 min_price = prices[0] max_profit = 0 for price in prices: if price < min_price: min_price = price else: max_profit = max(max_profit, price - min_price) return max_profit
<gh_stars>0 import ElectronStore from 'electron-store' import { ipcRenderer } from 'electron' import { ProjectOptions } from '@lib/frameworks/project' export class Project { protected store: any constructor (id: string) { log.info('Initializing project store: ' + id) this.store = new ElectronStore({ encryptionKey: process.env.NODE_ENV === 'production' ? 'v1' : undefined, name: 'project', defaults: { busy: false, options: { id } }, fileExtension: 'db', cwd: `Projects/${id}` }) } public getPath (): string { return this.store.path.replace(/\/project\.db$/i, '') } public get (key?: string, fallback?: any): any { if (!key) { return this.store.store } return this.store.get(key, fallback) } public set (key: string, value?: any): void { this.store.set(key, value) } public save (options: ProjectOptions): void { options = {...this.store.get('options'), ...options} this.store.set('options', options) if (ipcRenderer) { ipcRenderer.emit('project-saved', JSON.stringify(options)) } } public toJSON (): ProjectOptions { return this.store.get('options') } public isBusy (): boolean { return this.store.get('busy', false) } }
import { initClient } from './client.js'; const rootElement = document.querySelector('#root'); initClient(rootElement);
// Copyright 2022 @nepoche/ // SPDX-License-Identifier: Apache-2.0 import BigNumber from 'bignumber.js'; import { expect } from 'chai'; import { Fixed18 } from '../fixed-18.js'; describe('fixed 128 constructor', () => { it('constructor should work', () => { const a = new Fixed18(1); const b = new Fixed18('1'); const c = new Fixed18(new BigNumber(1)); expect(a).to.deep.equal(b); expect(a).to.deep.equal(c); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const d = new Fixed18(); // test for no params expect(d).to.deep.equal(Fixed18.ZERO); }); it('from parts should work', () => { const a = Fixed18.fromParts(1); expect(a.getInner().toNumber()).to.deep.equal(1); }); it('from natural should work', () => { const a = Fixed18.fromNatural(1); expect(a.getInner().toNumber()).to.deep.equal(1e18); }); it('from rational should work', () => { const a = Fixed18.fromRational(10, 2); const b = Fixed18.fromRational(100, 20); // 0.0000000000000000001 will be 0 const c = Fixed18.fromRational(1, 10000000000000000000); expect(a.toNumber()).to.deep.equal(5); expect(a).to.deep.equal(b); expect(c).to.deep.equal(Fixed18.ZERO); }); }); describe('toFixed should work', () => { const a = Fixed18.fromNatural(0.123456789); const b = Fixed18.fromNatural(0.00000000001); expect(a.toFixed(6)).to.deep.equal('0.123456'); expect(a.toFixed(9)).to.deep.equal('0.123456789'); expect(b.toFixed(11)).to.deep.equal('0.00000000001'); expect(b.toFixed(20)).to.deep.equal('0.00000000001'); expect(b.toString(11)).to.deep.equal('1e-11'); }); describe('fixed 128 operation', () => { const a = Fixed18.fromNatural(10); const b = Fixed18.fromNatural(20); it('add should work', () => { const c = Fixed18.fromNatural(30); expect(a.add(b)).to.deep.equal(c); }); it('sub should work', () => { const c = Fixed18.fromNatural(-10); expect(a.sub(b)).to.deep.equal(c); }); it('mul should work', () => { const c = Fixed18.fromNatural(200); expect(a.mul(b)).to.deep.equal(c); }); it('div should work', () => { const c = Fixed18.fromRational(1, 2); expect(a.div(b)).to.deep.equal(c); }); it('div with zero should be Infinity', () => { const b = Fixed18.fromNatural(0); const c = new Fixed18(Infinity); expect(a.div(b)).to.deep.equal(c); }); it('negated should work', () => { const c = Fixed18.fromNatural(-10); expect(a.negated()).to.deep.equal(c); }); }); describe('fixed 128 compare should work', () => { const a = Fixed18.fromNatural(10); const b = Fixed18.fromNatural(20); it('lessThan should work', () => { expect(a.isLessThan(b)).to.deep.equal(true); }); it('greaterThan should work', () => { expect(a.isGreaterThan(b)).to.deep.equal(false); }); it('isEqual should work', () => { const c = Fixed18.fromNatural(10); expect(a.isEqualTo(b)).to.deep.equal(false); expect(a.isEqualTo(c)).to.deep.equal(true); }); it('max should work', () => { expect(a.max(b)).to.deep.equal(b); expect(a.min(b)).to.deep.equal(a); }); it('isZero should work', () => { const c = Fixed18.ZERO; expect(c.isZero()).to.deep.equal(true); expect(a.isZero()).to.deep.equal(false); }); it('isInfinite should work', () => { const c1 = Fixed18.fromNatural(Infinity); const c2 = Fixed18.fromNatural(-Infinity); const c3 = Fixed18.fromNatural(NaN); expect(c1.isFinity()).to.deep.equal(false); expect(c2.isFinity()).to.deep.equal(false); expect(c3.isFinity()).to.deep.equal(false); expect(a.isFinity()).to.deep.equal(true); }); it('isNaN should work', () => { const c = Fixed18.fromNatural(NaN); const d = Fixed18.ZERO.div(Fixed18.ZERO); expect(a.isNaN()).to.deep.equal(false); expect(c.isNaN()).to.deep.equal(true); expect(d.isNaN()).to.deep.equal(true); }); }); describe('fixed 128 format', () => { const a = Fixed18.fromRational(256, 100); it('toNumber should work', () => { expect(a.toNumber()).to.deep.equal(2.56); expect(a.toNumber(1, 2)).to.deep.equal(2.6); // round towards infinity expect(a.toNumber(1, 3)).to.deep.equal(2.5); // roound towards -infinity }); it('toString should work', () => { expect(a.toString()).to.deep.equal('2.56'); expect(a.toString(1, 2)).to.deep.equal('2.6'); // round towards infinity expect(a.toString(1, 3)).to.deep.equal('2.5'); // round towards -intinity }); it('innerToString should work', () => { const b = Fixed18.fromParts(5.5); const c1 = Fixed18.fromNatural(NaN); const c2 = Fixed18.fromNatural(Infinity); expect(a.innerToString()).to.deep.equal('2560000000000000000'); expect(b.innerToString()).to.deep.equal('5'); expect(c1.innerToString()).to.deep.equal('0'); expect(c2.innerToString()).to.deep.equal('0'); }); });
/* * Copyright © 2019 <NAME>, Inc. * * 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 io.cdap.plugin.dlp; import com.google.privacy.dlp.v2.FieldId; import com.google.privacy.dlp.v2.Table; import com.google.privacy.dlp.v2.Value; import com.google.protobuf.Timestamp; import com.google.type.Date; import com.google.type.TimeOfDay; import io.cdap.cdap.api.data.format.StructuredRecord; import io.cdap.cdap.api.data.schema.Schema; import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.stream.Collectors; /** * Helper class for converting to DLP data types */ public final class Utils { /** * Created updated StructuredRecord from existing record and DLP Table of new values * StructuredRecord * * @param table Table representation from DLP containing new values to be updated * @param oldRecord Existing StructuredRecord that needs to be updated * @return New StructuredRecord with the updated values * @throws Exception when table contain unexpected type or type-casting fails due to invalid values */ public static StructuredRecord getStructuredRecordFromTable(Table table, StructuredRecord oldRecord) throws Exception { StructuredRecord.Builder recordBuilder = createBuilderFromStructuredRecord(oldRecord); if (table.getRowsCount() == 0) { String headers = String.join(", ", table.getHeadersList().stream().map(fieldId -> fieldId.getName()).collect( Collectors.toList())); throw new IndexOutOfBoundsException(String.format( "DLP returned a table with no rows, expected one row. Table has headers: %s.", headers)); } Table.Row row = table.getRows(0); for (int i = 0; i < table.getHeadersList().size(); i++) { String fieldName = table.getHeadersList().get(i).getName(); Value fieldValue = row.getValues(i); if (fieldValue == null) { continue; } Schema tempSchema = oldRecord.getSchema().getField(fieldName).getSchema(); Schema fieldSchema = tempSchema.isNullable() ? tempSchema.getNonNullable() : tempSchema; Schema.LogicalType logicalType = fieldSchema.getLogicalType(); if (logicalType != null) { switch (logicalType) { case TIME_MICROS: case TIME_MILLIS: TimeOfDay timeValue = fieldValue.getTimeValue(); recordBuilder.setTime(fieldName, LocalTime .of(timeValue.getHours(), timeValue.getMinutes(), timeValue.getSeconds(), timeValue.getNanos())); break; case TIMESTAMP_MICROS: case TIMESTAMP_MILLIS: Timestamp timestampValue = fieldValue.getTimestampValue(); ZoneId zoneId = oldRecord.getTimestamp(fieldName).getZone(); LocalDateTime localDateTime; if (timestampValue.getSeconds() + timestampValue.getNanos() == 0) { localDateTime = LocalDateTime .parse(fieldValue.getStringValue(), DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm'Z'")); } else { localDateTime = Instant .ofEpochSecond(timestampValue.getSeconds(), timestampValue.getNanos()) .atZone(zoneId) .toLocalDateTime(); } recordBuilder.setTimestamp(fieldName, ZonedDateTime.of(localDateTime, zoneId)); break; case DATE: Date dateValue = fieldValue.getDateValue(); recordBuilder .setDate(fieldName, LocalDate.of(dateValue.getYear(), dateValue.getMonth(), dateValue.getDay())); break; default: throw new IllegalArgumentException("Failed to parse table into structured record"); } } else { Schema.Type type = fieldSchema.getType(); String value = ""; switch (type) { case STRING: value = fieldValue.getStringValue(); break; case INT: case LONG: value = String.valueOf(fieldValue.getIntegerValue()); break; case BOOLEAN: value = String.valueOf(fieldValue.getBooleanValue()); break; case DOUBLE: case FLOAT: value = String.valueOf(fieldValue.getFloatValue()); break; default: throw new IllegalStateException( String.format("DLP plugin does not support type '%s' for field '%s'", type.toString(), fieldName)); } recordBuilder.convertAndSet(fieldName, value); } } return recordBuilder.build(); } /** * Create a StructuredRecord Builder using an existing record as the starting point. This should be used to * edit/update an existing record * * @param record StructuredRecord to use as a base * @return StructuredRecord Builder with all fields from {@code record} set */ private static StructuredRecord.Builder createBuilderFromStructuredRecord(StructuredRecord record) { StructuredRecord.Builder recordBuilder = StructuredRecord.builder(record.getSchema()); for (Schema.Field field : record.getSchema().getFields()) { String fieldName = field.getName(); Object fieldValue = record.get(fieldName); Schema fieldSchema = field.getSchema().isNullable() ? field.getSchema().getNonNullable() : field.getSchema(); Schema.LogicalType logicalType = fieldSchema.getLogicalType(); if (fieldSchema.getType().isSimpleType()) { recordBuilder.set(fieldName, fieldValue); } else { if (logicalType != null) { switch (logicalType) { case TIME_MICROS: case TIME_MILLIS: recordBuilder.setTime(fieldName, (LocalTime) fieldValue); break; case TIMESTAMP_MICROS: case TIMESTAMP_MILLIS: recordBuilder.setTimestamp(fieldName, (ZonedDateTime) fieldValue); break; case DATE: recordBuilder.setDate(fieldName, (LocalDate) fieldValue); break; default: throw new IllegalStateException( String.format("DLP plugin does not support type '%s' for field '%s'", logicalType.toString(), field.getSchema().getDisplayName())); } } } } return recordBuilder; } /** * Creates a DLP Table from a StructuredRecord * * @param record StructuredRecord to convert to Table * @return Table with one row containing the data from {@code record} * @throws Exception when record contains unexpected type or type-casting fails due to invalid values */ public static Table getTableFromStructuredRecord(StructuredRecord record) throws Exception { Table.Builder tableBuiler = Table.newBuilder(); Table.Row.Builder rowBuilder = Table.Row.newBuilder(); for (Schema.Field field : record.getSchema().getFields()) { String fieldName = field.getName(); Object fieldValue = record.get(fieldName); if (fieldValue == null) { continue; } tableBuiler.addHeaders(FieldId.newBuilder().setName(fieldName).build()); Value.Builder valueBuilder = Value.newBuilder(); Schema fieldSchema = field.getSchema().isNullable() ? field.getSchema().getNonNullable() : field.getSchema(); Schema.LogicalType logicalType = fieldSchema.getLogicalType(); if (logicalType != null) { switch (logicalType) { case TIME_MICROS: case TIME_MILLIS: LocalTime time = record.getTime(fieldName); valueBuilder.setTimeValue( TimeOfDay.newBuilder() .setHours(time.getHour()) .setMinutes(time.getMinute()) .setSeconds(time.getSecond()) .setNanos(time.getNano()) .build() ); break; case TIMESTAMP_MICROS: case TIMESTAMP_MILLIS: ZonedDateTime timestamp = record.getTimestamp(fieldName); valueBuilder.setTimestampValue( Timestamp.newBuilder() .setSeconds(timestamp.toEpochSecond()) .setNanos(timestamp.getNano()) .build() ); break; case DATE: LocalDate date = record.getDate(fieldName); valueBuilder.setDateValue( Date.newBuilder() .setYear(date.getYear()) .setMonth(date.getMonthValue()) .setDay(date.getDayOfMonth()) .build() ); break; default: throw new IllegalStateException( String.format("DLP plugin does not support type '%s' for field '%s'", logicalType.toString(), fieldName)); } } else { Schema.Type type = fieldSchema.getType(); switch (type) { case STRING: valueBuilder.setStringValue(String.valueOf(fieldValue)); break; case INT: case LONG: valueBuilder.setIntegerValue((Long) fieldValue); break; case BOOLEAN: valueBuilder.setBooleanValue((Boolean) fieldValue); break; case DOUBLE: case FLOAT: valueBuilder.setFloatValue((Double) fieldValue); break; default: throw new IllegalStateException( String.format("DLP plugin does not support type '%s' for field '%s'", type.toString(), fieldName)); } } rowBuilder.addValues(valueBuilder.build()); } tableBuiler.addRows(rowBuilder.build()); return tableBuiler.build(); } }
# encoding: utf-8 require File.expand_path('../../test_helper', __FILE__) class InterpolationTest < Test::Unit::TestCase test "interpolation" do user = User.new(:name => 'John %{surname}') assert_equal user.name(:surname => 'Bates'), '<NAME>' end test "when no params are passed in" do user = User.new(:name => 'John %{surname}') assert_equal user.name, 'John %{surname}' end test "interpolation error" do user = User.new(:name => 'John %{surname}') exception = assert_raise(I18n::MissingInterpolationArgument) { user.name(:foo => "bar") } assert_match(/missing interpolation argument.*John %{surname}/, exception.message) end end
-- <NAME>. INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (53, '1', '85', '2', '2'), (53, '2', '95', '1', '1'), (53, '3', '95', '1', '1'), (53, '4', '95', '1', '1'), (53, '5', '96', '1', '1'), (53, '6', '90', '1', '1'), (53, '7', '92', '1', '1'), (53, '8', '97', '1', '1'), (53, '9', '90', '1', '1'), (53, '10', '90', '1', '1'), (53, '11', '92', '1', '1'), (53, '12', '92', '1', '1'), (53, '13', '100', '1', '1'), (53, '14', '99', '1', '1'), (53, '15', '95', '1', '1'), (53, '16', '92', '1', '1'), (53, '17', '97', '1', '1'), (53, '18', '93', '1', '1'), (53, '19', '90', '1', '1'), (53, '20', '91', '1', '1'), (53, '21', '90', '1', '1'), (53, '22', '94', '1', '1'), (53, '23', '90', '1', '1'), (53, '24', '95', '1', '1'), (53, '25', '83', '2', '2'), (53, '26', '90', '1', '1'), (53, '27', '90', '1', '1'), (53, '28', '90', '1', '1'), (53, '29', '90', '1', '1'), (53, '30', '90', '1', '1'), (53, '31', '93', '1', '1'), (53, '32', '90', '1', '1'), (53, '33', '85', '2', '2'), (53, '34', '95', '1', '1'), (53, '35', '90', '1', '1'), (53, '36', '90', '1', '1'), (53, '37', '94', '1', '1'), (53, '38', '90', '1', '1'), (53, '39', '93', '1', '1'), (53, '40', '90', '1', '1'), (53, '41', '91', '1', '1'), (53, '42', '85', '2', '2'), (53, '43', '95', '1', '1'), (53, '44', '95', '1', '1'), (53, '45', '80', '3', '2'), (53, '46', '90', '1', '1'), (53, '47', '85', '2', '2'), (53, '48', '95', '1', '1'), (53, '49', '90', '1', '1'), (53, '50', '76', '3', '2'), (53, '51', '90', '1', '1'), (53, '52', '90', '1', '1'), (53, '53', '90', '1', '1'), (53, '54', '94', '1', '1'), (53, '55', '95', '1', '1'), (53, '56', '90', '1', '1'), (53, '57', '95', '1', '1'), (53, '58', '90', '1', '1'), (53, '59', '90', '1', '1'), (53, '60', '95', '1', '1'); -- ('Близнюк О.В.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (54, '1', '76', '3', '2'), (54, '2', '90', '1', '1'), (54, '3', '93', '1', '1'), (54, '4', '82', '2', '2'), (54, '5', '97', '1', '1'), (54, '6', '75', '3', '2'), (54, '7', '84', '2', '2'), (54, '8', '79', '3', '2'), (54, '9', '62', '5', '3'), (54, '10', '75', '3', '2'), (54, '11', '75', '3', '2'), (54, '12', '80', '3', '2'), (54, '13', '90', '1', '1'), (54, '14', '90', '1', '1'), (54, '15', '72', '4', '3'), (54, '16', '60', '5', '3'), (54, '17', '75', '3', '2'), (54, '18', '76', '3', '2'), (54, '19', '60', '5', '3'), (54, '20', '60', '5', '3'), (54, '21', '85', '2', '2'), (54, '22', '90', '1', '1'), (54, '23', '75', '3', '2'), (54, '24', '60', '5', '3'), (54, '25', '73', '4', '3'), (54, '26', '60', '5', '3'), (54, '27', '60', '5', '3'), (54, '28', '90', '1', '1'), (54, '29', '63', '5', '3'), (54, '30', '90', '1', '1'), (54, '31', '79', '3', '2'), (54, '32', '75', '3', '2'), (54, '33', '90', '1', '1'), (54, '34', '75', '3', '2'), (54, '35', '63', '5', '3'), (54, '36', '75', '3', '2'), (54, '37', '75', '3', '2'), (54, '38', '60', '5', '3'), (54, '39', '80', '3', '2'), (54, '40', '60', '5', '3'), (54, '41', '76', '3', '2'), (54, '42', '75', '3', '2'), (54, '43', '75', '3', '2'), (54, '44', '69', '4', '3'), (54, '45', '75', '3', '2'), (54, '46', '90', '1', '1'), (54, '47', '60', '5', '3'), (54, '48', '92', '1', '1'), (54, '49', '75', '3', '2'), (54, '50', '90', '1', '1'), (54, '51', '75', '3', '2'), (54, '52', '68', '4', '3'), (54, '53', '68', '4', '3'), (54, '54', '94', '1', '1'), (54, '55', '75', '3', '2'), (54, '56', '75', '3', '2'), (54, '57', '60', '5', '3'), (54, '58', '75', '3', '2'), (54, '59', '80', '3', '2'), (54, '60', '84', '2', '2'); -- ('Боднарук І.О.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (55, '1', '60', '5', '3'), (55, '2', '82', '2', '2'), (55, '3', '91', '1', '1'), (55, '4', '60', '5', '3'), (55, '5', '90', '1', '1'), (55, '6', '77', '3', '2'), (55, '7', '69', '4', '3'), (55, '8', '91', '1', '1'), (55, '9', '62', '5', '3'), (55, '10', '62', '5', '3'), (55, '11', '69', '4', '3'), (55, '12', '78', '3', '2'), (55, '13', '69', '4', '3'), (55, '14', '90', '1', '1'), (55, '15', '79', '3', '2'), (55, '16', '62', '5', '3'), (55, '17', '82', '2', '2'), (55, '18', '92', '1', '1'), (55, '19', '69', '4', '3'), (55, '20', '84', '2', '2'), (55, '21', '86', '2', '2'), (55, '22', '79', '3', '2'), (55, '23', '70', '4', '3'), (55, '24', '66', '5', '3'), (55, '25', '80', '3', '2'), (55, '26', '83', '2', '2'), (55, '27', '76', '3', '2'), (55, '28', '75', '3', '2'), (55, '29', '90', '1', '1'), (55, '30', '75', '3', '2'), (55, '31', '84', '2', '2'), (55, '32', '72', '4', '3'), (55, '33', '75', '3', '2'), (55, '34', '60', '5', '3'), (55, '35', '70', '4', '3'), (55, '36', '75', '3', '2'), (55, '37', '78', '3', '2'), (55, '38', '90', '1', '1'), (55, '39', '82', '2', '2'), (55, '40', '85', '2', '2'), (55, '41', '90', '1', '1'), (55, '42', '75', '3', '2'), (55, '43', '81', '3', '2'), (55, '44', '81', '3', '2'), (55, '45', '80', '3', '2'), (55, '46', '80', '3', '2'), (55, '47', '60', '5', '3'), (55, '48', '93', '1', '1'), (55, '49', '75', '3', '2'), (55, '50', '61', '5', '3'), (55, '51', '68', '4', '3'), (55, '52', '84', '2', '2'), (55, '53', '92', '1', '1'), (55, '54', '80', '3', '2'), (55, '55', '85', '2', '2'), (55, '56', '75', '3', '2'), (55, '57', '80', '3', '2'), (55, '58', '85', '2', '2'), (55, '59', '85', '2', '2'), (55, '60', '84', '2', '2'); -- ('<NAME> ',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (56, '1', 0, '5', 0), (56, '2', 0, '5', 0), (56, '3', 0, '5', 0), (56, '4', 0, '5', 0), (56, '5', 0, '5', 0), (56, '6', 0, '5', 0), (56, '7', 0, '5', 0), (56, '8', 0, '5', 0), (56, '9', 0, '5', 0), (56, '10', 0, '5', 0), (56, '11', 0, '5', 0), (56, '12', 0, '5', 0), (56, '13', 0, '5', 0), (56, '14', 0, '5', 0), (56, '15', 0, '5', 0), (56, '16', 0, '5', 0), (56, '17', 0, '5', 0), (56, '18', 0, '5', 0), (56, '19', 0, '5', 0), (56, '20', 0, '5', 0), (56, '21', 0, '5', 0), (56, '22', 0, '5', 0), (56, '23', 0, '5', 0), (56, '24', 0, '5', 0), (56, '25', 0, '5', 0), (56, '26', 0, '5', 0), (56, '27', 0, '5', 0), (56, '28', '77', '3', '2'), (56, '29', '63', '5', '3'), (56, '30', '60', '5', '3'), (56, '31', '64', '5', '3'), (56, '32', '60', '5', '3'), (56, '33', '61', '5', '3'), (56, '34', '65', '5', '3'), (56, '35', '65', '5', '3'), (56, '36', '65', '5', '3'), (56, '37', '75', '3', '2'), (56, '38', '60', '5', '3'), (56, '39', '82', '2', '2'), (56, '40', '70', '4', '3'), (56, '41', '63', '5', '3'), (56, '42', 0, '5', 0), (56, '43', 0, '5', 0), (56, '44', 0, '5', 0), (56, '45', 0, '5', 0), (56, '46', 0, '5', 0), (56, '47', 0, '5', 0), (56, '48', '60', '5', '3'), (56, '49', '61', '5', '3'), (56, '50', '60', '5', '3'), (56, '51', '60', '5', '3'), (56, '52', '68', '4', '3'), (56, '53', '60', '5', '3'), (56, '54', '65', '5', '3'), (56, '55', 0, '5', 0), (56, '56', '60', '5', '3'), (56, '57', 0, '5', 0), (56, '58', 0, '5', 0), (56, '59', '65', '5', '3'), (56, '60', '86', '2', '2'); -- ('Велі<NAME>. І.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (57, '1', '63', '5', '3'), (57, '2', '90', '1', '1'), (57, '3', '91', '1', '1'), (57, '4', '94', '1', '1'), (57, '5', '94', '1', '1'), (57, '6', '92', '1', '1'), (57, '7', '76', '3', '2'), (57, '8', '90', '1', '1'), (57, '9', '76', '3', '2'), (57, '10', '78', '3', '2'), (57, '11', '91', '1', '1'), (57, '12', '93', '1', '1'), (57, '13', '60', '5', '3'), (57, '14', '98', '1', '1'), (57, '15', '95', '1', '1'), (57, '16', '67', '4', '3'), (57, '17', '84', '2', '2'), (57, '18', '92', '1', '1'), (57, '19', '90', '1', '1'), (57, '20', '90', '1', '1'), (57, '21', '83', '2', '2'), (57, '22', '90', '1', '1'), (57, '23', '80', '3', '2'), (57, '24', '90', '1', '1'), (57, '25', '90', '1', '1'), (57, '26', '90', '1', '1'), (57, '27', '90', '1', '1'), (57, '28', '90', '1', '1'), (57, '29', '92', '1', '1'), (57, '30', '90', '1', '1'), (57, '31', '81', '3', '2'), (57, '32', '75', '3', '2'), (57, '33', '90', '1', '1'), (57, '34', '77', '3', '2'), (57, '35', '78', '3', '2'), (57, '36', '75', '3', '2'), (57, '37', '66', '5', '3'), (57, '38', '75', '3', '2'), (57, '39', '81', '3', '2'), (57, '40', '85', '2', '2'), (57, '41', '63', '5', '3'), (57, '42', '75', '3', '2'), (57, '43', '90', '1', '1'), (57, '44', '95', '1', '1'), (57, '45', '79', '3', '2'), (57, '46', '80', '3', '2'), (57, '47', '60', '5', '3'), (57, '48', '90', '1', '1'), (57, '49', '78', '3', '2'), (57, '50', '62', '5', '3'), (57, '51', '65', '5', '3'), (57, '52', '79', '3', '2'), (57, '53', '78', '3', '2'), (57, '54', '96', '1', '1'), (57, '55', '85', '2', '2'), (57, '56', '82', '2', '2'), (57, '57', '90', '1', '1'), (57, '58', '90', '1', '1'), (57, '59', '90', '1', '1'), (57, '60', '90', '1', '1'); -- ('Вінтоняк В.М.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (58, '1', '67', '4', '3'), (58, '2', '81', '3', '2'), (58, '3', '81', '3', '2'), (58, '4', '60', '5', '3'), (58, '5', '92', '1', '1'), (58, '6', '81', '3', '2'), (58, '7', '84', '2', '2'), (58, '8', '91', '1', '1'), (58, '9', '81', '3', '2'), (58, '10', '90', '1', '1'), (58, '11', '70', '4', '3'), (58, '12', '93', '1', '1'), (58, '13', '90', '1', '1'), (58, '14', '88', '2', '2'), (58, '15', '82', '2', '2'), (58, '16', '72', '4', '3'), (58, '17', '90', '1', '1'), (58, '18', '91', '1', '1'), (58, '19', '75', '3', '2'), (58, '20', '90', '1', '1'), (58, '21', '90', '1', '1'), (58, '22', '80', '3', '2'), (58, '23', '78', '3', '2'), (58, '24', '75', '3', '2'), (58, '25', '92', '1', '1'), (58, '26', '84', '2', '2'), (58, '27', '90', '1', '1'), (58, '28', '90', '1', '1'), (58, '29', '90', '1', '1'), (58, '30', '75', '3', '2'), (58, '31', '77', '3', '2'), (58, '32', '75', '3', '2'), (58, '33', '80', '3', '2'), (58, '34', '78', '3', '2'), (58, '35', '85', '2', '2'), (58, '36', '75', '3', '2'), (58, '37', '90', '1', '1'), (58, '38', '91', '1', '1'), (58, '39', '84', '2', '2'), (58, '40', '80', '3', '2'), (58, '41', '90', '1', '1'), (58, '42', '94', '1', '1'), (58, '43', '85', '2', '2'), (58, '44', '74', '4', '3'), (58, '45', '82', '2', '2'), (58, '46', '75', '3', '2'), (58, '47', '60', '5', '3'), (58, '48', '85', '2', '2'), (58, '49', '72', '4', '3'), (58, '50', '62', '5', '3'), (58, '51', '61', '5', '3'), (58, '52', '75', '3', '2'), (58, '53', '84', '2', '2'), (58, '54', '82', '2', '2'), (58, '55', '93', '1', '1'), (58, '56', '75', '3', '2'), (58, '57', '78', '3', '2'), (58, '58', '90', '1', '1'), (58, '59', '90', '1', '1'), (58, '60', '91', '1', '1'); -- ('<NAME>.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (59, '1', '90', '1', '1'), (59, '2', '90', '1', '1'), (59, '3', '90', '1', '1'), (59, '4', '90', '1', '1'), (59, '5', '91', '1', '1'), (59, '6', '90', '1', '1'), (59, '7', '90', '1', '1'), (59, '8', '90', '1', '1'), (59, '9', '90', '1', '1'), (59, '10', '95', '1', '1'), (59, '11', '96', '1', '1'), (59, '12', '95', '1', '1'), (59, '13', '100', '1', '1'), (59, '14', '97', '1', '1'), (59, '15', '90', '1', '1'), (59, '16', '90', '1', '1'), (59, '17', '98', '1', '1'), (59, '18', '90', '1', '1'), (59, '19', '90', '1', '1'), (59, '20', '90', '1', '1'), (59, '21', '93', '1', '1'), (59, '22', '95', '1', '1'), (59, '23', '90', '1', '1'), (59, '24', '90', '1', '1'), (59, '25', '95', '1', '1'), (59, '26', '90', '1', '1'), (59, '27', '90', '1', '1'), (59, '28', '90', '1', '1'), (59, '29', '92', '1', '1'), (59, '30', '90', '1', '1'), (59, '31', '94', '1', '1'), (59, '32', '90', '1', '1'), (59, '33', '91', '1', '1'), (59, '34', '95', '1', '1'), (59, '35', '91', '1', '1'), (59, '36', '90', '1', '1'), (59, '37', '96', '1', '1'), (59, '38', '94', '1', '1'), (59, '39', '80', '3', '2'), (59, '40', '90', '1', '1'), (59, '41', '90', '1', '1'), (59, '42', '75', '3', '2'), (59, '43', '100', '1', '1'), (59, '44', '100', '1', '1'), (59, '45', '93', '1', '1'), (59, '46', '80', '3', '2'), (59, '47', '86', '2', '2'), (59, '48', '90', '1', '1'), (59, '49', '90', '1', '1'), (59, '50', '75', '3', '2'), (59, '51', '76', '4', '3'), (59, '52', '92', '1', '1'), (59, '53', '90', '1', '1'), (59, '54', '93', '1', '1'), (59, '55', '95', '1', '1'), (59, '56', '100', '1', '1'), (59, '57', '100', '1', '1'), (59, '58', '90', '1', '1'), (59, '59', '90', '1', '1'), (59, '60', '94', '1', '1'); -- ('<NAME>.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (60, '1', '90', '1', '1'), (60, '2', '98', '1', '1'), (60, '3', '98', '1', '1'), (60, '4', '94', '1', '1'), (60, '5', '97', '1', '1'), (60, '6', '95', '1', '1'), (60, '7', '90', '1', '1'), (60, '8', '95', '1', '1'), (60, '9', '79', '3', '2'), (60, '10', '99', '1', '1'), (60, '11', '98', '1', '1'), (60, '12', '93', '1', '1'), (60, '13', '90', '1', '1'), (60, '14', '97', '1', '1'), (60, '15', '90', '1', '1'), (60, '16', '94', '1', '1'), (60, '17', '100', '1', '1'), (60, '18', '98', '1', '1'), (60, '19', '90', '1', '1'), (60, '20', '91', '1', '1'), (60, '21', '96', '1', '1'), (60, '22', '93', '1', '1'), (60, '23', '97', '1', '1'), (60, '24', '90', '1', '1'), (60, '25', '91', '1', '1'), (60, '26', '93', '1', '1'), (60, '27', '92', '1', '1'), (60, '28', '95', '1', '1'), (60, '29', '93', '1', '1'), (60, '30', '90', '1', '1'), (60, '31', '99', '1', '1'), (60, '32', '90', '1', '1'), (60, '33', '97', '1', '1'), (60, '34', '99', '1', '1'), (60, '35', '94', '1', '1'), (60, '36', '90', '1', '1'), (60, '37', '97', '1', '1'), (60, '38', '90', '1', '1'), (60, '39', '90', '1', '1'), (60, '40', '90', '1', '1'), (60, '41', '93', '1', '1'), (60, '42', '90', '1', '1'), (60, '43', '95', '1', '1'), (60, '44', '95', '1', '1'), (60, '45', '91', '1', '1'), (60, '46', '90', '1', '1'), (60, '47', '92', '1', '1'), (60, '48', '90', '1', '1'), (60, '49', '90', '1', '1'), (60, '50', '95', '1', '1'), (60, '51', '96', '1', '1'), (60, '52', '92', '1', '1'), (60, '53', '92', '1', '1'), (60, '54', '93', '1', '1'), (60, '55', '95', '1', '1'), (60, '56', '100', '1', '1'), (60, '57', '95', '1', '1'), (60, '58', '90', '1', '1'), (60, '59', '95', '1', '1'), (60, '60', '95', '1', '1'); -- ('Граділь В.В.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (61, '1', '66', '5', '3'), (61, '2', '80', '3', '2'), (61, '3', '90', '1', '1'), (61, '4', '60', '5', '3'), (61, '5', '81', '3', '2'), (61, '6', '90', '1', '1'), (61, '7', '73', '4', '3'), (61, '8', '82', '2', '2'), (61, '9', '68', '4', '3'), (61, '10', '77', '3', '2'), (61, '11', '79', '3', '2'), (61, '12', '77', '3', '2'), (61, '13', '90', '1', '1'), (61, '14', '92', '1', '1'), (61, '15', '88', '2', '2'), (61, '16', '69', '4', '3'), (61, '17', '87', '2', '2'), (61, '18', '87', '2', '2'), (61, '19', '76', '3', '2'), (61, '20', '81', '3', '2'), (61, '21', '80', '3', '2'), (61, '22', '87', '2', '2'), (61, '23', '66', '5', '3'), (61, '24', '81', '3', '2'), (61, '25', '71', '4', '3'), (61, '26', '60', '5', '3'), (61, '27', '75', '3', '2'), (61, '28', '90', '1', '1'), (61, '29', '77', '3', '2'), (61, '30', '60', '5', '3'), (61, '31', '64', '5', '3'), (61, '32', '75', '3', '2'), (61, '33', '73', '4', '3'), (61, '34', '60', '5', '3'), (61, '35', '71', '4', '3'), (61, '36', '75', '3', '2'), (61, '37', '70', '4', '3'), (61, '38', '63', '5', '3'), (61, '39', '63', '5', '3'), (61, '40', '85', '2', '2'), (61, '41', '78', '3', '2'), (61, '42', '60', '5', '3'), (61, '43', '76', '3', '2'), (61, '44', '72', '4', '3'), (61, '45', '70', '4', '3'), (61, '46', '60', '5', '3'), (61, '47', '60', '5', '3'), (61, '48', '82', '2', '2'), (61, '49', '61', '5', '3'), (61, '50', '61', '5', '3'), (61, '51', '64', '5', '3'), (61, '52', '60', '5', '3'), (61, '53', '60', '5', '3'), (61, '54', '90', '1', '1'), (61, '55', '85', '2', '2'), (61, '56', '82', '2', '2'), (61, '57', '78', '3', '2'), (61, '58', '68', '4', '3'), (61, '59', '60', '5', '3'), (61, '60', '85', '2', '2'); -- ('<NAME>.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (63, '1', '75', '3', '2'), (63, '2', '84', '2', '2'), (63, '3', '75', '3', '2'), (63, '4', '64', '5', '3'), (63, '5', '84', '2', '2'), (63, '6', '75', '3', '2'), (63, '7', '64', '5', '3'), (63, '8', '89', '2', '2'), (63, '9', '69', '4', '3'), (63, '10', '75', '3', '2'), (63, '11', '60', '5', '3'), (63, '12', '85', '2', '2'), (63, '13', '76', '3', '2'), (63, '14', '77', '3', '2'), (63, '15', '74', '4', '3'), (63, '16', '61', '5', '3'), (63, '17', '75', '3', '2'), (63, '18', '83', '2', '2'), (63, '19', '75', '3', '2'), (63, '20', '73', '4', '3'), (63, '21', '90', '1', '1'), (63, '22', '90', '1', '1'), (63, '23', '75', '3', '2'), (63, '24', '61', '5', '3'), (63, '25', '78', '3', '2'), (63, '26', '81', '3', '2'), (63, '27', '85', '2', '2'), (63, '28', '90', '1', '1'), (63, '29', '90', '1', '1'), (63, '30', '90', '1', '1'), (63, '31', '72', '4', '3'), (63, '32', '75', '3', '2'), (63, '33', '90', '1', '1'), (63, '34', '90', '1', '1'), (63, '35', '63', '5', '3'), (63, '36', '60', '5', '3'), (63, '37', '61', '5', '3'), (63, '38', '60', '5', '3'), (63, '39', '60', '5', '3'), (63, '40', '65', '5', '3'), (63, '41', '85', '2', '2'), (63, '42', '60', '5', '3'), (63, '43', '63', '5', '3'), (63, '44', '63', '5', '3'), (63, '45', '69', '4', '3'), (63, '46', '60', '5', '3'), (63, '47', '60', '5', '3'), (63, '48', '71', '4', '3'), (63, '49', '60', '5', '3'), (63, '50', '60', '5', '3'), (63, '51', '60', '5', '3'), (63, '52', '60', '5', '3'), (63, '53', '60', '5', '3'), (63, '54', '82', '2', '2'), (63, '55', '75', '3', '2'), (63, '56', '70', '4', '3'), (63, '57', '60', '5', '3'), (63, '58', '75', '3', '2'), (63, '59', '75', '3', '2'), (63, '60', '84', '2', '2'); -- ('<NAME>.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (64, '1', '87', '2', '2'), (64, '2', '89', '2', '2'), (64, '3', '75', '3', '2'), (64, '4', '75', '3', '2'), (64, '5', '84', '2', '2'), (64, '6', '83', '2', '2'), (64, '7', '76', '3', '2'), (64, '8', '90', '1', '1'), (64, '9', '88', '2', '2'), (64, '10', '90', '1', '1'), (64, '11', '75', '3', '2'), (64, '12', '93', '1', '1'), (64, '13', '100', '1', '1'), (64, '14', '90', '1', '1'), (64, '15', '79', '3', '2'), (64, '16', '68', '4', '3'), (64, '17', '94', '1', '1'), (64, '18', '91', '1', '1'), (64, '19', '75', '3', '2'), (64, '20', '85', '2', '2'), (64, '21', '93', '1', '1'), (64, '22', '79', '3', '2'), (64, '23', '92', '1', '1'), (64, '24', '78', '3', '2'), (64, '25', '78', '3', '2'), (64, '26', '80', '3', '2'), (64, '28', '80', '3', '2'), (64, '28', '90', '1', '1'), (64, '29', '91', '1', '1'), (64, '30', '75', '3', '2'), (64, '31', '82', '2', '2'), (64, '32', '75', '3', '2'), (64, '33', '90', '1', '1'), (64, '34', '75', '3', '2'), (64, '35', '90', '1', '1'), (64, '36', '75', '3', '2'), (64, '37', '75', '3', '2'), (64, '38', '75', '3', '2'), (64, '39', '83', '2', '2'), (64, '40', '80', '3', '2'), (64, '41', '90', '1', '1'), (64, '42', '75', '3', '2'), (64, '43', '90', '1', '1'), (64, '44', '90', '1', '1'), (64, '45', '83', '2', '2'), (64, '46', '75', '3', '2'), (64, '47', '60', '5', '3'), (64, '48', '100', '1', '1'), (64, '49', '62', '5', '3'), (64, '50', '62', '5', '3'), (64, '51', '68', '4', '3'), (64, '52', '60', '5', '3'), (64, '53', '60', '5', '3'), (64, '54', '93', '1', '1'), (64, '55', '95', '1', '1'), (64, '56', '80', '3', '2'), (64, '57', '90', '1', '1'), (64, '58', '85', '2', '2'), (64, '59', '80', '3', '2'), (64, '60', '90', 1, 1); -- ('<NAME>.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (65, '1', '84', '2', '2'), (65, '2', '90', '1', '1'), (65, '3', '88', '2', '2'), (65, '4', '75', '3', '2'), (65, '5', '92', '1', '1'), (65, '6', '90', '1', '1'), (65, '7', '92', '1', '1'), (65, '8', '90', '1', '1'), (65, '9', '75', '3', '2'), (65, '10', '97', '1', '1'), (65, '11', '84', '2', '2'), (65, '12', '95', '1', '1'), (65, '13', '90', '1', '1'), (65, '14', '91', '1', '1'), (65, '15', '90', '1', '1'), (65, '16', '90', '1', '1'), (65, '17', '85', '2', '2'), (65, '18', '95', '1', '1'), (65, '19', '75', '3', '2'), (65, '20', '86', '2', '2'), (65, '21', '90', '1', '1'), (65, '22', '79', '3', '2'), (65, '23', '90', '1', '1'), (65, '24', '90', '1', '1'), (65, '25', '92', '1', '1'), (65, '26', '90', '1', '1'), (65, '27', '90', '1', '1'), (65, '28', '90', '1', '1'), (65, '29', '93', '1', '1'), (65, '30', '75', '3', '2'), (65, '31', '93', '1', '1'), (65, '32', '90', '1', '1'), (65, '33', '90', '1', '1'), (65, '34', '75', '3', '2'), (65, '35', '90', '1', '1'), (65, '36', '75', '3', '2'), (65, '37', '94', '1', '1'), (65, '38', '90', '1', '1'), (65, '39', '85', '2', '2'), (65, '40', '90', '1', '1'), (65, '41', '90', '1', '1'), (65, '42', '85', '2', '2'), (65, '43', '81', '3', '2'), (65, '44', '81', '3', '2'), (65, '45', '90', '1', '1'), (65, '46', '90', '1', '1'), (65, '47', '78', '3', '2'), (65, '48', '95', '1', '1'), (65, '49', '90', '1', '1'), (65, '50', '91', '1', '1'), (65, '51', '90', '1', '1'), (65, '52', '90', '1', '1'), (65, '53', '90', '1', '1'), (65, '54', '95', '1', '1'), (65, '55', '80', '3', '2'), (65, '56', '90', '1', '1'), (65, '57', '85', '2', '2'), (65, '58', '90', '1', '1'), (65, '59', '90', '1', '1'), (65, '60', '92', '1', '1'); -- ('Д<NAME>.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (66, '1', '68', '4', '3'), (66, '2', '91', '1', '1'), (66, '3', '90', '2', '2'), (66, '4', '90', '3', '2'), (66, '5', '78', '3', '2'), (66, '6', '90', '1', '1'), (66, '7', '83', '2', '2'), (66, '8', '96', '1', '1'), (66, '9', '90', '2', '2'), (66, '10', '75', '3', '2'), (66, '11', '91', '1', '1'), (66, '12', '95', '1', '1'), (66, '13', '75', '3', '2'), (66, '14', '99', '1', '1'), (66, '15', '90', '1', '1'), (66, '16', '61', '5', '3'), (66, '17', '97', '1', '1'), (66, '18', '90', '2', '2'), (66, '19', '81', '3', '2'), (66, '20', '86', '2', '2'), (66, '21', '82', '2', '2'), (66, '22', '91', '1', '1'), (66, '23', '94', '1', '1'), (66, '24', '90', '1', '1'), (66, '25', '90', '2', '2'), (66, '26', '90', '1', '1'), (66, '27', '90', '1', '1'), (66, '28', '90', '1', '1'), (66, '29', '94', '1', '1'), (66, '30', '90', '1', '1'), (66, '31', '96', '1', '1'), (66, '32', '75', '3', '2'), (66, '33', '90', '1', '1'), (66, '34', '78', '3', '2'), (66, '35', '90', '1', '1'), (66, '36', '90', '1', '1'), (66, '37', '94', '1', '1'), (66, '38', '90', '1', '1'), (66, '39', '90', '1', '1'), (66, '40', '90', '1', '1'), (66, '41', '90', '1', '1'), (66, '42', '75', '3', '2'), (66, '43', '95', '1', '1'), (66, '44', '95', '1', '1'), (66, '45', '75', '3', '2'), (66, '46', '90', '1', '1'), (66, '47', '60', '5', '3'), (66, '48', '90', '1', '1'), (66, '49', '76', '3', '2'), (66, '50', '75', '5', '3'), (66, '51', '62', '5', '3'), (66, '52', '92', '1', '1'), (66, '53', '84', '2', '2'), (66, '54', '94', '1', '1'), (66, '55', '95', '1', '1'), (66, '56', '90', '1', '1'), (66, '57', '95', '1', '1'), (66, '58', '90', '1', '1'), (66, '59', '90', '1', '1'), (66, '60', '97', '1', '1'); -- ('Дівнич І.І.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (67, '1', '71', '4', '3'), (67, '2', '83', '2', '2'), (67, '3', '83', '2', '2'), (67, '4', '76', '3', '2'), (67, '5', '92', '1', '1'), (67, '6', '90', '1', '1'), (67, '7', '79', '3', '2'), (67, '8', '91', '1', '1'), (67, '9', '66', '5', '3'), (67, '10', '78', '3', '2'), (67, '11', '78', '3', '2'), (67, '12', '65', '5', '3'), (67, '13', '85', '2', '2'), (67, '14', '71', '4', '3'), (67, '15', '79', '3', '2'), (67, '16', '67', '4', '3'), (67, '17', '75', '3', '2'), (67, '18', '82', '2', '2'), (67, '19', '71', '4', '3'), (67, '20', '84', '2', '2'), (67, '21', '81', '3', '2'), (67, '22', '84', '2', '2'), (67, '23', '75', '3', '2'), (67, '24', '74', '4', '3'), (67, '25', '60', '5', '3'), (67, '26', '75', '3', '2'), (67, '27', '75', '3', '2'), (67, '28', '75', '3', '2'), (67, '29', '71', '4', '3'), (67, '30', '75', '3', '2'), (67, '31', '71', '4', '3'), (67, '32', '60', '5', '3'), (67, '33', '82', '2', '2'), (67, '34', '60', '5', '3'), (67, '35', '63', '5', '3'), (67, '36', '75', '3', '2'), (67, '37', '75', '3', '2'), (67, '38', '75', '3', '2'), (67, '39', '82', '2', '2'), (67, '40', '85', '2', '2'), (67, '41', '75', '3', '2'), (67, '42', '75', '3', '2'), (67, '43', '67', '4', '3'), (67, '44', '63', '5', '3'), (67, '45', '63', '5', '3'), (67, '46', '75', '3', '2'), (67, '47', '60', '5', '3'), (67, '48', '60', '5', '3'), (67, '49', '62', '5', '3'), (67, '50', '60', '5', '3'), (67, '51', '60', '5', '3'), (67, '52', '60', '5', '3'), (67, '53', '60', '5', '3'), (67, '54', '75', '3', '2'), (67, '55', '75', '3', '2'), (67, '56', '75', '3', '2'), (67, '57', '60', '5', '3'), (67, '58', '80', '3', '2'), (67, '59', '63', '5', '3'), (67, '60', '76', '3', '2'); -- ('<NAME>.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (68, '1', '76', '3', '2'), (68, '2', '90', '1', '1'), (68, '3', '95', '1', '1'), (68, '4', '77', '3', '2'), (68, '5', '91', '1', '1'), (68, '6', '93', '1', '1'), (68, '7', '95', '1', '1'), (68, '8', '90', '1', '1'), (68, '9', '93', '1', '1'), (68, '10', '92', '1', '1'), (68, '11', '92', '1', '1'), (68, '12', '94', '1', '1'), (68, '13', '78', '3', '2'), (68, '14', '93', '1', '1'), (68, '15', '90', '1', '1'), (68, '16', '62', '5', '3'), (68, '17', '84', '2', '2'), (68, '18', '91', '1', '1'), (68, '19', '90', '1', '1'), (68, '20', '90', '1', '1'), (68, '21', '90', '1', '1'), (68, '22', '90', '1', '1'), (68, '23', '72', '4', '3'), (68, '24', '90', '1', '1'), (68, '25', '75', '3', '2'), (68, '26', '80', '3', '2'), (68, '27', '75', '3', '2'), (68, '28', '90', '1', '1'), (68, '29', '91', '1', '1'), (68, '30', '75', '3', '2'), (68, '31', '84', '2', '2'), (68, '32', '90', '1', '1'), (68, '33', '92', '1', '1'), (68, '34', '92', '1', '1'), (68, '35', '90', '1', '1'), (68, '36', '75', '3', '2'), (68, '37', '90', '1', '1'), (68, '38', '90', '1', '1'), (68, '39', '90', '1', '1'), (68, '40', '90', '1', '1'), (68, '41', '94', '1', '1'), (68, '42', '60', '5', '3'), (68, '43', '76', '3', '2'), (68, '44', '81', '3', '2'), (68, '45', '75', '3', '2'), (68, '46', '75', '3', '2'), (68, '47', '60', '5', '3'), (68, '48', '90', '1', '1'), (68, '49', '72', '4', '3'), (68, '50', '60', '5', '3'), (68, '51', '60', '5', '3'), (68, '52', '98', '1', '1'), (68, '53', '84', '2', '2'), (68, '54', '96', '1', '1'), (68, '55', '85', '2', '2'), (68, '56', '82', '2', '2'), (68, '57', '80', '3', '2'), (68, '58', '90', '1', '1'), (68, '59', '90', '1', '1'), (68, '60', '85', '2', '2'); -- ('<NAME>.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (69, '1', '74', '4', '3'), (69, '2', '92', '1', '1'), (69, '3', '71', '4', '3'), (69, '4', '75', '3', '2'), (69, '5', '93', '1', '1'), (69, '6', '94', '1', '1'), (69, '7', '82', '2', '2'), (69, '8', '82', '2', '2'), (69, '9', '70', '4', '3'), (69, '10', '64', '5', '3'), (69, '11', '77', '3', '2'), (69, '12', '81', '3', '2'), (69, '13', '100', '1', '1'), (69, '14', '72', '4', '3'), (69, '15', '90', '1', '1'), (69, '16', '94', '1', '1'), (69, '17', '84', '2', '2'), (69, '18', '90', '1', '1'), (69, '19', '71', '4', '3'), (69, '20', '90', '1', '1'), (69, '21', '90', '1', '1'), (69, '22', '80', '3', '2'), (69, '23', '81', '3', '2'), (69, '24', '63', '5', '3'), (69, '25', '78', '3', '2'), (69, '26', '90', '1', '1'), (69, '27', '86', '2', '2'), (69, '28', '90', '1', '1'), (69, '29', '91', '1', '1'), (69, '30', '90', '1', '1'), (69, '31', '86', '2', '2'), (69, '32', '66', '5', '3'), (69, '33', '75', '3', '2'), (69, '34', '75', '3', '2'), (69, '35', '90', '1', '1'), (69, '36', '75', '3', '2'), (69, '37', '75', '3', '2'), (69, '38', '95', '1', '1'), (69, '39', '84', '2', '2'), (69, '40', '90', '1', '1'), (69, '41', '90', '1', '1'), (69, '42', '75', '3', '2'), (69, '43', '76', '3', '2'), (69, '44', '76', '3', '2'), (69, '45', '80', '3', '2'), (69, '46', '80', '3', '2'), (69, '47', '92', '1', '1'), (69, '48', '90', '1', '1'), (69, '49', '83', '2', '2'), (69, '50', '64', '5', '3'), (69, '51', '75', '3', '2'), (69, '52', '90', '1', '1'), (69, '53', '90', '1', '1'), (69, '54', '77', '3', '2'), (69, '55', '95', '1', '1'), (69, '56', '85', '2', '2'), (69, '57', '80', '3', '2'), (69, '58', '90', '1', '1'), (69, '59', '90', '1', '1'), (69, '60', '91', '1', '1'); -- ('<NAME>.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (70, '1', '60', '5', '3'), (70, '2', '69', '4', '3'), (70, '3', '68', '4', '3'), (70, '4', '75', '3', '2'), (70, '5', '76', '3', '2'), (70, '6', '65', '5', '3'), (70, '7', '66', '5', '3'), (70, '8', '64', '5', '3'), (70, '9', '61', '5', '3'), (70, '10', '70', '4', '3'), (70, '11', '60', '5', '3'), (70, '12', '67', '4', '3'), (70, '13', '90', '1', '1'), (70, '14', '77', '3', '2'), (70, '15', '64', '5', '3'), (70, '16', '70', '4', '3'), (70, '17', '62', '5', '3'), (70, '18', '76', '3', '2'), (70, '19', '75', '3', '2'), (70, '20', '68', '4', '3'), (70, '21', '78', '3', '2'), (70, '22', '75', '3', '2'), (70, '23', '75', '3', '2'), (70, '24', '64', '5', '3'), (70, '25', '80', '3', '2'), (70, '26', '72', '4', '3'), (70, '27', '85', '2', '2'), (70, '28', '83', '2', '2'), (70, '29', '95', '1', '1'), (70, '30', '60', '5', '3'), (70, '31', '82', '2', '2'), (70, '32', '60', '5', '3'), (70, '33', '75', '3', '2'), (70, '34', '60', '5', '3'), (70, '35', '69', '4', '3'), (70, '36', '60', '5', '3'), (70, '37', '69', '4', '3'), (70, '38', '68', '4', '3'), (70, '39', '71', '4', '3'), (70, '40', '80', '3', '2'), (70, '41', '85', '2', '2'), (70, '42', '60', '5', '3'), (70, '43', '73', '4', '3'), (70, '44', '63', '5', '3'), (70, '45', '77', '3', '2'), (70, '46', '65', '5', '3'), (70, '47', '60', '5', '3'), (70, '48', '90', '1', '1'), (70, '49', '84', '2', '2'), (70, '50', '62', '5', '3'), (70, '51', '60', '5', '3'), (70, '52', '75', '3', '2'), (70, '53', '68', '4', '3'), (70, '54', '68', '4', '3'), (70, '55', '60', '5', '3'), (70, '56', '80', '3', '2'), (70, '57', '60', '5', '3'), (70, '58', '80', '3', '2'), (70, '59', '80', '3', '2'), (70, '60', '90', '1', '1'); -- ('Космірак Р.Т.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (71, '1', '75', '3', '2'), (71, '2', '85', '2', '2'), (71, '3', '100', '1', '1'), (71, '4', '90', '1', '1'), (71, '5', '100', '1', '1'), (71, '6', '91', '1', '1'), (71, '7', '72', '4', '3'), (71, '8', '90', '1', '1'), (71, '9', '82', '2', '2'), (71, '10', '96', '1', '1'), (71, '11', '90', '1', '1'), (71, '12', '92', '1', '1'), (71, '13', '100', '1', '1'), (71, '14', '93', '1', '1'), (71, '15', '90', '1', '1'), (71, '16', '93', '1', '1'), (71, '17', '99', '1', '1'), (71, '18', '92', '1', '1'), (71, '19', '90', '1', '1'), (71, '20', '94', '1', '1'), (71, '21', '90', '1', '1'), (71, '22', '91', '1', '1'), (71, '23', '90', '1', '1'), (71, '24', '90', '1', '1'), (71, '25', '86', '2', '2'), (71, '26', '70', '4', '3'), (71, '27', '90', '1', '1'), (71, '28', '90', '1', '1'), (71, '29', '92', '1', '1'), (71, '30', '90', '1', '1'), (71, '31', '76', '3', '2'), (71, '32', '90', '1', '1'), (71, '33', '75', '3', '2'), (71, '34', '90', '1', '1'), (71, '35', '78', '3', '2'), (71, '36', '85', '2', '2'), (71, '37', '64', '5', '3'), (71, '38', '60', '5', '3'), (71, '39', '70', '4', '3'), (71, '40', '90', '1', '1'), (71, '41', '90', '1', '1'), (71, '42', '60', '5', '3'), (71, '43', '90', '1', '1'), (71, '44', '90', '1', '1'), (71, '45', '75', '3', '2'), (71, '46', '95', '1', '1'), (71, '47', '78', '3', '2'), (71, '48', '90', '1', '1'), (71, '49', '63', '5', '3'), (71, '50', '61', '5', '3'), (71, '51', '62', '5', '3'), (71, '52', '60', '5', '3'), (71, '53', '60', '5', '3'), (71, '54', '95', '1', '1'), (71, '55', '93', '1', '1'), (71, '56', '85', '2', '2'), (71, '57', '90', '1', '1'), (71, '58', '90', '1', '1'), (71, '59', '90', '1', '1'), (71, '60', '91', '1', '1'); -- ('Кравців К.І.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (72, '1', '67', '4', '3'), (72, '2', '90', '1', '1'), (72, '3', '90', '1', '1'), (72, '4', '60', '5', '3'), (72, '5', '90', '1', '1'), (72, '6', '90', '1', '1'), (72, '7', '77', '3', '2'), (72, '8', '91', '1', '1'), (72, '9', '91', '1', '1'), (72, '10', '92', '1', '1'), (72, '11', '90', '1', '1'), (72, '12', '97', '1', '1'), (72, '13', '60', '5', '3'), (72, '14', '92', '1', '1'), (72, '15', '94', '1', '1'), (72, '16', '90', '1', '1'), (72, '17', '90', '1', '1'), (72, '18', '90', '1', '1'), (72, '19', '90', '1', '1'), (72, '20', '90', '1', '1'), (72, '21', '90', '1', '1'), (72, '22', '90', '1', '1'), (72, '23', '90', '1', '1'), (72, '24', '90', '1', '1'), (72, '25', '93', '1', '1'), (72, '26', '82', '2', '2'), (72, '27', '90', '1', '1'), (72, '28', '90', '1', '1'), (72, '29', '90', '1', '1'), (72, '30', '90', '1', '1'), (72, '31', '90', '1', '1'), (72, '32', '90', '1', '1'), (72, '33', '90', '1', '1'), (72, '34', '80', '3', '2'), (72, '35', '90', '1', '1'), (72, '36', '90', '1', '1'), (72, '37', '94', '1', '1'), (72, '38', '97', '1', '1'), (72, '39', '90', '1', '1'), (72, '40', '90', '1', '1'), (72, '41', '92', '1', '1'), (72, '42', '90', '1', '1'), (72, '43', '90', '1', '1'), (72, '44', '90', '1', '1'), (72, '45', '90', '1', '1'), (72, '46', '90', '1', '1'), (72, '47', '93', '1', '1'), (72, '48', '95', '1', '1'), (72, '49', '90', '1', '1'), (72, '50', '90', '1', '1'), (72, '51', '90', '1', '1'), (72, '52', '80', '3', '2'), (72, '53', '82', '2', '2'), (72, '54', '95', '1', '1'), (72, '55', '95', '1', '1'), (72, '56', '85', '2', '2'), (72, '57', '90', '1', '1'), (72, '58', '90', '1', '1'), (72, '59', '90', '1', '1'), (72, '60', '90', '1', '1'); -- ('<NAME>. Вигнали',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (73, '1', '60', '5', '3'), (73, '2', '84', '2', '2'), (73, '3', '94', '1', '1'), (73, '4', '62', '5', '3'), (73, '5', '76', '3', '2'), (73, '6', '68', '4', '3'), (73, '7', '73', '4', '3'), (73, '8', '67', '4', '3'), (73, '9', '74', '4', '3'), (73, '10', '76', '3', '2'), (73, '11', '60', '5', '3'), (73, '12', '63', '5', '3'), (73, '13', '60', '5', '3'), (73, '14', '74', '4', '3'), (73, '15', '67', '4', '3'), (73, '16', '70', '4', '3'), (73, '17', '75', '3', '2'), (73, '18', '83', '2', '2'), (73, '19', '90', '1', '1'), (73, '20', '63', '5', '3'), (73, '21', '74', '4', '3'), (73, '22', '81', '3', '2'), (73, '23', '71', '4', '3'), (73, '24', '63', '5', '3'), (73, '25', '60', '5', '3'), (73, '26', '62', '5', '3'), (73, '27', '75', '3', '2'), (73, '28', '63', '5', '3'), (73, '29', '63', '5', '3'), (73, '30', '60', '5', '3'), (73, '31', '63', '5', '3'), (73, '32', '61', '5', '3'), (73, '33', '68', '4', '3'), (73, '34', '60', '5', '3'), (73, '35', '60', '5', '3'), (73, '36', '60', '5', '3'), (73, '37', '60', '5', '3'), (73, '38', '60', '5', '3'), (73, '39', '62', '5', '3'), (73, '40', '60', '5', '3'), (73, '41', '62', '5', '3'), (73, '42', 0, '5', 0), (73, '43', 0, '5', 0), (73, '44', 0, '5', 0), (73, '45', 0, '5', 0), (73, '46', 0, '5', 0), (73, '47', 0, '5', 0), (73, '48', 0, '5', 0), (73, '49', 0, '5', 0), (73, '50', 0, '5', 0), (73, '51', 0, '5', 0), (73, '52', 0, '5', 0), (73, '53', 0, '5', 0), (73, '54', '76', '3', '2'), (73, '55', '75', '3', '2'), (73, '56', '60', '5', '3'), (73, '57', 0, '5', 0), (73, '58', 0, '5', 0), (73, '59', 0, '5', 0), (73, '60', 0, '5', 0); -- ('Овчарук С.Р.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (74, '1', '87', '2', '2'), (74, '2', '90', '1', '1'), (74, '3', '95', '1', '1'), (74, '4', '90', '5', '3'), (74, '5', '94', '1', '1'), (74, '6', '78', '3', '2'), (74, '7', '90', '1', '1'), (74, '8', '94', '1', '1'), (74, '9', '91', '1', '1'), (74, '10', '96', '1', '1'), (74, '11', '90', '1', '1'), (74, '12', '93', '1', '1'), (74, '13', '90', '1', '1'), (74, '14', '93', '1', '1'), (74, '15', '90', '1', '1'), (74, '16', '98', '1', '1'), (74, '17', '95', '1', '1'), (74, '18', '91', '1', '1'), (74, '19', '90', '1', '1'), (74, '20', '91', '1', '1'), (74, '21', '92', '1', '1'), (74, '22', '91', '1', '1'), (74, '23', '94', '1', '1'), (74, '24', '90', '1', '1'), (74, '25', '93', '1', '1'), (74, '26', '90', '1', '1'), (74, '27', '90', '1', '1'), (74, '28', '90', '1', '1'), (74, '29', '90', '1', '1'), (74, '30', '90', '1', '1'), (74, '31', '91', '1', '1'), (74, '32', '90', '1', '1'), (74, '33', '90', '1', '1'), (74, '34', '90', '1', '1'), (74, '35', '92', '1', '1'), (74, '36', '90', '1', '1'), (74, '37', '95', '1', '1'), (74, '38', '96', '1', '1'), (74, '39', '90', '1', '1'), (74, '40', '90', '1', '1'), (74, '41', '90', '1', '1'), (74, '42', '90', '1', '1'), (74, '43', '100', '1', '1'), (74, '44', '100', '1', '1'), (74, '45', '93', '1', '1'), (74, '46', '90', '1', '1'), (74, '47', '92', '1', '1'), (74, '48', '90', '1', '1'), (74, '49', '94', '1', '1'), (74, '50', '75', '3', '2'), (74, '51', '90', '1', '1'), (74, '52', '90', '1', '1'), (74, '53', '92', '1', '1'), (74, '54', '93', '1', '1'), (74, '55', '95', '1', '1'), (74, '56', '95', '1', '1'), (74, '57', '100', '1', '1'), (74, '58', '90', '1', '1'), (74, '59', '95', '1', '1'), (74, '60', '93', '1', '1'); -- ('<NAME>.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (75, '1', '66', '5', '3'), (75, '2', '90', '1', '1'), (75, '3', '88', '2', '2'), (75, '4', '60', '5', '3'), (75, '5', '83', '2', '2'), (75, '6', '90', '1', '1'), (75, '7', '83', '2', '2'), (75, '8', '85', '2', '2'), (75, '9', '88', '2', '2'), (75, '10', '90', '1', '1'), (75, '11', '90', '1', '1'), (75, '12', '93', '1', '1'), (75, '13', '90', '1', '1'), (75, '14', '90', '1', '1'), (75, '15', '90', '1', '1'), (75, '16', '60', '5', '3'), (75, '17', '77', '3', '2'), (75, '18', '90', '1', '1'), (75, '19', '90', '1', '1'), (75, '20', '84', '2', '2'), (75, '21', '90', '1', '1'), (75, '22', '91', '1', '1'), (75, '23', '77', '3', '2'), (75, '24', '90', '1', '1'), (75, '25', '89', '2', '2'), (75, '26', '69', '4', '3'), (75, '27', '90', '1', '1'), (75, '28', '90', '1', '1'), (75, '29', '90', '1', '1'), (75, '30', '90', '1', '1'), (75, '31', '94', '1', '1'), (75, '32', '78', '3', '2'), (75, '33', '90', '1', '1'), (75, '34', '77', '3', '2'), (75, '35', '90', '1', '1'), (75, '36', '75', '3', '2'), (75, '37', '90', '1', '1'), (75, '38', '76', '3', '2'), (75, '39', '80', '3', '2'), (75, '40', '85', '2', '2'), (75, '41', '85', '2', '2'), (75, '42', '75', '3', '2'), (75, '43', '90', '1', '1'), (75, '44', '90', '1', '1'), (75, '45', '82', '2', '2'), (75, '46', '80', '3', '2'), (75, '47', '77', '3', '2'), (75, '48', '92', '1', '1'), (75, '49', '80', '3', '2'), (75, '50', '75', '3', '2'), (75, '51', '60', '5', '3'), (75, '52', '90', '1', '1'), (75, '53', '75', '3', '2'), (75, '54', '91', '1', '1'), (75, '55', '90', '1', '1'), (75, '56', '75', '3', '2'), (75, '57', '90', '1', '1'), (75, '58', '90', '1', '1'), (75, '59', '90', '1', '1'), (75, '60', '91', '1', '1'); -- ('Рєзнік Д.В.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (76, '1', '75', '3', '2'), (76, '2', '79', '3', '2'), (76, '3', '84', '2', '2'), (76, '4', '94', '1', '1'), (76, '5', '92', '1', '1'), (76, '6', '93', '1', '1'), (76, '7', '77', '3', '2'), (76, '8', '90', '1', '1'), (76, '9', '64', '5', '3'), (76, '10', '82', '2', '2'), (76, '11', '100', '1', '1'), (76, '12', '90', '1', '1'), (76, '13', '96', '1', '1'), (76, '14', '98', '1', '1'), (76, '15', '90', '1', '1'), (76, '16', '90', '1', '1'), (76, '17', '88', '2', '2'), (76, '18', '91', '1', '1'), (76, '19', '80', '3', '2'), (76, '20', '90', '1', '1'), (76, '21', '74', '4', '3'), (76, '22', '90', '1', '1'), (76, '23', '96', '1', '1'), (76, '24', '90', '1', '1'), (76, '25', '77', '3', '2'), (76, '26', '65', '5', '3'), (76, '27', '90', '1', '1'), (76, '28', '90', '1', '1'), (76, '29', '90', '1', '1'), (76, '30', '90', '1', '1'), (76, '31', '92', '1', '1'), (76, '32', '75', '3', '2'), (76, '33', '95', '1', '1'), (76, '34', '90', '1', '1'), (76, '35', '90', '1', '1'), (76, '36', '80', '3', '2'), (76, '37', '67', '4', '3'), (76, '38', '98', '1', '1'), (76, '39', '82', '2', '2'), (76, '40', '85', '2', '2'), (76, '41', '70', '4', '3'), (76, '42', '85', '2', '2'), (76, '43', '90', '1', '1'), (76, '44', '90', '1', '1'), (76, '45', '60', '5', '3'), (76, '46', '92', '1', '1'), (76, '47', '60', '5', '3'), (76, '48', '90', '1', '1'), (76, '49', '61', '5', '3'), (76, '50', '90', '1', '1'), (76, '51', '60', '5', '3'), (76, '52', '82', '2', '2'), (76, '53', '82', '2', '2'), (76, '54', '98', '1', '1'), (76, '55', '95', '1', '1'), (76, '56', '75', '3', '2'), (76, '57', '90', '1', '1'), (76, '58', '80', '3', '2'), (76, '59', '90', '1', '1'), (76, '60', '90', '1', '1'); -- ('Рубашний М.М.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (78, '1', '73', '4', '3'), (78, '2', '93', '1', '1'), (78, '3', '83', '2', '2'), (78, '4', '65', '5', '3'), (78, '5', '90', '1', '1'), (78, '6', '75', '3', '2'), (78, '7', '79', '3', '2'), (78, '8', '90', '1', '1'), (78, '9', '78', '3', '2'), (78, '10', '93', '1', '1'), (78, '11', '82', '2', '2'), (78, '12', '93', '1', '1'), (78, '13', '100', '1', '1'), (78, '14', '90', '1', '1'), (78, '15', '90', '1', '1'), (78, '16', '75', '3', '2'), (78, '17', '83', '2', '2'), (78, '18', '94', '1', '1'), (78, '19', '80', '3', '2'), (78, '20', '86', '2', '2'), (78, '21', '90', '1', '1'), (78, '22', '91', '1', '1'), (78, '23', '80', '3', '2'), (78, '24', '90', '1', '1'), (78, '25', '86', '2', '2'), (78, '26', '90', '1', '1'), (78, '27', '90', '1', '1'), (78, '28', '90', '1', '1'), (78, '29', '90', '1', '1'), (78, '30', '90', '1', '1'), (78, '31', '90', '1', '1'), (78, '32', '90', '1', '1'), (78, '33', '90', '1', '1'), (78, '34', '77', '3', '2'), (78, '35', '93', '1', '1'), (78, '36', '92', '1', '1'), (78, '37', '90', '1', '1'), (78, '38', '98', '1', '1'), (78, '39', '90', '1', '1'), (78, '40', '90', '1', '1'), (78, '41', '93', '1', '1'), (78, '42', '75', '3', '2'), (78, '43', '90', '1', '1'), (78, '44', '90', '1', '1'), (78, '45', '81', '3', '2'), (78, '46', '80', '3', '2'), (78, '47', '92', '1', '1'), (78, '48', '90', '1', '1'), (78, '49', '90', '1', '1'), (78, '50', '75', '3', '2'), (78, '51', '75', '3', '2'), (78, '52', '84', '2', '2'), (78, '53', '90', '1', '1'), (78, '54', '95', '1', '1'), (78, '55', '75', '3', '2'), (78, '56', '80', '3', '2'), (78, '57', '60', '5', '3'), (78, '58', '90', '1', '1'), (78, '59', '90', '1', '1'), (78, '60', '91', '1', '1'); -- ('<NAME>.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (79, '1', '60', '5', '3'), (79, '2', '69', '4', '3'), (79, '3', '85', '2', '2'), (79, '4', '61', '5', '3'), (79, '5', '79', '3', '2'), (79, '6', '90', '1', '1'), (79, '7', '76', '3', '2'), (79, '8', '60', '5', '3'), (79, '9', '67', '4', '3'), (79, '10', '61', '5', '3'), (79, '11', '90', '1', '1'), (79, '12', '83', '2', '2'), (79, '13', '90', '1', '1'), (79, '14', '75', '3', '2'), (79, '15', '65', '5', '3'), (79, '16', '61', '5', '3'), (79, '17', '75', '3', '2'), (79, '18', '80', '3', '2'), (79, '19', '75', '3', '2'), (79, '20', '70', '4', '3'), (79, '21', '87', '2', '2'), (79, '22', '92', '1', '1'), (79, '23', '90', '1', '1'), (79, '24', '71', '4', '3'), (79, '25', '82', '2', '2'), (79, '26', '60', '5', '3'), (79, '27', '75', '3', '2'), (79, '28', '85', '2', '2'), (79, '29', '79', '3', '2'), (79, '30', '75', '3', '2'), (79, '31', '80', '3', '2'), (79, '32', '76', '3', '2'), (79, '33', '90', '1', '1'), (79, '34', '75', '3', '2'), (79, '35', '72', '4', '3'), (79, '36', '75', '3', '2'), (79, '37', '62', '5', '3'), (79, '38', '75', '3', '2'), (79, '39', '80', '3', '2'), (79, '40', '80', '3', '2'), (79, '41', '78', '3', '2'), (79, '42', '60', '5', '3'), (79, '43', '66', '5', '3'), (79, '44', '63', '5', '3'), (79, '45', '60', '5', '3'), (79, '46', '60', '5', '3'), (79, '47', '60', '5', '3'), (79, '48', '71', '4', '3'), (79, '49', '60', '5', '3'), (79, '50', '60', '5', '3'), (79, '51', '62', '5', '3'), (79, '52', '62', '5', '3'), (79, '53', '60', '5', '3'), (79, '54', '91', '1', '1'), (79, '55', '75', '3', '2'), (79, '56', '80', '3', '2'), (79, '57', '60', '5', '3'), (79, '58', '65', '5', '3'), (79, '59', '60', '5', '3'), (79, '60', '81', '3', '2'); -- ('<NAME>.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (82, '1', '78', '3', '2'), (82, '2', '94', '1', '1'), (82, '3', '90', '1', '1'), (82, '4', '92', '1', '1'), (82, '5', '96', '1', '1'), (82, '6', '95', '1', '1'), (82, '7', '95', '1', '1'), (82, '8', '92', '1', '1'), (82, '9', '91', '1', '1'), (82, '10', '93', '1', '1'), (82, '11', '90', '1', '1'), (82, '12', '92', '1', '1'), (82, '13', '92', '1', '1'), (82, '14', '90', '1', '1'), (82, '15', '90', '1', '1'), (82, '16', '97', '1', '1'), (82, '17', '100', '1', '1'), (82, '18', '92', '1', '1'), (82, '19', '92', '1', '1'), (82, '20', '94', '1', '1'), (82, '21', '90', '1', '1'), (82, '22', '90', '1', '1'), (82, '23', '90', '1', '1'), (82, '24', '90', '1', '1'), (82, '25', '80', '3', '2'), (82, '26', '82', '2', '2'), (82, '27', '90', '1', '1'), (82, '28', '90', '1', '1'), (82, '29', '90', '1', '1'), (82, '30', '90', '1', '1'), (82, '31', '78', '3', '2'), (82, '32', '90', '1', '1'), (82, '33', '92', '1', '1'), (82, '34', '77', '3', '2'), (82, '35', '84', '2', '2'), (82, '36', '75', '3', '2'), (82, '37', '77', '3', '2'), (82, '38', '75', '3', '2'), (82, '39', '80', '3', '2'), (82, '40', '78', '3', '2'), (82, '41', '62', '5', '3'), (82, '42', '75', '3', '2'), (82, '43', '91', '1', '1'), (82, '44', '90', '1', '1'), (82, '45', '78', '3', '2'), (82, '46', '80', '3', '2'), (82, '47', '60', '5', '3'), (82, '48', '90', '1', '1'), (82, '49', '75', '3', '2'), (82, '50', '63', '5', '3'), (82, '51', '60', '5', '3'), (82, '52', '75', '3', '2'), (82, '53', '75', '3', '2'), (82, '54', '95', '1', '1'), (82, '55', '95', '1', '1'), (82, '56', '82', '2', '2'), (82, '57', '90', '1', '1'), (82, '58', '90', '1', '1'), (82, '59', '90', '1', '1'), (82, '60', '90', '1', '1'); -- ('<NAME>.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (83, '1', '60', '5', '3'), (83, '2', '71', '4', '3'), (83, '3', '99', '1', '1'), (83, '4', '60', '5', '3'), (83, '5', '90', '1', '1'), (83, '6', '61', '5', '3'), (83, '7', '76', '3', '2'), (83, '8', '69', '4', '3'), (83, '9', '77', '3', '2'), (83, '10', '62', '5', '3'), (83, '11', '90', '1', '1'), (83, '12', '91', '1', '1'), (83, '13', '92', '1', '1'), (83, '14', '90', '1', '1'), (83, '15', '68', '4', '3'), (83, '16', '60', '5', '3'), (83, '17', '75', '3', '2'), (83, '18', '76', '3', '2'), (83, '19', '79', '3', '2'), (83, '20', '78', '3', '2'), (83, '21', '84', '2', '2'), (83, '22', '90', '1', '1'), (83, '23', '75', '3', '2'), (83, '24', '62', '5', '3'), (83, '25', '84', '2', '2'), (83, '26', '66', '5', '3'), (83, '27', '75', '3', '2'), (83, '28', '75', '3', '2'), (83, '29', '69', '4', '3'), (83, '30', '60', '5', '3'), (83, '31', '78', '3', '2'), (83, '32', '71', '4', '3'), (83, '33', '75', '3', '2'), (83, '34', '71', '4', '3'), (83, '35', '63', '5', '3'), (83, '36', '60', '5', '3'), (83, '37', '60', '5', '3'), (83, '38', '60', '5', '3'), (83, '39', '60', '5', '3'), (83, '40', '60', '5', '3'), (83, '41', '75', '3', '2'), (83, '42', '60', '5', '3'), (83, '43', '66', '5', '3'), (83, '44', '63', '5', '3'), (83, '45', '61', '5', '3'), (83, '46', '60', '5', '3'), (83, '47', '60', '5', '3'), (83, '48', '60', '5', '3'), (83, '49', '60', '5', '3'), (83, '50', '61', '5', '3'), (83, '51', '65', '5', '3'), (83, '52', '62', '5', '3'), (83, '53', '60', '5', '3'), (83, '54', '78', '3', '2'), (83, '55', '75', '3', '2'), (83, '56', '65', '5', '3'), (83, '57', '60', '5', '3'), (83, '58', '75', '3', '2'), (83, '59', '60', '5', '3'), (83, '60', '81', '3', '2'); -- ('Якимів Н.В.',0,0,0), INSERT INTO educational_component (diploma_id, educational_component_template_id, national_score, rating_point_id, national_grade_id) VALUES (84, '1', '80', '3', '2'), (84, '2', '90', '1', '1'), (84, '3', '95', '1', '1'), (84, '4', '90', '5', '3'), (84, '5', '96', '1', '1'), (84, '6', '81', '3', '2'), (84, '7', '90', '1', '1'), (84, '8', '91', '1', '1'), (84, '9', '77', '3', '2'), (84, '10', '95', '1', '1'), (84, '11', '90', '1', '1'), (84, '12', '93', '1', '1'), (84, '13', '78', '3', '2'), (84, '14', '87', '2', '2'), (84, '15', '90', '1', '1'), (84, '16', '93', '1', '1'), (84, '17', '94', '1', '1'), (84, '18', '90', '1', '1'), (84, '19', '90', '1', '1'), (84, '20', '91', '1', '1'), (84, '21', '92', '1', '1'), (84, '22', '78', '3', '2'), (84, '23', '90', '1', '1'), (84, '24', '90', '1', '1'), (84, '25', '93', '1', '1'), (84, '26', '90', '1', '1'), (84, '27', '90', '1', '1'), (84, '28', '90', '1', '1'), (84, '29', '93', '1', '1'), (84, '30', '90', '1', '1'), (84, '31', '90', '1', '1'), (84, '32', '90', '1', '1'), (84, '33', '92', '1', '1'), (84, '34', '99', '1', '1'), (84, '35', '90', '1', '1'), (84, '36', '90', '1', '1'), (84, '37', '94', '1', '1'), (84, '38', '90', '1', '1'), (84, '39', '90', '1', '1'), (84, '40', '90', '1', '1'), (84, '41', '90', '1', '1'), (84, '42', '90', '1', '1'), (84, '43', '100', '1', '1'), (84, '44', '100', '1', '1'), (84, '45', '90', '1', '1'), (84, '46', '90', '1', '1'), (84, '47', '92', '1', '1'), (84, '48', '90', '1', '1'), (84, '49', '90', '1', '1'), (84, '50', '76', '3', '2'), (84, '51', '90', '1', '1'), (84, '52', '94', '1', '1'), (84, '53', '90', '1', '1'), (84, '54', '94', '1', '1'), (84, '55', '95', '1', '1'), (84, '56', '95', '1', '1'), (84, '57', '100', '1', '1'), (84, '58', '90', '1', '1'), (84, '59', '90', '1', '1'), (84, '60', '94', '1', '1');
# Function to calculate distinct # substrings of a string def countDistinctSubstring(s): n = len(s) # To store the result result = n * (n + 1) / 2 # To store the count of characters count = [0] * 256 # To store the count of substrings substring_count = [0] * n # Store the frequency of characters for i in range(n): count[ord(s[i])] += 1 # Change count[i] so that count[i]now contains actual # position of this character in output string for i in range(256): count[i] = count[i] + (count[i] - 1) * count[i] // 2 # Count the number of substrings having same characters for i in range(n): # substring_count[i] stores count of # substring ending with s[i] substring_count[i] = count[ord(s[i])] # Add to result count of distinct substrings # that have already been calculated result = result - substring_count[i] return int(result) # Driver Program s = "[ABC]" print(countDistinctSubstring(s))
#!/bin/bash set -e set -x echo "Starting elasticblast..." elasticblast \ --blast-url=$BLAST_URL \ --log-level=$LOG_LEVEL
#!/bin/bash -f #********************************************************************************************************* # Vivado (TM) v2019.2 (64-bit) # # Filename : TriangleFifo.sh # Simulator : Mentor Graphics ModelSim Simulator # Description : Simulation script for compiling, elaborating and verifying the project source files. # The script will automatically create the design libraries sub-directories in the run # directory, add the library logical mappings in the simulator setup file, create default # 'do/prj' file, execute compilation, elaboration and simulation steps. # # Generated by Vivado on Wed Dec 04 17:34:13 +0100 2019 # SW Build 2700185 on Thu Oct 24 18:46:05 MDT 2019 # # Copyright 1986-2019 Xilinx, Inc. All Rights Reserved. # # usage: TriangleFifo.sh [-help] # usage: TriangleFifo.sh [-lib_map_path] # usage: TriangleFifo.sh [-noclean_files] # usage: TriangleFifo.sh [-reset_run] # # Prerequisite:- To compile and run simulation, you must compile the Xilinx simulation libraries using the # 'compile_simlib' TCL command. For more information about this command, run 'compile_simlib -help' in the # Vivado Tcl Shell. Once the libraries have been compiled successfully, specify the -lib_map_path switch # that points to these libraries and rerun export_simulation. For more information about this switch please # type 'export_simulation -help' in the Tcl shell. # # You can also point to the simulation libraries by either replacing the <SPECIFY_COMPILED_LIB_PATH> in this # script with the compiled library directory path or specify this path with the '-lib_map_path' switch when # executing this script. Please type 'TriangleFifo.sh -help' for more information. # # Additional references - 'Xilinx Vivado Design Suite User Guide:Logic simulation (UG900)' # #********************************************************************************************************* # Script info echo -e "TriangleFifo.sh - Script generated by export_simulation (Vivado v2019.2 (64-bit)-id)\n" # Main steps run() { check_args $# $1 setup $1 $2 compile simulate } # RUN_STEP: <compile> compile() { # Compile design files source compile.do 2>&1 | tee -a compile.log } # RUN_STEP: <simulate> simulate() { vsim -64 -c -do "do {simulate.do}" -l simulate.log } # STEP: setup setup() { case $1 in "-lib_map_path" ) if [[ ($2 == "") ]]; then echo -e "ERROR: Simulation library directory path not specified (type \"./TriangleFifo.sh -help\" for more information)\n" exit 1 fi copy_setup_file $2 ;; "-reset_run" ) reset_run echo -e "INFO: Simulation run files deleted.\n" exit 0 ;; "-noclean_files" ) # do not remove previous data ;; * ) copy_setup_file $2 esac create_lib_dir # Add any setup/initialization commands here:- # <user specific commands> } # Copy modelsim.ini file copy_setup_file() { file="modelsim.ini" if [[ ($1 != "") ]]; then lib_map_path="$1" else lib_map_path="C:/Universiteit/VivadoProjects/RandomDriehoeken/RandomDriehoeken.cache/compile_simlib/modelsim" fi if [[ ($lib_map_path != "") ]]; then src_file="$lib_map_path/$file" cp $src_file . fi } # Create design library directory create_lib_dir() { lib_dir="modelsim_lib" if [[ -e $lib_dir ]]; then rm -rf $lib_dir fi mkdir $lib_dir } # Delete generated data from the previous run reset_run() { files_to_remove=(compile.log elaborate.log simulate.log vsim.wlf modelsim_lib) for (( i=0; i<${#files_to_remove[*]}; i++ )); do file="${files_to_remove[i]}" if [[ -e $file ]]; then rm -rf $file fi done create_lib_dir } # Check command line arguments check_args() { if [[ ($1 == 1 ) && ($2 != "-lib_map_path" && $2 != "-noclean_files" && $2 != "-reset_run" && $2 != "-help" && $2 != "-h") ]]; then echo -e "ERROR: Unknown option specified '$2' (type \"./TriangleFifo.sh -help\" for more information)\n" exit 1 fi if [[ ($2 == "-help" || $2 == "-h") ]]; then usage fi } # Script usage usage() { msg="Usage: TriangleFifo.sh [-help]\n\ Usage: TriangleFifo.sh [-lib_map_path]\n\ Usage: TriangleFifo.sh [-reset_run]\n\ Usage: TriangleFifo.sh [-noclean_files]\n\n\ [-help] -- Print help information for this script\n\n\ [-lib_map_path <path>] -- Compiled simulation library directory path. The simulation library is compiled\n\ using the compile_simlib tcl command. Please see 'compile_simlib -help' for more information.\n\n\ [-reset_run] -- Recreate simulator setup files and library mappings for a clean run. The generated files\n\ from the previous run will be removed. If you don't want to remove the simulator generated files, use the\n\ -noclean_files switch.\n\n\ [-noclean_files] -- Reset previous run, but do not remove simulator generated files from the previous run.\n\n" echo -e $msg exit 1 } # Launch script run $1 $2
<reponame>nabeelkhan/Oracle-DBA-Life col c1 heading 'Program|Name' format a30 col c2 heading 'PGA|Used|Memory' format 999,999,999 col c3 heading 'PGA|Allocated|Memory' format 999,999,999 col c4 heading 'PGA|Maximum|Memory' format 999,999,999 select program c1,pga_used_mem c2,pga_alloc_mem c3,pga_max_mem c4 from v$process order by c4 desc;
<gh_stars>0 package edu.sagado.tictactoe.activities; import edu.sagado.tictactoe.R; import edu.sagado.tictactoe.utils.Constants; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.view.View; import android.widget.RadioGroup; /** * First view to be opened. * Contains the button for starting a new game * and the settings menu. For now the only * setting available is the one related to * the GameAI level. * @author 5agado * */ public class MainActivity extends Activity { private RadioGroup radioGameAI; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); radioGameAI = (RadioGroup)findViewById(R.id.radioGameAI); } /** * Action executed when the Play button is clicked. * Here we create a new intent with an extra that * defines the GameAI level. * Default case is equal to a weak AI * @param view */ public void startGame(View view){ int gameAI = radioGameAI.getCheckedRadioButtonId(); Intent intent = new Intent(this, PlayActivity.class); switch (gameAI) { case R.id.weakAI: intent.putExtra(Constants.AI_PARAM_NAME, Constants.WEAK_AI); break; case R.id.notSoStrongAI: intent.putExtra(Constants.AI_PARAM_NAME, Constants.NOTSOSTRONG_AI); break; case R.id.strongAI: intent.putExtra(Constants.AI_PARAM_NAME, Constants.STRONG_AI); break; case R.id.godAI: intent.putExtra(Constants.AI_PARAM_NAME, Constants.GOD_AI); break; default: intent.putExtra(Constants.AI_PARAM_NAME, Constants.WEAK_AI); break; } startActivity(intent); } /** * Action executed when the Settings button is clicked * @param view */ public void settings(View view){ radioGameAI.setVisibility((radioGameAI.getVisibility() == View.VISIBLE)? View.INVISIBLE : View.VISIBLE); } }
const diablo2Data = require('diablo2-data')('pod_1.13d') const Utils = require('../utils') const Map = require('../map') const { findPath, walkNeighborsCandidates, tpNeighborsCandidates } = require('../pathFinding') function inject (bot) { bot.destination = null bot.warps = [] bot.objects = [] // This is used to store the objects around the bot bot.map = new Map(10) // Think about bot.objects list clearing ? delay ? or D2GS_REMOVEOBJECT ? // received compressed packet D2GS_REMOVEOBJECT {"unitType":2,"unitId":16} bot._client.on('D2GS_ASSIGNLVLWARP', (data) => { bot.warps.push(data) }) /* bot._client.on('D2GS_LOADACT', ({ areaId }) => { // received compressed packet D2GS_LOADACT {"act":0,"mapId":336199680,"areaId":5188,"unkwown":88448} // packet broken ????????????????????? if (bot.area !== areaId) { bot.say(`My area ${areaId}`) } bot.area = areaId }) */ bot._client.on('D2GS_MAPREVEAL', ({ areaId }) => { if (bot.area !== areaId) { bot.say(`My area ${areaId}`) } bot.area = areaId }) bot._client.on('D2GS_WORLDOBJECT', (object) => { /* d2gsToClient : D2GS_WORLDOBJECT {"objectType":2,"objectId":10,"objectUniqueCode":119,"x":4419,"y":5609,"state":2, "interactionCondition":0} */ // if (bot.objects.find(ob => ob['objectId'] === object['objectId']) === undefined) { // Don't duplicate the same object if (bot.debug) { bot.say(`Detected worldobject ${diablo2Data.objects[object['objectUniqueCode']]['description - not loaded']}`) } bot.objects.push(object) // Contains the objects around me // } }) bot._client.on('D2GS_REMOVEOBJECT', (object) => { /* received compressed packet D2GS_REMOVEOBJECT {"unitType":2,"unitId":104} received compressed packet D2GS_REMOVEOBJECT {"unitType":2,"unitId":103} received compressed packet D2GS_REMOVEOBJECT {"unitType":2,"unitId":102} */ if (bot.debug) { bot.say(`Removed worldobject ${diablo2Data.objects[object['objectUniqueCode']]['description - not loaded']}`) } // TODO: test this // bot.objects.splice(bot.objects.findIndex(ob => { return ob['unitId'] === object['unitId']}), 1) }) bot._client.on('D2GS_REASSIGNPLAYER', ({ x, y }) => { bot.x = x bot.y = y }) bot._client.on('D2GS_WALKVERIFY', ({ x, y }) => { bot.x = x bot.y = y }) // Maybe remove this bot.run = (x, y) => { bot._client.write('D2GS_RUNTOLOCATION', { x: x, y: y }) } bot.moveToNextArea = async (teleportation) => { bot.say('Looking for the next level !') bot.say(await reachedWarp() ? 'Found the next level' : 'Could\'nt find the next level') } // Tentative to do pathfinding by exploring all 4 corners of the map // The bot should stop when receiving assignlvlwarp from the next area const DirectionsEnum = Object.freeze({ 'left': 1, 'top': 2, 'right': 3, 'bottom': 4 }) // This will return when the teleportation is done async function reachedPosition (previousPos) { return new Promise(resolve => { bot.say(`arrived at ${bot.x};${bot.y}`) bot.say(`previousPos difference ${Math.abs(bot.x - previousPos.x)};${Math.abs(bot.y - previousPos.y)}`) // We check if we moved resolve(Math.abs(bot.x - previousPos.x) > 5 || Math.abs(bot.y - previousPos.y) > 5) // Means we hit a corner }) } // TODO: Return the path used, to get optimized latter async function reachedWarp (direction = DirectionsEnum.left) { if (bot.warps.findIndex(warp => warp['warpId'] === bot.area + 1) !== -1) { // While we didn't go near the next level warp return true } // Reset the direction if (direction === DirectionsEnum.bottom) { direction = DirectionsEnum.left } let reachedCorner = false let nextPos = { x: bot.x, y: bot.y } while (!reachedCorner) { if (direction === DirectionsEnum.left) { nextPos = { x: bot.x, y: bot.y + 30 } } if (direction === DirectionsEnum.top) { nextPos = { x: bot.x + 30, y: bot.y } } if (direction === DirectionsEnum.right) { nextPos = { x: bot.x, y: bot.y - 30 } } if (direction === DirectionsEnum.top) { nextPos = { x: bot.x - 30, y: bot.y } } let previousPos = { x: bot.x, y: bot.y } await bot.moveTo(true, nextPos.x, nextPos.y) reachedCorner = await reachedPosition(previousPos) } bot.say(`Going ${direction}`) await reachedWarp(direction + 1) } function generatePosition (fromPos, d = 60) { const pos = { x: fromPos.x - d, y: fromPos.y - d } for (;pos.x < d + fromPos.x; pos.x += 20) { for (;pos.y < d + fromPos.y; pos.y += 20) { if (bot.map.getAtPosition(pos) === undefined) { return pos } } } return generatePosition(fromPos, d * 10) } bot.findWarp = async (teleportation) => { let done = false bot.on('D2GS_ASSIGNLVLWARP', () => { bot.say('lol I found a warp') for (let i = 0; i < 100; i++) console.log('lol I found a warp') done = true }) while (true) { const pos = generatePosition({ x: bot.x, y: bot.y }) console.log(pos) const r = await Promise.race([bot.moveTo(teleportation, pos.x, pos.y), Utils.delay(60000)]) if (done || r === false) { return } } } bot.moveTo = async (teleportation, x, y) => { if (x === undefined || y === undefined) { bot.say(`bot.moveTo incorrect coordinate undefined`) return false } await pf2(teleportation, x, y) } // TODO: test, make it works for all type of entity bot.moveToEntity = async (teleportation, entityId) => { let entity = bot.npcs.find(npc => { return npc['unitId'] === entityId }) let type = 1 if (entity === undefined) { entity = bot.warps.find(warp => { return warp['unitId'] === entityId }) if (entity === undefined) { entity = bot.objects.find(object => { return object['objectId'] === entityId }) } type = 2 } try { await pf2(teleportation, entity['x'], entity['y']) } catch (err) { bot.say('Oh sorry I crashed') console.log(err) } bot._client.write('D2GS_RUNTOENTITY', { entityType: type, // 1 seems to be npc, 2 portal ... entityId: entityId }) } async function pf2 (teleportation, x, y) { if (bot.destination !== null) { bot.destination = { x, y } await bot.pf2InternalPromise return } bot.destination = { x, y } bot.pf2InternalPromise = pf2Internal(teleportation, x, y) } async function pf2Internal (teleportation, x, y) { const verbose = true const verboseSay = (message) => { if (verbose) { bot.say(message) } } // const start = +new Date() let stuck = 0 verboseSay(`My position ${bot.x} - ${bot.y}`) verboseSay(`Heading with astar to ${bot.destination.x} - ${bot.destination.y} by ${teleportation ? 'teleporting' : 'walking'}`) // We'll continue till arrived at destination let path = null let indexInPath = 0 const lookForPath = () => { path = findPath({ x: bot.x, y: bot.y }, bot.destination, bot.map, teleportation ? tpNeighborsCandidates : walkNeighborsCandidates) if ((path.status !== 'success' && path.status !== 'timeout') || path.path.length < 2) { bot.wss.broadcast(JSON.stringify({ protocol: 'event', name: 'noPath' })) verboseSay('Sorry, I can\'t go there') console.log(path) bot.destination = null return false } else if (path.status === 'timeout') { if (path.path.length < 2) { bot.wss.broadcast(JSON.stringify({ protocol: 'event', name: 'noPath' })) verboseSay('Sorry, I can\'t go there') bot.destination = null return false } verboseSay('Searching the path took too long but I found a new path of cost ' + path.cost + ' and length ' + path.path.length + ', let\'s go !') } else { verboseSay('Found a new path of cost ' + path.cost + ' and length ' + path.path.length + ', let\'s go !') } bot.wss.broadcast(JSON.stringify({ protocol: 'event', name: 'path', params: path.path })) indexInPath = 1 return true } while (Utils.distance({ x: bot.x, y: bot.y }, bot.destination) > 10.0) { const distance = Utils.distance({ x: bot.x, y: bot.y }, bot.destination) verboseSay(`Calculated distance ${distance.toFixed(2)}`) verboseSay(`Am i arrived ? ${distance <= 10.0}`) if (path === null || indexInPath >= path.path.length) { if (!lookForPath()) { return } } let dest = path.path[indexInPath] indexInPath++ verboseSay(`Movement from ${bot.x.toFixed(2)} - ${bot.y.toFixed(2)} to ${dest.x.toFixed(2)} - ${dest.y.toFixed(2)}`) const moved = await movementWithMapFilling(teleportation, dest.x, dest.y) if (!moved) { // If the bot is stuck verboseSay(`Stuck ${stuck} times`) stuck++ if (!lookForPath()) { return } } else { stuck = 0 } } bot.destination = null bot.pf2InternalPromise = Promise.resolve() verboseSay(`Arrived at destination`) } async function movementWithMapFilling (teleportation, destX, destY) { const previousPosition = { x: bot.x, y: bot.y } await movement(teleportation, destX, destY) const currentPosition = { x: bot.x, y: bot.y } const dest = { x: destX, y: destY } if (Math.abs(previousPosition.x - currentPosition.x) < 2 && Math.abs(previousPosition.y - currentPosition.y) < 2) { // If the bot is stuck let obstacle if (teleportation) { obstacle = dest } else { obstacle = dest } console.log('stuck') bot.map.setAtPosition(obstacle, true) bot.wss.broadcast(JSON.stringify({ protocol: 'event', name: 'mapPoint', params: { x: obstacle.x, y: obstacle.y, isWall: true } })) // bot.say(`Obstacle at ${dest.x.toFixed(2)} - ${dest.y.toFixed(2)}`) return false } else { console.log('no stuck') const nature = bot.map.getAtPosition(dest) if (nature === undefined) { bot.wss.broadcast(JSON.stringify({ protocol: 'event', name: 'mapPoint', params: { x: dest.x, y: dest.y, isWall: false } })) bot.map.setAtPosition(dest, false) } } return true } // This will return when the movement is done async function movement (teleportation, destX, destY) { return new Promise(resolve => { if (!teleportation) { let timeOut const callbackWalkVerify = ({ x, y }) => { // bot.say(`endOfMovement at ${x};${y}`) bot.x = x bot.y = y clearTimeout(timeOut) resolve(true) } bot._client.once('D2GS_WALKVERIFY', callbackWalkVerify) bot.run(destX, destY) timeOut = setTimeout(() => { // in case we run in a wall // let's assume failure then bot._client.removeListener('D2GS_WALKVERIFY', callbackWalkVerify) resolve(false) }, 2000) } else { let timeOut const callback = ({ x, y }) => { // bot.say(`endOfMovement at ${x};${y}`) bot.x = x bot.y = y clearTimeout(timeOut) resolve(true) } bot.castSkillOnLocation(destX, destY, 53).then(() => { bot._client.once('D2GS_REASSIGNPLAYER', callback) }) timeOut = setTimeout(() => { // in case we run in a wall // let's assume failure then bot._client.removeListener('D2GS_REASSIGNPLAYER', callback) resolve(false) }, 2000) } }) } bot.runToWarp = () => { try { const nextArea = bot.warps.find(warp => { return warp['warpId'] === bot.area + 1 }) bot.moveTo(false, nextArea.x, nextArea.y) bot.say(`Heading for the next area`) bot._client.removeAllListeners('D2GS_PLAYERMOVE') bot.follow = false bot.say(`Follow off`) } catch (error) { bot.say('Can\'t find any warp') } } bot.takeWaypoint = async (level) => { // Should we move this to a property of bot to avoid looping the array everytime we use the wp ? Or not // let waypoint = bot.objects.find(object => { return diablo2Data.objects[object['objectUniqueCode']]['description - not loaded'].includes('waypoint') }) let waypoint for (let i = bot.objects.length - 1; i > 0; i--) { // We start at the end, just in case, so we check the latest received objects if (diablo2Data.objects[bot.objects[i]['objectUniqueCode']]['description - not loaded'].includes('waypoint')) { waypoint = bot.objects[i] } } if (waypoint === undefined) { // No waypoint in my area !!! bot.say(`No waypoint in area ${bot.area}`) return false } await bot.moveTo(false, waypoint['x'], waypoint['y']) const area = diablo2Data.areasByName[level] bot._client.once('D2GS_WAYPOINTMENU', ({ unitId, availableWaypoints }) => { bot._client.write('D2GS_WAYPOINT', { // TODO: Handle the case where the bot aint got the wp waypointId: unitId, levelNumber: area === undefined ? level : area['id'] // Allows to use this function with the name of the level or the id }) }) await bot.moveToEntity(false, waypoint['objectId']) bot._client.write('D2GS_INTERACTWITHENTITY', { entityType: waypoint['objectType'], entityId: waypoint['objectId'] }) } bot.base = () => { bot._client.once('D2GS_PORTALOWNERSHIP', ({ ownerId, ownerName, localId, remoteId }) => { bot._client.write('D2GS_RUNTOENTITY', { entityType: 2, entityId: localId }) bot._client.write('D2GS_INTERACTWITHENTITY', { entityType: 2, entityId: localId }) }) if (bot.checkTomes(true) > 0) { bot.castSkillOnLocation(bot.x, bot.y, 220) // Must have a tome of portal } else { bot._client.write('D2GS_USESCROLL', { type: 4, itemId: 1 }) } } } module.exports = inject
import { configureStore } from '@reduxjs/toolkit'; import thunk from 'redux-thunk'; import { recipeSlice } from './slices/recipeSlice'; import { searchFilterSlice } from './slices/searchFilterSlice'; import { writingSlice } from './slices/writingSlice'; const loadState = () => { try { const serializedState = sessionStorage.getItem('state'); if (serializedState === null) { return {}; } return JSON.parse(serializedState); } catch (e) { return undefined; } }; const saveState = (state) => { try { const serializedState = JSON.stringify(state); sessionStorage.setItem('state', serializedState); } catch (e) { // Ignore write errors; } }; const persistedState = loadState(); const store = configureStore({ reducer: { recipe: recipeSlice.reducer, writing: writingSlice.reducer, searchFilter: searchFilterSlice.reducer, }, devTools: process.env.NODE_ENV !== 'production', preloadedState: persistedState, middleware: [thunk], }); store.subscribe(() => { saveState(store.getState()); }); export default store;
package org.firstinspires.ftc.teamcode.Autonomous; import com.qualcomm.robotcore.eventloop.opmode.Autonomous; import com.qualcomm.robotcore.eventloop.opmode.Disabled; @Autonomous(name = "Auto State V2", group = "Linear Opmode") public class AutoStateV2 extends AutoStateV1 { private static final int CAMERA_X_POSITION = 20; private static final int CAMERA_Y_POSITION = 50; @Override public void runOpMode() { initOpMode(CAMERA_X_POSITION, CAMERA_Y_POSITION); waitForStart(); runAutonomous(); while(opModeIsActive()){ sleep(100); } } @Override protected void crabToBlue(){ // this.autoOmni.crab(getCorrectedDistance(-200), 0.6); this.autoOmni.initDriveMotors(hardwareMap, telemetry); this.crabToBlue(false); } @Override protected void moveToLine(SkystoneDeterminationPipeline.RingPosition ringPosition){ switch (ringPosition){ case NONE: // this.autoOmni.move(getCorrectedDistance(2750), 0.4); // break; case ONE: case FOUR: this.autoOmni.move(getCorrectedDistance(2750), 0.4); // this.autoOmni.move(getCorrectedDistance(2650), this.getDefaultPower(ringPosition)); break; // case FOUR: // this.autoOmni.diagonal(HeadingEnum.NORTH_EAST, 2000, this.getDefaultPower()); // sleep(SLEEP_TIME); // this.autoOmni.diagonal(HeadingEnum.NORTH_WEST, 3100, this.getDefaultPower()); // sleep(SLEEP_TIME); // this.autoOmni.crab(-400, this.getDefaultPower()); } } @Override protected void getBackToWhiteLine(SkystoneDeterminationPipeline.RingPosition ringPosition){ switch (ringPosition){ case NONE: // this.autoOmni.crab(getCorrectedDistance(1400), this.getDefaultPower(ringPosition)); this.autoOmni.crab(getCorrectedDistance(1400), 0.3); break; case ONE: this.autoOmni.crab(getCorrectedDistance(200), this.getDefaultPower(ringPosition)); sleep(SLEEP_TIME); this.autoOmni.move(getCorrectedDistance(-1100), this.getDefaultPower(ringPosition)); break; case FOUR: // this.autoOmni.diagonal(HeadingEnum.SOUTH_EAST, getCorrectedDistance(3000), this.getDefaultPower(ringPosition)); this.autoOmni.move(getCorrectedDistance(-2100), this.getDefaultPower(ringPosition)); break; default: telemetry.addData(String.valueOf(ringPosition), "NO Rings Detected"); } } }