text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UnityThreading
{
    public static class TaskExtension
    {
        /// <summary>
        /// Sets the name of the task
        /// </summary>
        public static Task WithName(this Task task, string name)
        {
            task.Name = name;
            return task;
        }

        /// <summary>
        /// Sets the name of the task
        /// </summary>
        public static Task<T> WithName<T>(this Task<T> task, string name)
        {
            task.Name = name;
            return task;
        }

        /// <summary>
        /// Waits for the completion of all tasks in the Enumerable.
        /// </summary>
        public static void WaitAll(this IEnumerable<Task> tasks)
        {
            foreach (var task in tasks)
                task.Wait();
        }

        /// <summary>
        /// Starts the given Task when the tasks ended successfully.
        /// </summary>
        /// <param name="followingTask">The task to start.</param>
        /// <param name="target">The DispatcherBase to start the following task on.</param>
        /// <returns>The tasks.</returns>
        public static IEnumerable<Task> Then(this IEnumerable<Task> that, Task followingTask, DispatcherBase target)
        {
            var remaining = that.Count();
            var syncRoot = new object();

            foreach (var task in that)
            {
                task.WhenFailed(() =>
                {
                    if (followingTask.ShouldAbort)
                        return;
                    followingTask.Abort();
                });
                task.WhenSucceeded(() =>
                {
                    if (followingTask.ShouldAbort)
                        return;

                    lock (syncRoot)
                    {
                        remaining--;
                        if (remaining == 0)
                        {
                            if (target != null)
                                followingTask.Run(target);
                            else if (ThreadBase.CurrentThread is TaskWorker)
                                followingTask.Run(((TaskWorker)ThreadBase.CurrentThread).TaskDistributor);
                            else
                                followingTask.Run();
                        }
                    }
                });
            }
            return that;
        }

        /// <summary>
        /// Starts the given Action when all Tasks ended successfully.
        /// </summary>
        /// <param name="action">The action to start.</param>
        /// <param name="target">The DispatcherBase to start the following action on.</param>
        /// <returns>The tasks.</returns>
        public static IEnumerable<Task> WhenSucceeded(this IEnumerable<Task> that, Action action, DispatcherBase target)
        {
            var remaining = that.Count();
            var syncRoot = new object();

            foreach (var task in that)
            {
                task.WhenSucceeded(() =>
                {
                    lock (syncRoot)
                    {
                        remaining--;
                        if (remaining == 0)
                        {
                            if (target == null)
                                action();
                            else
                                target.Dispatch(() => {
                                    action(); });
                        }
                    }
                });
            }
            return that;
        }

        /// <summary>
        /// Starts the given Action when one task has not successfully ended
        /// </summary>
        /// <param name="action">The action to start.</param>
        /// <param name="target">The DispatcherBase to start the following action on.</param>
        /// <returns>The tasks.</returns>
        public static IEnumerable<Task> WhenFailed(this IEnumerable<Task> that, Action action, DispatcherBase target)
        {
            var hasFailed = false;
            var syncRoot = new object();
            foreach (var task in that)
            {
                task.WhenFailed(() =>
                {
                    lock (syncRoot)
                    {
                        if (hasFailed)
                            return;
                        hasFailed = true;

                        if (target == null)
                            action();
                        else
                            target.Dispatch(() => {
                                action(); });
                    }
                });
            }
            return that;
        }

        /// <summary>
        /// Invokes the given action with the set result of the task when the task succeeded.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <returns>This task.</returns>
        public static Task OnResult(this Task task, Action<object> action)
        {
            return task.OnResult(action, null);
        }

        /// <summary>
        /// Invokes the given action with the set result of the task when the task succeeded.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <param name="target">The DispatcherBase to perform the action on.</param>
        /// <returns>This task.</returns>
        public static Task OnResult(this Task task, Action<object> action, DispatcherBase target)
        {
            return task.WhenSucceeded(t => action(t.RawResult), target);
        }

        /// <summary>
        /// Invokes the given action with the set result of the task when the task succeeded.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <returns>This task.</returns>
        public static Task OnResult<T>(this Task task, Action<T> action)
        {
            return task.OnResult<T>(action, null);
        }

        /// <summary>
        /// Invokes the given action with the set result of the task when the task succeeded.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <param name="target">The DispatcherBase to perform the action on.</param>
        /// <returns>This task.</returns>
        public static Task OnResult<T>(this Task task, Action<T> action, DispatcherBase target)
        {
            return task.WhenSucceeded(t => action((T)t.RawResult), target);
        }

        /// <summary>
        /// Invokes the given action with the set result of the task when the task succeeded.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <returns>This task.</returns>
        public static Task<T> OnResult<T>(this Task<T> task, Action<T> action)
        {
            return task.OnResult<T>(action, null);
        }

        /// <summary>
        /// Invokes the given action with the set result of the task when the task succeeded.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <param name="target">The DispatcherBase to perform the action on.</param>
        /// <returns>This task.</returns>
        public static Task<T> OnResult<T>(this Task<T> task, Action<T> action, DispatcherBase actionTarget)
        {
            return task.WhenSucceeded<T>(t => action(t.Result), actionTarget);
        }

      #region Succeeded

        /// <summary>
        /// The given Action will be performed when the task succeeds.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <returns>This task.</returns>
        public static Task<T> WhenSucceeded<T>(this Task<T> task, Action action)
        {
            return task.WhenSucceeded<T>(t => action(), null);
        }

        /// <summary>
        /// The given Action will be performed when the task succeeds.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <returns>This task.</returns>
        public static Task<T> WhenSucceeded<T>(this Task<T> task, Action<Task<T>> action)
        {
            return task.WhenSucceeded<T>(action, null);
        }

        /// <summary>
        /// The given Action will be performed when the task succeeds.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <param name="target">The DispatcherBase to perform the action on.</param>
        /// <returns>This task.</returns>
        public static Task<T> WhenSucceeded<T>(this Task<T> task, Action<Task<T>> action, DispatcherBase target)
        {
            Action<Task<T>> perform = t =>
            {
                if (target == null)
                    action(t);
                else
                    target.Dispatch(() => {
                        if (t.IsSucceeded)
                            action(t); });
            };

            return task.WhenEnded<T>(t => {
                if (t.IsSucceeded)
                    perform(t); }, null);
        }

        /// <summary>
        /// The given Action will be performed when the task succeeds.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <returns>This task.</returns>
        public static Task WhenSucceeded(this Task task, Action action)
        {
            return task.WhenEnded(t => {
                if (t.IsSucceeded)
                    action(); });
        }

        /// <summary>
        /// The given Action will be performed when the task succeeds.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <returns>This task.</returns>
        public static Task WhenSucceeded(this Task task, Action<Task> action)
        {
            return task.WhenEnded(t => {
                if (t.IsSucceeded)
                    action(t); });
        }

        /// <summary>
        /// The given Action will be performed when the task succeeds.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <param name="target">The DispatcherBase to perform the action on.</param>
        /// <returns>This task.</returns>
        public static Task WhenSucceeded(this Task task, Action<Task> action, DispatcherBase actiontargetTarget)
        {
            Action<Task> perform = t =>
            {
                if (actiontargetTarget == null)
                    action(t);
                else
                    actiontargetTarget.Dispatch(() => {
                        if (t.IsSucceeded)
                            action(t); });
            };

            return task.WhenEnded(t => {
                if (t.IsSucceeded)
                    perform(t); }, null);
        }

      #endregion

      #region Failed

        /// <summary>
        /// The given Action will be performed when the task fails.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <returns>This task.</returns>
        public static Task<T> WhenFailed<T>(this Task<T> task, Action action)
        {
            return task.WhenFailed<T>(t => action(), null);
        }

        /// <summary>
        /// The given Action will be performed when the task fails.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <returns>This task.</returns>
        public static Task<T> WhenFailed<T>(this Task<T> task, Action<Task<T>> action)
        {
            return task.WhenFailed<T>(action, null);
        }

        /// <summary>
        /// The given Action will be performed when the task fails.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <param name="target">The DispatcherBase to perform the action on.</param>
        /// <returns>This task.</returns>
        public static Task<T> WhenFailed<T>(this Task<T> task, Action<Task<T>> action, DispatcherBase target)
        {
            return task.WhenEnded<T>(t => {
                if (t.IsFailed)
                    action(t); }, target);
        }

        /// <summary>
        /// The given Action will be performed when the task fails.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <returns>This task.</returns>
        public static Task WhenFailed(this Task task, Action action)
        {
            return task.WhenEnded(t => {
                if (t.IsFailed)
                    action(); });
        }

        /// <summary>
        /// The given Action will be performed when the task fails.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <returns>This task.</returns>
        public static Task WhenFailed(this Task task, Action<Task> action)
        {
            return task.WhenEnded(t => {
                if (t.IsFailed)
                    action(t); });
        }

        /// <summary>
        /// The given Action will be performed when the task fails.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <param name="target">The DispatcherBase to perform the action on.</param>
        /// <returns>This task.</returns>
        public static Task WhenFailed(this Task task, Action<Task> action, DispatcherBase target)
        {
            return task.WhenEnded(t => {
                if (t.IsFailed)
                    action(t); }, target);
        }

      #endregion

      #region Ended

        /// <summary>
        /// The given Action will be performed when the task ends.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <returns>This task.</returns>
        public static Task<T> WhenEnded<T>(this Task<T> task, Action action)
        {
            return task.WhenEnded<T>(t => action(), null);
        }

        /// <summary>
        /// The given Action will be performed when the task ends.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <returns>This task.</returns>
        public static Task<T> WhenEnded<T>(this Task<T> task, Action<Task<T>> action)
        {
            return task.WhenEnded<T>(action, null);
        }

        /// <summary>
        /// The given Action will be performed when the task ends.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <param name="target">The DispatcherBase to perform the action on.</param>
        /// <returns>This task.</returns>
        public static Task<T> WhenEnded<T>(this Task<T> task, Action<Task<T>> action, DispatcherBase target)
        {
            task.TaskEnded += t =>
            {
                if (target == null)
                    action(task);
                else
                    target.Dispatch(() => action(task));
            };

            return task;
        }

        /// <summary>
        /// The given Action will be performed when the task ends.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <returns>This task.</returns>
        public static Task WhenEnded(this Task task, Action action)
        {
            return task.WhenEnded(t => action());
        }

        /// <summary>
        /// The given Action will be performed when the task ends.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <returns>This task.</returns>
        public static Task WhenEnded(this Task task, Action<Task> action)
        {
            return task.WhenEnded(t => action(t), null);
        }

        /// <summary>
        /// The given Action will be performed when the task ends.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <param name="target">The DispatcherBase to perform the action on.</param>
        /// <returns>This task.</returns>
        public static Task WhenEnded(this Task task, Action<Task> action, DispatcherBase target)
        {
            task.TaskEnded += (t) =>
            {
                if (target == null)
                    action(task);
                else
                    target.Dispatch(() => action(task));
            };

            return task;
        }

      #endregion

        /// <summary>
        /// Starts the given Task when this Task ended successfully.
        /// </summary>
        /// <param name="followingTask">The task to start.</param>
        /// <returns>This task.</returns>
        public static Task Then(this Task that, Task followingTask)
        {
            TaskDistributor target = null;
            if (ThreadBase.CurrentThread is TaskWorker)
                target = ((TaskWorker)ThreadBase.CurrentThread).TaskDistributor;

            return that.Then(followingTask, target);
        }

        /// <summary>
        /// Starts the given Task when this Task ended successfully.
        /// </summary>
        /// <param name="followingTask">The task to start.</param>
        /// <param name="target">The DispatcherBase to start the following task on.</param>
        /// <returns>This task.</returns>
        public static Task Then(this Task that, Task followingTask, DispatcherBase target)
        {
            that.WhenFailed(() =>
            {
                followingTask.Abort();
            });
            that.WhenSucceeded(() =>
            {
                if (target != null)
                    followingTask.Run(target);
                else if (ThreadBase.CurrentThread is TaskWorker)
                    followingTask.Run(((TaskWorker)ThreadBase.CurrentThread).TaskDistributor);
                else
                    followingTask.Run();
            });
            return that;
        }

        /// <summary>
        /// Starts this Task when the other Task ended successfully.
        /// </summary>
        /// <param name="followingTask">The task to await.</param>
        /// <returns>This task.</returns>
        public static Task Await(this Task that, Task taskToWaitFor)
        {
            taskToWaitFor.Then(that);
            return that;
        }

        /// <summary>
        /// Starts this Task when the other Task ended successfully.
        /// </summary>
        /// <param name="followingTask">The task to await.</param>
        /// <param name="target">The DispatcherBase to start this task on.</param>
        /// <returns>This task.</returns>
        public static Task Await(this Task that, Task taskToWaitFor, DispatcherBase target)
        {
            taskToWaitFor.Then(that, target);
            return that;
        }

        /// <summary>
        /// Converts this Task.
        /// </summary>
        /// <param name="that"></param>
        /// <returns>The converted task.</returns>
        public static Task<T> As<T>(this Task that)
        {
            return (Task<T>)that;
        }

        /// <summary>
        /// Starts the given Action when any Task in the Enumerable has ended.
        /// </summary>
        /// <param name="action">The action to start.</param>
        /// <returns>This Enumerable of Tasks.</returns>
        public static IEnumerable<Task> ContinueWhenAnyEnded(this IEnumerable<Task> tasks, Action action)
        {
            return tasks.ContinueWhenAnyEnded(t => action());
        }

        /// <summary>
        /// Starts the given Action when any Task in the Enumerable has ended.
        /// </summary>
        /// <param name="action">The action to start.</param>
        /// <returns>This Enumerable of Tasks.</returns>
        public static IEnumerable<Task> ContinueWhenAnyEnded(this IEnumerable<Task> tasks, Action<Task> action)
        {
            var syncRoot = new object();
            var done = false;
            foreach (var task in tasks)
            {
                task.WhenEnded(t =>
                {
                    lock (syncRoot)
                    {
                        if (done)
                            return;

                        done = true;
                        action(t);
                    }
                });
            }

            return tasks;
        }

        /// <summary>
        /// Starts the given Action when all Tasks in the Enumerable have ended.
        /// </summary>
        /// <param name="action">The action to start.</param>
        /// <returns>This Enumerable of Tasks.</returns>
        public static IEnumerable<Task> ContinueWhenAllEnded(this IEnumerable<Task> tasks, Action action)
        {
            return tasks.ContinueWhenAllEnded(t => action());
        }

        /// <summary>
        /// Starts the given Action when all Tasks in the Enumerable have ended.
        /// </summary>
        /// <param name="action">The action to start.</param>
        /// <returns>This Enumerable of Tasks.</returns>
        public static IEnumerable<Task> ContinueWhenAllEnded(this IEnumerable<Task> tasks, Action<IEnumerable<Task>> action)
        {
            var count = tasks.Count();

            if (count == 0)
                action(new Task[0]);

            var finishedTasks = new List<Task>();
            var syncRoot = new object();

            foreach (var task in tasks)
            {
                task.WhenEnded(t =>
                {
                    lock (syncRoot)
                    {
                        finishedTasks.Add(task);
                        if (finishedTasks.Count == count)
                            action(finishedTasks);
                    }
                });
            }

            return tasks;
        }
    }
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>All Classes</title>
<meta name="date" content="2014-04-04">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">

All Classes

AllTopicPageActivity

BitmapConverter

BuildConfig

CacheController

Comment

CommentList

CommentMap

CommentPageActivity

ConnectionChecker

CreateCommentPageActivity

CustomLocationLoader

EditCommentPageActivity

ElasticSearchResponse

FavoritePageActivity

GsonConstructor

IdSet

IoStreamHandler

ListViewAdapter

LocalCommentPageActivity

LocationComparator

LocationConverter

LocationGenerator

LoginViewActivity

NetworkObserver

OtherProfilePageActivity

PictureComparator

ProfileIoHandler

ProfilePageActivity

R

R.attr

R.dimen

R.drawable

R.id

R.layout

R.menu

R.string

R.style

ScoreSystem

TimeComparator

UserNameHandler

UserProfile

redpajama_set_name: RedPajamaGithub


text:
package org.devocative.wickomp.demo.service.ssh;

public interface IAsyncResult {
	void onMessage(String text);
}


text:
using System.Collections.Generic;

namespace EventStoreLite
{
    internal class EventStream
    {
        public EventStream()
        {
            History = new List<IDomainEvent>();
        }

        public string Id { get; set; }

        public List<IDomainEvent> History { get; internal set; }
    }
}


text:
"use strict";

define(function()
{
   var EnvironmentAction = {};

   EnvironmentAction.ADD_ROUND = "addRound";
   EnvironmentAction.DISCARD_DAMAGE = "discardDamage";
   EnvironmentAction.DRAW_DAMAGE = "drawDamage";
   EnvironmentAction.MOVE_TOKEN = "moveToken";
   EnvironmentAction.PLACE_TOKEN = "placeToken";
   EnvironmentAction.REMOVE_TOKEN = "removeToken";
   EnvironmentAction.REMOVE_TOKEN_AT = "removeTokenAt";
   EnvironmentAction.REPLENISH_DAMAGE_DECK = "replenishDamageDeck";
   EnvironmentAction.SET_ACTIVE_TOKEN = "setActiveToken";
   EnvironmentAction.SET_DAMAGE_DECK = "setDamageDeck";
   EnvironmentAction.SET_FIRST_AGENT = "setFirstAgent";
   EnvironmentAction.SET_FIRST_SQUAD = "setFirstSquad";
   EnvironmentAction.SET_PLAY_AREA_SCALE = "setPlayAreaScale";
   EnvironmentAction.SET_PLAY_FORMAT = "setPlayFormat";
   EnvironmentAction.SET_SECOND_AGENT = "setSecondAgent";
   EnvironmentAction.SET_SECOND_SQUAD = "setSecondSquad";
   EnvironmentAction.SET_TOKEN_TOUCHING = "setTokenTouching";

   EnvironmentAction.addRound = function(value)
   {
      var myValue = (value !== undefined ? value : 1);

      return (
      {
         type: EnvironmentAction.ADD_ROUND,
         value: myValue,
      });
   };

   EnvironmentAction.discardDamage = function(damage)
   {
      InputValidator.validateNotNull("damage", damage);

      return (
      {
         type: EnvironmentAction.DISCARD_DAMAGE,
         damage: damage,
      });
   };

   EnvironmentAction.drawDamage = function(damage)
   {
      InputValidator.validateNotNull("damage", damage);

      return (
      {
         type: EnvironmentAction.DRAW_DAMAGE,
         damage: damage,
      });
   };

   EnvironmentAction.moveToken = function(fromPosition, toPosition)
   {
      InputValidator.validateNotNull("fromPosition", fromPosition);
      InputValidator.validateNotNull("toPosition", toPosition);

      return (
      {
         type: EnvironmentAction.MOVE_TOKEN,
         fromPosition: fromPosition,
         toPosition: toPosition,
      });
   };

   EnvironmentAction.placeToken = function(position, token)
   {
      InputValidator.validateNotNull("position", position);
      InputValidator.validateNotNull("token", token);
      InputValidator.validateIsFunction("token.id", token.id);

      return (
      {
         type: EnvironmentAction.PLACE_TOKEN,
         position: position,
         token: token,
      });
   };

   EnvironmentAction.removeToken = function(token)
   {
      InputValidator.validateNotNull("token", token);

      return (
      {
         type: EnvironmentAction.REMOVE_TOKEN,
         token: token,
      });
   };

   EnvironmentAction.removeTokenAt = function(position)
   {
      InputValidator.validateNotNull("position", position);

      return (
      {
         type: EnvironmentAction.REMOVE_TOKEN_AT,
         position: position,
      });
   };

   EnvironmentAction.replenishDamageDeck = function()
   {
      return (
      {
         type: EnvironmentAction.REPLENISH_DAMAGE_DECK,
      });
   };

   EnvironmentAction.setActiveToken = function(token)
   {
      return (
      {
         type: EnvironmentAction.SET_ACTIVE_TOKEN,
         token: token,
      });
   };

   EnvironmentAction.setDamageDeck = function(damageDeck)
   {
      InputValidator.validateNotNull("damageDeck", damageDeck);

      return (
      {
         type: EnvironmentAction.SET_DAMAGE_DECK,
         damageDeck: damageDeck,
      });
   };

   EnvironmentAction.setFirstAgent = function(agent)
   {
      InputValidator.validateNotNull("agent", agent);

      return (
      {
         type: EnvironmentAction.SET_FIRST_AGENT,
         agent: agent,
      });
   };

   EnvironmentAction.setFirstSquad = function(squad)
   {
      InputValidator.validateNotNull("squad", squad);

      return (
      {
         type: EnvironmentAction.SET_FIRST_SQUAD,
         squad: squad,
      });
   };

   EnvironmentAction.setPlayAreaScale = function(scale)
   {
      InputValidator.validateNotNull("scale", scale);

      return (
      {
         type: EnvironmentAction.SET_PLAY_AREA_SCALE,
         scale: scale,
      });
   };

   EnvironmentAction.setPlayFormat = function(playFormatKey)
   {
      InputValidator.validateNotNull("playFormatKey", playFormatKey);

      return (
      {
         type: EnvironmentAction.SET_PLAY_FORMAT,
         playFormatKey: playFormatKey,
      });
   };

   EnvironmentAction.setSecondAgent = function(agent)
   {
      InputValidator.validateNotNull("agent", agent);

      return (
      {
         type: EnvironmentAction.SET_SECOND_AGENT,
         agent: agent,
      });
   };

   EnvironmentAction.setSecondSquad = function(squad)
   {
      InputValidator.validateNotNull("squad", squad);

      return (
      {
         type: EnvironmentAction.SET_SECOND_SQUAD,
         squad: squad,
      });
   };

   EnvironmentAction.setTokenTouching = function(token, isTouching)
   {
      InputValidator.validateNotNull("token", token);
      InputValidator.validateIsBoolean("isTouching", isTouching);

      return (
      {
         type: EnvironmentAction.SET_TOKEN_TOUCHING,
         token: token,
         isTouching: isTouching,
      });
   };

   if (Object.freeze)
   {
      Object.freeze(EnvironmentAction);
   }

   return EnvironmentAction;
});


text:
module X86_64 where

import HakeTypes
import Path
import qualified Config
import qualified ArchDefaults

-------------------------------------------------------------------------
--
-- Architecture specific definitions for x86_64
--
-------------------------------------------------------------------------

arch = "x86_64"
archFamily = "x86_64"
compiler = "gcc"
cxxcompiler = "g++"

ourCommonFlags = [ Str "-m64",
                   Str "-mno-red-zone",
                   Str "-fPIE",
                   Str "-fno-stack-protector",
		   Str "-Wno-unused-but-set-variable",
                   Str "-Wno-packed-bitfield-compat",
                   Str "-D__x86__" ]

cFlags = ArchDefaults.commonCFlags
               ++ ArchDefaults.commonFlags
               ++ ourCommonFlags

cxxFlags = ArchDefaults.commonCxxFlags
                 ++ ArchDefaults.commonFlags
                 ++ ourCommonFlags

cDefines = ArchDefaults.cDefines options

ourLdFlags = [ Str "-Wl,-z,max-page-size=0x1000",
               Str "-Wl,--build-id=none",
               Str "-m64" ]

ldFlags = ArchDefaults.ldFlags arch ++ ourLdFlags
ldCxxFlags = ArchDefaults.ldCxxFlags arch ++ ourLdFlags

options = (ArchDefaults.options arch archFamily) {
            optFlags = cFlags,
            optCxxFlags = cxxFlags,
            optDefines = cDefines,
            optLdFlags = ldFlags,
            optLdCxxFlags = ldCxxFlags,
            optInterconnectDrivers = ["lmp", "ump", "multihop"],
            optFlounderBackends = ["lmp", "ump", "multihop"]
          }

--
-- The kernel is "different"
--

kernelCFlags = [ Str s | s <- [ "-fno-builtin",
                                "-nostdinc",
                                "-std=c99",
                                "-m64",
                                "-mno-red-zone",
                                "-fPIE",
                                "-fno-stack-protector",
                                "-U__linux__",
                                "-Wall",
                                "-Wshadow",
                                "-Wstrict-prototypes",
                                "-Wold-style-definition",
                                "-Wmissing-prototypes",
                                "-Wmissing-declarations",
                                "-Wmissing-field-initializers",
                                "-Wredundant-decls",
                                "-Wno-packed-bitfield-compat",
				"-Wno-unused-but-set-variable",
                                "-Werror",
                                "-imacros deputy/nodeputy.h",
                                "-mno-mmx",
                                "-mno-sse",
                                "-mno-sse2",
                                "-mno-sse3",
                                "-mno-sse4.1",
                                "-mno-sse4.2",
--		  		"-Wno-unused-but-set-variable",
                                "-mno-sse4",
                                "-mno-sse4a",
                                "-mno-3dnow" ]]

kernelLdFlags = [ Str s | s <- [ "-Wl,-N",
                                "-pie",
                                 "-fno-builtin",
                                "-nostdlib",
                                "-Wl,--fatal-warnings",
                                "-m64" ] ]

------------------------------------------------------------------------
--
-- Now, commands to actually do something
--
------------------------------------------------------------------------

--
-- Compilers
--
cCompiler = ArchDefaults.cCompiler arch compiler
cxxCompiler = ArchDefaults.cxxCompiler arch cxxcompiler
makeDepend = ArchDefaults.makeDepend arch compiler
makeCxxDepend  = ArchDefaults.makeCxxDepend arch cxxcompiler
cToAssembler = ArchDefaults.cToAssembler arch compiler
assembler = ArchDefaults.assembler arch compiler
archive = ArchDefaults.archive arch
linker = ArchDefaults.linker arch compiler
cxxlinker = ArchDefaults.cxxlinker arch cxxcompiler

--
-- Link the kernel (CPU Driver)
--
linkKernel :: Options -> [String] -> [String] -> String -> HRule
linkKernel opts objs libs kbin =
    let linkscript = "/kernel/linker.lds"
    in
      Rules [ Rule ([ Str compiler, Str Config.cOptFlags,
                      NStr "-T", In BuildTree arch "/kernel/linker.lds",
                      Str "-o", Out arch kbin
                    ]
                    ++ (optLdFlags opts)
                    ++
                    [ In BuildTree arch o | o <- objs ]
                    ++
                    [ In BuildTree arch l | l <- libs ]
                    ++
                    [ NL, NStr "/bin/echo -e '\\0002' | dd of=",
                      Out arch kbin,
                      Str "bs=1 seek=16 count=1 conv=notrunc status=noxfer"
                    ]
                   ),
              Rule [ Str "cpp",
                     NStr "-I", NoDep SrcTree "src" "/kernel/include/",
                     Str "-D__ASSEMBLER__",
                     Str "-P", In SrcTree "src" "/kernel/arch/x86_64/linker.lds.in",
                     Out arch linkscript
                   ]
            ]


text:
package org.onosproject.ui;

import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.HostId;
import org.onosproject.net.link.LinkEvent;
import org.onosproject.ui.topo.PropertyPanel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

/**
 * Represents user interface topology view overlay.
 *

 * This base class does little more than provide a logger and an identifier.
 * Subclasses will probably want to override some or all of the base methods
 * to do useful things during the life-cycle of the overlay.
 */
public class UiTopoOverlay {

    /**
     * Logger for this overlay.
     */
    protected final Logger log = LoggerFactory.getLogger(getClass());

    private final String id;

    private boolean isActive = false;

    /**
     * Creates a new user interface topology view overlay descriptor, with
     * the given identifier.
     *
     * @param id overlay identifier
     */
    public UiTopoOverlay(String id) {
        this.id = id;
    }

    /**
     * Returns the identifier for this overlay.
     *
     * @return the identifier
     */
    public String id() {
        return id;
    }

    /**
     * Callback invoked to initialize this overlay, soon after creation.
     * This default implementation does nothing.
     */
    public void init() {
    }

    /**
     * Callback invoked when this overlay is activated.
     */
    public void activate() {
        isActive = true;
    }

    /**
     * Callback invoked when this overlay is deactivated.
     */
    public void deactivate() {
        isActive = false;
    }

    /**
     * Returns true if this overlay is currently active.
     *
     * @return true if overlay active
     */
    public boolean isActive() {
        return isActive;
    }

    /**
     * Callback invoked to destroy this instance by cleaning up any
     * internal state ready for garbage collection.
     * This default implementation holds no state and does nothing.
     */
    public void destroy() {
    }

    /**
     * Callback to modify the contents of the summary panel.
     * This default implementation does nothing.
     *
     * @param pp property panel model of summary data
     */
    public void modifySummary(PropertyPanel pp) {
    }

    /**
     * Callback to modify the contents of the details panel for
     * a selected device.
     * This default implementation does nothing.
     *
     * @param pp       property panel model of device data
     * @param deviceId device id
     */
    public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) {
    }

    /**
     * Callback to modify the contents of the details panel for
     * a selected host.
     * This default implementation does nothing.
     *
     * @param pp     property panel model of host data
     * @param hostId host id
     */
    public void modifyHostDetails(PropertyPanel pp, HostId hostId) {
    }

    /**
     * Callback to modify the contents of the details panel for a selected
     * edge link. The parameters include identifiers for the host and the
     * connect point (device and port) to which the host is connected.
     *

     * This default implementation does nothing.
     *
     * @param pp     property panel model of edge link data
     * @param hostId host ID
     * @param cp     connect point
     */
    public void modifyEdgeLinkDetails(PropertyPanel pp,
                                      HostId hostId, ConnectPoint cp) {
    }

    /**
     * Callback to modify the contents of the details panel for a selected
     * infrastructure link. The parameters include the two connect points
     * at either end of the link.
     *

     * Note that links in the topology view are (usually) "bi-directional",
     * meaning that both {@literal A-->B} and {@literal B-->A} backing links
     * exist. If, however, there is only one backing link, it is guaranteed
     * to be {@literal A-->B}.
     *

     * This default implementation does nothing.
     *
     * @param pp  property panel model of infrastructure link data
     * @param cpA connect point A
     * @param cpB connect point B
     */
    public void modifyInfraLinkDetails(PropertyPanel pp,
                                       ConnectPoint cpA, ConnectPoint cpB) {
    }

    /**
     * Callback invoked when a link event is processed (e.g. link added).
     * A subclass may override this method to return a map of property
     * key/value pairs to be included in the JSON event back to the client,
     * so that those additional properties are available to be displayed as
     * link details.
     *

     * The default implementation returns {@code null}, that is, no additional
     * properties to be added.
     *
     * @param event the link event
     * @return map of additional key/value pairs to be added to the JSON event
     * @deprecated this is a temporary addition for Goldeneye (1.6) release,
     * and is superceded by use of {@link #modifyEdgeLinkDetails} and
     * {@link #modifyInfraLinkDetails}.
     */
    @Deprecated
    public Map<String, String> additionalLinkData(LinkEvent event) {
        return null;
    }
}


