text:
<?php

namespace App\Http\Controllers;

use App\Events\ProjectCreated;
use App\Events\ProjectDeleted;
use App\Events\ProjectModified;
use App\Policies\ProjectPolicy;
use App\Repositories\Catalog;
use App\Repositories\Document;
use App\Repositories\DocumentScore;
use App\Repositories\Group;
use App\Repositories\OperationLogs;
use App\Repositories\PageShare;
use App\Repositories\Project;
use App\Repositories\DocumentHistory;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Symfony\Component\Translation\Exception\NotFoundResourceException;

class ProjectController extends Controller
{
    protected $types = [
        Document::TYPE_DOC     => 'markdown',
        Document::TYPE_SWAGGER => 'swagger',
        Document::TYPE_TABLE   => 'table',
    ];

    /**
     * 用户个人首页(个人项目列表)
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function home(Request $request)
    {
        $perPage = $request->input('per_page', 19);
        $name = $request->input('name');

        /** @var Project $projectModel */
        $projectModel = Project::query();
        $projectModel->withCount('pages');
        if (!empty($name)) {
            $projectModel->where('name', 'like', "%{$name}%");
        }

        /** @var LengthAwarePaginator $projects */
        $projects = $projectModel->where('user_id', \Auth::user()->id)
                                 ->orderBy('sort_level', 'ASC')
                                 ->paginate($perPage)
                                 ->appends([
                                     'per_page' => $perPage,
                                     'name'     => $name,
                                 ]);

        return view('user-home',
            ['projects' => $projects, 'name' => $name,]);
    }

    /**
     * 创建新项目
     *
     * @param Request $request
     *
     * @return array
     * @throws \Illuminate\Auth\Access\AuthorizationException
     * @throws \Illuminate\Validation\ValidationException
     */
    public function newProjectHandle(Request $request)
    {
        $this->authorize('project-create');

        $this->validate(
            $request,
            [
                'name'        => 'required|between:1,100',
                'description' => 'max:255',
                'visibility'  => 'required|in:1,2',
                'sort_level'  => 'integer|between:-9999999999,999999999',
                'catalog'     => 'required|integer',
            ],
            [
                'name.required'   => __('project.validation.project_name_required'),
                'name.between'    => __('project.validation.project_name_between'),
                'description.max' => __('project.validation.project_description_max'),
            ]
        );

        $name = $request->input('name');
        $description = $request->input('description');
        $visibility = $request->input('visibility');
        $catalog = $request->input('catalog');

        if (\Auth::user()->can('project-sort')) {
            $sortLevel = $request->input('sort_level', 1000);
        } else {
            $sortLevel = 1000;
        }

        $project = Project::create([
            'name'        => $name,
            'description' => $description,
            'user_id'     => \Auth::user()->id,
            'visibility'  => $visibility,
            'sort_level'  => (int)$sortLevel,
            'catalog_id'  => $catalog,
        ]);

        event(new ProjectCreated($project));

        $this->alertSuccess(__('common.operation_success'));
        return [
            'id'          => $project->id,
            'name'        => $project->name,
            'description' => $project->description,
            'visibility'  => $project->visibility,
        ];
    }

    /**
     * 删除项目
     *
     * @param Request $request
     * @param         $id
     *
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
     * @throws \Exception
     * @throws \Illuminate\Auth\Access\AuthorizationException
     */
    public function delete(Request $request, $id)
    {
        $project = Project::where('id', $id)->firstOrFail();
        $this->authorize('project-delete', $project);

        $project->delete();
        event(new ProjectDeleted($project));

        return redirect(wzRoute('user:home'));
    }

    /**
     * 项目页面
     *
     * p - 文档ID
     * cm - 高亮显示的评论ID
     *
     * @param Request $request
     * @param         $id
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     * @throws \Illuminate\Validation\ValidationException
     */
    public function project(Request $request, $id)
    {
        $pageID = (int)$request->input('p', 0);

        /** @var Project $project */
        $project = Project::with('catalog')->findOrFail($id);

        $policy = new ProjectPolicy();
        if (!$policy->view(\Auth::user(), $project)) {
            abort(403, '您没有访问该项目的权限');
        }

        $page = $type = null;
        if ($pageID !== 0) {
            $queryBuilder = Document::query();

            if (config('wizard.reply_support')) {
                $queryBuilder->with([
                    'comments' => function ($query) {
                        $query->orderBy('created_at', 'desc');
                    }
                ]);
            }

            $page = $queryBuilder->where('project_id', $id)
                                 ->where('id', $pageID)
                                 ->firstOrFail();
            $type = $this->types[$page->type];

            $history = DocumentHistory::where('page_id', $page->id)
                                      ->where('id', '!=', $page->history_id)
                                      ->orderBy('id', 'desc')
                                      ->first();
            $share = PageShare::where('page_id', $page->id)
                              ->where('project_id', $page->project_id)
                              ->first();
            // 文档评分
            $scores = DocumentScore::select(DB::raw('score_type, count(*) as count'))
                                   ->where('page_id', $page->id)
                                   ->groupBy('score_type')
                                   ->get()
                                   ->mapWithKeys(function ($item) {
                                       return [$item['score_type'] => $item['count']];
                                   });
            $usefulScoreUsers = DocumentScore::where('page_id', $page->id)
                                             ->where('score_type', DocumentScore::SCORE_USEFUL)
                                             ->with([
                                                 'user' => function ($query) {
                                                     $query->select('id', 'name');
                                                 }
                                             ])
                                             ->select('id', 'user_id', 'page_id')
                                             ->orderBy('updated_at', 'desc')
                                             ->limit(10)->get();
            if (!Auth::guest()) {
                $userScoreType = DocumentScore::where('page_id', $page->id)->where('user_id',
                    Auth::user()->id)->value('score_type');
            }
        } else {
            // 查询操作历史
            $operationLogs = OperationLogs::where('project_id', $id)
                                          ->whereNotNull('page_id')
                                          ->orderBy('created_at', 'desc')
                                          ->limit(10)->get();
        }
        return view('project.project', [
            'project'            => $project,
            'pageID'             => $pageID,
            'pageItem'           => $page,
            'keyword'            => trim(urldecode($request->input('keyword', ''))),
            'scores'             => $scores ?? [],
            'useful_score_users' => $usefulScoreUsers ?? [],
            'user_score_type'    => $userScoreType ?? 0,
            'type'               => $type,
            'code'               => '',
            'operationLogs'      => $operationLogs ?? [],
            'comment_highlight'  => $request->input('cm', ''),
            'navigators'         => navigator($id, $pageID),
            'history'            => $history ?? false,
            'share'              => $share ?? false,
            'isFavorited'        => $project->isFavoriteByUser(\Auth::user()),
        ]);
    }

    /**
     * 项目配置页面
     *
     * @param Request $request
     * @param         $id
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     * @throws \Illuminate\Auth\Access\AuthorizationException
     * @throws \Illuminate\Validation\ValidationException
     */
    public function setting(Request $request, $id)
    {
        $this->validate(
            $request,
            [
                'op' => 'in:basic,privilege,advanced,sort'
            ]
        );

        $project = Project::findOrFail($id);
        $this->authorize('project-edit', $project);

        $op = $request->input('op', 'basic');
        $viewData = ['project' => $project, 'op' => $op];

        switch ($op) {
            case 'basic':
                $viewData['catalogs'] = Catalog::all();
                break;
            case 'privilege':
                $groups = Group::with([
                    'projects' => function ($query) use ($id) {
                        $query->wherePivot('project_id', $id);
                    }
                ])->get();

                // 对用户组进行分组,分为已经分配的组合剩余组,方面页面分开展示
                $viewData['addedGroups'] = $viewData['restGroups'] = [];
                /** @var Group $group */
                foreach ($groups as $group) {
                    if ($group->projects->count() === 0) {
                        $viewData['restGroups'][] = $group;
                    } else {
                        $viewData['addedGroups'][] = $group;
                    }
                }
                break;
            case 'advanced':
                break;
            case 'sort':
                $viewData['navigators'] = navigator($id);
                break;
        }

        return view("project.setting-{$op}", $viewData);
    }

    /**
     * 更新项目配置信息
     *
     * @param Request $request
     * @param         $id
     *
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
     * @throws \Illuminate\Auth\Access\AuthorizationException
     * @throws \Illuminate\Validation\ValidationException
     */
    public function settingHandle(Request $request, $id)
    {
        $this->validate($request, ['op' => 'required|in:basic,privilege,advanced,sort']);

        $op = $request->input('op');

        $project = Project::where('id', $id)->firstOrFail();
        $this->authorize('project-edit', $project);

        switch ($op) {
            case 'basic':
                $updated = $this->basicSettingHandle($request, $project);
                break;
            case 'privilege':
                $updated = $this->privilegeSettingHandle($request, $project);
                break;
            case 'advanced':
                $updated = false;
                break;
            case 'sort':
                $updated = $this->sortSettingHandle($request, $project);
                break;
            default:
                $updated = false;
        }

        if ($updated) {
            event(new ProjectModified($project, $op));
        }

        $this->alertSuccess(__('project.project_update_success'));
        return redirect(wzRoute(
            'project:setting:show',
            ['id' => $id, 'op' => $op]
        ));
    }

    /**
     * 项目基本信息更新
     *
     * @param Request $request
     * @param Project $project
     *
     * @return bool
     * @throws \Illuminate\Validation\ValidationException
     */
    private function basicSettingHandle(Request $request, Project $project): bool
    {
        $this->validate(
            $request,
            [
                'name'               => 'required|between:1,100',
                'description'        => 'max:255',
                'project_id'         => "required|in:{$project->id}|project_exist",
                'visibility'         => 'required|in:1,2',
                'sort_level'         => 'integer|between:-999999999,999999999',
                'catalog'            => 'required|integer',
                'catalog_sort_style' => 'in:0,1',
                'catalog_fold_style' => 'in:0,1,2',
            ],
            [
                'name.required'   => __('project.validation.project_name_required'),
                'name.between'    => __('project.validation.project_name_between'),
                'description.max' => __('project.validation.project_description_max'),
            ]
        );

        $name = $request->input('name');
        $description = $request->input('description');
        $visibility = $request->input('visibility');
        $sortLevel = $request->input('sort_level');
        $catalog = $request->input('catalog');
        $catalogSortStyle = $request->input('catalog_sort_style', Project::SORT_STYLE_DIR_FIRST);
        $catalogFoldStyle = $request->input('catalog_fold_style', Project::FOLD_STYLE_AUTO);

        $project->name = $name;
        $project->description = $description;
        $project->visibility = $visibility;
        $project->catalog_id = empty($catalog) ? null : $catalog;
        $project->catalog_fold_style = $catalogFoldStyle;
        $project->catalog_sort_style = $catalogSortStyle;
        if (\Auth::user()->can('project-sort') && $sortLevel != null) {
            $project->sort_level = (int)$sortLevel;
        }

        if ($project->isDirty()) {
            $project->save();
            return true;
        }

        return false;
    }

    /**
     * 项目权限信息更新
     *
     * @param Request $request
     * @param Project $project
     *
     * @return bool 如果返回true,说明执行了更新操作,false说明没有更新
     * @throws \Illuminate\Validation\ValidationException
     */
    private function privilegeSettingHandle(Request $request, Project $project): bool
    {
        $this->validate(
            $request,
            [
                'group_id'  => 'required|integer|min:1|group_exist',
                'privilege' => 'in:wr,r'
            ]
        );

        $groupID = $request->input('group_id');
        $privilege = $request->input('privilege', 'r');

        $project->groups()->detach($groupID);
        $project->groups()->attach($groupID, ['privilege' => $privilege == 'r' ? 2 : 1]);

        return true;
    }

    /**
     * 更新项目中文档的排序
     *
     * @param Request $request
     * @param Project $project
     *
     * @return bool
     * @throws \Throwable
     */
    private function sortSettingHandle(Request $request, Project $project): bool
    {
        $sortLevelsJson = $request->input('sort_levels');
        if (empty($sortLevelsJson)) {
            return false;
        }

        $sortLevels = new Collection(json_decode($sortLevelsJson, true));

        // 检查ID是否存在
        $ids = $sortLevels->map(function ($s) {
            return $s['id'];
        });

        /** @var \Illuminate\Database\Eloquent\Collection $documents */
        $documents =
            Document::whereIn('id', $ids->toArray())->where('project_id', $project->id)->get();
        $retrivedIds = $documents->map(function ($s) {
            return $s->id;
        });

        if (!$ids->diff($retrivedIds)->isEmpty()) {
            throw new NotFoundResourceException('部分文档不存在');
        }

        // 更新文档
        $sortLevelsById = $sortLevels->keyBy('id');
        \DB::transaction(function () use ($documents, $sortLevelsById) {
            $documents->each(function (Document $doc) use ($sortLevelsById) {
                $doc->sort_level = (int)$sortLevelsById->get($doc->id)['sort_level'];
                $doc->save();
            });
        });

        return false;
    }

    /**
     * 项目权限回收
     *
     * @param Request $request
     * @param         $id
     * @param         $group_id
     *
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
     * @throws \Illuminate\Auth\Access\AuthorizationException
     */
    public function groupPrivilegeRevoke(Request $request, $id, $group_id)
    {
        $project = Project::where('id', $id)->firstOrFail();
        $this->authorize('project-edit', $project);

        $project->groups()->detach($group_id);

        $this->alertSuccess(__('project.revoke_privilege_success'));

        $redirectURL = $request->input('redirect');
        if (!empty($redirectURL)) {
            return redirect($redirectURL);
        }

        return redirect(wzRoute('project:setting:handle', ['id' => $id, 'op' => 'privilege']));
    }

    /**
     * 关注、取消关注项目
     *
     * @param Request $request
     * @param         $id
     *
     * @return array
     * @throws \Illuminate\Validation\ValidationException
     */
    public function favorite(Request $request, $id)
    {
        $this->validate($request, ['action' => 'required|in:fav,unfav']);

        $action = $request->input('action');
        $project = Project::where('id', $id)->firstOrFail();
        $user = \Auth::user();

        if ($action == 'fav') {
            $user->favoriteProjects()->attach($project->id);
        } else {
            $user->favoriteProjects()->detach($project->id);
        }

        $this->alertSuccess($action == 'fav' ? '您已成功关注该项目' : '您已取消对该项目的关注');

        return [
            'message' => '操作成功',
            'reload'  => true,
        ];
    }

    /**
     * 文档目录选择,用于select的option
     *
     * @param Request $request
     * @param         $project_id
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function documentSelector(Request $request, $project_id)
    {
        /** @var Project $project */
        $project = Project::with('catalog')->findOrFail($project_id);

        $policy = new ProjectPolicy();
        if (!$policy->view(\Auth::user(), $project)) {
            abort(403, '您没有访问该项目的权限');
        }

        $exclude = [];
        $excludePageID = $request->input('exclude_page_id');
        if (!empty($excludePageID)) {
            $exclude[] = $excludePageID;
        }

        return view('project.document-selector',
            ['navigator' => navigator($project_id, 0, $exclude)]);
    }
}


