text:
<?php

/**
 *
 * @file
 * @ingroup Extensions
 * @author James Montalvo
 * @licence MIT License
 */

# Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly.
if ( !defined( 'MEDIAWIKI' ) ) {
	echo <<<EOT
To install this extension, put the following line in LocalSettings.php:
require_once( "$IP/extensions/WatchAnalytics/WatchAnalytics.php" );
EOT;
	exit( 1 );
}

class WatchSuggest {

	/**
	 * @var User $mUser: reference to current user
	 */
	public $mUser;

	/**
	 * @var DatabaseBase $dbr: FIXME confirm correct class
	 */
	public $dbr;

	public function __construct ( User $user ) {
		$this->mUser = $user;
		$this->dbr = wfGetDB( DB_SLAVE );
	}

	/**
	 * Handles something.
	 *
	 * @return bool
	 */
	public function getWatchSuggestionList () {

		$html = '';

		// gets id, NS and title of all pages in users watchlist in NS_MAIN
		$userWatchlist = $this->getUserWatchlist( $this->mUser, NS_MAIN );
		$linkedPages = array();

		// if the user has pages from NS_MAIN in their watchlist then find all
		// pages linked to/from those pages
		if ( count( $userWatchlist ) > 0 ) {
			$linkedPages = $this->getPagesRelatedByLinks( $userWatchlist );
		}

		if ( count( $linkedPages ) == 0 ) {

			// if the users watchlist in NS_MAIN is empty (e.g. probably a new user)
			// create a list of all pages in NS_MAIN as an approximation. Ideally it'd
			// find some other way to suggest pages (by pages the person has viewed, perhaps)
			$noWatchlist = $this->dbr->select(
				'page',
				'page_id',
				'page_namespace = 0',
				__METHOD__
			);

			$linkedPages = array();

			// create "fake" $linkedPages where all pages in NS_MAIN are given the same number
			// of inbound/outbound links from the users watchlist
			while ( $row = $noWatchlist->fetchObject() ) {
				$linkedPages[ $row->page_id ] = array( 'num_links' => 1 );
			}

		}

		$pageWatchQuery = new PageWatchesQuery;
		$pageWatchesAndViews = $pageWatchQuery->getPageWatchesAndViews( array_keys( $linkedPages ) );

		// add newly found number of watchers to linkedPages...
		foreach ( $pageWatchesAndViews as $row ) {
			$linkedPages[ $row->page_id ][ 'num_watches' ] = $row->num_watches;
			$linkedPages[ $row->page_id ][ 'num_views' ] = $row->num_views;
		}

		$sortedPages = $this->sortPagesByWatchImportance( $linkedPages );

		global $wgUser;
		$userIsViewer = $wgUser->getId() == $this->mUser->getId();

		$count = 1;
		$watchSuggestionsTitle = wfMessage( 'pendingreviews-watch-suggestion-title' )->text();
		$watchSuggestionsDescription = wfMessage( 'pendingreviews-watch-suggestion-description' )->text();

		global $egPendingReviewsNumberWatchSuggestions;

		$watchSuggestionsLIs = array();
		foreach( $sortedPages as $pageId => $pageInfo ) {

			$suggestedTitle = Title::newFromID( $pageInfo[ 'page_id' ] );
			if ( ! $suggestedTitle // for some reason some pages in the pagelinks table don't exist in either table page or table archive...
				|| $suggestedTitle->getNamespace() !== 0 // skip pages not in the main namespace
				|| $suggestedTitle->isRedirect() ) { // don't need redirects
				continue;
			}

			// $cats = $suggestedTitle->getParentCategories();
			// if (  )

			if ( $userIsViewer ) {
				$watchLink = '' . self::getWatchLink( $suggestedTitle ) . ': ';
			}
			else {
				$watchLink = '';
			}

			$pageLink = 'getLinkURL() . '">' . $suggestedTitle->getFullText() . '';

			$watchSuggestionsLIs[] = '
' . $watchLink . $pageLink . '
';

			$count++;
			if ( $count > $egPendingReviewsNumberWatchSuggestions ) {
				break;
			}

		}

		$numTopWatchers = 20;

		$html .= "

"
			. "
$watchSuggestionsTitle
"
			. "
$watchSuggestionsDescription
"
			. WatchAnalyticsHtmlHelper::formatListArray( $watchSuggestionsLIs, 2 )
			. '

Watch Leaders
'
			. "
The following $numTopWatchers users are watching the most pages.
"
			. WatchAnalyticsHtmlHelper::formatListArray( $this->getMostWatchesListArray( $numTopWatchers ), 2 );

		return $html;

	}