text:
@interface MREIncrementalStore : PFIncrementalStore

@end


text:
package main

import (
	"log"

	tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
)

func newBot(token string) (*tgbotapi.BotAPI, error) {
	bot, err := tgbotapi.NewBotAPI(token)
	if err == nil {
		log.Printf("Authorized on account %s", bot.Self.UserName)
	}
	return bot, err
}

func botUpdatesChan(bot *tgbotapi.BotAPI) (tgbotapi.UpdatesChannel, error) {
	u := tgbotapi.NewUpdate(0)
	u.Timeout = 60
	return bot.GetUpdatesChan(u)
}

func newTextMessage(update *tgbotapi.Update, text string) tgbotapi.MessageConfig {
	msg := tgbotapi.NewMessage(update.Message.Chat.ID, text)
	msg.ReplyToMessageID = update.Message.MessageID
	return msg
}


text:
/**
 * This program imports the AMiner Dataset into SAE.
 * Currently we need the following data schema for the demo.
 *
 *  Author:
 *      Id
 *      Names
 *      Position
 *      Affiliation
 *      H-Index
 *      CitationNumber
 *      PublicationNumber
 *      Topics
 *      ImgUrl
 *
 *  Publication:
 *      Id
 *      Title
 *      Year
 *      Topics
 *
 *  Conference:
 *      JConfId
 *      ConferenceName
 *
 *  Relations:
 *      Publish: Author-Publication
 *      Appear: Publication-Conference
 *
 */