text:
package com.jonass.filmespopulares.model;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by jonas on 16/01/17.
 */

public class Comentario implements Parcelable {
    private String id;
    private String autor;
    private String conteudo;

    public Comentario() {

    }

    public Comentario(String id, String autor, String conteudo) {
        this.id = id;
        this.autor = autor;
        this.conteudo = conteudo;
    }

    protected Comentario(Parcel in) {
        id = in.readString();
        autor = in.readString();
        conteudo = in.readString();
    }

    public static final Creator<Comentario> CREATOR = new Creator<Comentario>() {
        @Override
        public Comentario createFromParcel(Parcel in) {
            return new Comentario(in);
        }

        @Override
        public Comentario[] newArray(int size) {
            return new Comentario[size];
        }
    };

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getAutor() {
        return autor;
    }

    public void setAutor(String autor) {
        this.autor = autor;
    }

    public String getConteudo() {
        return conteudo;
    }

    public void setConteudo(String conteudo) {
        this.conteudo = conteudo;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(id);
        dest.writeString(autor);
        dest.writeString(conteudo);
    }

    @Override
    public String toString() {
        return "Comentario{" +
                "id='" + id + '\'' +
                ", autor='" + autor + '\'' +
                ", conteudo='" + conteudo + '\'' +
                '}';
    }
}

redpajama_set_name: RedPajamaGithub


text:
<?php

namespace AppBundle\Command;

use AppBundle\Entity\Author;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class AddAdminCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this
            ->setName('app:admin:add')
            ->setDescription('Add admin')
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $dialog = $this->getHelperSet()->get('dialog');
        $em = $this->getContainer()->get('doctrine')->getManager();
        $username = $dialog->ask($output, 'Enter admin username: ', '');
        $firstname = $dialog->ask($output, 'Firstname: ', '');
        $lastname = $dialog->ask($output, 'Lastname: ', '');
        $email = $dialog->ask($output, 'Email: ', '');
        $password = $dialog->ask($output, 'Password: ', '');
        $repeatPassword = $dialog->ask($output, 'Repeat password: ', '');

        if ($password != $repeatPassword) {
            die('Different passwords!' . "\n");
        }

        if (
            $em->getRepository("AppBundle:Author")->findOneBy(["username" => $username]) ||
            $em->getRepository("AppBundle:Author")->findOneBy(["email" => $email])
        ) {
            die('User with those login or password already exist!' . "\n");
        } else {
            $encoder = $this->getContainer()->get('security.password_encoder');;
            $admin = new Author();
            $admin->setUsername($username);
            $admin->setFirstname($firstname);
            $admin->setLastname($lastname);
            $admin->setEmail($email);
            $admin->setIsAdmin(true);
            $encoded = $encoder->encodePassword($admin, $password);

            $admin->setPassword($encoded);
            $em->persist($admin);
            $em->flush();
        }
    }
}


text:
window.LS = {};

window.LS.registration = {
    registration_data: null,
    login_data: null,
    callbacks: {
        registration_performed: null,
        login_performed: null,
        transform_form_data_pre_save: null
    },
    utils: {
        get_registration_data_as_json: function() {
            return JSON.stringify(window.LS.registration.registration_data);
        }
    },
    default_setup: function() {
        // call optionally to initialise a page as a registration page.
        // custom code can written otherwise
        // This does the following:
        //     * expects all standard field names (and matching id attributes) to be part of the form:
        //         * first_name
        //         * last_name
        //         * email
        //         * username
        //         * password
        // Accepts any additional form field and submits it too for it to be turned into profile data
        // Triggers registration upon submission of the form
        // Disables the submit button and changes the text on it (reversing this after 10 seconds in case there was an error).
        window.LS.registration.callbacks.registration_performed = function() {
            window.LS.registration.login_data = {
                username: $('#username').val(),
                password: $('#password').val()
            };
            document.location.href = 'liquidstate://onboarding/login/';
        };

        // login after registration is finished
        window.LS.registration.callbacks.login_performed = function() {
            document.location.href = 'liquidstate://onboarding/dismiss/';
        };

        window.LS.registration.callbacks.transform_form_data_pre_save = function(form_data) {
            return form_data;
        };

        $('form').on('submit', function(e) {
            e.preventDefault();
            var form_data = $(this).serializeJSON(); // actually makes a JS object
            var data = window.LS.registration.callbacks.transform_form_data_pre_save(form_data);
            window.LS.registration.registration_data = data;
            var $button = $('button[type=submit]').last();
            var previous_text = $button.text();
            var registering_text = $button.attr('data-registering-text') || 'Registering...';
            $button.html(registering_text).attr('disabled', 'disabled');
            var restore = function() {
                $button.text(previous_text).removeAttr('disabled');
            };
            setTimeout(restore, 10000);
            document.location.href = 'liquidstate://onboarding/register/';
        });
    }
};

window.LS.profile = {
    data: null,
    callbacks: {
        data_retrieved: null,
        data_set: null,
        transform_form_data_pre_load: null,
        transform_form_data_pre_save: null
    },
    options: {
        overwrite_entire_profile: false
    },
    utils: {
        get_data_as_json: function() {
            return JSON.stringify(window.LS.profile.data);
        },
        set_data_from_json: function (json_data) {
          window.LS.profile.data = JSON.parse(json_data);
        }
    },
    default_setup: function() {
            window.LS.profile.callbacks.data_retrieved = function() {
                var data = window.LS.profile.callbacks.transform_form_data_pre_load(window.LS.profile.data);
                if (data) {
                    window.LS.utils.forms.populate_profile_form(null, data);
                }
            };

            window.LS.profile.callbacks.transform_form_data_pre_load = function(form_data) {
                return form_data;
            };
            window.LS.profile.callbacks.transform_form_data_pre_save = function(form_data) {
                return form_data;
            };

            $('form').on('submit', function(e) {
                e.preventDefault();
                e.stopPropagation();

                var should_return = false;
                $('.no-submit-if-focused').each(function(index, el) {
                    if ($(el).is(':focus')) {
                        should_return = true;
                    }
                });
                if (should_return) {
                    return false;
                }

                var $button = $('button[type=submit]').last();
                var previous_text = $button.text();
                var registering_text = $button.attr('data-saving-text') || 'Saving...';
                $('button[type=submit]').html(registering_text).attr('disabled', 'disabled');
                var restore = function() {
                    $('button[type=submit]').text(previous_text).removeAttr('disabled');
                };
                setTimeout(restore, 10000);
                var form_data = $(this).serializeJSON(); // actually makes a JS object
                var data = window.LS.profile.callbacks.transform_form_data_pre_save(form_data);
                if (window.LS.profile.options.overwrite_entire_profile) {
                    window.LS.profile.data = data;
                    window.LS.profile.data['_clear_profile'] = true;
                } else {
                    $.extend(window.LS.profile.data, data);
                }
                document.location.href = 'liquidstate://app_user/set_profile/';
            });

            window.LS.profile.callbacks.data_set = function() {
                setTimeout(function() {
                    document.location.href = 'liquidstate://app_user/dismiss/';
                }, 1000);
            };
    }
};

window.LS.utils = {
    forms: {
        // generic utility, not called by the native app
        populate_profile_form: function (form, data) {
            form = form || $('form')[0];
            data = data || window.LS.profile.data;
            // reset form values from json object
            $.each(data, function (name, val) {
                var $el = $('[name="' + name + '"]', form);
                if ($el.length == 1) {
                    $el.val(val);
                } else {
                    $el = $('[name="' + name + '[]"]', form);
                    if ($el.length > 0) {
                        $el.each(function(index, input_el) {
                            var $input_el = $(input_el);
                            if (val.indexOf($input_el.val()) > -1) {
                                if ($input_el.attr('type') == 'checkbox') $input_el.attr('checked', 'checked');
                                if ($input_el.attr('type') == 'radio') $input_el.attr('checked', 'checked');
                            }
                        });
                    }
                }
            });
        }
    }
};


