text:
package org.pm4j.core.pb;

import org.pm4j.core.pb.PbFactory.ValueUpdateEvent;

/**
 * Base iterface/implementation for presentation binding default settings.
 *
 * @author olaf boede
 *
 * @param <T_WIDGET_FACTORY_SET> The view platform specific widget set class.
 */
public abstract class PbDefaultsBase <T_WIDGET_FACTORY_SET extends PbWidgetFactorySet> {

  /**
   * Defines the UI event that triggers transfer of entered values to the PM.
   *

   * This may be done on each modification (each click) or on the focus lost
   * event.
   */
  private ValueUpdateEvent valueUpdateEvent = ValueUpdateEvent.MODIFY;

  /**
   * Defines the set of default UI widgets factories used within the application.
   */
  private T_WIDGET_FACTORY_SET widgetFactorySet;

  /**
   * Configures the PM to view matching strategies.

   * It defines the default view representation of PMs.
   *

   * This {@link PbMatcher} defines the default set of {@link PbMatcher}s used
   * for the application.
   */
  private PbMatcher matcher;
  /**
   * Generates the default PM to factory matcher.
   *

   * Each application may define here its own PM to view matching strategy
   * for generic views.
   */
  private PbMatcherFactory matcherFactory;

  public PbDefaultsBase() {
    super();
  }

  public ValueUpdateEvent getValueUpdateEvent() {
    return valueUpdateEvent;
  }

  public void setValueUpdateEvent(ValueUpdateEvent valueUpdateEvent) {
    this.valueUpdateEvent = valueUpdateEvent;
  }

  public PbMatcher getMatcher() {
    if (matcher == null) {
      matcher = getMatcherFactory().makeMatcher();
    }
    return matcher;
  }

  public void setMatcher(PbMatcher pbMatcher) {
    this.matcher = pbMatcher;
  }

  public PbMatcherFactory getMatcherFactory() {
    if (matcherFactory == null) {
      matcherFactory = new PbMatcherFactory(getWidgetFactorySet());
    }
    return matcherFactory;
  }

  public void setMatcherFactory(PbMatcherFactory pbMatcherFactory) {
    this.matcherFactory = pbMatcherFactory;
  }

  public T_WIDGET_FACTORY_SET getWidgetFactorySet() {
    if (widgetFactorySet == null) {
      widgetFactorySet = makeWidgetFactorySet();
    }
    return widgetFactorySet;
  }

  protected abstract T_WIDGET_FACTORY_SET makeWidgetFactorySet();

  public void setWidgetFactorySet(T_WIDGET_FACTORY_SET widgetFactorySet) {
    this.widgetFactorySet = widgetFactorySet;
  }

}


text:
user = node['jetty']['user']

user user do
  comment "I run Jetty"
  home node['jetty']['user_home']
  shell "/bin/bash"
end

package "jetty-hightide-server" do
  version "#{node['jetty']['version']}-1"
end

java_options = node['jetty']['java_options'].map { |key, value| "#{key}#{value}" }.join ' '

template "/etc/default/jetty" do
  source "jetty-config-options.erb"
  mode "0644"
  owner user
  group node['jetty']['group']
  variables :jetty_home   => node['jetty']['home'],
            :jetty_user   => user,
            :jetty_port   => node['jetty']['port'],
            :java_options => java_options
end

cookbook_file "/etc/init.d/jetty" do
  mode "0755"
  owner "root"
  group "root"
end

service "jetty" do
  supports :restart => true
  action [:enable, :start]
end

redpajama_set_name: RedPajamaGithub


text:
function generateStoreCatalogue(data) {
    let catalogue = new Map;
    for (let line of data) {
        let tokens = line.split(/\s:\s/);
        let [product, price] = [tokens[0], Number(tokens[1])];
        let productFirstLetter = product[0].toUpperCase();
        if (!catalogue.has(productFirstLetter)) {
            catalogue.set(productFirstLetter, []);
        }

        catalogue.get(productFirstLetter).push({title: product, value: price});
    }

    function customComparator(productA, productB) {
        return productA.title.toLowerCase().localeCompare(productB.title.toLowerCase());
    }

    let sortedCategories = [...catalogue.keys()].sort();
    for (let category of sortedCategories) {
        console.log(category);
        let products = catalogue.get(category).sort(customComparator);
        products.forEach(p => console.log(`  ${p.title}: ${p.value}`));
    }
}

// generateStoreCatalogue(["Appricot : 20.4", "Fridge : 1500", "TV : 1499", "Deodorant : 10", "Boiler : 300", "Apple : 1.25", "Anti-Bug Spray : 15", "T-Shirt : 10"]);
generateStoreCatalogue(["Banana : 2","Rubic's Cube : 5","Raspberry P : 4999","Rolex : 100000","Rollon : 10","Rali Car : 2000000","Pesho : 0.000001","Barrel : 10"]);