#include <iostream>
#include <fstream>
#include <unordered_map>
#include "csv_reader.hpp"
#include "storage/mgraph.hpp"
#include "../search/aminer.hpp"

using namespace std;

unordered_map<int, int> aid_map;
unordered_map<int, int> pid_map;
unordered_map<int, int> jconf_map;

int getId(unordered_map<int, int>& map, int id) {
    auto it = map.find(id);
    if (it == map.end()) {
        int next = map.size();
        map.insert(make_pair(id, next));
        return next;
    } else {
        return it->second;
    }
}

std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {
    std::stringstream ss(s);
    std::string item;
    while (std::getline(ss, item, delim)) {
        elems.push_back(item);
    }
    return elems;
}

std::vector<std::string> split(const std::string &s, char delim) {
    std::vector<std::string> elems;
    split(s, delim, elems);
    return elems;
}

#define AUTHOR_BASE 0
#define PUBLICATION_BASE (1LL << 32)
#define JCONF_BASE (1LL << 33)

int main() {
    sae::io::vid_t gvid = 0, geid = 0;

    // GraphBuilder is not efficient for this kind of large data.
    cerr << "graph builder..." << endl;
    sae::io::GraphBuilder<uint64_t> builder;
    builder.AddVertexDataType("Author");
    builder.AddVertexDataType("Publication");
    builder.AddVertexDataType("JConf");
    builder.AddEdgeDataType("Publish");
    builder.AddEdgeDataType("Appear");
    builder.AddEdgeDataType("Influence");

    // build Authors
    cerr << "building authors..." << endl;
    {
        ifstream authors_csv("authors.csv");
        CSVReader authors_reader(authors_csv);
        Author a;
        string names;
        vector<string> row;
        authors_reader.readrow(row); // header
        while (authors_reader.readrow(row)) {
            a.id = stoi(row[0]);
            a.names = split(row[1], ',');
            a.position = row[2];
            a.affiliation = row[3];
            a.imgurl = row[4];
            a.topics = split(row[5], ',');
            a.h_index = stoi(row[6]);
            a.publication_number = stoi(row[7]);
            a.citation_number = stoi(row[8]);
            aid_map[a.id] = gvid++;

            builder.AddVertex(a.id, a, "Author");
        }
    }

    // build Conferences
    cerr << "building conferences..." << endl;
    {
        ifstream jconfs("jconf_name.txt");
        JConf j;
        while (jconfs >> j.id) {
            getline(jconfs >> std::ws, j.name);
            jconf_map[j.id] = gvid++;
            builder.AddVertex(JCONF_BASE + j.id, j, "JConf");
        }
    }

    // build Publications
    cerr << "building publications and appear relations..." << endl;
    {
        ifstream pubs("publication.txt");
        ifstream pub_ext("publication_ext.txt");
        ifstream pub_topics("terms_given_publication.txt");

        int pid, tmp_id, tmp_pubtopic_id;
        string tmp_abstract, tmp_topics;
        tmp_id = tmp_pubtopic_id = -1;

        while (pubs >> pid) {
            Publication p;
            p.id = pid;
            if (p.id % 10000 == 0) {
                cerr << "publication" << p.id << std::endl;
            }
            getline(pubs.ignore(), p.title, '\t');
            pubs >> p.jconf;
            pubs >> p.year;

            string authors;
            getline(pubs.ignore(), authors, '\t');  // unused

            string citation_number;
            getline(pubs, citation_number);
            if (citation_number.size() > 0) {
                //cerr << "!!!" << citation_number << endl;
                p.citation_number = stoi(citation_number);
            } else {
                p.citation_number = -1;
            }

            if (p.id > tmp_id) {
                while (pub_ext >> tmp_id) {
                    getline(pub_ext.ignore(), tmp_abstract);
                    if (tmp_id >= p.id) break;
                }
            }

            if (p.id > tmp_pubtopic_id) {
                while (pub_topics >> tmp_pubtopic_id) {
                    getline(pub_topics.ignore(), tmp_topics);
                    if (tmp_id >= p.id) break;
                }
            }

            if (p.id == tmp_id) {
                p.abstract = tmp_abstract;
            }

            if (p.id == tmp_pubtopic_id) {
                p.topics = split(tmp_topics, '\t');
            }

            pid_map[p.id] = gvid++;
            builder.AddVertex(PUBLICATION_BASE + p.id, p, "Publication");

            auto jit = jconf_map.find(p.jconf);
            if (jit == jconf_map.end()) {
                if (p.jconf > 0)
                    cerr << "jconf not found: " << p.jconf << endl;
            } else {
                builder.AddEdge(PUBLICATION_BASE + p.id, JCONF_BASE + p.jconf, PublicationJConf(), "Appear");
            }
            if (pubs.fail()) {
                cerr << "Read failed!" << p.id << endl;
                pubs.clear(ios::failbit);
            }

            //cerr << "pub id: " << p.id << " % " << gvid << " % " << p.title << " % " << authors << " % "  << p.jconf << " % " << p.year << " % "<< p.citation_number << endl;
        }
    }

    // build relations
    cerr << "building publish relations..." << endl;
    {
        ifstream a2p("a2p_a.txt");
        AuthorPublication ap;
        int aid, pid;
        int ncount = 0;
        while (a2p >> aid >> pid) {
            auto ait = aid_map.find(aid);
            auto pit = pid_map.find(pid);
            if (ait == aid_map.end()) {
                cerr << "Author not found: " << aid << endl;
            }
            if (pit == pid_map.end()) {
                cerr << "Publication not found: " << pid << ", not found count: " << (++ncount) << endl;
            }
            if (ait == aid_map.end() || pit == pid_map.end()) {
                continue;
            }
            builder.AddEdge(AUTHOR_BASE + aid, PUBLICATION_BASE + pid, ap, "Publish");
        }
    }

    cerr << "building influence graph..." << endl;
    {
        ifstream influence("influence_all.txt");
        AuthorInfluence ai;
        int source, target;
        while (influence >> source >> target >> ai.topic >> ai.score) {
            if (aid_map.find(source) == aid_map.end() || aid_map.find(target) == aid_map.end()) {
                cerr << "Author not found: " << source << ", " << target << endl;
                continue;
            }
            builder.AddEdge(AUTHOR_BASE + source, AUTHOR_BASE + target, ai, "Influence");
        }
    }

    cerr << "saving graph..." << endl;
    // save graph
    builder.Save("aminer");
    cerr << "saved graph" << endl;
    return 0;
}


