text:
import assert from 'assert';
import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import DocumentMeta from '../';
import DocumentMetaServer from '../server';

describe('DocumentMeta', () => {
  beforeAll(() => {
    DocumentMeta.canUseDOM = false;
  });

  describe('.rewind()', () => {
    it('clears the mounted instances', () => {
      renderToStaticMarkup(
        React.createElement(
          DocumentMeta,
          { title: 'a' },
          React.createElement(
            DocumentMeta,
            { title: 'b' },
            React.createElement(DocumentMeta, { title: 'c' })
          )
        )
      );
      assert.deepEqual(DocumentMeta.peek(), { title: 'c' });
      DocumentMeta.rewind();
      assert.strictEqual(DocumentMeta.peek(), undefined);
    });

    it('returns the latest document meta', () => {
      const title = 'cheese';
      renderToStaticMarkup(
        React.createElement(
          DocumentMeta,
          { title: 'a' },
          React.createElement(
            DocumentMeta,
            { title: 'b' },
            React.createElement(DocumentMeta, { title })
          )
        )
      );
      assert.deepEqual(DocumentMeta.rewind(), { title });
    });

    it('returns undefined if no mounted instances exist', () => {
      renderToStaticMarkup(
        React.createElement(
          DocumentMeta,
          { title: 'a' },
          React.createElement(
            DocumentMeta,
            { title: 'b' },
            React.createElement(DocumentMeta, { title: 'c' })
          )
        )
      );
      DocumentMeta.rewind();
      assert.strictEqual(DocumentMeta.peek(), undefined);
    });
  });

  describe('.renderAsReact()', () => {
    it('returns an empty array if no meta data has been mounted', () => {
      React.createElement(
        DocumentMeta,
        { title: 'a' },
        React.createElement(
          DocumentMeta,
          { title: 'b' },
          React.createElement(DocumentMeta, { title: 'c' })
        )
      );

      const rendered = DocumentMeta.renderAsReact();
      assert.ok(Array.isArray(rendered));
      assert.strictEqual(rendered.length, 0);
    });

    it('returns the latest document meta as an array of React components', () => {
      renderToStaticMarkup(
        React.createElement(
          DocumentMeta,
          { title: 'a' },
          React.createElement(
            DocumentMeta,
            { title: 'b' },
            React.createElement(DocumentMeta, { title: 'c' })
          )
        )
      );

      const rendered = DocumentMeta.renderAsReact();
      assert.ok(Array.isArray(rendered));
      assert.strictEqual(rendered.length, 1);
      assert.strictEqual(rendered[0].type, 'title');
      assert.strictEqual(rendered[0].props.children, 'c');
    });
  });

  describe('container element with children', () => {
    it('renders the child', () => {
      const title = 'foo';
      const markup = renderToStaticMarkup(
        <DocumentMeta title={title}>

Child element

        </DocumentMeta>
      );

      assert.strictEqual(markup, '
Child element
');
      assert.deepEqual(DocumentMeta.rewind(), { title });
    });
    it('renders the children, wrapped in a div if more than one child', () => {
      const title = 'foo';
      const markup = renderToStaticMarkup(
        <DocumentMeta title={title}>

foo

bar

        </DocumentMeta>
      );

      assert.strictEqual(markup, '

foo

bar

');
      assert.deepEqual(DocumentMeta.rewind(), { title });
    });
  });
});

describe('DocumentMetaServer', () => {
  describe('.renderToStaticMarkup()', () => {
    it('returns an empty string if no meta data has been mounted', () => {
      React.createElement(
        DocumentMeta,
        { title: 'a' },
        React.createElement(
          DocumentMeta,
          { title: 'b' },
          React.createElement(DocumentMeta, { title: 'c' })
        )
      );
      assert.strictEqual(DocumentMetaServer.renderToStaticMarkup(), '');
    });

    it('returns the latest document meta as HTML', () => {
      renderToStaticMarkup(
        React.createElement(
          DocumentMeta,
          { title: 'a' },
          React.createElement(
            DocumentMeta,
            { title: 'b' },
            React.createElement(DocumentMeta, { title: 'c' })
          )
        )
      );
      assert.strictEqual(
        DocumentMetaServer.renderToStaticMarkup(),
        '<title>c</title>'
      );
    });
  });

  describe('.renderAsHTML()', () => {
    it('returns an empty string if no meta data has been mounted', () => {
      React.createElement(
        DocumentMeta,
        { title: 'a' },
        React.createElement(
          DocumentMeta,
          { title: 'b' },
          React.createElement(DocumentMeta, { title: 'c' })
        )
      );
      assert.strictEqual(DocumentMetaServer.renderAsHTML(), '');
    });

    it('returns the latest document meta as HTML', () => {
      renderToStaticMarkup(
        React.createElement(
          DocumentMeta,
          { title: 'a' },
          React.createElement(
            DocumentMeta,
            { title: 'b' },
            React.createElement(DocumentMeta, { title: 'c' })
          )
        )
      );
      assert.strictEqual(DocumentMetaServer.renderAsHTML(), '<title>c</title>');
    });
  });
});


text:
error()
{
  echo "running bench for signature failed on line $1"
  exit 1
}
trap 'error ${LINENO}' ERR

# obtain

signature=`./stockfish bench all &>/dev/null && ./stockfish bench 2>&1 | grep "Nodes searched  : " | awk '{print $4}'`

if [ $# -gt 0 ]; then
   # compare to given reference
   if [ "$1" != "$signature" ]; then
      if [ "x$1" == "x" ]; then
         echo "No signature obtained from bench. Code crashed or assert triggered ?"
      else
         echo "signature mismatch: reference $1 obtained: $signature ."
      fi
      exit 1
   else
      echo "signature OK: $signature"
   fi
else
   # just report signature
   echo $signature
fi

redpajama_set_name: RedPajamaGithub


text:
require 'puppet_x/dell_powerconnect/possible_facts'
require 'json'

module PuppetX::DellPowerconnect::PossibleFacts::Base
  def self.register(base)

    base.register_param 'machinetype' do
      match do |txt|
        txt.scan(/^Machine\s+Type:\s+(.+)$/).flatten.first
      end
      cmd 'show system'
    end

    base.register_param 'snmp_community_string' do
      match  do |txt|
        item = txt.scan(/^(\w+)\s+\w+.\w+\s+\w+\s+\w+$/).flatten
        item.to_json
      end
      cmd 'show snmp'
    end

    base.register_param 'management_ip' do
      match do |txt|
        @transport.host
      end
      cmd 'show ip interface'
    end

    base.register_param 'system_description' do
      match do |txt|
        txt.scan(/^System\s+Description:\s+(.+)$/).flatten.first
      end
      cmd 'show system'
    end

    base.register_param 'bootimage' do
      res = ''
      match do |txt|
        txt.scan(/^\d+\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/) do |arr|
          res = arr[2]
        end
        res
      end
      cmd 'show bootvar'
    end

    base.register_param 'model' do
      match do |txt|
        txt.scan(/^System\s+Model\s+ID:\s+(.+)$/).flatten.first
      end
      cmd 'show system'
    end

    base.register_param 'systemuptime' do
      match do |txt|
        txt.scan(/^System\s+Up\s+Time:\s+(.+)$/).flatten.first
      end
      cmd 'show system'
    end

    base.register_param 'hostname' do
      match /^System Name:\s+(\S+)$/
      cmd 'show system | include "System Name"'
    end

    base.register_param 'defaultdomain' do
      match do |txt|
        txt.scan(/^Default\s+domain:\s+(.+)$/).flatten.first
      end
      cmd 'show hosts'
    end

    base.register_param 'servicetag' do
      match do |txt|
        txt.scan(/^Service\s+Tag:\s+(.+)$/).flatten.first
      end
      cmd 'show system id'
    end

    base.register_param 'assettag' do
      match do |txt|
        txt.scan(/^Asset\s+Tag:\s+(.+)$/).flatten.first
      end
      cmd 'show system id'
    end

    base.register_param 'serialnumber' do
      match do |txt|
        txt.scan(/^Serial\s+Number:\s+(.+)$/).flatten.first
      end
      cmd 'show system id'
    end

    base.register_param 'totalmemory' do
      match do |txt|
        txt.scan(/^Total Memory[.]+\s+(.+)$/).flatten.first
      end
      cmd 'show memory cpu'
    end

    base.register_param 'availablememory' do
      match do |txt|
        txt.scan(/^Available Memory Space[.]+\s+(.+)$/).flatten.first
      end
      cmd 'show memory cpu'
    end

    base.register_param 'switchstate' do
      state = 'Unknown'
      match do |txt|
        txt.scan(/(.*)\s+(\w+)\s+(\d.+)$/) do |arr|
          state = arr[1]
        end
        state
      end
      cmd 'show switch'
    end

    base.register_param 'powerstate' do
      match do |txt|
        txt.scan(/^[\d+]\s+System\s+(\S+)/).flatten.first
      end
      cmd 'show system power'
    end

    base.register_param 'macaddress' do
      match do |txt|
        txt.scan(/^Burned\s+In\s+MAC\s+Address:\s+(.+)$/).flatten.first
      end
      cmd 'show system'
    end

    base.register_param 'managementip' do
      match do |txt|
        @transport.host
      end
      cmd 'show ip interface'
    end

    base.register_param 'interfaces' do
      all_interfaces = ''
      match do |txt|
        txt.each_line do |line|
          line.scan(/^[a-zA-Z]+[0-9\/]+/) do |item|
            if all_interfaces.to_s != ''
              all_interfaces = all_interfaces + ","
            end
            all_interfaces = all_interfaces + item
          end
        end
        all_interfaces
      end
      cmd 'show interfaces status'
    end

    base.register_param ['interfaces_gigabitethernet'] do
      count = 0
      match do |txt|
        txt.each_line do |line|
          line.scan(/^Gi[0-9\/]+/) do |item|
            count = count + 1
          end
        end
        count.to_s
      end
      cmd 'show interfaces status'
    end

    base.register_param ['interfaces_tengigabitethernet'] do
      count = 0
      match do |txt|
        txt.each_line do |line|
          line.scan(/^Te[0-9\/]+/) do |item|
            count = count + 1
          end
        end
        count.to_s
      end
      cmd 'show interfaces status'
    end

    base.register_param 'vlan' do
      vlan_conf = ''
      match do |txt|
        txt.each_line do |line|
          line.scan(/^[0-9]+/) do |item|
            #Puppet.debug "item = #{item}"
            if vlan_conf.to_s != ''
              vlan_conf = vlan_conf + ","
            end
            vlan_conf = vlan_conf + item
          end
        end
        vlan_conf
      end
      cmd "show vlan"
    end

    base.register_param 'vlandata' do
      res = Hash.new
      vlan_data = Hash.new
      vlan_attrs_global = Hash.new
      match do |txt|
        index = 0
        linenum = 0
        newvlan = true
        txt.each_line do |line|
          if linenum > 3 then
            confvlans = base.facts['vlan'].value.split(',')
            numbered_lines = line.scan(/[0-9]\s+(.+)/).flatten.compact
            if numbered_lines[0].to_s != '' then
              vlan_attrs = Hash.new
              vlan_data[confvlans[index].to_s] = vlan_attrs
              line.scan(/[0-9]\s+(.+)/) do |item|
                attributes = item[0].gsub(/[ \r\t\n]+/, ' ').strip.split(' ')
                vlan_attrs["name"] = attributes[0]
                vlan_attrs["type"] = attributes[2]
                vlan_attrs["ports"] = attributes[1]
                vlan_attrs_global = vlan_attrs
                index = index+1
              end
            else
              justports = line.gsub(/[ \r\t\n]+/, ' ').strip
              if justports.count('#') == 0 then
                vlan_attrs_global["ports"] = vlan_attrs_global["ports"] + justports
              end
            end
            linenum = linenum +1
          else
            linenum = linenum + 1
          end

        end
        res["vlandata"] = vlan_data.to_json
        res
      end
      cmd "show vlan"
    end

    base.register_param 'interfacedata' do
      res = Hash.new
      interface_data = Hash.new
      match do |txt|
        txt.scan(/^interface ((Gi|Te)[0-9\/]+)\n(description (.*)\n)?(channel-group (.*)\n)?(shutdown\n)?(spanning-tree (.*)\n)?mtu (.*)\n(switchport mode (.*)\n)?(switchport (.*) allowed vlan add (.*) tagged\n)?(switchport access vlan (.*)\n)?exit$/) do |item|
          interface_attrs = Hash.new
          #interface_attrs["mtu"] = item[9]
          if item[14] != nil then
            Puppet.debug "TaggedVlans #{item[14]}"
            interface_attrs["TaggedVlans"] = item[14]
          end
          if item[16] != nil then
            interface_attrs["TaggedVlans"] = item[16]
          end
          interface_data[item[0]] = interface_attrs
        end
        res["interfacedata"] = interface_data.to_json
        res
      end
      cmd 'show running-config'
    end

    base.register_param 'portchannelstatus' do
      res = Hash.new
      portchannels = Hash.new
      match do |txt|
        txt.scan(/^(Po[0-9]+)[a-zA-Z0-9 ]+\s+\d+\s+(\S+)$/) do |arr|
          portchannels[arr[0]] = arr[1]
        end
        res["portchannelstatus"] = portchannels.to_json
        res
      end
      cmd 'show interfaces configuration'
    end

    base.register_param 'portchannelmap' do
      res = Hash.new
      portchannels = Hash.new
      match do |txt|
        channel = ""
        txt.split("\n").collect do |line|
          channel = line.scan(/(Po\d+)/).flatten.first if line.start_with?("Po")
          port = line.scan(/((?:Te|Fo|Gi)\d+\/\d+\/\d+)/).flatten.first
          if channel && port
            portchannels[channel] ||= []
            portchannels[channel] << port
          end
        end
        res["portchannelmap"] = portchannels.to_json
        res
      end
      cmd 'show interfaces port-channel'
    end

    base.register_param 'remote_device_info' do
      res = Hash.new
      remote_device = nil
      remote_device_info_list = []
      match do |txt|
        txt.split(/\n+/).each_with_index do |line, i|
          #Line will be something like "Te1/0/5   29      AA:BB:CC:DD:EE:FF   eth0                name"
          next if i < 5  # Skip the first 5 lines (headers)
          tokens = line.scan(/\S+/)
          next unless tokens.size > 3

          interface = tokens[0]
          location = tokens[3]
          remote_mac = tokens[2]
          remote_system_name = tokens[4]

          next unless remote_mac =~ /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/i

          remote_device = {:interface => interface, :location => location, :remote_mac => remote_mac ,:remote_system_name => remote_system_name}
          remote_device_info_list << remote_device
        end
        res["remote_device_info"] = remote_device_info_list.uniq.to_json
        res
      end
      cmd 'show lldp remote-device all'
    end

    base.register_param 'remotedeviceinfo' do
      res = Hash.new
      devices = Hash.new
      match do |txt|
        txt.split(/\n+/).each do |line|
          #Line will be something like "Te1/0/5   29      AA:BB:CC:DD:EE:FF   eth0                name"
          tokens = line.scan(/\S+/)
          next unless tokens.size > 3

          port = tokens[0]
          mac = tokens[2]

          next unless mac =~ /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/i

          devices[mac] = port
        end
        # Commenting remote hash information as mac-address information is
        # listing from other switches via inter-switch link
        res["remotedeviceinfo"] = devices.to_json
      end
      cmd 'show lldp remote-device all'
    end

    base.register_param 'Active_Software_Version' do
      match do |txt|
        txt.scan(/System\sSoftware\sVersion\s+(.+)/).flatten.first
      end
      cmd 'show running-config'
    end

    base.register_param 'vlan_information' do
      match do |txt|
        base.vlan_information(txt).to_json
      end
      cmd "show interface status"
    end

  end

end


text:
/**
 * Installer skin stylesheet
 * Author: MeDBeJoHok
 * Tweaked by Trustmaster
 */

@media (min-width: 811px) {
    .container{
        width:810px;
    }
}

.marginbottom10 {margin-bottom: 10px;}


text:
.class Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;
.super Ljava/lang/Object;
.source "MoviePlayer.java"

# interfaces
.implements Lcom/android/gallery3d/app/MoviePlayer$Restorable;
.implements Lcom/mediatek/gallery3d/ext/IMoviePlayer;

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/android/gallery3d/app/MoviePlayer;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x2
    name = "MoviePlayerExtension"
.end annotation

# static fields
.field private static final KEY_VIDEO_IS_LOOP:Ljava/lang/String; = "video_is_loop"

# instance fields
.field private mAuthor:Ljava/lang/String;

.field private mBookmark:Lcom/mediatek/gallery3d/video/BookmarkEnhance;

.field private mCopyRight:Ljava/lang/String;

.field private mIsLoop:Z

.field private mLastCanPaused:Z

.field private mLastPlaying:Z

.field private mPauseBuffering:Z

.field private mTitle:Ljava/lang/String;

.field final synthetic this$0:Lcom/android/gallery3d/app/MoviePlayer;

# direct methods
.method private constructor <init>(Lcom/android/gallery3d/app/MoviePlayer;)V
    .locals 0
    .parameter

    .prologue
    .line 1313
    iput-object p1, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method synthetic constructor <init>(Lcom/android/gallery3d/app/MoviePlayer;Lcom/android/gallery3d/app/MoviePlayer$1;)V
    .locals 0
    .parameter "x0"
    .parameter "x1"

    .prologue
    .line 1313
    invoke-direct {p0, p1}, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;-><init>(Lcom/android/gallery3d/app/MoviePlayer;)V

    return-void
.end method

.method static synthetic access$3400(Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;)V
    .locals 0
    .parameter "x0"

    .prologue
    .line 1313
    invoke-direct {p0}, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->pauseIfNeed()V

    return-void
.end method

.method static synthetic access$3500(Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;)V
    .locals 0
    .parameter "x0"

    .prologue
    .line 1313
    invoke-direct {p0}, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->resumeIfNeed()V

    return-void
.end method

.method private pauseIfNeed()V
    .locals 4

    .prologue
    const/4 v2, 0x0

    const/4 v1, 0x1

    .line 1474
    invoke-virtual {p0}, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->canStop()Z

    move-result v0

    if-eqz v0, :cond_2

    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mVideoView:Lcom/mediatek/gallery3d/video/MTKVideoView;
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$000(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/video/MTKVideoView;

    move-result-object v0

    invoke-virtual {v0}, Landroid/widget/VideoView;->canPause()Z

    move-result v0

    if-eqz v0, :cond_2

    move v0, v1

    :goto_0
    iput-boolean v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mLastCanPaused:Z

    .line 1475
    iget-boolean v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mLastCanPaused:Z

    if-eqz v0, :cond_1

    .line 1476
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mTState:Lcom/android/gallery3d/app/MoviePlayer$TState;
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$2500(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/android/gallery3d/app/MoviePlayer$TState;

    move-result-object v0

    sget-object v3, Lcom/android/gallery3d/app/MoviePlayer$TState;->PLAYING:Lcom/android/gallery3d/app/MoviePlayer$TState;

    if-ne v0, v3, :cond_0

    move v2, v1

    :cond_0
    iput-boolean v2, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mLastPlaying:Z

    .line 1477
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mOverlayExt:Lcom/mediatek/gallery3d/ext/IContrllerOverlayExt;
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$2600(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/ext/IContrllerOverlayExt;

    move-result-object v0

    invoke-interface {v0}, Lcom/mediatek/gallery3d/ext/IContrllerOverlayExt;->clearBuffering()V

    .line 1478
    iput-boolean v1, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mPauseBuffering:Z

    .line 1479
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #calls: Lcom/android/gallery3d/app/MoviePlayer;->pauseVideo()V
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$1600(Lcom/android/gallery3d/app/MoviePlayer;)V

    .line 1482
    :cond_1
    const-string v0, "MoviePlayer"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "pauseIfNeed() mLastPlaying="

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-boolean v2, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mLastPlaying:Z

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, ", mLastCanPaused="

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-boolean v2, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mLastCanPaused:Z

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, ", mPauseBuffering="

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-boolean v2, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mPauseBuffering:Z

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Lcom/mediatek/gallery3d/ext/MtkLog;->v(Ljava/lang/String;Ljava/lang/String;)I

    .line 1485
    return-void

    :cond_2
    move v0, v2

    .line 1474
    goto :goto_0
.end method

.method private resumeIfNeed()V
    .locals 3

    .prologue
    .line 1488
    iget-boolean v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mLastCanPaused:Z

    if-eqz v0, :cond_0

    .line 1489
    iget-boolean v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mLastPlaying:Z

    if-eqz v0, :cond_0

    .line 1490
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mPauseBuffering:Z

    .line 1491
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #calls: Lcom/android/gallery3d/app/MoviePlayer;->playVideo()V
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$3800(Lcom/android/gallery3d/app/MoviePlayer;)V

    .line 1495
    :cond_0
    const-string v0, "MoviePlayer"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "resumeIfNeed() mLastPlaying="

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-boolean v2, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mLastPlaying:Z

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, ", mLastCanPaused="

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-boolean v2, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mLastCanPaused:Z

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, ", mPauseBuffering="

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-boolean v2, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mPauseBuffering:Z

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Lcom/mediatek/gallery3d/ext/MtkLog;->v(Ljava/lang/String;Ljava/lang/String;)I

    .line 1498
    return-void
.end method

# virtual methods
.method public addBookmark()V
    .locals 7

    .prologue
    const/4 v6, 0x0

    .line 1360
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mBookmark:Lcom/mediatek/gallery3d/video/BookmarkEnhance;

    if-nez v0, :cond_0

    .line 1361
    new-instance v0, Lcom/mediatek/gallery3d/video/BookmarkEnhance;

    iget-object v1, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mActivityContext:Lcom/android/gallery3d/app/MovieActivity;
    invoke-static {v1}, Lcom/android/gallery3d/app/MoviePlayer;->access$700(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/android/gallery3d/app/MovieActivity;

    move-result-object v1

    invoke-direct {v0, v1}, Lcom/mediatek/gallery3d/video/BookmarkEnhance;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mBookmark:Lcom/mediatek/gallery3d/video/BookmarkEnhance;

    .line 1363
    :cond_0
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mMovieItem:Lcom/mediatek/gallery3d/ext/IMovieItem;
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$3300(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/ext/IMovieItem;

    move-result-object v0

    invoke-interface {v0}, Lcom/mediatek/gallery3d/ext/IMovieItem;->getUri()Landroid/net/Uri;

    move-result-object v0

    invoke-static {v0}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v2

    .line 1364
    .local v2, uri:Ljava/lang/String;
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mBookmark:Lcom/mediatek/gallery3d/video/BookmarkEnhance;

    invoke-virtual {v0, v2}, Lcom/mediatek/gallery3d/video/BookmarkEnhance;->exists(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_1

    .line 1365
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mActivityContext:Lcom/android/gallery3d/app/MovieActivity;
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$700(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/android/gallery3d/app/MovieActivity;

    move-result-object v0

    const v1, 0x7f0c017e

    invoke-static {v0, v1, v6}, Landroid/widget/Toast;->makeText(Landroid/content/Context;II)Landroid/widget/Toast;

    move-result-object v0

    invoke-virtual {v0}, Landroid/widget/Toast;->show()V

    .line 1371
    :goto_0
    const-string v0, "MoviePlayer"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, "addBookmark() mTitle="

    invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-object v3, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mTitle:Ljava/lang/String;

    invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v3, ", mUri="

    invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-object v3, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mMovieItem:Lcom/mediatek/gallery3d/ext/IMovieItem;
    invoke-static {v3}, Lcom/android/gallery3d/app/MoviePlayer;->access$3300(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/ext/IMovieItem;

    move-result-object v3

    invoke-interface {v3}, Lcom/mediatek/gallery3d/ext/IMovieItem;->getUri()Landroid/net/Uri;

    move-result-object v3

    invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Lcom/mediatek/gallery3d/ext/MtkLog;->v(Ljava/lang/String;Ljava/lang/String;)I

    .line 1373
    return-void

    .line 1367
    :cond_1
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mBookmark:Lcom/mediatek/gallery3d/video/BookmarkEnhance;

    iget-object v1, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mTitle:Ljava/lang/String;

    iget-object v3, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mMovieItem:Lcom/mediatek/gallery3d/ext/IMovieItem;
    invoke-static {v3}, Lcom/android/gallery3d/app/MoviePlayer;->access$3300(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/ext/IMovieItem;

    move-result-object v3

    invoke-interface {v3}, Lcom/mediatek/gallery3d/ext/IMovieItem;->getMimeType()Ljava/lang/String;

    move-result-object v3

    const-wide/16 v4, 0x0

    invoke-virtual/range {v0 .. v5}, Lcom/mediatek/gallery3d/video/BookmarkEnhance;->insert(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;J)Landroid/net/Uri;

    .line 1368
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mActivityContext:Lcom/android/gallery3d/app/MovieActivity;
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$700(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/android/gallery3d/app/MovieActivity;

    move-result-object v0

    const v1, 0x7f0c017f

    invoke-static {v0, v1, v6}, Landroid/widget/Toast;->makeText(Landroid/content/Context;II)Landroid/widget/Toast;

    move-result-object v0

    invoke-virtual {v0}, Landroid/widget/Toast;->show()V

    goto :goto_0
.end method

.method public canStop()Z
    .locals 4

    .prologue
    .line 1348
    const/4 v0, 0x0

    .line 1349
    .local v0, stopped:Z
    iget-object v1, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mController:Lcom/android/gallery3d/app/MovieControllerOverlay;
    invoke-static {v1}, Lcom/android/gallery3d/app/MoviePlayer;->access$100(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/android/gallery3d/app/MovieControllerOverlay;

    move-result-object v1

    if-eqz v1, :cond_0

    .line 1350
    iget-object v1, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mOverlayExt:Lcom/mediatek/gallery3d/ext/IContrllerOverlayExt;
    invoke-static {v1}, Lcom/android/gallery3d/app/MoviePlayer;->access$2600(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/ext/IContrllerOverlayExt;

    move-result-object v1

    invoke-interface {v1}, Lcom/mediatek/gallery3d/ext/IContrllerOverlayExt;->isPlayingEnd()Z

    move-result v0

    .line 1353
    :cond_0
    const-string v1, "MoviePlayer"

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, "canStop() stopped="

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Lcom/mediatek/gallery3d/ext/MtkLog;->v(Ljava/lang/String;Ljava/lang/String;)I

    .line 1355
    if-nez v0, :cond_1

    const/4 v1, 0x1

    :goto_0
    return v1

    :cond_1
    const/4 v1, 0x0

    goto :goto_0
.end method

.method public getLoop()Z
    .locals 3

    .prologue
    .line 1378
    const-string v0, "MoviePlayer"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "getLoop() return "

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-boolean v2, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mIsLoop:Z

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Lcom/mediatek/gallery3d/ext/MtkLog;->v(Ljava/lang/String;Ljava/lang/String;)I

    .line 1380
    iget-boolean v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mIsLoop:Z

    return v0
.end method

.method public onFirstShow(Landroid/content/DialogInterface;)V
    .locals 3
    .parameter "dialog"

    .prologue
    .line 1457
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    invoke-virtual {v0}, Lcom/android/gallery3d/app/MoviePlayer;->isLiveStreaming()Z

    move-result v0

    if-eqz v0, :cond_0

    .line 1463
    :goto_0
    return-void

    .line 1459
    :cond_0
    invoke-direct {p0}, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->pauseIfNeed()V

    .line 1461
    const-string v0, "MoviePlayer"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "onFirstShow() mLastPlaying="

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-boolean v2, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mLastPlaying:Z

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Lcom/mediatek/gallery3d/ext/MtkLog;->v(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_0
.end method

.method public onLastDismiss(Landroid/content/DialogInterface;)V
    .locals 3
    .parameter "dialog"

    .prologue
    .line 1467
    invoke-direct {p0}, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->resumeIfNeed()V

    .line 1469
    const-string v0, "MoviePlayer"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "onLastDismiss() mLastPlaying="

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-boolean v2, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mLastPlaying:Z

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Lcom/mediatek/gallery3d/ext/MtkLog;->v(Ljava/lang/String;Ljava/lang/String;)I

    .line 1471
    return-void
.end method

.method public onRestoreInstanceState(Landroid/os/Bundle;)V
    .locals 2
    .parameter "icicle"

    .prologue
    .line 1443
    const-string v0, "video_is_loop"

    const/4 v1, 0x0

    invoke-virtual {p1, v0, v1}, Landroid/os/Bundle;->getBoolean(Ljava/lang/String;Z)Z

    move-result v0

    iput-boolean v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mIsLoop:Z

    .line 1444
    iget-boolean v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mIsLoop:Z

    if-eqz v0, :cond_0

    .line 1445
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mController:Lcom/android/gallery3d/app/MovieControllerOverlay;
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$100(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/android/gallery3d/app/MovieControllerOverlay;

    move-result-object v0

    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Lcom/android/gallery3d/app/MovieControllerOverlay;->setCanReplay(Z)V

    .line 1447
    :cond_0
    return-void
.end method

.method public onSaveInstanceState(Landroid/os/Bundle;)V
    .locals 2
    .parameter "outState"

    .prologue
    .line 1451
    const-string v0, "video_is_loop"

    iget-boolean v1, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mIsLoop:Z

    invoke-virtual {p1, v0, v1}, Landroid/os/Bundle;->putBoolean(Ljava/lang/String;Z)V

    .line 1452
    return-void
.end method

.method public pauseBuffering()Z
    .locals 1

    .prologue
    .line 1501
    iget-boolean v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mPauseBuffering:Z

    return v0
.end method

.method public setLoop(Z)V
    .locals 3
    .parameter "loop"

    .prologue
    .line 1386
    const-string v0, "MoviePlayer"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "setLoop("

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, ") mIsLoop="

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-boolean v2, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mIsLoop:Z

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Lcom/mediatek/gallery3d/ext/MtkLog;->v(Ljava/lang/String;Ljava/lang/String;)I

    .line 1388
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    invoke-virtual {v0}, Lcom/android/gallery3d/app/MoviePlayer;->isLocalFile()Z

    move-result v0

    if-eqz v0, :cond_0

    .line 1389
    iput-boolean p1, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mIsLoop:Z

    .line 1390
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mController:Lcom/android/gallery3d/app/MovieControllerOverlay;
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$100(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/android/gallery3d/app/MovieControllerOverlay;

    move-result-object v0

    invoke-virtual {v0, p1}, Lcom/android/gallery3d/app/MovieControllerOverlay;->setCanReplay(Z)V

    .line 1392
    :cond_0
    return-void
.end method

.method public setVideoInfo(Landroid/media/Metadata;)V
    .locals 4
    .parameter "data"

    .prologue
    const/16 v3, 0xa

    const/4 v2, 0x7

    const/4 v1, 0x5

    .line 1505
    invoke-virtual {p1, v1}, Landroid/media/Metadata;->has(I)Z

    move-result v0

    if-eqz v0, :cond_0

    .line 1506
    invoke-virtual {p1, v1}, Landroid/media/Metadata;->getString(I)Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mTitle:Ljava/lang/String;

    .line 1508
    :cond_0
    invoke-virtual {p1, v3}, Landroid/media/Metadata;->has(I)Z

    move-result v0

    if-eqz v0, :cond_1

    .line 1509
    invoke-virtual {p1, v3}, Landroid/media/Metadata;->getString(I)Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mAuthor:Ljava/lang/String;

    .line 1511
    :cond_1
    invoke-virtual {p1, v2}, Landroid/media/Metadata;->has(I)Z

    move-result v0

    if-eqz v0, :cond_2

    .line 1512
    invoke-virtual {p1, v2}, Landroid/media/Metadata;->getString(I)Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mCopyRight:Ljava/lang/String;

    .line 1514
    :cond_2
    return-void
.end method

.method public showDetail()V
    .locals 5

    .prologue
    .line 1396
    new-instance v0, Lcom/mediatek/gallery3d/video/DetailDialog;

    iget-object v1, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mActivityContext:Lcom/android/gallery3d/app/MovieActivity;
    invoke-static {v1}, Lcom/android/gallery3d/app/MoviePlayer;->access$700(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/android/gallery3d/app/MovieActivity;

    move-result-object v1

    iget-object v2, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mTitle:Ljava/lang/String;

    iget-object v3, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mAuthor:Ljava/lang/String;

    iget-object v4, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->mCopyRight:Ljava/lang/String;

    invoke-direct {v0, v1, v2, v3, v4}, Lcom/mediatek/gallery3d/video/DetailDialog;-><init>(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

    .line 1397
    .local v0, detailDialog:Lcom/mediatek/gallery3d/video/DetailDialog;
    const v1, 0x7f0c018a

    invoke-virtual {v0, v1}, Landroid/app/Dialog;->setTitle(I)V

    .line 1398
    new-instance v1, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension$1;

    invoke-direct {v1, p0}, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension$1;-><init>(Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;)V

    invoke-virtual {v0, v1}, Landroid/app/Dialog;->setOnShowListener(Landroid/content/DialogInterface$OnShowListener;)V

    .line 1408
    new-instance v1, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension$2;

    invoke-direct {v1, p0}, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension$2;-><init>(Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;)V

    invoke-virtual {v0, v1}, Landroid/app/Dialog;->setOnDismissListener(Landroid/content/DialogInterface$OnDismissListener;)V

    .line 1418
    invoke-virtual {v0}, Landroid/app/Dialog;->show()V

    .line 1419
    return-void
.end method

.method public startNextVideo(Lcom/mediatek/gallery3d/ext/IMovieItem;)V
    .locals 6
    .parameter "item"

    .prologue
    .line 1423
    move-object v1, p1

    .line 1424
    .local v1, next:Lcom/mediatek/gallery3d/ext/IMovieItem;
    if-eqz v1, :cond_0

    iget-object v3, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mMovieItem:Lcom/mediatek/gallery3d/ext/IMovieItem;
    invoke-static {v3}, Lcom/android/gallery3d/app/MoviePlayer;->access$3300(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/ext/IMovieItem;

    move-result-object v3

    if-eq v1, v3, :cond_0

    .line 1425
    iget-object v3, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mVideoView:Lcom/mediatek/gallery3d/video/MTKVideoView;
    invoke-static {v3}, Lcom/android/gallery3d/app/MoviePlayer;->access$000(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/video/MTKVideoView;

    move-result-object v3

    invoke-virtual {v3}, Lcom/mediatek/gallery3d/video/MTKVideoView;->getCurrentPosition()I

    move-result v2

    .line 1426
    .local v2, position:I
    iget-object v3, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mVideoView:Lcom/mediatek/gallery3d/video/MTKVideoView;
    invoke-static {v3}, Lcom/android/gallery3d/app/MoviePlayer;->access$000(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/video/MTKVideoView;

    move-result-object v3

    invoke-virtual {v3}, Lcom/mediatek/gallery3d/video/MTKVideoView;->getDuration()I

    move-result v0

    .line 1427
    .local v0, duration:I
    iget-object v3, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mBookmarker:Lcom/android/gallery3d/app/Bookmarker;
    invoke-static {v3}, Lcom/android/gallery3d/app/MoviePlayer;->access$3600(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/android/gallery3d/app/Bookmarker;

    move-result-object v3

    iget-object v4, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mMovieItem:Lcom/mediatek/gallery3d/ext/IMovieItem;
    invoke-static {v4}, Lcom/android/gallery3d/app/MoviePlayer;->access$3300(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/ext/IMovieItem;

    move-result-object v4

    invoke-interface {v4}, Lcom/mediatek/gallery3d/ext/IMovieItem;->getUri()Landroid/net/Uri;

    move-result-object v4

    invoke-virtual {v3, v4, v2, v0}, Lcom/android/gallery3d/app/Bookmarker;->setBookmark(Landroid/net/Uri;II)V

    .line 1428
    iget-object v3, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mVideoView:Lcom/mediatek/gallery3d/video/MTKVideoView;
    invoke-static {v3}, Lcom/android/gallery3d/app/MoviePlayer;->access$000(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/video/MTKVideoView;

    move-result-object v3

    invoke-virtual {v3}, Landroid/widget/VideoView;->stopPlayback()V

    .line 1429
    iget-object v3, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mVideoView:Lcom/mediatek/gallery3d/video/MTKVideoView;
    invoke-static {v3}, Lcom/android/gallery3d/app/MoviePlayer;->access$000(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/video/MTKVideoView;

    move-result-object v3

    const/4 v4, 0x4

    invoke-virtual {v3, v4}, Landroid/view/SurfaceView;->setVisibility(I)V

    .line 1430
    iget-object v3, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #calls: Lcom/android/gallery3d/app/MoviePlayer;->clearVideoInfo()V
    invoke-static {v3}, Lcom/android/gallery3d/app/MoviePlayer;->access$3100(Lcom/android/gallery3d/app/MoviePlayer;)V

    .line 1431
    iget-object v3, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #setter for: Lcom/android/gallery3d/app/MoviePlayer;->mMovieItem:Lcom/mediatek/gallery3d/ext/IMovieItem;
    invoke-static {v3, v1}, Lcom/android/gallery3d/app/MoviePlayer;->access$3302(Lcom/android/gallery3d/app/MoviePlayer;Lcom/mediatek/gallery3d/ext/IMovieItem;)Lcom/mediatek/gallery3d/ext/IMovieItem;

    .line 1432
    iget-object v3, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mActivityContext:Lcom/android/gallery3d/app/MovieActivity;
    invoke-static {v3}, Lcom/android/gallery3d/app/MoviePlayer;->access$700(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/android/gallery3d/app/MovieActivity;

    move-result-object v3

    iget-object v4, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mMovieItem:Lcom/mediatek/gallery3d/ext/IMovieItem;
    invoke-static {v4}, Lcom/android/gallery3d/app/MoviePlayer;->access$3300(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/ext/IMovieItem;

    move-result-object v4

    invoke-virtual {v3, v4}, Lcom/android/gallery3d/app/MovieActivity;->refreshMovieInfo(Lcom/mediatek/gallery3d/ext/IMovieItem;)V

    .line 1433
    iget-object v3, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #calls: Lcom/android/gallery3d/app/MoviePlayer;->startVideoCareDrm()V
    invoke-static {v3}, Lcom/android/gallery3d/app/MoviePlayer;->access$3700(Lcom/android/gallery3d/app/MoviePlayer;)V

    .line 1434
    iget-object v3, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mVideoView:Lcom/mediatek/gallery3d/video/MTKVideoView;
    invoke-static {v3}, Lcom/android/gallery3d/app/MoviePlayer;->access$000(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/video/MTKVideoView;

    move-result-object v3

    const/4 v4, 0x0

    invoke-virtual {v3, v4}, Landroid/view/SurfaceView;->setVisibility(I)V

    .line 1438
    .end local v0           #duration:I
    .end local v2           #position:I
    :goto_0
    iget-object v3, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mActivityContext:Lcom/android/gallery3d/app/MovieActivity;
    invoke-static {v3}, Lcom/android/gallery3d/app/MoviePlayer;->access$700(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/android/gallery3d/app/MovieActivity;

    move-result-object v3

    invoke-virtual {v3}, Landroid/app/Activity;->closeOptionsMenu()V

    .line 1439
    return-void

    .line 1436
    :cond_0
    const-string v3, "MoviePlayer"

    new-instance v4, Ljava/lang/StringBuilder;

    invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V

    const-string v5, "Cannot play the next video! "

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-static {v3, v4}, Lcom/mediatek/gallery3d/ext/MtkLog;->e(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_0
.end method

.method public stopVideo()V
    .locals 4

    .prologue
    const/4 v3, 0x1

    const/4 v2, 0x0

    .line 1328
    const-string v0, "MoviePlayer"

    const-string v1, "stopVideo()"

    invoke-static {v0, v1}, Lcom/mediatek/gallery3d/ext/MtkLog;->v(Ljava/lang/String;Ljava/lang/String;)I

    .line 1330
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    sget-object v1, Lcom/android/gallery3d/app/MoviePlayer$TState;->STOPED:Lcom/android/gallery3d/app/MoviePlayer$TState;

    #setter for: Lcom/android/gallery3d/app/MoviePlayer;->mTState:Lcom/android/gallery3d/app/MoviePlayer$TState;
    invoke-static {v0, v1}, Lcom/android/gallery3d/app/MoviePlayer;->access$2502(Lcom/android/gallery3d/app/MoviePlayer;Lcom/android/gallery3d/app/MoviePlayer$TState;)Lcom/android/gallery3d/app/MoviePlayer$TState;

    .line 1331
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mVideoView:Lcom/mediatek/gallery3d/video/MTKVideoView;
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$000(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/video/MTKVideoView;

    move-result-object v0

    invoke-virtual {v0}, Lcom/mediatek/gallery3d/video/MTKVideoView;->clearSeek()V

    .line 1332
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mVideoView:Lcom/mediatek/gallery3d/video/MTKVideoView;
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$000(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/video/MTKVideoView;

    move-result-object v0

    invoke-virtual {v0}, Lcom/mediatek/gallery3d/video/MTKVideoView;->clearDuration()V

    .line 1333
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mVideoView:Lcom/mediatek/gallery3d/video/MTKVideoView;
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$000(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/video/MTKVideoView;

    move-result-object v0

    invoke-virtual {v0}, Landroid/widget/VideoView;->stopPlayback()V

    .line 1334
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mVideoView:Lcom/mediatek/gallery3d/video/MTKVideoView;
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$000(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/video/MTKVideoView;

    move-result-object v0

    invoke-virtual {v0, v2}, Lcom/mediatek/gallery3d/video/MTKVideoView;->setResumed(Z)V

    .line 1335
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mVideoView:Lcom/mediatek/gallery3d/video/MTKVideoView;
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$000(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/video/MTKVideoView;

    move-result-object v0

    const/4 v1, 0x4

    invoke-virtual {v0, v1}, Landroid/view/SurfaceView;->setVisibility(I)V

    .line 1336
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mVideoView:Lcom/mediatek/gallery3d/video/MTKVideoView;
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$000(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/mediatek/gallery3d/video/MTKVideoView;

    move-result-object v0

    invoke-virtual {v0, v2}, Landroid/view/SurfaceView;->setVisibility(I)V

    .line 1337
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #calls: Lcom/android/gallery3d/app/MoviePlayer;->clearVideoInfo()V
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$3100(Lcom/android/gallery3d/app/MoviePlayer;)V

    .line 1338
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #setter for: Lcom/android/gallery3d/app/MoviePlayer;->mFirstBePlayed:Z
    invoke-static {v0, v2}, Lcom/android/gallery3d/app/MoviePlayer;->access$3202(Lcom/android/gallery3d/app/MoviePlayer;Z)Z

    .line 1339
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mController:Lcom/android/gallery3d/app/MovieControllerOverlay;
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$100(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/android/gallery3d/app/MovieControllerOverlay;

    move-result-object v0

    invoke-virtual {v0, v3}, Lcom/android/gallery3d/app/MovieControllerOverlay;->setCanReplay(Z)V

    .line 1340
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mController:Lcom/android/gallery3d/app/MovieControllerOverlay;
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$100(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/android/gallery3d/app/MovieControllerOverlay;

    move-result-object v0

    invoke-virtual {v0}, Lcom/android/gallery3d/app/MovieControllerOverlay;->showEnded()V

    .line 1342
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #getter for: Lcom/android/gallery3d/app/MoviePlayer;->mController:Lcom/android/gallery3d/app/MovieControllerOverlay;
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$100(Lcom/android/gallery3d/app/MoviePlayer;)Lcom/android/gallery3d/app/MovieControllerOverlay;

    move-result-object v0

    invoke-virtual {v0, v3}, Lcom/android/gallery3d/app/MovieControllerOverlay;->setViewEnabled(Z)V

    .line 1343
    iget-object v0, p0, Lcom/android/gallery3d/app/MoviePlayer$MoviePlayerExtension;->this$0:Lcom/android/gallery3d/app/MoviePlayer;

    #calls: Lcom/android/gallery3d/app/MoviePlayer;->setProgress()I
    invoke-static {v0}, Lcom/android/gallery3d/app/MoviePlayer;->access$500(Lcom/android/gallery3d/app/MoviePlayer;)I

    .line 1344
    return-void
.end method


text:
<?php
include "session.php";

release();

header("Location: /");
?>


text:
using System.Collections.Generic;
using System.Net;

namespace Finkit.ManicTime.Server.SampleClient
{
    public class NoCredentials : IServerHttpCredentials
    {
        private static readonly KeyValuePair<string, string>[] NoHeaders = new KeyValuePair<string, string>[0];

        public static NoCredentials Value = new NoCredentials();
        public ICredentials Credentials { get; } = null;
        public KeyValuePair<string, string>[] Headers { get; } = NoHeaders;

        private NoCredentials()
        {
        }
    }
}


text:
<?php

namespace Embera\Provider;

use Embera\ProviderTester;

/**
 * Test the Smrthi Provider
 */
final class SmrthiTest extends ProviderTester
{
    protected $tasks = [
        'valid_urls' => [
            'https://www.smrthi.com/book/RigVeda/1.1.1',
        ],
        'invalid_urls' => [
            'https://www.smrthi.com/',
        ],
    ];

    public function testProvider()
    {
        $this->validateProvider('Smrthi', [ 'width' => 480, 'height' => 270]);
    }
}


text:
import sys, os, subprocess

if len(sys.argv) < 3:
    print 'To package a single file:'
    print '    python %s PACKAGE_NAME FILE' % sys.argv[0];
    print 'To package a directory tree:'
    print '    python %s PACKAGE_NAME DIRECTORY FILE_TO_RUN' % sys.argv[0];
    print ''
    print 'Requires dosbox.html as template.'
    print 'Creates PACKAGE_NAME.data and PACKAGE_NAME.html.'
    sys.exit(1)

def error(s):
    print >> sys.stderr, s
    sys.exit(1)

OUTPUT_HTML = sys.argv[1] + '.html'
OUTPUT_DATA = sys.argv[1] + '.data'

if os.path.isfile(sys.argv[2]):
    ( BASE_DIR, PACKAGE_ARG ) = os.path.split(sys.argv[2])
    EXECUTABLE = PACKAGE_ARG
elif os.path.isdir(sys.argv[2]):
    BASE_DIR = sys.argv[2];
    PACKAGE_ARG = '.'
    if (len(sys.argv) < 4):
        error('When packaging directory, supply file to run as 3rd argument.')
    else:
        p = os.path.join(sys.argv[2], sys.argv[3])
        if os.path.isfile(p):
            EXECUTABLE = sys.argv[3]
        else:
            error("Did not find executable at %s" % p)
elif not os.path.exists(sys.argv[2]):
    error("Can't find %s" % sys.argv[2])
else:
    error("Don't know how to package %s" % sys.argv[2])

def getfiletext(fn):
    try:
        f = open(fn, 'r')
        txt = f.read()
    except Exception, e:
        error('Error reading file: %s' % (str(e)))
    f.close
    return txt

try:
  exec(getfiletext(os.path.expanduser('~/.emscripten')))
except Exception, e:
  error('Error evaluating Emscripten configuration: %s' % (str(e)))

# Find folder in PATH environment variable which contains specified file
def find_in_path(fn):
    for d in os.environ["PATH"].split(os.pathsep):
        if os.path.isfile(os.path.join(d, fn)):
            return d
    return None

# Find Emscripten from EMSCRIPTEN_ROOT or by searching via PATH
def find_emscripten():
    if 'EMSCRIPTEN_ROOT' in globals():
        em_path = EMSCRIPTEN_ROOT
    else:
        em_path = find_in_path('emcc');

    if em_path is None or not os.path.isdir(em_path):
        error("Can't find Emscripten. Add it to PATH or set EMSCRIPTEN_ROOT.");

    return em_path;

# Find Emscripten's file packager
def find_packager():
    p = os.path.join(find_emscripten(), "tools", "file_packager.py");
    if not os.path.isfile(p):
        error('Emscripten file_packager.py not found.')
    return p;

# Run Emscripten's file packager from the appropriate directory
def run_packager():
    if BASE_DIR != '':
        # Need to change directory because paths in package are
        # relative to directory where Emscripten packager is run.
        cwd = os.getcwd()
        os.chdir(BASE_DIR)
        if os.path.isabs(OUTPUT_DATA):
            datafile = OUTPUT_DATA
        else:
            datafile = os.path.join(cwd, OUTPUT_DATA)
    else:
        datafile = OUTPUT_DATA

    packager_path = find_packager();

    if 'PYTHON' in globals():
        python_path = PYTHON
    else:
        python_path = sys.executable

    try:
        res = subprocess.check_output([python_path, packager_path,
                                       datafile,
                                       "--no-heap-copy",
                                       "--preload",
                                       PACKAGE_ARG])
    except:
        error('Error reported by Emscripten packager.')

    if BASE_DIR != '':
        os.chdir(cwd)

    return res

def inject_files(f):
    f.write('<script type="text/javascript">')
    f.write(run_packager())
    f.write("Module['arguments'] = [ './" + EXECUTABLE + "' ];\n</script>\n")

try:
    outf = open(OUTPUT_HTML, 'w')
except Exception, e:
    error('Error opening %s for writing: %s' %( OUTPUT_HTML, (str(e)) ))

with open('dosbox.html') as f:
    for line in iter(f.readline, ''):
        if 'INJECT_HERE' in line:
            inject_files(outf)
            outf.write(line)
        elif '<title>' in line:
            outf.write('    <title>')
            outf.write(sys.argv[1]);
            outf.write('</title>\n')
        else:
            outf.write(line)

outf.close


text:
<?php

namespace Sonata\UserBundle\Twig;

use Sonata\AdminBundle\Admin\AdminInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * GlobalVariables.
 *
 * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
 */
class GlobalVariables
{
    protected $container;

    /**
     * @param ContainerInterface $container
     */
    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    /**
     * @return string
     */
    public function getImpersonating()
    {
        return $this->container->getParameter('sonata.user.impersonating');
    }

    /**
     * @return string
     */
    public function getDefaultAvatar()
    {
        return $this->container->getParameter('sonata.user.default_avatar');
    }

    /**
     * @return AdminInterface
     */
    public function getUserAdmin()
    {
        return $this->container->get('sonata.user.admin.user');
    }
}


text:
using System;
using Prism.Navigation;

namespace PopupPluginSample.ViewModels
{
    public class NavigationRootViewModel : BaseViewModel
    {
        public NavigationRootViewModel(INavigationService navigationService)
            : base(navigationService)
        {
        }
    }
}


text:
class ModelExistenceValidator < ActiveModel::EachValidator

  #
  # Custom Model name validator
  #
  def validate_each(object, attribute, value)
    if value.present?
      if !(Rulez.get_models.map{|m| m.name}.include? value)
        object.errors[attribute] << "must be an existing Model name."
      end
    end
  end
end

#
# Defines a validator for parameters definition
#
class ParametersValidator < ActiveModel::EachValidator

  #
  # Custom paramters definition validator
  #
  def validate_each(object, attribute, value)
    if value.present?
      regex = /\A[A-Za-z_][A-Za-z0-9_]*(, *[A-Za-z_][A-Za-z0-9_]*)*\z/
      if !(value =~ regex)
        object.errors[attribute] << "must be defined separated by comma. Only alphanumeric and \'_\' characters are allowed. Spaces are allowed only after comma."
      end
    end
  end
end

#
# Defines a syntax validator for rulez expressions
#
class SyntaxValidator < ActiveModel::EachValidator

  #
  # Custom expression validator
  #
  def validate_each(object, attribute, value)
    if value
      begin
        Rulez::Parser.parse(value)

        if object.context

          # check all functions
          parsed = Rulez::Parser.functions_list
          parsed = parsed - Rulez.get_methods_class.methods(false).map { |s| s.to_s } #check functions

          parsed = parsed - object.get_parameters_list
          if !parsed.empty?
            object.errors[attribute] << "expression contains invalid variables: #{parsed.join(', ')}."
          end

          # check all variables
          Rulez::Parser.context_variables_list.each do |context_variable|
            # split variable from method
            splitted = context_variable.split('.')
            variable_object = splitted.first
            variable_method = splitted.last

            # check if variable is permitted
            variable_class_name = false
            object.context.variables.each do |s|
              if s.name == variable_object
                variable_class_name = s.model
                break
              end
            end

            # check if variable is permitted
            if variable_class_name
              # check if method is permitted
              valid_methods = (eval "#{variable_class_name}.new.public_methods(false)").map { |e| e.to_s }
              valid_methods += (eval "#{variable_class_name}.new.attribute_names")
              if !valid_methods.include?(variable_method)
                object.errors[attribute] << "not valid: #{variable_method} is not a valid method/attribute for #{variable_object}."
              end
            else
              object.errors[attribute] << "expression contains invalid variable: #{variable_object}."
            end
          end
        end
      rescue Whittle::ParseError => e
        object.errors[attribute] << "is not a valid expression, parse error."
      rescue Rulez::Error => e
        object.errors[attribute] << "something went wrong in the parsing validation."
      rescue StandardError => e
        object.errors[attribute] << "bad things are happening with validator!"
      end
    end
  end
end


text:
// Distrubuted under the MIT license
// ===================================================
// SharpMC uses the permissive MIT license.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// ©Copyright Kenny van Vulpen - 2015
namespace SharpMC.Core.Blocks
{
	internal class BlockFactory
	{
		public static Block GetBlockById(ushort id, short metadata)
		{
			if (id == 1) return new BlockStone() {Metadata = (byte)metadata};
			if (id == 46) return new BlockTnt();
			if (id == 0) return new BlockAir();
			if (id == 51) return new BlockFire();
			if (id == 7) return new BlockBedrock();
			if (id == 3) return new BlockDirt();
			if (id == 2) return new BlockGrass();
			if (id == 16) return new BlockCoalOre();
			if (id == 21) return new BlockLapisLazuliOre();
			if (id == 56) return new BlockDiamondOre();
			if (id == 10) return new BlockFlowingLava();
			if (id == 8) return new BlockFlowingWater();
			if (id == 11) return new BlockFlowingLava();
			if (id == 9) return new BlockFlowingWater();
			if (id == 31 && metadata == 1) return new BlockTallGrass();
			if (id == 5 && metadata == 0) return new OakWoodPlank();
			if (id == 69) return new BlockLever();
			if (id == 55) return new BlockRedstoneDust();
			if (id == 123) return new BlockRedstoneLampInActive();
			if (id == 124) return new BlockRedstoneLampActive();
			if (id == 63) return new BlockStandingSign();

			//Doors
			if (id == 64 || id == 71 || id == 193 ||
				id == 194 || id == 195 || id == 196 ||
				id == 197 || id == 324 || id == 330 ||
				id == 427 || id == 428 || id == 429 ||
				id == 430 || id == 431) return new Door(id);

			//Stairs
			if (id == 67 || id == 53 || id == 108 ||
				id == 109 || id == 114 || id == 128 ||
				id == 134 || id == 135 || id == 136 ||
				id == 156 || id == 163 || id == 164 ||
				id == 180) return new StairsBlock(id);

			//Slabs
			if (id == 44) return new Slab((byte)metadata);
			if (id == 43) return new DoubleSlab((byte)metadata);

			return new Block(id);
		}

		public static Block GetBlockById(ushort id)
		{
			return GetBlockById(id, 0);
		}
	}
}


text:
Code Refactoring
====

Until you've had to live with the same piece of code for a while, you will not experience the need for refactoring.  This lecture tries to summarize what refactoring is, when you need to do it, what patterns and tools are available.  Further, I provide some jGuru examples to illustrate some of the concepts.

These lecture notes paraphrase or quote much content from [Martin Fowler's Refactoring Book](http://www.amazon.com/exec/obidos/ASIN/0201485672/002-9330989-7896037).

Fowler:

  "Any fool can write code that a computer can understand.  Good programmers write code that humans can understand."

# Refactoring?

## What?

Fowler says that refactoring is the

... process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure.

In other words, just cleaning up code. Contrary to waterfall development strategy, for example:

1. analysis and design
1. code
1. test

At first, code is pretty good but as requirements change or new features are added, the code structure tends to atrophy.  Refactoring is the process of fixing a bad or chaotic design.

Amounts to moving methods around, creating new methods, adding or deleting classes, ...

TJP: Sometimes it means completely redoing the entire code base (i.e., throwing stuff away).  But, avoid the _second system effect_!

## Why?

Improve code structure and design

* more maintainable
* easier to understand
* easier to modify
* easier to add new features

Cumulative effect can radically improve design rather than letting it slide into decay.

Flip-flop code development and refactoring.  Only refactor when refactoring--do not add features during refactoring.

TJP: kind of like an immune system that constantly grooms the body looking for offensive and intrusive entities.

Bad code usually takes more code to do the same thing often because of duplication:

![](figures/code.duplication.gif)

TJP: from Fred Brook's "mythical man-month" remember that conceptual integrity is one of his big points.  Addition of new features can break current system conceptual integrity.  Must refactor your concept sometimes as well as your code to make it fit properly.  For example, I integrated page snoopers with search so that I could look for keywords regardless of whether the source was local or on some other page or other some other site's search engine.

Improving design then often includes removing duplicate code.  Don't want duplicates because of bloat and also you only want one place to change functionality not multiple.

Fowler says he will refactor existing code just to understand it better and sometimes it helps to find bugs. TJP I'm not sure I agree with this, unless of course the code needs re-factoring.

In summary, refactoring helps you develop better code, faster!

Kent Beck:

Programs have two kinds of value: what they can do for you today and what they can do for you tomorrow.

Mostly we are focused on today, but you cannot code today so that you cannot code tomorrow.  Actively making the future smoother is a great idea.  When you find tomorrow that today you made a mistake, you use refactoring to fix the decision.

Fowler says database refactoring is super hard.  TJP: things like my entity specifications for jGuru can help.

### When?

When you can't stand the code anymore or it becomes impossible to add new features or fix bugs.

When your boss isn't looking. ;)  There is a lot of pressure not to do work that adds no functionality--shortsighted.

Rule of 3 from Don Roberts:

The first time you do something, you just do it.  The second time you do something similar, you wince at the duplication, but you do the duplicate thing anyway.  The third time you do something similar, you refactor.

Refactor when

1. you add new features and the code is brittle or hard to understand.  Refactoring makes this feature and future features easier to build.
1. you fix bugs.
1. during code review.

### When not to refactor?

1. Sometimes you should throw things out and start again.
1. Sometimes you are too close to a deadline.

## jGuru experience

TJP: Locally-inoptimal refactoring-detours generally lead to a more optimal global solution.  From personal experience, I can say that refactoring is absolutely and totally required to develop a large piece of software in the face of an ever-changing list of features.

*Example 1*: I started with a /search/results.jsp page that worked well for the single task.  Then, had to show only some stuff for nonpremium folks.  Then had to show a "marketing" version of the page.  Finally it was too damn much--couldn't read the code and literally couldn't make it work in all combinations.  After factoring out basically functionality and making separate pages that used the common functionality, I was able to quickly break apart results.jsp into 3 pages that were obvious.

*Example 2*: We started out using a search engine by thunderstone.

1. An employee coded some scripts in Thunderstone's proprietary xml-based programming language to do the right thing when we went to a particular page.  He parsed the results in Java and then displayed it on a jguru-style page.  So far so good.

1. Then we wanted to search other people's sites like slashdot, ibm, sun, etc...  The employee wanted to use the Thunderstone language to grab, parse, and return a simple list of results that can be easily reparsed by jguru and displayed in a jguru page.  I vetoed this suggesting that he get everything into a set of Java classes that did the same thing but that would integrate better into our Java code.  Even though it was more work, I suspected we'd reap a benefit later.  Further, I don't like be tied to a particular tool.  After the effort, we had some "search resource" type objects that could do searches (either remotely or locally via Thunderstone) and display them on jGuru.  We didn't treat our local search differently than a Slashdot search.  Cool!  Sounds good.

1. At this point, we also had some random code lying around that snooped other people's websites for articles.  Bad.  Getting a list of articles is same as getting list of search results (just different remote page).  Duplicated code etc...  Oh well.  We left it.

1. Sure enough, we decided to get rid of thunderstone.  My advice was worth it because no "user level" code changed to incorporate Lucene (new engine).  Yeah!  Unfortunately, there was a huge amount of code duplication among the snooper and search spiders.  I combined these into a nice hierarchy and common functionality.  Now, just about anything can pretend to be a source of search results or snooped information.

1. So then we decided to not do remote searches because everybody else's search engines are so slow and we had lots of them to search.  So, I added code to occasionally walk foreign (remote) sites to get their content (and only the good stuff) and add it to a local Lucene search database.  We get better and faster results because of this, but...

1. Current smelly code: snooper does not add things to search db...I have separate code that fills the foreign search db.  This is because you need the article list and search db to operate independently.  Still, it would be better if the same code did both the snooping and the search db updates.

*Example 3*: An employee built a prototype forum manager.  It had evolved over months and had naturally decayed in code beauty.  I rewrote (since I was only coder employee then) to be better designed and fast etc...  Boy was the new thing beautiful.  Well, as we added more features and so on, it got uglier and uglier.  Still I left it.  Then we realized it was taking forever at start up because it loaded all forum messages up front.  Ok, so I finally redesigned it to load last 3 months worth and do others dynamically.  Actually I knew that I would eventually have this "popularity" problem and it was hanging over me all the time.  Now I don't worry about it. :)

# Re-factoring Patterns TJP likes

I use [Intellij's re-factoring tool](https://www.jetbrains.com/idea/features/refactoring.html).

* [Extract Method](http://www.refactoring.com/catalog/extractMethod.html)
* [Pull up method](http://www.refactoring.com/catalog/pullUpMethod.html)
* [Pull up field](http://refactoring.com/catalog/pullUpField.html)
* Inline method
* Change method signature
* Rename variable, method, class, etc..
* Introduce constant
* Introduce variable
* Move method, static field, class, interface
* [Extract interface](http://refactoring.com/catalog/extractInterface.html)

Useful code generation templates:

* implement methods from interface/superclass
* override method
* generate getter/setters for instance variables
* generate constructor
* generate toString

_Renaming_ is a great idea because code should communicate clearly and variable names are super important (imagine a program where everything is `v1`, `v2`, ...; that is what obfuscaters do).

My first impression was that all of this was not very useful (coming from emacs), but I have come to really rely on the power of these operations.  For example, change method signature changes every reference to that method even for messages to all subclasses of the method's class you change etc...

# Example re-factoring

Refers to [Sample Http Client code](https://github.com/parrt/cs601/blob/master/lectures/code/refactoring/MyClient.java).

Kind of a stream of consciousness as I sniff the code:

Copy MyClient to FooClient or something like that.

1. Rename to HttpClient
2. Move ServerSideJava to a non-nested interface (pull up)
3. Select all, then adjust indentation
4. Rename ErrorManager() to errPage
5. Simplify expression in indexFileHandler() the checks equal to true; there are actually a bunch of those. a simple replace "== true" with "" would work.
6. Rename parameter contentIn in the page methods to message or msg.
7. Extract method: getContentTypeHeader from downloadFile.
8. Notice that `FileInputStream inFile` is not closed; and `try-finally`.
9. Think about moving closeAll() out of download file because it is not a method that does the open. Use "find all references" and noticed that there are about eight or nine. This is a prime example of unstructured programming. Ideally there should be one spot to open and another spot to close socket connections, preferably symmetrically in the same method. Obviously everybody goes all the way back to run() so let's move it there is a `finally` clause.  Yep, now only one is necessary.
10. This makes me start thinking about those fields. `p` is not a very good name; at least we can change it to `pout`.
11. Whoa, I see an element in the stream pipeline that will not be closed because there's no reference to it. Likely this is not a problem as closing the outermost pipe element will close all the intermediary pipes, but for cleanliness let's introduce a variable here:
```java
buf = new BufferedReader(new InputStreamReader(in));
```
becomes
```java
InputStreamReader isr = new InputStreamReader(in);
buf = new BufferedReader(isr);
```
12. This creates a local variable and then we notice that not all of the fields are needed. Whoops.  All of the methods reference `pout`, after renaming, except the download file references `out`, which will jump directly into the middle of an IO stream pipeline. In the end, this code should not be using PrintStream. Rather than do a string replace, which might make me miss one, I'm going to remove that variable so that the compiler tells me where the issues are. All of those `pout.writeln(s)` become `out.write(s.getBytes())`. This removes a lot of cruft and, as we know from our proxy project, we should be using raw bytes to communicate anyway.
13. Of all of these fields:
```java
	Socket socket;
	String docRoot;
	String fileLocation;
	OutputStream out = null;
	InputStream in = null;
	BufferedReader buf;
```
Only the `socket` and `docRoot` make sense and, in this case, only `out` is actually used among the methods. I manually move all but those three locals into `run()`. That means we need to move some things out of the `closeAll` method and into our try finally of `run`:
```java
if ( in!=null ) in.close();
if ( buf!=null ) buf.close();
closeAll();
```
14. At this point, we might as well inline method `closeAll`. (add `if ( out!=null )` to the `close`).
15. It bugs me to have that `out` field as it is totally unnecessary; we can pass that around as a parameter, which then as a side effect makes our functions more reusable. Use "change signature" to add a `OutputStream out` parameter with a default value of out. Do this for both functions that use `out`.
16. Hmm...BufferedReader doesn't make sense because that would assume an encoding and might mess up the byte stream.  We want to replace this line:
```java
InputStreamReader isr = new InputStreamReader(in);
```
with
```java
din = new DataInputStream(in);
```
17. Ok, I changed my mind. Let's only close the outermost IO stream element:
```java
din = new DataInputStream(new BufferedInputStream(in));
```
which means we replace something in the finally:
```java
if ( din!=null ) din.close();
```
18. Local variable `fileLocation` is at the highest level but only used at inner level so let's move it closer to its usage.
19. Local `get` is a bad name because it's a general command perhaps not a get.
20. put this line together:
```java
String[] requestPart;
requestPart = headerLine.split(" ");
```
21. It might be worth extracting a method called `processGet`, that grabs the job and file processing code.  It cleans up the main functionality of `run`, which is really too open the sockets, process, and close up shop.
22. Method `execJava` doesn't use his return value so let's get rid of it, which gets rid of four or five return statements.
23. It seems that the message is the same for all exceptions coming from the server-side Java; They don't track null pointers and so on but we might as well wrap that all up into one exception catcher. We can print the actual type of exception.
24. Since it's easy to do, it looks like we might be able to create a nice superclass from this that is reusable. In preparation, let's rename the class to the specific functionality: `FileAndJavaHttpHandler`. Then, extract superclass and call it `HttpClientHandler`, pulling up the socket, fileLocation, run, and the error page methods. (I had to manually move the fields as they didn't have the right visibility and intellij didn't move them.) We have to make a superclass constructor and also add this default implementation:
```java
public void processGet(OutputStream out, String filePath) throws IOException { }
```
25. Run optimize imports on the files.

Okay, I think it looks pretty good now. The end result files are [HttpClientHandler.java](https://github.com/parrt/cs601/blob/master/lectures/code/refactoring/HttpClientHandler.java) and [FileAndJavaHttpHandler](https://github.com/parrt/cs601/blob/master/lectures/code/refactoring/FileAndJavaHttpHandler.java) and [ServerSideJava.java](https://github.com/parrt/cs601/blob/master/lectures/code/refactoring/ServerSideJava.java).

# Thoughts on IDEs vs emacs (TJP)

Coding/refactoring is part

1. thinking
1. text editing using well-established idioms and patterns
1. questioning (searching, jumping to a class def, finding implementations of methods etc...)
1. cutting-n-pasting / re-factoring / implementing changes

Emacs really only does a good job of 2, which is not a huge percentage of coding.  It is much better to treat your program like a database of code not just plain text.  Being able to quickly see the class hierarchy or find implementors or references of a method is very useful.

After switching to Intellij's IDE (still the best IDE on any platform in my opinion) I became MUCH more productive.  Without code completion of method names and variables, I'd have worse tendonitus i can tell you.


text:
package org.motechproject.outbox.api.service.impl;

import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.motechproject.commons.api.MotechObject;
import org.motechproject.commons.date.util.DateUtil;
import org.motechproject.event.MotechEvent;
import org.motechproject.event.listener.EventRelay;
import org.motechproject.outbox.api.EventKeys;
import org.motechproject.outbox.api.contract.SortKey;
import org.motechproject.outbox.api.domain.OutboundVoiceMessage;
import org.motechproject.outbox.api.domain.OutboundVoiceMessageStatus;
import org.motechproject.outbox.api.repository.AllOutboundVoiceMessages;
import org.motechproject.outbox.api.service.VoiceOutboxService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;

import java.util.Calendar;
import java.util.List;

public class VoiceOutboxServiceImpl extends MotechObject implements VoiceOutboxService {
    private final Logger log = LoggerFactory.getLogger(VoiceOutboxServiceImpl.class);
    private static final String OUTBOUND_VOICE_MESSAGE_ID = "OutboundVoiceMessageId";

    private int numDaysKeepSavedMessages;
    private int maxNumberOfPendingMessages = Integer.MAX_VALUE;

    @Autowired
    private EventRelay eventRelay;

    @Autowired
    private AllOutboundVoiceMessages allOutboundVoiceMessages;

    @Override
    @SuppressWarnings("unchecked")
    public void addMessage(OutboundVoiceMessage outboundVoiceMessage) {
        assertArgumentNotNull("OutboundVoiceMessage", outboundVoiceMessage);
        logInfo("Add message: %s", outboundVoiceMessage);

        outboundVoiceMessage.setStatus(OutboundVoiceMessageStatus.PENDING);
        outboundVoiceMessage.setCreationTime(DateUtil.now().toDate());
        allOutboundVoiceMessages.add(outboundVoiceMessage);

        //sends max-pending-messages event if needed
        String externalId = outboundVoiceMessage.getExternalId();
        Assert.hasText(externalId, "VoiceMessage must have a valid externalId");
        int msgNum = allOutboundVoiceMessages.getMessagesCount(externalId, OutboundVoiceMessageStatus.PENDING);
        if (maxNumberOfPendingMessages == msgNum) {
            log.warn(String.format("Max number (%d) of pending messages reached!", msgNum));
            eventRelay.sendEventMessage(new MotechEvent(EventKeys.OUTBOX_MAX_PENDING_MESSAGES_EVENT_SUBJECT, ArrayUtils.toMap(new Object[][]{{EventKeys.EXTERNAL_ID_KEY, externalId}})));
        }
    }

    @Override
    public OutboundVoiceMessage getNextMessage(String externalId, OutboundVoiceMessageStatus messageStatus) {
        return getNextMessage(externalId, messageStatus, SortKey.CreationTime);
    }

    public OutboundVoiceMessage getNextMessage(String externalId, OutboundVoiceMessageStatus messageStatus, SortKey sortKey) {
        assertArgumentNotEmpty("ExternalId", externalId);
        assertArgumentNotNull("OutboundVoiceMessageStatus", messageStatus);
        assertArgumentNotNull("SortKey", sortKey);
        logInfo("Get next message for the external ID: %s with status %s", externalId, messageStatus);

        List<OutboundVoiceMessage> voiceMessages = allOutboundVoiceMessages.getMessages(externalId, messageStatus, sortKey);
        return voiceMessages.size() > 0 ? voiceMessages.get(0) : null;
    }

    @Override
    public OutboundVoiceMessage getMessageById(String outboundVoiceMessageId) {
        assertArgumentNotEmpty(OUTBOUND_VOICE_MESSAGE_ID, outboundVoiceMessageId);
        logInfo("Get message by ID: %s", outboundVoiceMessageId);
        return allOutboundVoiceMessages.get(outboundVoiceMessageId);
    }

    @Override
    public void removeMessage(String outboundVoiceMessageId) {
        assertArgumentNotEmpty(OUTBOUND_VOICE_MESSAGE_ID, outboundVoiceMessageId);
        logInfo("Remove message ID: %s", outboundVoiceMessageId);
        OutboundVoiceMessage outboundVoiceMessage = getMessageById(outboundVoiceMessageId);
        allOutboundVoiceMessages.safeRemove(outboundVoiceMessage);
    }

    @Override
    public void setMessageStatus(String outboundVoiceMessageId, OutboundVoiceMessageStatus status) {
        assertArgumentNotEmpty(OUTBOUND_VOICE_MESSAGE_ID, outboundVoiceMessageId);
        logInfo("Set status: %s to the message ID: %s", status, outboundVoiceMessageId);
        OutboundVoiceMessage outboundVoiceMessage = allOutboundVoiceMessages.get(outboundVoiceMessageId);
        outboundVoiceMessage.setStatus(status);
        allOutboundVoiceMessages.update(outboundVoiceMessage);
    }

    @Override
    public void saveMessage(String outboundVoiceMessageId) {
        assertArgumentNotEmpty(OUTBOUND_VOICE_MESSAGE_ID, outboundVoiceMessageId);
        logInfo("Save in the outbox message ID: %s", outboundVoiceMessageId);

        OutboundVoiceMessage outboundVoiceMessage = getMessageById(outboundVoiceMessageId);
        outboundVoiceMessage.setStatus(OutboundVoiceMessageStatus.SAVED);

        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DATE, numDaysKeepSavedMessages);
        outboundVoiceMessage.setExpirationDate(calendar.getTime());
        allOutboundVoiceMessages.update(outboundVoiceMessage);
    }

    @Override
    public int getNumberOfMessages(String externalId, OutboundVoiceMessageStatus messageStatus) {
        logInfo("Get number of messages for the external ID: %s", externalId);
        assertArgumentNotEmpty("ExternalID", externalId);
        assertArgumentNotNull("OutboundVoiceMessageStatus", messageStatus);
        return allOutboundVoiceMessages.getMessagesCount(externalId, messageStatus);
    }

    @Override
    public int getNumberOfMessages(String externalId, OutboundVoiceMessageStatus messageStatus, String voiceMessageTypeName) {
        logInfo("Get number of pending messages for the external ID: %s", externalId);
        assertArgumentNotEmpty("ExternalID", externalId);
        assertArgumentNotNull("OutboundVoiceMessageStatus", messageStatus);
        return allOutboundVoiceMessages.getMessagesCount(externalId, messageStatus, voiceMessageTypeName);
    }

    @Override
    public List<OutboundVoiceMessage> getMessages(String externalId, OutboundVoiceMessageStatus status, SortKey sortKey) {
        return allOutboundVoiceMessages.getMessages(externalId, status, sortKey);
    }

    @Override
    public int getNumDaysKeepSavedMessages() {
        return numDaysKeepSavedMessages;
    }

    @Override
    public void setNumDaysKeepSavedMessages(int numDaysKeepSavedMessages) {
        this.numDaysKeepSavedMessages = numDaysKeepSavedMessages;
    }

    @Override
    public void setMaxNumberOfPendingMessages(int maxNumberOfPendingMessages) {
        this.maxNumberOfPendingMessages = maxNumberOfPendingMessages;
    }

    @Override
    public int getMaxNumberOfPendingMessages() {
        return this.maxNumberOfPendingMessages;
    }

    @Override
    public OutboundVoiceMessage nextMessage(String lastMessageId, String externalId) {
        if (StringUtils.isNotEmpty(lastMessageId)) {
            setMessageStatus(lastMessageId, OutboundVoiceMessageStatus.PLAYED);
        }
        return getNextMessage(externalId, OutboundVoiceMessageStatus.PENDING);
    }
}


text:
using System.Threading.Tasks;

namespace MR.AspNetCore.Jobs
{
	/// <summary>
	/// Represents bootstrapping logic. For example, adding initial state to the storage or querying certain entities.
	/// </summary>
	public interface IBootstrapper
	{
		/// <summary>
		/// Bootstraps Jobs. This method also handles starting an <see cref="Server.IProcessingServer"/> implementation.
		/// </summary>
		Task BootstrapAsync();
	}
}


text:
<head>
  <meta charset="UTF-8">
  <link href="http://gmpg.org/xfn/11" rel="profile">

  <!-- Enable responsiveness on mobile devices-->
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">

<!--  <title>
    {% if page.title == "Home" %}
      {{ site.title }} · {{ site.tagline }}
    {% else %}
      {{ page.title }} · {{ site.title }}
    {% endif %}
  </title>-->

  <!-- CSS -->
  <link rel="stylesheet" href="{{ site.baseurl }}/css/style.css">
  <link rel="stylesheet" href="{{ site.baseurl }}/css/blog.css">
  <script src="{{ site.baseurl }}/js/jquery-1.10.0.min.js"></script>
  <title>Route Rater Blog</title>

  <!-- Icons -->
<!--  <link rel="shortcut icon" href="{{ site.baseurl }}public/favicon.ico">-->

  <!-- RSS -->
<!--  <link rel="alternate" type="application/atom+xml" title="{{ site.title }}" href="{{ site.baseurl }}atom.xml">-->
</head>


text:
class CreateLfsObjectsProjects < ActiveRecord::Migration
  DOWNTIME = false

  def change
    create_table :lfs_objects_projects do |t|
      t.integer :lfs_object_id, null: false
      t.integer :project_id, null: false

      t.timestamps null: true
    end

    add_index :lfs_objects_projects, :project_id
  end
end