text:
function stringPermutation(string) {
    if (string.length < 2) return string; // This is our break condition

    var permutations = []; // This array will hold our permutations

    for (var i = 0; i < string.length; i++) {
        var char = string[i];

        // Cause we don't want any duplicates:
        if (string.indexOf(char) != i) // if char was used already
            continue; // skip it this time

        var remainingString = string.slice(0, i) + string.slice(i + 1, string.length); //Note: you can concat Strings via '+' in JS

        for (var subPermutation of permut(remainingString))
            permutations.push(char + subPermutation)

    }
    return permutations;
}
("Marquis");
// var myString = "xyz";
// permutations = permut(myString);
// for (permutation of permutations)
//     print(permutation) //Use the output method of your choice


text:
<?php

namespace AppBundle\Controller;

use AppBundle\Entity\Hosting;
use AppBundle\Form\HostingType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class HostingController extends Controller
{
    /**
     * @param Request $request
     * @Route("/add-new-hosting/", name="add_new_hosting")
     * @Security("has_role('ROLE_DEV')")
     * @return Response
     */
    public function newAction(Request $request)
    {
        $hosting = new Hosting();

        $form = $this->createForm(HostingType::class, $hosting);

        $form->handleRequest($request);
        if ( $form->isSubmitted() && $form->isValid() ){
            $em = $this->getDoctrine()->getManager();
            $em->persist($hosting);
            $em->flush();

            $this->addFlash('notice', 'hosting added successfully!');

            return $this->redirectToRoute('list_all_hosting');
        }

        return $this->render('hosting/add-hosting.html.twig', array(
            'form' => $form->createView(),
        ));
    }

    /**
     * @Route("/hosts/", name="list_all_hosting")
     * @Security("has_role('ROLE_DEV')")
     * @return Response
     */
    public function listAction(){

        $hosts = $this->getDoctrine()->getRepository('AppBundle:Hosting')->findAll();

        return $this->render('hosting/hosts.html.twig', array(
            'hosts' => $hosts,
        ));

    }

    /**
     * @param Hosting $hosting
     * @Route("/view-hosting/{hosting}/", name="view_hosting")
     * @Security("has_role('ROLE_DEV')")
     * @return Response
     */
    public function viewAction(Hosting $hosting){

        if ( !$hosting ){
            throw $this->createNotFoundException("hosting Not found!");
        }

        return $this->render('hosting/view-hosting.html.twig', array(
            'hosting' => $hosting,
        ));

    }

    /**
     * @param Hosting $hosting
     * @Route("/delete-hosting/{hosting}/", name="delete_hosting")
     * @Security("has_role('ROLE_DEV')")
     * @return Response
     */
    public function deleteAction(Hosting $hosting){

        if ( !$hosting ){
            throw $this->createNotFoundException("hosting Not found!");
        }

        $em = $this->getDoctrine()->getManager();
        $em->remove($hosting);
        $em->flush();

        $this->addFlash('notice', 'hosting deleted successfully!');

        return $this->redirectToRoute('list_all_hosting');

    }

    /**
     * @param Request $request
     * @param Hosting $hosting
     * @return Response
     * @Route("/edit-hosting/{hosting}/", name="edit_hosting")
     * @Security("has_role('ROLE_DEV')")
     */
    public function editAction(Request $request, Hosting $hosting)
    {

        $form = $this->createForm(HostingType::class, $hosting);

        $form->remove('domain');

        $form->handleRequest($request);
        if ( $form->isSubmitted() && $form->isValid() ){
            $em = $this->getDoctrine()->getManager();
            $em->persist($hosting);
            $em->flush();

            $this->addFlash('notice', 'hosting saved successfully!');

            return $this->redirectToRoute('view_hosting', array(
                'hosting' => $hosting->getId(),
            ));
        }

        return $this->render('hosting/edit-hosting.html.twig', array(
            'form' => $form->createView(),
            'hosting' => $hosting,
        ));
    }
}


text:
package commands

import (
	"fmt"
	"strconv"
	"strings"

	"github.com/github/hub/v2/git"
	"github.com/github/hub/v2/github"
	"github.com/github/hub/v2/ui"
	"github.com/github/hub/v2/utils"
)