text:
/* Faux Console by Chris Heilmann http://wait-till-i.com */
if (!window.console) {
    var console = {
        init: function () {
            console.d = document.createElement('div');
            document.body.appendChild(console.d);
            var a = document.createElement('a');
            a.href = 'javascript:console.hide()';
            a.innerHTML = 'close';
            console.d.appendChild(a);
            var a = document.createElement('a');
            a.href = 'javascript:console.clear();';
            a.innerHTML = 'clear';
            console.d.appendChild(a);
            var id = 'fauxconsole';
            if (!document.getElementById(id)) {
                console.d.id = id;
            }
            console.hide();
        },
        hide: function () {
            console.d.style.display = 'none';
        },
        show: function () {
            console.d.style.display = 'block';
        },
        log: function (o) {
            console.d.innerHTML += '<br/>' + o;
            console.show();
        },
        clear: function () {
            console.d.parentNode.removeChild(console.d);
            console.init();
            console.show();
        },
        /*Simon Willison rules*/
        addLoadEvent: function (func) {
            var oldonload = window.onload;
            if (typeof window.onload != 'function') {
                window.onload = func;
            } else {
                window.onload = function () {
                    if (oldonload) {
                        oldonload();
                    }
                    func();
                }
            };
        }
    };
    console.addLoadEvent(console.init);
}


text:
import { ICellEditorComp, ICellEditorParams } from "./cellEditors/iCellEditor";
export declare class CellEditorFactory {
    private static TEXT;
    private static SELECT;
    private static POPUP_TEXT;
    private static POPUP_SELECT;
    private static LARGE_TEXT;
    private context;
    private gridOptionsWrapper;
    private cellEditorMap;
    private init();
    addCellEditor(key: string, cellEditor: {
        new (): ICellEditorComp;
    }): void;
    createCellEditor(key: string | {
        new (): ICellEditorComp;
    }, params: ICellEditorParams): ICellEditorComp;
}


text:
Audits

Filter by date

                from
                <input type="date" class="input-sm form-control" name="start" [(ngModel)]="fromDate" (ngModelChange)="onChangeDate($event)" required/>
                to
                <input type="date" class="input-sm form-control" name="end" [(ngModel)]="toDate" (ngModelChange)="onChangeDate($event)" required/>

                Date
                User
                State
                Extra data

                {{audit.timestamp| date:'medium'}}
                {{audit.principal}}
                {{audit.type}}

                    {{audit.data.message}}
                    Remote Address {{audit.data.remoteAddress}}

        <jhi-item-count [page]="page" [total]="totalItems" [itemsPerPage]="itemsPerPage"></jhi-item-count>
        <ngb-pagination [collectionSize]="totalItems" [(page)]="page" (pageChange)="loadPage(page)"></ngb-pagination>


text:
/**
 * GPIO management based on http://www.mjmwired.net/kernel/Documentation/gpio.txt
 */
#include "BitOperations.h"

/* members */
static int mGpioPin = -1;

/* methods */
static void assertPinIsValid(void);

static int outputGpio(Bit initialBit);
static int inputGpio(void);
static void writeGpio(Bit bitToWrite);
static Bit readGpio(void);

void pullBusLow(void)
{
  outputGpio(ZERO);
  writeGpio(ZERO);
}

void releaseBus(void)
{
  inputGpio();
}

Bit readBus(void)
{
  return readGpio();
}

static void writeGpio(Bit bitToWrite)
{
  int bit;
  assertPinIsValid();
  bit = BitToInt(bitToWrite);
  gpio_set_value(mGpioPin, bit);
}

static int outputGpio(Bit initialBit) // takes an argument to avoid bit glitching
{
  int bit, errorOccured;
  assertPinIsValid();
  bit = BitToInt(initialBit);
  errorOccured = gpio_direction_output(mGpioPin, initialBit);
  return errorOccured;
}