	public function getUserWatchlist ( User $user, $namespaces = array() ) {

		if ( ! is_array( $namespaces ) ) {
			if ( intval( $namespaces ) < 0 ) {
				throw new MWException( __METHOD__ . ' argument $namespace requires integer or array' );
			}
			$namespaces = array( $namespaces );
		}

		if ( count( $namespaces ) > 1 ) {
			$namespaceCondition = 'AND p.page_namespace IN (' . $this->dbr->makeList( $namespaces ) . ')';
		}
		else if ( count( $namespaces ) === 1 ) {
			$namespaceCondition = 'AND p.page_namespace = ' . $namespaces[0];
		}
		else {
			$namespaceCondition = '';
		}

		$userId = $user->getId();

		// SELECT
		// 	p.page_id AS p_id,
		// 	w.wl_title AS p_title
		// FROM page AS p
		// LEFT JOIN watchlist AS w
		// 	ON (
		// 		w.wl_namespace = p.page_namespace
		// 		AND w.wl_title = p.page_title
		// 	)
		// WHERE
		// 	w.wl_user = $userId
		// 	AND p.page_namespace = 0
		$userWatchlist = $this->dbr->select(
			array(
				'p' => 'page',
				'w' => 'watchlist',
			),
			array(
				'p.page_id AS p_id',
				'w.wl_namespace AS p_namespace',
				'w.wl_title AS p_title',
 			),
			"w.wl_user=$userId " . $namespaceCondition,
			__METHOD__,
			array(), // options
			array(
				'w' => array(
					'LEFT JOIN',
					'w.wl_namespace = p.page_namespace AND w.wl_title = p.page_title'
				)
			)
		);

		$return = array();
		while ( $row = $userWatchlist->fetchObject() ) {
			$return[] = $row;
		}

		return $return;
	}

	public function getPagesRelatedByLinks ( $userWatchlist ) {

		$userWatchlistPageIds = array();
		$userWatchlistPageTitles = array();
		foreach ( $userWatchlist as $row ) {
			$userWatchlistPageIds[] = $row->p_id;

			// FIXME: for now this will only work in NS_MAIN since the next query
			// these are used in assumes NS_MAIN
			$userWatchlistPageTitles[] = $row->p_title;
		}

		$ids = $this->dbr->makeList( $userWatchlistPageIds );
		$titles = $this->dbr->makeList( $userWatchlistPageTitles );

		// SELECT
		// 	pl.pl_from AS pl_from_id,
		// 	p_to.page_id AS pl_to_id
		// FROM pagelinks AS pl
		// INNER JOIN page AS p_to
		// 	ON (
		// 		pl.pl_namespace = p_to.page_namespace
		// 		AND pl.pl_title = p_to.page_title
		// 	)
		// WHERE
		// 	pl.pl_from IN ( <LIST OF all p_id found above> )
		// 	OR ( pl.pl_namespace = 0 AND pl.pl_title IN ( <LIST OF ALL p_title found above> ) )
		$where =
			"pl.pl_from IN ($ids) " .
			" OR ( pl.pl_namespace = 0 AND pl.pl_title IN ($titles) )";

		$linkedPagesResult = $this->dbr->select(
			array(
				'pl' => 'pagelinks',
				'p_to' => 'page',
			),
			array(
				'pl.pl_from AS pl_from_id',
				'p_to.page_id AS pl_to_id',
 			),
			$where,
			__METHOD__,
			array(), // options
			array(
				'p_to' => array(
					'INNER JOIN',
					'pl.pl_namespace = p_to.page_namespace AND pl.pl_title = p_to.page_title'
				),
			)
		);
		$linkedPages = array();
		while ( $row = $linkedPagesResult->fetchObject() ) {
			if ( ! isset( $linkedPages[ $row->pl_from_id ] ) ) {
				$linkedPages[ $row->pl_from_id ] = 1;
			}
			else {
				$linkedPages[ $row->pl_from_id ]++;
			}

			if ( ! isset( $linkedPages[ $row->pl_to_id ] ) ) {
				$linkedPages[ $row->pl_to_id ] = 1;
			}
			else {
				$linkedPages[ $row->pl_to_id ]++;
			}
		}

		$linkedPagesToKeep = array();
		foreach ( $linkedPages as $pageId => $numLinks ) {
			if ( ! in_array( $pageId, $userWatchlistPageIds ) ) {
				$linkedPagesToKeep[ $pageId ] = array( 'num_links' => $numLinks );
			}
		}

		return $linkedPagesToKeep;

	}