var (
	cmdPr = &Command{
		Run: printHelp,
		Usage: `
pr list [-s <STATE>] [-h <HEAD>] [-b <BASE>] [-o <SORT_KEY> [-^]] [-f <FORMAT>] [-L <LIMIT>]
pr checkout <PR-NUMBER> [<BRANCH>]
pr show [-uc] [-f <FORMAT>] [-h <HEAD>]
pr show [-uc] [-f <FORMAT>] <PR-NUMBER>
pr merge [-d] [--squash | --rebase] <PR-NUMBER> [-m <MESSAGE> | -F <FILE>] [--head-sha <COMMIT-SHA>]
`,
		Long: `Manage GitHub Pull Requests for the current repository.

## Commands:

	* _list_:
		List pull requests in the current repository.

	* _checkout_:
		Check out the head of a pull request in a new branch.

		To update the pull request with new commits, use ''git push''.

	* _show_:
		Open a pull request page in a web browser. When no <PR-NUMBER> is
		specified, <HEAD> is used to look up open pull requests and defaults to
		the current branch name. With ''--format'', print information about the
		pull request instead of opening it.

	* _merge_:
		Merge a pull request in the current repository remotely. Select an
		alternate merge method with ''--squash'' or ''--rebase''. Change the
		commit subject and body with ''--message'' or ''--file''.

## Options:

	-s, --state <STATE>
		Filter pull requests by <STATE>. Supported values are: "open" (default),
		"closed", "merged", or "all".

	-h, --head <BRANCH>
		Show pull requests started from the specified head <BRANCH>. The
		"OWNER:BRANCH" format must be used for pull requests from forks.

	-b, --base <BRANCH>
		Show pull requests based off the specified <BRANCH>.

	-f, --format <FORMAT>
		Pretty print the list of pull requests using format <FORMAT> (default:
		"%pC%>(8)%i%Creset  %t%  l%n"). See the "PRETTY FORMATS" section of
		git-log(1) for some additional details on how placeholders are used in
		format. The available placeholders are:

		%I: pull request number

		%i: pull request number prefixed with "#"

		%U: the URL of this pull request

		%S: state ("open" or "closed")

		%pS: pull request state ("open", "draft", "merged", or "closed")

		%sC: set color to red or green, depending on state

		%pC: set color according to pull request state

		%t: title

		%l: colored labels

		%L: raw, comma-separated labels

		%b: body

		%B: base branch

		%sB: base commit SHA

		%H: head branch

		%sH: head commit SHA

		%sm: merge commit SHA

		%au: login name of author

		%as: comma-separated list of assignees

		%rs: comma-separated list of requested reviewers

		%Mn: milestone number

		%Mt: milestone title

		%cD: created date-only (no time of day)

		%cr: created date, relative

		%ct: created date, UNIX timestamp

		%cI: created date, ISO 8601 format

		%uD: updated date-only (no time of day)

		%ur: updated date, relative

		%ut: updated date, UNIX timestamp

		%uI: updated date, ISO 8601 format

		%mD: merged date-only (no time of day)

		%mr: merged date, relative

		%mt: merged date, UNIX timestamp

		%mI: merged date, ISO 8601 format

		%n: newline

		%%: a literal %

	--color[=<WHEN>]
		Enable colored output even if stdout is not a terminal. <WHEN> can be one
		of "always" (default for ''--color''), "never", or "auto" (default).

	-o, --sort <KEY>
		Sort displayed pull requests by "created" (default), "updated", "popularity", or "long-running".

	-^, --sort-ascending
		Sort by ascending dates instead of descending.

	-L, --limit <LIMIT>
		Display only the first <LIMIT> pull requests.

	-u, --url
		Print the pull request URL instead of opening it.

	-c, --copy
		Put the pull request URL to clipboard instead of opening it.

	-m, --message <MESSAGE>
		The text up to the first blank line in <MESSAGE> is treated as the commit
		subject for the merge commit, and the rest is used as commit body.

		When multiple ''--message'' are passed, their values are concatenated with a
		blank line in-between.

	-F, --file <FILE>
		Read the subject and body for the merge commit from <FILE>. Pass "-" to read
		from standard input instead. See ''--message'' for the formatting rules.

	--head-sha <COMMIT-SHA>
		Ensure that the head of the pull request matches the commit SHA when merging.

	--squash
		Squash commits instead of creating a merge commit when merging a pull request.

	--rebase
		Rebase commits on top of the base branch when merging a pull request.

	-d, --delete-branch
		Delete the head branch after successfully merging a pull request.

## See also:

hub-issue(1), hub-pull-request(1), hub(1)
`,
	}

	cmdCheckoutPr = &Command{
		Key:        "checkout",
		Run:        checkoutPr,
		KnownFlags: "\n",
	}

	cmdListPulls = &Command{
		Key:  "list",
		Run:  listPulls,
		Long: cmdPr.Long,
	}

	cmdShowPr = &Command{
		Key: "show",
		Run: showPr,
		KnownFlags: `
		-h, --head HEAD
		-u, --url
		-c, --copy
		-f, --format FORMAT
		--color
		`,
	}

	cmdMergePr = &Command{
		Key: "merge",
		Run: mergePr,
		KnownFlags: `
		-m, --message MESSAGE
		-F, --file FILE
		--head-sha COMMIT
		--squash
		--rebase
		-d, --delete-branch
		`,
	}
)

func init() {
	cmdPr.Use(cmdListPulls)
	cmdPr.Use(cmdCheckoutPr)
	cmdPr.Use(cmdShowPr)
	cmdPr.Use(cmdMergePr)
	CmdRunner.Use(cmdPr)
}

func printHelp(command *Command, args *Args) {
	utils.Check(command.UsageError(""))
}