static int inputGpio(void)
{
  int errorOccured;
  assertPinIsValid();
  errorOccured = gpio_direction_input(mGpioPin);
  if (errorOccured)
  {
    logk((KERN_ALERT "Error when setting %d pin to input\n", mGpioPin));
  }
  return errorOccured;
}

Bit readGpio(void)
{
  int bit;
  assertPinIsValid();
  bit = gpio_get_value(mGpioPin);
  return (intToBit(bit));
}

int BitToInt(Bit myBit)
{
  return (myBit == ZERO) ? 0 : 1;
}

Bit intToBit(int myInt)
{
  return (myInt == 0) ? ZERO : ONE;
}

static void assertPinIsValid(void)
{
  if (mGpioPin == -1 || !gpio_is_valid(mGpioPin))
  {
    logk((KERN_ALERT "ERROR: %d pin is not valid\n", mGpioPin));
  }
}

int initializeBus(int GpioPin)
{
  int errorOccured;
  mGpioPin = GpioPin;
  if (!gpio_is_valid(mGpioPin))
  {
    logk((KERN_ALERT "ERROR: %d pin is not valid\n", mGpioPin));
    return -1;
  }
  // initialize the port we want to work on
  // request the gpio device
  errorOccured = gpio_request_one(mGpioPin, GPIOF_OPEN_DRAIN, "One-Wire Bus"); // used for w1 bus
  if (errorOccured)
  {
    logk((KERN_ALERT "ERROR occured requesting the GPIO pin\n"));
  }
  return (errorOccured);
}

void deleteBus(void)
{
  gpio_free(mGpioPin);
}


text:
isdarwin(){
    [[ $OSTYPE == darwin* ]] && return 0
    return 1
}

isalpine(){
    [[ $OSTYPE == linux-musl ]] && return 0
    return 1
}

islinux(){
    [[ $OSTYPE == linux-musl ]] && return 1
    [[ $OSTYPE == linux* ]] && return 0
    return 1
}

#f1# are we running within an utf environment?
isutfenv() {
    case "$LANG $CHARSET $LANGUAGE" in
        *utf*) return 0 ;;
        *UTF*) return 0 ;;
        *)     return 1 ;;
    esac
}
# h/t [http://mivok.net/2009/09/20/bashfunctionoverrist.html]
save_function()
{     local ORIG_FUNC=$(declare -f )
    local NEWNAME_FUNC="${ORIG_FUNC#}"
    eval "$NEWNAME_FUNC"
}

#http://stackoverflow.com/questions/85880/determine-if-a-function-exists-in-bash
command_exists() {
  declare $1 > /dev/null
  return $?
}

# Added from https://github.com/jdavis/zsh-files/blob/master/functions/functions.zsh
# Automatically run ls when cd-ing into a directory
cd() {
    builtin cd $* && ls;
}

#Get IP
ip-addr() {
    wget -qO- http://ipecho.net/plain
    echo
}

# Time ZSH startup
zsh-time() {
    time zsh -i -c exit
}

# Run a command or multiple commands without saving it in the $HISTFILE
incognito() {
    if [ -z $EDITOR ]; then
        EDITOR=vim
    fi

    # Create temp for storing commands
    TEMPFILE=`mktemp -q incognito.XXXXXXXX`

    # Prompt for commands, only run if successful
    $EDITOR $TEMPFILE || {
        echo "Invalid return on the editing"
        return
    }

    # Run the script
    sh $TEMPFILE

    # Clean everything up
    rm -f $TEMPFILE
}

mkcd(){
  mkdir -p $1
  cd $1
}


text:
<idea-plugin version="2">
    <id>com.christofferklang.pyxl</id>
    <name>Pyxl Support</name>
    <version>1.2</version>
    <vendor email="christoffer.klang@gmail.com">Christoffer Klang</vendor>

    <description><![CDATA[
      Adds support for Pyxl files.

      Created by Nils Bunger (nils@dropbox.com), Robert Kajic (kajic@dropbox.com) and Christoffer Klang (christoffer@dropbox.com).

      Please report any bugs or missing features to https://github.com/christoffer/pycharm-pyxl, or email any of the creators.

      Requires PyCharm or the Python plugin.
    ]]></description>

    <change-notes><![CDATA[

IDEA 2016.1 support

    ]]>
    </change-notes>

    <idea-version since-build="131"/>

    <extensions defaultExtensionNs="com.intellij">
        <lang.parserDefinition
                language="Python"
                order="first, before PythonParserDefinition"
                implementationClass="com.christofferklang.pyxl.parsing.PyxlParserDefinition"
                />

        <lang.syntaxHighlighterFactory
                key="Python"
                order="first"
                implementationClass="com.christofferklang.pyxl.PyxlHighlighterFactory"
                />

        <colorSettingsPage implementation="com.christofferklang.pyxl.PyxlColorSettingsPage" />
    </extensions>

    <extensions defaultExtensionNs="Pythonid">
        <dialectsTokenSetContributor
                implementation="com.christofferklang.pyxl.PyxlDialectTokenContributor" />
    </extensions>

    <application-components>

    </application-components>

    <project-components>

    </project-components>

    <depends>com.intellij.modules.python</depends>
</idea-plugin>


text:
/*
 * Native ethread spinlocks on PowerPC.
 * Author: Mikael Pettersson.
 *
 * Based on the examples in Appendix E of Motorola's
 * "Programming Environments Manual For 32-Bit Implementations
 * of the PowerPC Architecture".
 */
#ifndef ETHREAD_PPC_SPINLOCK_H
#define ETHREAD_PPC_SPINLOCK_H

#define ETHR_HAVE_NATIVE_SPINLOCKS 1
#define ETHR_NATIVE_SPINLOCK_IMPL "ethread"

/* Unlocked if zero, locked if non-zero. */
typedef struct {
    volatile unsigned int lock;
} ethr_native_spinlock_t;

#if defined(ETHR_TRY_INLINE_FUNCS) || defined(ETHR_AUX_IMPL__)

static ETHR_INLINE void
ethr_native_spinlock_init(ethr_native_spinlock_t *lock)
{
    lock->lock = 0;
}

static ETHR_INLINE void
ethr_native_spin_unlock(ethr_native_spinlock_t *lock)
{
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    lock->lock = 0;
}

static ETHR_INLINE int
ethr_native_spin_trylock(ethr_native_spinlock_t *lock)
{
    unsigned int prev;

    __asm__ __volatile__(
	"1:\t"
	"lwarx	%0,0,%1\n\t"	/* read lock to prev */
	"cmpwi	0,%0,0\n\t"
	"bne-	2f\n\t"		/* bail if non-zero/locked */
	"stwcx.	%2,0,%1\n\t"	/* try to make the lock non-zero */
	"bne-	1b\n\t"		/* loop if lost reservation */
	"isync\n\t"		/* wait for previous insns to complete */
	"2:"
	: "=&r"(prev)
	: "r"(&lock->lock), "r"(1)
	: "cr0", "memory");
    return prev == 0;
}

static ETHR_INLINE int
ethr_native_spin_is_locked(ethr_native_spinlock_t *lock)
{

    return lock->lock != 0;
}

static ETHR_INLINE void
ethr_native_spin_lock(ethr_native_spinlock_t *lock)
{
    for(;;) {
	if (__builtin_expect(ethr_native_spin_trylock(lock) != 0, 1))
	    break;
	do {
	    __asm__ __volatile__("":::"memory");
	} while (ethr_native_spin_is_locked(lock));
    }
}

#endif /* ETHR_TRY_INLINE_FUNCS */

#endif /* ETHREAD_PPC_SPINLOCK_H */


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>com.amazonaws.auth (AWS SDK for Android - 2.2.1)</title>
<meta name="date" content="2015-04-21">
<link rel="stylesheet" type="text/css" href="../../../JavaDoc.css" title="Style">

com.amazonaws.auth

Interfaces

AWSCognitoIdentityProvider

AWSCredentials

AWSCredentialsProvider

AWSIdentityProvider

AWSRefreshableSessionCredentials

AWSSessionCredentials

IdentityChangedListener

NoSessionSupportCredentials

Presigner

RegionAwareSigner

ServiceAwareSigner

Signer

Classes

AbstractAWSSigner

AnonymousAWSCredentials

AWS3Signer

AWS4Signer

AWSAbstractCognitoDeveloperIdentityProvider

AWSAbstractCognitoIdentityProvider

AWSBasicCognitoIdentityProvider

AwsChunkedEncodingInputStream

AWSCredentialsProviderChain

AWSEnhancedCognitoIdentityProvider

BasicAWSCredentials

BasicSessionCredentials

ClasspathPropertiesFileCredentialsProvider

CognitoCachingCredentialsProvider

CognitoCredentialsProvider

DefaultAWSCredentialsProviderChain

NoOpSigner

PropertiesCredentials

PropertiesFileCredentialsProvider

QueryStringSigner

SessionCredentialsProviderFactory

SignerFactory

STSAssumeRoleSessionCredentialsProvider

STSSessionCredentials

STSSessionCredentialsProvider

SystemPropertiesCredentialsProvider

WebIdentityFederationSessionCredentialsProvider

Enums

SignatureVersion

SigningAlgorithm


text:
package com.android.ddmlib;

import com.android.ddmlib.AdbHelper.AdbResponse;
import com.android.ddmlib.FileListingService.FileEntry;
import com.android.ddmlib.SyncException.SyncError;
import com.android.ddmlib.utils.ArrayHelper;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;

/**
 * Sync service class to push/pull to/from devices/emulators, through the debug bridge.
 *

 * To get a {@link SyncService} object, use {@link Device#getSyncService()}.
 */
public final class SyncService {

    private final static byte[] ID_OKAY = { 'O', 'K', 'A', 'Y' };
    private final static byte[] ID_FAIL = { 'F', 'A', 'I', 'L' };
    private final static byte[] ID_STAT = { 'S', 'T', 'A', 'T' };
    private final static byte[] ID_RECV = { 'R', 'E', 'C', 'V' };
    private final static byte[] ID_DATA = { 'D', 'A', 'T', 'A' };
    private final static byte[] ID_DONE = { 'D', 'O', 'N', 'E' };
    private final static byte[] ID_SEND = { 'S', 'E', 'N', 'D' };
//    private final static byte[] ID_LIST = { 'L', 'I', 'S', 'T' };
//    private final static byte[] ID_DENT = { 'D', 'E', 'N', 'T' };

    private final static NullSyncProgresMonitor sNullSyncProgressMonitor =
            new NullSyncProgresMonitor();