text:
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
                  xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
    <entity name="Enhavo\Bundle\ShopBundle\Entity\Voucher" table="shop_voucher" repository-class="Enhavo\Bundle\ShopBundle\Repository\VoucherRepository">
        <id name="id" type="integer" column="id">
            <generator />
        </id>

        <field name="code" nullable="true" />
        <field name="amount" type="integer" nullable="true" />
        <field name="redeemAmount" type="integer" nullable="true" />
        <field name="redeemedAt" type="datetime" nullable="true" />
        <field name="createdAt" type="datetime" nullable="true">
            <gedmo:timestampable on="create" />
        </field>

        <one-to-one field="coupon" target-entity="Sylius\Component\Promotion\Model\PromotionCouponInterface">
            <cascade>
                <cascade-persist />
                <cascade-remove />
                <cascade-refresh />
            </cascade>
        </one-to-one>
    </entity>
</doctrine-mapping>


text:
/*
 *
 * CommentPage constants
 *
 */

export const FETCH_MESSAGE_LIST = 'app/DailyPage/FETCH_MESSAGE_LIST';
export const LOAD_MESSAGE_LIST = 'app/DailyPage/LOAD_MESSAGE_LIST';
export const LOAD_MESSAGE_LIST_LOADING = 'app/DailyPage/LOAD_MESSAGE_LIST_LOADING';

export const SEND_MESSAGE = 'app/DailyPage/SEND_MESSAGE';
export const ADD_MESSAGE = 'app/DailyPage/ADD_MESSAGE';


text:
#if !defined(__COREFOUNDATION_CFKNOWNLOCATIONS__)
#define __COREFOUNDATION_CFKNOWNLOCATIONS__ 1

#include <CoreFoundation/CFBase.h>
#include <CoreFoundation/CFURL.h>

CF_ASSUME_NONNULL_BEGIN

typedef CF_ENUM(CFIndex, CFKnownLocationUser) {
    _kCFKnownLocationUserAny,
    _kCFKnownLocationUserCurrent,
    _kCFKnownLocationUserByName,
};

/* A note on support:

 - We document that CFPreferences… can only take AnyUser or CurrentUser as users.
 - The code we shipped so far accepted the name of any one user on the current system as an alternative, but:
 - For platforms that use the XDG spec to identify a configuration path in a user's home, we cannot determine that path for any user other than the one we're currently running as.

 So:
  - We're keeping that behavior when building Core Foundation for Darwin/ObjC for compatibility, hence the _EXTENSIBLE above; on those platforms, the …ByName enum will continue working to get locations for arbitrary usernames. But:
  - For Swift and any new platform, we are enforcing the documented constraint. Using a user value other than …Any or …Current above will assert (or return NULL if asserts are off).

 See CFKnownLocations.c for a summary of what paths are returned.
 */

// The username parameter is ignored for any user constant other than …ByName. …ByName with a NULL username is the same as …Current.
extern CFURLRef _Nullable _CFKnownLocationCreatePreferencesURLForUser(CFKnownLocationUser user, CFStringRef _Nullable username);

CF_ASSUME_NONNULL_END

#endif /* __COREFOUNDATION_CFKNOWNLOCATIONS__ */


text:
function idx = varname2varidx(vsm,names)

% VARNAME2VARIDX locates variables in vsmatrix by their name.
% --------------------------------
% idx = varname2varidx(vsm, names)
% --------------------------------
% Description: locates variables in dataset by their name.
% Input:       {vsm} vsmatrix instance.
%              {names} cell array of names, or character matrix of names.
% Output:      {idx} index(ices) of corresponding variable(s).

% © Liran Carmel
% Classification: Housekeeping functions
% Last revision date: 04-Feb-2005

% no input parsing - private directory

% turn cell into characters, if required
names = char(names);

% initialize
no_vars = size(names,1);
idx = zeros(1,no_vars);

% loop on variables names
list_vars = lower(vsm.variables(:).name);
for ii = 1:no_vars
    ind = strmatch(lower(deblank(names(ii,:))),list_vars,'exact');
    if isempty(ind)
        error('variable named ''%s'' was not found in vsmatrix %s',...
            deblank(names(ii,:)),upper(inputname(1)));
    elseif length(ind) > 1
        error(['variable named ''%s'' appears more than once in ' ...
            'dataset %s'],deblank(names(ii,:)),upper(inputname(1)));
    else
        idx(ii) = ind;
    end
end


text:
var args = [
  "rebuild",

  // The --update-binary flag tells node-pre-gyp to replace previously
  // installed local binaries with remote binaries:
  // https://github.com/mapbox/node-pre-gyp#options
  "--update-binary"
];

// Allow additional flags to be passed via the $METEOR_NPM_REBUILD_FLAGS
// environment variable.
var flags = process.env.METEOR_NPM_REBUILD_FLAGS;
if (flags) {
  args = ["rebuild"];
  flags.split(/\s+/g).forEach(function (flag) {
    if (flag) {
      args.push(flag);
    }
  });
}

exports.get = function () {
  // Make a defensive copy.
  return args.slice(0);
};


text:
module.exports = require("./webpack.config")({
	devtool: "eval",
  isDev: true
});


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

namespace PermacallWebApp.Models.ViewModels
{
    public class ShowTeamSpeakModel
    {
        public TSChannel TSRootChannel { get; set; }

    }
}


text:
namespace SmartPaging
{
    using System.Collections.Generic;

    /// <summary>
    /// Objeto de retorno para realizar páginação.
    /// </summary>
    /// <typeparam name="T">Classe a dos objetos a serem retornados.</typeparam>
    public sealed class PagedResult<T>
    {
        /// <summary>
        /// Lista com uma fração (uma página) de registros a serem entregues.
        /// </summary>
        public IList<T> Items { get; set; }

        /// <summary>
        /// Total de registros.
        /// </summary>
        public int Count { get; set; }
    }
}


text:
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/things-scene-viewer/things-scene-viewer.html">
<link rel="import" href="../../bower_components/things-scene-gmap/things-scene-gmap.html">

<link rel="import" href="../../bower_components/things-global-behavior/things-global-behavior.html">

<dom-module id="things-scene-player">
  <template>
    <style>
    :host {
      display: block;
      width: 100%;
      height: 100%;
    }

    things-scene-viewer{
      display: block;
      width: 100%; /* 전체화면보기를 위해서 필요함. */
      height: 100%;
    }

    things-scene-gmap {
      display: block;
      width: 100%; /* 전체화면보기를 위해서 필요함. */
      height: 100%;
    }
    </style>

    <things-ajax  auto=true
                  id="get-label"
                  resource-url="labels/{{labelUrl}}"
                  last-response="{{response}}"
                  response-root="items">
    </things-ajax>

    <things-scene-viewer model="[[model]]"
                         screen-size="[[globals.screen]]"
                         values="[[messages]]"
                         mode="0"
                         fit="both">
    </things-scene-viewer>

<!--
    <things-scene-gmap model="[[model]]"
                               zoom="2"
                               mode="2"
                               values="[[message]]">
    </things-scene-gmap>
 -->
  </template>

  <script>
    (function() {
      'use strict';

      Polymer({
        is: 'things-scene-player',

        behaviors: [
          Things.GlobalBehavior,
        ],

        properties: {
          label: {
            type: Object
          },
          labelUrl: {
            notify: true,
            computed: '_computeUrl(globals.baseUrl, label)'
          },
          model: {
            type: Object,
            computed: '_evalModel(response)'
          },
          message: {
            type: Object,
            notify: true
          }
        },

        _computeUrl: function(baseUrl, label) {
          if(label)
            return [label.id, '.json'].join('')
        },

        _evalModel: function(response) {
          return eval("(" + response.model + ")")
        }
      });
    })();
  </script>
</dom-module>


text:
package in.studyowl.android_recyclerview;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;

public class ListAdapter extends RecyclerView.Adapter<ItemHolder> {

  private ArrayList<String> items;

  public ListAdapter(ArrayList<String> items) {
    this.items = items;
  }

  @Override public ItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemView =
        LayoutInflater.from(parent.getContext()).inflate(R.layout.item_list, parent, false);
    return new ItemHolder(itemView);
  }

  @Override public void onBindViewHolder(ItemHolder holder, int position) {
    String text = items.get(position);
    holder.bind(text);
  }

  @Override public int getItemCount() {
    return items.size();
  }
}


text:
<!DOCTYPE html>

    <meta name="generator" content="Hugo 0.56.0" />
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>politics | Michael Lee</title>

      <meta name="robots" content="noindex">

  <meta name="author" content="">

    <meta property="og:title" content="politics" />
<meta property="og:description" content="" />
<meta property="og:type" content="website" />
<meta property="og:url" content="/tags/politics/" />

<meta property="og:updated_time" content="2017-01-05T00:00:00+00:00" />

    <meta name="twitter:site" content="@mikeleeco">
<meta name="twitter:creator" content="@mikeleeco">
<meta name="twitter:title" content="" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:image" content=""/>
<meta name="twitter:description" content=""/>

    <link href="/tags/politics/index.xml" rel="alternate" type="application/rss+xml" title="Michael Lee" />

    <link rel="canonical" href="/tags/politics/">   <link rel="icon" type="image/png" href="img/avatar-transparent.png">

    <link rel="stylesheet" href="/css/bulma.css">
    <link rel="stylesheet" href="/css/code-highlighting/highlight.min.css">

    <link rel="stylesheet" href="/css/landing.css">

  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">

        Blog

        Projects

        Interactives

        Animation

        Resume

politics

        Mapping Wisconsin Presidential Election Results

        “Your home state did us no favors…” As a Wisconsinite transplanted into the highest density of left-leaning voters in the country (District of Columbia) I’ve heard from several friends over the weeks in the aftermath of the US presidential election that voters in my home state should shoulder responsibility for contributing to Donald Trump winning an electoral majority.
The “winner-take-all” basis in which electoral votes are allocated means the margin of victory in each state is null - extra votes don’t matter - which contributes to an outcome in which a winning candidate can have fewer total votes than another nominee.

            Read More…

           Page 1 of 1

        Michael Lee - 2020


text:
Application Preview

        <textarea id="app-summary" readonly="readonly" rows="16"
            style="width: 100%;"></textarea>

        ERROR Invalid spec or server
        failure

ERROR
  Failure performing specified action


text:
/**
 * A sample application to show hwo to get Point Cloud Data from Project Tango API
 * and display in world coordinates of Opengl ES2.0.
 */
package com.bluedangertango.batvision;


text:
import { AfterViewInit, Component, ElementRef, EventEmitter, Input, Output } from '@angular/core';
import { LineNumberingMode, ViewMotion } from '../../models/view-motion';
import { ViewUnifiedChange, ViewUnifiedChangeType } from '../../models/view-unified-change';
import { DomSanitizer, SafeHtml, Title } from '@angular/platform-browser';
import { MotionRepositoryService } from '../../services/motion-repository.service';
import { LineRange, ModificationType } from '../../services/diff.service';
import { ViewChangeReco } from '../../models/view-change-reco';
import { MatDialog, MatSnackBar } from '@angular/material';
import { ChangeRecommendationRepositoryService } from '../../services/change-recommendation-repository.service';
import {
    MotionChangeRecommendationComponent,
    MotionChangeRecommendationComponentData
} from '../motion-change-recommendation/motion-change-recommendation.component';
import { BaseViewComponent } from '../../../base/base-view';
import { TranslateService } from '@ngx-translate/core';
import { ConfigService } from '../../../../core/services/config.service';