func listPulls(cmd *Command, args *Args) {
	localRepo, err := github.LocalRepo()
	utils.Check(err)

	project, err := localRepo.MainProject()
	utils.Check(err)

	gh := github.NewClient(project.Host)

	args.NoForward()
	if args.Noop {
		ui.Printf("Would request list of pull requests for %s\n", project)
		return
	}

	filters := map[string]interface{}{}
	if args.Flag.HasReceived("--state") {
		filters["state"] = args.Flag.Value("--state")
	}
	if args.Flag.HasReceived("--sort") {
		filters["sort"] = args.Flag.Value("--sort")
	}
	if args.Flag.HasReceived("--base") {
		filters["base"] = args.Flag.Value("--base")
	}
	if args.Flag.HasReceived("--head") {
		head := args.Flag.Value("--head")
		if !strings.Contains(head, ":") {
			head = fmt.Sprintf("%s:%s", project.Owner, head)
		}
		filters["head"] = head
	}

	if args.Flag.Bool("--sort-ascending") {
		filters["direction"] = "asc"
	} else {
		filters["direction"] = "desc"
	}

	onlyMerged := false
	if filters["state"] == "merged" {
		filters["state"] = "closed"
		onlyMerged = true
	}

	flagPullRequestLimit := args.Flag.Int("--limit")
	flagPullRequestFormat := args.Flag.Value("--format")
	if !args.Flag.HasReceived("--format") {
		flagPullRequestFormat = "%pC%>(8)%i%Creset  %t%  l%n"
	}

	pulls, err := gh.FetchPullRequests(project, filters, flagPullRequestLimit, func(pr *github.PullRequest) bool {
		return !(onlyMerged && pr.MergedAt.IsZero())
	})
	utils.Check(err)

	colorize := colorizeOutput(args.Flag.HasReceived("--color"), args.Flag.Value("--color"))
	for _, pr := range pulls {
		ui.Print(formatPullRequest(pr, flagPullRequestFormat, colorize))
	}
}

func checkoutPr(command *Command, args *Args) {
	words := args.Words()
	var newBranchName string

	if len(words) == 0 {
		utils.Check(fmt.Errorf("Error: No pull request number given"))
	} else if len(words) > 1 {
		newBranchName = words[1]
	}

	prNumberString := words[0]
	_, err := strconv.Atoi(prNumberString)
	utils.Check(err)

	// Figure out the PR URL
	localRepo, err := github.LocalRepo()
	utils.Check(err)
	baseProject, err := localRepo.MainProject()
	utils.Check(err)
	host, err := github.CurrentConfig().PromptForHost(baseProject.Host)
	utils.Check(err)
	client := github.NewClientWithHost(host)
	pr, err := client.PullRequest(baseProject, prNumberString)
	utils.Check(err)

	newArgs, err := transformCheckoutArgs(args, pr, newBranchName)
	utils.Check(err)

	args.Replace(args.Executable, "checkout", newArgs...)
}

func showPr(command *Command, args *Args) {
	localRepo, err := github.LocalRepo()
	utils.Check(err)

	baseProject, err := localRepo.MainProject()
	utils.Check(err)

	host, err := github.CurrentConfig().PromptForHost(baseProject.Host)
	utils.Check(err)
	gh := github.NewClientWithHost(host)

	words := args.Words()
	openURL := ""
	prNumber := 0
	var pr *github.PullRequest

	if len(words) > 0 {
		if prNumber, err = strconv.Atoi(words[0]); err == nil {
			openURL = baseProject.WebURL("", "", fmt.Sprintf("pull/%d", prNumber))
		} else {
			utils.Check(fmt.Errorf("invalid pull request number: '%s'", words[0]))
		}
	} else {
		pr, err = findCurrentPullRequest(localRepo, gh, baseProject, args.Flag.Value("--head"))
		utils.Check(err)
		openURL = pr.HTMLURL
	}

	args.NoForward()
	if format := args.Flag.Value("--format"); format != "" {
		if pr == nil {
			pr, err = gh.PullRequest(baseProject, strconv.Itoa(prNumber))
			utils.Check(err)
		}
		colorize := colorizeOutput(args.Flag.HasReceived("--color"), args.Flag.Value("--color"))
		ui.Println(formatPullRequest(*pr, format, colorize))
		return
	}

	printURL := args.Flag.Bool("--url")
	copyURL := args.Flag.Bool("--copy")

	printBrowseOrCopy(args, openURL, !printURL && !copyURL, copyURL)
}

