text:
"""
flow.py

Created by Thomas Mangin on 2010-01-14.
Copyright (c) 2009-2013  Exa Networks. All rights reserved.
"""

from struct import pack,unpack

from exabgp.protocol.family import AFI,SAFI
from exabgp.protocol.ip.address import Address
from exabgp.bgp.message.direction import OUT
from exabgp.bgp.message.update.nlri.prefix import Prefix
from exabgp.bgp.message.notification import Notify

from exabgp.protocol import Protocol,NamedProtocol
from exabgp.protocol.ip.icmp import ICMPType,ICMPCode,NamedICMPType,NamedICMPCode
from exabgp.protocol.ip.fragment import Fragment,NamedFragment
from exabgp.protocol.ip.tcp.flag import TCPFlag,NamedTCPFlag

# =================================================================== Flow Components

class IComponent (object):
	# all have ID
	# should have an interface for serialisation and put it here
	pass

class CommonOperator (object):
	# power (2,x) is the same as 1 << x which is what the RFC say the len is
	power = {0:1, 1:2, 2:4, 3:8,}
	rewop = {1:0, 2:1, 4:2, 8:3,}
	len_position = 0x30

	EOL       = 0x80  # 0b10000000
	AND       = 0x40  # 0b01000000
	LEN       = 0x30  # 0b00110000
	NOP       = 0x00

	OPERATOR  = 0xFF ^ (EOL | LEN)

	@staticmethod
	def eol (data):
		return data & CommonOperator.EOL

	@staticmethod
	def operator (data):
		return data & CommonOperator.OPERATOR

	@staticmethod
	def length (data):
		return 1 << ((data & CommonOperator.LEN) >> 4)

class NumericOperator (CommonOperator):
#	reserved  = 0x08  # 0b00001000
	LT        = 0x04  # 0b00000100
	GT        = 0x02  # 0b00000010
	EQ        = 0x01  # 0b00000001

class BinaryOperator (CommonOperator):
#	reserved  = 0x0C  # 0b00001100
	NOT       = 0x02  # 0b00000010
	MATCH     = 0x01  # 0b00000001

def _len_to_bit (value):
	return NumericOperator.rewop[value] << 4

def _bit_to_len (value):
	return NumericOperator.power[(value & CommonOperator.len_position) >> 4]

def _number (string):
	value = 0
	for c in string:
		value = (value << 8) + ord(c)
	return value

# def short (value):
# 	return (ord(value[0]) << 8) + ord(value[1])

# Interface ..................

class IPv4 (object):
	afi = AFI.ipv4

class IPv6 (object):
	afi = AFI.ipv6

class IPrefix (object):
	pass

# Prococol

class IPrefix4 (IPrefix,IComponent,IPv4):
	# not used, just present for simplying the nlri generation
	operations = 0x0
	# NAME

	def __init__ (self,raw,netmask):
		self.nlri = Prefix(self.afi,SAFI.flow_ip,raw,netmask)

	def pack (self):
		raw = self.nlri.pack()
		return "%s%s" % (chr(self.ID),raw)

	def __str__ (self):
		return str(self.nlri)

class IPrefix6 (IPrefix,IComponent,IPv6):
	# not used, just present for simplying the nlri generation
	operations = 0x0
	# NAME

	def __init__ (self,raw,netmask,offset):
		self.nlri = Prefix(self.afi,SAFI.flow_ip,raw,netmask)
		self.offset = offset

	def pack (self):
		raw = self.nlri.packed_ip()
		return "%s%s%s%s" % (chr(self.ID),chr(self.nlri.mask),chr(self.offset),raw)

	def __str__ (self):
		return "%s/%s" % (self.nlri,self.offset)

class IOperation (IComponent):
	# need to implement encode which encode the value of the operator

	def __init__ (self,operations,value):
		self.operations = operations
		self.value = value
		self.first = None  # handled by pack/str

	def pack (self):
		l,v = self.encode(self.value)
		op = self.operations | _len_to_bit(l)
		return "%s%s" % (chr(op),v)

	def encode (self,value):
		raise NotImplemented('this method must be implemented by subclasses')

	def decode (self,value):
		raise NotImplemented('this method must be implemented by subclasses')