/**
 * This component displays the original motion text with the change blocks inside.
 * If the user is an administrator, each change block can be rejected.
 *
 * The line numbers are provided within the pre-rendered HTML, so we have to work with raw HTML and native HTML elements.
 *
 * It takes the styling from the parent component.
 *
 * ## Examples
 *
 * ```html
 *  <os-motion-detail-diff
 *       [motion]="motion"
 *       [changes]="changes"
 *       [scrollToChange]="change"
 *       (createChangeRecommendation)="createChangeRecommendation($event)"
 * ></os-motion-detail-diff>
 * ```
 */
@Component({
    selector: 'os-motion-detail-diff',
    templateUrl: './motion-detail-diff.component.html',
    styleUrls: ['./motion-detail-diff.component.scss']
})
export class MotionDetailDiffComponent extends BaseViewComponent implements AfterViewInit {
    @Input()
    public motion: ViewMotion;
    @Input()
    public changes: ViewUnifiedChange[];
    @Input()
    public scrollToChange: ViewUnifiedChange;

    @Output()
    public createChangeRecommendation: EventEmitter<LineRange> = new EventEmitter<LineRange>();

    /**
     * Indicates the LineNumberingMode Mode.
     */
    public lnMode: LineNumberingMode;

    /**
     * Indicates the maximum line length as defined in the configuration.
     */
    public lineLength: number;

    /**
     * @param title
     * @param translate
     * @param matSnackBar
     * @param sanitizer
     * @param motionRepo
     * @param recoRepo
     * @param dialogService
     * @param configService
     * @param el
     */
    public constructor(
        title: Title,
        translate: TranslateService,
        matSnackBar: MatSnackBar,
        private sanitizer: DomSanitizer,
        private motionRepo: MotionRepositoryService,
        private recoRepo: ChangeRecommendationRepositoryService,
        private dialogService: MatDialog,
        private configService: ConfigService,
        private el: ElementRef
    ) {
        super(title, translate, matSnackBar);

        this.configService.get('motions_default_line_numbering').subscribe(mode => (this.lnMode = mode));
        this.configService.get('motions_line_length').subscribe(lineLength => (this.lineLength = lineLength));
    }

    /**
     * Returns the part of this motion between two change objects
     * @param {ViewUnifiedChange} change1
     * @param {ViewUnifiedChange} change2
     */
    public getTextBetweenChanges(change1: ViewUnifiedChange, change2: ViewUnifiedChange): string {
        // @TODO Highlighting
        const lineRange: LineRange = {
            from: change1 ? change1.getLineTo() : 1,
            to: change2 ? change2.getLineFrom() : null
        };

        if (lineRange.from >= lineRange.to) {
            // Empty space between two amendments, or between colliding amendments
            return '';
        }

        return this.motionRepo.extractMotionLineRange(this.motion.id, lineRange, true, this.lineLength);
    }

    /**
     * Returns true if this change is colliding with another change
     * @param {ViewUnifiedChange} change
     * @param {ViewUnifiedChange[]} changes
     */
    public hasCollissions(change: ViewUnifiedChange, changes: ViewUnifiedChange[]): boolean {
        return (
            changes.filter((otherChange: ViewUnifiedChange) => {
                return (
                    otherChange.getChangeId() !== change.getChangeId() &&
                    ((otherChange.getLineFrom() >= change.getLineFrom() &&
                        otherChange.getLineFrom() < change.getLineTo()) ||
                        (otherChange.getLineTo() > change.getLineFrom() &&
                            otherChange.getLineTo() <= change.getLineTo()) ||
                        (otherChange.getLineFrom() < change.getLineFrom() &&
                            otherChange.getLineTo() > change.getLineTo()))
                );
            }).length > 0
        );
    }

    /**
     * Returns the diff string from the motion to the change
     * @param {ViewUnifiedChange} change
     */
    public getDiff(change: ViewUnifiedChange): SafeHtml {
        const html = this.motionRepo.getChangeDiff(this.motion, change, this.lineLength);
        return this.sanitizer.bypassSecurityTrustHtml(html);
    }

    /**
     * Returns the remainder text of the motion after the last change
     */
    public getTextRemainderAfterLastChange(): string {
        if (!this.lineLength) {
            return ''; // @TODO This happens in the test case when the lineLength-variable is not set
        }
        return this.motionRepo.getTextRemainderAfterLastChange(this.motion, this.changes, this.lineLength);
    }

    /**
     * Returns true if the change is a Change Recommendation
     *
     * @param {ViewUnifiedChange} change
     */
    public isRecommendation(change: ViewUnifiedChange): boolean {
        return change.getChangeType() === ViewUnifiedChangeType.TYPE_CHANGE_RECOMMENDATION;
    }

    /**
     * Returns true if no line numbers are to be shown.
     *
     * @returns whether there are line numbers at all
     */
    public isLineNumberingNone(): boolean {
        return this.lnMode === LineNumberingMode.None;
    }

    /**
     * Returns true if the line numbers are to be shown within the text with no line breaks.
     *
     * @returns whether the line numberings are inside
     */
    public isLineNumberingInline(): boolean {
        return this.lnMode === LineNumberingMode.Inside;
    }

    /**
     * Returns true if the line numbers are to be shown to the left of the text.
     *
     * @returns whether the line numberings are outside
     */
    public isLineNumberingOutside(): boolean {
        return this.lnMode === LineNumberingMode.Outside;
    }

    /**
     * Returns accepted, rejected or an empty string depending on the state of this change.
     *
     * @param change
     */
    public getAcceptanceValue(change: ViewUnifiedChange): string {
        if (change.isAccepted()) {
            return 'accepted';
        }
        if (change.isRejected()) {
            return 'rejected';
        }
        return '';
    }

    /**
     * Returns true if the change is an Amendment
     *
     * @param {ViewUnifiedChange} change
     */
    public isAmendment(change: ViewUnifiedChange): boolean {
        return change.getChangeType() === ViewUnifiedChangeType.TYPE_AMENDMENT;
    }

    /**
     * Returns true if the change is a Change Recommendation
     *
     * @param {ViewUnifiedChange} change
     */
    public isChangeRecommendation(change: ViewUnifiedChange): boolean {
        return change.getChangeType() === ViewUnifiedChangeType.TYPE_CHANGE_RECOMMENDATION;
    }

    /**
     * Gets the name of the modification type
     *
     * @param change
     */
    public getRecommendationTypeName(change: ViewChangeReco): string {
        switch (change.type) {
            case ModificationType.TYPE_REPLACEMENT:
                return 'Replacement';
            case ModificationType.TYPE_INSERTION:
                return 'Insertion';
            case ModificationType.TYPE_DELETION:
                return 'Deletion';
            default:
                return '@UNKNOWN@';
        }
    }

    /**
     * Sets a change recommendation to accepted or rejected.
     * The template has to make sure only to pass change recommendations to this method.
     *
     * @param {ViewChangeReco} change
     * @param {string} value
     */
    public async setAcceptanceValue(change: ViewChangeReco, value: string): Promise<void> {
        try {
            if (value === 'accepted') {
                await this.recoRepo.setAccepted(change);
            }
            if (value === 'rejected') {
                await this.recoRepo.setRejected(change);
            }
        } catch (e) {
            this.raiseError(e);
        }
    }

    /**
     * Sets if a change recommendation is internal or not
     *
     * @param {ViewChangeReco} change
     * @param {boolean} internal
     */
    public setInternal(change: ViewChangeReco, internal: boolean): void {
        this.recoRepo.setInternal(change, internal).then(null, this.raiseError);
    }

    /**
     * Deletes a change recommendation.
     * The template has to make sure only to pass change recommendations to this method.
     *
     * @param {ViewChangeReco} reco
     * @param {MouseEvent} $event
     */
    public deleteChangeRecommendation(reco: ViewChangeReco, $event: MouseEvent): void {
        $event.stopPropagation();
        $event.preventDefault();
        this.recoRepo.delete(reco).then(null, this.raiseError);
    }

    /**
     * Edits a change recommendation.
     * The template has to make sure only to pass change recommendations to this method.
     *
     * @param {ViewChangeReco} reco
     * @param {MouseEvent} $event
     */
    public editChangeRecommendation(reco: ViewChangeReco, $event: MouseEvent): void {
        $event.stopPropagation();
        $event.preventDefault();

        const data: MotionChangeRecommendationComponentData = {
            editChangeRecommendation: true,
            newChangeRecommendation: false,
            lineRange: {
                from: reco.getLineFrom(),
                to: reco.getLineTo()
            },
            changeRecommendation: reco
        };
        this.dialogService.open(MotionChangeRecommendationComponent, {
            height: '400px',
            width: '600px',
            data: data
        });
    }

    /**
     * Scrolls to the native element specified by [scrollToChange]
     */
    private scrollToChangeElement(change: ViewUnifiedChange): void {
        const element = <HTMLElement>this.el.nativeElement;
        const target = element.querySelector('[data-change-id="' + change.getChangeId() + '"]');
        target.scrollIntoView({ behavior: 'smooth' });
    }

    public scrollToChangeClicked(change: ViewUnifiedChange, $event: MouseEvent): void {
        $event.preventDefault();
        $event.stopPropagation();
        this.scrollToChangeElement(change);
    }

    /**
     * Called from motion-detail-original-change-recommendations -> delegate to parent
     *
     * @param {LineRange} event
     */
    public onCreateChangeRecommendation(event: LineRange): void {
        this.createChangeRecommendation.emit(event);
    }

    public ngAfterViewInit(): void {
        if (this.scrollToChange) {
            window.setTimeout(() => {
                this.scrollToChangeElement(this.scrollToChange);
            }, 50);
        }
    }
}


text:
<properties pageTitle="Test Apache Cordova apps with Karma and Jasmine"
  description="Test Apache Cordova apps with Karma and Jasmine"
  services=""
  documentationCenter=""
  authors="ajoysfernandes" />
  <tags ms.technology="cordova" s.product="Visual Studio 2015"
     ms.service="na"
     ms.devlang="javascript"
     ms.topic="article"
     ms.tgt_pltfrm="mobile-multiple"
     ms.workload="na"
     ms.date="09/10/2015"
     ms.author="t-ajfern"/>

#Test Apache Cordova apps with Karma and Jasmine
===================