	public function sortPagesByWatchImportance ( $pages ) {

		$watches = array();
		$links = array();
		$watchNeedArray = array();
		$sortedPages = array();
		foreach( $pages as $pageId => $pageData ) {
			if ( isset( $pageData[ 'num_watches' ] ) ) {
				$numWatches = intval( $pageData[ 'num_watches' ] );
				$numViews = intval( $pageData[ 'num_views' ] );
			}
			else {
				$numWatches = 0;
				$numViews = 0;
			}
			$numLinks = intval( $pageData[ 'num_links' ] );

			$watchNeed = $numLinks * pow( $numViews, 2 );

			$sortedPages[] = array(
				'page_id' => $pageId,
				'num_watches' => $numWatches,
				'num_links' => $numLinks,
				'num_views' => $numViews,
				'watch_need' => $watchNeed,
			);
			$watches[] = $numWatches;
			$links[] = $numLinks;
			$watchNeedArray[] = $watchNeed;
		}
		array_multisort( $watches, SORT_ASC, $watchNeedArray, SORT_DESC, $sortedPages );

		return $sortedPages;
	}

	// SELECT
	// 	u.user_name AS uname,
	// 	u.user_real_name AS name,
	// 	COUNT( * ) AS user_watches
	// FROM
	// 	watchlist AS w
	// RIGHT JOIN page AS p ON
	// 	(w.wl_namespace = p.page_namespace AND w.wl_title = p.page_title)
	// LEFT JOIN user AS u ON
	// 	(w.wl_user = u.user_id)
	// WHERE
	// 	p.page_is_redirect = 0
	// GROUP BY w.wl_user
	// ORDER BY user_watches DESC
	public function getMostWatchesListArray ( $limit = 20 ) {

		$mostWatches = $this->dbr->select(
			array(
				'w' => 'watchlist',
				'p' => 'page',
				'u' => 'user',
			),
			array(
				'u.user_name AS user_name',
				'u.user_real_name AS real_name',
				'COUNT( * ) AS user_watches',
 			),
			'p.page_is_redirect = 0 AND w.wl_user != 0', // no redirects, and don't include maintenance scripts and other non-users
			__METHOD__,
			array(
				'GROUP BY' => 'w.wl_user',
				'ORDER BY' => 'user_watches DESC',
				'LIMIT' => $limit,
			),
			array(
				'p' => array(
					'RIGHT JOIN',
					'w.wl_namespace = p.page_namespace AND w.wl_title = p.page_title'
				),
				'u' => array(
					'LEFT JOIN',
					'w.wl_user = u.user_id'
				),
			)
		);

		$return = array();
		$count = 0;
		while ( $user = $mostWatches->fetchObject() ) {
			$count++;
			// CONSIDERING usering real name
			// if ( $user->real_name ) {
			// 	$displayName = $user->real_name;
			// }
			// else {
			// 	$displayName = $user->user_name;
			// }

			$watchUser = User::newFromName( $user->user_name );
			if ( $watchUser ) {
				$userPage = $watchUser->getUserPage();
				$userPageLink = Linker::link( $userPage, htmlspecialchars( $userPage->getFullText() ) );

				$watches = '' . $user->user_watches . ' pages watched';

				$return[] = "
$userPageLink - $watches
";
			}

		}

		return $return;

	}