    private final static int S_ISOCK = 0xC000; // type: symbolic link
    private final static int S_IFLNK = 0xA000; // type: symbolic link
    private final static int S_IFREG = 0x8000; // type: regular file
    private final static int S_IFBLK = 0x6000; // type: block device
    private final static int S_IFDIR = 0x4000; // type: directory
    private final static int S_IFCHR = 0x2000; // type: character device
    private final static int S_IFIFO = 0x1000; // type: fifo
/*
    private final static int S_ISUID = 0x0800; // set-uid bit
    private final static int S_ISGID = 0x0400; // set-gid bit
    private final static int S_ISVTX = 0x0200; // sticky bit
    private final static int S_IRWXU = 0x01C0; // user permissions
    private final static int S_IRUSR = 0x0100; // user: read
    private final static int S_IWUSR = 0x0080; // user: write
    private final static int S_IXUSR = 0x0040; // user: execute
    private final static int S_IRWXG = 0x0038; // group permissions
    private final static int S_IRGRP = 0x0020; // group: read
    private final static int S_IWGRP = 0x0010; // group: write
    private final static int S_IXGRP = 0x0008; // group: execute
    private final static int S_IRWXO = 0x0007; // other permissions
    private final static int S_IROTH = 0x0004; // other: read
    private final static int S_IWOTH = 0x0002; // other: write
    private final static int S_IXOTH = 0x0001; // other: execute
*/

    private final static int SYNC_DATA_MAX = 64*1024;
    private final static int REMOTE_PATH_MAX_LENGTH = 1024;

    /**
     * Classes which implement this interface provide methods that deal
     * with displaying transfer progress.
     */
    public interface ISyncProgressMonitor {
        /**
         * Sent when the transfer starts
         * @param totalWork the total amount of work.
         */
        public void start(int totalWork);
        /**
         * Sent when the transfer is finished or interrupted.
         */
        public void stop();
        /**
         * Sent to query for possible cancellation.
         * @return true if the transfer should be stopped.
         */
        public boolean isCanceled();
        /**
         * Sent when a sub task is started.
         * @param name the name of the sub task.
         */
        public void startSubTask(String name);
        /**
         * Sent when some progress have been made.
         * @param work the amount of work done.
         */
        public void advance(int work);
    }

    /**
     * A Sync progress monitor that does nothing
     */
    private static class NullSyncProgresMonitor implements ISyncProgressMonitor {
        public void advance(int work) {
        }
        public boolean isCanceled() {
            return false;
        }

        public void start(int totalWork) {
        }
        public void startSubTask(String name) {
        }
        public void stop() {
        }
    }

    private InetSocketAddress mAddress;
    private Device mDevice;
    private SocketChannel mChannel;

    /**
     * Buffer used to send data. Allocated when needed and reused afterward.
     */
    private byte[] mBuffer;

    /**
     * Creates a Sync service object.
     * @param address The address to connect to
     * @param device the {@link Device} that the service connects to.
     */
    SyncService(InetSocketAddress address, Device device) {
        mAddress = address;
        mDevice = device;
    }

    /**
     * Opens the sync connection. This must be called before any calls to push[File] / pull[File].
     * @return true if the connection opened, false if adb refuse the connection. This can happen
     * if the {@link Device} is invalid.
     * @throws TimeoutException in case of timeout on the connection.
     * @throws AdbCommandRejectedException if adb rejects the command
     * @throws IOException If the connection to adb failed.
     */
    boolean openSync() throws TimeoutException, AdbCommandRejectedException, IOException {
        try {
            mChannel = SocketChannel.open(mAddress);
            mChannel.configureBlocking(false);

            // target a specific device
            AdbHelper.setDevice(mChannel, mDevice);

            byte[] request = AdbHelper.formAdbRequest("sync:"); //$NON-NLS-1$
            AdbHelper.write(mChannel, request, -1, DdmPreferences.getTimeOut());

            AdbResponse resp = AdbHelper.readAdbResponse(mChannel, false /* readDiagString */);

            if (resp.okay == false) {
                Log.w("ddms", "Got unhappy response from ADB sync req: " + resp.message);
                mChannel.close();
                mChannel = null;
                return false;
            }
        } catch (TimeoutException e) {
            if (mChannel != null) {
                try {
                    mChannel.close();
                } catch (IOException e2) {
                    // we want to throw the original exception, so we ignore this one.
                }
                mChannel = null;
            }

            throw e;
        } catch (IOException e) {
            if (mChannel != null) {
                try {
                    mChannel.close();
                } catch (IOException e2) {
                    // we want to throw the original exception, so we ignore this one.
                }
                mChannel = null;
            }

            throw e;
        }

        return true;
    }

    /**
     * Closes the connection.
     */
    public void close() {
        if (mChannel != null) {
            try {
                mChannel.close();
            } catch (IOException e) {
                // nothing to be done really...
            }
            mChannel = null;
        }
    }

    /**
     * Returns a sync progress monitor that does nothing. This allows background tasks that don't
     * want/need to display ui, to pass a valid {@link ISyncProgressMonitor}.
     *
This object can be reused multiple times and can be used by concurrent threads.
     */
    public static ISyncProgressMonitor getNullProgressMonitor() {
        return sNullSyncProgressMonitor;
    }

    /**
     * Pulls file(s) or folder(s).
     * @param entries the remote item(s) to pull
     * @param localPath The local destination. If the entries count is > 1 or
     *      if the unique entry is a folder, this should be a folder.
     * @param monitor The progress monitor. Cannot be null.
     * @throws SyncException
     * @throws IOException
     * @throws TimeoutException
     *
     * @see FileListingService.FileEntry
     * @see #getNullProgressMonitor()
     */
    public void pull(FileEntry[] entries, String localPath, ISyncProgressMonitor monitor)
            throws SyncException, IOException, TimeoutException {

        // first we check the destination is a directory and exists
        File f = new File(localPath);
        if (f.exists() == false) {
            throw new SyncException(SyncError.NO_DIR_TARGET);
        }
        if (f.isDirectory() == false) {
            throw new SyncException(SyncError.TARGET_IS_FILE);
        }

        // get a FileListingService object
        FileListingService fls = new FileListingService(mDevice);

        // compute the number of file to move
        int total = getTotalRemoteFileSize(entries, fls);

        // start the monitor
        monitor.start(total);

        doPull(entries, localPath, fls, monitor);

        monitor.stop();
    }

    /**
     * Pulls a single file.
     * @param remote the remote file
     * @param localFilename The local destination.
     * @param monitor The progress monitor. Cannot be null.
     *
     * @throws IOException in case of an IO exception.
     * @throws TimeoutException in case of a timeout reading responses from the device.
     * @throws SyncException in case of a sync exception.
     *
     * @see FileListingService.FileEntry
     * @see #getNullProgressMonitor()
     */
    public void pullFile(FileEntry remote, String localFilename, ISyncProgressMonitor monitor)
            throws IOException, SyncException, TimeoutException {
        int total = remote.getSizeValue();
        monitor.start(total);

        doPullFile(remote.getFullPath(), localFilename, monitor);

        monitor.stop();
    }

    /**
     * Pulls a single file.
     *
Because this method just deals with a String for the remote file instead of a
     * {@link FileEntry}, the size of the file being pulled is unknown and the
     * {@link ISyncProgressMonitor} will not properly show the progress
     * @param remoteFilepath the full path to the remote file
     * @param localFilename The local destination.
     * @param monitor The progress monitor. Cannot be null.
     *
     * @throws IOException in case of an IO exception.
     * @throws TimeoutException in case of a timeout reading responses from the device.
     * @throws SyncException in case of a sync exception.
     *
     * @see #getNullProgressMonitor()
     */
    public void pullFile(String remoteFilepath, String localFilename,
            ISyncProgressMonitor monitor) throws TimeoutException, IOException, SyncException {
        Integer mode = readMode(remoteFilepath);
        if (mode == null) {
            // attempts to download anyway
        } else if (mode == 0) {
            throw new SyncException(SyncError.NO_REMOTE_OBJECT);
        }

        monitor.start(0);
        //TODO: use the {@link FileListingService} to get the file size.

        doPullFile(remoteFilepath, localFilename, monitor);

        monitor.stop();
    }

    /**
     * Push several files.
     * @param local An array of loca files to push
     * @param remote the remote {@link FileEntry} representing a directory.
     * @param monitor The progress monitor. Cannot be null.
     * @throws SyncException if file could not be pushed
     * @throws IOException in case of I/O error on the connection.
     * @throws TimeoutException in case of a timeout reading responses from the device.
     */
    public void push(String[] local, FileEntry remote, ISyncProgressMonitor monitor)
            throws SyncException, IOException, TimeoutException {
        if (remote.isDirectory() == false) {
            throw new SyncException(SyncError.REMOTE_IS_FILE);
        }

        // make a list of File from the list of String
        ArrayList<File> files = new ArrayList<File>();
        for (String path : local) {
            files.add(new File(path));
        }

        // get the total count of the bytes to transfer
        File[] fileArray = files.toArray(new File[files.size()]);
        int total = getTotalLocalFileSize(fileArray);

        monitor.start(total);

        doPush(fileArray, remote.getFullPath(), monitor);

        monitor.stop();
    }

    /**
     * Push a single file.
     * @param local the local filepath.
     * @param remote The remote filepath.
     * @param monitor The progress monitor. Cannot be null.
     *
     * @throws SyncException if file could not be pushed
     * @throws IOException in case of I/O error on the connection.
     * @throws TimeoutException in case of a timeout reading responses from the device.
     */
    public void pushFile(String local, String remote, ISyncProgressMonitor monitor)
            throws SyncException, IOException, TimeoutException {
        File f = new File(local);
        if (f.exists() == false) {
            throw new SyncException(SyncError.NO_LOCAL_FILE);
        }

        if (f.isDirectory()) {
            throw new SyncException(SyncError.LOCAL_IS_DIRECTORY);
        }

        monitor.start((int)f.length());

        doPushFile(local, remote, monitor);

        monitor.stop();
    }

    /**
     * compute the recursive file size of all the files in the list. Folder
     * have a weight of 1.
     * @param entries
     * @param fls
     * @return
     */
    private int getTotalRemoteFileSize(FileEntry[] entries, FileListingService fls) {
        int count = 0;
        for (FileEntry e : entries) {
            int type = e.getType();
            if (type == FileListingService.TYPE_DIRECTORY) {
                // get the children
                FileEntry[] children = fls.getChildren(e, false, null);
                count += getTotalRemoteFileSize(children, fls) + 1;
            } else if (type == FileListingService.TYPE_FILE) {
                count += e.getSizeValue();
            }
        }

        return count;
    }

    /**
     * compute the recursive file size of all the files in the list. Folder
     * have a weight of 1.
     * This does not check for circular links.
     * @param files
     * @return
     */
    private int getTotalLocalFileSize(File[] files) {
        int count = 0;

        for (File f : files) {
            if (f.exists()) {
                if (f.isDirectory()) {
                    return getTotalLocalFileSize(f.listFiles()) + 1;
                } else if (f.isFile()) {
                    count += f.length();
                }
            }
        }

        return count;
    }

