Emulate brpoplpush
176534
def brpoplpush(self, source, destination, timeout=0):
        """"""
        transfer_item = self.brpop(source, timeout)
        if transfer_item is None:
            return None

        key, val = transfer_item
        self.lpush(destination, val)
        return val
1083506
function rpoplpush(source, destination, req) {
  var src = this.getKey(source, req)
    , dest = this.getKey(destination, req)
    , element;
  if(src === undefined) return null;
  if(dest === undefined) {
    dest = new List();
    this.setKey(destination, dest, undefined, undefined, undefined, req);
  }
  element = src.rpop();
  if(src.llen() === 0) {
    this.delKey(source, req);
  }
  dest.lpush([element]);
  return element;
}
575657
function callYarnOrNpm(yarnCommand, npmCommand) {
  let command;

  if (isYarnAvailable) {
    command = yarnCommand;
  } else {
    command = npmCommand;
  }

  const args = command.split(' ');
  const cmd = args.shift();

  const res = spawnSync(cmd, args, spawnOpts);

  return res;
}
582470
function BRK() {
		var high, low;

		PC += 1;
		push( (PC & HIGH) >> 8 );
		push( PC & LOW );

		setP();
		push( P|0x10 );

		low = peek(0xfffe);
		high = peek(0xffff) << 8;
		PC = high | low;
	}
175622
def __emulate_buttons(self, changed_buttons, timeval=None):
        """"""
        events = []
        for button in changed_buttons:
            code, value, ev_type = self.__map_button(button)
            event = self.create_event_object(
                ev_type,
                code,
                value,
                timeval=timeval)
            events.append(event)
        return events
604944
function projectEnvironmentMapGPU(renderer, envMap) {
    var shTexture = new Texture2D({
        width: 9,
        height: 1,
        type: Texture.FLOAT
    });
    var pass = new Pass({
        fragment: projectEnvMapShaderCode
    });
    pass.material.define('fragment', 'TEXTURE_SIZE', envMap.width);
    pass.setUniform('environmentMap', envMap);

    var framebuffer = new FrameBuffer();
    framebuffer.attach(shTexture);
    pass.render(renderer, framebuffer);

    framebuffer.bind(renderer);
    // TODO Only chrome and firefox support Float32Array
    var pixels = new vendor.Float32Array(9 * 4);
    renderer.gl.readPixels(0, 0, 9, 1, Texture.RGBA, Texture.FLOAT, pixels);

    var coeff = new vendor.Float32Array(9 * 3);
    for (var i = 0; i < 9; i++) {
        coeff[i * 3] = pixels[i * 4];
        coeff[i * 3 + 1] = pixels[i * 4 + 1];
        coeff[i * 3 + 2] = pixels[i * 4 + 2];
    }
    framebuffer.unbind(renderer);

    framebuffer.dispose(renderer);
    pass.dispose(renderer);
    return coeff;
}
1055850
def run_bang(alt_args=None):
    
    parser = get_parser()
    args = parser.parse_args(alt_args)

    source = args.config_specs or get_env_configs()
    if not source:
        return

    config = Config.from_config_specs(source)

    if args.playbooks:
        config[A.PLAYBOOKS] = args.playbooks

    if args.dump_config:

        if args.dump_config in ('yaml', 'yml'):
            import yaml
            print yaml.safe_dump(dict(config))
        elif args.dump_config == 'json':
            import json
            print json.dumps(config)
        else:
            print config
        sys.exit()

    set_ssh_creds(config, args)

    annoy(config)

    stack = Stack(config)

    if args.ansible_list:
        stack.show_inventory(
                os.isatty(sys.stdout.fileno())
                )
        return

    initialize_logging(config)
    # TODO:  config.validate()
    if args.deploy:
        stack.deploy()
    if args.configure:
        stack.configure()
    config.autoinc()
