text:
let aiArr = []
let humanArr = []
let aiClickCount = 0
let humanClickCount = 0
let round = 0
let i
let gameMode = "normal"
let power = "off"
let turn = "ai"
let ready = true

document.getElementById("1").addEventListener('click', function() {
  if (turn === "human" && ready === true) {
    userPick(1)
  }
})
document.getElementById("2").addEventListener('click', function() {
  if (turn === "human" && ready === true) {
    userPick(2)
  }
})
document.getElementById("3").addEventListener('click', function() {
  if (turn === "human" && ready === true) {
    userPick(3)
  }
})
document.getElementById("4").addEventListener('click', function() {
  if (turn === "human" && ready === true) {
    userPick(4)
  }
})
document.getElementById('onOff').addEventListener('click', function() {
  if (power === "off") {
    on()
  } else if (power === "on") {
    off()
  }
})
document.getElementById("start").addEventListener('click', function() {
  if (power === "on") {
    start()
  }
})
document.getElementById('strict').addEventListener('click', function() {
  if (power === "on") {
    strict()
  }
})

function defaults() {
  aiArr = []
  humanArr = []
  round = 0
  gameMode = "normal"
  aiClickCount = 0
  humanClickCount = 0
  turn = 'ai'
}

function on() {
  power = "on"
  document.getElementById('switch').style.left = "37px"
  document.getElementById('count').innerHTML = "--"
}

function off() {
  power = "off"
  defaults()
  pauseSound()
  resetSound()
  originalColor()
  document.getElementById('switch').style.left = "1px"
  document.getElementById('count').innerHTML = ""
}

function strict() {
  if (power === "off") {
    return
  }
  if (gameMode === "normal") {
    gameMode = "strict"
    document.getElementById('led').style.backgroundColor = "#ff1a1a"
  } else if (gameMode === "strict") {
    gameMode = "normal"
    document.getElementById('led').style.backgroundColor = "#cc0000"
  }
}

function start() {
  if (power === "off") {
    return
  }
  randomNum()
}

function randomNum() {
  if (power === "off") {
    return
  }
  let num = Math.floor(Math.random() * (4 - 1 + 1)) + 1
  push("ai", num)
}

function push(user, num) {
  if (power === "off") {
    return
  }
  if (user === "ai") {
    humanClickCount = 0
    round++
    changeCount()
    aiArr.push(num)
    readArr()
  } else if (user === "human") {
    aiClickCount = 0
    humanArr.push(num)
  }
}

function readArr() {
  if (power === "off") {
    return
  }
  setTimeout(click, 1200, "ai", aiArr[aiClickCount])
}

function click(user, num) {
  if (power === "off") {
    return
  }
  if (num === 1) {
    document.getElementById('1').style.backgroundColor = "#ff1a1a"
    document.getElementById('sound1').play()
    setTimeout(changeBack, 500, 1)
  } else if (num === 2) {
    document.getElementById('2').style.backgroundColor = "#0080ff"
    document.getElementById('sound2').play()
    setTimeout(changeBack, 500, 2)
  } else if (num === 3) {
    document.getElementById('3').style.backgroundColor = "#47d147"
    document.getElementById('sound3').play()
    setTimeout(changeBack, 500, 3)
  } else if (num === 4) {
    document.getElementById('4').style.backgroundColor = "#ffff00"
    document.getElementById('sound4').play()
    setTimeout(changeBack, 500, 4)
  }
  ready = false
  increaseCount(user)
  next(user)
}

function increaseCount(user) {
  if (power === "off") {
    return
  }
  if (user === 'ai') {
    aiClickCount++
  } else if (user === 'human') {
    humanClickCount++
  }
}