    /**
     * Pulls multiple files/folders recursively.
     * @param entries The list of entry to pull
     * @param localPath the localpath to a directory
     * @param fileListingService a FileListingService object to browse through remote directories.
     * @param monitor the progress monitor. Must be started already.
     *
     * @throws SyncException if file could not be pushed
     * @throws IOException in case of I/O error on the connection.
     * @throws TimeoutException in case of a timeout reading responses from the device.
     */
    private void doPull(FileEntry[] entries, String localPath,
            FileListingService fileListingService,
            ISyncProgressMonitor monitor) throws SyncException, IOException, TimeoutException {

        for (FileEntry e : entries) {
            // check if we're cancelled
            if (monitor.isCanceled() == true) {
                throw new SyncException(SyncError.CANCELED);
            }

            // get type (we only pull directory and files for now)
            int type = e.getType();
            if (type == FileListingService.TYPE_DIRECTORY) {
                monitor.startSubTask(e.getFullPath());
                String dest = localPath + File.separator + e.getName();

                // make the directory
                File d = new File(dest);
                d.mkdir();

                // then recursively call the content. Since we did a ls command
                // to get the number of files, we can use the cache
                FileEntry[] children = fileListingService.getChildren(e, true, null);
                doPull(children, dest, fileListingService, monitor);
                monitor.advance(1);
            } else if (type == FileListingService.TYPE_FILE) {
                monitor.startSubTask(e.getFullPath());
                String dest = localPath + File.separator + e.getName();
                doPullFile(e.getFullPath(), dest, monitor);
            }
        }
    }

    /**
     * Pulls a remote file
     * @param remotePath the remote file (length max is 1024)
     * @param localPath the local destination
     * @param monitor the monitor. The monitor must be started already.
     * @throws SyncException if file could not be pushed
     * @throws IOException in case of I/O error on the connection.
     * @throws TimeoutException in case of a timeout reading responses from the device.
     */
    private void doPullFile(String remotePath, String localPath,
            ISyncProgressMonitor monitor) throws IOException, SyncException, TimeoutException {
        byte[] msg = null;
        byte[] pullResult = new byte[8];

        final int timeOut = DdmPreferences.getTimeOut();

        try {
            byte[] remotePathContent = remotePath.getBytes(AdbHelper.DEFAULT_ENCODING);

            if (remotePathContent.length > REMOTE_PATH_MAX_LENGTH) {
                throw new SyncException(SyncError.REMOTE_PATH_LENGTH);
            }

            // create the full request message
            msg = createFileReq(ID_RECV, remotePathContent);

            // and send it.
            AdbHelper.write(mChannel, msg, -1, timeOut);

            // read the result, in a byte array containing 2 ints
            // (id, size)
            AdbHelper.read(mChannel, pullResult, -1, timeOut);

            // check we have the proper data back
            if (checkResult(pullResult, ID_DATA) == false &&
                    checkResult(pullResult, ID_DONE) == false) {
                throw new SyncException(SyncError.TRANSFER_PROTOCOL_ERROR,
                        readErrorMessage(pullResult, timeOut));
            }
        } catch (UnsupportedEncodingException e) {
            throw new SyncException(SyncError.REMOTE_PATH_ENCODING, e);
        }

        // access the destination file
        File f = new File(localPath);

        // create the stream to write in the file. We use a new try/catch block to differentiate
        // between file and network io exceptions.
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream(f);
        } catch (IOException e) {
            Log.e("ddms", String.format("Failed to open local file %s for writing, Reason: %s",
                    f.getAbsolutePath(), e.toString()));
            throw new SyncException(SyncError.FILE_WRITE_ERROR);
        }

        // the buffer to read the data
        byte[] data = new byte[SYNC_DATA_MAX];

        // loop to get data until we're done.
        while (true) {
            // check if we're cancelled
            if (monitor.isCanceled() == true) {
                throw new SyncException(SyncError.CANCELED);
            }

            // if we're done, we stop the loop
            if (checkResult(pullResult, ID_DONE)) {
                break;
            }
            if (checkResult(pullResult, ID_DATA) == false) {
                // hmm there's an error
                throw new SyncException(SyncError.TRANSFER_PROTOCOL_ERROR,
                        readErrorMessage(pullResult, timeOut));
            }
            int length = ArrayHelper.swap32bitFromArray(pullResult, 4);
            if (length > SYNC_DATA_MAX) {
                // buffer overrun!
                // error and exit
                throw new SyncException(SyncError.BUFFER_OVERRUN);
            }

            // now read the length we received
            AdbHelper.read(mChannel, data, length, timeOut);

            // get the header for the next packet.
            AdbHelper.read(mChannel, pullResult, -1, timeOut);

            // write the content in the file
            fos.write(data, 0, length);

            monitor.advance(length);
        }

        fos.flush();
    }

    /**
     * Push multiple files
     * @param fileArray
     * @param remotePath
     * @param monitor
     *
     * @throws SyncException if file could not be pushed
     * @throws IOException in case of I/O error on the connection.
     * @throws TimeoutException in case of a timeout reading responses from the device.
     */
    private void doPush(File[] fileArray, String remotePath, ISyncProgressMonitor monitor)
            throws SyncException, IOException, TimeoutException {
        for (File f : fileArray) {
            // check if we're canceled
            if (monitor.isCanceled() == true) {
                throw new SyncException(SyncError.CANCELED);
            }
            if (f.exists()) {
                if (f.isDirectory()) {
                    // append the name of the directory to the remote path
                    String dest = remotePath + "/" + f.getName(); // $NON-NLS-1S
                    monitor.startSubTask(dest);
                    doPush(f.listFiles(), dest, monitor);

                    monitor.advance(1);
                } else if (f.isFile()) {
                    // append the name of the file to the remote path
                    String remoteFile = remotePath + "/" + f.getName(); // $NON-NLS-1S
                    monitor.startSubTask(remoteFile);
                    doPushFile(f.getAbsolutePath(), remoteFile, monitor);
                }
            }
        }
    }

    /**
     * Push a single file
     * @param localPath the local file to push
     * @param remotePath the remote file (length max is 1024)
     * @param monitor the monitor. The monitor must be started already.
     *
     * @throws SyncException if file could not be pushed
     * @throws IOException in case of I/O error on the connection.
     * @throws TimeoutException in case of a timeout reading responses from the device.
     */
    private void doPushFile(String localPath, String remotePath,
            ISyncProgressMonitor monitor) throws SyncException, IOException, TimeoutException {
        FileInputStream fis = null;
        byte[] msg;

        final int timeOut = DdmPreferences.getTimeOut();

        try {
            byte[] remotePathContent = remotePath.getBytes(AdbHelper.DEFAULT_ENCODING);

            if (remotePathContent.length > REMOTE_PATH_MAX_LENGTH) {
                throw new SyncException(SyncError.REMOTE_PATH_LENGTH);
            }

            File f = new File(localPath);

            // create the stream to read the file
            fis = new FileInputStream(f);

            // create the header for the action
            msg = createSendFileReq(ID_SEND, remotePathContent, 0644);
        } catch (UnsupportedEncodingException e) {
            throw new SyncException(SyncError.REMOTE_PATH_ENCODING, e);
        }

        // and send it. We use a custom try/catch block to make the difference between
        // file and network IO exceptions.
        AdbHelper.write(mChannel, msg, -1, timeOut);

        // create the buffer used to read.
        // we read max SYNC_DATA_MAX, but we need 2 4 bytes at the beginning.
        if (mBuffer == null) {
            mBuffer = new byte[SYNC_DATA_MAX + 8];
        }
        System.arraycopy(ID_DATA, 0, mBuffer, 0, ID_DATA.length);

        // look while there is something to read
        while (true) {
            // check if we're canceled
            if (monitor.isCanceled() == true) {
                throw new SyncException(SyncError.CANCELED);
            }

            // read up to SYNC_DATA_MAX
            int readCount = fis.read(mBuffer, 8, SYNC_DATA_MAX);

            if (readCount == -1) {
                // we reached the end of the file
                break;
            }

            // now send the data to the device
            // first write the amount read
            ArrayHelper.swap32bitsToArray(readCount, mBuffer, 4);

            // now write it
            AdbHelper.write(mChannel, mBuffer, readCount+8, timeOut);

            // and advance the monitor
            monitor.advance(readCount);
        }
        // close the local file
        fis.close();

        // create the DONE message
        long time = System.currentTimeMillis() / 1000;
        msg = createReq(ID_DONE, (int)time);

        // and send it.
        AdbHelper.write(mChannel, msg, -1, timeOut);

        // read the result, in a byte array containing 2 ints
        // (id, size)
        byte[] result = new byte[8];
        AdbHelper.read(mChannel, result, -1 /* full length */, timeOut);

        if (checkResult(result, ID_OKAY) == false) {
            throw new SyncException(SyncError.TRANSFER_PROTOCOL_ERROR,
                    readErrorMessage(result, timeOut));
        }
    }

    /**
     * Reads an error message from the opened {@link #mChannel}.
     * @param result the current adb result. Must contain both FAIL and the length of the message.
     * @param timeOut
     * @return
     * @throws TimeoutException in case of a timeout reading responses from the device.
     * @throws IOException
     */
    private String readErrorMessage(byte[] result, final int timeOut) throws TimeoutException,
            IOException {
        if (checkResult(result, ID_FAIL)) {
            int len = ArrayHelper.swap32bitFromArray(result, 4);

            if (len > 0) {
                AdbHelper.read(mChannel, mBuffer, len, timeOut);

                String message = new String(mBuffer, 0, len);
                Log.e("ddms", "transfer error: " + message);

                return message;
            }
        }

        return null;
    }

    /**
     * Returns the mode of the remote file.
     * @param path the remote file
     * @return an Integer containing the mode if all went well or null
     *      otherwise
     * @throws IOException
     * @throws TimeoutException in case of a timeout reading responses from the device.
     */
    private Integer readMode(String path) throws TimeoutException, IOException {
        // create the stat request message.
        byte[] msg = createFileReq(ID_STAT, path);

        AdbHelper.write(mChannel, msg, -1 /* full length */, DdmPreferences.getTimeOut());

        // read the result, in a byte array containing 4 ints
        // (id, mode, size, time)
        byte[] statResult = new byte[16];
        AdbHelper.read(mChannel, statResult, -1 /* full length */, DdmPreferences.getTimeOut());

        // check we have the proper data back
        if (checkResult(statResult, ID_STAT) == false) {
            return null;
        }

        // we return the mode (2nd int in the array)
        return ArrayHelper.swap32bitFromArray(statResult, 4);
    }

    /**
     * Create a command with a code and an int values
     * @param command
     * @param value
     * @return
     */
    private static byte[] createReq(byte[] command, int value) {
        byte[] array = new byte[8];

        System.arraycopy(command, 0, array, 0, 4);
        ArrayHelper.swap32bitsToArray(value, array, 4);

        return array;
    }

    /**
     * Creates the data array for a stat request.
     * @param command the 4 byte command (ID_STAT, ID_RECV, ...)
     * @param path The path of the remote file on which to execute the command
     * @return the byte[] to send to the device through adb
     */
    private static byte[] createFileReq(byte[] command, String path) {
        byte[] pathContent = null;
        try {
            pathContent = path.getBytes(AdbHelper.DEFAULT_ENCODING);
        } catch (UnsupportedEncodingException e) {
            return null;
        }

        return createFileReq(command, pathContent);
    }

    /**
     * Creates the data array for a file request. This creates an array with a 4 byte command + the
     * remote file name.
     * @param command the 4 byte command (ID_STAT, ID_RECV, ...).
     * @param path The path, as a byte array, of the remote file on which to
     *      execute the command.
     * @return the byte[] to send to the device through adb
     */
    private static byte[] createFileReq(byte[] command, byte[] path) {
        byte[] array = new byte[8 + path.length];

        System.arraycopy(command, 0, array, 0, 4);
        ArrayHelper.swap32bitsToArray(path.length, array, 4);
        System.arraycopy(path, 0, array, 8, path.length);

        return array;
    }

    private static byte[] createSendFileReq(byte[] command, byte[] path, int mode) {
        // make the mode into a string
        String modeStr = "," + (mode & 0777); // $NON-NLS-1S
        byte[] modeContent = null;
        try {
            modeContent = modeStr.getBytes(AdbHelper.DEFAULT_ENCODING);
        } catch (UnsupportedEncodingException e) {
            return null;
        }

        byte[] array = new byte[8 + path.length + modeContent.length];

        System.arraycopy(command, 0, array, 0, 4);
        ArrayHelper.swap32bitsToArray(path.length + modeContent.length, array, 4);
        System.arraycopy(path, 0, array, 8, path.length);
        System.arraycopy(modeContent, 0, array, 8 + path.length, modeContent.length);

        return array;

    }

    /**
     * Checks the result array starts with the provided code
     * @param result The result array to check
     * @param code The 4 byte code.
     * @return true if the code matches.
     */
    private static boolean checkResult(byte[] result, byte[] code) {
        if (result[0] != code[0] ||
                result[1] != code[1] ||
                result[2] != code[2] ||
                result[3] != code[3]) {
            return false;
        }

        return true;

    }

    private static int getFileType(int mode) {
        if ((mode & S_ISOCK) == S_ISOCK) {
            return FileListingService.TYPE_SOCKET;
        }

        if ((mode & S_IFLNK) == S_IFLNK) {
            return FileListingService.TYPE_LINK;
        }

        if ((mode & S_IFREG) == S_IFREG) {
            return FileListingService.TYPE_FILE;
        }

        if ((mode & S_IFBLK) == S_IFBLK) {
            return FileListingService.TYPE_BLOCK;
        }

        if ((mode & S_IFDIR) == S_IFDIR) {
            return FileListingService.TYPE_DIRECTORY;
        }

        if ((mode & S_IFCHR) == S_IFCHR) {
            return FileListingService.TYPE_CHARACTER;
        }

        if ((mode & S_IFIFO) == S_IFIFO) {
            return FileListingService.TYPE_FIFO;
        }

        return FileListingService.TYPE_OTHER;
    }
}