func findCurrentPullRequest(localRepo *github.GitHubRepo, gh *github.Client, baseProject *github.Project, headArg string) (*github.PullRequest, error) {
	filterParams := map[string]interface{}{
		"state": "open",
	}
	headWithOwner := ""

	if headArg != "" {
		headWithOwner = headArg
		if !strings.Contains(headWithOwner, ":") {
			headWithOwner = fmt.Sprintf("%s:%s", baseProject.Owner, headWithOwner)
		}
	} else {
		currentBranch, err := localRepo.CurrentBranch()
		utils.Check(err)
		if headBranch, headProject, err := findPushTarget(currentBranch); err == nil {
			headWithOwner = fmt.Sprintf("%s:%s", headProject.Owner, headBranch.ShortName())
		} else if headProject, err := deducePushTarget(currentBranch, gh.Host.User); err == nil {
			headWithOwner = fmt.Sprintf("%s:%s", headProject.Owner, currentBranch.ShortName())
		} else {
			headWithOwner = fmt.Sprintf("%s:%s", baseProject.Owner, currentBranch.ShortName())
		}
	}

	filterParams["head"] = headWithOwner

	pulls, err := gh.FetchPullRequests(baseProject, filterParams, 1, nil)
	if err != nil {
		return nil, err
	} else if len(pulls) == 1 {
		return &pulls[0], nil
	} else {
		return nil, fmt.Errorf("no open pull requests found for branch '%s'", headWithOwner)
	}
}

func branchTrackingInformation(branch *github.Branch) (string, *github.Branch, error) {
	branchRemote, err := git.Config(fmt.Sprintf("branch.%s.remote", branch.ShortName()))
	if branchRemote == "." {
		err = fmt.Errorf("branch is tracking another local branch")
	}
	if err != nil {
		return "", nil, err
	}
	branchMerge, err := git.Config(fmt.Sprintf("branch.%s.merge", branch.ShortName()))
	if err != nil {
		return "", nil, err
	}
	trackingBranch := &github.Branch{
		Repo: branch.Repo,
		Name: branchMerge,
	}
	return branchRemote, trackingBranch, nil
}

func findPushTarget(branch *github.Branch) (*github.Branch, *github.Project, error) {
	branchRemote, headBranch, err := branchTrackingInformation(branch)
	if err != nil {
		return nil, nil, err
	}

	if headRemote, err := branch.Repo.RemoteByName(branchRemote); err == nil {
		headProject, err := headRemote.Project()
		if err != nil {
			return nil, nil, err
		}
		return headBranch, headProject, nil
	}

	remoteURL, err := git.ParseURL(branchRemote)
	if err != nil {
		return nil, nil, err
	}
	headProject, err := github.NewProjectFromURL(remoteURL)
	if err != nil {
		return nil, nil, err
	}
	return headBranch, headProject, nil
}

func deducePushTarget(branch *github.Branch, owner string) (*github.Project, error) {
	remote := branch.Repo.RemoteForBranch(branch, owner)
	if remote == nil {
		return nil, fmt.Errorf("no remote found for branch %s", branch.ShortName())
	}
	return remote.Project()
}

func mergePr(command *Command, args *Args) {
	words := args.Words()
	if len(words) == 0 {
		utils.Check(fmt.Errorf("Error: No pull request number given"))
	}

	prNumber, err := strconv.Atoi(words[0])
	utils.Check(err)

	params := map[string]interface{}{
		"merge_method": "merge",
	}
	if args.Flag.Bool("--squash") {
		params["merge_method"] = "squash"
	}
	if args.Flag.Bool("--rebase") {
		params["merge_method"] = "rebase"
	}

	msgs := args.Flag.AllValues("--message")
	if len(msgs) > 0 {
		params["commit_title"] = msgs[0]
		params["commit_message"] = strings.Join(msgs[1:], "\n\n")
	} else if args.Flag.HasReceived("--file") {
		content, err := msgFromFile(args.Flag.Value("--file"))
		utils.Check(err)
		params["commit_title"], params["commit_message"] = github.SplitTitleBody(content)
	}

	if headSHA := args.Flag.Value("--head-sha"); headSHA != "" {
		params["sha"] = args.Flag.Value("--head-sha")
	}

	localRepo, err := github.LocalRepo()
	utils.Check(err)

	project, err := localRepo.MainProject()
	utils.Check(err)

	args.NoForward()
	if args.Noop {
		ui.Printf("Would merge pull request #%d for %s\n", prNumber, project)
		return
	}

	gh := github.NewClient(project.Host)
	_, err = gh.MergePullRequest(project, prNumber, params)
	utils.Check(err)

	if !args.Flag.Bool("--delete-branch") {
		return
	}

	pr, err := gh.PullRequest(project, strconv.Itoa(prNumber))
	utils.Check(err)
	if !pr.IsSameRepo() {
		return
	}

	branchName := pr.Head.Ref
	err = gh.DeleteBranch(project, branchName)
	utils.Check(err)
}

func formatPullRequest(pr github.PullRequest, format string, colorize bool) string {
	placeholders := formatIssuePlaceholders(github.Issue(pr), colorize)
	delete(placeholders, "NC")
	delete(placeholders, "Nc")

	for key, value := range formatPullRequestPlaceholders(pr, colorize) {
		placeholders[key] = value
	}
	return ui.Expand(format, placeholders, colorize)
}