#class IOperationIPv4 (IOperation):
#	def encode (self,value):
#		return 4, socket.pton(socket.AF_INET,value)

class IOperationByte (IOperation):
	def encode (self,value):
		return 1,chr(value)

	def decode (self,bgp):
		return ord(bgp[0]),bgp[1:]

class IOperationByteShort (IOperation):
	def encode (self,value):
		if value < (1<<8):
			return 1,chr(value)
		return 2,pack('!H',value)

	def decode (self,bgp):
		return unpack('!H',bgp[:2])[0],bgp[2:]

# String representation for Numeric and Binary Tests

class NumericString (object):
	_string = {
		NumericOperator.LT   : '<',
		NumericOperator.GT   : '>',
		NumericOperator.EQ   : '=',
		NumericOperator.LT|NumericOperator.EQ : '<=',
		NumericOperator.GT|NumericOperator.EQ : '>=',

		NumericOperator.AND|NumericOperator.LT   : '&<',
		NumericOperator.AND|NumericOperator.GT   : '&>',
		NumericOperator.AND|NumericOperator.EQ   : '&=',
		NumericOperator.AND|NumericOperator.LT|NumericOperator.EQ : '&<=',
		NumericOperator.AND|NumericOperator.GT|NumericOperator.EQ : '&>=',
	}

	def __str__ (self):
		return "%s%s" % (self._string[self.operations & (CommonOperator.EOL ^ 0xFF)], self.value)

class BinaryString (object):
	_string = {
		BinaryOperator.NOT   : '!',
		BinaryOperator.MATCH : '=',
		BinaryOperator.AND|BinaryOperator.NOT   : '&!',
		BinaryOperator.AND|BinaryOperator.MATCH : '&=',
	}

	def __str__ (self):
		return "%s%s" % (self._string[self.operations & (CommonOperator.EOL ^ 0xFF)], self.value)

# Components ..............................

def converter (function,klass=int):
	def _integer (value):
		try:
			return klass(value)
		except ValueError:
			return function(value)
	return _integer

def decoder (function,klass=int):
	def _inner (value):
		return klass(function(value))
	return _inner

def PacketLength (data):
	_str_bad_length = "cloudflare already found that invalid max-packet length for for you .."
	number = int(data)
	if number > 0xFFFF:
		raise ValueError(_str_bad_length)
	return number

def PortValue (data):
	_str_bad_port = "you tried to set an invalid port number .."
	number = int(data)
	if number < 0 or number > 0xFFFF:
		raise ValueError(_str_bad_port)
	return number

def DSCPValue (data):
	_str_bad_dscp = "you tried to filter a flow using an invalid dscp for a component .."
	number = int(data)
	if number < 0 or number > 0xFFFF:
		raise ValueError(_str_bad_dscp)
	return number

def ClassValue (data):
	_str_bad_class = "you tried to filter a flow using an invalid traffic class for a component .."
	number = int(data)
	if number < 0 or number > 0xFFFF:
		raise ValueError(_str_bad_class)
	return number

def LabelValue (data):
	_str_bad_label = "you tried to filter a flow using an invalid traffic label for a component .."
	number = int(data)
	if number < 0 or number > 0xFFFFF:  # 20 bits 5 bytes
		raise ValueError(_str_bad_label)
	return number

# Protocol Shared

class FlowDestination (object):
	ID = 0x01
	NAME = 'destination'

class FlowSource (object):
	ID = 0x02
	NAME = 'source'

# Prefix
class Flow4Destination (IPrefix4,FlowDestination):
	pass

# Prefix
class Flow4Source (IPrefix4,FlowSource):
	pass

# Prefix
class Flow6Destination (IPrefix6,FlowDestination):
	pass

# Prefix
class Flow6Source (IPrefix6,FlowSource):
	pass

class FlowIPProtocol (IOperationByte,NumericString,IPv4):
	ID  = 0x03
	NAME = 'protocol'
	converter = staticmethod(converter(NamedProtocol,Protocol))
	decoder = staticmethod(decoder(ord,Protocol))

class FlowNextHeader (IOperationByte,NumericString,IPv6):
	ID  = 0x03
	NAME = 'next-header'
	converter = staticmethod(converter(NamedProtocol,Protocol))
	decoder = staticmethod(decoder(ord,Protocol))