In this article, you will learn how to use the [Karma test runner](http://karma-runner.github.io/0.13/index.html) with the [Jasmine test framework](http://jasmine.github.io/) in Visual Studio 2015. To help with this, we are going to look at a simple Apache Cordova project. Download the file here: [Calculator.zip](https://github.com/Microsoft/cordova-docs/blob/master/articles/tutorial-testing-cordova/karma_files/Calculator.zip?raw=true)

Once you've downloaded and opened this project in Visual Studio, the folder structure of this project should look very similar to that of a new Apache Cordova project template. The difference is that there are some additional files that we've added, and these files are highlighted below:

![enter image description here](media/karma/1.png)

----------
## Karma Video Walkthrough

After you download the file, follow the steps below or [watch the video walkthrough](https://channel9.msdn.com/Series/Visual-Studio-Tools-for-Apache-Cordova/Using-Karma-and-Jasmine-To-Test-Apache-Cordova-Apps-in-Visual-Studio-2015). In this short video, we will walk through unit testing a simple Apache Cordova application in Visual Studio 2015 using Karma and Jasmine. Along the way, we'll cover how to work with some cool new features such as the Visual Studio Task Runner Explorer that make unit testing your apps inside Visual Studio really simple.
[![Karma video walkthrough](media/karma/karma_video.png)](https://channel9.msdn.com/Series/Visual-Studio-Tools-for-Apache-Cordova/Using-Karma-and-Jasmine-To-Test-Apache-Cordova-Apps-in-Visual-Studio-2015)

----------

In order to test our files using Karma, we will:

 1. Modify package.json to download testing dependencies
 2. Modify karma.config.js to reference our required files
 3. Run gulpfile.js from the Task Runner Explorer
 4. Modify calculator-test_Jasmine.js, in the "test folder"

In the following sections, we'll walk through each step in detail and highlight any interesting things along the way!

Step 1: Modify package.json
-------------

In order to let Visual Studio know what dependencies to download, first open package.json and replace its contents with the following lines:

    {
      "name": "Calculator",
      "version": "1.0.0",
      "dependencies": {
      },
       "description": "",
      "repository": {
        "type": "git",
        "url": "https://github.com/karma-runner/gulp-karma"
      },
      "bugs": {
        "url": "https://github.com/karma-runner/gulp-karma/issues"
      },
      "homepage": "https://github.com/karma-runner/gulp-karma",
      "devDependencies": {
        "karma": "^0.13.0",
        "karma-jasmine": "^0.3.6",
        "karma-chrome-launcher": "^0.2.0",
        "gulp": "^3.9.0"
      }
    }

This will automatically install the required packages needed to test your app using Karma.

Step 2: Modify karma.config.js
-------------
In order to use Karma, we first need to make sure that our files are correctly referenced. Take a look at the "js" folder where you will see the calculator.js file. Its associated test file can be found in the "test" folder.

To reference these files, select karma.conf.js and replace the content with the following lines of code:

    module.exports = function(config) {
      config.set({
        browsers: ['Chrome'],
        frameworks: ['jasmine'],
        files: [
          'www/scripts/js/**/*.js',
          'test/**/*js'
        ]
      });
    };

This configures Chrome as the browser, selects Jasmine as the test framework, and includes any file from the js or test folder.
To learn more about configuration options, click [here](http://karma-runner.github.io/0.8/config/configuration-file.html).

Step 3: Run gulpfile.js from the Task Runner Explorer
-------------
Now click on View | Other Windows | Task Runner Explorer).

![enter image description here](media/karma/2.png)

This will open up a Task Runner Explorer window.

![enter image description here](media/karma/3.png)

Right-click on "default," which is linked to the gulp task in gulpfile.js. Select run.
This should open up a Chrome browser instance, and within the task runner, Visual Studio will show that our test case has passed.

![enter image description here](media/karma/4.png)

Step 4: Modify test file
-------------
Open the file calculator-tests_Jasmine.js and uncomment the additional three tests. Save the file. You should immediately see three of the four tests passing. This is due to the "tdd" task in gulpfile.js, which watches for changes in your files.

![enter image description here](media/karma/5.png)

The test "Calculator Jasmine can divide" failed. In order to solve this problem make a single-character change to the last test case ( .toEqual(1)), or simply replace it using the following line of code:

    it("can divide", function () {
        expect(calculator.divide(5, 5)).toEqual(1);
    });
When you save the files again, you should see that all tests have passed.

![enter image description here](media/karma/6.png)

Note that if all files are correctly referenced, you can also run gulp tasks in the Windows Command Prompt by changing directories to the project root and then typing in "gulp." (If you use this method, Node and gulp dependencies must be installed first.)

Conclusion:
-------------
In this article, you learned how to use Karma on Visual Studio. You first downloaded the required dependencies by modifying package.json, then you selected the files you wanted to reference in the karma.config.js file, and finally you learned about the Visual Studio Task Runner Explorer to run your tests.

If you would like to use the Visual Studio Test Explorer to test out your JavaScript code, try out Chutzpah <link to Chutzpah>!

A competed version of this project is provided for your use. Upon opening the solution file, please wait for all Node dependencies to automatically install. Once this is done, click on View | Other Windows | Task Runner Explorer, and you should see the gulp tasks ready to run. Download the completed version of this project : [Calculator_Final.zip](https://github.com/Microsoft/cordova-docs/blob/master/articles/tutorial-testing-cordova/karma_files/Calculator_Final.zip?raw=true)


text:
package com.hits.modules.bean;

import org.nutz.dao.DB;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Id;
import org.nutz.dao.entity.annotation.Prev;
import org.nutz.dao.entity.annotation.SQL;
import org.nutz.dao.entity.annotation.Table;

@Table("TXL_GROUP")
public class Txl_group {
	@Column
	@Id
	@Prev({
		@SQL(db = DB.ORACLE, value="SELECT TXL_GROUP_S.nextval FROM dual")
	})
	private int id;
	@Column
	private String creater;
	@Column
	private String name;
	public int getIsInsider() {
		return isInsider;
	}
	public void setIsInsider(int isInsider) {
		this.isInsider = isInsider;
	}
	@Column
	private String bz;
	@Column
	private int isInsider;
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getCreater() {
		return creater;
	}
	public void setCreater(String creater) {
		this.creater = creater;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getBz() {
		return bz;
	}
	public void setBz(String bz) {
		this.bz = bz;
	}

}


text:
package com.s3auth.hosts;

import com.amazonaws.ClientConfiguration;
import com.amazonaws.Protocol;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import com.jcabi.aspects.Cacheable;
import com.jcabi.aspects.Immutable;
import com.jcabi.aspects.Loggable;
import com.jcabi.aspects.Tv;
import java.util.concurrent.TimeUnit;
import javax.validation.constraints.NotNull;
import lombok.EqualsAndHashCode;

/**
 * Default implementation of {@link Bucket}.
 *
 * @author Yegor Bugayenko (yegor@tpc2.com)
 * @version $Id$
 * @since 0.0.1
 */
@Immutable
@EqualsAndHashCode(of = "domain")
@Loggable(Loggable.DEBUG)
final class DefaultBucket implements Bucket {

    /**
     * The domain.
     */
    private final transient Domain domain;

    /**
     * Public ctor.
     * @param dmn The domain
     */
    DefaultBucket(@NotNull final Domain dmn) {
        this.domain = dmn;
    }

    @Override
    @NotNull
    @Cacheable(lifetime = Tv.TEN, unit = TimeUnit.MINUTES)
    public AmazonS3 client() {
        final AmazonS3 client = new AmazonS3Client(
            new BasicAWSCredentials(this.domain.key(), this.domain.secret()),
            new ClientConfiguration()
                .withSocketTimeout(0)
                .withProtocol(Protocol.HTTP)
        );
        client.setEndpoint(
            String.format("%s.amazonaws.com", this.domain.region())
        );
        return client;
    }

    @Override
    public String toString() {
        return this.domain.toString();
    }

    @Override
    @NotNull
    public String name() {
        return this.domain.name();
    }

    @Override
    @NotNull
    public String key() {
        return this.domain.key();
    }

    @Override
    @NotNull
    public String secret() {
        return this.domain.secret();
    }

    @Override
    @NotNull
    public String bucket() {
        return this.domain.bucket();
    }

    @Override
    @NotNull
    public String region() {
        return this.domain.region();
    }

    @Override
    public String syslog() {
        return this.domain.syslog();
    }

}


text:
typedef struct CustomContainer CustomContainer;
typedef struct CustomContainerClass CustomContainerClass;

struct CustomContainer {
	GtkContainer parent_instance;
	GtkWidget *child;
};

struct CustomContainerClass {
	GtkContainerClass parent_class;
};

G_DEFINE_TYPE(CustomContainer, customContainer, GTK_TYPE_CONTAINER)

static void customContainer_init(CustomContainer *c)
{
	gtk_widget_set_has_window(GTK_WIDGET(c), FALSE);
}

static void customContainer_dispose(GObject *obj)
{
	G_OBJECT_CLASS(customContainer_parent_class)->dispose(obj);
}

static void customContainer_finalize(GObject *obj)
{
	G_OBJECT_CLASS(customContainer_parent_class)->finalize(obj);
}

static void customContainer_add(GtkContainer *container, GtkWidget *widget)
{
	gtk_widget_set_parent(widget, GTK_WIDGET(container));
	CUSTOM_CONTAINER(container)->child = widget;
}

static void customContainer_remove(GtkContainer *container, GtkWidget *widget)
{
	gtk_widget_unparent(widget);
	CUSTOM_CONTAINER(container)->child = NULL;
}

static void customContainer_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
	gtk_widget_set_allocation(widget, allocation);
	if (CUSTOM_CONTAINER(widget)->child != NULL)
		gtk_widget_size_allocate(CUSTOM_CONTAINER(widget)->child, allocation);
}

static void customContainer_get_preferred_width(GtkWidget *widget, gint *min, gint *nat)
{
	if (CUSTOM_CONTAINER(widget)->child != NULL) {
		gtk_widget_get_preferred_width(CUSTOM_CONTAINER(widget)->child, min, nat);
		return;
	}
	if (min != NULL)
		*min = 0;
	if (nat != NULL)
		*nat = 0;
}

static void customContainer_get_preferred_height(GtkWidget *widget, gint *min, gint *nat)
{
	if (CUSTOM_CONTAINER(widget)->child != NULL) {
		gtk_widget_get_preferred_height(CUSTOM_CONTAINER(widget)->child, min, nat);
		return;
	}
	if (min != NULL)
		*min = 0;
	if (nat != NULL)
		*nat = 0;
}

static void customContainer_forall(GtkContainer *container, gboolean includeInternals, GtkCallback callback, gpointer data)
{
	if (CUSTOM_CONTAINER(container)->child != NULL)
		(*callback)(CUSTOM_CONTAINER(container)->child, data);
}

static void customContainer_class_init(CustomContainerClass *class)
{
	G_OBJECT_CLASS(class)->dispose = customContainer_dispose;
	G_OBJECT_CLASS(class)->finalize = customContainer_finalize;
	GTK_WIDGET_CLASS(class)->size_allocate = customContainer_size_allocate;
//	GTK_WIDGET_CLASS(class)->get_preferred_width = customContainer_get_preferred_width;
//	GTK_WIDGET_CLASS(class)->get_preferred_height = customContainer_get_preferred_height;
	GTK_CONTAINER_CLASS(class)->add = customContainer_add;
	GTK_CONTAINER_CLASS(class)->remove = customContainer_remove;
	GTK_CONTAINER_CLASS(class)->forall = customContainer_forall;
}

int main(void)
{
	gtk_init(NULL, NULL);
	GtkWidget *mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	GtkWidget *cc = g_object_new(CUSTOM_CONTAINER_TYPE, NULL);
	gtk_container_add(GTK_CONTAINER(cc), gtk_button_new_with_label("Test"));
	gtk_container_add(GTK_CONTAINER(mainwin), cc);
	gtk_widget_show_all(mainwin);
	gtk_main();
	return 0;
}


text:
//////////////////////////////////////////////////////////////////

#ifndef H_SG_WC6MERGE__PRIVATE_PROTOTYPES_H
#define H_SG_WC6MERGE__PRIVATE_PROTOTYPES_H

BEGIN_EXTERN_C;

//////////////////////////////////////////////////////////////////
// TODO 2012/01/20 Change the "SG_" to "sg_" to make these routines
// TODO            look like private routines.

void SG_mrg__free(SG_context * pCtx, SG_mrg * pMrg);

#define SG_MRG_NULLFREE(pCtx,p) _sg_generic_nullfree(pCtx,p,SG_mrg__free)

/**
 * Allocate a pMrg structure for computing a merge on the version control tree.
 * This only allocates the structure and used the given pending-tree to find the
 * WD, REPO, BASELINE, and determine if the WD is dirty.
 *
 * Use SG_mrg__compute_merge() to actually compute the merge in memory
 * and then SG_mrg__apply_merge() to actually update the WD.
 */
void SG_mrg__alloc(SG_context * pCtx,
				   SG_wc_tx * pWcTx,
				   const SG_wc_merge_args * pMergeArgs,
				   SG_mrg ** ppMrg_New);

#if defined(DEBUG)
#define SG_MRG__ALLOC(pCtx,pWcTx,pMergeArgs,ppMrg_New)					\
	SG_STATEMENT(	SG_mrg * _pNew = NULL;								\
					SG_mrg__alloc(pCtx,pWcTx,pMergeArgs,&_pNew);		\
					_sg_mem__set_caller_data(_pNew,__FILE__,__LINE__,"SG_mrg");	\
					*(ppMrg_New) = _pNew;								)
#else
#define SG_MRG__ALLOC(pCtx,pWcTx,pMergeArgs,ppMrg_New)					\
	SG_mrg__alloc(pCtx,pWcTx,pMergeArgs,ppMrg_New)
#endif

//////////////////////////////////////////////////////////////////

void SG_mrg_cset_entry__free(SG_context * pCtx, SG_mrg_cset_entry * pMrgCSetEntry);

/**
 * Load the contents of the SG_treenode_entry into a new SG_mrg_cset_entry
 * and add it to the flat list of entries in the SG_mrg_cset.
 */
void SG_mrg_cset_entry__load__using_repo(SG_context * pCtx,
										 SG_mrg * pMrg,
										 SG_mrg_cset * pMrgCSet,
										 const char * pszGid_Parent,		// will be null for actual-root directory
										 const char * pszGid_Self,
										 const SG_treenode_entry * pTne_Self,
										 SG_mrg_cset_entry ** ppMrgCSetEntry_New);

/**
 * Load the SG_treenode for a directory and convert each SG_treenode_entry
 * into a SG_mrg_cset_entry and load it into the flat list of entries in
 * the SG_mrg_cset.
 */
void SG_mrg_cset_entry__load_subdir__using_repo(SG_context * pCtx,
												SG_mrg * pMrg,
												SG_mrg_cset * pMrgCSet,
												const char * pszGid_Self,
												SG_mrg_cset_entry * pMrgCSetEntry_Self,
												const char * pszHid_Blob);

void SG_mrg_cset_entry__load__using_wc(SG_context * pCtx,
											 SG_mrg * pMrg,
											 SG_mrg_cset * pMrgCSet,
											 const char * pszGid_Parent,
											 const char * pszGid_Self,
											 sg_wc_liveview_item * pLVI_Self,
											 SG_mrg_cset_entry ** ppMrgCSetEntry_New);

void SG_mrg_cset_entry__load_subdir__using_wc(SG_context * pCtx,
													SG_mrg * pMrg,
													SG_mrg_cset * pMrgCSet,
													const char * pszGid_Self,
													sg_wc_liveview_item * pLVI_Self,
													SG_mrg_cset_entry * pMrgCSetEntry_Self);

/**
 * Compare 2 entries for equality.  For files and symlinks we compare everything.
 * For directories, we omit the contents of the directory (the HID-BLOB).
 */
void SG_mrg_cset_entry__equal(SG_context * pCtx,
							  const SG_mrg_cset_entry * pMrgCSetEntry_1,
							  const SG_mrg_cset_entry * pMrgCSetEntry_2,
							  SG_mrg_cset_entry_neq * pNeq);

/**
 * Clone the given entry and add it to the flat list of entries in the
 * given SG_mrg_cset.
 *
 * We do not copy the HID-BLOB for directories because it is a computed
 * field and the value from the source entry probably won't match the
 * value that will be computed on the directory in the destination CSET.
 *
 * If the entry does not have a parent, we assume that it is the root "@/"
 * directory and set the _Root fields in the destination CSET.
 *
 * You DO NOT own the returned pointer.
 */
void SG_mrg_cset_entry__clone_and_insert_in_cset(SG_context * pCtx,
												 SG_mrg * pMrg,
												 const SG_mrg_cset_entry * pMrgCSetEntry_Src,
												 SG_mrg_cset * pMrgCSet_Result,
												 SG_mrg_cset_entry ** ppMrgCSetEntry_Result);

/**
 * We get called once for each entry which is a member of a collision
 * equivalence class.
 *
 * We want to assign a unique entryname to this file/symlink/directory
 * so that we can completely populate the directory during the merge.
 *
 * That is, if we have 2 branches that each created a new file
 * called "foo", we can't put both in the directory.  So create
 * something like "foo~<gid7>".
 * and let the user decide the names when they RESOLVE things.
 */
SG_rbtree_foreach_callback SG_mrg_cset_entry__make_unique_entrynames;

void SG_mrg_cset_entry__forget_inherited_hid_blob(SG_context * pCtx,
												  SG_mrg_cset_entry * pMrgCSetEntry);

void SG_mrg_cset_entry__check_for_outstanding_issue(SG_context * pCtx,
													SG_mrg * pMrg,
													sg_wc_liveview_item * pLVI,
													SG_mrg_cset_entry * pMrgCSetEntry);

//////////////////////////////////////////////////////////////////

void SG_mrg_cset__free(SG_context * pCtx, SG_mrg_cset * pMrgCSet);

void SG_mrg_cset__alloc(SG_context * pCtx,
						const char * pszMnemonicName,
						const char * pszCSetLabel,
						const char * pszAcceptLabel,
						SG_mrg_cset_origin origin,
						SG_daglca_node_type nodeType,
						SG_mrg_cset ** ppMrgCSet);

#if defined(DEBUG)
#define SG_MRG_CSET__ALLOC(pCtx,p1,p2,p3,o,n,pp)						\
	SG_STATEMENT(	SG_mrg_cset * _pNew = NULL;							\
					SG_mrg_cset__alloc(pCtx,p1,p2,p3,o,n,&_pNew);		\
					_sg_mem__set_caller_data(_pNew,__FILE__,__LINE__,"SG_mrg_cset"); \
					*(pp) = _pNew;										)
#else
#define SG_MRG_CSET__ALLOC(pCtx,p1,p2,p3,o,n,pp)	\
	SG_mrg_cset__alloc(pCtx,p1,p2,p3,o,n,pp)
#endif

/**
 * Load the entire contents of the version control tree as of
 * this CSET into memory.
 *
 * This loads all of the entries (files/symlinks/directories) into
 * a flat list.  Each SG_treenode_entry is converted to a SG_mrg_cset_entry
 * and they are added to SG_mrg_cset.prbEntries.
 *
 * This version of __load_entire_cset__ uses the REPO to get a
 * clean view of the CSET as it was recorded.
 *
 */
void SG_mrg_cset__load_entire_cset__using_repo(SG_context * pCtx,
											   SG_mrg * pMrg,
											   SG_mrg_cset * pMrgCSet,
											   const char * pszHid_CSet);

/**
 * This version loads the CSET using the current/live view
 * as it exists in the WC (and the WC TX).
 *
 */
void SG_mrg_cset__load_entire_cset__using_wc(SG_context * pCtx,
											 SG_mrg * pMrg,
											 SG_mrg_cset * pMrgCSet,
											 const char * pszHid_CSet);

/**
 * Load a specific CSet into the AUX table.  These
 * are used when we need an alternate per-item ancestor.
 *
 * You do not own the result.
 *
 */
void sg_mrg_cset__load_aux__using_repo(SG_context * pCtx,
									   SG_mrg * pMrg,
									   const char * pszHid_CSet,
									   SG_mrg_cset **ppMrgCSet);

/**
 * Set the value of SG_mrg_cset_entry.markerValue to the given newValue
 * on all entries in the tree.
 */
void SG_mrg_cset__set_all_markers(SG_context * pCtx,
								  SG_mrg_cset * pMrgCSet,
								  SG_int64 newValue);

#if TRACE_WC_MERGE
/**
 * Create a debug string containing the full repo-path of the entry
 * as it appeared in this version of this version control tree.
 *
 * The caller must free the returned string.
 */
void _sg_mrg_cset__compute_repo_path_for_entry(SG_context * pCtx,
											   SG_mrg_cset * pMrgCSet,
											   const char * pszGid_Entry,
											   SG_string ** ppStringResult);		// caller must free this
#endif

/**
 * Create a flat list of the directories in the CSET.  Within each directory, create
 * a flat list of the entries within the directory.  This is not a true hierarchy
 * (because we don't have links between the directories), but it can simulate one
 * when needed.
 *
 * This populates the SG_mrg_cset.prbDirs and .pMrgCSetDir_Root members.  We use the
 * flat list of entries in .prbEntries to drive this.
 *
 * Once this is computed and bound to the SG_mrg_cset, we must consider the
 * SG_mrg_cset frozen.
 */
void SG_mrg_cset__compute_cset_dir_list(SG_context * pCtx,
										SG_mrg_cset * pMrgCSet);

/**
 * Inspect all of the directories and look for real and potential collisions.
 */
void SG_mrg_cset__check_dirs_for_collisions(SG_context * pCtx,
											SG_mrg_cset * pMrgCSet,
											SG_mrg * pMrg);

/**
 * Register a conflict on the merge.  That is, add the conflict info for an entry
 * (the ancestor entry and all of the leaf versions that changed it in divergent
 * ways) to the conflict-list.
 *
 * Note that we do not distinguish between hard-conflicts (that can't be automatically
 * resolved) and candiate-conflicts (where we just need to do diff3 or something before
 * we can decide what to do).
 *
 * We take ownership of the conflict object given, if there are no errors.
 */
void SG_mrg_cset__register_conflict(SG_context * pCtx,
									SG_mrg_cset * pMrgCSet,
									SG_mrg_cset_entry_conflict * pMrgCSetEntryConflict);

/**
 * Register that an entry was deleted on the merge.  We do this by adding the GID-ENTRY
 * of the entry in a deleted-list in the result-cset.  (We can't store the entry as it
 * appeared in the source-cset that deleted it, because it, well, deleleted it.)
 *
 * As a convenience, we remember the original entry from the ancestor in the deleted-list
 * in case it would be helpful.  (<gid-entry>, <entry-from-ancestor>).
 *
 * Also, since the entry may have been deleted in multiple branches, we DON'T try to store
 * (<gid-entry>,<cset-leaf>) because we'd just get duplicates.
 *
 * We do not own the entry (but then you didn't own it either).
 */
void SG_mrg_cset__register_delete(SG_context * pCtx,
								  SG_mrg_cset * pMrgCSet,
								  SG_mrg_cset_entry * pMrgCSetEntry_Ancestor);

/**
 * We allow entries to be added to the CSET at random.
 * But as soon as you compute the directory list, we consider it frozen.
 */
#define SG_MRG_CSET__IS_FROZEN(pMrgCSet)	((pMrgCSet)->prbDirs != NULL)

/**
 * Look at all entries in the (result) cset and make unique entrynames
 * for any that have issues.  This includes:
 * [] members of a collision (multiple entries in different branches
 *    that want to use the same entryname (such as independent ADDS
 *    with the same name))
 * [] divergent renames (an entry given different names in different
 *    branches (and where we have to arbitrarily pick a name))
 * [] optionally, entries that had portability warnings (such as
 *    "README" and "readme" comming together in a directory for the
 *    first time).
 */
void SG_mrg_cset__make_unique_entrynames(SG_context * pCtx,
										 SG_mrg_cset * pMrgCSet);

//////////////////////////////////////////////////////////////////

void SG_mrg_cset_dir__free(SG_context * pCtx,
						   SG_mrg_cset_dir * pMrgCSetDir);

void SG_mrg_cset_dir__alloc__from_entry(SG_context * pCtx,
										SG_mrg_cset * pMrgCSet,
										SG_mrg_cset_entry * pMrgCSetEntry,
										SG_mrg_cset_dir ** ppMrgCSetDir);

void SG_mrg_cset_dir__add_child_entry(SG_context * pCtx,
									  SG_mrg_cset_dir * pMrgCSetDir,
									  SG_mrg_cset_entry * pMrgCSetEntry);

SG_rbtree_foreach_callback SG_mrg_cset_dir__check_for_collisions;

//////////////////////////////////////////////////////////////////

void SG_mrg_cset_entry_collision__alloc(SG_context * pCtx,
										SG_mrg_cset_entry_collision ** ppMrgCSetEntryCollision);

void SG_mrg_cset_entry_collision__free(SG_context * pCtx,
									   SG_mrg_cset_entry_collision * pMrgCSetEntryCollision);

void SG_mrg_cset_entry_collision__add_entry(SG_context * pCtx,
											SG_mrg_cset_entry_collision * pMrgCSetEntryCollision,
											SG_mrg_cset_entry * pMrgCSetEntry);

//////////////////////////////////////////////////////////////////

void SG_mrg_cset_entry_conflict__alloc(SG_context * pCtx,
									   SG_mrg_cset * pMrgCSet,
									   SG_mrg_cset_entry * pMrgCSetEntry_Ancestor,
									   SG_mrg_cset_entry * pMrgCSetEntry_Baseline,
									   SG_mrg_cset_entry_conflict ** ppMrgCSetEntryConflict);

void SG_mrg_cset_entry_conflict__free(SG_context * pCtx,
									  SG_mrg_cset_entry_conflict * pMrgCSetEntryConflict);

/**
 * Add this leaf to the list of branches where this entry was deleted.
 */
void SG_mrg_cset_entry_conflict__append_delete(SG_context * pCtx,
											   SG_mrg_cset_entry_conflict * pMrgCSetEntryConflict,
											   SG_mrg_cset * pMrgCSet_Leaf_k);

/**
 * Add a this leaf's entry as a CHANGED-ENTRY to the (potential) conflict.
 * We also store the NEQ flags relative to the ancestor entry.
 */
void SG_mrg_cset_entry_conflict__append_change(SG_context * pCtx,
											   SG_mrg_cset_entry_conflict * pMrgCSetEntryConflict,
											   SG_mrg_cset_entry * pMrgCSetEntry_Leaf_k,
											   SG_mrg_cset_entry_neq neq);

void SG_mrg_cset_entry_conflict__count_deletes(SG_context * pCtx,
											   SG_mrg_cset_entry_conflict * pMrgCSetEntryConflict,
											   SG_uint32 * pCount);

void SG_mrg_cset_entry_conflict__count_changes(SG_context * pCtx,
											   SG_mrg_cset_entry_conflict * pMrgCSetEntryConflict,
											   SG_uint32 * pCount);

void SG_mrg_cset_entry_conflict__count_unique_attrbits(SG_context * pCtx,
													   SG_mrg_cset_entry_conflict * pMrgCSetEntryConflict,
													   SG_uint32 * pCount);

void SG_mrg_cset_entry_conflict__count_unique_entryname(SG_context * pCtx,
														SG_mrg_cset_entry_conflict * pMrgCSetEntryConflict,
														SG_uint32 * pCount);

void SG_mrg_cset_entry_conflict__count_unique_gid_parent(SG_context * pCtx,
														 SG_mrg_cset_entry_conflict * pMrgCSetEntryConflict,
														 SG_uint32 * pCount);

void SG_mrg_cset_entry_conflict__count_unique_symlink_hid_blob(SG_context * pCtx,
															   SG_mrg_cset_entry_conflict * pMrgCSetEntryConflict,
															   SG_uint32 * pCount);

void SG_mrg_cset_entry_conflict__count_unique_submodule_hid_blob(SG_context * pCtx,
																 SG_mrg_cset_entry_conflict * pMrgCSetEntryConflict,
																 SG_uint32 * pCount);

void SG_mrg_cset_entry_conflict__count_unique_file_hid_blob(SG_context * pCtx,
															SG_mrg_cset_entry_conflict * pMrgCSetEntryConflict,
															SG_uint32 * pCount);

//////////////////////////////////////////////////////////////////

/**
 * Compute what NEEDS TO HAPPEN to perform a simple merge
 * of CSETs L0 and L1 relative to common ancestor A and
 * producing M.  (We do not actually produce M.)
 *
 * We assume a clean WD.
 *
 *     A
 *    / \.
 *  L0   L1
 *    \ /
 *     M
 *
 * The ancestor may or may not be the absolute LCA.  Our
 * computation may be part of a larger merge that will use
 * our result M as a leaf in another portion of the graph.
 *
 * We return a "candidate SG_mrg_cset" that relects what
 * *should* be in the merge result if we decide to apply it.
 * This HAS NOT be added to any container in pMrg; you are
 * responsible for freeing it.
 *
 * pszInterimCSetName is a label for your convenience (and
 * may be used in debug/log messages).
 */
void SG_mrg__compute_simple2(SG_context * pCtx,
							 SG_mrg * pMrg,
							 const char * pszInterimCSetName,
							 SG_mrg_cset * pMrgCSet_Ancestor,
							 SG_mrg_cset * pMrgCSet_Leaf_0,
							 SG_mrg_cset * pMrgCSet_Leaf_1,
							 SG_mrg_cset ** ppMrgCSet_Result);

/**
 * TODO 2012/01/20 remove this routine since n-way never happened.
 *
 * Compute what NEEDS TO HAPPEN to perform a simple merge
 * of N CSets relative to a common ancestor A and producing
 * a single M.  (We do not actually produce M.)
 *
 * We assume a clean WD.
 *
 * When N > 2, this is conceptually similar to GIT's Octopus Merge.
 * And like them, we may complain and stop if there are conflicts
 * that would require too much manual involvement; that is, for
 * large values of N, we only attempt to merge orthogonal changes.
 *
 *               A
 *    __________/ \__________
 *   /   /                   \.
 * L0  L1       ...           Ln-1
 *   \___\______   __________/
 *              \ /
 *               M
 *
 * The ancestor may or may not be the absolute LCA.  Our
 * computation may be part of a larger merge that will use
 * our result M as a leaf in another portion of the graph.
 *
 * We return a "candidate SG_mrg_cset" that relects what
 * *should* be in the merge result if we decide to apply it.
 * This HAS NOT be added to any container in pMrg; you are
 * responsible for freeing it.
 *
 * pszInterimCSetName is a label for your convenience (and
 * may be used in debug/log messages).
 */
void SG_mrg__compute_simpleV(SG_context * pCtx,
							 SG_mrg * pMrg,
							 const char * pszInterimCSetName,
							 SG_mrg_cset * pMrgCSet_Ancestor,
							 SG_vector * pVec_MrgCSets_Leaves,
							 SG_mrg_cset ** ppMrgCSet_Result);

//////////////////////////////////////////////////////////////////

/**
 * Resolve all of the __FILE_EDIT_TBD conflicts in the given result-cset.
 * Update the stats if we were able to auto-merge any.
 */
void SG_mrg__automerge_files(SG_context * pCtx, SG_mrg * pMrg, SG_mrg_cset * pMrgCSet);

//////////////////////////////////////////////////////////////////

void _sg_mrg__create_pathname_for_conflict_file(SG_context * pCtx,
												SG_mrg * pMrg,
												SG_mrg_cset_entry_conflict * pMrgCSetEntryConflict,
												const char * pszPrefix,
												SG_pathname ** ppPathReturned);

void _sg_mrg__export_to_temp_file(SG_context * pCtx, SG_mrg * pMrg,
								  const char * pszHidBlob,
								  const SG_pathname * pPathTempFile);

void _sg_mrg__copy_wc_to_temp_file(SG_context * pCtx, SG_mrg * pMrg,
								   SG_mrg_cset_entry * pMrgCSetEntry,
								   const SG_pathname * pPathTempFile);

//////////////////////////////////////////////////////////////////

void sg_wc_tx__merge__determine_target_cset(SG_context * pCtx,
											SG_mrg * pMrg);

void sg_wc_tx__merge__get_starting_conditions(SG_context * pCtx,
											  SG_mrg * pMrg);

void sg_wc_tx__merge__compute_lca(SG_context * pCtx,
								  SG_mrg * pMrg);

void sg_wc_tx__merge__load_csets(SG_context * pCtx,
								 SG_mrg * pMrg);

void sg_wc_tx__merge__compute_simple2(SG_context * pCtx,
									  SG_mrg * pMrg);

void sg_wc_tx__merge__prepare_issue_table(SG_context * pCtx,
										  SG_mrg * pMrg);

void sg_wc_tx__merge__prepare_issues(SG_context * pCtx,
									 SG_mrg * pMrg);

void sg_wc_tx__merge__queue_plan(SG_context * pCtx,
								 SG_mrg * pMrg);

void sg_wc_tx__merge__queue_plan__add_special(SG_context * pCtx,
											  SG_mrg * pMrg,
											  const char * pszGid,
											  SG_mrg_cset_entry * pMrgCSetEntry_FinalResult);

void sg_wc_tx__merge__queue_plan__delete(SG_context * pCtx,
										SG_mrg * pMrg);

void sg_wc_tx__merge__queue_plan__entry(SG_context * pCtx,
										SG_mrg * pMrg);

void sg_wc_tx__merge__queue_plan__peer(SG_context * pCtx, SG_mrg * pMrg,
									   const char * pszKey_GidEntry,
									   SG_mrg_cset_entry * pMrgCSetEntry_FinalResult,
									   const SG_mrg_cset_entry * pMrgCSetEntry_Baseline);

void sg_wc_tx__merge__queue_plan__park(SG_context * pCtx,
									   SG_mrg * pMrg,
									   SG_mrg_cset_entry * pMrgCSetEntry);

void sg_wc_tx__merge__queue_plan__undo_delete(SG_context * pCtx,
											  SG_mrg * pMrg,
											  const char * pszGid,
											  SG_mrg_cset_entry * pMrgCSetEntry_FinalResult);

void sg_wc_tx__merge__queue_plan__undo_lost(SG_context * pCtx,
											SG_mrg * pMrg,
											const char * pszGid,
											SG_mrg_cset_entry * pMrgCSetEntry_FinalResult);

void sg_wc_tx__merge__queue_plan__unpark(SG_context * pCtx,
										 SG_mrg * pMrg);

void sg_wc_tx__merge__queue_plan__kill_list(SG_context * pCtx,
											SG_mrg * pMrg);

void sg_wc_tx__merge__make_stats(SG_context * pCtx,
								 SG_mrg * pMrg,
								 SG_vhash ** ppvhStats);

//////////////////////////////////////////////////////////////////

void sg_wc_tx__postmerge__commit_cleanup(SG_context * pCtx,
										 SG_wc_tx * pWcTx);

//////////////////////////////////////////////////////////////////

#define SG_MRG_CSET_ENTRY_COLLISION_NULLFREE(pCtx,p)        SG_STATEMENT( SG_context__push_level(pCtx);      SG_mrg_cset_entry_collision__free(pCtx, p);    SG_ASSERT(!SG_CONTEXT__HAS_ERR(pCtx)); SG_context__pop_level(pCtx); p=NULL; )
#define SG_MRG_CSET_ENTRY_CONFLICT_NULLFREE(pCtx,p)         SG_STATEMENT( SG_context__push_level(pCtx);       SG_mrg_cset_entry_conflict__free(pCtx, p);    SG_ASSERT(!SG_CONTEXT__HAS_ERR(pCtx)); SG_context__pop_level(pCtx); p=NULL; )
#define SG_MRG_CSET_ENTRY_NULLFREE(pCtx,p)                  SG_STATEMENT( SG_context__push_level(pCtx);                SG_mrg_cset_entry__free(pCtx, p);    SG_ASSERT(!SG_CONTEXT__HAS_ERR(pCtx)); SG_context__pop_level(pCtx); p=NULL; )
#define SG_MRG_CSET_DIR_NULLFREE(pCtx,p)                    SG_STATEMENT( SG_context__push_level(pCtx);                  SG_mrg_cset_dir__free(pCtx, p);    SG_ASSERT(!SG_CONTEXT__HAS_ERR(pCtx)); SG_context__pop_level(pCtx); p=NULL; )
#define SG_MRG_CSET_NULLFREE(pCtx,p)                        SG_STATEMENT( SG_context__push_level(pCtx);                      SG_mrg_cset__free(pCtx, p);    SG_ASSERT(!SG_CONTEXT__HAS_ERR(pCtx)); SG_context__pop_level(pCtx); p=NULL; )

//////////////////////////////////////////////////////////////////

#if TRACE_WC_MERGE
void _sg_wc_tx__merge__trace_msg__dump_entry_conflict_flags(SG_context * pCtx,
															SG_mrg_cset_entry_conflict_flags flags,
															SG_uint32 indent);

void _sg_wc_tx__merge__trace_msg__dir_list_as_hierarchy(SG_context * pCtx,
														const char * pszLabel,
														SG_mrg_cset * pMrgCSet);

void _sg_wc_tx__merge__trace_msg__dump_raw_stats(SG_context * pCtx,
												 SG_mrg * pMrg);

#endif

#if 0 && TRACE_WC_MERGE

static SG_rbtree_foreach_callback _sg_wc_tx__merge__trace_msg__dir_list_as_hierarchy1;

static void _sg_wc_tx__merge__trace_msg__v_input(SG_context * pCtx,
												 const char * pszLabel,
												 const char * pszInterimCSetName,
												 SG_mrg_cset * pMrgCSet_Ancestor,
												 SG_vector * pVec_MrgCSet_Leaves);
static void _sg_wc_tx__merge__trace_msg__v_ancestor(SG_context * pCtx,
													const char * pszLabel,
													SG_int32 marker_value,
													SG_mrg_cset * pMrgCSet_Ancestor,
													const char * pszGid_Entry);
static void _sg_wc_tx__merge__trace_msg__v_leaf_eq_neq(SG_context * pCtx,
													   const char * pszLabel,
													   SG_int32 marker_value,
													   SG_uint32 kLeaf,
													   SG_mrg_cset * pMrgCSet_Leaf_k,
													   const char * pszGid_Entry,
													   SG_mrg_cset_entry_neq neq);
static void _sg_wc_tx__merge__trace_msg__v_leaf_deleted(SG_context * pCtx,
														const char * pszLabel,
														SG_int32 marker_value,
														SG_mrg_cset * pMrgCSet_Ancestor,
														SG_uint32 kLeaf,
														const char * pszGid_Entry);
static void _sg_wc_tx__merge__trace_msg__v_leaf_added(SG_context * pCtx,
													  const char * pszLabel,
													  SG_int32 marker_value,
													  SG_mrg_cset * pMrgCSet_Leaf_k,
													  SG_uint32 kLeaf,
													  SG_mrg_cset_entry * pMrgCSetEntry_Leaf_k);
static void _sg_wc_tx__merge__trace_msg__dump_delete_list(SG_context * pCtx,
														  const char * pszLabel,
														  SG_mrg_cset * pMrgCSet_Result);

#endif

//////////////////////////////////////////////////////////////////

void sg_wc_tx__merge__delete_automerge_tempfiles_on_abort(SG_context * pCtx,
														  SG_wc_tx * pWcTx);

//////////////////////////////////////////////////////////////////

void sg_wc_tx__fake_merge__update__build_pc(SG_context * pCtx,
											SG_mrg * pMrg);

void sg_wc_tx__fake_merge__update__get_starting_conditions(SG_context * pCtx,
														   SG_mrg * pMrg,
														   const char * pszHid_StartingBaseline,
														   const char * pszBranchName_Starting);

void sg_wc_tx__fake_merge__update__determine_target_cset(SG_context * pCtx,
														 SG_mrg * pMrg,
														 const char * pszHidTarget);

void sg_wc_tx__fake_merge__update__compute_lca(SG_context * pCtx, SG_mrg * pMrg);

void sg_wc_tx__fake_merge__update__load_csets(SG_context * pCtx, SG_mrg * pMrg);

void sg_wc_tx__fake_merge__update__status(SG_context * pCtx,
										  SG_mrg * pMrg,
										  SG_varray ** ppvaStatus);

//////////////////////////////////////////////////////////////////

void sg_wc_tx__fake_merge__revert_all__get_starting_conditions(SG_context * pCtx, SG_mrg * pMrg);

void sg_wc_tx__fake_merge__revert_all__determine_target_cset(SG_context * pCtx, SG_mrg * pMrg);

void sg_wc_tx__fake_merge__revert_all__compute_lca(SG_context * pCtx, SG_mrg * pMrg);

void sg_wc_tx__fake_merge__revert_all__load_csets(SG_context * pCtx, SG_mrg * pMrg);

void sg_wc_tx__fake_merge__revert_all__cleanup_db(SG_context * pCtx, SG_mrg * pMrg);

//////////////////////////////////////////////////////////////////

void sg_wc_tx__merge__add_to_kill_list(SG_context * pCtx,
									   SG_mrg * pMrg,
									   SG_uint64 uiAliasGid);

void sg_wc_tx__merge__remove_from_kill_list(SG_context * pCtx,
											SG_mrg * pMrg,
											const SG_uint64 uiAliasGid);

//////////////////////////////////////////////////////////////////

void sg_wc_tx__merge__main(SG_context * pCtx,
						   SG_wc_tx * pWcTx,
						   const SG_wc_merge_args * pMergeArgs,
						   SG_vhash ** ppvhStats,
						   char ** ppszHidTarget);

void sg_wc_tx__merge__compute_preview_target(SG_context * pCtx,
											 SG_wc_tx * pWcTx,
											 const SG_wc_merge_args * pMergeArgs,
											 char ** ppszHidTarget);

//////////////////////////////////////////////////////////////////

END_EXTERN_C;

#endif//H_SG_WC6MERGE__PRIVATE_PROTOTYPES_H


text:
package com.droidcon.snaphack.manager;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import com.droidcon.snaphack.key.KitKatKeyStore;
import com.droidcon.snaphack.key.MyKeyStore;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.Key;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.UnrecoverableEntryException;
import java.security.cert.CertificateException;
import java.security.spec.InvalidKeySpecException;

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;

public class KeyManager {

    public static final boolean IS_M = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
    public static final boolean IS_KK = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;

    private static final String KEY_PREFS = "sdfsdf";
    private final SharedPreferences prefs;
    private static final String PREFS = "prefs";
    MyKeyStore myKeyStore = null;

    public KeyManager(Context context) {
        this.prefs = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE);

        if(IS_M){
            myKeyStore = new KitKatKeyStore(context);// new MarshmallowKeyStore();
        }else if(IS_KK){
            myKeyStore = new KitKatKeyStore(context);
        } else {
            myKeyStore = new KitKatKeyStore(context);
        }

    }

    public void save(String keyName) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, KeyStoreException {
        prefs.edit().putString(KEY_PREFS, keyName).apply();
        myKeyStore.saveKey(keyName);
    }

    public Key read() throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException, UnrecoverableEntryException {
        String keyName = prefs.getString(KEY_PREFS, "");
        Key key = myKeyStore.readKey(keyName);
        return key;
    }

    public boolean isHardwareBacked() throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException, UnrecoverableEntryException, NoSuchProviderException, InvalidKeySpecException {
        return myKeyStore.isHardwareBacked();
    }

    public String getKeyAlias(){
        String keyName = prefs.getString(KEY_PREFS, "");
        return keyName;
    }

}


text:
from django.db import models
from apps.core.models import OpenHours
from django.core.validators import MinValueValidator

class Event(models.Model):
    title = models.CharField(max_length=200, blank=False, null=False)
    description = models.CharField(max_length=2000, blank=False, null=False)
    price = models.DecimalField(
        decimal_places=2, max_digits=5, blank=False, null=False,
        validators=[MinValueValidator(0.0)])
    event_type = models.ForeignKey('events.EventType', blank=False, null=False)
    institute = models.ForeignKey(
        'institutions.Institute', blank=False, null=False)
    address = models.ForeignKey('core.Address', blank=True, null=True)

    def __str__(self):
        return self.title

class EventType(models.Model):
    name = models.CharField(max_length=50, blank=False, null=False)

    def __str__(self):
        return self.name

class EventOpenHours(OpenHours):
    event_fk = models.ForeignKey('events.Event', blank=False, null=False)


text:
.class synthetic Lo/yh$1;
.super Ljava/lang/Object;

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lo/yh;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x1008
    name = null
.end annotation


text:
namespace ash::libassistant {

// Enums representing states of Libassistant services in the order of the
// bootup progession. States are monotonic and cannot get reverted back to
// any previous states once a state is reached.
enum class ServicesStatus {
  // Connection to the libassistant's gRPC service is not available.
  OFFLINE,

  // Services are booting up. Only a few core gRPC services will be available
  // at this stage.
  ONLINE_BOOTING_UP,

  // All services are available and ready to take requests.
  ONLINE_ALL_SERVICES_AVAILABLE,
};

class ServicesStatusObserver : public base::CheckedObserver {
 public:
  virtual void OnServicesStatusChanged(ServicesStatus status) = 0;
};

}  // namespace ash::libassistant

// TODO(https://crbug.com/1164001): remove when the migration is finished.
namespace chromeos::libassistant {
using ::ash::libassistant::ServicesStatus;
using ::ash::libassistant::ServicesStatusObserver;
}  // namespace chromeos::libassistant

#endif  // CHROMEOS_ASH_SERVICES_LIBASSISTANT_GRPC_SERVICES_STATUS_OBSERVER_H_


text:
/*
 * Exercicio 9.1
 * Livro: Aprenda a programar com C#
 * Autores: Antonio Trigo e Jorge Henriques
 * Disponível em: http://www.silabo.pt
*/

using System;

namespace Cap9
{
    class Program
    {
        static void Main(string[] args)
        {
            string nome;
            Console.Write("Introduza o seu nome: ");
            nome = Console.ReadLine();
            Console.WriteLine("O seu nome é {0} ", nome);
        }
    }
}