function next(user) {
  if (power === "off") {
    return
  }
  if (user === 'ai' && aiClickCount !== round) {
    turn = 'ai'
    readArr();
  } else if (user === 'ai' && aiClickCount === round) {
    turn = "human"
  } else if (user === "human" && humanClickCount !== round) {
    turn = "human"
  } else if (user === "human" && humanClickCount === round) {
    turn = "ai"
    checkArr();
  }
}

function userPick(num) {
  if (power === "off") {
    return
  }
  push("human", num)
  click("human", num)
}

function checkArr() {
  if (aiArr.length !== humanArr.length || power === "off") {
    return
  }
  for (i = 0; i < aiArr.length; i++) {
    if (aiArr[i] !== humanArr[i]) {
      fail()
      return
    } else if (round === 20) {
      win()
      return
    }
  }
  humanArr = []
  randomNum()
}

function changeBack(num) {
  if (power === "off") {
    return
  }
  if (num === 1) {
    document.getElementById('1').style.backgroundColor = "#cc0000"
  } else if (num === 2) {
    document.getElementById('2').style.backgroundColor = "#0059b3"
  } else if (num === 3) {
    document.getElementById('3').style.backgroundColor = "#29a329"
  } else if (num === 4) {
    document.getElementById('4').style.backgroundColor = "#ffdf00"
  }
  ready = true
}

function originalColor() {
  document.getElementById('1').style.backgroundColor = "#cc0000"
  document.getElementById('2').style.backgroundColor = "#0059b3"
  document.getElementById('3').style.backgroundColor = "#29a329"
  document.getElementById('4').style.backgroundColor = "#ffdf00"
}

function pauseSound() {
  document.getElementById('sound1').pause()
  document.getElementById('sound2').pause()
  document.getElementById('sound3').pause()
  document.getElementById('sound4').pause()
}

function resetSound() {
  document.getElementById('sound1').currentTime = 0
  document.getElementById('sound2').currentTime = 0
  document.getElementById('sound3').currentTime = 0
  document.getElementById('sound4').currentTime = 0
}

function changeCount() {
  if (round < 10) {
    document.getElementById('count').innerHTML = "0" + round
  } else if (round > 9) {
    document.getElementById('count').innerHTML = round
  }
}

function fail() {
  if (gameMode === "strict") {
    restart()
  } else if (gameMode === "normal") {
    aiClickCount = 0
    humanClickCount = 0
    humanArr = []
    readArr()
  }
}

function restart() {
  setTimeout(blink, 300, "on")
  setTimeout(blink, 600, "off")
  setTimeout(blink, 900, "on")
  setTimeout(blink, 1200, "off")
  setTimeout(reset, 1500)
}

function blink(status){
  if (status === 'on') {
    document.getElementById('count').innerHTML = "!!"
  } else if (status === 'off') {
    document.getElementById('count').innerHTML = ""
  }
}

function reset() {
  defaults()
  document.getElementById('count').innerHTML = "--"
  setTimeout(start, 200)
}

function win() {
  defaults()
  document.getElementById('count').innerHTML = "--"
  setTimeout(winAlert, 500)
}

function winAlert() {
  alert("You Won!")
}


text:
namespace gl {
class GLImageNativePixmap;
}

namespace gpu {

class GLTestHelper {
 public:
  static const uint8_t kCheckClearValue = 123u;

  static gl::GLDisplay* InitializeGL(gl::GLImplementation gl_impl);
  static gl::GLDisplay* InitializeGLDefault();

  static bool HasExtension(const char* extension);
  static bool CheckGLError(const char* msg, int line);

  // Compiles a shader.
  // Does not check for errors, always returns shader.
  static GLuint CompileShader(GLenum type, const char* shaderSrc);

  // Compiles a shader and checks for compilation errors.
  // Returns shader, 0 on failure.
  static GLuint LoadShader(GLenum type, const char* shaderSrc);

  // Attaches 2 shaders and links them to a program.
  // Does not check for errors, always returns program.
  static GLuint LinkProgram(GLuint vertex_shader, GLuint fragment_shader);