	public static function getWatchLink ( Title $title ) {

		global $wgUser;

		// action=watch&token=9d1186bca6dd20866e607538b92be6c8%2B%5C
		$watchLinkURL = $title->getLinkURL( array(
			'action' => 'watch',
			'token' => WatchAction::getWatchToken( $title, $wgUser ),
		) );

		$watchLink =
			Xml::element(
				'a',
				array(
					'href' => $watchLinkURL,
					'class' => 'pendingreviews-watch-suggest-link',
					'suggest-title-prefixed-text' => $title->getPrefixedDBkey(),
					'thanks-msg' => wfMessage( 'pendingreviews-watch-suggestion-thanks' )->text()// FIXME: there's a better way
				),
				wfMessage( 'pendingreviews-watch-suggestion-watchlink' )->text()
			);

		return $watchLink;

	}

}


text:
define([
        ]
     , function() {

// load sap.m and sap.me
var oCore = sap.ui.getCore();

// mark forced re-load of sap.m events bundle
oCfgData = window["sap-ui-config"]

if(oCfgData.libs.indexOf("sap.m") == -1) {
	oCore.loadLibrary("sap.m");

	oCfgData.libs = oCfgData.libs + ",sap.m";

	if(!sap.ui.Device.support.touch) {
		// unload events bundle
		jQuery.sap.unloadResources("jquery.sap.events.js", false, true, true);
		// reload events bundle to assure that sap.m events are active
		jQuery.sap.require("jquery.sap.events");
	}
}

});// End of closure

redpajama_set_name: RedPajamaGithub


text:
//
//  YRNBluetoothHUD.h
//  Eggs&Beacon
//
//  Created by Mouhcine El Amine on 13/01/14.
//  Copyright (c) 2014 Yron Lab. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface YRNBluetoothHUD : UIView

/**
 *  Shows the bluetooth hud.
 */
+ (void)show;

/**
 *  Hides the bluetooth hud.
 */
+ (void)hide;

/**
 *  Checks whether the hud is visible.
 *
 *  @return YES if the hud is visible, NO otherwise.
 */
+ (BOOL)isVisible;

@end


text:
/**
 * A sample streaming application which indexes tweets live into elastic search
 */

package com.holdenkarau.esspark

import org.apache.spark.streaming.{Seconds, StreamingContext}
import StreamingContext._
import org.apache.spark._
import org.apache.spark.SparkContext._
import org.apache.spark.streaming.twitter._
import org.apache.spark.SparkConf
import org.elasticsearch.hadoop.mr.EsOutputFormat
import org.elasticsearch.hadoop.cfg.ConfigurationOptions;
// sqlcontext
import org.apache.spark.sql._
import org.elasticsearch.spark.sql._
// Hadoop imports
import org.apache.hadoop.mapred.{FileOutputCommitter, FileOutputFormat, JobConf, OutputFormat}
import org.apache.hadoop.fs.Path
import org.apache.hadoop.io.{MapWritable, Text, NullWritable}