text:
<!DOCTYPE html>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">

    <link rel="stylesheet" href="https://cdn.webrtc-experiment.com/style.css">

    <title>WebRTC Scalable Media Broadcast using RTCMultiConnection</title>

    <meta name="description" content="This module simply initializes socket.io and configures it in a way that single audio/video/screen stream can be shared/relayed over unlimited users without any bandwidth/CPU usage issues. Everything happens peer-to-peer!" />
    <meta name="keywords" content="WebRTC,RTCMultiConnection,Demos,Experiments,Samples,Examples" />

WebRTC Scalable Media Broadcast using RTCMultiConnection

                HOME
                 ©
                Muaz Khan .
                @WebRTCWeb .
                Github .
                Latest issues .
                What's New?

                <input type="text" id="broadcast-id" placeholder="broadcast-id" value="room-xyz">
                <button id="open-or-join">Open or Join Broadcast</button>

            <video id="video-preview" controls loop></video>

            This demo has built-in (open-sourced) apps both for iOS and Android.

            This module simply initializes socket.io and configures it in a way that single audio/video/screen stream can be shared/relayed over unlimited users without any bandwidth/CPU usage issues. Everything happens peer-to-peer!

            Share files with unlimited users using p2p methods! Files Scalable Broadcast

Latest Updates

Latest Issues

Feedback

                <textarea id="message" style="height: 8em; margin: .2em; width: 98%; border: 1px solid rgb(189, 189, 189); outline: none; resize: vertical;" placeholder="Have any message? Suggestions or something went wrong?"></textarea>

            <button id="send-message" style="font-size: 1em;">Send Message</button>Enter your email too; if you want "direct" reply!

            WebRTC Experiments © Muaz Khan
            muazkh@gmail.com
            Github


text:
<?php
/**
 * This file is part of the IsecureFi.WsCliPhpSdk
 */
namespace IsecureFi\WsCliPhpSdk\Exception;

class RuntimeException extends \RuntimeException implements ExceptionInterface
{
}


text:
import moment from 'moment';
import toastr from 'toastr';

Meteor.methods({
	deleteMessage(message) {
		if (!Meteor.userId()) {
			return false;
		}

		//We're now only passed in the `_id` property to lower the amount of data sent to the server
		message = ChatMessage.findOne({ _id: message._id });

		const hasPermission = RocketChat.authz.hasAtLeastOnePermission('delete-message', message.rid);
		const forceDelete = RocketChat.authz.hasAtLeastOnePermission('force-delete-message', message.rid);
		const deleteAllowed = RocketChat.settings.get('Message_AllowDeleting');
		let deleteOwn = false;

		if (message && message.u && message.u._id) {
			deleteOwn = message.u._id === Meteor.userId();
		}
		if (!(forceDelete || hasPermission || (deleteAllowed && deleteOwn))) {
			return false;
		}
		const blockDeleteInMinutes = RocketChat.settings.get('Message_AllowDeleting_BlockDeleteInMinutes');
		if (!(forceDelete) || (_.isNumber(blockDeleteInMinutes) && blockDeleteInMinutes !== 0)) {
			if (message.ts) {
				const msgTs = moment(message.ts);
				if (msgTs) {
					const currentTsDiff = moment().diff(msgTs, 'minutes');
					if (currentTsDiff > blockDeleteInMinutes) {
						toastr.error(t('error-message-deleting-blocked'));
						return false;
					}
				}
			}
		}

		Tracker.nonreactive(function() {
			ChatMessage.remove({
				_id: message._id,
				'u._id': Meteor.userId()
			});
		});
	}
});


text:
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package relex.corpus;

@SuppressWarnings("unchecked")

public class DocSplitterFactory
{
	private static final Class<? extends DocSplitter> clazz;
	static {
		Class<? extends DocSplitter> clazz0;
		clazz0 = null;

		// First, try to load opennlp-1.5.0
		try
		{
			// Earlier versions of opennlp don't have this class,
			// and so we'll throw an error if its not found.
			Class.forName("opennlp.tools.sentdetect.SentenceModel");

			// clazz0 = DocSplitterOpenNLP15Impl.class;
			Class<?> c = Class.forName("relex.corpus.DocSplitterOpenNLP15Impl");

			// It seems to be impossible to perform this cast and not get
			// a type-safety warning,
			clazz0 = (Class<DocSplitter>) c;
		}
		catch(Throwable t) {}

		if (null == clazz0)
		{
			clazz0 = DocSplitterFallbackImpl.class;
			System.err.println(
				"\nWARNING:\n" +
				"\tIt appears that the OpenNLP tools are not installed or are not\n" +
				"\tcorrectly specified in the java classpath. The OpenNLP tools are\n" +
				"\tused to perform sentence detection. Without them, ReleEx will use\n" +
				"\tthe less accurate Java sentence detector. See the README file for info.\n");
		}

		clazz = clazz0;
	}