  // Attaches 2 shaders, links them to a program, and checks for errors.
  // Returns program, 0 on failure.
  static GLuint SetupProgram(GLuint vertex_shader, GLuint fragment_shader);

  // Compiles 2 shaders, attaches and links them to a program
  // Returns program, 0 on failure.
  static GLuint LoadProgram(
      const char* vertex_shader_source,
      const char* fragment_shader_source);

  // Make a unit quad with position only.
  // Returns the created buffer.
  static GLuint SetupUnitQuad(GLint position_location);

  // Returns a vector of size 2. The first is the array buffer object,
  // the second is the element array buffer object.
  static std::vector<GLuint> SetupIndexedUnitQuad(GLint position_location);

  // Make a 6 vertex colors.
  // Returns the created buffer.
  static GLuint SetupColorsForUnitQuad(
      GLint location, const GLfloat color[4], GLenum usage);

  // Checks an area of pixels for a color.
  // If mask is nullptr, compare all color channels; otherwise, compare the
  // channels whose corresponding mask bit is true.
  static bool CheckPixels(GLint x,
                          GLint y,
                          GLsizei width,
                          GLsizei height,
                          GLint tolerance,
                          const uint8_t* color,
                          const uint8_t* mask);

  static bool CheckPixels(GLint x,
                          GLint y,
                          GLsizei width,
                          GLsizei height,
                          GLint tolerance,
                          const std::vector<uint8_t>& expected,
                          const uint8_t* mask);

  // Uses ReadPixels to save an area of the current FBO/Backbuffer.
  static bool SaveBackbufferAsBMP(const char* filename, int width, int height);

  static void DrawTextureQuad(const GLenum texture_target,
                              const char* vertex_src,
                              const char* fragment_src,
                              const char* position_name,
                              const char* sampler_name,
                              const char* face_name);
};

class GpuCommandBufferTestEGL {
 public:
  GpuCommandBufferTestEGL();
  ~GpuCommandBufferTestEGL();

  // Reinitialize GL to an EGL implementation if it is available and not
  // the current initialized GL implementation. Return true on success, false
  // otherwise.
  bool InitializeEGL(int width, int height);

  // Restore the default GL implementation.
  void RestoreGLDefault();

  // Returns whether the current context supports the named EGL extension.
  bool HasEGLExtension(const base::StringPiece& extension) {
    return gfx::HasExtension(egl_extensions_, extension);
  }

  // Returns whether the current context supports the named GL extension.
  bool HasGLExtension(const base::StringPiece& extension) {
    return gfx::HasExtension(gl_extensions_, extension);
  }

#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
  // Create GLImageNativePixmap filled in with the given pixels.
  scoped_refptr<gl::GLImageNativePixmap> CreateGLImageNativePixmap(
      gfx::BufferFormat format,
      gfx::Size size,
      uint8_t* pixels) const;

  // Get some real dmabuf fds for testing by exporting an EGLImage created from
  // a GL texture.
  gfx::NativePixmapHandle CreateNativePixmapHandle(gfx::BufferFormat format,
                                                   gfx::Size size,
                                                   uint8_t* pixels);
#endif

 protected:
  bool gl_reinitialized_;
  GLManager gl_;
  gl::GLWindowSystemBindingInfo window_system_binding_info_;
  gfx::ExtensionSet egl_extensions_;
  gfx::ExtensionSet gl_extensions_;
  raw_ptr<gl::GLDisplay> gl_display_ = nullptr;
};

}  // namespace gpu

#endif  // GPU_COMMAND_BUFFER_TESTS_GL_TEST_UTILS_H_

redpajama_set_name: RedPajamaGithub


text:
require 'test_helper'