class FlowAnyPort (IOperationByteShort,NumericString,IPv4,IPv6):
	ID  = 0x04
	NAME = 'port'
	converter = staticmethod(converter(PortValue))
	decoder = staticmethod(_number)

class FlowDestinationPort (IOperationByteShort,NumericString,IPv4,IPv6):
	ID  = 0x05
	NAME = 'destination-port'
	converter = staticmethod(converter(PortValue))
	decoder = staticmethod(_number)

class FlowSourcePort (IOperationByteShort,NumericString,IPv4,IPv6):
	ID  = 0x06
	NAME = 'source-port'
	converter = staticmethod(converter(PortValue))
	decoder = staticmethod(_number)

class FlowICMPType (IOperationByte,BinaryString,IPv4,IPv6):
	ID = 0x07
	NAME = 'icmp-type'
	converter = staticmethod(converter(NamedICMPType))
	decoder = staticmethod(decoder(_number,ICMPType))

class FlowICMPCode (IOperationByte,BinaryString,IPv4,IPv6):
	ID = 0x08
	NAME = 'icmp-code'
	converter = staticmethod(converter(NamedICMPCode))
	decoder = staticmethod(decoder(_number,ICMPCode))

class FlowTCPFlag (IOperationByte,BinaryString,IPv4,IPv6):
	ID = 0x09
	NAME = 'tcp-flags'
	converter = staticmethod(converter(NamedTCPFlag))
	decoder = staticmethod(decoder(ord,TCPFlag))

class FlowPacketLength (IOperationByteShort,NumericString,IPv4,IPv6):
	ID = 0x0A
	NAME = 'packet-length'
	converter = staticmethod(converter(PacketLength))
	decoder = staticmethod(_number)

# RFC2474
class FlowDSCP (IOperationByteShort,NumericString,IPv4):
	ID = 0x0B
	NAME = 'dscp'
	converter = staticmethod(converter(DSCPValue))
	decoder = staticmethod(_number)

# RFC2460
class FlowTrafficClass (IOperationByte,NumericString,IPv6):
	ID = 0x0B
	NAME = 'traffic-class'
	converter = staticmethod(converter(ClassValue))
	decoder = staticmethod(_number)

# BinaryOperator
class FlowFragment (IOperationByteShort,NumericString,IPv4):
	ID = 0x0C
	NAME = 'fragment'
	converter = staticmethod(converter(NamedFragment))
	decoder = staticmethod(decoder(ord,Fragment))

# draft-raszuk-idr-flow-spec-v6-01
class FlowFlowLabel (IOperationByteShort,NumericString,IPv6):
	ID = 0x0D
	NAME = 'flow-label'
	converter = staticmethod(converter(LabelValue))
	decoder = staticmethod(_number)

# ..........................................................

decode = {AFI.ipv4: {}, AFI.ipv6: {}}
factory = {AFI.ipv4: {}, AFI.ipv6: {}}

for content in dir():
	klass = globals().get(content,None)
	if not isinstance(klass,type(IComponent)):
		continue
	if not issubclass(klass,IComponent):
		continue
	if issubclass(klass,IPv4):
		afi = AFI.ipv4
	elif issubclass(klass,IPv6):
		afi = AFI.ipv6
	else:
		continue
	ID = getattr(klass,'ID',None)
	if not ID:
		continue
	factory[afi][ID] = klass
	name = getattr(klass,'NAME')

	if issubclass(klass, IOperation):
		if issubclass(klass, BinaryString):
			decode[afi][ID] = 'binary'
		elif issubclass(klass, NumericString):
			decode[afi][ID] = 'numeric'
		else:
			raise RuntimeError('invalid class defined (string)')
	elif issubclass(klass, IPrefix):
		decode[afi][ID] = 'prefix'
	else:
		raise RuntimeError('unvalid class defined (type)')

# ..........................................................

def _unique ():
	value = 0
	while True:
		yield value
		value += 1

unique = _unique()