	public static DocSplitter create()
	{
		try {
			DocSplitter ds =  clazz.newInstance();
			if (false == ds.operational())
			{
				System.err.println(
					"\nWARNING:\n" +
					"\tIt appears that the DocSplitter class is not working for some reason.\n" +
					"\tMake sure that data/opennlp/models-1.5/en-sent.bin is installed\n" +
					"\tor that an alternate location is specified with -DEnglishModelFilename\n" +
					"\tin the script/run files.\n" +
					"\tWithout it, ReleEx will use the less-accurate Java native sentence detector.\n" +
					"\tPlease see the README file for info.\n");
				Class<? extends DocSplitter> clazzy;
				clazzy = DocSplitterFallbackImpl.class;
				ds =  clazzy.newInstance();
			}
			return ds;
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}
	}
}


text:
using namespace swganh::statics;
using namespace swganh::object;

void SkillManager::Start(std::shared_ptr<sql::Statement> statement)
{
    _loadSkills(std::move(std::unique_ptr<sql::ResultSet>(statement->getResultSet())));

    statement->getMoreResults();
    _loadSkillPrereqs(std::move(std::unique_ptr<sql::ResultSet>(statement->getResultSet())));

    //statement->getMoreResults();
    //_loadSkillsRequiredSpecies(std::move(std::unique_ptr<sql::ResultSet>(statement->getResultSet())));

    statement->getMoreResults();
    _loadSkillMods(std::move(std::unique_ptr<sql::ResultSet>(statement->getResultSet())));

	statement->getMoreResults();
    _loadSkillCommands(std::move(std::unique_ptr<sql::ResultSet>(statement->getResultSet())));

}

void SkillManager::_loadSkillCommands(std::unique_ptr<sql::ResultSet> result)
{
    while(result->next())
    {
		std::string skill_name = result->getString(1);
        std::string cmd_name = result->getString(2);

        auto find_itr = skills_.find(skill_name);

		if(find_itr != skills_.end())
        {
			find_itr->second->commands_.insert(cmd_name);
		}
		else
		{
			DLOG(error) << "SkillManager::_loadSkillCommands couldnt find skill : " << skill_name << " for command : " << cmd_name;
		}
	}
}

void SkillManager::_loadSkills(std::unique_ptr<sql::ResultSet> result)
{
    while(result->next())
    {
        auto skill = std::make_shared<Skill>();

        std::string name = result->getString(1);
        skill->is_title = result->getBoolean(2);
        skill->is_profession = result->getBoolean(3);
        skill->money_required = result->getUInt(4);
        skill->skill_points_consumed = result->getUInt(5);
        skill->xp_type = result->getString(6);
        skill->xp_cost = result->getUInt(7);
        skill->xp_cap = result->getUInt(8);

        skills_.insert(std::make_pair(name, skill));
    }

}

void SkillManager::_loadSkillPrereqs(std::unique_ptr<sql::ResultSet> result)
{
    while(result->next())
    {
        std::string skill_name = result->getString(1);
        std::string prereq_name = result->getString(2);

        auto skill_find = skills_.find(skill_name);
        auto prereq_find = skills_.find(prereq_name);

        if(skill_find != skills_.end() && prereq_find != skills_.end())
        {
            skill_find->second->required_skills_.insert(prereq_find->second);
        }
    }
}

void SkillManager::_loadSkillsRequiredSpecies(std::unique_ptr<sql::ResultSet> results)
{
}

void SkillManager::_loadSkillMods(std::unique_ptr<sql::ResultSet> result)
{
	//SELECT s.skill_name, smod.skillmod_name, m.value FROM skills_skillmods m
    while(result->next())
    {
		//look up the relevant skill
        std::string skillname = result->getString(1);
        auto find_itr = skills_.find(skillname);
		//adds the skillmods
        if(find_itr != skills_.end())
        {
            std::string modname = result->getString(2);
            find_itr->second->skill_mods_.insert(std::make_pair(modname, result->getUInt(3)));
		}
    }
}

const std::shared_ptr <Skill> SkillManager::GetStaticSkillData(std::string skill_name)
{
	auto find_itr = skills_.find(skill_name);
	if(find_itr != skills_.end())	{
		return find_itr->second;
	}
	return nullptr;
}

bool SkillManager::CheckSkillCommandDuplicity(const std::shared_ptr<swganh::object::Creature>& creature, const std::string& command_name)
{
	// when we get called we check whether an available skill grants us the command_name skill command
	auto skill_list = creature->GetSkills();
	auto find_itr = skill_list.begin();

	//iterate through all the skills
	while(find_itr != skill_list.end())
	{
		//get the skills name
		auto skill_name = (*find_itr);

		//and look it up in the skill list
		auto skill_find_itr = skills_.find(skill_name);
		if(skill_find_itr == skills_.end())	{
			find_itr++;
			break;
		}

		//is the command in the skills command list?
		auto cmd_map = (skill_find_itr)->second->commands_;
		auto cmd_iter = cmd_map.find(command_name);

		if(cmd_iter != cmd_map.end()){
			return true;
		}

		find_itr++;
	}

	return false;

}