module Tire

  class FilteredQueriesIntegrationTest < Test::Unit::TestCase
    include Test::Integration

    context "Filtered queries" do

      should "restrict the results with a filter" do
        # 2.json > Begins with "T" and is tagged "ruby"

        s = Tire.search('articles-test') do
          query do
            filtered do
              query { string 'title:T*' }
              filter :terms, :tags => ['ruby']
            end
          end
        end

        assert_equal 1, s.results.count
        assert_equal 'Two', s.results.first.title
      end

      should "restrict the results with multiple filters, chained with AND by default" do
        # 2.json > Is tagged "ruby" and has 250 words

        s = Tire.search('articles-test') do
          query do
            filtered do
              query { all }
              filter :terms, :tags => ['ruby', 'python']
              filter :range, :words => { :from => '250', :to => '250' }
            end
          end
        end

        assert_equal 1, s.results.count
        assert_equal 'Two', s.results.first.title
      end

      should "restrict the results with multiple OR filters" do
        # 1.json > Is tagged "ruby"
        # 1.json > Is tagged "ruby" and has 250 words
        # 4.json > Has 250 words

        s = Tire.search('articles-test') do
          query do
            filtered do
              query { all }
              filter :or, { :terms => { :tags => ['ruby', 'python'] } },
                          { :range => { :words => { :from => '250', :to => '250' } } }
            end
          end
        end

        assert_equal 3, s.results.count
        assert_equal %w(Four One Two), s.results.map(&:title).sort
      end

    end

  end

end


text:
package uk.co.real_logic.agrona.concurrent;

/**
 * Retrieves the number of milliseconds since 1 Jan 1970 UTC.
 */
@FunctionalInterface
public interface EpochClock
{
    /**
     * Time in milliseconds since the 1 Jan 1970 UTC.
     *
     * @return the number of milliseconds since the 1 Jan 1970 UTC.
     */
    long time();
}


text:
LIBS=-lGL -lglfw -lGLEW
FILES=lodepng.cpp main.cpp shaderprogram.cpp game.cpp game_object.cpp ball_object.cpp model.cpp renderer.cpp assets/*.cpp

main: $(FILES)
	g++ -std=c++11 -o main.exe $(FILES)  $(LIBS) -I.


text:
module SpreeApiContentTypeRewriter
  class Engine < Rails::Engine
    require 'spree/core'
    isolate_namespace Spree
    engine_name 'spree_api_content_type_rewriter'

    Spree::Core::Engine.middleware.use "SpreeApiContentTypeRewriter::Middleware::ContentTypeRewriter"
    config.autoload_paths += %W(#{config.root}/lib)

    # use rspec for tests
    config.generators do |g|
      g.test_framework :rspec
    end

    def self.activate
      Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
        Rails.configuration.cache_classes ? require(c) : load(c)
      end
    end

    config.to_prepare &method(:activate).to_proc
  end
end


text:
package com.github.mummyding.raidersrecord.ui.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.github.mummyding.raidersrecord.R;
import com.github.mummyding.raidersrecord.support.DataLoader;
import com.github.mummyding.raidersrecord.support.adapter.ListAdapter;

/**
 * Created by MummyDing on 16-3-16.
 * GitHub: https://github.com/MummyDing
 * Blog: http://blog.csdn.net/mummyding
 */
public abstract class BaseListFragment extends Fragment {
    /**
     * you must to implement it,this title will be regarded as tab title by default.
     * @return
     */
    public abstract String getTitle();

    private View parentView;
    private RecyclerView recyclerView;
    private ListAdapter adapter;
    protected RecyclerView.LayoutManager mLayoutManager;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        parentView =  inflater.inflate(R.layout.fragment_list, container, false);
        initView();
        return parentView;
    }

    private void initView(){
        recyclerView = (RecyclerView) parentView.findViewById(R.id.recyclerView);
        mLayoutManager = new LinearLayoutManager(getContext());
        adapter = new ListAdapter(DataLoader.load());
        recyclerView.setAdapter(adapter);
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        recyclerView.setLayoutManager(mLayoutManager);
    }
}