class FlowNLRI (Address):
	def __init__ (self,afi=AFI.ipv4,safi=SAFI.flow_ip,rd=None):
		Address.__init__(self,afi,safi)
		self.rules = {}
		self.action = OUT.announce
		self.nexthop = None
		self.rd = rd

	def __len__ (self):
		return len(self.pack())

	def add (self,rule):
		ID = rule.ID
		if ID in (FlowDestination.ID,FlowSource.ID):
			if ID in self.rules:
				return False
			if ID == FlowDestination.ID:
				pair = self.rules.get(FlowSource.ID,[])
			else:
				pair = self.rules.get(FlowDestination.ID,[])
			if pair:
				if rule.afi != pair[0].afi:
					return False
		self.rules.setdefault(ID,[]).append(rule)
		return True

	# The API requires addpath, but it is irrelevant here.
	def pack (self,addpath=None):
		ordered_rules = []
		# the order is a RFC requirement
		for ID in sorted(self.rules.keys()):
			rules = self.rules[ID]
			# for each component get all the operation to do
			# the format use does not prevent two opposing rules meaning that no packet can ever match
			for rule in rules:
				rule.operations &= (CommonOperator.EOL ^ 0xFF)
			rules[-1].operations |= CommonOperator.EOL
			# and add it to the last rule
			if ID not in (FlowDestination.ID,FlowSource.ID):
				ordered_rules.append(chr(ID))
			ordered_rules.append(''.join(rule.pack() for rule in rules))

		components = ''.join(ordered_rules)

		if self.safi == SAFI.flow_vpn:
			components = self.rd.pack() + components

		l = len(components)
		if l < 0xF0:
			data = "%s%s" % (chr(l),components)
		elif l < 0x0FFF:
			data = "%s%s" % (pack('!H',l | 0xF000),components)
		else:
			raise Notify("rule too big for NLRI - how to handle this - does this work ?")
			data = "%s" % chr(0)

		return data

	def extensive (self):
		string = []
		for index in sorted(self.rules):
			rules = self.rules[index]
			s = []
			for idx,rule in enumerate(rules):
				# only add ' ' after the first element
				if idx and not rule.operations & NumericOperator.AND:
					s.append(' ')
				s.append(rule)
			string.append(' %s %s' % (rules[0].NAME,''.join(str(_) for _ in s)))
		nexthop = ' next-hop %s' % self.nexthop if self.nexthop else ''
		rd = str(self.rd) if self.rd else ''
		return 'flow' + rd + ''.join(string) + nexthop

	def __str__ (self):
		return self.extensive()

	def json (self):
		# this is a stop gap so flow route parsing does not crash exabgp
		# delete unique when this is fixed
		return '"flow-%d": { "string": "%s" }' % (unique.next(),str(self),)

	def index (self):
		return self.pack()

def _next_index ():
	value = 0
	while True:
		yield str(value)
		value += 1

next_index = _next_index()


text:
<?php

