<commit_before>class AbstractTimelineController < UIViewController
  def self.controller
    @controller ||= alloc.initWithNibName(nil, bundle:nil)
  end

  def viewDidLoad
    super

    view.backgroundColor = UIColor.whiteColor

    @table = UITableView.alloc.initWithFrame(view.bounds, style:UITableViewStylePlain)
    @table.autoresizingMask = UIViewAutoresizingFlexibleHeight
    @table.dataSource = self
    @table.delegate = self

    @refresh = UIRefreshControl.alloc.init
    @refresh.addTarget(self, action:'refreshTimeline', forControlEvents:UIControlEventValueChanged)
    @table.addSubview(@refresh)

    view.addSubview(@table)

    refreshButton = UIBarButtonItem.alloc.initWithBarButtonSystemItem(
      UIBarButtonSystemItemCompose, target:self, action:'compose'
    )
    navigationItem.rightBarButtonItem = refreshButton

    @timeline = []
    load_timeline
    async_load_timeline
  end

  def compose
    composeController = ComposeController.controller
    composeNavigationController = UINavigationController.alloc.init
    composeNavigationController.pushViewController(composeController, animated:false)

    presentModalViewController(composeNavigationController, animated:true)
  end

  def async_load_timeline
    @timer = NSTimer.scheduledTimerWithTimeInterval(
      10, target:self, selector:'load_timeline', userInfo:nil, repeats:true
    )
  end

  def load_data(data)
    Dispatch::Queue.main.sync do
      @timeline = data
      @table.reloadData
    end
  end

  def tableView(tableView, numberOfRowsInSection:section)
    @timeline.size
  end

  def tableView(tableView, heightForRowAtIndexPath:indexPath)
    text = @timeline[indexPath.row]['text']
    font = UIFont.systemFontOfSize(15)
    size = text.sizeWithFont(font, constrainedToSize:[300.0, 640.0], lineBreakMode:NSLineBreakByWordWrapping)
    size.height + 15 + 20 # tweet size + by size + padding
  end

  def tableView(tableView, cellForRowAtIndexPath:indexPath)
    @reuse_id ||= 'TIMELINE_TWEET_CELL'

    cell = tableView.dequeueReusableCellWithIdentifier(@reuse_id)
    cell ||= UITableViewCell.alloc.initWithStyle(
      UITableViewCellStyleSubtitle, reuseIdentifier:@reuse_id
    )
    cell.selectionStyle = UITableViewCellSelectionStyleNone

    cell.textLabel.font = UIFont.boldSystemFontOfSize(15)
    cell.textLabel.text = "@#{@timeline[indexPath.row]['user']['screen_name']}"

    cell.detailTextLabel.font = UIFont.systemFontOfSize(15)
    cell.detailTextLabel.textColor = UIColor.blackColor
    cell.detailTextLabel.numberOfLines = 10
    cell.detailTextLabel.lineBreakMode = NSLineBreakByWordWrapping
    cell.detailTextLabel.text = @timeline[indexPath.row]['text']

    cell
  end

  def refreshTimeline
    load_timeline { @refresh.endRefreshing }
  end

  def refresh
  end

  def account
    App.delegate.account
  end
end
<commit_msg>less frequent timeline updates (rate limit)<commit_after>class AbstractTimelineController < UIViewController
  def self.controller
    @controller ||= alloc.initWithNibName(nil, bundle:nil)
  end

  def viewDidLoad
    super

    view.backgroundColor = UIColor.whiteColor

    @table = UITableView.alloc.initWithFrame(view.bounds, style:UITableViewStylePlain)
    @table.autoresizingMask = UIViewAutoresizingFlexibleHeight
    @table.dataSource = self
    @table.delegate = self

    @refresh = UIRefreshControl.alloc.init
    @refresh.addTarget(self, action:'refreshTimeline', forControlEvents:UIControlEventValueChanged)
    @table.addSubview(@refresh)

    view.addSubview(@table)

    refreshButton = UIBarButtonItem.alloc.initWithBarButtonSystemItem(
      UIBarButtonSystemItemCompose, target:self, action:'compose'
    )
    navigationItem.rightBarButtonItem = refreshButton

    @timeline = []
    load_timeline
    async_load_timeline
  end

  def compose
    composeController = ComposeController.controller
    composeNavigationController = UINavigationController.alloc.init
    composeNavigationController.pushViewController(composeController, animated:false)

    presentModalViewController(composeNavigationController, animated:true)
  end

  def async_load_timeline
    @timer = NSTimer.scheduledTimerWithTimeInterval(
      60, target:self, selector:'load_timeline', userInfo:nil, repeats:true
    )
  end

  def load_data(data)
    Dispatch::Queue.main.sync do
      @timeline = data
      @table.reloadData
    end
  end

  def tableView(tableView, numberOfRowsInSection:section)
    @timeline.size
  end

  def tableView(tableView, heightForRowAtIndexPath:indexPath)
    text = @timeline[indexPath.row]['text']
    font = UIFont.systemFontOfSize(15)
    size = text.sizeWithFont(font, constrainedToSize:[300.0, 640.0], lineBreakMode:NSLineBreakByWordWrapping)
    size.height + 15 + 20 # tweet size + by size + padding
  end

  def tableView(tableView, cellForRowAtIndexPath:indexPath)
    @reuse_id ||= 'TIMELINE_TWEET_CELL'

    cell = tableView.dequeueReusableCellWithIdentifier(@reuse_id)
    cell ||= UITableViewCell.alloc.initWithStyle(
      UITableViewCellStyleSubtitle, reuseIdentifier:@reuse_id
    )
    cell.selectionStyle = UITableViewCellSelectionStyleNone

    cell.textLabel.font = UIFont.boldSystemFontOfSize(15)
    cell.textLabel.text = "@#{@timeline[indexPath.row]['user']['screen_name']}"

    cell.detailTextLabel.font = UIFont.systemFontOfSize(15)
    cell.detailTextLabel.textColor = UIColor.blackColor
    cell.detailTextLabel.numberOfLines = 10
    cell.detailTextLabel.lineBreakMode = NSLineBreakByWordWrapping
    cell.detailTextLabel.text = @timeline[indexPath.row]['text']

    cell
  end

  def refreshTimeline
    load_timeline { @refresh.endRefreshing }
  end

  def refresh
  end

  def account
    App.delegate.account
  end
end

{'fraction_non_alphanumeric': 0.08507670850767085, 'fraction_numerical': 0.007670850767085077, 'mean_word_length': 4.559108527131783, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3099208', 'n_tokens_mistral': 1833, 'n_tokens_neox': 1730, 'n_words': 283}