1366570
function() {
		var gl = this.gl;

		var fragmentShaderSource = [
			"precision mediump float;",
			"uniform sampler2D bgTexture;",
			"uniform sampler2D spriteTexture;",
			"uniform sampler2D prioTexture;",
			"uniform sampler2D paletteTexture;",
			"uniform vec4 bgColor;",
			"varying vec2 texCoord;",

			"void main(void) {",
				"float bgIndex = texture2D(bgTexture, texCoord).r;",
				"float spriteIndex = texture2D(spriteTexture, texCoord).r;",
				"float prioIndex = texture2D(prioTexture, texCoord).r;",
				"float colorIndex = ((spriteIndex > 0.0 && (prioIndex == 0.0 || bgIndex == 0.0)) ? spriteIndex : bgIndex);",
				"vec4 color = texture2D(paletteTexture, vec2( colorIndex * 4.0 + 0.0078, 0.5));", // 0.0078 == ( 0.5 * 3 / 192 ) === ( 0.5 * [RGB colors] / [palette width] )
				"if ( colorIndex > 0.0 ) {",
					"gl_FragColor = color;",
				"} else {",
					"gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);",
					"gl_FragColor = bgColor;",
				"}",
			"}"
		].join("\n");

		var vertexShaderSource = [
			"attribute vec2 vertCoord;",
			"varying vec2 texCoord;",

			"void main() {",
				"gl_Position = vec4(vertCoord, 0, 1);",
				"texCoord = vec2( 0.5 * ( vertCoord.x + 1.0 ), 0.5 * (1.0 - vertCoord.y));",
			"}"
		].join("");

		this.fragmentShader = compileShader( gl.FRAGMENT_SHADER, fragmentShaderSource );
		this.vertexShader = compileShader( gl.VERTEX_SHADER, vertexShaderSource );

		function compileShader( shaderType, shaderSource ) {
			var shader = gl.createShader( shaderType );
			gl.shaderSource( shader, shaderSource );
			gl.compileShader( shader );

			if ( !gl.getShaderParameter( shader, gl.COMPILE_STATUS ) ) {  
				throw ( "An error occurred compiling the shaders: " + gl.getShaderInfoLog( shader ) );
			}

			return shader;
		}
	}
710359
def mock_bable(monkeypatch):
    
    mocked_bable = MockBaBLE()
    mocked_bable.set_controllers([
        Controller(0, '11:22:33:44:55:66', '#0'),
        Controller(1, '22:33:44:55:66:11', '#1', settings={'powered': True, 'low_energy': True}),
        Controller(2, '33:44:55:66:11:22', '#2', settings={'powered': True})
    ])

    monkeypatch.setattr(bable_interface, 'BaBLEInterface', lambda: mocked_bable)

    return mocked_bable
169093
function run (x, cb) {
  const s = speculum(null, Echo, x)
  s.on('end', cb)
  s.on('error', cb)

  const reader = new Count({ highWaterMark: 0 }, 10)

  reader.pipe(s).resume()
}
316083
function run() {
  var bin = path.resolve(__dirname, '../node_modules/.bin/mocha');
  var args = Array.prototype.slice.call(arguments);
  var fn = args.pop();
  var cmd = [bin].concat(args).join(' ') + ' --no-colors';
  exec(cmd, fn);
}
47943
def main(argv):
    """"""
    _, black_model, white_model = argv
    utils.ensure_dir_exists(FLAGS.eval_sgf_dir)
    play_match(black_model, white_model, FLAGS.num_evaluation_games, FLAGS.eval_sgf_dir)
928385
public function emulateFatalOnRemoteLoop()
    {
        if ($this->isExternal()) {
            $this->loop->nextTick(function () {
                $this->emulateFatal();
            });
        } else {
            $this->callOnChild(__FUNCTION__, func_get_args());
        }
    }
846711
def play(quiet, session_file, shell, speed, prompt, commentecho):
    """"""
    run(
        session_file.readlines(),
        shell=shell,
        speed=speed,
        quiet=quiet,
        test_mode=TESTING,
        prompt_template=prompt,
        commentecho=commentecho,
    )