return [

    /**
     * What attributes do we use to build the slug?
     * This can be a single field, like "name" which will build a slug from:
     *
     *     $model->name;
     *
     * Or it can be an array of fields, like ("name", "company"), which builds a slug from:
     *
     *     $model->name . ' ' . $model->company;
     *
     * If you've defined custom getters in your model, you can use those too,
     * since Eloquent will call them when you request a custom attribute.
     *
     * Defaults to null, which uses the toString() method on your model.
     */

    'build_from' => null,

    /**
     * What field to we store the slug in?  Defaults to "slug".
     * You need to configure this when building the SQL for your database, e.g.:
     *
     * Schema::create('users', function($table)
     * {
     *    $table->string('slug');
     * });
     */

    'save_to' => 'slug',

    /**
     * The maximum length of a generated slug.  Defaults to "null", which means
     * no length restrictions are enforced.  Set it to a positive integer if you
     * want to make sure your slugs aren't too long.
     */

    'max_length' => null,

    /**
     * If left to "null", then use the cocur/slugify package to generate the slug
     * (with the separator defined below).
     *
     * Set this to a closure that accepts two parameters (string and separator)
     * to define a custom slugger.  e.g.:
     *
     *    'method' => function( $string, $sep ) {
     *       return preg_replace('/[^a-z]+/i', $sep, $string);
     *    },
     *
     * Otherwise, this will be treated as a callable to be used.  e.g.:
     *
     *    'method' => array('Str','slug'),
     */

    'method' => null,

    /**
     * Separator to use when generating slugs.  Defaults to a hyphen.
     */

    'separator' => '-',

    /**
     * Enforce uniqueness of slugs?  Defaults to true.
     * If a generated slug already exists, an incremental numeric
     * value will be appended to the end until a unique slug is found.  e.g.:
     *
     *     my-slug
     *     my-slug-1
     *     my-slug-2
     */

    'unique' => true,

    /**
     * Should we include the trashed items when generating a unique slug?
     * This only applies if the softDelete property is set for the Eloquent model.
     * If set to "false", then a new slug could duplicate one that exists on a trashed model.
     * If set to "true", then uniqueness is enforced across trashed and existing models.
     */

    'include_trashed' => false,

    /**
     * Whether to update the slug value when a model is being
     * re-saved (i.e. already exists).  Defaults to false, which
     * means slugs are not updated.
     */

    'on_update' => false,

    /**
     * An array of slug names that can never be used for this model,
     * e.g. to prevent collisions with existing routes or controller methods, etc..
     * Defaults to null (i.e. no reserved names).
     * Can be a static array, e.g.:
     *
     *    'reserved' => array('add', 'delete'),
     *
     * or a closure that returns an array of reserved names.
     * If using a closure, it will accept one parameter: the model itself, and should
     * return an array of reserved names, or null. e.g.
     *
     *    'reserved' => function( Model $model) {
     *      return $model->some_method_that_returns_an_array();
     *    }
     *
     * In the case of a slug that gets generated with one of these reserved names,
     * we will do:
     *
     *    $slug .= $seperator + "1"
     *
     * and continue from there.
     */

    'reserved' => null,

];

redpajama_set_name: RedPajamaGithub


text:
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Kooboo.CMS.Content.Models;
using Kooboo.CMS.Content.Query;

namespace Kooboo.CMS.Content.Persistence.SqlServer.Tests
{
    /// <summary>
    /// Summary description for SimpleQueryTests
    /// </summary>
    [TestClass]
    public class ParentQueryTests
    {
        static Repository repository = null;
        static Schema newsSchema;
        static TextFolder newsFolder;
        static Schema commentSchema;

        static TextContentProvider textContentProvider = new TextContentProvider();
        static ParentQueryTests()
        {
            repository = new Repository("ParentQueryTests");

            commentSchema = new Schema(repository, "comments");
            commentSchema.AddColumn(new Column() { Name = "title", DataType = Kooboo.Data.DataType.String, Length = 256 });

            newsSchema = new Schema(repository, "news") { ChildSchemas = new[] { commentSchema.Name } };
            newsSchema.AddColumn(new Column()
            {
                Name = "Title",
                DataType = Kooboo.Data.DataType.String,
                Length = 256
            });
            newsSchema.AddColumn(new Column()
            {
                Name = "Comments",
                DataType = Kooboo.Data.DataType.Int
            });

            newsFolder = new TextFolder(repository, "news") { SchemaName = newsSchema.Name };

            ProviderFactory providerFactory = new ProviderFactory();
            Providers.DefaultProviderFactory = providerFactory;
            providerFactory.GetProvider<IRepositoryProvider>().Add(repository);
            providerFactory.GetProvider<ISchemaProvider>().Add(commentSchema);
            providerFactory.GetProvider<ISchemaProvider>().Add(newsSchema);
            providerFactory.GetProvider<ITextFolderProvider>().Add(newsFolder);
            InitializeData();
        }
        [TestMethod]
        public void TestQuery()
        {
            var query = commentSchema.CreateQuery().WhereEquals("title", "comment1").Parent(newsSchema.Name);

            Assert.AreEqual(1, query.Count());
            var first = query.OrderBy("id").First();
            Assert.AreEqual("news1", first["title"]);
        }

        private static void InitializeData()
        {
            dynamic news1 = new TextContent(repository.Name, newsSchema.Name, newsFolder.Name)
            {
                UserKey = "news1"
            };
            news1.title = "news1";
            textContentProvider.Add(news1);

            dynamic comment1 = new TextContent(repository.Name, commentSchema.Name, null)
            {
                UserKey = "comment1",
                ParentUUID = news1.UUID
            };
            comment1.Title = "comment1";

            textContentProvider.Add(comment1);

            dynamic comment2 = new TextContent(repository.Name, commentSchema.Name, null)
            {
                UserKey = "comment2",
                ParentUUID = news1.UUID
            };
            comment2.Title = "comment2";

            textContentProvider.Add(comment2);
        }
    }
}