std::pair<uint32_t, uint32_t> SkillManager::GetSkillMod(const std::shared_ptr<Creature>& creature, const std::string& skill_mod_name)
{
    std::map<std::string, std::pair<uint32_t, uint32_t>> mods = GetSkillMods(creature);

    auto find_itr = mods.find(skill_mod_name);

    if(find_itr != mods.end())
    {
        return find_itr->second;
    }

    return std::make_pair<uint32_t, uint32_t>(0, 0);
}

void addMod(std::map<std::string, std::pair<uint32_t, uint32_t>>& map, std::string modname, uint32_t baseDelta, uint32_t modDelta)
{
    auto lb = map.lower_bound(modname);

    if(lb != map.end() && !(map.key_comp()(modname, lb->first)))
    {
        lb->second.first += baseDelta;
        lb->second.second += modDelta;
    }
    else
    {
        map.insert(lb, std::make_pair(modname, std::make_pair(baseDelta, modDelta)));
    }
}

SkillModsMap SkillManager::GetSkillMods(const std::shared_ptr<Creature>& creature)
{
    std::map<std::string, std::pair<uint32_t, uint32_t>> result;

    //Add the base values
    auto skill_end = this->skills_.end();
    for(auto& skill : creature->GetSkills())
    {
        auto skill_itr = this->skills_.find(skill);
        if(skill_itr != skill_end)
        {
            for(auto& mod : skill_itr->second->skill_mods_)
            {
                addMod(result, mod.first, mod.second, 0);
            }
        }
    }

    //Add the mod values
    creature->ViewObjects(creature, 1, true, [&] (std::shared_ptr<Object> child)
    {
        for(auto& mod : result)
        {
            auto modifier = child->GetAttribute(mod.first); //@TODO : EquipmentList this
            if(modifier.which() == 1)
            {
                mod.second.second += boost::get<int32_t>(modifier);
            }
        }
    });

    return result;
}


text:
Manage Users

                            id
                            firstName
                            lastName
                            role
                            status

                            {{ user.id }}
                            {{ user.firstName }}
                            {{ user.lastName }}
                            {{ user.role }}
                            {{ user.status }}
                            <button class="logout" ng-click="$ctrl.showUserEdit(user)">edit</button>

                    <input type="text" placeholder="id" ng-model="$ctrl.newUser.id">
                    <input type="text" placeholder="title (optional)" ng-model="$ctrl.newUser.title">
                    <input type="text" placeholder="firstName" ng-model="$ctrl.newUser.firstName">
                    <input type="text" placeholder="lastName" ng-model="$ctrl.newUser.lastName">
                    <input type="text" placeholder="orcid" ng-model="$ctrl.newUser.orcid">
                    <input type="text" placeholder="affiliation" ng-model="$ctrl.newUser.affiliation">
                    <input type="password" placeholder="password" ng-model="$ctrl.newUser.pwd">
                    <input type="password" placeholder="confirm password" ng-model="$ctrl.newUser.passwordConfirm">

                    error!

                    <input type="text" placeholder="id" ng-model="$ctrl.user.id" ng-class="{'inactive': true}" disabled>
                    <input type="text" placeholder="title (optional)" ng-model="$ctrl.user.title">
                    <input type="text" placeholder="firstName" ng-model="$ctrl.user.firstName">
                    <input type="text" placeholder="lastName" ng-model="$ctrl.user.lastName">
                    <input type="text" placeholder="orcid" ng-model="$ctrl.user.orcid">
                    <input type="text" placeholder="affiliation" ng-model="$ctrl.user.affiliation">
                    <select ng-model="$ctrl.user.status">
                        <option value="active">active</option>
                        <option value="inactive">inactive</option>
                    </select>

                    error!

    <button class="logout apply" ng-click="$ctrl.openNewUser()" ng-if="!$ctrl.showNewUser && !$ctrl.editUser">
        Create User
    </button>

    <button class="logout cancel" ng-if="$ctrl.showNewUser || $ctrl.editUser" ng-click="$ctrl.showNewUser = false; $ctrl.editUser = false">    back
    </button>

    <button class="logout apply" ng-click="$ctrl.save($ctrl.user)" ng-if="$ctrl.editUser" ng-class="{'inactive': !$ctrl.isValidUpdate($ctrl.user)}" ng-disabled="!$ctrl.isValidUpdate($ctrl.user)">
        save
    </button>

    <button class="logout apply" ng-click="$ctrl.create()" ng-class="{'inactive': !$ctrl.isValidNew($ctrl.newUser)}" ng-disabled="!$ctrl.isValidNew($ctrl.newUser)" ng-if="$ctrl.showNewUser">
        create
    </button>


text:
layout: page
title: About
header-img: "img/about-bg.png"
---

Full stack dev in training. Eater of cake, petter of dogs.