object IndexTweetsLive {
  def main(args: Array[String]) {
    if (args.length < 5) {
      System.err.println("Usage IndexTweetsLive <master> <key> <secret key> <access token> <access token secret>  <es-resource> [es-nodes]")
    }
    val Array(master, consumerKey, consumerSecret, accessToken, accessTokenSecret, esResource) = args.take(6)
    val esNodes = args.length match {
        case x: Int if x > 6 => args(6)
        case _ => "localhost"
    }

    SharedIndex.setupTwitter(consumerKey, consumerSecret, accessToken, accessTokenSecret)

    val ssc = new StreamingContext(master, "IndexTweetsLive", Seconds(1))

    val tweets = TwitterUtils.createStream(ssc, None)
    tweets.print()
    // Old way
    /**
    tweets.foreachRDD{(tweetRDD, time) =>
      val sc = tweetRDD.context
      val jobConf = SharedESConfig.setupEsOnSparkContext(sc, esResource, Some(esNodes))
      val tweetsAsMap = tweetRDD.map(SharedIndex.prepareTweets)
      tweetsAsMap.saveAsHadoopDataset(jobConf)
    }
    **/
    // New fancy way
    tweets.foreachRDD{(tweetRDD, time) =>
      val sc = tweetRDD.context
      val sqlCtx = new SQLContext(sc)
      import sqlCtx.createSchemaRDD
      val tweetsAsCS = createSchemaRDD(tweetRDD.map(SharedIndex.prepareTweetsCaseClass))
      tweetsAsCS.saveToEs(esResource)
    }
    println("pandas: sscstart")
    ssc.start()
    println("pandas: awaittermination")
    ssc.awaitTermination()
    println("pandas: done!")
  }
}


text:
const express = require('express'),
    async = require('async'),
    _ = require('lodash')

const config = require('../config');

module.exports.bootstrap = (next) => {
    const app = express();
    _vendorMiddlewares(app);
    _appMiddlewares(app);
    _biz(app);
    _rest(app);
    // Listen
    app.listen(config.app.port);

    next();
}

const _vendorMiddlewares = app => {
    const cors = require('cors'),
        connect = require('connect'),
        cookieParser = require('cookie-parser'),
        expressSession = require('express-session'),
        sessionMongoose = require('session-mongoose'),
        bodyParser = require('body-parser'),
        responseTime = require('response-time'),
        methodOverride = require('method-override');

    // Log response time
    app.use(responseTime());
    // Cross domain
    app.use(cors());
    // Lets you use HTTP verbs such as PUT or DELETE in places where the client doesn't support it.
    app.use(methodOverride());
    // Cookie parser
    app.use(cookieParser(config.app.cookieSecret));
    // Session
    var SessionStore = sessionMongoose(connect);
    var session = expressSession({
        store : new SessionStore({
            interval : 24 * 60 * 60 * 1000,
            connection : mongoose.connection,
            modelName : 'sessions'
        }),
        cookie : {
            maxAge : 365 * 24 * 60 * 60 * 1000
        },
        resave : false,
        saveUninitialized : false,
        secret : config.app.sessionSecret
    })
    app.use(session);
    // Body parser
    app.use(bodyParser.json());
    app.use(bodyParser.urlencoded({
        extended : true
    }));
}

const _appMiddlewares = app => {
	app.use((req, res, next) => {
		// req.
		// res.
		next()
	})
}

const _biz = app => {
    const router = express.Router();
    const biz = require('./biz');

    for (let name in biz) {
        const module = biz[name],
            module.get = module.get || {},
            module.post = module.post || {};

        for (let method in module.get) {
            router.get(`/${name}/${method}`, module.get[method], (req, res) => {});
        }
        for (let method in module.post) {
            router.get(`/${name}/${method}`, module.post[method], (req, res) => {});
        }
    };

    app.use('/services/biz', router)
}

const _rest = app => {
    const restify = require('express-restify-mongoose'),

    const router = express.Router();
    restify.defaults({
        prefix : '',
        version : '',
        // TODO
        // preCreate : validateLogin,
        // preUpdate : validateLogin,
        // preDelete : validateLogin,
        // Whether to use .findOneAndUpdate() or .findById() and then .save(), allowing document middleware to be called. For more information regarding mongoose middleware, read the docs.
        findOneAndUpdate : false,
        findOneAndRemove : false,
        // Handle err thrown by mongoose
        // TODO
        // outputFn
        // onError: _middlewares.errorHandling
    });

    const rest = require('./rest');
    for (var name in rest) {
        var module = rest[name];
        module.options = module.options || {};
        module.options.name = module.options.name || name;
        restify.serve(router, module.model, module.options);
    };
    app.use('/services/rest', router)
}