text:
"""
    Support Requests
"""

if deployment_settings.get_options_support_requests():

    # -------------------------------------------------------------------------
    support_request_types = {
        1 : T("Bug"),
        2 : T("Feature Request")
    }
    support_status_opts = {
        1 : T("Open"),
        2 : T("Closed")
    }

    tablename = "support_req"
    table = db.define_table(tablename,
                            Field("name", notnull=True,
                                  label=T("Short Description")),
                            Field("type", "integer", label=T("Type"),
                                  requires=IS_IN_SET(support_request_types,
                                                     zero="%s..." % T("Please select")),
                                  represent=lambda opt: \
                                    support_request_types.get(opt,
                                                              UNKNOWN_OPT)),
                            Field("details", "text", label = T("Details"),
                                  comment = "%s%s" % (T("Please provide the URL of the page you are referring to, a description of what you expected to happen & what actually happened."),
                                                      T("If a ticket was issued then please provide the Ticket ID."))),
                            Field("status", "integer", label=T("Status"),
                                  default=1,
                                  requires=IS_IN_SET(support_status_opts),
                                  represent=lambda opt: \
                                    support_status_opts.get(opt, UNKNOWN_OPT)),
                            Field("actions", "text", label = T("Actions"),
                                  comment = T("Actions taken as a result of this request.")),
                            *s3_meta_fields())

    # CRUD strings
    ADD_REQUEST = T("New Support Request")
    LIST_REQUESTS = T("List Support Requests")
    s3.crud_strings[tablename] = Storage(
        title_create = ADD_REQUEST,
        title_display = T("Request Details"),
        title_list = LIST_REQUESTS,
        title_update = T("Edit Request"),
        title_search = T("Search Support Requests"),
        subtitle_create = T("Add New Request"),
        subtitle_list = T("Support Requests"),
        label_list_button = LIST_REQUESTS,
        label_create_button = ADD_REQUEST,
        label_delete_button = T("Delete Request"),
        msg_record_created = T("Request added"),
        msg_record_modified = T("Request updated"),
        msg_record_deleted = T("Request deleted"),
        msg_list_empty = T("No Support Requests currently registered"))

# END -------------------------------------------------------------------------


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

<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<title>ElementData (Apache Jena ARQ)</title>
<meta name="date" content="2014-10-02">
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

com.hp.hpl.jena.sparql.syntax

Class ElementData

java.lang.Object

com.hp.hpl.jena.sparql.syntax.Element

com.hp.hpl.jena.sparql.syntax.ElementData

public class ElementData
extends Element

Constructor Summary

Constructors

Constructor and Description

ElementData()

Method Summary

Methods

Modifier and Type
Method and Description

void
add(Binding binding)

void
add(Var var)

boolean
equalTo(Element el2,
       NodeIsomorphismMap isoMap)

List<Binding>
getRows()

Table
getTable()

List<Var>
getVars()

int
hashCode()

void
visit(ElementVisitor v)

Methods inherited from class com.hp.hpl.jena.sparql.syntax.Element

equals, toString

Methods inherited from class java.lang.Object

getClass, notify, notifyAll, wait, wait, wait

Constructor Detail

ElementData

public ElementData()

Method Detail

getTable

public Table getTable()

getVars

public List<Var> getVars()

getRows

public List<Binding> getRows()

add

public void add(Var var)

add

public void add(Binding binding)

equalTo

public boolean equalTo(Element el2,
              NodeIsomorphismMap isoMap)

Specified by:

equalTo in class Element

hashCode

public int hashCode()

Specified by:

hashCode in class Element

visit

public void visit(ElementVisitor v)

Specified by:

visit in class Element

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

Licenced under the Apache License, Version 2.0


text:
function newGame() {
	var escapedName = encodeURI($("#new-game-name").val());
	var ajaxURI = "/ajax/new_game?name=" + escapedName;

	$.post(ajaxURI).done(updateGameList);
}

var fn;