796898
def run():
    """"""
    import optparse

    parser = optparse.OptionParser(usage=r"%prog [<options>] [file ...]")
    parser.add_option(
        "-p", "--spread", type="float", default=3.0, help="Rainbow spread"
    )
    parser.add_option(
        "-F", "--freq", type="float", default=0.1, help="Rainbow frequency"
    )
    parser.add_option("-S", "--seed", type="int", default=0, help="Rainbow seed")
    parser.add_option(
        "-a",
        "--animate",
        action="store_true",
        default=False,
        help="Enable psychedelics",
    )
    parser.add_option(
        "-d", "--duration", type="int", default=12, help="Animation duration"
    )
    parser.add_option(
        "-s", "--speed", type="float", default=20.0, help="Animation speed"
    )
    parser.add_option(
        "-f",
        "--force",
        action="store_true",
        default=False,
        help="Force colour even when stdout is not a tty",
    )

    parser.add_option(
        "-3", action="store_const", dest="mode", const=8, help="Force 3 bit colour mode"
    )
    parser.add_option(
        "-4",
        action="store_const",
        dest="mode",
        const=16,
        help="Force 4 bit colour mode",
    )
    parser.add_option(
        "-8",
        action="store_const",
        dest="mode",
        const=256,
        help="Force 8 bit colour mode",
    )

    parser.add_option(
        "-c",
        "--charset-py2",
        default="utf-8",
        help="Manually set a charset to convert from, for python 2.7",
    )

    options, args = parser.parse_args()
    options.os = random.randint(0, 256) if options.seed == 0 else options.seed
    options.mode = options.mode or detect_mode()

    lolcat = LolCat(mode=options.mode)

    if not args:
        args = ["-"]

    for filename in args:
        if filename == "-":
            lolcat.cat(sys.stdin, options)
        else:
            try:
                with open(filename, "r") as handle:
                    lolcat.cat(handle, options)
            except IOError as error:
                sys.stderr.write(str(error) + "\n")
207721
def run(self):
        '''
        
        '''
        self._update_opts()
        cmd = self.opts['fun']

        veri = None
        ret = None
        try:
            if cmd in ('accept', 'reject', 'delete'):
                ret = self._run_cmd('name_match')
                if not isinstance(ret, dict):
                    salt.output.display_output(ret, 'key', opts=self.opts)
                    return ret
                ret = self._filter_ret(cmd, ret)
                if not ret:
                    self._print_no_match(cmd, self.opts['match'])
                    return
                print('The following keys are going to be {0}ed:'.format(cmd.rstrip('e')))
                salt.output.display_output(ret, 'key', opts=self.opts)

                if not self.opts.get('yes', False):
                    try:
                        if cmd.startswith('delete'):
                            veri = input('Proceed? [N/y] ')
                            if not veri:
                                veri = 'n'
                        else:
                            veri = input('Proceed? [n/Y] ')
                            if not veri:
                                veri = 'y'
                    except KeyboardInterrupt:
                        raise SystemExit("\nExiting on CTRL-c")
                # accept/reject/delete the same keys we're printed to the user
                self.opts['match_dict'] = ret
                self.opts.pop('match', None)
                list_ret = ret

            if veri is None or veri.lower().startswith('y'):
                ret = self._run_cmd(cmd)
                if cmd in ('accept', 'reject', 'delete'):
                    if cmd == 'delete':
                        ret = list_ret
                    for minions in ret.values():
                        for minion in minions:
                            print('Key for minion {0} {1}ed.'.format(minion,
                                                                     cmd.rstrip('e')))
                elif isinstance(ret, dict):
                    salt.output.display_output(ret, 'key', opts=self.opts)
                else:
                    salt.output.display_output({'return': ret}, 'key', opts=self.opts)
        except salt.exceptions.SaltException as exc:
            ret = '{0}'.format(exc)
            if not self.opts.get('quiet', False):
                salt.output.display_output(ret, 'nested', self.opts)
        return ret
910285
def spawn(spec, kwargs, pass_fds=()):
    
    r, w = os.pipe()
    for fd in [r] + list(pass_fds):
        set_inheritable(fd, True)

    preparation_data = get_preparation_data()

    r_handle = get_handle(r)
    args, env = get_command_line(pipe_handle=r_handle)
    process = subprocess.Popen(args, env=env, close_fds=False)

    to_child = os.fdopen(w, 'wb')
    to_child.write(pickle.dumps([preparation_data, spec, kwargs]))
    to_child.close()

    return process