<commit_before>const renderFunction = (func, name) => {
  const s = func.toString();
  const openParen = s.indexOf("(");
  const closeParen = s.indexOf(")");
  return (
    <li key={name}>
      <code>{name}({s.substr(openParen+1, closeParen-openParen-1)})</code>
    </li>
  )
}

const renderCallback = (callbacks, key) => {
  if (Array.isArray(callbacks)) {
    return (
      <div className="callbacks" key={key}>
        <h4>{key}</h4>
        <ul>
          {_.map(callbacks, (item, key) => <li key={key}><code>{item.name}</code></li>)}
        </ul>
      </div>
    )
  } else {
    return null
  }
}

const Cheatsheet = props => {
  return (
    <div className="cheatsheet">
      <h1>Cheatsheet</h1>

      <div className="cheatsheet-wrapper">

        <div className="cheatsheet-block">
          <h2>Users</h2>
          <h3>Helpers (<code>Users.*</code>)</h3>
          <ul>
            {_.map(Users, (item, key) => (key[0] !== "_" ? renderFunction(item, key) : null) )}
          </ul>
          <h3>Permissions (<code>Users.can.*</code>)</h3>
          <ul>
            {_.map(Users.can, renderFunction)}
          </ul>
          <h3>Roles (<code>Users.is.*</code>)</h3>
          <ul>
            {_.map(Users.is, renderFunction)}
          </ul>
          <h3>Methods</h3>
          <ul>
            {_.map(Meteor.connection._methodHandlers, (item, key) => (key.indexOf("users.") !== -1 ? renderFunction(item, key) : null))}
          </ul>
        </div>

        <div className="cheatsheet-block">
          <h2>Posts</h2>
          <h3>Helpers (<code>Posts.*</code>)</h3>
          <ul>
            {_.map(Posts, (item, key) => (key[0] !== "_" ? renderFunction(item, key) : null) )}
          </ul>
          <h3>Methods</h3>
          <ul>
            {_.map(Meteor.connection._methodHandlers, (item, key) => (key.indexOf("posts.") !== -1 ? renderFunction(item, key) : null))}
          </ul>
        </div>
        
        <div className="cheatsheet-block">
          <h2>Comments</h2>
          <h3>Helpers (<code>Comments.*</code>)</h3>
          <ul>
            {_.map(Comments, (item, key) => (key[0] !== "_" ? renderFunction(item, key) : null) )}
          </ul>
          <h3>Methods</h3>
          <ul>
            {_.map(Meteor.connection._methodHandlers, (item, key) => (key.indexOf("comments.") !== -1 ? renderFunction(item, key) : null))}
          </ul>
        </div><commit_msg>fix cheatsheet SSR<commit_after>const methodList = Meteor.isServer ? Meteor.server.method_handlers : Meteor.connection._methodHandlers;

const renderFunction = (func, name) => {
  const s = func.toString();
  const openParen = s.indexOf("(");
  const closeParen = s.indexOf(")");
  return (
    <li key={name}>
      <code>{name}({s.substr(openParen+1, closeParen-openParen-1)})</code>
    </li>
  )
}

const renderCallback = (callbacks, key) => {
  if (Array.isArray(callbacks)) {
    return (
      <div className="callbacks" key={key}>
        <h4>{key}</h4>
        <ul>
          {_.map(callbacks, (item, key) => <li key={key}><code>{item.name}</code></li>)}
        </ul>
      </div>
    )
  } else {
    return null
  }
}

const Cheatsheet = props => {
  return (
    <div className="cheatsheet">
      <h1>Cheatsheet</h1>

      <div className="cheatsheet-wrapper">

        <div className="cheatsheet-block">
          <h2>Users</h2>
          <h3>Helpers (<code>Users.*</code>)</h3>
          <ul>
            {_.map(Users, (item, key) => (key[0] !== "_" ? renderFunction(item, key) : null) )}
          </ul>
          <h3>Permissions (<code>Users.can.*</code>)</h3>
          <ul>
            {_.map(Users.can, renderFunction)}
          </ul>
          <h3>Roles (<code>Users.is.*</code>)</h3>
          <ul>
            {_.map(Users.is, renderFunction)}
          </ul>
          <h3>Methods</h3>
          <ul>
            {_.map(methodList, (item, key) => (key.indexOf("users.") !== -1 ? renderFunction(item, key) : null))}
          </ul>
        </div>

        <div className="cheatsheet-block">
          <h2>Posts</h2>
          <h3>Helpers (<code>Posts.*</code>)</h3>
          <ul>
            {_.map(Posts, (item, key) => (key[0] !== "_" ? renderFunction(item, key) : null) )}
          </ul>
          <h3>Methods</h3>
          <ul>
            {_.map(methodList, (item, key) => (key.indexOf("posts.") !== -1 ? renderFunction(item, key) : null))}
          </ul>
        </div>
        
        <div className="cheatsheet-block">
          <h2>Comments</h2>
          <h3>Helpers (<code>Comments.*</code>)</h3>
          <ul>
            {_.map(Comments, (item, key) => (key[0] !== "_" ? renderFunction(item, key) : null) )}
          </ul>
          <h3>Methods</h3>
          <ul>
            {_.map(methodList, (item, key) => (key.indexOf("comments.") !== -1 ? renderFunction(item, key) : null))}
          </ul>
        </div>
{'fraction_non_alphanumeric': 0.205007182433819, 'fraction_numerical': 0.01395444284834804, 'mean_word_length': 1.9993846153846153, 'pattern_counts': {'":': 0, '<': 147, '<?xml version=': 0, '>': 167, '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': '972341', 'n_tokens_mistral': 1720, 'n_tokens_neox': 1692, 'n_words': 286}