function updateGameList() {
	$.getJSON("/ajax/games")
		.done(function(games) {
			// rerender template using new game list
			fn = fn || $(".game-list").compile(null, games);
			$(".game-list").render(games, fn);

			$("#create-game").click(newGame);
		});
}

$(function () {
	updateGameList();
})


text:
package org.apache.ivy.core.pack;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import org.apache.ivy.util.FileUtil;
import org.apache.ivy.util.Message;

public class ZipPacking extends ArchivePacking {

    private static final String[] NAMES = {"zip", "jar", "war"};

    @Override
    public String[] getNames() {
        return NAMES;
    }

    @Override
    public String getUnpackedExtension(String ext) {
        if (ext.endsWith("zip") || ext.endsWith("jar") || ext.endsWith("war")) {
            ext = ext.substring(0, ext.length() - 3);
            if (ext.endsWith(".")) {
                ext = ext.substring(0, ext.length() - 1);
            }
        }
        return ext;
    }

    @Override
    public void unpack(InputStream packed, File dest) throws IOException {
        try (ZipInputStream zip = new ZipInputStream(packed)) {
            ZipEntry entry = null;
            while (((entry = zip.getNextEntry()) != null)) {
                File f = new File(dest, entry.getName());
                Message.verbose("\t\texpanding " + entry.getName() + " to " + f);

                // create intermediary directories - sometimes zip don't add them
                File dirF = f.getParentFile();
                if (dirF != null) {
                    dirF.mkdirs();
                }

                if (entry.isDirectory()) {
                    f.mkdirs();
                } else {
                    writeFile(zip, f);
                }

                f.setLastModified(entry.getTime());
            }
        }
    }

    protected void writeFile(InputStream zip, File f) throws IOException {
        try (FileOutputStream out = new FileOutputStream(f)) {
            FileUtil.copy(zip, out, null, false);
        }
    }

}


text:
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.

Imports System.Collections.Immutable
Imports System.Composition
Imports System.Diagnostics.CodeAnalysis
Imports System.Threading
Imports Microsoft.CodeAnalysis.CaseCorrection
Imports Microsoft.CodeAnalysis.Formatting
Imports Microsoft.CodeAnalysis.Host
Imports Microsoft.CodeAnalysis.Text

Namespace Microsoft.CodeAnalysis.CodeCleanup.Providers
    <ExportCodeCleanupProvider(PredefinedCodeCleanupProviderNames.CaseCorrection, LanguageNames.VisualBasic), [Shared]>
    <ExtensionOrder(Before:=PredefinedCodeCleanupProviderNames.Format)>
    Friend Class CaseCorrectionCodeCleanupProvider
        Implements ICodeCleanupProvider

        <ImportingConstructor>
        <SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification:="https://github.com/dotnet/roslyn/issues/42820")>
        Public Sub New()
        End Sub

        Public ReadOnly Property Name As String Implements ICodeCleanupProvider.Name
            Get
                Return PredefinedCodeCleanupProviderNames.CaseCorrection
            End Get
        End Property

        Public Function CleanupAsync(document As Document, spans As ImmutableArray(Of TextSpan), options As CodeCleanupOptions, cancellationToken As CancellationToken) As Task(Of Document) Implements ICodeCleanupProvider.CleanupAsync
            Return CaseCorrector.CaseCorrectAsync(document, spans, cancellationToken)
        End Function

        Public Function CleanupAsync(root As SyntaxNode, spans As ImmutableArray(Of TextSpan), options As SyntaxFormattingOptions, services As SolutionServices, cancellationToken As CancellationToken) As Task(Of SyntaxNode) Implements ICodeCleanupProvider.CleanupAsync
            Return Task.FromResult(CaseCorrector.CaseCorrect(root, spans, services, cancellationToken))
        End Function
    End Class
End Namespace


text:
package com.pacoapp.paco.shared.model2;

import org.codehaus.jackson.annotate.JsonProperty;

import java.io.Serializable;

public class Output implements Serializable {

  @JsonProperty("answer")
  private String value;

  private String name;

  public Output(String name, String value) {
    this.value = value;
    this.name = name;
  }

  @JsonProperty("answer")
  public String getValue() {
    return value;
  }

  @JsonProperty("answer")
  public void setValue(String value) {
    this.value = value;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

}