text:
<#
.EXAMPLE
    This example shows how to ensure that the server role named
    AdminSqlforBI is present on instance SQLServer\DSC and logins
    CONTOSO\Mark and CONTOSO\Lucy are not members of this role.
#>

Configuration Example
{
    param(
        [Parameter(Mandatory = $true)]
        [PSCredential]
        $SysAdminAccount
    )

    Import-DscResource -ModuleName xSqlServer

    node localhost {
        xSQLServerRole Drop_ServerRole_AdminSqlforBI
        {
            Ensure                  = 'Present'
            ServerRoleName          = 'AdminSqlforBI'
            MembersToExclude        = "CONTOSO\Mark","CONTOSO\Lucy"
            SQLServer               = 'SQLServer'
            SQLInstanceName         = 'DSC'
            PsDscRunAsCredential    = $SysAdminAccount
        }
    }
}


text:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.magnoveras.ado02pi02;

import java.util.Random;
import java.util.Scanner;

/**
 *
 * @author Magno
 */
public class Exercicio5 {
    //Método gera número automático para o usuário
    public static int geraNumero(){
        int numero;

        Random r = new Random();
        return numero = r.nextInt(100);
    }
    //Método que implementa o menu a ser jogado
    public static void jogoAdivinhacao(String numero){
        String numeroU;
        boolean sair = false;
        Scanner leia = new Scanner(System.in);

        do{

            System.out.println("Digite um número: ");
            numeroU = leia.nextLine();
            System.out.println(numero);

            if(numeroU.equalsIgnoreCase(numero)){
                System.out.println("Sucesso você acertou o número");
                System.out.println("Número = " + numero);
                sair = true;
            }

            if(numeroU.equalsIgnoreCase("desistir")){
                sair = true;
            }
        }while(sair == false);

    }

    public static void main(String[] args) {
        int numero = geraNumero();

        jogoAdivinhacao(String.valueOf(numero));
    }
}


text:
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js">module.exports = function(result, callback){
	Ti.API.info("loading search results: ");
	Ti.API.info(JSON.stringify(result));
	var make_row = require('ui/common/elements/search_results/make_row');
	var tbl_data = [];
	//result.Products.List
	var pl = result.Products.List;
	Ti.API.info(pl.length + " results");
	// if we have a result
	if(pl.length > 0){
		for(var i = 0; i < pl.length; ++i)
			tbl_data.push(make_row(pl[i]));

	}
	else
	{
		var row = Ti.UI.createTableViewRow
		({
			hasChild:true
		});
		var message = Ti.UI.createLabel
		({
			color:'black',
			text: "0 results",
			font:{fontSize:16,fontWeight:'normal',fontFamily:'Helvetica Neue'},
			touchEnabled:false
		});
		row.add(message);
		tbl_data.push(row);
	}
	var table = Titanium.UI.createTableView
	({
		backgroundColor:'transparent',
		top:10,
		width:'100%',
		height:'100%',
		data:tbl_data
	});
	if(pl.length > 0)
		table.addEventListener('click', function(data){
			callback(data.row.wine);
		});

	return table;
}

</pre>
</body>
</html>


text:
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.chromium.chromoting.cardboard;

import android.opengl.GLES20;

import org.chromium.base.Log;

/**
 * Helper class for working with OpenGL shaders and programs.
 */
public class ShaderHelper {
    private static final String TAG = "cr.ShaderHelper";

    /**
     * Compile a shader.
     *
     * @param shaderType The shader type.
     * @param shaderSource The shader source code.
     * @return An OpenGL handle to the shader.
     */
    public static int compileShader(int shaderType, String shaderSource) {
        int shaderHandle = GLES20.glCreateShader(shaderType);

        if (shaderHandle != 0) {
            // Pass in the shader source.
            GLES20.glShaderSource(shaderHandle, shaderSource);

            // Compile the shader.
            GLES20.glCompileShader(shaderHandle);

            // Get the compilation status.
            int[] compileStatus = new int[1];
            GLES20.glGetShaderiv(shaderHandle, GLES20.GL_COMPILE_STATUS, compileStatus, 0);

            // If the compilation failed, delete the shader.
            if (compileStatus[0] == 0) {
                Log.e(TAG, "Error compiling shader: " + GLES20.glGetShaderInfoLog(shaderHandle));
                GLES20.glDeleteShader(shaderHandle);
                shaderHandle = 0;
            }
        }

        if (shaderHandle == 0) {
            // TODO(shichengfeng): Handle Exception gracefully.
            throw new RuntimeException("Error creating shader.");
        }

        return shaderHandle;
    }

    /**
     * Compile and link a program.
     *
     * @param vertexShaderHandle An OpenGL handle to an already-compiled vertex shader.
     * @param fragmentShaderHandle An OpenGL handle to an already-compiled fragment shader.
     * @param attributes Attributes that need to be bound to the program.
     * @return An OpenGL handle to the program.
     */
    public static int createAndLinkProgram(int vertexShaderHandle,
            int fragmentShaderHandle, String[] attributes) {
        int programHandle = GLES20.glCreateProgram();

        if (programHandle != 0) {
            // Bind the vertex shader to the program.
            GLES20.glAttachShader(programHandle, vertexShaderHandle);

            // Bind the fragment shader to the program.
            GLES20.glAttachShader(programHandle, fragmentShaderHandle);

            // Bind attributes
            if (attributes != null) {
                int size = attributes.length;
                for (int i = 0; i < size; i++) {
                    GLES20.glBindAttribLocation(programHandle, i, attributes[i]);
                }
            }

            // Link the two shaders together into a program.
            GLES20.glLinkProgram(programHandle);

            // Get the link status.
            int[] linkStatus = new int[1];
            GLES20.glGetProgramiv(programHandle, GLES20.GL_LINK_STATUS, linkStatus, 0);

            // If the link failed, delete the program.
            if (linkStatus[0] == 0) {
                Log.e(TAG, "Error compiling program: " + GLES20.glGetProgramInfoLog(programHandle));
                GLES20.glDeleteProgram(programHandle);
                programHandle = 0;
            }
        }

        if (programHandle == 0) {
            // TODO(shichengfeng): Handle Exception gracefully.
            throw new RuntimeException("Error creating program.");
        }

        return programHandle;
    }
}


text:
#ifndef _TIPC_NODE_SUBSCR_H
#define _TIPC_NODE_SUBSCR_H

#include "addr.h"

typedef void (*net_ev_handler) (void *usr_handle);

/**
 * struct tipc_node_subscr - "node down" subscription entry
 * @node: ptr to node structure of interest (or NULL, if none)
 * @handle_node_down: routine to invoke when node fails
 * @usr_handle: argument to pass to routine when node fails
 * @nodesub_list: adjacent entries in list of subscriptions for the node
 */
struct tipc_node_subscr {
	struct tipc_node *node;
	net_ev_handler handle_node_down;
	void *usr_handle;
	struct list_head nodesub_list;
};

void tipc_nodesub_subscribe(struct tipc_node_subscr *node_sub, u32 addr,
			    void *usr_handle, net_ev_handler handle_down);
void tipc_nodesub_unsubscribe(struct tipc_node_subscr *node_sub);
void tipc_nodesub_notify(struct tipc_node *node);

#endif