code stringlengths 5 1.01M | repo_name stringlengths 5 84 | path stringlengths 4 311 | language stringclasses 30
values | license stringclasses 15
values | size int64 5 1.01M | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|
/* GStreamer dmabuf allocator
* Copyright (C) 2013 Linaro SA
* Author: Benjamin Gaignard <benjamin.gaignard@linaro.org> for Linaro.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_DMABUF_H__
#define __GST_DMABUF_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_ALLOCATOR_DMABUF "dmabuf"
GstAllocator * gst_dmabuf_allocator_new (void);
GstMemory * gst_dmabuf_allocator_alloc (GstAllocator * allocator, gint fd, gsize size);
gint gst_dmabuf_memory_get_fd (GstMemory * mem);
gboolean gst_is_dmabuf_memory (GstMemory * mem);
G_END_DECLS
#endif /* __GST_DMABUF_H__ */
| JulienMcJay/eclock | windows/gstreamer/include/gstreamer-1.0/gst/allocators/gstdmabuf.h | C | gpl-2.0 | 1,309 | [
30522,
1013,
1008,
28177,
25379,
2121,
1040,
2863,
8569,
2546,
2035,
24755,
4263,
1008,
9385,
1006,
1039,
1007,
2286,
27022,
3217,
7842,
1008,
3166,
1024,
6425,
11721,
23773,
4232,
1026,
6425,
1012,
11721,
23773,
4232,
1030,
27022,
3217,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
default_app_config = "gallery.apps.GalleryConfig"
| cdriehuys/chmvh-website | chmvh_website/gallery/__init__.py | Python | mit | 50 | [
30522,
12398,
1035,
10439,
1035,
9530,
8873,
2290,
1027,
1000,
3916,
1012,
18726,
1012,
3916,
8663,
8873,
2290,
1000,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package eu.motogymkhana.server.api.result;
public class TokenResult extends GymkhanaResult{
}
| xtien/motogymkhana-server-ui | src/main/java/eu/motogymkhana/server/api/result/TokenResult.java | Java | apache-2.0 | 96 | [
30522,
7427,
7327,
1012,
9587,
3406,
6292,
2213,
26370,
2050,
1012,
8241,
1012,
17928,
1012,
2765,
1025,
2270,
2465,
19204,
6072,
11314,
8908,
9726,
26370,
17933,
11314,
1063,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.camel.util;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.ModelHelper;
/**
*
*/
public class DumpModelAsXmlChoiceFilterRouteTest extends ContextTestSupport {
public void testDumpModelAsXml() throws Exception {
String xml = ModelHelper.dumpModelAsXml(context.getRouteDefinition("myRoute"));
assertNotNull(xml);
log.info(xml);
assertTrue(xml.contains("<header>gold</header>"));
assertTrue(xml.contains("<header>extra-gold</header>"));
assertTrue(xml.contains("<simple>${body} contains Camel</simple>"));
}
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").routeId("myRoute")
.to("log:input")
.choice()
.when().header("gold")
.to("mock:gold")
.filter().header("extra-gold")
.to("mock:extra-gold")
.endChoice()
.when().simple("${body} contains Camel")
.to("mock:camel")
.otherwise()
.to("mock:other")
.end()
.to("mock:result");
}
};
}
}
| engagepoint/camel | camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlChoiceFilterRouteTest.java | Java | apache-2.0 | 2,322 | [
30522,
1013,
1008,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
2030,
2062,
1008,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
5500,
2007,
1008,
2023,
2147,
2005,
3176,
2592,
4953,
9385,
6095,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Tag-closer extension for CodeMirror.
*
* This extension adds an "autoCloseTags" option that can be set to
* either true to get the default behavior, or an object to further
* configure its behavior.
*
* These are supported options:
*
* `whenClosing` (default true)
* Whether to autoclose when the '/' of a closing tag is typed.
* `whenOpening` (default true)
* Whether to autoclose the tag when the final '>' of an opening
* tag is typed.
* `dontCloseTags` (default is empty tags for HTML, none for XML)
* An array of tag names that should not be autoclosed.
* `indentTags` (default is block tags for HTML, none for XML)
* An array of tag names that should, when opened, cause a
* blank line to be added inside the tag, and the blank line and
* closing line to be indented.
*
* See demos/closetag.html for a usage example.
*/
(function() {
CodeMirror.defineOption("autoCloseTags", false, function(cm, val, old) {
if (val && (old == CodeMirror.Init || !old)) {
var map = {name: "autoCloseTags"};
if (typeof val != "object" || val.whenClosing)
map["'/'"] = function(cm) { autoCloseTag(cm, '/'); };
if (typeof val != "object" || val.whenOpening)
map["'>'"] = function(cm) { autoCloseTag(cm, '>'); };
cm.addKeyMap(map);
} else if (!val && (old != CodeMirror.Init && old)) {
cm.removeKeyMap("autoCloseTags");
}
});
var htmlDontClose = ["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param",
"source", "track", "wbr"];
var htmlIndent = ["applet", "blockquote", "body", "button", "div", "dl", "fieldset", "form", "frameset", "h1", "h2", "h3", "h4",
"h5", "h6", "head", "html", "iframe", "layer", "legend", "object", "ol", "p", "select", "table", "ul"];
function autoCloseTag(cm, ch) {
var pos = cm.getCursor(), tok = cm.getTokenAt(pos);
var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
if (inner.mode.name != "xml") throw CodeMirror.Pass;
var opt = cm.getOption("autoCloseTags"), html = inner.mode.configuration == "html";
var dontCloseTags = (typeof opt == "object" && opt.dontCloseTags) || (html && htmlDontClose);
var indentTags = (typeof opt == "object" && opt.indentTags) || (html && htmlIndent);
if (ch == ">" && state.tagName) {
var tagName = state.tagName;
if (tok.end > pos.ch) tagName = tagName.slice(0, tagName.length - tok.end + pos.ch);
var lowerTagName = tagName.toLowerCase();
// Don't process the '>' at the end of an end-tag or self-closing tag
if (tok.type == "tag" && state.type == "closeTag" ||
/\/\s*$/.test(tok.string) ||
dontCloseTags && indexOf(dontCloseTags, lowerTagName) > -1)
throw CodeMirror.Pass;
var doIndent = indentTags && indexOf(indentTags, lowerTagName) > -1;
cm.replaceSelection(">" + (doIndent ? "\n\n" : "") + "</" + tagName + ">",
doIndent ? {line: pos.line + 1, ch: 0} : {line: pos.line, ch: pos.ch + 1});
if (doIndent) {
cm.indentLine(pos.line + 1);
cm.indentLine(pos.line + 2);
}
return;
} else if (ch == "/" && tok.type == "tag" && tok.string == "<") {
var tagName = state.context && state.context.tagName;
if (tagName) cm.replaceSelection("/" + tagName + ">", "end");
return;
}
throw CodeMirror.Pass;
}
function indexOf(collection, elt) {
if (collection.indexOf) return collection.indexOf(elt);
for (var i = 0, e = collection.length; i < e; ++i)
if (collection[i] == elt) return i;
return -1;
}
})();
| d8ta/CMS_Skiclub | wp-content/plugins/ilightbox/scripts/codemirror/closetag.js | JavaScript | gpl-2.0 | 3,778 | [
30522,
1013,
1008,
1008,
1008,
6415,
1011,
3553,
5331,
2005,
3642,
14503,
29165,
1012,
1008,
1008,
2023,
5331,
9909,
2019,
1000,
8285,
20464,
9232,
15900,
2015,
1000,
5724,
2008,
2064,
2022,
2275,
2000,
1008,
2593,
2995,
2000,
2131,
1996,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Astro.createValidator({
name: 'array',
validate: _.isArray,
events: {
validationerror: function(e) {
var fieldName = e.data.field;
e.data.message = 'The "' + fieldName +
'" field\'s value has to be an array';
}
}
});
| ribbedcrown/meteor-astronomy-validators | lib/validators/type/array.js | JavaScript | mit | 254 | [
30522,
28625,
1012,
3443,
10175,
8524,
4263,
1006,
1063,
2171,
1024,
1005,
9140,
1005,
1010,
9398,
3686,
1024,
1035,
1012,
18061,
11335,
2100,
1010,
2824,
1024,
1063,
27354,
2121,
29165,
1024,
3853,
1006,
1041,
1007,
1063,
13075,
2492,
1844... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package models
import (
"koding/db/mongodb/modelhelper"
"net"
"socialapi/config"
"socialapi/request"
"github.com/koding/logging"
)
// Client holds the contextual requester/client info
type Client struct {
// Account holds the requester info
Account *Account
// IP is remote IP of the requester
IP net.IP
// SessionID is session cookie id
SessionID string
}
// Context holds contextual info regarding a REST query
type Context struct {
GroupName string
Client *Client
log logging.Logger
}
// NewContext creates a new context
func NewContext(log logging.Logger) *Context {
return &Context{
log: log,
}
}
// OverrideQuery overrides Query with context info
func (c *Context) OverrideQuery(q *request.Query) *request.Query {
// get group name from context
q.GroupName = c.GroupName
if c.IsLoggedIn() {
q.AccountId = c.Client.Account.Id
} else {
q.AccountId = 0
}
return q
}
// IsLoggedIn checks if the request is an authenticated one
func (c *Context) IsLoggedIn() bool {
if c.Client == nil {
return false
}
if c.Client.Account == nil {
return false
}
if c.Client.Account.Id == 0 {
return false
}
return true
}
// IsAdmin checks if the current requester is an admin or not, this part is just
// a stub and temproray solution for moderation security, when we implement the
// permission system fully, this should be the first function to remove.
func (c *Context) IsAdmin() bool {
if !c.IsLoggedIn() {
return false
}
superAdmins := config.MustGet().DummyAdmins
return IsIn(c.Client.Account.Nick, superAdmins...)
}
// CanManage checks if the current context is the admin of the context's
// group.
// mongo connection is required.
func (c *Context) CanManage() error {
if !c.IsLoggedIn() {
return ErrNotLoggedIn
}
canManage, err := modelhelper.CanManage(c.Client.Account.Nick, c.GroupName)
if err != nil {
return err
}
if !canManage {
return ErrCannotManageGroup
}
return nil
}
// MustGetLogger gets the logger from context, otherwise panics
func (c *Context) MustGetLogger() logging.Logger {
if c.log == nil {
panic(ErrLoggerNotExist)
}
return c.log
}
| acbodine/koding | go/src/socialapi/models/context.go | GO | agpl-3.0 | 2,142 | [
30522,
7427,
4275,
12324,
1006,
1000,
12849,
4667,
1013,
16962,
1013,
12256,
3995,
18939,
1013,
2944,
16001,
4842,
1000,
1000,
5658,
1000,
1000,
2591,
9331,
2072,
1013,
9530,
8873,
2290,
1000,
1000,
2591,
9331,
2072,
1013,
5227,
1000,
1000,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
namespace LinqToDB.ServiceModel
{
using Common;
using Extensions;
using Mapping;
using SqlQuery;
static class LinqServiceSerializer
{
#region Public Members
public static string Serialize(SelectQuery query, SqlParameter[] parameters, List<string> queryHints)
{
return new QuerySerializer().Serialize(query, parameters, queryHints);
}
public static LinqServiceQuery Deserialize(string str)
{
return new QueryDeserializer().Deserialize(str);
}
public static string Serialize(LinqServiceResult result)
{
return new ResultSerializer().Serialize(result);
}
public static LinqServiceResult DeserializeResult(string str)
{
return new ResultDeserializer().DeserializeResult(str);
}
public static string Serialize(string[] data)
{
return new StringArraySerializer().Serialize(data);
}
public static string[] DeserializeStringArray(string str)
{
return new StringArrayDeserializer().Deserialize(str);
}
#endregion
#region SerializerBase
const int ParamIndex = -1;
const int TypeIndex = -2;
const int TypeArrayIndex = -3;
class SerializerBase
{
protected readonly StringBuilder Builder = new StringBuilder();
protected readonly Dictionary<object,int> Dic = new Dictionary<object,int>();
protected int Index;
static string ConvertToString(Type type, object value)
{
switch (type.GetTypeCodeEx())
{
case TypeCode.Decimal : return ((decimal) value).ToString(CultureInfo.InvariantCulture);
case TypeCode.Double : return ((double) value).ToString(CultureInfo.InvariantCulture);
case TypeCode.Single : return ((float) value).ToString(CultureInfo.InvariantCulture);
case TypeCode.DateTime : return ((DateTime)value).ToString("o");
}
if (type == typeof(DateTimeOffset))
return ((DateTimeOffset)value).ToString("o");
return Converter.ChangeTypeTo<string>(value);
}
protected void Append(Type type, object value)
{
Append(type);
if (value == null)
Append((string)null);
else if (!type.IsArray)
{
Append(ConvertToString(type, value));
}
else
{
var elementType = type.GetElementType();
Builder.Append(' ');
var len = Builder.Length;
var cnt = 0;
if (elementType.IsArray)
foreach (var val in (IEnumerable)value)
{
Append(elementType, val);
cnt++;
}
else
foreach (var val in (IEnumerable)value)
{
if (val == null)
Append(elementType, null);
else
Append(val.GetType(), val); //Append(ConvertToString(val.GetType(), val));
cnt++;
}
Builder.Insert(len, cnt.ToString(CultureInfo.CurrentCulture));
}
}
protected void Append(int value)
{
Builder.Append(' ').Append(value);
}
protected void Append(int? value)
{
Builder.Append(' ').Append(value.HasValue ? '1' : '0');
if (value.HasValue)
Builder.Append(value.Value);
}
protected void Append(Type value)
{
Builder.Append(' ').Append(value == null ? 0 : GetType(value));
}
protected void Append(bool value)
{
Builder.Append(' ').Append(value ? '1' : '0');
}
protected void Append(IQueryElement element)
{
Builder.Append(' ').Append(element == null ? 0 : Dic[element]);
}
protected void Append(string str)
{
Builder.Append(' ');
if (str == null)
{
Builder.Append('-');
}
else if (str.Length == 0)
{
Builder.Append('0');
}
else
{
Builder
.Append(str.Length)
.Append(':')
.Append(str);
}
}
protected int GetType(Type type)
{
if (type == null)
return 0;
int idx;
if (!Dic.TryGetValue(type, out idx))
{
if (type.IsArray)
{
var elementType = GetType(type.GetElementType());
Dic.Add(type, idx = ++Index);
Builder
.Append(idx)
.Append(' ')
.Append(TypeArrayIndex)
.Append(' ')
.Append(elementType);
}
else
{
Dic.Add(type, idx = ++Index);
Builder
.Append(idx)
.Append(' ')
.Append(TypeIndex);
Append(Configuration.LinqService.SerializeAssemblyQualifiedName ? type.AssemblyQualifiedName : type.FullName);
}
Builder.AppendLine();
}
return idx;
}
}
#endregion
#region DeserializerBase
public class DeserializerBase
{
protected readonly Dictionary<int,object> Dic = new Dictionary<int,object>();
protected string Str;
protected int Pos;
protected char Peek()
{
return Str[Pos];
}
char Next()
{
return Str[++Pos];
}
protected bool Get(char c)
{
if (Peek() == c)
{
Pos++;
return true;
}
return false;
}
protected int ReadInt()
{
Get(' ');
var minus = Get('-');
var value = 0;
for (var c = Peek(); char.IsDigit(c); c = Next())
value = value * 10 + ((int)c - '0');
return minus ? -value : value;
}
protected int? ReadNullableInt()
{
Get(' ');
if (Get('0'))
return null;
Get('1');
var minus = Get('-');
var value = 0;
for (var c = Peek(); char.IsDigit(c); c = Next())
value = value * 10 + ((int)c - '0');
return minus ? -value : value;
}
protected int? ReadCount()
{
Get(' ');
if (Get('-'))
return null;
var value = 0;
for (var c = Peek(); char.IsDigit(c); c = Next())
value = value * 10 + ((int)c - '0');
return value;
}
protected string ReadString()
{
Get(' ');
var c = Peek();
if (c == '-')
{
Pos++;
return null;
}
if (c == '0')
{
Pos++;
return string.Empty;
}
var len = ReadInt();
var value = Str.Substring(++Pos, len);
Pos += len;
return value;
}
protected bool ReadBool()
{
Get(' ');
var value = Peek() == '1';
Pos++;
return value;
}
protected T Read<T>()
where T : class
{
var idx = ReadInt();
return idx == 0 ? null : (T)Dic[idx];
}
protected Type ReadType()
{
var idx = ReadInt();
object type;
if (!Dic.TryGetValue(idx, out type))
{
Pos++;
var typecode = ReadInt();
Pos++;
switch (typecode)
{
case TypeIndex : type = ResolveType(ReadString()); break;
case TypeArrayIndex: type = GetArrayType(Read<Type>()); break;
default:
throw new SerializationException("TypeIndex or TypeArrayIndex ({0} or {1}) expected, but was {2}".Args(TypeIndex, TypeArrayIndex, typecode));
}
Dic.Add(idx, type);
NextLine();
var idx2 = ReadInt();
if (idx2 != idx)
throw new SerializationException("Wrong type reading, expected index is {0} but was {1}".Args(idx, idx2));
}
return (Type) type;
}
protected T[] ReadArray<T>()
where T : class
{
var count = ReadCount();
if (count == null)
return null;
var items = new T[count.Value];
for (var i = 0; i < count; i++)
items[i] = Read<T>();
return items;
}
protected List<T> ReadList<T>()
where T : class
{
var count = ReadCount();
if (count == null)
return null;
var items = new List<T>(count.Value);
for (var i = 0; i < count; i++)
items.Add(Read<T>());
return items;
}
protected void NextLine()
{
while (Pos < Str.Length && (Peek() == '\n' || Peek() == '\r'))
Pos++;
}
interface IDeserializerHelper
{
object GetArray(DeserializerBase deserializer);
}
class DeserializerHelper<T> : IDeserializerHelper
{
public object GetArray(DeserializerBase deserializer)
{
var count = deserializer.ReadCount();
if (count == null)
return null;
var arr = new T[count.Value];
for (var i = 0; i < count.Value; i++)
{
var elementType = deserializer.ReadType();
arr[i] = (T) deserializer.ReadValue(elementType);
}
return arr;
}
}
static readonly Dictionary<Type,Func<DeserializerBase,object>> _arrayDeserializers =
new Dictionary<Type,Func<DeserializerBase,object>>();
protected object ReadValue(Type type)
{
if (type == null)
return ReadString();
if (type.IsArray)
{
var elem = type.GetElementType();
Func<DeserializerBase,object> deserializer;
lock (_arrayDeserializers)
{
if (!_arrayDeserializers.TryGetValue(elem, out deserializer))
{
var helper = (IDeserializerHelper)Activator.CreateInstance(typeof(DeserializerHelper<>).MakeGenericType(elem));
_arrayDeserializers.Add(elem, deserializer = helper.GetArray);
}
}
return deserializer(this);
}
var str = ReadString();
if (str == null)
return null;
switch (type.GetTypeCodeEx())
{
case TypeCode.Decimal : return decimal. Parse(str, CultureInfo.InvariantCulture);
case TypeCode.Double : return double. Parse(str, CultureInfo.InvariantCulture);
case TypeCode.Single : return float. Parse(str, CultureInfo.InvariantCulture);
case TypeCode.DateTime : return DateTime.ParseExact(str, "o", CultureInfo.InvariantCulture);
}
if (type == typeof(DateTimeOffset))
return DateTimeOffset.ParseExact(str, "o", CultureInfo.InvariantCulture);
return Converter.ChangeType(str, type);
}
protected readonly List<string> UnresolvedTypes = new List<string>();
protected Type ResolveType(string str)
{
if (str == null)
return null;
var type = Type.GetType(str, false);
if (type == null)
{
if (str == "System.Data.Linq.Binary")
return typeof(System.Data.Linq.Binary);
#if !SILVERLIGHT && !NETFX_CORE
type = LinqService.TypeResolver(str);
#endif
if (type == null)
{
if (Configuration.LinqService.ThrowUnresolvedTypeException)
throw new LinqToDBException("Type '{0}' cannot be resolved. Use LinqService.TypeResolver to resolve unknown types.".Args(str));
UnresolvedTypes.Add(str);
Debug.WriteLine(
"Type '{0}' cannot be resolved. Use LinqService.TypeResolver to resolve unknown types.".Args(str),
"LinqServiceSerializer");
}
}
return type;
}
}
#endregion
#region QuerySerializer
class QuerySerializer : SerializerBase
{
public string Serialize(SelectQuery query, SqlParameter[] parameters, List<string> queryHints)
{
var queryHintCount = queryHints == null ? 0 : queryHints.Count;
Builder.AppendLine(queryHintCount.ToString());
if (queryHintCount > 0)
foreach (var hint in queryHints)
Builder.AppendLine(hint);
var visitor = new QueryVisitor();
visitor.Visit(query, Visit);
foreach (var parameter in parameters)
if (!Dic.ContainsKey(parameter))
Visit(parameter);
Builder
.Append(++Index)
.Append(' ')
.Append(ParamIndex);
Append(parameters.Length);
foreach (var parameter in parameters)
Append(parameter);
Builder.AppendLine();
return Builder.ToString();
}
void Visit(IQueryElement e)
{
switch (e.ElementType)
{
case QueryElementType.SqlField :
{
var fld = (SqlField)e;
if (fld != fld.Table.All)
GetType(fld.SystemType);
break;
}
case QueryElementType.SqlParameter :
{
var p = (SqlParameter)e;
var v = p.Value;
var t = v == null ? p.SystemType : v.GetType();
if (v == null || t.IsArray || t == typeof(string) || !(v is IEnumerable))
{
GetType(t);
}
else
{
var elemType = t.GetItemType();
GetType(GetArrayType(elemType));
}
break;
}
case QueryElementType.SqlFunction : GetType(((SqlFunction) e).SystemType); break;
case QueryElementType.SqlExpression : GetType(((SqlExpression) e).SystemType); break;
case QueryElementType.SqlBinaryExpression : GetType(((SqlBinaryExpression)e).SystemType); break;
case QueryElementType.SqlDataType : GetType(((SqlDataType) e).Type); break;
case QueryElementType.SqlValue : GetType(((SqlValue) e).SystemType); break;
case QueryElementType.SqlTable : GetType(((SqlTable) e).ObjectType); break;
}
Dic.Add(e, ++Index);
Builder
.Append(Index)
.Append(' ')
.Append((int)e.ElementType);
switch (e.ElementType)
{
case QueryElementType.SqlField :
{
var elem = (SqlField)e;
Append(elem.SystemType);
Append(elem.Name);
Append(elem.PhysicalName);
Append(elem.CanBeNull);
Append(elem.IsPrimaryKey);
Append(elem.PrimaryKeyOrder);
Append(elem.IsIdentity);
Append(elem.IsUpdatable);
Append(elem.IsInsertable);
Append((int)elem.DataType);
Append(elem.DbType);
Append(elem.Length);
Append(elem.Precision);
Append(elem.Scale);
Append(elem.CreateFormat);
break;
}
case QueryElementType.SqlFunction :
{
var elem = (SqlFunction)e;
Append(elem.SystemType);
Append(elem.Name);
Append(elem.IsAggregate);
Append(elem.Precedence);
Append(elem.Parameters);
break;
}
case QueryElementType.SqlParameter :
{
var elem = (SqlParameter)e;
Append(elem.Name);
Append(elem.IsQueryParameter);
Append((int)elem.DataType);
Append(elem.DbSize);
Append(elem.LikeStart);
Append(elem.LikeEnd);
Append(elem.ReplaceLike);
var value = elem.LikeStart != null ? elem.RawValue : elem.Value;
var type = value == null ? elem.SystemType : value.GetType();
if (value == null || type.IsArray || type == typeof(string) || !(value is IEnumerable))
{
Append(type, value);
}
else
{
var elemType = type.GetItemType();
value = ConvertIEnumerableToArray(value, elemType);
Append(GetArrayType(elemType), value);
}
break;
}
case QueryElementType.SqlExpression :
{
var elem = (SqlExpression)e;
Append(elem.SystemType);
Append(elem.Expr);
Append(elem.Precedence);
Append(elem.Parameters);
break;
}
case QueryElementType.SqlBinaryExpression :
{
var elem = (SqlBinaryExpression)e;
Append(elem.SystemType);
Append(elem.Expr1);
Append(elem.Operation);
Append(elem.Expr2);
Append(elem.Precedence);
break;
}
case QueryElementType.SqlValue :
{
var elem = (SqlValue)e;
Append(elem.SystemType, elem.Value);
break;
}
case QueryElementType.SqlDataType :
{
var elem = (SqlDataType)e;
Append((int)elem.DataType);
Append(elem.Type);
Append(elem.Length);
Append(elem.Precision);
Append(elem.Scale);
break;
}
case QueryElementType.SqlTable :
{
var elem = (SqlTable)e;
Append(elem.SourceID);
Append(elem.Name);
Append(elem.Alias);
Append(elem.Database);
Append(elem.Owner);
Append(elem.PhysicalName);
Append(elem.ObjectType);
if (elem.SequenceAttributes.IsNullOrEmpty())
Builder.Append(" -");
else
{
Append(elem.SequenceAttributes.Length);
foreach (var a in elem.SequenceAttributes)
{
Append(a.Configuration);
Append(a.SequenceName);
}
}
Append(Dic[elem.All]);
Append(elem.Fields.Count);
foreach (var field in elem.Fields)
Append(Dic[field.Value]);
Append((int)elem.SqlTableType);
if (elem.SqlTableType != SqlTableType.Table)
{
if (elem.TableArguments == null)
Append(0);
else
{
Append(elem.TableArguments.Length);
foreach (var expr in elem.TableArguments)
Append(Dic[expr]);
}
}
break;
}
case QueryElementType.ExprPredicate :
{
var elem = (SelectQuery.Predicate.Expr)e;
Append(elem.Expr1);
Append(elem.Precedence);
break;
}
case QueryElementType.NotExprPredicate :
{
var elem = (SelectQuery.Predicate.NotExpr)e;
Append(elem.Expr1);
Append(elem.IsNot);
Append(elem.Precedence);
break;
}
case QueryElementType.ExprExprPredicate :
{
var elem = (SelectQuery.Predicate.ExprExpr)e;
Append(elem.Expr1);
Append((int)elem.Operator);
Append(elem.Expr2);
break;
}
case QueryElementType.LikePredicate :
{
var elem = (SelectQuery.Predicate.Like)e;
Append(elem.Expr1);
Append(elem.IsNot);
Append(elem.Expr2);
Append(elem.Escape);
break;
}
case QueryElementType.BetweenPredicate :
{
var elem = (SelectQuery.Predicate.Between)e;
Append(elem.Expr1);
Append(elem.IsNot);
Append(elem.Expr2);
Append(elem.Expr3);
break;
}
case QueryElementType.IsNullPredicate :
{
var elem = (SelectQuery.Predicate.IsNull)e;
Append(elem.Expr1);
Append(elem.IsNot);
break;
}
case QueryElementType.InSubQueryPredicate :
{
var elem = (SelectQuery.Predicate.InSubQuery)e;
Append(elem.Expr1);
Append(elem.IsNot);
Append(elem.SubQuery);
break;
}
case QueryElementType.InListPredicate :
{
var elem = (SelectQuery.Predicate.InList)e;
Append(elem.Expr1);
Append(elem.IsNot);
Append(elem.Values);
break;
}
case QueryElementType.FuncLikePredicate :
{
var elem = (SelectQuery.Predicate.FuncLike)e;
Append(elem.Function);
break;
}
case QueryElementType.SqlQuery :
{
var elem = (SelectQuery)e;
Append(elem.SourceID);
Append((int)elem.QueryType);
Append(elem.From);
var appendInsert = false;
var appendUpdate = false;
var appendDelete = false;
var appendSelect = false;
var appendCreateTable = false;
switch (elem.QueryType)
{
case QueryType.InsertOrUpdate :
appendUpdate = true;
appendInsert = true;
break;
case QueryType.Update :
appendUpdate = true;
appendSelect = elem.Select.SkipValue != null || elem.Select.TakeValue != null;
break;
case QueryType.Delete :
appendDelete = true;
appendSelect = true;
break;
case QueryType.Insert :
appendInsert = true;
if (elem.From.Tables.Count != 0)
appendSelect = true;
break;
case QueryType.CreateTable :
appendCreateTable = true;
break;
default :
appendSelect = true;
break;
}
Append(appendInsert); if (appendInsert) Append(elem.Insert);
Append(appendUpdate); if (appendUpdate) Append(elem.Update);
Append(appendDelete); if (appendDelete) Append(elem.Delete);
Append(appendSelect); if (appendSelect) Append(elem.Select);
Append(appendCreateTable); if (appendCreateTable) Append(elem.CreateTable);
Append(elem.Where);
Append(elem.GroupBy);
Append(elem.Having);
Append(elem.OrderBy);
Append(elem.ParentSelect == null ? 0 : elem.ParentSelect.SourceID);
Append(elem.IsParameterDependent);
if (!elem.HasUnion)
Builder.Append(" -");
else
Append(elem.Unions);
Append(elem.Parameters);
if (Dic.ContainsKey(elem.All))
Append(Dic[elem.All]);
else
Builder.Append(" -");
break;
}
case QueryElementType.Column :
{
var elem = (SelectQuery.Column) e;
Append(elem.Parent.SourceID);
Append(elem.Expression);
Append(elem._alias);
break;
}
case QueryElementType.SearchCondition :
{
Append(((SelectQuery.SearchCondition)e).Conditions);
break;
}
case QueryElementType.Condition :
{
var elem = (SelectQuery.Condition)e;
Append(elem.IsNot);
Append(elem.Predicate);
Append(elem.IsOr);
break;
}
case QueryElementType.TableSource :
{
var elem = (SelectQuery.TableSource)e;
Append(elem.Source);
Append(elem._alias);
Append(elem.Joins);
break;
}
case QueryElementType.JoinedTable :
{
var elem = (SelectQuery.JoinedTable)e;
Append((int)elem.JoinType);
Append(elem.Table);
Append(elem.IsWeak);
Append(elem.Condition);
break;
}
case QueryElementType.SelectClause :
{
var elem = (SelectQuery.SelectClause)e;
Append(elem.IsDistinct);
Append(elem.SkipValue);
Append(elem.TakeValue);
Append(elem.Columns);
break;
}
case QueryElementType.InsertClause :
{
var elem = (SelectQuery.InsertClause)e;
Append(elem.Items);
Append(elem.Into);
Append(elem.WithIdentity);
break;
}
case QueryElementType.UpdateClause :
{
var elem = (SelectQuery.UpdateClause)e;
Append(elem.Items);
Append(elem.Keys);
Append(elem.Table);
break;
}
case QueryElementType.DeleteClause :
{
Append(((SelectQuery.DeleteClause)e).Table);
break;
}
case QueryElementType.SetExpression :
{
var elem = (SelectQuery.SetExpression)e;
Append(elem.Column);
Append(elem.Expression);
break;
}
case QueryElementType.CreateTableStatement :
{
var elem = (SelectQuery.CreateTableStatement)e;
Append(elem.Table);
Append(elem.IsDrop);
Append(elem.StatementHeader);
Append(elem.StatementFooter);
Append((int)elem.DefaulNullable);
break;
}
case QueryElementType.FromClause : Append(((SelectQuery.FromClause) e).Tables); break;
case QueryElementType.WhereClause : Append(((SelectQuery.WhereClause) e).SearchCondition); break;
case QueryElementType.GroupByClause : Append(((SelectQuery.GroupByClause)e).Items); break;
case QueryElementType.OrderByClause : Append(((SelectQuery.OrderByClause)e).Items); break;
case QueryElementType.OrderByItem :
{
var elem = (SelectQuery.OrderByItem)e;
Append(elem.Expression);
Append(elem.IsDescending);
break;
}
case QueryElementType.Union :
{
var elem = (SelectQuery.Union)e;
Append(elem.SelectQuery);
Append(elem.IsAll);
break;
}
}
Builder.AppendLine();
}
void Append<T>(ICollection<T> exprs)
where T : IQueryElement
{
if (exprs == null)
Builder.Append(" -");
else
{
Append(exprs.Count);
foreach (var e in exprs)
Append(Dic[e]);
}
}
}
#endregion
#region QueryDeserializer
public class QueryDeserializer : DeserializerBase
{
SelectQuery _query;
SqlParameter[] _parameters;
readonly Dictionary<int,SelectQuery> _queries = new Dictionary<int,SelectQuery>();
readonly List<Action> _actions = new List<Action>();
public LinqServiceQuery Deserialize(string str)
{
Str = str;
List<string> queryHints = null;
var queryHintCount = ReadInt();
NextLine();
if (queryHintCount > 0)
{
queryHints = new List<string>();
for (var i = 0; i < queryHintCount; i++)
{
var pos = Pos;
while (Pos < Str.Length && Peek() != '\n' && Peek() != '\r')
Pos++;
queryHints.Add(Str.Substring(pos, Pos - pos));
NextLine();
}
}
while (Parse()) {}
foreach (var action in _actions)
action();
return new LinqServiceQuery { Query = _query, Parameters = _parameters, QueryHints = queryHints };
}
bool Parse()
{
NextLine();
if (Pos >= Str.Length)
return false;
var obj = null as object;
var idx = ReadInt(); Pos++;
var type = ReadInt(); Pos++;
switch ((QueryElementType)type)
{
case (QueryElementType)ParamIndex : obj = _parameters = ReadArray<SqlParameter>(); break;
case (QueryElementType)TypeIndex : obj = ResolveType(ReadString()); break;
case (QueryElementType)TypeArrayIndex : obj = GetArrayType(Read<Type>()); break;
case QueryElementType.SqlField :
{
var systemType = Read<Type>();
var name = ReadString();
var physicalName = ReadString();
var nullable = ReadBool();
var isPrimaryKey = ReadBool();
var primaryKeyOrder = ReadInt();
var isIdentity = ReadBool();
var isUpdatable = ReadBool();
var isInsertable = ReadBool();
var dataType = ReadInt();
var dbType = ReadString();
var length = ReadNullableInt();
var precision = ReadNullableInt();
var scale = ReadNullableInt();
var createFormat = ReadString();
obj = new SqlField
{
SystemType = systemType,
Name = name,
PhysicalName = physicalName,
CanBeNull = nullable,
IsPrimaryKey = isPrimaryKey,
PrimaryKeyOrder = primaryKeyOrder,
IsIdentity = isIdentity,
IsInsertable = isInsertable,
IsUpdatable = isUpdatable,
DataType = (DataType)dataType,
DbType = dbType,
Length = length,
Precision = precision,
Scale = scale,
CreateFormat = createFormat,
};
break;
}
case QueryElementType.SqlFunction :
{
var systemType = Read<Type>();
var name = ReadString();
var isAggregate = ReadBool();
var precedence = ReadInt();
var parameters = ReadArray<ISqlExpression>();
obj = new SqlFunction(systemType, name, isAggregate, precedence, parameters);
break;
}
case QueryElementType.SqlParameter :
{
var name = ReadString();
var isQueryParameter = ReadBool();
var dbType = (DataType)ReadInt();
var dbSize = ReadInt();
var likeStart = ReadString();
var likeEnd = ReadString();
var replaceLike = ReadBool();
var systemType = Read<Type>();
var value = ReadValue(systemType);
obj = new SqlParameter(systemType, name, value)
{
IsQueryParameter = isQueryParameter,
DataType = dbType,
DbSize = dbSize,
LikeStart = likeStart,
LikeEnd = likeEnd,
ReplaceLike = replaceLike,
};
break;
}
case QueryElementType.SqlExpression :
{
var systemType = Read<Type>();
var expr = ReadString();
var precedence = ReadInt();
var parameters = ReadArray<ISqlExpression>();
obj = new SqlExpression(systemType, expr, precedence, parameters);
break;
}
case QueryElementType.SqlBinaryExpression :
{
var systemType = Read<Type>();
var expr1 = Read<ISqlExpression>();
var operation = ReadString();
var expr2 = Read<ISqlExpression>();
var precedence = ReadInt();
obj = new SqlBinaryExpression(systemType, expr1, operation, expr2, precedence);
break;
}
case QueryElementType.SqlValue :
{
var systemType = Read<Type>();
var value = ReadValue(systemType);
obj = new SqlValue(systemType, value);
break;
}
case QueryElementType.SqlDataType :
{
var dbType = (DataType)ReadInt();
var systemType = Read<Type>();
var length = ReadNullableInt();
var precision = ReadNullableInt();
var scale = ReadNullableInt();
obj = new SqlDataType(dbType, systemType, length, precision, scale);
break;
}
case QueryElementType.SqlTable :
{
var sourceID = ReadInt();
var name = ReadString();
var alias = ReadString();
var database = ReadString();
var owner = ReadString();
var physicalName = ReadString();
var objectType = Read<Type>();
var sequenceAttributes = null as SequenceNameAttribute[];
var count = ReadCount();
if (count != null)
{
sequenceAttributes = new SequenceNameAttribute[count.Value];
for (var i = 0; i < count.Value; i++)
sequenceAttributes[i] = new SequenceNameAttribute(ReadString(), ReadString());
}
var all = Read<SqlField>();
var fields = ReadArray<SqlField>();
var flds = new SqlField[fields.Length + 1];
flds[0] = all;
Array.Copy(fields, 0, flds, 1, fields.Length);
var sqlTableType = (SqlTableType)ReadInt();
var tableArgs = sqlTableType == SqlTableType.Table ? null : ReadArray<ISqlExpression>();
obj = new SqlTable(
sourceID, name, alias, database, owner, physicalName, objectType, sequenceAttributes, flds,
sqlTableType, tableArgs);
break;
}
case QueryElementType.ExprPredicate :
{
var expr1 = Read<ISqlExpression>();
var precedence = ReadInt();
obj = new SelectQuery.Predicate.Expr(expr1, precedence);
break;
}
case QueryElementType.NotExprPredicate :
{
var expr1 = Read<ISqlExpression>();
var isNot = ReadBool();
var precedence = ReadInt();
obj = new SelectQuery.Predicate.NotExpr(expr1, isNot, precedence);
break;
}
case QueryElementType.ExprExprPredicate :
{
var expr1 = Read<ISqlExpression>();
var @operator = (SelectQuery.Predicate.Operator)ReadInt();
var expr2 = Read<ISqlExpression>();
obj = new SelectQuery.Predicate.ExprExpr(expr1, @operator, expr2);
break;
}
case QueryElementType.LikePredicate :
{
var expr1 = Read<ISqlExpression>();
var isNot = ReadBool();
var expr2 = Read<ISqlExpression>();
var escape = Read<ISqlExpression>();
obj = new SelectQuery.Predicate.Like(expr1, isNot, expr2, escape);
break;
}
case QueryElementType.BetweenPredicate :
{
var expr1 = Read<ISqlExpression>();
var isNot = ReadBool();
var expr2 = Read<ISqlExpression>();
var expr3 = Read<ISqlExpression>();
obj = new SelectQuery.Predicate.Between(expr1, isNot, expr2, expr3);
break;
}
case QueryElementType.IsNullPredicate :
{
var expr1 = Read<ISqlExpression>();
var isNot = ReadBool();
obj = new SelectQuery.Predicate.IsNull(expr1, isNot);
break;
}
case QueryElementType.InSubQueryPredicate :
{
var expr1 = Read<ISqlExpression>();
var isNot = ReadBool();
var subQuery = Read<SelectQuery>();
obj = new SelectQuery.Predicate.InSubQuery(expr1, isNot, subQuery);
break;
}
case QueryElementType.InListPredicate :
{
var expr1 = Read<ISqlExpression>();
var isNot = ReadBool();
var values = ReadList<ISqlExpression>();
obj = new SelectQuery.Predicate.InList(expr1, isNot, values);
break;
}
case QueryElementType.FuncLikePredicate :
{
var func = Read<SqlFunction>();
obj = new SelectQuery.Predicate.FuncLike(func);
break;
}
case QueryElementType.SqlQuery :
{
var sid = ReadInt();
var queryType = (QueryType)ReadInt();
var from = Read<SelectQuery.FromClause>();
var readInsert = ReadBool();
var insert = readInsert ? Read<SelectQuery.InsertClause>() : null;
var readUpdate = ReadBool();
var update = readUpdate ? Read<SelectQuery.UpdateClause>() : null;
var readDelete = ReadBool();
var delete = readDelete ? Read<SelectQuery.DeleteClause>() : null;
var readSelect = ReadBool();
var select = readSelect ? Read<SelectQuery.SelectClause>() : new SelectQuery.SelectClause(null);
var readCreateTable = ReadBool();
var createTable = readCreateTable ?
Read<SelectQuery.CreateTableStatement>() :
new SelectQuery.CreateTableStatement();
var where = Read<SelectQuery.WhereClause>();
var groupBy = Read<SelectQuery.GroupByClause>();
var having = Read<SelectQuery.WhereClause>();
var orderBy = Read<SelectQuery.OrderByClause>();
var parentSql = ReadInt();
var parameterDependent = ReadBool();
var unions = ReadArray<SelectQuery.Union>();
var parameters = ReadArray<SqlParameter>();
var query = _query = new SelectQuery(sid) { QueryType = queryType };
query.Init(
insert,
update,
delete,
select,
from,
where,
groupBy,
having,
orderBy,
unions == null ? null : unions.ToList(),
null,
createTable,
parameterDependent,
parameters.ToList());
_queries.Add(sid, _query);
if (parentSql != 0)
_actions.Add(() =>
{
SelectQuery selectQuery;
if (_queries.TryGetValue(parentSql, out selectQuery))
query.ParentSelect = selectQuery;
});
query.All = Read<SqlField>();
obj = query;
break;
}
case QueryElementType.Column :
{
var sid = ReadInt();
var expression = Read<ISqlExpression>();
var alias = ReadString();
var col = new SelectQuery.Column(null, expression, alias);
_actions.Add(() => { col.Parent = _queries[sid]; return; });
obj = col;
break;
}
case QueryElementType.SearchCondition :
obj = new SelectQuery.SearchCondition(ReadArray<SelectQuery.Condition>());
break;
case QueryElementType.Condition :
obj = new SelectQuery.Condition(ReadBool(), Read<ISqlPredicate>(), ReadBool());
break;
case QueryElementType.TableSource :
{
var source = Read<ISqlTableSource>();
var alias = ReadString();
var joins = ReadArray<SelectQuery.JoinedTable>();
obj = new SelectQuery.TableSource(source, alias, joins);
break;
}
case QueryElementType.JoinedTable :
{
var joinType = (SelectQuery.JoinType)ReadInt();
var table = Read<SelectQuery.TableSource>();
var isWeak = ReadBool();
var condition = Read<SelectQuery.SearchCondition>();
obj = new SelectQuery.JoinedTable(joinType, table, isWeak, condition);
break;
}
case QueryElementType.SelectClause :
{
var isDistinct = ReadBool();
var skipValue = Read<ISqlExpression>();
var takeValue = Read<ISqlExpression>();
var columns = ReadArray<SelectQuery.Column>();
obj = new SelectQuery.SelectClause(isDistinct, takeValue, skipValue, columns);
break;
}
case QueryElementType.InsertClause :
{
var items = ReadArray<SelectQuery.SetExpression>();
var into = Read<SqlTable>();
var wid = ReadBool();
var c = new SelectQuery.InsertClause { Into = into, WithIdentity = wid };
c.Items.AddRange(items);
obj = c;
break;
}
case QueryElementType.UpdateClause :
{
var items = ReadArray<SelectQuery.SetExpression>();
var keys = ReadArray<SelectQuery.SetExpression>();
var table = Read<SqlTable>();
var c = new SelectQuery.UpdateClause { Table = table };
c.Items.AddRange(items);
c.Keys. AddRange(keys);
obj = c;
break;
}
case QueryElementType.DeleteClause :
{
var table = Read<SqlTable>();
obj = new SelectQuery.DeleteClause { Table = table };
break;
}
case QueryElementType.CreateTableStatement :
{
var table = Read<SqlTable>();
var isDrop = ReadBool();
var statementHeader = ReadString();
var statementFooter = ReadString();
var defaultNullable = (DefaulNullable)ReadInt();
obj = new SelectQuery.CreateTableStatement
{
Table = table,
IsDrop = isDrop,
StatementHeader = statementHeader,
StatementFooter = statementFooter,
DefaulNullable = defaultNullable,
};
break;
}
case QueryElementType.SetExpression : obj = new SelectQuery.SetExpression(Read <ISqlExpression>(), Read<ISqlExpression>()); break;
case QueryElementType.FromClause : obj = new SelectQuery.FromClause (ReadArray<SelectQuery.TableSource>()); break;
case QueryElementType.WhereClause : obj = new SelectQuery.WhereClause (Read <SelectQuery.SearchCondition>()); break;
case QueryElementType.GroupByClause : obj = new SelectQuery.GroupByClause(ReadArray<ISqlExpression>()); break;
case QueryElementType.OrderByClause : obj = new SelectQuery.OrderByClause(ReadArray<SelectQuery.OrderByItem>()); break;
case QueryElementType.OrderByItem :
{
var expression = Read<ISqlExpression>();
var isDescending = ReadBool();
obj = new SelectQuery.OrderByItem(expression, isDescending);
break;
}
case QueryElementType.Union :
{
var sqlQuery = Read<SelectQuery>();
var isAll = ReadBool();
obj = new SelectQuery.Union(sqlQuery, isAll);
break;
}
}
Dic.Add(idx, obj);
return true;
}
}
#endregion
#region ResultSerializer
class ResultSerializer : SerializerBase
{
public string Serialize(LinqServiceResult result)
{
Append(result.FieldCount);
Append(result.VaryingTypes.Length);
Append(result.RowCount);
Append(result.QueryID.ToString());
Builder.AppendLine();
foreach (var name in result.FieldNames)
{
Append(name);
Builder.AppendLine();
}
foreach (var type in result.FieldTypes)
{
Append(Configuration.LinqService.SerializeAssemblyQualifiedName ? type.AssemblyQualifiedName : type.FullName);
Builder.AppendLine();
}
foreach (var type in result.VaryingTypes)
{
Append(type.FullName);
Builder.AppendLine();
}
foreach (var data in result.Data)
{
foreach (var str in data)
{
if (result.VaryingTypes.Length > 0 && !string.IsNullOrEmpty(str) && str[0] == '\0')
{
Builder.Append('*');
Append((int)str[1]);
Append(str.Substring(2));
}
else
Append(str);
}
Builder.AppendLine();
}
return Builder.ToString();
}
}
#endregion
#region ResultDeserializer
class ResultDeserializer : DeserializerBase
{
public LinqServiceResult DeserializeResult(string str)
{
Str = str;
var fieldCount = ReadInt();
var varTypesLen = ReadInt();
var result = new LinqServiceResult
{
FieldCount = fieldCount,
RowCount = ReadInt(),
VaryingTypes = new Type[varTypesLen],
QueryID = new Guid(ReadString()),
FieldNames = new string[fieldCount],
FieldTypes = new Type [fieldCount],
Data = new List<string[]>(),
};
NextLine();
for (var i = 0; i < fieldCount; i++) { result.FieldNames [i] = ReadString(); NextLine(); }
for (var i = 0; i < fieldCount; i++) { result.FieldTypes [i] = ResolveType(ReadString()); NextLine(); }
for (var i = 0; i < varTypesLen; i++) { result.VaryingTypes[i] = ResolveType(ReadString()); NextLine(); }
for (var n = 0; n < result.RowCount; n++)
{
var data = new string[fieldCount];
for (var i = 0; i < fieldCount; i++)
{
if (varTypesLen > 0)
{
Get(' ');
if (Get('*'))
{
var idx = ReadInt();
data[i] = "\0" + (char)idx + ReadString();
}
else
data[i] = ReadString();
}
else
data[i] = ReadString();
}
result.Data.Add(data);
NextLine();
}
return result;
}
}
#endregion
#region StringArraySerializer
class StringArraySerializer : SerializerBase
{
public string Serialize(string[] data)
{
Append(data.Length);
foreach (var str in data)
Append(str);
Builder.AppendLine();
return Builder.ToString();
}
}
#endregion
#region StringArrayDeserializer
class StringArrayDeserializer : DeserializerBase
{
public string[] Deserialize(string str)
{
Str = str;
var data = new string[ReadInt()];
for (var i = 0; i < data.Length; i++)
data[i] = ReadString();
return data;
}
}
#endregion
#region Helpers
interface IArrayHelper
{
Type GetArrayType();
object ConvertToArray(object list);
}
class ArrayHelper<T> : IArrayHelper
{
public Type GetArrayType()
{
return typeof(T[]);
}
public object ConvertToArray(object list)
{
return ((IEnumerable<T>)list).ToArray();
}
}
static readonly Dictionary<Type,Type> _arrayTypes = new Dictionary<Type,Type>();
static readonly Dictionary<Type,Func<object,object>> _arrayConverters = new Dictionary<Type,Func<object,object>>();
static Type GetArrayType(Type elementType)
{
Type arrayType;
lock (_arrayTypes)
{
if (!_arrayTypes.TryGetValue(elementType, out arrayType))
{
var helper = (IArrayHelper)Activator.CreateInstance(typeof(ArrayHelper<>).MakeGenericType(elementType));
_arrayTypes.Add(elementType, arrayType = helper.GetArrayType());
}
}
return arrayType;
}
static object ConvertIEnumerableToArray(object list, Type elementType)
{
Func<object,object> converter;
lock (_arrayConverters)
{
if (!_arrayConverters.TryGetValue(elementType, out converter))
{
var helper = (IArrayHelper)Activator.CreateInstance(typeof(ArrayHelper<>).MakeGenericType(elementType));
_arrayConverters.Add(elementType, converter = helper.ConvertToArray);
}
}
return converter(list);
}
#endregion
}
}
| lvaleriu/linq2db | Source/ServiceModel/LinqServiceSerializer.cs | C# | mit | 45,280 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
2478,
2291,
1012,
16474,
2015,
1025,
2478,
2291,
1012,
24370,
1025,
2478,
2291,
1012,
11409,
4160,
1025,
2478,
2291,
1012,
2448,
7292,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#!/usr/bin/env bash
# Copyright 2015, Rackspace US, Inc.
# Copyright 2017, SUSE LINUX GmbH.
#
# 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.
# This script was created to rapidly interate through a repo_package file
# that contains git sources and set the various repositories inside to
# the head of given branch via the SHA. This makes it possible to update
# all of the services that we support in an "automated" fashion.
OS_BRANCH=${OS_BRANCH:-"master"}
OSA_BRANCH=${OSA_BRANCH:-"$OS_BRANCH"}
SERVICE_FILE=${SERVICE_FILE:-"playbooks/defaults/repo_packages/openstack_services.yml"}
OPENSTACK_SERVICE_LIST=${OPENSTACK_SERVICE_LIST:-"$(grep 'git_repo\:' ${SERVICE_FILE} | awk -F '/' '{ print $NF }' | egrep -v 'requirements|-' | tr '\n' ' ')"}
PRE_RELEASE=${PRE_RELEASE:-"false"}
FORCE_MASTER=${FORCE_MASTER:-"false"}
source scripts/sources-branch-updater-lib.sh || { echo "Failed to source updater library"; exit 1; }
if echo "$@" | grep -e '-h' -e '--help';then
echo "
Options:
-b|--openstack-branch (name of OpenStack branch, eg: stable/newton)
-o|--osa-branch (name of the OSA branch, eg: stable/newton)
-s|--service-file (path to service file to parse)
"
exit 0
fi
# Provide some CLI options
while [[ $# > 1 ]]; do
key="$1"
case $key in
-b|--openstack-branch)
OS_BRANCH="$2"
shift
;;
-o|--osa-branch)
OSA_BRANCH="$2"
shift
;;
-s|--service-file)
SERVICE_FILE="$2"
shift
;;
*)
;;
esac
shift
done
commit_changes() {
local repo_name="${1}"
local osa_repo_tmp_path="/tmp/osa_${repo_name}"
# Switch into the OSA git directory to work with it
pushd ${osa_repo_tmp_path} > /dev/null
# Check for changed files
git_changed=$(git status --porcelain | wc -l)
# Check for untracked files
git_untracked=$(git ls-files --other --exclude-standard --directory | wc -l)
if [ ${git_untracked} -gt 0 ]; then
# If there are untracked files, ensure that the commit message includes
# a WIP prefix so that the patch is revised in more detail.
git_msg_prefix="[New files - needs update] "
else
git_msg_prefix=""
fi
# If any files have changed, submit a patch including the changes
if [ ${git_changed} -gt 0 ]; then
git checkout -b sha-update
git review -s > /dev/null
git add --all
git commit -a -m "${git_msg_prefix}Update paste, policy and rootwrap configurations $(date +%Y-%m-%d)" --quiet
git review > /dev/null
fi
popd > /dev/null
}
osa_post_sync_hook() { commit_changes "$@"; }
sync_roles_and_packages ${OS_BRANCH} ${OSA_BRANCH} ${SERVICE_FILE} ${OPENSTACK_SERVICE_LIST}
update_pip_options
update_ansible_role_requirements ${OSA_BRANCH} ${PRE_RELEASE} ${FORCE_MASTER}
update_release_version ${OSA_BRANCH} ${SERVICE_FILE}
| cloudnull/os-ansible-deployment | scripts/sources-branch-updater.sh | Shell | apache-2.0 | 3,261 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
4372,
2615,
24234,
1001,
9385,
2325,
1010,
27259,
15327,
2149,
1010,
4297,
1012,
1001,
9385,
2418,
1010,
10514,
3366,
11603,
18289,
1012,
1001,
1001,
7000,
2104,
1996,
15895,
6105,
1010,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
"""add graphql ACL to users
Revision ID: 2d4882d39dbb
Revises: c4d0e9ec46a9
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '2d4882d39dbb'
down_revision = 'dc2848563b53'
POLICY_NAME = 'wazo_default_user_policy'
ACL_TEMPLATES = ['dird.graphql.me']
policy_table = sa.sql.table(
'auth_policy', sa.Column('uuid', sa.String(38)), sa.Column('name', sa.String(80))
)
acl_template_table = sa.sql.table(
'auth_acl_template', sa.Column('id', sa.Integer), sa.Column('template', sa.Text)
)
policy_template = sa.sql.table(
'auth_policy_template',
sa.Column('policy_uuid', sa.String(38)),
sa.Column('template_id', sa.Integer),
)
def _find_acl_template(conn, acl_template):
query = (
sa.sql.select([acl_template_table.c.id])
.where(acl_template_table.c.template == acl_template)
.limit(1)
)
return conn.execute(query).scalar()
def _find_acl_templates(conn, acl_templates):
acl_template_ids = []
for acl_template in acl_templates:
acl_template_id = _find_acl_template(conn, acl_template)
if acl_template_id:
acl_template_ids.append(acl_template_id)
return acl_template_ids
def _get_policy_uuid(conn, policy_name):
policy_query = sa.sql.select([policy_table.c.uuid]).where(
policy_table.c.name == policy_name
)
for policy in conn.execute(policy_query).fetchall():
return policy[0]
def _insert_acl_template(conn, acl_templates):
acl_template_ids = []
for acl_template in acl_templates:
acl_template_id = _find_acl_template(conn, acl_template)
if not acl_template_id:
query = (
acl_template_table.insert()
.returning(acl_template_table.c.id)
.values(template=acl_template)
)
acl_template_id = conn.execute(query).scalar()
acl_template_ids.append(acl_template_id)
return acl_template_ids
def _get_acl_template_ids(conn, policy_uuid):
query = sa.sql.select([policy_template.c.template_id]).where(
policy_template.c.policy_uuid == policy_uuid
)
return [acl_template_id for (acl_template_id,) in conn.execute(query).fetchall()]
def upgrade():
conn = op.get_bind()
policy_uuid = _get_policy_uuid(conn, POLICY_NAME)
if not policy_uuid:
return
acl_template_ids = _insert_acl_template(conn, ACL_TEMPLATES)
acl_template_ids_already_associated = _get_acl_template_ids(conn, policy_uuid)
for template_id in set(acl_template_ids) - set(acl_template_ids_already_associated):
query = policy_template.insert().values(
policy_uuid=policy_uuid, template_id=template_id
)
conn.execute(query)
def downgrade():
conn = op.get_bind()
acl_template_ids = _find_acl_templates(conn, ACL_TEMPLATES)
if not acl_template_ids:
return
policy_uuid = _get_policy_uuid(conn, POLICY_NAME)
if not policy_uuid:
return
delete_query = policy_template.delete().where(
sa.sql.and_(
policy_template.c.policy_uuid == policy_uuid,
policy_template.c.template_id.in_(acl_template_ids),
)
)
op.execute(delete_query)
| wazo-pbx/xivo-auth | alembic/versions/2d4882d39dbb_add_graphql_acl_to_users.py | Python | gpl-3.0 | 3,250 | [
30522,
1000,
1000,
1000,
5587,
10629,
4160,
2140,
9353,
2140,
2000,
5198,
13921,
8909,
1024,
14134,
18139,
2620,
2475,
2094,
23499,
18939,
2497,
7065,
13087,
1024,
1039,
2549,
2094,
2692,
2063,
2683,
8586,
30524,
13921,
1027,
1005,
14134,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
def template(from, to)
tmpl = File.read(File.expand_path("../templates/#{from}", __FILE__))
erb = ERB.new(tmpl).result(binding)
execute :touch, "#{to}"
upload! StringIO.new(erb), to
end
| parasquid/capistrano-devops | lib/capistrano/devops/base.rb | Ruby | mit | 194 | [
30522,
13366,
23561,
1006,
2013,
1010,
2000,
1007,
1056,
8737,
2140,
1027,
5371,
1012,
3191,
1006,
5371,
1012,
7818,
1035,
4130,
1006,
1000,
1012,
1012,
1013,
23561,
2015,
1013,
1001,
1063,
2013,
1065,
1000,
1010,
1035,
1035,
5371,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int_memmove_64b.c
Label Definition File: CWE122_Heap_Based_Buffer_Overflow__c_CWE805.label.xml
Template File: sources-sink-64b.tmpl.c
*/
/*
* @description
* CWE: 122 Heap Based Buffer Overflow
* BadSource: Allocate using malloc() and set data pointer to a small buffer
* GoodSource: Allocate using malloc() and set data pointer to a large buffer
* Sinks: memmove
* BadSink : Copy int array to data using memmove
* Flow Variant: 64 Data flow: void pointer to data passed from one function to another in different source files
*
* */
#include "std_testcase.h"
#ifndef OMITBAD
void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int_memmove_64b_badSink(void * dataVoidPtr)
{
/* cast void pointer to a pointer of the appropriate type */
int * * dataPtr = (int * *)dataVoidPtr;
/* dereference dataPtr into data */
int * data = (*dataPtr);
{
int source[100] = {0}; /* fill with 0's */
/* POTENTIAL FLAW: Possible buffer overflow if data < 100 */
memmove(data, source, 100*sizeof(int));
printIntLine(data[0]);
free(data);
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int_memmove_64b_goodG2BSink(void * dataVoidPtr)
{
/* cast void pointer to a pointer of the appropriate type */
int * * dataPtr = (int * *)dataVoidPtr;
/* dereference dataPtr into data */
int * data = (*dataPtr);
{
int source[100] = {0}; /* fill with 0's */
/* POTENTIAL FLAW: Possible buffer overflow if data < 100 */
memmove(data, source, 100*sizeof(int));
printIntLine(data[0]);
free(data);
}
}
#endif /* OMITGOOD */
| JianpingZeng/xcc | xcc/test/juliet/testcases/CWE122_Heap_Based_Buffer_Overflow/s08/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int_memmove_64b.c | C | bsd-3-clause | 1,867 | [
30522,
1013,
1008,
23561,
7013,
3231,
18382,
5371,
5371,
18442,
1024,
19296,
2063,
12521,
2475,
1035,
16721,
1035,
2241,
1035,
17698,
1035,
2058,
12314,
1035,
1035,
1039,
1035,
19296,
2063,
17914,
2629,
1035,
20014,
1035,
2033,
7382,
21818,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// (C) Copyright 2009-2011 Frederic Bron.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/type_traits/has_operator.hpp>
#include "test.hpp"
#include "check_integral_constant.hpp"
#include "has_binary_classes.hpp"
TT_TEST_BEGIN(BOOST_TT_TRAIT_NAME)
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000, C000, void >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000, C000 const, void >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000, C000 const, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000, C000 const, ret const & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000, C000 const &, void >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000 const, C000, ret const & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000 const, C000 const, void >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000 const, C000 const, ret >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000 const, C000 const, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000 const, C000 &, ret const & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000 &, C000, void >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000 &, C000, ret >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000 &, C000, ret const >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000 &, C000 const, ret >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000 &, C000 const &, ret >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000 &, C000 const &, ret const & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000 const &, C000, ret >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000 const &, C000 const, void >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000 const &, C000 const, ret const >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000 const &, C000 &, ret >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C000 const &, C000 &, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001, C001, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001, C001 const, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001, C001 const, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001, C001 &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 const, C001 &, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 const, C001 &, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 const, C001 const &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 const, C001 const &, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 const, C001 const &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 &, C001, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 &, C001, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 &, C001, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 &, C001, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 &, C001 const, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 &, C001 &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 &, C001 &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 &, C001 const &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 const &, C001, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 const &, C001 const, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 const &, C001 const, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 const &, C001 const, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 const &, C001 &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 const &, C001 &, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 const &, C001 &, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 const &, C001 &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 const &, C001 const &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 const &, C001 const &, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C001 const &, C001 const &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002, C002, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002, C002 const, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002, C002 const, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002, C002 const, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002, C002 &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002, C002 &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002, C002 const &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002, C002 const &, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002, C002 const &, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 const, C002, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 const, C002 &, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 const, C002 &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 const, C002 const &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 const, C002 const &, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 const, C002 const &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 &, C002, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 &, C002, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 &, C002, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 &, C002, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 &, C002 const, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 &, C002 &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 &, C002 &, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 &, C002 const &, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 &, C002 const &, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 &, C002 const &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 const &, C002, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 const &, C002, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 const &, C002, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 const &, C002 const, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 const &, C002 const, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 const &, C002 const, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 const &, C002 const, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 const &, C002 &, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 const &, C002 &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C002 const &, C002 const &, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005, C005, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005, C005, ret & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005, C005, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005, C005 const, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005, C005 const, ret & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005, C005 &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005, C005 &, ret & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005, C005 const &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005, C005 const &, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005, C005 const &, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005, C005 const &, ret & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 const, C005, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 const, C005, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 const, C005 const, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 const, C005 &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 const, C005 const &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 const, C005 const &, ret & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 &, C005, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 &, C005, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 &, C005, ret & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 &, C005, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 &, C005 const, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 &, C005 const, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 &, C005 &, ret & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 &, C005 &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 const &, C005 const, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 const &, C005 const, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 const &, C005 const, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 const &, C005 const, ret & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 const &, C005 const, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 const &, C005 &, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 const &, C005 &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 const &, C005 const &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 const &, C005 const &, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C005 const &, C005 const &, ret & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006, C006, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006, C006 const, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006, C006 &, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 const, C006, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 const, C006, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 const, C006, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 const, C006 const, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 const, C006 &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 const, C006 &, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 const, C006 const &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 const, C006 const &, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 const, C006 const &, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 &, C006, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 &, C006, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 &, C006, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 &, C006 const, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 &, C006 const, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 &, C006 &, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 &, C006 const &, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 const &, C006, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 const &, C006 const, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 const &, C006 &, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 const &, C006 &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 const &, C006 const &, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C006 const &, C006 const &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009, C009, void >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009, C009, ret const & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009, C009 const, void >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009, C009 const, ret const >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009, C009 const, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009, C009 &, ret const >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009, C009 const &, void >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 const, C009, ret const & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 const, C009 const, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 const, C009 &, void >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 const, C009 &, ret >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 const, C009 &, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 const, C009 const &, ret >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 const, C009 const &, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 &, C009, void >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 &, C009, ret >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 &, C009, ret const & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 &, C009 const, ret const & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 &, C009 &, ret const >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 &, C009 const &, ret >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 &, C009 const &, ret const >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 &, C009 const &, ret const & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 const &, C009 const, void >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 const &, C009 &, void >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 const &, C009 &, ret const >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 const &, C009 &, ret const & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 const &, C009 const &, ret >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 const &, C009 const &, ret const >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 const &, C009 const &, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C009 const &, C009 const &, ret const & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010, C010, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010, C010 const, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010, C010 const, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010, C010 const, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010, C010 &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010, C010 &, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010, C010 const &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010, C010 const &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 const, C010, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 const, C010, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 const, C010, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 const, C010, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 const, C010 const, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 const, C010 const, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 const, C010 const &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 &, C010, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 &, C010, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 &, C010 const, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 &, C010 const &, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 &, C010 const &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 const &, C010, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 const &, C010, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 const &, C010 const, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 const &, C010 &, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 const &, C010 &, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 const &, C010 &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C010 const &, C010 const &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011, C011, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011, C011, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011, C011, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011, C011 const, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011, C011 const, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011, C011 &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011, C011 &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011, C011 const &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011, C011 const &, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011, C011 const &, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011, C011 const &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 const, C011, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 const, C011, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 const, C011, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 const, C011 const, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 const, C011 const, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 const, C011 &, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 const, C011 &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 const, C011 const &, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 const, C011 const &, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 &, C011, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 &, C011, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 &, C011, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 &, C011 const, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 &, C011 const, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 &, C011 &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 &, C011 &, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 &, C011 &, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 &, C011 const &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 &, C011 const &, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 &, C011 const &, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 const &, C011, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 const &, C011, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 const &, C011 const, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 const &, C011 const, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 const &, C011 &, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 const &, C011 &, ret & >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 const &, C011 &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C011 const &, C011 const &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C014, C014, ret >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C014, C014, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C014, C014 const, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C014, C014 const, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C014, C014 &, void >::value), 0);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C014, C014 &, ret const >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C014, C014 &, ret & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C014, C014 &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C014, C014 const &, ret const & >::value), 1);
BOOST_CHECK_INTEGRAL_CONSTANT((::boost::has_plus< C014 const, C014, ret const >::value), 1);
TT_TEST_END
| davehorton/drachtio-server | deps/boost_1_77_0/libs/type_traits/test/has_binary_classes0_test.cpp | C++ | mit | 24,220 | [
30522,
1013,
1013,
1006,
1039,
1007,
9385,
2268,
1011,
2249,
15296,
22953,
2078,
1012,
1013,
1013,
2224,
1010,
14080,
1998,
4353,
2024,
3395,
2000,
1996,
1013,
1013,
12992,
4007,
6105,
1010,
2544,
1015,
1012,
1014,
1012,
1006,
2156,
10860,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using MilkShakeFramework.Core.Scenes;
using MilkShakeFramework.Core.Game.Components.Misc;
namespace MilkShakeFramework.Tools.Utils
{
public class Wait
{
public Wait(float delay, BasicEvent callBack)
{
EventTimer eventTimer = new EventTimer(delay);
eventTimer.AddEvent(100, () =>
{
callBack();
SceneManager.CurrentScene.RemoveNode(eventTimer);
});
SceneManager.CurrentScene.AddNode(eventTimer);
}
}
}
| lucas-jones/MilkShake-old | MilkShake/Tools/Utils/Wait.cs | C# | gpl-3.0 | 535 | [
30522,
2478,
6501,
7377,
3489,
15643,
6198,
1012,
4563,
1012,
5019,
1025,
2478,
6501,
7377,
3489,
15643,
6198,
1012,
4563,
1012,
2208,
1012,
6177,
1012,
28616,
2278,
1025,
3415,
15327,
6501,
7377,
3489,
15643,
6198,
1012,
5906,
1012,
21183,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import { run } from '@ember/runloop';
import { merge } from '@ember/polyfills';
import Application from '../../app';
import config from '../../config/environment';
export default function startApp(attrs) {
let application;
let attributes = merge({}, config.APP);
attributes = merge(attributes, attrs); // use defaults, but you can override;
run(() => {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
});
return application;
}
| bustlelabs/ember-mobiledoc-dom-renderer | tests/helpers/start-app.js | JavaScript | mit | 517 | [
30522,
12324,
1063,
2448,
1065,
2013,
1005,
1030,
7861,
5677,
1013,
2448,
4135,
7361,
1005,
1025,
12324,
1063,
13590,
1065,
2013,
1005,
1030,
7861,
5677,
1013,
26572,
8873,
12718,
1005,
1025,
12324,
4646,
2013,
1005,
1012,
1012,
1013,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
// Copyright (C) 2009-2012, International Business Machines
// Corporation and others. All Rights Reserved.
//
// Copyright 2007 Google Inc. All Rights Reserved.
// Author: sanjay@google.com (Sanjay Ghemawat)
//
// Abstract interface that consumes a sequence of bytes (ByteSink).
//
// Used so that we can write a single piece of code that can operate
// on a variety of output string types.
//
// Various implementations of this interface are provided:
// ByteSink:
// CheckedArrayByteSink Write to a flat array, with bounds checking
// StringByteSink Write to an STL string
// This code is a contribution of Google code, and the style used here is
// a compromise between the original Google code and the ICU coding guidelines.
// For example, data types are ICU-ified (size_t,int->int32_t),
// and API comments doxygen-ified, but function names and behavior are
// as in the original, if possible.
// Assertion-style error handling, not available in ICU, was changed to
// parameter "pinning" similar to UnicodeString.
//
// In addition, this is only a partial port of the original Google code,
// limited to what was needed so far. The (nearly) complete original code
// is in the ICU svn repository at icuhtml/trunk/design/strings/contrib
// (see ICU ticket 6765, r25517).
#ifndef __BYTESTREAM_H__
#define __BYTESTREAM_H__
/**
* \file
* \brief C++ API: Interface for writing bytes, and implementation classes.
*/
#include "unicode/utypes.h"
#include "unicode/uobject.h"
#include "unicode/std_string.h"
U_NAMESPACE_BEGIN
/**
* A ByteSink can be filled with bytes.
* @stable ICU 4.2
*/
class U_COMMON_API ByteSink : public UMemory {
public:
/**
* Default constructor.
* @stable ICU 4.2
*/
ByteSink() { }
/**
* Virtual destructor.
* @stable ICU 4.2
*/
virtual ~ByteSink();
/**
* Append "bytes[0,n-1]" to this.
* @param bytes the pointer to the bytes
* @param n the number of bytes; must be non-negative
* @stable ICU 4.2
*/
virtual void Append(const char* bytes, int32_t n) = 0;
/**
* Returns a writable buffer for appending and writes the buffer's capacity to
* *result_capacity. Guarantees *result_capacity>=min_capacity.
* May return a pointer to the caller-owned scratch buffer which must have
* scratch_capacity>=min_capacity.
* The returned buffer is only valid until the next operation
* on this ByteSink.
*
* After writing at most *result_capacity bytes, call Append() with the
* pointer returned from this function and the number of bytes written.
* Many Append() implementations will avoid copying bytes if this function
* returned an internal buffer.
*
* Partial usage example:
* int32_t capacity;
* char* buffer = sink->GetAppendBuffer(..., &capacity);
* ... Write n bytes into buffer, with n <= capacity.
* sink->Append(buffer, n);
* In many implementations, that call to Append will avoid copying bytes.
*
* If the ByteSink allocates or reallocates an internal buffer, it should use
* the desired_capacity_hint if appropriate.
* If a caller cannot provide a reasonable guess at the desired capacity,
* it should pass desired_capacity_hint=0.
*
* If a non-scratch buffer is returned, the caller may only pass
* a prefix to it to Append().
* That is, it is not correct to pass an interior pointer to Append().
*
* The default implementation always returns the scratch buffer.
*
* @param min_capacity required minimum capacity of the returned buffer;
* must be non-negative
* @param desired_capacity_hint desired capacity of the returned buffer;
* must be non-negative
* @param scratch default caller-owned buffer
* @param scratch_capacity capacity of the scratch buffer
* @param result_capacity pointer to an integer which will be set to the
* capacity of the returned buffer
* @return a buffer with *result_capacity>=min_capacity
* @stable ICU 4.2
*/
virtual char* GetAppendBuffer(int32_t min_capacity,
int32_t desired_capacity_hint,
char* scratch, int32_t scratch_capacity,
int32_t* result_capacity);
/**
* Flush internal buffers.
* Some byte sinks use internal buffers or provide buffering
* and require calling Flush() at the end of the stream.
* The ByteSink should be ready for further Append() calls after Flush().
* The default implementation of Flush() does nothing.
* @stable ICU 4.2
*/
virtual void Flush();
private:
ByteSink(const ByteSink &) = delete;
ByteSink &operator=(const ByteSink &) = delete;
};
// -------------------------------------------------------------
// Some standard implementations
/**
* Implementation of ByteSink that writes to a flat byte array,
* with bounds-checking:
* This sink will not write more than capacity bytes to outbuf.
* If more than capacity bytes are Append()ed, then excess bytes are ignored,
* and Overflowed() will return true.
* Overflow does not cause a runtime error.
* @stable ICU 4.2
*/
class U_COMMON_API CheckedArrayByteSink : public ByteSink {
public:
/**
* Constructs a ByteSink that will write to outbuf[0..capacity-1].
* @param outbuf buffer to write to
* @param capacity size of the buffer
* @stable ICU 4.2
*/
CheckedArrayByteSink(char* outbuf, int32_t capacity);
/**
* Destructor.
* @stable ICU 4.2
*/
virtual ~CheckedArrayByteSink();
/**
* Returns the sink to its original state, without modifying the buffer.
* Useful for reusing both the buffer and the sink for multiple streams.
* Resets the state to NumberOfBytesWritten()=NumberOfBytesAppended()=0
* and Overflowed()=FALSE.
* @return *this
* @stable ICU 4.6
*/
virtual CheckedArrayByteSink& Reset();
/**
* Append "bytes[0,n-1]" to this.
* @param bytes the pointer to the bytes
* @param n the number of bytes; must be non-negative
* @stable ICU 4.2
*/
virtual void Append(const char* bytes, int32_t n);
/**
* Returns a writable buffer for appending and writes the buffer's capacity to
* *result_capacity. For details see the base class documentation.
* @param min_capacity required minimum capacity of the returned buffer;
* must be non-negative
* @param desired_capacity_hint desired capacity of the returned buffer;
* must be non-negative
* @param scratch default caller-owned buffer
* @param scratch_capacity capacity of the scratch buffer
* @param result_capacity pointer to an integer which will be set to the
* capacity of the returned buffer
* @return a buffer with *result_capacity>=min_capacity
* @stable ICU 4.2
*/
virtual char* GetAppendBuffer(int32_t min_capacity,
int32_t desired_capacity_hint,
char* scratch, int32_t scratch_capacity,
int32_t* result_capacity);
/**
* Returns the number of bytes actually written to the sink.
* @return number of bytes written to the buffer
* @stable ICU 4.2
*/
int32_t NumberOfBytesWritten() const { return size_; }
/**
* Returns true if any bytes were discarded, i.e., if there was an
* attempt to write more than 'capacity' bytes.
* @return TRUE if more than 'capacity' bytes were Append()ed
* @stable ICU 4.2
*/
UBool Overflowed() const { return overflowed_; }
/**
* Returns the number of bytes appended to the sink.
* If Overflowed() then NumberOfBytesAppended()>NumberOfBytesWritten()
* else they return the same number.
* @return number of bytes written to the buffer
* @stable ICU 4.6
*/
int32_t NumberOfBytesAppended() const { return appended_; }
private:
char* outbuf_;
const int32_t capacity_;
int32_t size_;
int32_t appended_;
UBool overflowed_;
CheckedArrayByteSink() = delete;
CheckedArrayByteSink(const CheckedArrayByteSink &) = delete;
CheckedArrayByteSink &operator=(const CheckedArrayByteSink &) = delete;
};
/**
* Implementation of ByteSink that writes to a "string".
* The StringClass is usually instantiated with a std::string.
* @stable ICU 4.2
*/
template<typename StringClass>
class StringByteSink : public ByteSink {
public:
/**
* Constructs a ByteSink that will append bytes to the dest string.
* @param dest pointer to string object to append to
* @stable ICU 4.2
*/
StringByteSink(StringClass* dest) : dest_(dest) { }
/**
* Constructs a ByteSink that reserves append capacity and will append bytes to the dest string.
*
* @param dest pointer to string object to append to
* @param initialAppendCapacity capacity beyond dest->length() to be reserve()d
* @stable ICU 60
*/
StringByteSink(StringClass* dest, int32_t initialAppendCapacity) : dest_(dest) {
if (initialAppendCapacity > 0 &&
(uint32_t)initialAppendCapacity > (dest->capacity() - dest->length())) {
dest->reserve(dest->length() + initialAppendCapacity);
}
}
/**
* Append "bytes[0,n-1]" to this.
* @param data the pointer to the bytes
* @param n the number of bytes; must be non-negative
* @stable ICU 4.2
*/
virtual void Append(const char* data, int32_t n) { dest_->append(data, n); }
private:
StringClass* dest_;
StringByteSink() = delete;
StringByteSink(const StringByteSink &) = delete;
StringByteSink &operator=(const StringByteSink &) = delete;
};
U_NAMESPACE_END
#endif // __BYTESTREAM_H__
| kumakoko/KumaGL | third_lib/icu4c/64.2/include/unicode/bytestream.h | C | mit | 9,767 | [
30522,
1013,
1013,
1075,
2355,
1998,
2101,
1024,
27260,
1010,
4297,
1012,
1998,
2500,
1012,
1013,
1013,
6105,
1004,
3408,
1997,
2224,
1024,
8299,
1024,
1013,
1013,
7479,
1012,
27260,
1012,
8917,
1013,
9385,
1012,
16129,
1013,
1013,
9385,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>18 --> 19</title>
<link href="./../../assets/style.css" rel="stylesheet">
</head>
<body>
<h2>You have to be fast</h2>
<a href="./bb164817dd2439b6c4fe52ce4b83e0c7310e711db01747678e05eeb9f2c43487.html">Teleport</a>
<hr>
<a href="./../../about.md">About</a> (Spoilers! )
<script src="./../../assets/md5.js"></script>
<script>
window.currentLevel = 7;
</script>
<script src="./../../assets/script.js"></script>
</body>
</html> | simonmysun/praxis | TAIHAO2019/pub/SmallGame/AsFastAsYouCan2/5714502d519026472035500c2bece0503b7a7fd442ad313e088fa4f5a0a1ff3c.html | HTML | mit | 550 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
2516,
1028,
2324,
1011,
1011,
1028,
2539,
1026... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
function generateArray(table) {
var out = [];
var rows = table.querySelectorAll('tr');
var ranges = [];
for (var R = 0; R < rows.length; ++R) {
var outRow = [];
var row = rows[R];
var columns = row.querySelectorAll('td');
for (var C = 0; C < columns.length; ++C) {
var cell = columns[C];
var colspan = cell.getAttribute('colspan');
var rowspan = cell.getAttribute('rowspan');
var cellValue = cell.innerText;
if(cellValue !== "" && cellValue == +cellValue) cellValue = +cellValue;
//Skip ranges
ranges.forEach(function(range) {
if(R >= range.s.r && R <= range.e.r && outRow.length >= range.s.c && outRow.length <= range.e.c) {
for(var i = 0; i <= range.e.c - range.s.c; ++i) outRow.push(null);
}
});
//Handle Row Span
if (rowspan || colspan) {
rowspan = rowspan || 1;
colspan = colspan || 1;
ranges.push({s:{r:R, c:outRow.length},e:{r:R+rowspan-1, c:outRow.length+colspan-1}});
};
//Handle Value
outRow.push(cellValue !== "" ? cellValue : null);
//Handle Colspan
if (colspan) for (var k = 0; k < colspan - 1; ++k) outRow.push(null);
}
out.push(outRow);
}
return [out, ranges];
};
function datenum(v, date1904) {
if(date1904) v+=1462;
var epoch = Date.parse(v);
return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000);
}
function sheet_from_array_of_arrays(data, opts) {
var ws = {};
var range = {s: {c:10000000, r:10000000}, e: {c:0, r:0 }};
for(var R = 0; R != data.length; ++R) {
for(var C = 0; C != data[R].length; ++C) {
if(range.s.r > R) range.s.r = R;
if(range.s.c > C) range.s.c = C;
if(range.e.r < R) range.e.r = R;
if(range.e.c < C) range.e.c = C;
var cell = {v: data[R][C] };
if(cell.v == null) continue;
var cell_ref = XLSX.utils.encode_cell({c:C,r:R});
if(typeof cell.v === 'number') cell.t = 'n';
else if(typeof cell.v === 'boolean') cell.t = 'b';
else if(cell.v instanceof Date) {
cell.t = 'n'; cell.z = XLSX.SSF._table[14];
cell.v = datenum(cell.v);
}
else cell.t = 's';
ws[cell_ref] = cell;
}
}
if(range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range);
return ws;
}
function Workbook() {
if(!(this instanceof Workbook)) return new Workbook();
this.SheetNames = [];
this.Sheets = {};
}
function s2ab(s) {
var buf = new ArrayBuffer(s.length);
var view = new Uint8Array(buf);
for (var i=0; i!=s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
return buf;
}
function export_table_to_excel(id) {
var theTable = document.getElementById(id);
var oo = generateArray(theTable);
var ranges = oo[1];
/* original data */
var data = oo[0];
var ws_name = "SheetJS";
var wb = new Workbook(), ws = sheet_from_array_of_arrays(data);
/* add ranges to worksheet */
ws['!merges'] = ranges;
/* add worksheet to workbook */
wb.SheetNames.push(ws_name);
wb.Sheets[ws_name] = ws;
var wbout = XLSX.write(wb, {bookType:'xlsx', bookSST:false, type: 'binary'});
saveAs(new Blob([s2ab(wbout)],{type:"application/octet-stream"}), "test.xlsx")
}
| hui-w/misc-fragment | javascript-excel/browser-version/vendor/Export2Excel.js | JavaScript | mit | 3,330 | [
30522,
3853,
9699,
2906,
9447,
1006,
2795,
1007,
1063,
13075,
2041,
1027,
1031,
1033,
1025,
13075,
10281,
1027,
2795,
1012,
23032,
11246,
22471,
6525,
3363,
1006,
1005,
19817,
1005,
1007,
1025,
13075,
8483,
1027,
1031,
1033,
1025,
2005,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php get_header(); ?>
<?php the_breadcrumb(); ?>
<div class="container">
<div class="row">
<!-- section -->
<section role="main" class="col-sm-9">
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<!-- article -->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<!-- post title -->
<div class="page-header">
<h1>
<?php the_title(); ?>
</h1>
</div>
<!-- /post title -->
<!-- post details -->
<p class="post-meta">
<span class="date text-muted">
<span class="fa fa-calendar-o"></span> <?php the_time('j. F - Y'); ?>
<span class="fa fa-folder-o"></span> <?php the_category(', '); // Separated by commas ?>
<span class="fa fa-pencil-square-o"></span> <?php the_author_posts_link(); ?></span>
</span>
</p>
<!-- /post details -->
<!-- Featured Image -->
<?php // check if the post has a Post Thumbnail assigned to it.
if ( has_post_thumbnail() ) { ?>
<?php the_post_thumbnail(" img-thumbnail"); ?>
<?php } ?>
<!-- /Featured Image -->
<?php the_content(); // Dynamic Content ?>
</article>
<?php get_template_part( 'partials/objects/meta-after-post' ); ?>
<!-- /article -->
<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() )
comments_template();
?>
<?php endwhile; ?>
<?php else: ?>
<!-- article -->
<article>
<h1><?php _e( 'Sorry, nothing to display.', 'toro' ); ?></h1>
</article>
<!-- /article -->
<?php endif; ?>
</section>
<!-- /section -->
<aside>
<?php // get_sidebar(); ?>
</aside>
</div>
</div>
<?php get_footer(); ?>
| Jursdotme/toro | single.php | PHP | mit | 1,748 | [
30522,
1026,
1029,
25718,
2131,
1035,
20346,
1006,
1007,
1025,
1029,
1028,
1026,
1029,
25718,
1996,
1035,
7852,
26775,
25438,
1006,
1007,
1025,
1029,
1028,
1026,
4487,
2615,
2465,
1027,
1000,
11661,
1000,
1028,
1026,
4487,
2615,
2465,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Basic setups
#
pkgs = value_for_platform(
%w(redhat centos fedora scientific) => {
%w(5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8) => %w(fcgi-perl spawn-fcgi),
"default" => %w(perl-FCGI perl-FCGI-ProcManager spawn-fcgi)
},
"default" => %w(libfcgi-perl libfcgi-procmanager-perl spawn-fcgi)
)
if(platform?(*%w(redhat centos fedora scientific)))
include_recipe 'yum::epel'
if(node[:nginx_simplecgi][:init_type].to_sym == :upstart)
node.set[:nginx_simplecgi][:init_type] = 'init'
end
end
pkgs.each do |package_name|
package package_name
end
if(pkgs.include?('fcgi-perl'))
include_recipe 'perl'
cpan_module 'FCGI::ProcManager'
end
directory node[:nginx_simplecgi][:dispatcher_directory] do
action :create
recursive true
owner node[:nginx][:user]
group node[:nginx][:group] || node[:nginx][:user]
end
# Setup our dispatchers
include_recipe 'nginx_simplecgi::cgi' if node[:nginx_simplecgi][:cgi]
include_recipe 'nginx_simplecgi::php' if node[:nginx_simplecgi][:php]
# Setup our init
case node[:nginx_simplecgi][:init_type].to_sym
when :upstart
include_recipe 'nginx_simplecgi::upstart'
when :runit
include_recipe 'nginx_simplecgi::runit'
when :bluepill
include_recipe 'nginx_simplecgi::bluepill'
when :init
include_recipe 'nginx_simplecgi::init'
else
raise "Not Implemented: #{node[:nginx_simplecgi][:init_type]}"
end
| chewd/chef-repo | cookbooks/nginx_simplecgi/recipes/setup.rb | Ruby | apache-2.0 | 1,361 | [
30522,
1001,
3937,
16437,
2015,
1001,
1052,
2243,
5620,
1027,
3643,
1035,
2005,
1035,
4132,
1006,
1003,
1059,
1006,
2417,
12707,
9358,
2891,
7349,
6525,
4045,
1007,
1027,
1028,
1063,
1003,
1059,
1006,
1019,
1012,
1014,
1019,
1012,
1015,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2015, Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package io.grpc.benchmarks.qps;
import static io.grpc.benchmarks.Utils.parseBoolean;
import static java.lang.Integer.parseInt;
import static java.util.Arrays.asList;
import io.grpc.ManagedChannel;
import io.grpc.benchmarks.Transport;
import io.grpc.benchmarks.Utils;
import io.grpc.benchmarks.proto.Control.RpcType;
import io.grpc.benchmarks.proto.Messages;
import io.grpc.benchmarks.proto.Messages.PayloadType;
import io.grpc.testing.TestUtils;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
/**
* Configuration options for benchmark clients.
*/
public class ClientConfiguration implements Configuration {
private static final ClientConfiguration DEFAULT = new ClientConfiguration();
Transport transport = Transport.NETTY_NIO;
boolean tls;
boolean testca;
String authorityOverride = TestUtils.TEST_SERVER_HOST;
boolean useDefaultCiphers;
boolean directExecutor;
SocketAddress address;
int channels = 4;
int outstandingRpcsPerChannel = 10;
int serverPayload;
int clientPayload;
int flowControlWindow = Utils.DEFAULT_FLOW_CONTROL_WINDOW;
// seconds
int duration = 60;
// seconds
int warmupDuration = 10;
int targetQps;
String histogramFile;
RpcType rpcType = RpcType.UNARY;
PayloadType payloadType = PayloadType.COMPRESSABLE;
private ClientConfiguration() {
}
public ManagedChannel newChannel() throws IOException {
return Utils.newClientChannel(transport, address, tls, testca, authorityOverride,
useDefaultCiphers, flowControlWindow, directExecutor);
}
public Messages.SimpleRequest newRequest() {
return Utils.makeRequest(payloadType, clientPayload, serverPayload);
}
/**
* Constructs a builder for configuring a client application with supported parameters. If no
* parameters are provided, all parameters are assumed to be supported.
*/
static Builder newBuilder(ClientParam... supportedParams) {
return new Builder(supportedParams);
}
static final class Builder extends AbstractConfigurationBuilder<ClientConfiguration> {
private final Collection<Param> supportedParams;
private Builder(ClientParam... supportedParams) {
this.supportedParams = supportedOptionsSet(supportedParams);
}
@Override
protected ClientConfiguration newConfiguration() {
return new ClientConfiguration();
}
@Override
protected Collection<Param> getParams() {
return supportedParams;
}
@Override
protected ClientConfiguration build0(ClientConfiguration config) {
if (config.tls) {
if (!config.transport.tlsSupported) {
throw new IllegalArgumentException(
"Transport " + config.transport.name().toLowerCase() + " does not support TLS.");
}
if (config.transport != Transport.OK_HTTP
&& config.testca && config.address instanceof InetSocketAddress) {
// Override the socket address with the host from the testca.
InetSocketAddress address = (InetSocketAddress) config.address;
config.address = TestUtils.testServerAddress(address.getHostName(),
address.getPort());
}
}
// Verify that the address type is correct for the transport type.
config.transport.validateSocketAddress(config.address);
return config;
}
private static Set<Param> supportedOptionsSet(ClientParam... supportedParams) {
if (supportedParams.length == 0) {
// If no options are supplied, default to including all options.
supportedParams = ClientParam.values();
}
return Collections.unmodifiableSet(new LinkedHashSet<Param>(asList(supportedParams)));
}
}
enum ClientParam implements AbstractConfigurationBuilder.Param {
ADDRESS("STR", "Socket address (host:port) or Unix Domain Socket file name "
+ "(unix:///path/to/file), depending on the transport selected.", null, true) {
@Override
protected void setClientValue(ClientConfiguration config, String value) {
config.address = Utils.parseSocketAddress(value);
}
},
CHANNELS("INT", "Number of Channels.", "" + DEFAULT.channels) {
@Override
protected void setClientValue(ClientConfiguration config, String value) {
config.channels = parseInt(value);
}
},
OUTSTANDING_RPCS("INT", "Number of outstanding RPCs per Channel.",
"" + DEFAULT.outstandingRpcsPerChannel) {
@Override
protected void setClientValue(ClientConfiguration config, String value) {
config.outstandingRpcsPerChannel = parseInt(value);
}
},
CLIENT_PAYLOAD("BYTES", "Payload Size of the Request.", "" + DEFAULT.clientPayload) {
@Override
protected void setClientValue(ClientConfiguration config, String value) {
config.clientPayload = parseInt(value);
}
},
SERVER_PAYLOAD("BYTES", "Payload Size of the Response.", "" + DEFAULT.serverPayload) {
@Override
protected void setClientValue(ClientConfiguration config, String value) {
config.serverPayload = parseInt(value);
}
},
TLS("", "Enable TLS.", "" + DEFAULT.tls) {
@Override
protected void setClientValue(ClientConfiguration config, String value) {
config.tls = parseBoolean(value);
}
},
TESTCA("", "Use the provided Test Certificate for TLS.", "" + DEFAULT.testca) {
@Override
protected void setClientValue(ClientConfiguration config, String value) {
config.testca = parseBoolean(value);
}
},
USE_DEFAULT_CIPHERS("", "Use the default JDK ciphers for TLS (Used to support Java 7).",
"" + DEFAULT.useDefaultCiphers) {
@Override
protected void setClientValue(ClientConfiguration config, String value) {
config.useDefaultCiphers = parseBoolean(value);
}
},
TRANSPORT("STR", Transport.getDescriptionString(), DEFAULT.transport.name().toLowerCase()) {
@Override
protected void setClientValue(ClientConfiguration config, String value) {
config.transport = Transport.valueOf(value.toUpperCase());
}
},
DURATION("SECONDS", "Duration of the benchmark.", "" + DEFAULT.duration) {
@Override
protected void setClientValue(ClientConfiguration config, String value) {
config.duration = parseInt(value);
}
},
WARMUP_DURATION("SECONDS", "Warmup Duration of the benchmark.", "" + DEFAULT.warmupDuration) {
@Override
protected void setClientValue(ClientConfiguration config, String value) {
config.warmupDuration = parseInt(value);
}
},
DIRECTEXECUTOR("",
"Don't use a threadpool for RPC calls, instead execute calls directly "
+ "in the transport thread.", "" + DEFAULT.directExecutor) {
@Override
protected void setClientValue(ClientConfiguration config, String value) {
config.directExecutor = parseBoolean(value);
}
},
SAVE_HISTOGRAM("FILE", "Write the histogram with the latency recordings to file.", null) {
@Override
protected void setClientValue(ClientConfiguration config, String value) {
config.histogramFile = value;
}
},
STREAMING_RPCS("", "Use Streaming RPCs.", "false") {
@Override
protected void setClientValue(ClientConfiguration config, String value) {
config.rpcType = RpcType.STREAMING;
}
},
FLOW_CONTROL_WINDOW("BYTES", "The HTTP/2 flow control window.",
"" + DEFAULT.flowControlWindow) {
@Override
protected void setClientValue(ClientConfiguration config, String value) {
config.flowControlWindow = parseInt(value);
}
},
TARGET_QPS("INT", "Average number of QPS to shoot for.", "" + DEFAULT.targetQps, true) {
@Override
protected void setClientValue(ClientConfiguration config, String value) {
config.targetQps = parseInt(value);
}
};
private final String type;
private final String description;
private final String defaultValue;
private final boolean required;
ClientParam(String type, String description, String defaultValue) {
this(type, description, defaultValue, false);
}
ClientParam(String type, String description, String defaultValue, boolean required) {
this.type = type;
this.description = description;
this.defaultValue = defaultValue;
this.required = required;
}
@Override
public String getName() {
return name().toLowerCase();
}
@Override
public String getType() {
return type;
}
@Override
public String getDescription() {
return description;
}
@Override
public String getDefaultValue() {
return defaultValue;
}
@Override
public boolean isRequired() {
return required;
}
@Override
public void setValue(Configuration config, String value) {
setClientValue((ClientConfiguration) config, value);
}
protected abstract void setClientValue(ClientConfiguration config, String value);
}
}
| xzy256/grpc-java-mips64 | benchmarks/src/main/java/io/grpc/benchmarks/qps/ClientConfiguration.java | Java | bsd-3-clause | 10,781 | [
30522,
1013,
1008,
1008,
9385,
2325,
1010,
8224,
4297,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
25707,
1998,
2224,
1999,
3120,
1998,
12441,
3596,
1010,
2007,
2030,
2302,
1008,
14080,
1010,
2024,
7936,
3024,
2008,
1996,
2206,
3785,
2024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// opening-tag.hpp
// Started 14 Aug 2018
#pragma once
#include <string>
#include <boost/spirit/include/qi.hpp>
namespace client {
// namespace fusion = boost::fusion;
// namespace phoenix = boost::phoenix;
namespace qi = boost::spirit::qi;
namespace ascii = boost::spirit::ascii;
template<typename Iterator>
struct opening_tag : qi::grammar<Iterator, mini_xml_tag(), ascii::space_type>
{
qi::rule<Iterator, mini_xml_tag(), ascii::space_type> start;
qi::rule<Iterator, std::string(), ascii::space_type> head;
qi::rule<Iterator, std::string(), ascii::space_type> tail;
opening_tag()
: base_type{ start }
{
head %= qi::lexeme[+ascii::alnum];
tail %= qi::no_skip[*(qi::char_ - '>')];
start %= qi::lit('<') >> head >> tail >> qi::lit('>');
}
};
}
| Lester-Dowling/studies | C++/boost/spirit/Mini-XML-2017/Unit-Tests/opening-tag.hpp | C++ | gpl-3.0 | 778 | [
30522,
1013,
1013,
3098,
1011,
6415,
1012,
6522,
2361,
1013,
1013,
2318,
2403,
15476,
2760,
1001,
10975,
8490,
2863,
2320,
1001,
2421,
1026,
5164,
1028,
1001,
2421,
1026,
12992,
1013,
4382,
1013,
2421,
1013,
18816,
1012,
6522,
2361,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Python 机器学习的必备技巧
======
> 尝试使用 Python 掌握机器学习、人工智能和深度学习。

想要入门机器学习并不难。除了<ruby>大规模网络公开课<rt>Massive Open Online Courses</rt></ruby>(MOOCs)之外,还有很多其它优秀的免费资源。下面我分享一些我觉得比较有用的方法。
1. 阅览一些关于这方面的视频、文章或者书籍,例如 [The Master Algorithm: How the Quest for the Ultimate Learning Machine Will Remake Our World][29],你肯定会喜欢这些[关于机器学习的互动页面][30]。
2. 对于“机器学习”、“人工智能”、“深度学习”、“数据科学”、“计算机视觉”和“机器人技术”这一堆新名词,你需要知道它们之前的区别。你可以阅览这些领域的专家们的演讲,例如[数据科学家 Brandon Rohrer 的这个视频][1]。
3. 明确你自己的学习目标,并选择合适的 [Coursera 课程][3],或者参加高校的网络公开课。例如[华盛顿大学的课程][4]就很不错。
4. 关注优秀的博客:例如 [KDnuggets][32] 的博客、[Mark Meloon][33] 的博客、[Brandon Rohrer][34] 的博客、[Open AI][35] 的博客,这些都值得推荐。
5. 如果你对在线课程有很大兴趣,后文中会有如何[正确选择 MOOC 课程][31]的指导。
6. 最重要的是,培养自己对这些技术的兴趣。加入一些优秀的社交论坛,专注于阅读和了解,将这些技术的背景知识和发展方向理解透彻,并积极思考在日常生活和工作中如何应用机器学习或数据科学的原理。例如建立一个简单的回归模型来预测下一次午餐的成本,又或者是从电力公司的网站上下载历史电费数据,在 Excel 中进行简单的时序分析以发现某种规律。在你对这些技术产生了浓厚兴趣之后,可以观看以下这个视频。
<https://www.youtube.com/embed/IpGxLWOIZy4>
### Python 是机器学习和人工智能方面的最佳语言吗?
除非你是一名专业的研究一些复杂算法纯理论证明的研究人员,否则,对于一个机器学习的入门者来说,需要熟悉至少一种高级编程语言一家相关的专业知识。因为大多数情况下都是需要考虑如何将机器学习算法应用于解决实际问题,而这需要有一定的编程能力作为基础。
哪一种语言是数据科学的最佳语言?这个讨论一直没有停息过。对于这方面,你可以提起精神来看一下 FreeCodeCamp 上这一篇关于[数据科学语言][6]的文章,又或者是 KDnuggets 关于 [Python 和 R][7] 之间的深入探讨。
目前人们普遍认为 Python 在开发、部署、维护各方面的效率都是比较高的。与 Java、C 和 C++ 这些较为传统的语言相比,Python 的语法更为简单和高级。而且 Python 拥有活跃的社区群体、广泛的开源文化、数百个专用于机器学习的优质代码库,以及来自业界巨头(包括Google、Dropbox、Airbnb 等)的强大技术支持。
### 基础 Python 库
如果你打算使用 Python 实施机器学习,你必须掌握一些 Python 包和库的使用方法。
#### NumPy
NumPy 的完整名称是 [Numerical Python][8],它是 Python 生态里高性能科学计算和数据分析都需要用到的基础包,几乎所有高级工具(例如 [Pandas][9] 和 [scikit-learn][10])都依赖于它。[TensorFlow][11] 使用了 NumPy 数组作为基础构建块以支持 Tensor 对象和深度学习的图形流。很多 NumPy 操作的速度都非常快,因为它们都是通过 C 实现的。高性能对于数据科学和现代机器学习来说是一个非常宝贵的优势。

#### Pandas
Pandas 是 Python 生态中用于进行通用数据分析的最受欢迎的库。Pandas 基于 NumPy 数组构建,在保证了可观的执行速度的同时,还提供了许多数据工程方面的功能,包括:
* 对多种不同数据格式的读写操作
* 选择数据子集
* 跨行列计算
* 查找并补充缺失的数据
* 将操作应用于数据中的独立组
* 按照多种格式转换数据
* 组合多个数据集
* 高级时间序列功能
* 通过 Matplotlib 和 Seaborn 进行可视化

#### Matplotlib 和 Seaborn
数据可视化和数据分析是数据科学家的必备技能,毕竟仅凭一堆枯燥的数据是无法有效地将背后蕴含的信息向受众传达的。这两项技能对于机器学习来说同样重要,因为首先要对数据集进行一个探索性分析,才能更准确地选择合适的机器学习算法。
[Matplotlib][12] 是应用最广泛的 2D Python 可视化库。它包含海量的命令和接口,可以让你根据数据生成高质量的图表。要学习使用 Matplotlib,可以参考这篇详尽的[文章][13]。

[Seaborn][14] 也是一个强大的用于统计和绘图的可视化库。它在 Matplotlib 的基础上提供样式灵活的 API、用于统计和绘图的常见高级函数,还可以和 Pandas 提供的功能相结合。要学习使用 Seaborn,可以参考这篇优秀的[教程][15]。

#### Scikit-learn
Scikit-learn 是机器学习方面通用的重要 Python 包。它实现了多种[分类][16]、[回归][17]和[聚类][18]算法,包括[支持向量机][19]、[随机森林][20]、[梯度增强][21]、[k-means 算法][22]和 [DBSCAN 算法][23],可以与 Python 的数值库 NumPy 和科学计算库 [SciPy][24] 结合使用。它通过兼容的接口提供了有监督和无监督的学习算法。Scikit-learn 的强壮性让它可以稳定运行在生产环境中,同时它在易用性、代码质量、团队协作、文档和性能等各个方面都有良好的表现。可以参考这篇基于 Scikit-learn 的[机器学习入门][25],或者这篇基于 Scikit-learn 的[简单机器学习用例演示][26]。
本文使用 [CC BY-SA 4.0][28] 许可,在 [Heartbeat][27] 上首发。
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/10/machine-learning-python-essential-hacks-and-tricks
作者:[Tirthajyoti Sarkar][a]
选题:[lujun9972][b]
译者:[HankChow](https://github.com/HankChow)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/tirthajyoti
[b]: https://github.com/lujun9972
[1]: https://www.youtube.com/watch?v=tKa0zDDDaQk
[2]: https://www.youtube.com/watch?v=Ura_ioOcpQI
[3]: https://www.coursera.org/learn/machine-learning
[4]: https://www.coursera.org/specializations/machine-learning
[5]: https://towardsdatascience.com/how-to-choose-effective-moocs-for-machine-learning-and-data-science-8681700ed83f
[6]: https://medium.freecodecamp.org/which-languages-should-you-learn-for-data-science-e806ba55a81f
[7]: https://www.kdnuggets.com/2017/09/python-vs-r-data-science-machine-learning.html
[8]: http://numpy.org/
[9]: https://pandas.pydata.org/
[10]: http://scikit-learn.org/
[11]: https://www.tensorflow.org/
[12]: https://matplotlib.org/
[13]: https://realpython.com/python-matplotlib-guide/
[14]: https://seaborn.pydata.org/
[15]: https://www.datacamp.com/community/tutorials/seaborn-python-tutorial
[16]: https://en.wikipedia.org/wiki/Statistical_classification
[17]: https://en.wikipedia.org/wiki/Regression_analysis
[18]: https://en.wikipedia.org/wiki/Cluster_analysis
[19]: https://en.wikipedia.org/wiki/Support_vector_machine
[20]: https://en.wikipedia.org/wiki/Random_forests
[21]: https://en.wikipedia.org/wiki/Gradient_boosting
[22]: https://en.wikipedia.org/wiki/K-means_clustering
[23]: https://en.wikipedia.org/wiki/DBSCAN
[24]: https://en.wikipedia.org/wiki/SciPy
[25]: http://scikit-learn.org/stable/tutorial/basic/tutorial.html
[26]: https://towardsdatascience.com/machine-learning-with-python-easy-and-robust-method-to-fit-nonlinear-data-19e8a1ddbd49
[27]: https://heartbeat.fritz.ai/some-essential-hacks-and-tricks-for-machine-learning-with-python-5478bc6593f2
[28]: https://creativecommons.org/licenses/by-sa/4.0/
[29]: https://www.goodreads.com/book/show/24612233-the-master-algorithm
[30]: http://www.r2d3.us/visual-intro-to-machine-learning-part-1/
[31]: https://towardsdatascience.com/how-to-choose-effective-moocs-for-machine-learning-and-data-science-8681700ed83f
[32]: https://www.kdnuggets.com/
[33]: http://www.markmeloon.com/
[34]: https://brohrer.github.io/blog.html
[35]: https://blog.openai.com/
| Flowsnow/TranslateProject | translated/tech/20181029 Machine learning with Python- Essential hacks and tricks.md | Markdown | apache-2.0 | 9,090 | [
30522,
18750,
100,
100,
1817,
100,
1916,
100,
100,
100,
100,
1027,
1027,
1027,
1027,
1027,
1027,
1028,
100,
100,
100,
100,
18750,
100,
100,
100,
100,
1817,
100,
1635,
1756,
100,
1869,
100,
1796,
100,
100,
1817,
100,
1636,
999,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* ARTarget.cpp
* ARToolKit5
*
* This file generate a special actor who defines a NFT target
* File descriptions: ARTarget contains very important features like size of the target,
* the offset calcultation for the NFT track point, a plane to display the target just for editor mode
*
* ARToolKit is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ARToolKit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ARToolKit. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, the copyright holders of this library give you
* permission to link this library with independent modules to produce an
* executable, regardless of the license terms of these independent modules, and to
* copy and distribute the resulting executable under terms of your choice,
* provided that you also meet, for each linked independent module, the terms and
* conditions of the license of that module. An independent module is a module
* which is neither derived from nor based on this library. If you modify this
* library, you may extend this exception to your version of the library, but you
* are not obligated to do so. If you do not wish to do so, delete this exception
* statement from your version.
*
* Copyright 2015 Daqri, LLC.
* Copyright 2010-2015 ARToolworks, Inc.
*
* Author(s): Philip Lamb, Julian Looser.
*
* Plugin Author(s): Jorge CR (AKA karmakun)
*
* Special Thanks: tgraupmann (your android knowledge helps a lot)
*/
#include "ARPrivatePCH.h"
#include "ARTarget.h"
#include "FileManagerGeneric.h"
// Fix WinBase.h override
#undef UpdateResource
#define UpdateResource UpdateResource
DEFINE_LOG_CATEGORY_STATIC(LogARToolKits, Log, All);
AARTarget::AARTarget()
{
//create components
targetPivot = CreateDefaultSubobject<USceneComponent>("Target Pivot");
targetPivot->SetMobility(EComponentMobility::Static);
RootComponent = targetPivot;
#if WITH_EDITOR
//Editor only: create static mesh component and display plane
plane = CreateDefaultSubobject<UStaticMeshComponent>("Target Plane");
plane->SetupAttachment(targetPivot);
UMaterial* targetMat = Cast<UMaterial>(StaticLoadObject(UMaterial::StaticClass(), NULL, TEXT("/AR/targetMat")));
if (targetMat != NULL)
{
plane->SetMaterial(0, targetMat);
}
// set dummy texture by default
UStaticMesh* myMeshPlane = Cast<UStaticMesh>(StaticLoadObject(UStaticMesh::StaticClass(), NULL, TEXT("/AR/Plane")));
if (myMeshPlane != NULL)
{
plane->SetStaticMesh(myMeshPlane);
plane->SetRelativeScale3D(FVector(1, sizeMM.X, sizeMM.Y));
plane->SetRelativeRotation(FQuat(FRotator(-90, 0, 0)));
plane->SetMobility(EComponentMobility::Static);
}
defaultTexture = Cast<UTexture2D>(StaticLoadObject(UTexture2D::StaticClass(), NULL, TEXT("/AR/icon128")));
#endif
//create shadow plane component
shadowPlane = CreateDefaultSubobject<UStaticMeshComponent>("shadow plane");
shadowPlane->SetupAttachment(RootComponent);
UStaticMesh* myMeshPlane2 = Cast<UStaticMesh>(StaticLoadObject(UStaticMesh::StaticClass(), NULL, TEXT("/AR/Plane")));
if (myMeshPlane2 != NULL)
{
shadowPlane->SetStaticMesh(myMeshPlane2);
shadowPlane->SetRelativeScale3D(FVector(1, shadowPlaneScale, shadowPlaneScale));
shadowPlane->SetRelativeRotation(FQuat(FRotator(-90, 0, 0)));
shadowPlane->SetRelativeLocation(FVector(0, 0, 1));
UMaterial* shadowMat = Cast<UMaterial>(StaticLoadObject(UMaterial::StaticClass(), NULL, TEXT("/AR/shadowPlane_mat")));
if (shadowMat != NULL)
{
shadowPlane->SetMaterial(0, shadowMat);
}
}
}
void AARTarget::OnConstruction(const FTransform& Transform)
{
Super::OnConstruction(Transform);
//set scale based on custom value
SetActorScale3D(FVector(scale, scale, scale));
#if WITH_EDITOR
if (targetName != "" && prevAcceptTargetName != targetName)
{
//load target from content
FString thisTarget = FPaths::GameContentDir() + "AR/" + targetName;
if (FPaths::FileExists(thisTarget + ".iset"))
{
AR2ImageSetT* imageSet = ar2ReadImageSet(TCHAR_TO_ANSI(*thisTarget));
if (imageSet != NULL)
{
//int32 halfIndex = imageSet->num / 2;
int32 halfIndex = 0;
int32 w = imageSet->scale[halfIndex]->xsize;
int32 h = imageSet->scale[halfIndex]->ysize;
int32 dpi = imageSet->scale[0]->dpi;
//UE_LOG(LogARToolKits, Log, TEXT("target size found: %i , %i , %i"), imageSet->scale[i]->xsize, imageSet->scale[i]->ysize, imageSet->scale[i]->dpi);
unsigned char* RawData = imageSet->scale[halfIndex]->imgBW;
targetTexture = UTexture2D::CreateTransient(w, h, PF_B8G8R8A8);
TArray<FColor> rawData;
rawData.Init(FColor(0, 0, 0, 255), w* h);
for (int y = 0; y < h; y++)
{
for (int x = 0; x < w; x++)
{
int i = x + (y * w);
rawData[i].B = RawData[i];
rawData[i].G = RawData[i];
rawData[i].R = RawData[i];
}
}
FTexture2DMipMap& Mip = targetTexture->PlatformData->Mips[0];
void* Data = Mip.BulkData.Lock(LOCK_READ_WRITE);
FMemory::Memcpy(Data,rawData.GetData(), w * h * 4);
Mip.BulkData.Unlock();
targetTexture->UpdateResource();
UMaterialInstanceDynamic* materialInstance = plane->CreateDynamicMaterialInstance(0);
if (materialInstance != NULL)
{
materialInstance->SetTextureParameterValue("tex", targetTexture);
sizeMM.X = w;
sizeMM.Y = h;
UE_LOG(LogARToolKits, Log, TEXT("target found name: %s, pixel size: (w: %i , h: %i), UE real size: (w: %f , h: %f)"), *targetName, w,h,pixels2millimeter(w), pixels2millimeter(h));
prevAcceptTargetName = targetName;
}
}
}
else
{
UMaterialInstanceDynamic* materialInstance = plane->CreateDynamicMaterialInstance(0);
if (materialInstance != NULL)
{
materialInstance->SetTextureParameterValue("tex", defaultTexture);
sizeMM.X = defaultTexture->GetSizeX() * 40;
sizeMM.Y = defaultTexture->GetSizeY() * 40;
UE_LOG(LogARToolKits, Warning, TEXT("this name is not found in AR content folder, check if really exists!"));
prevAcceptTargetName = "";
}
}
}
//set plane size based on image target
plane->SetRelativeScale3D(FVector(1, pixels2millimeter(sizeMM.X), pixels2millimeter(sizeMM.Y)));
#endif
//toogle shadow plane
shadowPlane->SetVisibility(AllowShadowPlane);
//set shadow plane sacle
shadowPlane->SetRelativeScale3D(FVector(1, shadowPlaneScale, shadowPlaneScale));
}
void AARTarget::BeginPlay()
{
Super::BeginPlay();
if (!AllowShadowPlane)
{
shadowPlane->DestroyComponent();
}
else
{
//if plane exist set camera texture
UMaterialInstanceDynamic* shadowDynamicMaterial = shadowPlane->CreateDynamicMaterialInstance(0);
if (shadowDynamicMaterial != NULL)
{
shadowDynamicMaterial->SetTextureParameterValue("tex", IARModule::Get().GetARToolKit()->getTexture());
}
}
}
void AARTarget::setTargetActorsHiddenInGame(bool bHidden)
{
TArray<USceneComponent*> childs;
targetPivot->GetChildrenComponents(true, childs);
for (auto& child : childs)
{
if (child != NULL && child != plane)
{
child->SetHiddenInGame(bHidden);
}
}
for (auto& movable : movableObjectList)
{
if (movable != NULL) movable->SetActorHiddenInGame(bHidden);
}
plane->SetHiddenInGame(true, false);
}
FRotator AARTarget::getTargetRotation()
{
return GetActorRotation();
}
| zkarmakun/ARToolKit-5.3-for-Unreal-Engine | AR/Source/AR/Private/ARTarget.cpp | C++ | gpl-3.0 | 7,722 | [
30522,
1013,
1008,
1008,
2396,
2906,
18150,
1012,
18133,
2361,
1008,
2396,
13669,
23615,
2629,
1008,
1008,
2023,
5371,
9699,
1037,
2569,
3364,
2040,
11859,
1037,
1050,
6199,
4539,
1008,
5371,
13271,
1024,
2396,
2906,
18150,
3397,
2200,
2590... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* Asserts that device property values match properties in |expectedProperties|.
* The method will *not* assert that the device contains *only* properties
* specified in expected properties.
* @param {Object} expectedProperties Expected device properties.
* @param {Object} device Device object to test.
*/
function assertDeviceMatches(expectedProperties, device) {
Object.keys(expectedProperties).forEach(function(key) {
chrome.test.assertEq(expectedProperties[key], device[key],
'Property ' + key + ' of device ' + device.id);
});
}
/**
* Verifies that list of devices contains all and only devices from set of
* expected devices. If will fail the test if an unexpected device is found.
*
* @param {Object.<string, Object>} expectedDevices Expected set of test
* devices. Maps device ID to device properties.
* @param {Array.<Object>} devices List of input devices.
*/
function assertDevicesMatch(expectedDevices, devices) {
var deviceIds = {};
devices.forEach(function(device) {
chrome.test.assertFalse(!!deviceIds[device.id],
'Duplicated device id: \'' + device.id + '\'.');
deviceIds[device.id] = true;
});
function sortedKeys(obj) {
return Object.keys(obj).sort();
}
chrome.test.assertEq(sortedKeys(expectedDevices), sortedKeys(deviceIds));
devices.forEach(function(device) {
assertDeviceMatches(expectedDevices[device.id], device);
});
}
/**
*
* @param {Array.<Object>} devices List of devices returned by
* chrome.audio.getInfo or chrome.audio.getDevices.
* @return {Object.<string, Object>} List of devices formatted as map of
* expected devices used to assert devices match expectation.
*/
function deviceListToExpectedDevicesMap(devices) {
var expectedDevicesMap = {};
devices.forEach(function(device) {
expectedDevicesMap[device.id] = device;
});
return expectedDevicesMap;
}
/**
* @param {Array.<Object>} devices List of devices returned by
* chrome.audio.getInfo or chrome.audio.getDevices.
* @return {Array.<string>} Sorted list devices IDs for devices in |devices|.
*/
function getDeviceIds(devices) {
return devices.map(function(device) {return device.id;}).sort();
}
function EventListener(targetEvent) {
this.targetEvent = targetEvent;
this.listener = this.handleEvent.bind(this);
this.targetEvent.addListener(this.listener);
this.eventCount = 0;
}
EventListener.prototype.handleEvent = function() {
++this.eventCount;
}
EventListener.prototype.reset = function() {
this.targetEvent.removeListener(this.listener);
}
var deviceChangedListener = null;
chrome.test.runTests([
// Sets up a listener for audio.onDeviceChanged event -
// |verifyNoDeviceChangedEvents| test will later verify that no
// onDeviceChanged events have been observed.
function startDeviceChangedListener() {
deviceChangedListener = new EventListener(chrome.audio.onDeviceChanged);
chrome.test.succeed();
},
function getDevicesTest() {
// Test output devices. Maps device ID -> tested device properties.
var kTestDevices = {
'30001': {
id: '30001',
stableDeviceId: '0',
displayName: 'Jabra Speaker 1',
deviceName: 'Jabra Speaker',
streamType: 'OUTPUT'
},
'30002': {
id: '30002',
stableDeviceId: '1',
displayName: 'Jabra Speaker 2',
deviceName: 'Jabra Speaker',
streamType: 'OUTPUT'
},
'30003': {
id: '30003',
stableDeviceId: '2',
displayName: 'HDA Intel MID',
deviceName: 'HDMI output',
streamType: 'OUTPUT'
},
'40001': {
id: '40001',
stableDeviceId: '3',
displayName: 'Jabra Mic 1',
deviceName: 'Jabra Mic',
streamType: 'INPUT'
},
'40002': {
id: '40002',
stableDeviceId: '4',
displayName: 'Jabra Mic 2',
deviceName: 'Jabra Mic',
streamType: 'INPUT'
},
'40003': {
id: '40003',
stableDeviceId: '5',
displayName: 'Logitech Webcam',
deviceName: 'Webcam Mic',
streamType: 'INPUT'
}
};
chrome.audio.getDevices(chrome.test.callbackPass(function(devices) {
assertDevicesMatch(kTestDevices, devices);
}));
},
function getDevicesWithEmptyFilterTest() {
// Test output devices. Maps device ID -> tested device properties.
var kTestDevices = {
'30001': {
id: '30001',
stableDeviceId: '0',
displayName: 'Jabra Speaker 1',
deviceName: 'Jabra Speaker',
streamType: 'OUTPUT'
},
'30002': {
id: '30002',
stableDeviceId: '1',
displayName: 'Jabra Speaker 2',
deviceName: 'Jabra Speaker',
streamType: 'OUTPUT'
},
'30003': {
id: '30003',
stableDeviceId: '2',
displayName: 'HDA Intel MID',
deviceName: 'HDMI output',
streamType: 'OUTPUT'
},
'40001': {
id: '40001',
stableDeviceId: '3',
displayName: 'Jabra Mic 1',
deviceName: 'Jabra Mic',
streamType: 'INPUT'
},
'40002': {
id: '40002',
stableDeviceId: '4',
displayName: 'Jabra Mic 2',
deviceName: 'Jabra Mic',
streamType: 'INPUT'
},
'40003': {
id: '40003',
stableDeviceId: '5',
displayName: 'Logitech Webcam',
deviceName: 'Webcam Mic',
streamType: 'INPUT'
}
};
chrome.audio.getDevices({}, chrome.test.callbackPass(function(devices) {
assertDevicesMatch(kTestDevices, devices);
}));
},
function getInputDevicesTest() {
var kTestDevices = {
'40001': {
id: '40001',
streamType: 'INPUT'
},
'40002': {
id: '40002',
streamType: 'INPUT'
},
'40003': {
id: '40003',
streamType: 'INPUT'
}
};
chrome.audio.getDevices({
streamTypes: ['INPUT']
}, chrome.test.callbackPass(function(devices) {
assertDevicesMatch(kTestDevices, devices);
}));
},
function getOutputDevicesTest() {
var kTestDevices = {
'30001': {
id: '30001',
streamType: 'OUTPUT'
},
'30002': {
id: '30002',
streamType: 'OUTPUT'
},
'30003': {
id: '30003',
streamType: 'OUTPUT'
},
};
chrome.audio.getDevices({
streamTypes: ['OUTPUT']
}, chrome.test.callbackPass(function(devices) {
assertDevicesMatch(kTestDevices, devices);
}));
},
function getActiveDevicesTest() {
chrome.audio.getDevices(chrome.test.callbackPass(function(initial) {
var initialActiveDevices = initial.filter(function(device) {
return device.isActive;
});
chrome.test.assertTrue(initialActiveDevices.length > 0);
chrome.audio.getDevices({
isActive: true
}, chrome.test.callbackPass(function(devices) {
assertDevicesMatch(
deviceListToExpectedDevicesMap(initialActiveDevices),
devices);
}));
var initialActiveInputs = initialActiveDevices.filter(function(device) {
return device.streamType === 'INPUT';
});
chrome.test.assertTrue(initialActiveInputs.length > 0);
chrome.audio.getDevices({
isActive: true,
streamTypes: ['INPUT']
}, chrome.test.callbackPass(function(devices) {
assertDevicesMatch(
deviceListToExpectedDevicesMap(initialActiveInputs),
devices);
}));
var initialActiveOutputs = initialActiveDevices.filter(function(device) {
return device.streamType === 'OUTPUT';
});
chrome.test.assertTrue(initialActiveOutputs.length > 0);
chrome.audio.getDevices({
isActive: true,
streamTypes: ['OUTPUT']
}, chrome.test.callbackPass(function(devices) {
assertDevicesMatch(
deviceListToExpectedDevicesMap(initialActiveOutputs),
devices);
}));
}));
},
function getInactiveDevicesTest() {
chrome.audio.getDevices(chrome.test.callbackPass(function(initial) {
var initialInactiveDevices = initial.filter(function(device) {
return !device.isActive;
});
chrome.test.assertTrue(initialInactiveDevices.length > 0);
chrome.audio.getDevices({
isActive: false
}, chrome.test.callbackPass(function(devices) {
assertDevicesMatch(
deviceListToExpectedDevicesMap(initialInactiveDevices),
devices);
}));
}));
},
function setPropertiesTest() {
chrome.audio.getDevices(chrome.test.callbackPass(function(initial) {
var expectedDevices = deviceListToExpectedDevicesMap(initial);
// Update expected input devices with values that should be changed in
// test.
var updatedInput = expectedDevices['40002'];
chrome.test.assertFalse(updatedInput.gain === 65);
updatedInput.level = 65;
// Update expected output devices with values that should be changed in
// test.
var updatedOutput = expectedDevices['30001'];
chrome.test.assertFalse(updatedOutput.volume === 45);
updatedOutput.level = 45;
chrome.audio.setProperties('30001', {
level: 45
}, chrome.test.callbackPass(function() {
chrome.audio.setProperties('40002', {
level: 65
}, chrome.test.callbackPass(function() {
chrome.audio.getDevices(chrome.test.callbackPass(function(devices) {
assertDevicesMatch(expectedDevices, devices);
}));
}));
}));
}));
},
function inputMuteTest() {
var getMute = function(callback) {
chrome.audio.getMute('INPUT', chrome.test.callbackPass(callback));
};
getMute(function(originalValue) {
chrome.audio.setMute(
'INPUT', !originalValue, chrome.test.callbackPass(function() {
getMute(function(value) {
chrome.test.assertEq(!originalValue, value);
});
}));
});
},
function outputMuteTest() {
var getMute = function(callback) {
chrome.audio.getMute('OUTPUT', chrome.test.callbackPass(callback));
};
getMute(function(originalValue) {
chrome.audio.setMute(
'OUTPUT', !originalValue, chrome.test.callbackPass(function() {
getMute(function(value) {
chrome.test.assertEq(!originalValue, value);
});
}));
});
},
function setActiveDevicesTest() {
chrome.audio.setActiveDevices({
input: ['40002', '40003'],
output: ['30001']
}, chrome.test.callbackPass(function() {
chrome.audio.getDevices({
isActive: true
}, chrome.test.callbackPass(function(activeDevices) {
chrome.test.assertEq(['30001', '40002', '40003'],
getDeviceIds(activeDevices));
}));
}));
},
function setActiveDevicesOutputOnlyTest() {
chrome.audio.getDevices({
streamTypes: ['INPUT'],
isActive: true
}, chrome.test.callbackPass(function(initial) {
var initialActiveInputs = getDeviceIds(initial);
chrome.test.assertTrue(initialActiveInputs.length > 0);
chrome.audio.setActiveDevices({
output: ['30003']
}, chrome.test.callbackPass(function() {
chrome.audio.getDevices({
isActive: true
}, chrome.test.callbackPass(function(devices) {
var expected = ['30003'].concat(initialActiveInputs).sort();
chrome.test.assertEq(expected, getDeviceIds(devices));
}));
}));
}));
},
function setActiveDevicesFailInputTest() {
chrome.audio.getDevices({
isActive: true
}, chrome.test.callbackPass(function(initial) {
var initialActiveIds = getDeviceIds(initial);
chrome.test.assertTrue(initialActiveIds.length > 0);
chrome.audio.setActiveDevices({
input: ['0000000'], /* does not exist */
output: []
}, chrome.test.callbackFail('Failed to set active devices.', function() {
chrome.audio.getDevices({
isActive: true
}, chrome.test.callbackPass(function(devices) {
chrome.test.assertEq(initialActiveIds, getDeviceIds(devices));
}));
}));
}));
},
function setActiveDevicesFailOutputTest() {
chrome.audio.getDevices({
isActive: true
}, chrome.test.callbackPass(function(initial) {
var initialActiveIds = getDeviceIds(initial);
chrome.test.assertTrue(initialActiveIds.length > 0);
chrome.audio.setActiveDevices({
input: [],
output: ['40001'] /* id is input node ID */
}, chrome.test.callbackFail('Failed to set active devices.', function() {
chrome.audio.getDevices({
isActive: true
}, chrome.test.callbackPass(function(devices) {
chrome.test.assertEq(initialActiveIds, getDeviceIds(devices));
}));
}));
}));
},
function clearActiveDevicesTest() {
chrome.audio.getDevices({
isActive: true
}, chrome.test.callbackPass(function(initial) {
chrome.test.assertTrue(getDeviceIds(initial).length > 0);
chrome.audio.setActiveDevices({
input: [],
output: []
}, chrome.test.callbackPass(function() {
chrome.audio.getDevices({
isActive: true
}, chrome.test.callbackPass(function(devices) {
chrome.test.assertEq([], devices);
}));
}));
}));
},
function verifyNoDeviceChangedEvents() {
chrome.test.assertTrue(!!deviceChangedListener);
chrome.test.assertEq(0, deviceChangedListener.eventCount);
deviceChangedListener.reset();
deviceChangedListener = null;
chrome.test.succeed();
},
// Tests verifying the app doesn't have access to deprecated part of the API:
function deprecated_GetInfoTest() {
chrome.audio.getInfo(chrome.test.callbackFail(
'audio.getInfo is deprecated, use audio.getDevices instead.'));
},
function deprecated_setProperties_isMuted() {
chrome.audio.getDevices(chrome.test.callbackPass(function(initial) {
var expectedDevices = deviceListToExpectedDevicesMap(initial);
var expectedError =
'|isMuted| property is deprecated, use |audio.setMute|.';
chrome.audio.setProperties('30001', {
isMuted: true,
// Output device - should have volume set.
level: 55
}, chrome.test.callbackFail(expectedError, function() {
// Assert that device properties haven't changed.
chrome.audio.getDevices(chrome.test.callbackPass(function(devices) {
assertDevicesMatch(expectedDevices, devices);
}));
}));
}));
},
function deprecated_setProperties_volume() {
chrome.audio.getDevices(chrome.test.callbackPass(function(initial) {
var expectedDevices = deviceListToExpectedDevicesMap(initial);
var expectedError = '|volume| property is deprecated, use |level|.';
chrome.audio.setProperties('30001', {
volume: 2,
// Output device - should have volume set.
level: 55
}, chrome.test.callbackFail(expectedError, function() {
// Assert that device properties haven't changed.
chrome.audio.getDevices(chrome.test.callbackPass(function(devices) {
assertDevicesMatch(expectedDevices, devices);
}));
}));
}));
},
function deprecated_setProperties_gain() {
chrome.audio.getDevices(chrome.test.callbackPass(function(initial) {
var expectedDevices = deviceListToExpectedDevicesMap(initial);
var expectedError = '|gain| property is deprecated, use |level|.';
chrome.audio.setProperties('40001', {
gain: 2,
// Output device - should have volume set.
level: 55
}, chrome.test.callbackFail(expectedError, function() {
// Assert that device properties haven't changed.
chrome.audio.getDevices(chrome.test.callbackPass(function(devices) {
assertDevicesMatch(expectedDevices, devices);
}));
}));
}));
},
function deprecated_SetActiveDevicesTest() {
var kExpectedError =
'String list |ids| is deprecated, use DeviceIdLists type.';
chrome.audio.setActiveDevices([
'30003',
'40002'
], chrome.test.callbackFail(kExpectedError));
},
]);
| scheib/chromium | extensions/test/data/api_test/audio/test.js | JavaScript | bsd-3-clause | 16,571 | [
30522,
1013,
1013,
9385,
2286,
1996,
10381,
21716,
5007,
6048,
1012,
2035,
2916,
9235,
1012,
1013,
1013,
2224,
1997,
2023,
3120,
3642,
2003,
9950,
2011,
1037,
18667,
2094,
1011,
2806,
6105,
2008,
2064,
2022,
1013,
1013,
2179,
1999,
1996,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* AngularJS filter for Numeral.js: number formatting as a filter
* @version v2.0.1 - 2017-05-06
* @link https://github.com/baumandm/angular-numeraljs
* @author Dave Bauman <baumandm@gmail.com>
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
"use strict";!function(a,b){"object"==typeof exports?module.exports=b(require("numeral")):"function"==typeof define&&define.amd?define(["numeral"],function(c){return a.ngNumeraljs=b(c)}):a.ngNumeraljs=b(a.numeral)}(this,function(a){return angular.module("ngNumeraljs",[]).provider("$numeraljsConfig",function(){var b={};this.defaultFormat=function(b){a.defaultFormat(b)},this.locale=function(b){a.locale(b)},this.namedFormat=function(a,c){b[a]=c},this.register=function(b,c,d){a.register(b,c,d)},this.$get=function(){return{customFormat:function(a){return b[a]||a},defaultFormat:this.defaultFormat,locale:this.locale,register:this.register,namedFormat:this.namedFormat}}}).filter("numeraljs",["$numeraljsConfig",function(b){return function(c,d){return null==c?c:(d=b.customFormat(d),a(c).format(d))}}])}); | baumandm/angular-numeraljs | dist/angular-numeraljs.min.js | JavaScript | mit | 1,075 | [
30522,
1013,
1008,
1008,
1008,
16108,
22578,
11307,
2005,
16371,
28990,
1012,
1046,
2015,
1024,
2193,
4289,
3436,
2004,
1037,
11307,
1008,
1030,
2544,
1058,
2475,
1012,
1014,
1012,
1015,
1011,
2418,
1011,
5709,
1011,
5757,
1008,
1030,
4957,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
require 'spock'
require 'trollop'
class Spock
module CLI
class << self
include Trollop
def run(args = ARGV)
opts = options args do
banner <<EOS
Usage: spock [CONFIG]
Merge multiple directories into one using symlinks.
If CONFIG is not given, try ~/.spockrc, ~/Dropbox/.spockrc, ~/Dropbox/Apps/Spock/spockrc, in that order.
EOS
opt :dry_run, "Don't actually merge anything; just print",
:short => '-n'
version Spock::VERSION
end
spock = Spock.new ARGV[0], opts
spock.merge
end
end
end
end
| ariofrio/spock | lib/spock/cli.rb | Ruby | mit | 606 | [
30522,
5478,
1005,
11867,
7432,
1005,
5478,
1005,
18792,
7361,
1005,
2465,
11867,
7432,
11336,
18856,
2072,
2465,
1026,
1026,
2969,
2421,
18792,
7361,
13366,
2448,
1006,
12098,
5620,
1027,
12098,
2290,
2615,
1007,
23569,
2015,
1027,
7047,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2016 the original author or authors.
*
* 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 com.github.antennaesdk.common.messages;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* <code>ServerRestMessage</code> carries a REST api call to the mobile-broker.
* Broker executes this call, and returns the result via <code>ClientMessage</code>.
*
* @see ClientMessage
*/
public class ServerRestMessage {
// from where the message originates.
// it can be from a user or from a server (bot)
private ClientAddress from;
// rest resource path such as "/api/books"
// another example would be "/api/books?id=383763"
// another example would be "/api/books/383763"
private String path;
// represents the "protocol//host:port" such as "https://toys.company.com:8443"
// or port can be optional such as "https://toys.company.com"
private String host;
// represents REST method such as "GET", "POST", "PUT", "DELETE" etc
// TODO: use an enum instead of string
private String method;
// actual message ( this the payload if its POST/PUT call )
// this is optional
private String payLoad;
// the headers for a REST message
private Map<String, String> headers = new HashMap<>();
// The name/value pairs of multipart entities. Implies a multipart request.
private Map<String, String> multipartEntities;
// unique identified to track the request on the client side.
private String requestId;
// TODO: use TypeAdapterFactory instead of passing the type.
private String classType = ServerRestMessage.class.getName();
// getters and setters
public ServerRestMessage(){
requestId = UUID.randomUUID().toString();
}
public ServerRestMessage( String requestId ){
this.requestId = requestId;
}
public ClientAddress getFrom() {
return from;
}
public void setFrom(ClientAddress from) {
this.from = from;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public String getPayLoad() {
return payLoad;
}
public void setPayLoad(String payLoad) {
this.payLoad = payLoad;
}
public Map<String, String> getHeaders() { return headers; }
public void setHeaders(Map<String, String> headers) { this.headers = headers; }
public void setMultipartEntities(Map<String, String> multipartEntities) { this.multipartEntities = multipartEntities; }
public Map<String, String> getMultipartEntities() { return multipartEntities; }
public String getRequestId() {
return requestId;
}
public void setRequestId(String requestId) {
this.requestId = requestId;
}
// utility methods
public String toJson(){
Gson gson = new Gson();
String json = gson.toJson(this);
return json;
}
public String toJsonPretty(){
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String json = gson.toJson(this);
return json;
}
public static ServerRestMessage fromJson(String json ){
Gson gson = new Gson();
ServerRestMessage result = gson.fromJson( json, ServerRestMessage.class);
return result;
}
}
| AntennaeSDK/MMS | client-api/src/main/java/com/github/antennaesdk/common/messages/ServerRestMessage.java | Java | apache-2.0 | 4,171 | [
30522,
1013,
1008,
1008,
9385,
2355,
1996,
2434,
3166,
2030,
6048,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
19... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# AUTOGENERATED FILE
FROM balenalib/imx8m-var-dart-fedora:32-run
ENV NODE_VERSION 10.24.0
ENV YARN_VERSION 1.22.4
RUN for key in \
6A010C5166006599AA17F08146C2130DFD2497F5 \
; do \
gpg --keyserver pgp.mit.edu --recv-keys "$key" || \
gpg --keyserver keyserver.pgp.com --recv-keys "$key" || \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" ; \
done \
&& curl -SLO "http://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-arm64.tar.gz" \
&& echo "65e6255c6f95b6dcf87f13c21994bc80205b4bd7c7d9a3fe1f8f2a18daec576d node-v$NODE_VERSION-linux-arm64.tar.gz" | sha256sum -c - \
&& tar -xzf "node-v$NODE_VERSION-linux-arm64.tar.gz" -C /usr/local --strip-components=1 \
&& rm "node-v$NODE_VERSION-linux-arm64.tar.gz" \
&& curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
&& curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \
&& gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
&& mkdir -p /opt/yarn \
&& tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/yarn --strip-components=1 \
&& ln -s /opt/yarn/bin/yarn /usr/local/bin/yarn \
&& ln -s /opt/yarn/bin/yarn /usr/local/bin/yarnpkg \
&& rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
&& npm config set unsafe-perm true -g --unsafe-perm \
&& rm -rf /tmp/*
CMD ["echo","'No CMD command was set in Dockerfile! Details about CMD command could be found in Dockerfile Guide section in our Docs. Here's the link: https://balena.io/docs"]
RUN curl -SLO "https://raw.githubusercontent.com/balena-io-library/base-images/8accad6af708fca7271c5c65f18a86782e19f877/scripts/assets/tests/test-stack@node.sh" \
&& echo "Running test-stack@node" \
&& chmod +x test-stack@node.sh \
&& bash test-stack@node.sh \
&& rm -rf test-stack@node.sh
RUN [ ! -d /.balena/messages ] && mkdir -p /.balena/messages; echo $'Here are a few details about this Docker image (For more information please visit https://www.balena.io/docs/reference/base-images/base-images/): \nArchitecture: ARM v8 \nOS: Fedora 32 \nVariant: run variant \nDefault variable(s): UDEV=off \nThe following software stack is preinstalled: \nNode.js v10.24.0, Yarn v1.22.4 \nExtra features: \n- Easy way to install packages with `install_packages <package-name>` command \n- Run anywhere with cross-build feature (for ARM only) \n- Keep the container idling with `balena-idle` command \n- Show base image details with `balena-info` command' > /.balena/messages/image-info
RUN echo $'#!/bin/sh.real\nbalena-info\nrm -f /bin/sh\ncp /bin/sh.real /bin/sh\n/bin/sh "$@"' > /bin/sh-shim \
&& chmod +x /bin/sh-shim \
&& cp /bin/sh /bin/sh.real \
&& mv /bin/sh-shim /bin/sh | nghiant2710/base-images | balena-base-images/node/imx8m-var-dart/fedora/32/10.24.0/run/Dockerfile | Dockerfile | apache-2.0 | 2,753 | [
30522,
1001,
8285,
6914,
16848,
5371,
2013,
28352,
8189,
29521,
1013,
10047,
2595,
2620,
2213,
1011,
13075,
1011,
14957,
1011,
7349,
6525,
1024,
3590,
1011,
2448,
4372,
2615,
13045,
1035,
2544,
2184,
1012,
2484,
1012,
1014,
4372,
2615,
2715... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.cidic.design.exception;
import org.apache.shiro.authc.AuthenticationException;
public class CaptchaException extends AuthenticationException {
private static final long serialVersionUID = 1L;
public CaptchaException() {
super();
}
public CaptchaException(String message, Throwable cause) {
super(message, cause);
}
public CaptchaException(String message) {
super(message);
}
public CaptchaException(Throwable cause) {
super(cause);
}
}
| zyhndesign/DesignCompetition | src/main/java/com/cidic/design/exception/CaptchaException.java | Java | mit | 480 | [
30522,
7427,
4012,
1012,
28744,
2594,
1012,
2640,
1012,
6453,
1025,
12324,
8917,
1012,
15895,
1012,
11895,
3217,
1012,
8740,
2705,
2278,
1012,
27280,
10288,
24422,
1025,
2270,
2465,
14408,
7507,
10288,
24422,
8908,
27280,
10288,
24422,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* line 1, ../scss/post-header.scss */
.post-header {
position: relative;
}
/* line 5, ../scss/post-header.scss */
.post-header .home-div {
position: absolute;
z-index: 5;
width: 100%;
height: 30vh;
top: 0%;
overflow: hidden;
}
/* line 19, ../scss/post-header.scss */
.post-header .home-div a {
overflow: hidden;
}
/* line 23, ../scss/post-header.scss */
.post-header .home-div a img {
background: linear-gradient(to right, white, rgba(255, 255, 255, 0));
position: relative;
bottom: 19vh;
right: 5vh;
height: 60vh;
opacity: 0.7;
}
/* line 35, ../scss/post-header.scss */
.post-header .post-banner {
position: relative;
z-index: 4;
width: 100%;
height: 30vh;
max-height: 30vh;
overflow-y: hidden;
display: flex;
align-items: center;
}
/* line 49, ../scss/post-header.scss */
.post-header .post-banner img {
z-index: 4;
filter: blur(3px);
-webkit-filter: blur(3px);
-moz-filter: blur(3px);
-ms-filter: blur(3px);
-o-filter: blur(3px);
width: 100%;
height: auto;
}
/* line 63, ../scss/post-header.scss */
.post-header header {
position: absolute;
z-index: 6;
width: 100%;
bottom: 0%;
background: linear-gradient(to right, black, rgba(0, 0, 0, 0.1));
}
/* line 73, ../scss/post-header.scss */
.post-header header h2 {
padding: 3pt;
padding-bottom: 15pt;
padding-top: 15pt;
font-size: 15pt;
font-family: "League Gothic";
text-decoration: none;
color: gainsboro;
}
| rossborchers/worldbeater | css/post-header.css | CSS | gpl-3.0 | 1,444 | [
30522,
1013,
1008,
2240,
1015,
1010,
1012,
1012,
1013,
8040,
4757,
1013,
2695,
1011,
20346,
1012,
8040,
4757,
1008,
1013,
1012,
2695,
1011,
20346,
1063,
2597,
1024,
5816,
1025,
1065,
1013,
1008,
2240,
1019,
1010,
1012,
1012,
1013,
8040,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2013
*
* Generated from xml/schema/CRM/Financial/PaymentProcessor.xml
* DO NOT EDIT. Generated by GenCode.php
*/
require_once 'CRM/Core/DAO.php';
require_once 'CRM/Utils/Type.php';
class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO
{
/**
* static instance to hold the table name
*
* @var string
* @static
*/
static $_tableName = 'civicrm_payment_processor';
/**
* static instance to hold the field values
*
* @var array
* @static
*/
static $_fields = null;
/**
* static instance to hold the keys used in $_fields for each field.
*
* @var array
* @static
*/
static $_fieldKeys = null;
/**
* static instance to hold the FK relationships
*
* @var string
* @static
*/
static $_links = null;
/**
* static instance to hold the values that can
* be imported
*
* @var array
* @static
*/
static $_import = null;
/**
* static instance to hold the values that can
* be exported
*
* @var array
* @static
*/
static $_export = null;
/**
* static value to see if we should log any modifications to
* this table in the civicrm_log table
*
* @var boolean
* @static
*/
static $_log = false;
/**
* Payment Processor ID
*
* @var int unsigned
*/
public $id;
/**
* Which Domain is this match entry for
*
* @var int unsigned
*/
public $domain_id;
/**
* Payment Processor Name.
*
* @var string
*/
public $name;
/**
* Payment Processor Description.
*
* @var string
*/
public $description;
/**
*
* @var int unsigned
*/
public $payment_processor_type_id;
/**
* Is this processor active?
*
* @var boolean
*/
public $is_active;
/**
* Is this processor the default?
*
* @var boolean
*/
public $is_default;
/**
* Is this processor for a test site?
*
* @var boolean
*/
public $is_test;
/**
*
* @var string
*/
public $user_name;
/**
*
* @var string
*/
public $password;
/**
*
* @var string
*/
public $signature;
/**
*
* @var string
*/
public $url_site;
/**
*
* @var string
*/
public $url_api;
/**
*
* @var string
*/
public $url_recur;
/**
*
* @var string
*/
public $url_button;
/**
*
* @var string
*/
public $subject;
/**
*
* @var string
*/
public $class_name;
/**
* Billing Mode
*
* @var int unsigned
*/
public $billing_mode;
/**
* Can process recurring contributions
*
* @var boolean
*/
public $is_recur;
/**
* Payment Type: Credit or Debit
*
* @var int unsigned
*/
public $payment_type;
/**
* class constructor
*
* @access public
* @return civicrm_payment_processor
*/
function __construct()
{
$this->__table = 'civicrm_payment_processor';
parent::__construct();
}
/**
* return foreign keys and entity references
*
* @static
* @access public
* @return array of CRM_Core_EntityReference
*/
static function getReferenceColumns()
{
if (!self::$_links) {
self::$_links = array(
new CRM_Core_EntityReference(self::getTableName() , 'domain_id', 'civicrm_domain', 'id') ,
new CRM_Core_EntityReference(self::getTableName() , 'payment_processor_type_id', 'civicrm_payment_processor_type', 'id') ,
);
}
return self::$_links;
}
/**
* returns all the column names of this table
*
* @access public
* @return array
*/
static function &fields()
{
if (!(self::$_fields)) {
self::$_fields = array(
'id' => array(
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'required' => true,
) ,
'domain_id' => array(
'name' => 'domain_id',
'type' => CRM_Utils_Type::T_INT,
'required' => true,
'FKClassName' => 'CRM_Core_DAO_Domain',
) ,
'name' => array(
'name' => 'name',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Payment Processor') ,
'maxlength' => 64,
'size' => CRM_Utils_Type::BIG,
) ,
'description' => array(
'name' => 'description',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Description') ,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
) ,
'payment_processor_type_id' => array(
'name' => 'payment_processor_type_id',
'type' => CRM_Utils_Type::T_INT,
'FKClassName' => 'CRM_Financial_DAO_PaymentProcessorType',
) ,
'is_active' => array(
'name' => 'is_active',
'type' => CRM_Utils_Type::T_BOOLEAN,
) ,
'is_default' => array(
'name' => 'is_default',
'type' => CRM_Utils_Type::T_BOOLEAN,
) ,
'is_test' => array(
'name' => 'is_test',
'type' => CRM_Utils_Type::T_BOOLEAN,
) ,
'user_name' => array(
'name' => 'user_name',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('User Name') ,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
) ,
'password' => array(
'name' => 'password',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Password') ,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
) ,
'signature' => array(
'name' => 'signature',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Signature') ,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
) ,
'url_site' => array(
'name' => 'url_site',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Site URL') ,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
) ,
'url_api' => array(
'name' => 'url_api',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('API URL') ,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
) ,
'url_recur' => array(
'name' => 'url_recur',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Recurring Payments URL') ,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
) ,
'url_button' => array(
'name' => 'url_button',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Button URL') ,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
) ,
'subject' => array(
'name' => 'subject',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Subject') ,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
) ,
'class_name' => array(
'name' => 'class_name',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Suffix for PHP clas name implementation') ,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
) ,
'billing_mode' => array(
'name' => 'billing_mode',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Billing Mode') ,
'required' => true,
) ,
'is_recur' => array(
'name' => 'is_recur',
'type' => CRM_Utils_Type::T_BOOLEAN,
) ,
'payment_type' => array(
'name' => 'payment_type',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Payment Type') ,
'default' => '1',
) ,
);
}
return self::$_fields;
}
/**
* Returns an array containing, for each field, the arary key used for that
* field in self::$_fields.
*
* @access public
* @return array
*/
static function &fieldKeys()
{
if (!(self::$_fieldKeys)) {
self::$_fieldKeys = array(
'id' => 'id',
'domain_id' => 'domain_id',
'name' => 'name',
'description' => 'description',
'payment_processor_type_id' => 'payment_processor_type_id',
'is_active' => 'is_active',
'is_default' => 'is_default',
'is_test' => 'is_test',
'user_name' => 'user_name',
'password' => 'password',
'signature' => 'signature',
'url_site' => 'url_site',
'url_api' => 'url_api',
'url_recur' => 'url_recur',
'url_button' => 'url_button',
'subject' => 'subject',
'class_name' => 'class_name',
'billing_mode' => 'billing_mode',
'is_recur' => 'is_recur',
'payment_type' => 'payment_type',
);
}
return self::$_fieldKeys;
}
/**
* returns the names of this table
*
* @access public
* @static
* @return string
*/
static function getTableName()
{
return self::$_tableName;
}
/**
* returns if this table needs to be logged
*
* @access public
* @return boolean
*/
function getLog()
{
return self::$_log;
}
/**
* returns the list of fields that can be imported
*
* @access public
* return array
* @static
*/
static function &import($prefix = false)
{
if (!(self::$_import)) {
self::$_import = array();
$fields = self::fields();
foreach($fields as $name => $field) {
if (CRM_Utils_Array::value('import', $field)) {
if ($prefix) {
self::$_import['payment_processor'] = & $fields[$name];
} else {
self::$_import[$name] = & $fields[$name];
}
}
}
}
return self::$_import;
}
/**
* returns the list of fields that can be exported
*
* @access public
* return array
* @static
*/
static function &export($prefix = false)
{
if (!(self::$_export)) {
self::$_export = array();
$fields = self::fields();
foreach($fields as $name => $field) {
if (CRM_Utils_Array::value('export', $field)) {
if ($prefix) {
self::$_export['payment_processor'] = & $fields[$name];
} else {
self::$_export[$name] = & $fields[$name];
}
}
}
}
return self::$_export;
}
}
| ChrisChinchilla/greenrenters.org | sites/all/modules/civicrm/CRM/Financial/DAO/PaymentProcessor.php | PHP | gpl-2.0 | 11,954 | [
30522,
1026,
1029,
25718,
1013,
1008,
1009,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Copyright 2015 Google Inc.
#
# 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.
require 'google/apis/container_v1/service.rb'
require 'google/apis/container_v1/classes.rb'
require 'google/apis/container_v1/representations.rb'
module Google
module Apis
# Google Container Engine API
#
# The Google Container Engine API is used for building and managing container
# based applications, powered by the open source Kubernetes technology.
#
# @see https://cloud.google.com/container-engine/
module ContainerV1
VERSION = 'V1'
REVISION = '20170424'
# View and manage your data across Google Cloud Platform services
AUTH_CLOUD_PLATFORM = 'https://www.googleapis.com/auth/cloud-platform'
end
end
end
| sqrrrl/google-api-ruby-client | generated/google/apis/container_v1.rb | Ruby | apache-2.0 | 1,250 | [
30522,
1001,
9385,
2325,
8224,
4297,
1012,
1001,
1001,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1001,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
1999,
12646,
2007,
1996,
6105,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* ng1hw.h: Tweaks the newport.h structures and definitions to be compatible
* with IRIX. Quite ugly, but it works.
*
* Copyright (C) 1999 Ulf Carlsson (ulfc@thepuffingroup.com)
*/
#ifndef _SGI_NG1HW_H
#define _SGI_NG1HW_H
#include <video/newport.h>
#define rex3regs newport_rexregs
#define configregs newport_cregs
#define float_long npfreg_t
typedef struct newport_rexregs Rex3regs;
typedef struct newport_cregs Configregs;
typedef union np_dcb DCB_reg;
/* It looks like I can't do a simple tweak with this structure because the IRIX
* version is just *too* stupid. Ok, here's a new version of it..
*/
struct rex3chip {
struct newport_rexregs set;
unsigned long _unused0[0x16e];
struct newport_rexregs go;
unsigned long _unused1[0x22e];
struct {
struct newport_cregs set;
unsigned long _unused2[0x1ef];
struct newport_cregs go;
} p1;
};
typedef struct rex3chip rex3Chip;
typedef struct rex3chip Rex3chip;
/* Tweak the defines .. */
#define DM0_OPCODE NPORT_DMODE0_OPMASK
#define DM0_NOP NPORT_DMODE0_NOP
#define DM0_READ NPORT_DMODE0_RD
#define DM0_DRAW NPORT_DMODE0_DRAW
#define DM0_SCR2SCR NPORT_DMODE0_S2S
#define DM0_ADRMODE_SHIFT 2
#define DM0_ADRMODE NPORT_DMODE0_AMMASK
#define DM0_SPAN NPORT_DMODE0_SPAN
#define DM0_BLOCK NPORT_DMODE0_BLOCK
#define DM0_ILINE NPORT_DMODE0_ILINE
#define DM0_FLINE NPORT_DMODE0_FLINE
#define DM0_ALINE NPORT_DMODE0_ALINE
#define DM0_TLINE NPORT_DMODE0_TLINE
#define DM0_BLINE NPORT_DMODE0_BLINE
#define DM0_DOSETUP NPORT_DMODE0_DOSETUP
#define DM0_COLORHOST NPORT_DMODE0_CHOST
#define DM0_ALPHAHOST NPORT_DMODE0_AHOST
#define DM0_STOPONX NPORT_DMODE0_STOPX
#define DM0_STOPONY NPORT_DMODE0_STOPY
#define DM0_STOPONXY (NPORT_DMODE0_STOPX | NPORT_DMODE0_STOPY)
#define DM0_SKIPFIRST NPORT_DMODE0_SK1ST
#define DM0_SKIPLAST NPORT_DMODE0_SKLST
#define DM0_ENZPATTERN NPORT_DMODE0_ZPENAB
#define DM0_ENLSPATTERN NPORT_DMODE0_LISPENAB
#define DM0_LSADVLAST NPORT_DMODE0_LISLST
#define DM0_LENGTH32 NPORT_DMODE0_L32
#define DM0_ZOPAQUE NPORT_DMODE0_ZOPQ
#define DM0_LSOPAQUE NPORT_DMODE0_LISOPQ
#define DM0_SHADE NPORT_DMODE0_SHADE
#define DM0_LRONLY NPORT_DMODE0_LRONLY
#define DM0_XYOFFSET NPORT_DMODE0_XYOFF
#define DM0_CICLAMP NPORT_DMODE0_CLAMP
#define DM0_ENDPTFILTER NPORT_DMODE0_ENDPF
#define DM0_YSTRIDE NPORT_DMODE0_YSTR
#define DM1_PLANES_SHIFT 0
/* The rest of the DM1 planes defines are in newport.h */
#define DM1_DRAWDEPTH_SHIFT 3
#define DM1_DRAWDEPTH_MASK NPORT_DMODE1_DDMASK
#define DM1_DRAWDEPTH NPORT_DMODE1_DD24 /* An alias? */
#define DM1_DRAWDEPTH4 NPORT_DMODE1_DD4
#define DM1_DRAWDEPTH8 NPORT_DMODE1_DD8
#define DM1_DRAWDEPTH12 NPORT_DMODE1_DD12
#define DM1_DRAWDEPTH24 NPORT_DMODE1_DD24
#define DM1_DBLSRC NPORT_DMODE1_DSRC
#define DM1_YFLIP NPORT_DMODE1_YFLIP
#define DM1_RWPACKED NPORT_DMODE1_RWPCKD
#define DM1_HOSTDEPTH_SHIFT 8
#define DM1_HOSTDEPTH_MASK NPORT_DMODE1_HDMASK
#define DM1_HOSTDEPTH NPORT_DMODE1_HD32 /* An alias? */
#define DM1_HOSTDEPTH4 NPORT_DMODE1_HD4
#define DM1_HOSTDEPTH8 NPORT_DMODE1_HD8
#define DM1_HOSTDEPTH12 NPORT_DMODE1_HD12
#define DM1_HOSTDEPTH32 NPORT_DMODE1_HD32
#define DM1_RWDOUBLE NPORT_DMODE1_RWDBL
#define DM1_SWAPENDIAN NPORT_DMODE1_ESWAP
#define DM1_COLORCOMPARE_SHIFT 12
#define DM1_COLORCOMPARE_MASK NPORT_DMODE1_CCMASK
#define DM1_COLORCOMPARE NPORT_DMODE1_CCMASK
#define DM1_COLORCOMPLT NPORT_DMODE1_CCLT
#define DM1_COLORCOMPEQ NPORT_DMODE1_CCEQ
#define DM1_COLORCOMPGT NPORT_DMODE1_CCGT
#define DM1_RGBMODE NPORT_DMODE1_RGBMD
#define DM1_ENDITHER NPORT_DMODE1_DENAB
#define DM1_FASTCLEAR NPORT_DMODE1_FCLR
#define DM1_ENBLEND NPORT_DMODE1_BENAB
#define DM1_SF_SHIFT 19
#define DM1_SF_MASK NPORT_DMODE1_SFMASK
#define DM1_SF NPORT_DMODE1_SFMASK
#define DM1_SF_ZERO NPORT_DMODE1_SF0
#define DM1_SF_ONE NPORT_DMODE1_SF1
#define DM1_SF_DC NPORT_DMODE1_SFDC
#define DM1_SF_MDC NPORT_DMODE1_SFMDC
#define DM1_SF_SA NPORT_DMODE1_SFSA
#define DM1_SF_MSA NPORT_DMODE1_SFMSA
#define DM1_DF_SHIFT 22 /* dfactor(2:0) */
#define DM1_DF_MASK NPORT_DMODE1_DFMASK
#define DM1_DF NPORT_DMODE1_DFMASK
#define DM1_DF_ZERO NPORT_DMODE1_DF0
#define DM1_DF_ONE NPORT_DMODE1_DF1
#define DM1_DF_SC NPORT_DMODE1_DFSC
#define DM1_DF_MSC NPORT_DMODE1_DFMSC
#define DM1_DF_SA NPORT_DMODE1_DFSA
#define DM1_DF_MSA NPORT_DMODE1_DFMSA
#define DM1_ENBACKBLEND NPORT_DMODE1_BBENAB
#define DM1_ENPREFETCH NPORT_DMODE1_PFENAB
#define DM1_BLENDALPHA NPORT_DMODE1_ABLEND
#define DM1_LO_SHIFT 28
#define DM1_LO NPORT_DMODE1_LOMASK
#define DM1_LO_MASK NPORT_DMODE1_LOMASK
#define DM1_LO_ZERO NPORT_DMODE1_LOZERO
#define DM1_LO_AND NPORT_DMODE1_LOAND
#define DM1_LO_ANDR NPORT_DMODE1_LOANDR
#define DM1_LO_SRC NPORT_DMODE1_LOSRC
#define DM1_LO_ANDI NPORT_DMODE1_LOANDI
#define DM1_LO_DST NPORT_DMODE1_LODST
#define DM1_LO_XOR NPORT_DMODE1_LOXOR
#define DM1_LO_OR NPORT_DMODE1_LOOR
#define DM1_LO_NOR NPORT_DMODE1_LONOR
#define DM1_LO_XNOR NPORT_DMODE1_LOXNOR
#define DM1_LO_NDST NPORT_DMODE1_LONDST
#define DM1_LO_ORR NPORT_DMODE1_LOORR
#define DM1_LO_NSRC NPORT_DMODE1_LONSRC
#define DM1_LO_ORI NPORT_DMODE1_LOORI
#define DM1_LO_NAND NPORT_DMODE1_LONAND
#define DM1_LO_ONE NPORT_DMODE1_LOONE
#define SMASK0 NPORT_CMODE_SM0
#define SMASK1 NPORT_CMODE_SM1
#define SMASK2 NPORT_CMODE_SM2
#define SMASK3 NPORT_CMODE_SM3
#define SMASK4 NPORT_CMODE_SM4
#define ALL_SMASKS 0x1f
#define CM_CIDMATCH_SHIFT 9
#define CM_CIDMATCH_MASK NPORT_CMODE_CMSK
#define REX3VERSION_MASK NPORT_STAT_VERS
#define GFXBUSY NPORT_STAT_GBUSY
#define BACKBUSY NPORT_STAT_BBUSY
#define VRINT NPORT_STAT_VRINT
#define VIDEOINT NPORT_STAT_VIDINT
#define GFIFO_LEVEL_SHIFT 7
#define GFIFO_LEVEL_MASK NPORT_STAT_GLMSK
#define BFIFO_LEVEL_SHIFT 13
#define BFIFO_LEVEL_MASK NPORT_STAT_BLMSK
#define BFIFO_INT NPORT_STAT_BFIRQ
#define GFIFO_INT NPORT_STAT_GFIRQ
#define GIO32MODE NPORT_CFG_G32MD
#define BUSWIDTH NPORT_CFG_BWIDTH
#define EXTREGXCVR NPORT_CFG_ERCVR
#define BFIFODEPTH_SHIFT 3
#define BFIFODEPTH_MASK NPORT_CFG_BDMSK
#define BFIFOABOVEINT NPORT_CFG_BFAINT
#define GFIFODEPTH_SHIFT 8
#define GFIFODEPTH_MASK NPORT_CFG_GDMSK
#define GFIFOABOVEINT NPORT_CFG_GFAINT
#define TIMEOUT_SHIFT 14
#define TIMEOUT_MASK NPORT_CFG_TOMSK
#define VREFRESH_SHIFT 17
#define VREFRESH_MASK NPORT_CFG_VRMSK
#define FB_TYPE NPORT_CFG_FBTYP
#define DCB_DATAWIDTH_MASK (0x3)
#define DCB_CRS_MASK (0x7 << DCB_CRS_SHIFT)
#define DCB_ADDR_MASK (0xf << DCB_ADDR_SHIFT)
#define DCB_CSWIDTH_MASK (0x1f << DCB_CSWIDTH_SHIFT)
#define DCB_CSHOLD_MASK (0x1f << DCB_CSHOLD_SHIFT)
#define DCB_CSSETUP_MASK (0x1f << DCB_CSSETUP_SHIFT)
#define DCB_SWAPENDIAN (1 << 28)
#define REX3WAIT(rex3) while ((rex3)->p1.set.status & GFXBUSY)
#define BFIFOWAIT(rex3) while ((rex3)->p1.set.status & BACKBUSY)
#define REX3_GIO_ADDR_0 0x1f0f0000
#define REX3_GIO_ADDR_1 0x1f4f0000
#define REX3_GIO_ADDR_2 0x1f8f0000
#define REX3_GIO_ADDR_3 0x1fcf0000
#define NG1_XSIZE 1280
#define NG1_YSIZE 1024
#endif
| z3bu/AH4222 | kernel/linux/include/asm-mips/ng1hw.h | C | gpl-2.0 | 7,147 | [
30522,
1013,
1008,
1008,
12835,
2487,
2232,
2860,
1012,
1044,
1024,
1056,
8545,
29243,
1996,
9464,
1012,
1044,
5090,
1998,
15182,
2000,
2022,
11892,
1008,
2007,
20868,
7646,
1012,
3243,
9200,
1010,
2021,
2009,
2573,
1012,
1008,
1008,
9385,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Copyright Iris contributors
#
# This file is part of Iris and is released under the LGPL license.
# See COPYING and COPYING.LESSER in the root of the repository for full
# licensing details.
"""Integration tests for loading and saving netcdf files."""
# Import iris.tests first so that some things can be initialised before
# importing anything else.
import iris.tests as tests
from os.path import join as path_join, dirname, sep as os_sep
import shutil
from subprocess import check_call
import tempfile
import iris
from iris.tests import stock
class TestClimatology(iris.tests.IrisTest):
reference_cdl_path = os_sep.join(
[
dirname(tests.__file__),
(
"results/integration/climatology/TestClimatology/"
"reference_simpledata.cdl"
),
]
)
@classmethod
def _simple_cdl_string(cls):
with open(cls.reference_cdl_path, "r") as f:
cdl_content = f.read()
# Add the expected CDL first line since this is removed from the
# stored results file.
cdl_content = "netcdf {\n" + cdl_content
return cdl_content
@staticmethod
def _load_sanitised_cube(filepath):
cube = iris.load_cube(filepath)
# Remove attributes convention, if any.
cube.attributes.pop("Conventions", None)
# Remove any var-names.
for coord in cube.coords():
coord.var_name = None
cube.var_name = None
return cube
@classmethod
def setUpClass(cls):
# Create a temp directory for temp files.
cls.temp_dir = tempfile.mkdtemp()
cls.path_ref_cdl = path_join(cls.temp_dir, "standard.cdl")
cls.path_ref_nc = path_join(cls.temp_dir, "standard.nc")
# Create reference CDL file.
with open(cls.path_ref_cdl, "w") as f_out:
f_out.write(cls._simple_cdl_string())
# Create reference netCDF file from reference CDL.
command = "ncgen -o {} {}".format(cls.path_ref_nc, cls.path_ref_cdl)
check_call(command, shell=True)
cls.path_temp_nc = path_join(cls.temp_dir, "tmp.nc")
# Create reference cube.
cls.cube_ref = stock.climatology_3d()
@classmethod
def tearDownClass(cls):
# Destroy a temp directory for temp files.
shutil.rmtree(cls.temp_dir)
###############################################################################
# Round-trip tests
def test_cube_to_cube(self):
# Save reference cube to file, load cube from same file, test against
# reference cube.
iris.save(self.cube_ref, self.path_temp_nc)
cube = self._load_sanitised_cube(self.path_temp_nc)
self.assertEqual(cube, self.cube_ref)
def test_file_to_file(self):
# Load cube from reference file, save same cube to file, test against
# reference CDL.
cube = iris.load_cube(self.path_ref_nc)
iris.save(cube, self.path_temp_nc)
self.assertCDL(
self.path_temp_nc,
reference_filename=self.reference_cdl_path,
flags="",
)
# NOTE:
# The saving half of the round-trip tests is tested in the
# appropriate dedicated test class:
# unit.fileformats.netcdf.test_Saver.Test_write.test_with_climatology .
# The loading half has no equivalent dedicated location, so is tested
# here as test_load_from_file.
def test_load_from_file(self):
# Create cube from file, test against reference cube.
cube = self._load_sanitised_cube(self.path_ref_nc)
self.assertEqual(cube, self.cube_ref)
if __name__ == "__main__":
tests.main()
| pp-mo/iris | lib/iris/tests/integration/test_climatology.py | Python | lgpl-3.0 | 3,683 | [
30522,
1001,
9385,
11173,
16884,
1001,
1001,
2023,
5371,
2003,
2112,
1997,
11173,
1998,
2003,
2207,
2104,
1996,
1048,
21600,
2140,
6105,
1012,
1001,
2156,
24731,
1998,
24731,
1012,
8276,
1999,
1996,
7117,
1997,
1996,
22409,
2005,
2440,
1001... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#
# Author: Martin Sandve Alnes
# Date: 2008-10-03
#
from ufl import (Coefficient, TestFunction, TrialFunction, VectorElement, dot,
dx, grad, triangle)
element = VectorElement("Lagrange", triangle, 1)
u = TrialFunction(element)
v = TestFunction(element)
w = Coefficient(element)
a = dot(dot(w, grad(u)), v) * dx
| FEniCS/ufl | demo/ExplicitConvection.py | Python | lgpl-3.0 | 332 | [
30522,
1001,
1001,
3166,
1024,
3235,
5472,
3726,
2632,
5267,
1001,
3058,
1024,
2263,
1011,
2184,
1011,
6021,
1001,
2013,
1057,
10258,
12324,
1006,
19064,
1010,
3231,
11263,
27989,
1010,
3979,
11263,
27989,
1010,
9207,
12260,
3672,
1010,
110... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.kensenter.p2poolwidget;
import android.content.Context;
import android.content.SharedPreferences;
public class GetPrefs {
public static final String PREFS_NAME = "p2poolwidgetprefs";
public String GetWidget(Context ctxt, int WidgetId){
SharedPreferences settings = ctxt.getSharedPreferences(PREFS_NAME+WidgetId, 0);
return settings.getString("servername", null);
}
public String GetServer(Context ctxt, int WidgetId){
SharedPreferences settings = ctxt.getSharedPreferences(PREFS_NAME+WidgetId, 0);
return settings.getString("servername", "");
}
public String getPayKey(Context ctxt, int WidgetId){
SharedPreferences settings = ctxt.getSharedPreferences(PREFS_NAME+WidgetId, 0);
return settings.getString("paykey", "");
}
public Integer getPort(Context ctxt, int WidgetId){
SharedPreferences settings = ctxt.getSharedPreferences(PREFS_NAME+WidgetId, 0);
return settings.getInt("portnum", 3332);
}
public Integer getHashLevel(Context ctxt, int WidgetId){
SharedPreferences settings = ctxt.getSharedPreferences(PREFS_NAME+WidgetId, 0);
return settings.getInt("hashlevel", 2);
}
public Integer getAlertRate(Context ctxt, int WidgetId){
SharedPreferences settings = ctxt.getSharedPreferences(PREFS_NAME+WidgetId, 0);
return settings.getInt("alertnum", 0);
}
public Integer getDOARate(Context ctxt, int WidgetId){
SharedPreferences settings = ctxt.getSharedPreferences(PREFS_NAME+WidgetId, 0);
return settings.getInt("doanum", 50);
}
public String getEfficiency(Context ctxt, int WidgetId){
SharedPreferences settings = ctxt.getSharedPreferences(PREFS_NAME+WidgetId, 0);
return settings.getString("efficiency", "");
}
public String getUptime(Context ctxt, int WidgetId){
SharedPreferences settings = ctxt.getSharedPreferences(PREFS_NAME+WidgetId, 0);
return settings.getString("uptime", "");
}
public String getShares(Context ctxt, int WidgetId){
SharedPreferences settings = ctxt.getSharedPreferences(PREFS_NAME+WidgetId, 0);
return settings.getString("shares", "");
}
public String getTimeToShare(Context ctxt, int WidgetId){
SharedPreferences settings = ctxt.getSharedPreferences(PREFS_NAME+WidgetId, 0);
return settings.getString("toshare", "");
}
public String getRoundTime(Context ctxt, int WidgetId){
SharedPreferences settings = ctxt.getSharedPreferences(PREFS_NAME+WidgetId, 0);
return settings.getString("roundtime", "");
}
public String getTimeToBlock(Context ctxt, int WidgetId){
SharedPreferences settings = ctxt.getSharedPreferences(PREFS_NAME+WidgetId, 0);
return settings.getString("toblock", "");
}
public String getBlockValue(Context ctxt, int WidgetId){
SharedPreferences settings = ctxt.getSharedPreferences(PREFS_NAME+WidgetId, 0);
return settings.getString("blockvalue", "");
}
public String getPoolRate(Context ctxt, int WidgetId){
SharedPreferences settings = ctxt.getSharedPreferences(PREFS_NAME+WidgetId, 0);
return settings.getString("pool_rate", "");
}
public boolean getRemoveLine(Context ctxt, int WidgetId){
SharedPreferences settings = ctxt.getSharedPreferences(PREFS_NAME+WidgetId, 0);
return settings.getBoolean("removeline", false);
}
public boolean getAlertOn(Context ctxt, int WidgetId){
SharedPreferences settings = ctxt.getSharedPreferences(PREFS_NAME+WidgetId, 0);
return settings.getBoolean("alerton", true);
}
public boolean getDOAOn(Context ctxt, int WidgetId){
SharedPreferences settings = ctxt.getSharedPreferences(PREFS_NAME+WidgetId, 0);
return settings.getBoolean("doaon", true);
}
}
| ksenter/P2PoolWidget | src/com/kensenter/p2poolwidget/GetPrefs.java | Java | mit | 3,843 | [
30522,
7427,
4012,
1012,
6358,
5054,
3334,
1012,
1052,
2475,
16869,
9148,
24291,
1025,
12324,
11924,
1012,
4180,
1012,
6123,
1025,
12324,
11924,
1012,
4180,
1012,
4207,
28139,
25523,
2015,
1025,
2270,
2465,
2131,
28139,
10343,
1063,
2270,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (c) 2012-2015 S-Core Co., Ltd.
*
* 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.
*/
require([
'common',
'lodash',
'moment',
'async',
'text!resource/add_wsdlg.html',
'text!resource/remove_wsdlg.html'
], function (common, _, moment, async, addDlg, removeDlg) {
'use strict';
/* global webidaFs, webidaApp, webidaAuth, webidaHost: true */
var WORKSPACE_PATH = '.profile/workspace.json';
var WORKSPACE_INFO;
//var _menuSettings = $('#menu-settings');
var _wsContents = $('.ws-body');
var _dimming = $('.dimming');
var _uniqId;
function _dimmingOn() {
_dimming.addClass('active');
}
function _dimmingOff() {
_dimming.removeClass('active');
}
function _checkValidWSFile(cb) {
webidaFs.readFile(WORKSPACE_PATH, function (err, data) {
if (err) {
cb('_checkValidWSFile() - readFile Error: ' + err);
} else {
var wsMeta = JSON.parse(data);
var wsMetaCount = Object.keys(wsMeta).length;
_getWSList(function (err, wslist) {
if (err) {
cb('_checkValidWSFile() - _getWSList Error: ' + err);
} else {
var wsCount = wslist.length;
if (wsMetaCount === wsCount) {
cb(null, true);
} else {
cb(null, false);
}
}
});
}
});
}
function _launchIDE(domObj) {
console.log($(domObj).attr('data-wsname'));
var workspace = '?workspace=' + webidaFs.fsid + '/' + domObj.attr('data-wsname');
webidaApp.launchApp('devenv', true, workspace);
}
function _registerDefaultEvent() {
// register dimming cancel event
_dimming.on('click', function () {
_dimming.removeClass('active');
var addWSDlg = $('.add_wsdlg');
var removeWSDlg = $('.remove_wsdlg');
if (addWSDlg) {
addWSDlg.remove();
}
if (removeWSDlg) {
removeWSDlg.remove();
}
});
$('#menu-logo').on('click', function () {
webidaApp.launchApp('desktop', false, null);
});
// register workspace event
$('#menu-ws').on('click', function () {
var wswrap = $('.ws-wrap');
var settingwrap = $('.settings-wrap');
if (wswrap.hasClass('acitve')) {
settingwrap.removeClass('active');
} else {
wswrap.addClass('active');
settingwrap.removeClass('active');
}
});
// register setting event
$('#menu-settings').on('click', function () {
var wswrap = $('.ws-wrap');
var settingwrap = $('.settings-wrap');
if (settingwrap.hasClass('acitve')) {
wswrap.removeClass('active');
} else {
settingwrap.addClass('active');
wswrap.removeClass('active');
}
});
// register logout event
$('#menu-logout').on('click', function () {
_setLogout();
});
// register workspace add event
$('.ws-icon-add').on('click', function () {
_addWSList();
});
}
// WORKSPACE_PATH 파일이 있는지 없는지 여부 확인 후 없으면 생성.
function _initialize() {
_registerDefaultEvent();
webidaFs.exists(WORKSPACE_PATH, function (err, exist) {
if (err) {
console.log('_checkWSFile() - exists Error: ' + err);
}
if (!exist) {
_setWorkspace(function (err) {
if (err) {
console.log(err);
}
_renderWSList();
});
} else {
_checkValidWSFile(function (err, bool) {
if (err) {
console.log(err);
} else {
if (bool) {
_renderWSList();
} else {
console.log('workspace meta-info is invalid.');
_renderWSList();
}
}
});
}
});
}
// WORKSPACE 목록 생성 및 WORKSPACE_PATH에 정보 저장.
function _setWorkspace(cb) {
webidaFs.list('/', function (err, data) {
if (err) {
console.log('setWorkspace() - list Error: ' + err);
cb(err);
} else {
var WSList =
_.chain(data).filter(function (fileObj) {
if (!fileObj.name.match(/^\./) && fileObj.isDirectory) { return true; }
}).map(function (fileObj) { return '/' + fileObj.name; }).value();
webidaFs.stat(WSList, function (err, stats) {
if (err) {
console.log('setWorkspace() - stat Error: ' + err);
cb(err);
} else {
var wsObj = {};
_.forEach(stats, function (fileObj) {
fileObj.birth = '';
fileObj.desc = '';
wsObj[fileObj.name] = fileObj;
});
webidaFs.writeFile(WORKSPACE_PATH, JSON.stringify(wsObj), function (err) {
if (err) {
console.log('setWorkspace() - writeFile Error: ' + err);
cb(err);
} else {
cb(null, true);
}
});
}
});
}
});
}
// 유니크 id 생성.
function _genUniuqeId() {
_uniqId = _.uniqueId();
return _uniqId;
}
// 로그아웃
function _setLogout() {
webidaAuth.logout(function (err) {
if (err) {
alert('Failed to logout');
} else {
location.href = '//' + webidaHost;
}
});
}
function _getWSList(cb) {
webidaFs.list('/', function (err, data) {
if (err) {
cb(err);
} else {
var WSList =
_.chain(data).filter(function (fileObj) {
if (!fileObj.name.match(/^\./) && fileObj.isDirectory) { return true; }
}).map(function (fileObj) { return '/' + fileObj.name; }).value();
webidaFs.stat(WSList, function (err, stats) {
if (err) {
cb(err);
} else {
cb(null, stats);
}
});
}
});
}
// 프로젝트 목록 얻어오기
function _getPJListPath(WSPath, cb) {
webidaFs.list(WSPath, function (err, pjList) {
if (err) {
cb(err);
} else {
var filteredPJList =
_.chain(pjList).filter(function (file) {
if (!file.name.match('.workspace') && file.isDirectory) {
return true;
}
}).map(function (file) {
return WSPath + '/' + file.name + '/.project/project.json';
}).value();
return cb(null, filteredPJList);
}
});
}
// 프로젝트 목록 그리기
function _renderPJList(domObj) {
var ws = domObj.attr('data-wspath');
var wsRow = domObj.parent();
if (wsRow.hasClass('ws-closed')) {
wsRow.addClass('ws-opened');
wsRow.removeClass('ws-closed');
wsRow.after('<div class="pj-body" data-id="' + wsRow.attr('data-id') + '"></div>');
var proRow = wsRow.next();
_getPJListPath(ws, function (err, pjPathList) {
if (err) {
console.log('_renderPJList() - _getPJListPath Error: ' + err);
} else {
_.forEach(pjPathList, function (pjPath) {
webidaFs.exists(pjPath, function (err, exist) {
if (err) {
console.log('_renderPJList() - exists Error: ' + err);
}
if (exist) {
webidaFs.readFile(pjPath, function (err, data) {
if (err) {
console.log('_renderPJList() - read Error: ' + err);
} else {
var projInfo = JSON.parse(data);
/* jshint maxlen : 200 */
var template =
'<div class="pj-row"">' +
'<div class="pj-content">' +
'<div class="pj-item pj-arrow"></div>' +
'<div class="pj-item pj-name">' + projInfo.name + '</div>' +
'<div class="pj-item pj-ltime"></div>' +
'<div class="pj-item pj-birth">' + moment(projInfo.created).fromNow() + '</div>' +
'<div class="pj-item pj-desc">' + projInfo.description + '</div>' +
'</div>' +
'<div class="pj-content-icon">' +
'</div>' +
'</div>';
/* jshint maxlen:120 */
proRow.append(template);
}
});
}
});
});
}
});
} else {
var projRow = wsRow.next();
if (projRow.hasClass('pj-body') && (projRow.attr('data-id') === wsRow.attr('data-id'))) {
projRow.remove();
wsRow.removeClass('ws-opened');
wsRow.addClass('ws-closed');
}
}
}
// 워크스페이스 목록 그리기
function _renderWSList() {
if (_wsContents.children.length) {
_wsContents.empty();
}
webidaFs.readFile(WORKSPACE_PATH, function (err, data) {
if (err) {
console.log('_renderWSList() - readFile Error: ' + err);
} else {
var wsObj = JSON.parse(data);
WORKSPACE_INFO = wsObj;
_.forEach(wsObj, function (ws) {
var id = _genUniuqeId();
var birth = '';
var desc = '';
if (ws.birth) {
birth = moment(ws.birth).fromNow();
}
if (ws.desc) {
desc = ws.desc;
}
/* jshint maxlen : 200 */
var template =
'<div class="ws-row ws-closed" data-id="' + id + '">' +
'<div class="ws-content" data-wspath="' + ws.path + '">' +
'<div class="ws-item ws-arrow"></div>' +
'<div class="ws-item ws-name">' + ws.name + '</div>' +
'<div class="ws-item ws-ltime">' + moment(ws.mtime).fromNow() + '</div>' +
'<div class="ws-item ws-birth">' + birth + '</div>' +
'<div class="ws-item ws-desc">' + desc + '</div>' +
'</div>' +
'<div class="ws-content-icon">' +
'<div class="ws-launch">' +
'<div class="ws-icon-launch" title="Launch IDE" data-wsname="' + ws.name + '"></div>' +
'</div>' +
'<div class="ws-delete">' +
'<div class="ws-icon-delete" title="Delete Workspace" data-wsname="' + ws.name + '" data-id="' + id + '"></div>' +
'</div>' +
'</div>' +
'</div>';
/* jshint maxlen : 120 */
_wsContents.append(template);
});
// register get project event
$('.ws-body .ws-content').on('click', function (evt) {
var domObj = $(evt.target).parent();
_renderPJList(domObj);
});
// register launch event
$('.ws-icon-launch').on('click', function (evt) {
var domObj = $(evt.target);
_launchIDE(domObj);
});
$('.ws-icon-delete').on('click', function (evt) {
var domObj = $(evt.target);
_removeWSList(domObj);
});
}
});
}
function _addWSList() {
_dimmingOn();
$('body').append(addDlg);
// register dialog close event
$('.adddlg_close').on('click', function () {
$('.add_wsdlg').remove();
_dimmingOff();
});
// input에 포커스
$('#workspace_name').focus();
$('#workspace_name').on('keyup', function () {
var wsname = this.value;
if (wsname) {
$('#adddlg_message').text('');
}
});
// register create workspace event
$('#adddlg_confirm').on('click', function (evt) {
evt.preventDefault();
var wsname = $('#workspace_name').val();
var wsdesc = $('#workspace_desc').val();
var message = $('#adddlg_message');
if (!wsname) {
message.text('Please enter workspace name.');
return;
}
_getWSList(function (err, wslist) {
if (err) {
console.log('_addWSList()' + err);
} else {
var isExist = _.find(wslist, { 'name' : wsname });
if (isExist) {
message.text('\'' + wsname + '\' worskpace is already existed.');
return;
} else {
// create workspace
var WS_META_PATH = wsname + '/.workspace';
var WS_META_FILE = WS_META_PATH + '/workspace.json';
async.waterfall([
function (next) {
webidaFs.createDirectory(wsname, false, function (err) {
if (err) {
next('_addWSList() - 1st createDirectory Error:' + err);
} else {
next();
}
});
},
function (next) {
webidaFs.createDirectory(WS_META_PATH, false, function (err) {
if (err) {
next('_addWSList() - 2nd createDirectory Error:' + err);
} else {
next();
}
});
},
function (next) {
webidaFs.writeFile(WS_META_FILE, '', function (err) {
if (err) {
next('_addWSList() - 1st writeFile Error:' + err);
} else {
next();
}
});
},
function (next) {
webidaFs.stat([wsname], function (err, stats) {
if (err) {
next('_addWSList() - stat Error:' + err);
} else {
stats[0].birth = new Date().toJSON();
stats[0].desc = wsdesc;
WORKSPACE_INFO[wsname] = stats[0];
next();
}
});
},
function (next) {
webidaFs.writeFile(WORKSPACE_PATH, JSON.stringify(WORKSPACE_INFO), function (err) {
if (err) {
next('_addWSList() - 2nd writeFile Error:' + err);
} else {
next();
}
});
}
], function (err) {
if (err) {
console.log(err);
} else {
$('.add_wsdlg').remove();
_dimmingOff();
_renderWSList();
}
});
}
}
});
});
}
function _removeWSList(domObj) {
_dimmingOn();
$('body').append(removeDlg);
$('.removedlg_close').on('click', function () {
$('.remove_wsdlg').remove();
_dimmingOff();
});
var deleteWSname = domObj.attr('data-wsname');
var msg = '<p>This action <strong style="color:#fff">CANNOT</strong> be undone. ' +
'This will delete the <span style="color:#fff; font-weight:bold;">' +
deleteWSname + '</span> workspace and projects permanetly.</p>' +
'<p>Please type in the name of the workspace to confirm.</p>';
$('.removedlg_warning_text').html(msg);
// input에 포커스
$('#workspace_name').focus();
$('#workspace_name').on('keyup', function () {
var wsname = this.value;
if (wsname) {
$('#removedlg_message').text('');
}
});
$('#removedlg_confirm').on('click', function (evt) {
evt.preventDefault();
var wsname = $('#workspace_name').val();
var message = $('#removedlg_message');
if (!wsname) {
message.text('Please enter workspace name.');
return;
} else if (wsname !== deleteWSname) {
message.text('workspace name doesn\'t match.');
return;
}
if (WORKSPACE_INFO[deleteWSname]) {
delete WORKSPACE_INFO[deleteWSname];
async.waterfall([
function (next) {
webidaFs.writeFile(WORKSPACE_PATH, JSON.stringify(WORKSPACE_INFO), function (err) {
if (err) {
err('_removeWSList() - writeFile Error: ' + err);
} else {
next();
}
});
},
function (next) {
webidaFs.delete(deleteWSname, true, function (err) {
if (err) {
next('_removeWSList() - delete Error:' + err);
} else {
next();
}
});
}
], function (err) {
if (err) {
console.log(err);
} else {
var id = domObj.attr('data-id');
var selectorWS = '.ws-row[data-id=' + id + ']';
var selectorProj = '.pj-body[data-id=' + id + ']';
$(selectorWS).remove();
if ($(selectorProj)) {
$(selectorProj).remove();
}
$('.remove_wsdlg').remove();
_dimmingOff();
}
});
}
});
}
common.getFS(function (exist) {
if (exist) {
_initialize();
} else {
location.href = '//' + webidaHost;
}
});
});
| 5hk/webida-client | apps/dashboard/src/js/main_bak.js | JavaScript | apache-2.0 | 22,004 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2262,
1011,
2325,
1055,
1011,
4563,
2522,
1012,
1010,
5183,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jsonp({"cep":"58428312","logradouro":"Rua Jos\u00e9 Moura","bairro":"Pedregal","cidade":"Campina Grande","uf":"PB","estado":"Para\u00edba"});
| lfreneda/cepdb | api/v1/58428312.jsonp.js | JavaScript | cc0-1.0 | 142 | [
30522,
1046,
3385,
2361,
1006,
1063,
1000,
8292,
2361,
1000,
1024,
1000,
5388,
20958,
2620,
21486,
2475,
1000,
1010,
1000,
8833,
12173,
8162,
2080,
1000,
1024,
1000,
21766,
2050,
8183,
2015,
1032,
1057,
8889,
2063,
2683,
9587,
4648,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package org.jabref.model.pdf.search;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
public final class PdfSearchResults {
private final List<SearchResult> searchResults;
public PdfSearchResults(List<SearchResult> search) {
this.searchResults = Collections.unmodifiableList(search);
}
public PdfSearchResults() {
this.searchResults = Collections.emptyList();
}
public List<SearchResult> getSortedByScore() {
List<SearchResult> sortedList = new ArrayList<>(searchResults);
sortedList.sort((searchResult, t1) -> Float.compare(searchResult.getLuceneScore(), t1.getLuceneScore()));
return Collections.unmodifiableList(sortedList);
}
public List<SearchResult> getSearchResults() {
return this.searchResults;
}
public HashMap<String, List<SearchResult>> getSearchResultsByPath() {
HashMap<String, List<SearchResult>> resultsByPath = new HashMap<>();
for (SearchResult result : searchResults) {
if (resultsByPath.containsKey(result.getPath())) {
resultsByPath.get(result.getPath()).add(result);
} else {
List<SearchResult> resultsForPath = new ArrayList<>();
resultsForPath.add(result);
resultsByPath.put(result.getPath(), resultsForPath);
}
}
return resultsByPath;
}
public int numSearchResults() {
return this.searchResults.size();
}
}
| JabRef/jabref | src/main/java/org/jabref/model/pdf/search/PdfSearchResults.java | Java | mit | 1,539 | [
30522,
7427,
8917,
1012,
14855,
13578,
2546,
1012,
2944,
1012,
11135,
1012,
3945,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
9140,
9863,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
6407,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
23325,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* SonarQube
* Copyright (C) 2009-2019 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import ListStyleFacet, { Props } from '../ListStyleFacet';
import { waitAndUpdate } from '../../../helpers/testUtils';
it('should render', () => {
expect(shallowRender()).toMatchSnapshot();
});
it('should select items', () => {
const onChange = jest.fn();
const wrapper = shallowRender({ onChange });
const instance = wrapper.instance() as ListStyleFacet<string>;
// select one item
instance.handleItemClick('b', false);
expect(onChange).lastCalledWith({ foo: ['b'] });
wrapper.setProps({ values: ['b'] });
// select another item
instance.handleItemClick('a', false);
expect(onChange).lastCalledWith({ foo: ['a'] });
wrapper.setProps({ values: ['a'] });
// unselect item
instance.handleItemClick('a', false);
expect(onChange).lastCalledWith({ foo: [] });
wrapper.setProps({ values: [] });
// select multiple items
wrapper.setProps({ values: ['b'] });
instance.handleItemClick('c', true);
expect(onChange).lastCalledWith({ foo: ['b', 'c'] });
wrapper.setProps({ values: ['b', 'c'] });
// unselect item
instance.handleItemClick('c', true);
expect(onChange).lastCalledWith({ foo: ['b'] });
});
it('should toggle', () => {
const onToggle = jest.fn();
const wrapper = shallowRender({ onToggle });
wrapper.find('FacetHeader').prop<Function>('onClick')();
expect(onToggle).toBeCalled();
});
it('should clear', () => {
const onChange = jest.fn();
const wrapper = shallowRender({ onChange, values: ['a'] });
wrapper.find('FacetHeader').prop<Function>('onClear')();
expect(onChange).toBeCalledWith({ foo: [] });
});
it('should search', async () => {
const onSearch = jest.fn().mockResolvedValue({
results: ['d', 'e'],
paging: { pageIndex: 1, pageSize: 2, total: 3 }
});
const loadSearchResultCount = jest.fn().mockResolvedValue({ d: 7, e: 3 });
const wrapper = shallowRender({ loadSearchResultCount, onSearch });
// search
wrapper.find('SearchBox').prop<Function>('onChange')('query');
await waitAndUpdate(wrapper);
expect(wrapper).toMatchSnapshot();
expect(onSearch).lastCalledWith('query');
expect(loadSearchResultCount).lastCalledWith(['d', 'e']);
// load more results
onSearch.mockResolvedValue({
results: ['f'],
paging: { pageIndex: 2, pageSize: 2, total: 3 }
});
loadSearchResultCount.mockResolvedValue({ f: 5 });
wrapper.find('ListFooter').prop<Function>('loadMore')();
await waitAndUpdate(wrapper);
expect(wrapper).toMatchSnapshot();
expect(onSearch).lastCalledWith('query', 2);
// clear search
onSearch.mockClear();
loadSearchResultCount.mockClear();
wrapper.find('SearchBox').prop<Function>('onChange')('');
await waitAndUpdate(wrapper);
expect(wrapper).toMatchSnapshot();
expect(onSearch).not.toBeCalled();
expect(loadSearchResultCount).not.toBeCalled();
// search for no results
onSearch.mockResolvedValue({ results: [], paging: { pageIndex: 1, pageSize: 2, total: 0 } });
wrapper.find('SearchBox').prop<Function>('onChange')('blabla');
await waitAndUpdate(wrapper);
expect(wrapper).toMatchSnapshot();
expect(onSearch).lastCalledWith('blabla');
expect(loadSearchResultCount).not.toBeCalled();
// search fails
onSearch.mockRejectedValue(undefined);
wrapper.find('SearchBox').prop<Function>('onChange')('blabla');
await waitAndUpdate(wrapper);
expect(wrapper).toMatchSnapshot(); // should render previous results
expect(onSearch).lastCalledWith('blabla');
expect(loadSearchResultCount).not.toBeCalled();
});
it('should limit the number of items', () => {
const wrapper = shallowRender({ maxInitialItems: 2, maxItems: 5 });
expect(wrapper.find('FacetItem').length).toBe(2);
wrapper.find('ListStyleFacetFooter').prop<Function>('showMore')();
wrapper.update();
expect(wrapper.find('FacetItem').length).toBe(3);
wrapper.find('ListStyleFacetFooter').prop<Function>('showLess')();
wrapper.update();
expect(wrapper.find('FacetItem').length).toBe(2);
});
it('should show warning that there might be more results', () => {
const wrapper = shallowRender({ maxInitialItems: 2, maxItems: 3 });
wrapper.find('ListStyleFacetFooter').prop<Function>('showMore')();
wrapper.update();
expect(wrapper.find('Alert').exists()).toBe(true);
});
it('should reset state when closes', () => {
const wrapper = shallowRender();
wrapper.setState({
query: 'foobar',
searchResults: ['foo', 'bar'],
searching: true,
showFullList: true
});
wrapper.setProps({ open: false });
checkInitialState(wrapper);
});
it('should reset search when query changes', () => {
const wrapper = shallowRender({ query: { a: ['foo'] } });
wrapper.setState({ query: 'foo', searchResults: ['foo'], searchResultsCounts: { foo: 3 } });
wrapper.setProps({ query: { a: ['foo'], b: ['bar'] } });
checkInitialState(wrapper);
});
it('should collapse list when new stats have few results', () => {
const wrapper = shallowRender({ maxInitialItems: 2, maxItems: 3 });
wrapper.setState({ showFullList: true });
wrapper.setProps({ stats: { d: 1 } });
expect(wrapper.state('showFullList')).toBe(false);
});
it('should display all selected items', () => {
const wrapper = shallowRender({
maxInitialItems: 2,
stats: { a: 10, b: 5, c: 3 },
values: ['a', 'b', 'c']
});
expect(wrapper).toMatchSnapshot();
});
it('should be disabled', () => {
const wrapper = shallowRender({ disabled: true, disabledHelper: 'Disabled helper description' });
expect(wrapper).toMatchSnapshot();
});
function shallowRender(props: Partial<Props<string>> = {}) {
return shallow(
<ListStyleFacet
facetHeader="facet header"
fetching={false}
getFacetItemText={identity}
getSearchResultKey={identity}
getSearchResultText={identity}
onChange={jest.fn()}
onSearch={jest.fn()}
onToggle={jest.fn()}
open={true}
property="foo"
renderFacetItem={identity}
renderSearchResult={identity}
searchPlaceholder="search for foo..."
stats={{ a: 10, b: 8, c: 1 }}
values={[]}
{...props}
/>
);
}
function identity(str: string) {
return str;
}
function checkInitialState(wrapper: ShallowWrapper) {
expect(wrapper.state('query')).toBe('');
expect(wrapper.state('searchResults')).toBe(undefined);
expect(wrapper.state('searching')).toBe(false);
expect(wrapper.state('searchResultsCounts')).toEqual({});
expect(wrapper.state('showFullList')).toBe(false);
}
| Godin/sonar | server/sonar-web/src/main/js/components/facet/__tests__/ListStyleFacet-test.tsx | TypeScript | lgpl-3.0 | 7,356 | [
30522,
1013,
1008,
1008,
24609,
28940,
4783,
1008,
9385,
1006,
1039,
1007,
2268,
1011,
10476,
24609,
6499,
3126,
3401,
7842,
1008,
5653,
3406,
1024,
18558,
2012,
24609,
6499,
3126,
3401,
11089,
4012,
1008,
1008,
2023,
2565,
2003,
2489,
4007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* This method start authentication workflow.
* It should be called by application which require authentication.
*
* Author: Yuriy Movchan Date: 11/06/2013
*/
var uuid = require('uuid');
var async = require('async');
var oxutil = require('../util/util.js');
var state = require('../shared/state.js');
var push = require('../push/push.js');
exports.rest_api = function(req, res, authenticationStore, applicationService, deviceService) {
console.log("Authenticate: '" + req.params.deployment_id + "'", "user: '" + req.params.user_name + "'");
// Load device and application entries
async.series([ function(done) {
deviceService.getDeviceById(req.params.deployment_id, function(found_deployment_entry) {
deployment_entry = found_deployment_entry;
done();
});
}, function(done) {
if (deployment_entry) {
applicationService.getApplication(deployment_entry.oxPushApplication, function(found_application_entry) {
application_entry = found_application_entry;
done();
});
} else {
console.warn("Failed to find deployment entry: '%s'", req.params.deployment_id);
oxutil.sendFailedJsonResponse(res);
done();
}
} ], function() {
if (application_entry && deployment_entry) {
var application_configuration = JSON.parse(application_entry.oxPushApplicationConf);
// TODO: Validate application_ip and req.ip
var authentication_id = uuid.v1();
var authentication_entry = {
'authentication_id' : authentication_id,
'authentication_time' : Date.now(),
'expires_in' : 60,
'expires_at' : Date.now() + 60 * 1000,
'clean_up_at' : Date.now() + 180 * 1000,
'application_id' : application_entry.oxId,
'application_name' : application_configuration.name,
'application_description' : application_configuration.description,
'application_ip' : req.ip,
'user_name' : req.params.user_name,
'authentication_status' : state.PENDING,
};
authenticationStore.set(authentication_id, authentication_entry);
// Send message to device
var device_configuration = JSON.parse(deployment_entry.oxPushDeviceConf);
try {
push.sendAuthenticationMessageToDevice(device_configuration, authentication_id);
} catch (err) {
console.log("Failed to send notification message to device: '" + device_configuration.device_uuid);
}
console.log("Initialized authentication process: '" + authentication_id + "' for application: '"
+ authentication_entry.application_name + "'");
oxutil.sendJsonResponse(res, {
authentication_id : authentication_entry.authentication_id,
expires_in : authentication_entry.expires_in,
result : true,
});
} else {
console.warn("Failed to find application entry: '%s'", deployment_entry.oxPushApplication);
oxutil.sendFailedJsonResponse(res);
}
});
};
| GluuFederation/oxPush | server/lib/authenticate/authenticate.js | JavaScript | mit | 2,809 | [
30522,
1013,
1008,
1008,
1008,
2023,
4118,
2707,
27280,
2147,
12314,
1012,
1008,
2009,
2323,
2022,
2170,
2011,
4646,
2029,
5478,
27280,
1012,
1008,
1008,
3166,
1024,
14331,
2100,
9587,
25465,
4819,
3058,
1024,
2340,
1013,
5757,
1013,
2286,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Copyright 2014 Google Inc. All rights reserved.
*
* 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 com.google.mr4c.message;
import com.google.mr4c.util.MR4CLogging;
import java.io.IOException;
import java.net.URI;
import org.slf4j.Logger;
public class DefaultMessageHandler implements MessageHandler {
protected static final Logger s_log = MR4CLogging.getLogger(DefaultMessageHandler.class);
public void setURI(URI uri) {}
public void handleMessage(Message msg) throws IOException {
s_log.info("Message sent to default handler for topic [{}] : [{}]", msg.getTopic(), msg.getContent());
}
}
| rickyHong/RSparkMR4C | java/src/java/com/google/mr4c/message/DefaultMessageHandler.java | Java | apache-2.0 | 1,149 | [
30522,
1013,
1008,
1008,
1008,
9385,
2297,
8224,
4297,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2025,
2224,
2023,
53... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Solanum pseudogeminifolium Dammer SPECIES
#### Status
SYNONYM
#### According to
The Catalogue of Life, 3rd January 2011
#### Published in
null
#### Original name
null
### Remarks
null | mdoering/backbone | life/Plantae/Magnoliophyta/Magnoliopsida/Solanales/Solanaceae/Solanum/Solanum anguivi/ Syn. Solanum pseudogeminifolium/README.md | Markdown | apache-2.0 | 190 | [
30522,
1001,
14017,
27975,
18404,
3351,
25300,
14876,
21816,
5477,
5017,
2427,
1001,
1001,
1001,
1001,
3570,
10675,
1001,
1001,
1001,
1001,
2429,
2000,
1996,
10161,
1997,
2166,
1010,
3822,
2254,
2249,
1001,
1001,
1001,
1001,
2405,
1999,
197... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/********************************************************************
* Copyright © 2016 Computational Molecular Biology Group, *
* Freie Universität Berlin (GER) *
* *
* This file is part of ReaDDy. *
* *
* ReaDDy is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General *
* Public License along with this program. If not, see *
* <http://www.gnu.org/licenses/>. *
********************************************************************/
/**
* << detailed description >>
*
* @file TopologyFusionReaction.h
* @brief << brief description >>
* @author clonker
* @date 23.06.17
* @copyright GNU Lesser General Public License v3.0
*/
#pragma once
#include <readdy/common/macros.h>
#include <readdy/common/common.h>
#include <readdy/common/ParticleTypeTuple.h>
#include <readdy/model/topologies/TopologyParticleTypeMap.h>
#include <readdy/common/string.h>
NAMESPACE_BEGIN(readdy)
NAMESPACE_BEGIN(model)
NAMESPACE_BEGIN(top)
class TopologyRegistry;
NAMESPACE_BEGIN(reactions)
/**
* TT - Topology-Topology
* TP - Topology-Particle
*/
enum class STRMode {
TT_ENZYMATIC = 0, TT_FUSION, TT_FUSION_ALLOW_SELF, TP_ENZYMATIC, TP_FUSION
};
class STRParser;
class SpatialTopologyReaction {
public:
SpatialTopologyReaction(std::string name, util::particle_type_pair types, topology_type_pair top_types,
util::particle_type_pair types_to, topology_type_pair top_types_to, scalar rate,
scalar radius, STRMode mode)
: _name(std::move(name)), _types(std::move(types)), _types_to(std::move(types_to)), _rate(rate),
_radius(radius), _mode(mode), _top_types(std::move(top_types)), _top_types_to(std::move(top_types_to)) {};
~SpatialTopologyReaction() = default;
SpatialTopologyReaction(const SpatialTopologyReaction &) = default;
SpatialTopologyReaction &operator=(const SpatialTopologyReaction &) = default;
SpatialTopologyReaction(SpatialTopologyReaction &&) = default;
SpatialTopologyReaction &operator=(SpatialTopologyReaction &&) = default;
const std::string &name() const {
return _name;
}
const particle_type_type type1() const {
return std::get<0>(_types);
}
const particle_type_type type2() const {
return std::get<1>(_types);
}
const util::particle_type_pair &types() const {
return _types;
}
const particle_type_type type_to1() const {
return std::get<0>(_types_to);
}
const particle_type_type type_to2() const {
return std::get<1>(_types_to);
}
const util::particle_type_pair &types_to() const {
return _types_to;
}
const topology_type_type top_type1() const {
return std::get<0>(_top_types);
}
const topology_type_type top_type2() const {
return std::get<1>(_top_types);
}
const topology_type_type top_type_to1() const {
return std::get<0>(_top_types_to);
}
const topology_type_type top_type_to2() const {
return std::get<1>(_top_types_to);
}
bool is_topology_particle_reaction() const {
return top_type2() == topology_type_empty;
}
bool is_topology_topology_reaction() const {
return !is_topology_particle_reaction();
}
const bool is_enzymatic() const {
return _mode == STRMode::TT_ENZYMATIC || _mode == STRMode::TP_ENZYMATIC;
}
const bool is_fusion() const {
return _mode == STRMode::TT_FUSION || _mode == STRMode::TT_FUSION_ALLOW_SELF || _mode == STRMode::TP_FUSION;
}
const scalar rate() const {
return _rate;
}
const scalar radius() const {
return _radius;
}
const bool allow_self_connection() const {
return _mode == STRMode::TT_FUSION_ALLOW_SELF;
}
const STRMode &mode() const {
return _mode;
}
private:
friend class STRParser;
SpatialTopologyReaction() = default;
std::string _name;
util::particle_type_pair _types;
util::particle_type_pair _types_to;
topology_type_pair _top_types;
topology_type_pair _top_types_to;
scalar _rate{0};
scalar _radius{0};
STRMode _mode{STRMode::TP_ENZYMATIC};
};
class STRParser {
public:
explicit STRParser(const TopologyRegistry ®istry) : _topology_registry(registry) {};
/**
* Pass descriptor of form for Topology<->Topology
* - fusion type:
* name: T1 (p1) + T2 (p2) -> T3 (p3--p4) [self=true|false]
* - enzymatic type:
* name: T1 (p1) + T2 (p2) -> T3 (p3) + T4 (p4)
*
* and for Topology<->Particle
* - fusion type:
* name: T1 (p1) + (p2) -> T2 (p3--p4)
* - enzymatic type:
* name: T1 (p1) + (p2) -> T2 (p3) + (p4)
*
* @param descriptor the descriptor
* @param rate the rate
* @param radius the radius
* @return the parsed reaction object
*/
SpatialTopologyReaction parse(const std::string &descriptor, scalar rate, scalar radius) const;
private:
std::reference_wrapper<const TopologyRegistry> _topology_registry;
};
NAMESPACE_END(reactions)
NAMESPACE_END(top)
NAMESPACE_END(model)
NAMESPACE_END(readdy)
| chrisfroe/readdy | include/readdy/model/topologies/reactions/SpatialTopologyReaction.h | C | lgpl-3.0 | 6,129 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* OMX Video encoder
* Copyright (C) 2011 Martin Storsjo
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#if CONFIG_OMX_RPI
#define OMX_SKIP64BIT
#endif
#include <dlfcn.h>
#include <OMX_Core.h>
#include <OMX_Component.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include "libavutil/avstring.h"
#include "libavutil/avutil.h"
#include "libavutil/common.h"
#include "libavutil/imgutils.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "h264.h"
#include "internal.h"
#ifdef OMX_SKIP64BIT
static OMX_TICKS to_omx_ticks(int64_t value)
{
OMX_TICKS s;
s.nLowPart = value & 0xffffffff;
s.nHighPart = value >> 32;
return s;
}
static int64_t from_omx_ticks(OMX_TICKS value)
{
return (((int64_t)value.nHighPart) << 32) | value.nLowPart;
}
#else
#define to_omx_ticks(x) (x)
#define from_omx_ticks(x) (x)
#endif
#define INIT_STRUCT(x) do { \
x.nSize = sizeof(x); \
x.nVersion = s->version; \
} while (0)
#define CHECK(x) do { \
if (x != OMX_ErrorNone) { \
av_log(avctx, AV_LOG_ERROR, \
"err %x (%d) on line %d\n", x, x, __LINE__); \
return AVERROR_UNKNOWN; \
} \
} while (0)
typedef struct OMXContext {
void *lib;
void *lib2;
OMX_ERRORTYPE (*ptr_Init)(void);
OMX_ERRORTYPE (*ptr_Deinit)(void);
OMX_ERRORTYPE (*ptr_ComponentNameEnum)(OMX_STRING, OMX_U32, OMX_U32);
OMX_ERRORTYPE (*ptr_GetHandle)(OMX_HANDLETYPE*, OMX_STRING, OMX_PTR, OMX_CALLBACKTYPE*);
OMX_ERRORTYPE (*ptr_FreeHandle)(OMX_HANDLETYPE);
OMX_ERRORTYPE (*ptr_GetComponentsOfRole)(OMX_STRING, OMX_U32*, OMX_U8**);
OMX_ERRORTYPE (*ptr_GetRolesOfComponent)(OMX_STRING, OMX_U32*, OMX_U8**);
void (*host_init)(void);
} OMXContext;
static av_cold void *dlsym_prefixed(void *handle, const char *symbol, const char *prefix)
{
char buf[50];
snprintf(buf, sizeof(buf), "%s%s", prefix ? prefix : "", symbol);
return dlsym(handle, buf);
}
static av_cold int omx_try_load(OMXContext *s, void *logctx,
const char *libname, const char *prefix,
const char *libname2)
{
if (libname2) {
s->lib2 = dlopen(libname2, RTLD_NOW | RTLD_GLOBAL);
if (!s->lib2) {
av_log(logctx, AV_LOG_WARNING, "%s not found\n", libname);
return AVERROR_ENCODER_NOT_FOUND;
}
s->host_init = dlsym(s->lib2, "bcm_host_init");
if (!s->host_init) {
av_log(logctx, AV_LOG_WARNING, "bcm_host_init not found\n");
dlclose(s->lib2);
s->lib2 = NULL;
return AVERROR_ENCODER_NOT_FOUND;
}
}
s->lib = dlopen(libname, RTLD_NOW | RTLD_GLOBAL);
if (!s->lib) {
av_log(logctx, AV_LOG_WARNING, "%s not found\n", libname);
return AVERROR_ENCODER_NOT_FOUND;
}
s->ptr_Init = dlsym_prefixed(s->lib, "OMX_Init", prefix);
s->ptr_Deinit = dlsym_prefixed(s->lib, "OMX_Deinit", prefix);
s->ptr_ComponentNameEnum = dlsym_prefixed(s->lib, "OMX_ComponentNameEnum", prefix);
s->ptr_GetHandle = dlsym_prefixed(s->lib, "OMX_GetHandle", prefix);
s->ptr_FreeHandle = dlsym_prefixed(s->lib, "OMX_FreeHandle", prefix);
s->ptr_GetComponentsOfRole = dlsym_prefixed(s->lib, "OMX_GetComponentsOfRole", prefix);
s->ptr_GetRolesOfComponent = dlsym_prefixed(s->lib, "OMX_GetRolesOfComponent", prefix);
if (!s->ptr_Init || !s->ptr_Deinit || !s->ptr_ComponentNameEnum ||
!s->ptr_GetHandle || !s->ptr_FreeHandle ||
!s->ptr_GetComponentsOfRole || !s->ptr_GetRolesOfComponent) {
av_log(logctx, AV_LOG_WARNING, "Not all functions found in %s\n", libname);
dlclose(s->lib);
s->lib = NULL;
if (s->lib2)
dlclose(s->lib2);
s->lib2 = NULL;
return AVERROR_ENCODER_NOT_FOUND;
}
return 0;
}
static av_cold OMXContext *omx_init(void *logctx, const char *libname, const char *prefix)
{
static const char * const libnames[] = {
#if CONFIG_OMX_RPI
"/opt/vc/lib/libopenmaxil.so", "/opt/vc/lib/libbcm_host.so",
#else
"libOMX_Core.so", NULL,
"libOmxCore.so", NULL,
#endif
NULL
};
const char* const* nameptr;
int ret = AVERROR_ENCODER_NOT_FOUND;
OMXContext *omx_context;
omx_context = av_mallocz(sizeof(*omx_context));
if (!omx_context)
return NULL;
if (libname) {
ret = omx_try_load(omx_context, logctx, libname, prefix, NULL);
if (ret < 0) {
av_free(omx_context);
return NULL;
}
} else {
for (nameptr = libnames; *nameptr; nameptr += 2)
if (!(ret = omx_try_load(omx_context, logctx, nameptr[0], prefix, nameptr[1])))
break;
if (!*nameptr) {
av_free(omx_context);
return NULL;
}
}
if (omx_context->host_init)
omx_context->host_init();
omx_context->ptr_Init();
return omx_context;
}
static av_cold void omx_deinit(OMXContext *omx_context)
{
if (!omx_context)
return;
omx_context->ptr_Deinit();
dlclose(omx_context->lib);
av_free(omx_context);
}
typedef struct OMXCodecContext {
const AVClass *class;
char *libname;
char *libprefix;
OMXContext *omx_context;
AVCodecContext *avctx;
char component_name[OMX_MAX_STRINGNAME_SIZE];
OMX_VERSIONTYPE version;
OMX_HANDLETYPE handle;
int in_port, out_port;
OMX_COLOR_FORMATTYPE color_format;
int stride, plane_size;
int num_in_buffers, num_out_buffers;
OMX_BUFFERHEADERTYPE **in_buffer_headers;
OMX_BUFFERHEADERTYPE **out_buffer_headers;
int num_free_in_buffers;
OMX_BUFFERHEADERTYPE **free_in_buffers;
int num_done_out_buffers;
OMX_BUFFERHEADERTYPE **done_out_buffers;
pthread_mutex_t input_mutex;
pthread_cond_t input_cond;
pthread_mutex_t output_mutex;
pthread_cond_t output_cond;
pthread_mutex_t state_mutex;
pthread_cond_t state_cond;
OMX_STATETYPE state;
OMX_ERRORTYPE error;
int mutex_cond_inited;
int num_in_frames, num_out_frames;
uint8_t *output_buf;
int output_buf_size;
int input_zerocopy;
} OMXCodecContext;
static void append_buffer(pthread_mutex_t *mutex, pthread_cond_t *cond,
int* array_size, OMX_BUFFERHEADERTYPE **array,
OMX_BUFFERHEADERTYPE *buffer)
{
pthread_mutex_lock(mutex);
array[(*array_size)++] = buffer;
pthread_cond_broadcast(cond);
pthread_mutex_unlock(mutex);
}
static OMX_BUFFERHEADERTYPE *get_buffer(pthread_mutex_t *mutex, pthread_cond_t *cond,
int* array_size, OMX_BUFFERHEADERTYPE **array,
int wait)
{
OMX_BUFFERHEADERTYPE *buffer;
pthread_mutex_lock(mutex);
if (wait) {
while (!*array_size)
pthread_cond_wait(cond, mutex);
}
if (*array_size > 0) {
buffer = array[0];
(*array_size)--;
memmove(&array[0], &array[1], (*array_size) * sizeof(OMX_BUFFERHEADERTYPE*));
} else {
buffer = NULL;
}
pthread_mutex_unlock(mutex);
return buffer;
}
static OMX_ERRORTYPE event_handler(OMX_HANDLETYPE component, OMX_PTR app_data, OMX_EVENTTYPE event,
OMX_U32 data1, OMX_U32 data2, OMX_PTR event_data)
{
OMXCodecContext *s = app_data;
// This uses casts in the printfs, since OMX_U32 actually is a typedef for
// unsigned long in official header versions (but there are also modified
// versions where it is something else).
switch (event) {
case OMX_EventError:
pthread_mutex_lock(&s->state_mutex);
av_log(s->avctx, AV_LOG_ERROR, "OMX error %"PRIx32"\n", (uint32_t) data1);
s->error = data1;
pthread_cond_broadcast(&s->state_cond);
pthread_mutex_unlock(&s->state_mutex);
break;
case OMX_EventCmdComplete:
if (data1 == OMX_CommandStateSet) {
pthread_mutex_lock(&s->state_mutex);
s->state = data2;
av_log(s->avctx, AV_LOG_VERBOSE, "OMX state changed to %"PRIu32"\n", (uint32_t) data2);
pthread_cond_broadcast(&s->state_cond);
pthread_mutex_unlock(&s->state_mutex);
} else if (data1 == OMX_CommandPortDisable) {
av_log(s->avctx, AV_LOG_VERBOSE, "OMX port %"PRIu32" disabled\n", (uint32_t) data2);
} else if (data1 == OMX_CommandPortEnable) {
av_log(s->avctx, AV_LOG_VERBOSE, "OMX port %"PRIu32" enabled\n", (uint32_t) data2);
} else {
av_log(s->avctx, AV_LOG_VERBOSE, "OMX command complete, command %"PRIu32", value %"PRIu32"\n",
(uint32_t) data1, (uint32_t) data2);
}
break;
case OMX_EventPortSettingsChanged:
av_log(s->avctx, AV_LOG_VERBOSE, "OMX port %"PRIu32" settings changed\n", (uint32_t) data1);
break;
default:
av_log(s->avctx, AV_LOG_VERBOSE, "OMX event %d %"PRIx32" %"PRIx32"\n",
event, (uint32_t) data1, (uint32_t) data2);
break;
}
return OMX_ErrorNone;
}
static OMX_ERRORTYPE empty_buffer_done(OMX_HANDLETYPE component, OMX_PTR app_data,
OMX_BUFFERHEADERTYPE *buffer)
{
OMXCodecContext *s = app_data;
if (s->input_zerocopy) {
if (buffer->pAppPrivate) {
if (buffer->pOutputPortPrivate)
av_free(buffer->pAppPrivate);
else
av_frame_free((AVFrame**)&buffer->pAppPrivate);
buffer->pAppPrivate = NULL;
}
}
append_buffer(&s->input_mutex, &s->input_cond,
&s->num_free_in_buffers, s->free_in_buffers, buffer);
return OMX_ErrorNone;
}
static OMX_ERRORTYPE fill_buffer_done(OMX_HANDLETYPE component, OMX_PTR app_data,
OMX_BUFFERHEADERTYPE *buffer)
{
OMXCodecContext *s = app_data;
append_buffer(&s->output_mutex, &s->output_cond,
&s->num_done_out_buffers, s->done_out_buffers, buffer);
return OMX_ErrorNone;
}
static const OMX_CALLBACKTYPE callbacks = {
event_handler,
empty_buffer_done,
fill_buffer_done
};
static av_cold int find_component(OMXContext *omx_context, void *logctx,
const char *role, char *str, int str_size)
{
OMX_U32 i, num = 0;
char **components;
int ret = 0;
#if CONFIG_OMX_RPI
if (av_strstart(role, "video_encoder.", NULL)) {
av_strlcpy(str, "OMX.broadcom.video_encode", str_size);
return 0;
}
#endif
omx_context->ptr_GetComponentsOfRole((OMX_STRING) role, &num, NULL);
if (!num) {
av_log(logctx, AV_LOG_WARNING, "No component for role %s found\n", role);
return AVERROR_ENCODER_NOT_FOUND;
}
components = av_mallocz(sizeof(char*) * num);
if (!components)
return AVERROR(ENOMEM);
for (i = 0; i < num; i++) {
components[i] = av_mallocz(OMX_MAX_STRINGNAME_SIZE);
if (!components) {
ret = AVERROR(ENOMEM);
goto end;
}
}
omx_context->ptr_GetComponentsOfRole((OMX_STRING) role, &num, (OMX_U8**) components);
av_strlcpy(str, components[0], str_size);
end:
for (i = 0; i < num; i++)
av_free(components[i]);
av_free(components);
return ret;
}
static av_cold int wait_for_state(OMXCodecContext *s, OMX_STATETYPE state)
{
int ret = 0;
pthread_mutex_lock(&s->state_mutex);
while (s->state != state && s->error == OMX_ErrorNone)
pthread_cond_wait(&s->state_cond, &s->state_mutex);
if (s->error != OMX_ErrorNone)
ret = AVERROR_ENCODER_NOT_FOUND;
pthread_mutex_unlock(&s->state_mutex);
return ret;
}
static av_cold int omx_component_init(AVCodecContext *avctx, const char *role)
{
OMXCodecContext *s = avctx->priv_data;
OMX_PARAM_COMPONENTROLETYPE role_params = { 0 };
OMX_PORT_PARAM_TYPE video_port_params = { 0 };
OMX_PARAM_PORTDEFINITIONTYPE in_port_params = { 0 }, out_port_params = { 0 };
OMX_VIDEO_PARAM_PORTFORMATTYPE video_port_format = { 0 };
OMX_VIDEO_PARAM_BITRATETYPE vid_param_bitrate = { 0 };
OMX_ERRORTYPE err;
int i;
s->version.s.nVersionMajor = 1;
s->version.s.nVersionMinor = 1;
s->version.s.nRevision = 2;
err = s->omx_context->ptr_GetHandle(&s->handle, s->component_name, s, (OMX_CALLBACKTYPE*) &callbacks);
if (err != OMX_ErrorNone) {
av_log(avctx, AV_LOG_ERROR, "OMX_GetHandle(%s) failed: %x\n", s->component_name, err);
return AVERROR_UNKNOWN;
}
// This one crashes the mediaserver on qcom, if used over IOMX
INIT_STRUCT(role_params);
av_strlcpy(role_params.cRole, role, sizeof(role_params.cRole));
// Intentionally ignore errors on this one
OMX_SetParameter(s->handle, OMX_IndexParamStandardComponentRole, &role_params);
INIT_STRUCT(video_port_params);
err = OMX_GetParameter(s->handle, OMX_IndexParamVideoInit, &video_port_params);
CHECK(err);
s->in_port = s->out_port = -1;
for (i = 0; i < video_port_params.nPorts; i++) {
int port = video_port_params.nStartPortNumber + i;
OMX_PARAM_PORTDEFINITIONTYPE port_params = { 0 };
INIT_STRUCT(port_params);
port_params.nPortIndex = port;
err = OMX_GetParameter(s->handle, OMX_IndexParamPortDefinition, &port_params);
if (err != OMX_ErrorNone) {
av_log(avctx, AV_LOG_WARNING, "port %d error %x\n", port, err);
break;
}
if (port_params.eDir == OMX_DirInput && s->in_port < 0) {
in_port_params = port_params;
s->in_port = port;
} else if (port_params.eDir == OMX_DirOutput && s->out_port < 0) {
out_port_params = port_params;
s->out_port = port;
}
}
if (s->in_port < 0 || s->out_port < 0) {
av_log(avctx, AV_LOG_ERROR, "No in or out port found (in %d out %d)\n", s->in_port, s->out_port);
return AVERROR_UNKNOWN;
}
s->color_format = 0;
for (i = 0; ; i++) {
INIT_STRUCT(video_port_format);
video_port_format.nIndex = i;
video_port_format.nPortIndex = s->in_port;
if (OMX_GetParameter(s->handle, OMX_IndexParamVideoPortFormat, &video_port_format) != OMX_ErrorNone)
break;
if (video_port_format.eColorFormat == OMX_COLOR_FormatYUV420Planar ||
video_port_format.eColorFormat == OMX_COLOR_FormatYUV420PackedPlanar) {
s->color_format = video_port_format.eColorFormat;
break;
}
}
if (s->color_format == 0) {
av_log(avctx, AV_LOG_ERROR, "No supported pixel formats (%d formats available)\n", i);
return AVERROR_UNKNOWN;
}
in_port_params.bEnabled = OMX_TRUE;
in_port_params.bPopulated = OMX_FALSE;
in_port_params.eDomain = OMX_PortDomainVideo;
in_port_params.format.video.pNativeRender = NULL;
in_port_params.format.video.bFlagErrorConcealment = OMX_FALSE;
in_port_params.format.video.eColorFormat = s->color_format;
s->stride = avctx->width;
s->plane_size = avctx->height;
// If specific codecs need to manually override the stride/plane_size,
// that can be done here.
in_port_params.format.video.nStride = s->stride;
in_port_params.format.video.nSliceHeight = s->plane_size;
in_port_params.format.video.nFrameWidth = avctx->width;
in_port_params.format.video.nFrameHeight = avctx->height;
if (avctx->framerate.den > 0 && avctx->framerate.num > 0)
in_port_params.format.video.xFramerate = (1 << 16) * avctx->framerate.num / avctx->framerate.den;
else
in_port_params.format.video.xFramerate = (1 << 16) * avctx->time_base.den / avctx->time_base.num;
err = OMX_SetParameter(s->handle, OMX_IndexParamPortDefinition, &in_port_params);
CHECK(err);
err = OMX_GetParameter(s->handle, OMX_IndexParamPortDefinition, &in_port_params);
CHECK(err);
s->stride = in_port_params.format.video.nStride;
s->plane_size = in_port_params.format.video.nSliceHeight;
s->num_in_buffers = in_port_params.nBufferCountActual;
err = OMX_GetParameter(s->handle, OMX_IndexParamPortDefinition, &out_port_params);
out_port_params.bEnabled = OMX_TRUE;
out_port_params.bPopulated = OMX_FALSE;
out_port_params.eDomain = OMX_PortDomainVideo;
out_port_params.format.video.pNativeRender = NULL;
out_port_params.format.video.nFrameWidth = avctx->width;
out_port_params.format.video.nFrameHeight = avctx->height;
out_port_params.format.video.nStride = 0;
out_port_params.format.video.nSliceHeight = 0;
out_port_params.format.video.nBitrate = avctx->bit_rate;
out_port_params.format.video.xFramerate = in_port_params.format.video.xFramerate;
out_port_params.format.video.bFlagErrorConcealment = OMX_FALSE;
if (avctx->codec->id == AV_CODEC_ID_MPEG4)
out_port_params.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4;
else if (avctx->codec->id == AV_CODEC_ID_H264)
out_port_params.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
err = OMX_SetParameter(s->handle, OMX_IndexParamPortDefinition, &out_port_params);
CHECK(err);
err = OMX_GetParameter(s->handle, OMX_IndexParamPortDefinition, &out_port_params);
CHECK(err);
s->num_out_buffers = out_port_params.nBufferCountActual;
INIT_STRUCT(vid_param_bitrate);
vid_param_bitrate.nPortIndex = s->out_port;
vid_param_bitrate.eControlRate = OMX_Video_ControlRateVariable;
vid_param_bitrate.nTargetBitrate = avctx->bit_rate;
err = OMX_SetParameter(s->handle, OMX_IndexParamVideoBitrate, &vid_param_bitrate);
if (err != OMX_ErrorNone)
av_log(avctx, AV_LOG_WARNING, "Unable to set video bitrate parameter\n");
if (avctx->codec->id == AV_CODEC_ID_H264) {
OMX_VIDEO_PARAM_AVCTYPE avc = { 0 };
INIT_STRUCT(avc);
avc.nPortIndex = s->out_port;
err = OMX_GetParameter(s->handle, OMX_IndexParamVideoAvc, &avc);
CHECK(err);
avc.nBFrames = 0;
avc.nPFrames = avctx->gop_size - 1;
err = OMX_SetParameter(s->handle, OMX_IndexParamVideoAvc, &avc);
CHECK(err);
}
err = OMX_SendCommand(s->handle, OMX_CommandStateSet, OMX_StateIdle, NULL);
CHECK(err);
s->in_buffer_headers = av_mallocz(sizeof(OMX_BUFFERHEADERTYPE*) * s->num_in_buffers);
s->free_in_buffers = av_mallocz(sizeof(OMX_BUFFERHEADERTYPE*) * s->num_in_buffers);
s->out_buffer_headers = av_mallocz(sizeof(OMX_BUFFERHEADERTYPE*) * s->num_out_buffers);
s->done_out_buffers = av_mallocz(sizeof(OMX_BUFFERHEADERTYPE*) * s->num_out_buffers);
if (!s->in_buffer_headers || !s->free_in_buffers || !s->out_buffer_headers || !s->done_out_buffers)
return AVERROR(ENOMEM);
for (i = 0; i < s->num_in_buffers && err == OMX_ErrorNone; i++) {
if (s->input_zerocopy)
err = OMX_UseBuffer(s->handle, &s->in_buffer_headers[i], s->in_port, s, in_port_params.nBufferSize, NULL);
else
err = OMX_AllocateBuffer(s->handle, &s->in_buffer_headers[i], s->in_port, s, in_port_params.nBufferSize);
if (err == OMX_ErrorNone)
s->in_buffer_headers[i]->pAppPrivate = s->in_buffer_headers[i]->pOutputPortPrivate = NULL;
}
CHECK(err);
s->num_in_buffers = i;
for (i = 0; i < s->num_out_buffers && err == OMX_ErrorNone; i++)
err = OMX_AllocateBuffer(s->handle, &s->out_buffer_headers[i], s->out_port, s, out_port_params.nBufferSize);
CHECK(err);
s->num_out_buffers = i;
if (wait_for_state(s, OMX_StateIdle) < 0) {
av_log(avctx, AV_LOG_ERROR, "Didn't get OMX_StateIdle\n");
return AVERROR_UNKNOWN;
}
err = OMX_SendCommand(s->handle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
CHECK(err);
if (wait_for_state(s, OMX_StateExecuting) < 0) {
av_log(avctx, AV_LOG_ERROR, "Didn't get OMX_StateExecuting\n");
return AVERROR_UNKNOWN;
}
for (i = 0; i < s->num_out_buffers && err == OMX_ErrorNone; i++)
err = OMX_FillThisBuffer(s->handle, s->out_buffer_headers[i]);
if (err != OMX_ErrorNone) {
for (; i < s->num_out_buffers; i++)
s->done_out_buffers[s->num_done_out_buffers++] = s->out_buffer_headers[i];
}
for (i = 0; i < s->num_in_buffers; i++)
s->free_in_buffers[s->num_free_in_buffers++] = s->in_buffer_headers[i];
return err != OMX_ErrorNone ? AVERROR_UNKNOWN : 0;
}
static av_cold void cleanup(OMXCodecContext *s)
{
int i, executing;
pthread_mutex_lock(&s->state_mutex);
executing = s->state == OMX_StateExecuting;
pthread_mutex_unlock(&s->state_mutex);
if (executing) {
OMX_SendCommand(s->handle, OMX_CommandStateSet, OMX_StateIdle, NULL);
wait_for_state(s, OMX_StateIdle);
OMX_SendCommand(s->handle, OMX_CommandStateSet, OMX_StateLoaded, NULL);
for (i = 0; i < s->num_in_buffers; i++) {
OMX_BUFFERHEADERTYPE *buffer = get_buffer(&s->input_mutex, &s->input_cond,
&s->num_free_in_buffers, s->free_in_buffers, 1);
if (s->input_zerocopy)
buffer->pBuffer = NULL;
OMX_FreeBuffer(s->handle, s->in_port, buffer);
}
for (i = 0; i < s->num_out_buffers; i++) {
OMX_BUFFERHEADERTYPE *buffer = get_buffer(&s->output_mutex, &s->output_cond,
&s->num_done_out_buffers, s->done_out_buffers, 1);
OMX_FreeBuffer(s->handle, s->out_port, buffer);
}
wait_for_state(s, OMX_StateLoaded);
}
if (s->handle) {
s->omx_context->ptr_FreeHandle(s->handle);
s->handle = NULL;
}
omx_deinit(s->omx_context);
s->omx_context = NULL;
if (s->mutex_cond_inited) {
pthread_cond_destroy(&s->state_cond);
pthread_mutex_destroy(&s->state_mutex);
pthread_cond_destroy(&s->input_cond);
pthread_mutex_destroy(&s->input_mutex);
pthread_cond_destroy(&s->output_cond);
pthread_mutex_destroy(&s->output_mutex);
s->mutex_cond_inited = 0;
}
av_freep(&s->in_buffer_headers);
av_freep(&s->out_buffer_headers);
av_freep(&s->free_in_buffers);
av_freep(&s->done_out_buffers);
av_freep(&s->output_buf);
}
static av_cold int omx_encode_init(AVCodecContext *avctx)
{
OMXCodecContext *s = avctx->priv_data;
int ret = AVERROR_ENCODER_NOT_FOUND;
const char *role;
OMX_BUFFERHEADERTYPE *buffer;
OMX_ERRORTYPE err;
#if CONFIG_OMX_RPI
s->input_zerocopy = 1;
#endif
s->omx_context = omx_init(avctx, s->libname, s->libprefix);
if (!s->omx_context)
return AVERROR_ENCODER_NOT_FOUND;
pthread_mutex_init(&s->state_mutex, NULL);
pthread_cond_init(&s->state_cond, NULL);
pthread_mutex_init(&s->input_mutex, NULL);
pthread_cond_init(&s->input_cond, NULL);
pthread_mutex_init(&s->output_mutex, NULL);
pthread_cond_init(&s->output_cond, NULL);
s->mutex_cond_inited = 1;
s->avctx = avctx;
s->state = OMX_StateLoaded;
s->error = OMX_ErrorNone;
switch (avctx->codec->id) {
case AV_CODEC_ID_MPEG4:
role = "video_encoder.mpeg4";
break;
case AV_CODEC_ID_H264:
role = "video_encoder.avc";
break;
default:
return AVERROR(ENOSYS);
}
if ((ret = find_component(s->omx_context, avctx, role, s->component_name, sizeof(s->component_name))) < 0)
goto fail;
av_log(avctx, AV_LOG_INFO, "Using %s\n", s->component_name);
if ((ret = omx_component_init(avctx, role)) < 0)
goto fail;
if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
while (1) {
buffer = get_buffer(&s->output_mutex, &s->output_cond,
&s->num_done_out_buffers, s->done_out_buffers, 1);
if (buffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG) {
if ((ret = av_reallocp(&avctx->extradata, avctx->extradata_size + buffer->nFilledLen + AV_INPUT_BUFFER_PADDING_SIZE)) < 0) {
avctx->extradata_size = 0;
goto fail;
}
memcpy(avctx->extradata + avctx->extradata_size, buffer->pBuffer + buffer->nOffset, buffer->nFilledLen);
avctx->extradata_size += buffer->nFilledLen;
memset(avctx->extradata + avctx->extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
}
err = OMX_FillThisBuffer(s->handle, buffer);
if (err != OMX_ErrorNone) {
append_buffer(&s->output_mutex, &s->output_cond,
&s->num_done_out_buffers, s->done_out_buffers, buffer);
av_log(avctx, AV_LOG_ERROR, "OMX_FillThisBuffer failed: %x\n", err);
ret = AVERROR_UNKNOWN;
goto fail;
}
if (avctx->codec->id == AV_CODEC_ID_H264) {
// For H264, the extradata can be returned in two separate buffers
// (the videocore encoder on raspberry pi does this);
// therefore check that we have got both SPS and PPS before continuing.
int nals[32] = { 0 };
int i;
for (i = 0; i + 4 < avctx->extradata_size; i++) {
if (!avctx->extradata[i + 0] &&
!avctx->extradata[i + 1] &&
!avctx->extradata[i + 2] &&
avctx->extradata[i + 3] == 1) {
nals[avctx->extradata[i + 4] & 0x1f]++;
}
}
if (nals[NAL_SPS] && nals[NAL_PPS])
break;
} else {
if (avctx->extradata_size > 0)
break;
}
}
}
return 0;
fail:
return ret;
}
static int omx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
OMXCodecContext *s = avctx->priv_data;
int ret = 0;
OMX_BUFFERHEADERTYPE* buffer;
OMX_ERRORTYPE err;
if (frame) {
uint8_t *dst[4];
int linesize[4];
int need_copy;
buffer = get_buffer(&s->input_mutex, &s->input_cond,
&s->num_free_in_buffers, s->free_in_buffers, 1);
buffer->nFilledLen = av_image_fill_arrays(dst, linesize, buffer->pBuffer, avctx->pix_fmt, s->stride, s->plane_size, 1);
if (s->input_zerocopy) {
uint8_t *src[4] = { NULL };
int src_linesize[4];
av_image_fill_arrays(src, src_linesize, frame->data[0], avctx->pix_fmt, s->stride, s->plane_size, 1);
if (frame->linesize[0] == src_linesize[0] &&
frame->linesize[1] == src_linesize[1] &&
frame->linesize[2] == src_linesize[2] &&
frame->data[1] == src[1] &&
frame->data[2] == src[2]) {
// If the input frame happens to have all planes stored contiguously,
// with the right strides, just clone the frame and set the OMX
// buffer header to point to it
AVFrame *local = av_frame_clone(frame);
if (!local) {
// Return the buffer to the queue so it's not lost
append_buffer(&s->input_mutex, &s->input_cond, &s->num_free_in_buffers, s->free_in_buffers, buffer);
return AVERROR(ENOMEM);
} else {
buffer->pAppPrivate = local;
buffer->pOutputPortPrivate = NULL;
buffer->pBuffer = local->data[0];
need_copy = 0;
}
} else {
// If not, we need to allocate a new buffer with the right
// size and copy the input frame into it.
uint8_t *buf = av_malloc(av_image_get_buffer_size(avctx->pix_fmt, s->stride, s->plane_size, 1));
if (!buf) {
// Return the buffer to the queue so it's not lost
append_buffer(&s->input_mutex, &s->input_cond, &s->num_free_in_buffers, s->free_in_buffers, buffer);
return AVERROR(ENOMEM);
} else {
buffer->pAppPrivate = buf;
// Mark that pAppPrivate is an av_malloc'ed buffer, not an AVFrame
buffer->pOutputPortPrivate = (void*) 1;
buffer->pBuffer = buf;
need_copy = 1;
buffer->nFilledLen = av_image_fill_arrays(dst, linesize, buffer->pBuffer, avctx->pix_fmt, s->stride, s->plane_size, 1);
}
}
} else {
need_copy = 1;
}
if (need_copy)
av_image_copy(dst, linesize, (const uint8_t**) frame->data, frame->linesize, avctx->pix_fmt, avctx->width, avctx->height);
buffer->nFlags = OMX_BUFFERFLAG_ENDOFFRAME;
buffer->nOffset = 0;
// Convert the timestamps to microseconds; some encoders can ignore
// the framerate and do VFR bit allocation based on timestamps.
buffer->nTimeStamp = to_omx_ticks(av_rescale_q(frame->pts, avctx->time_base, AV_TIME_BASE_Q));
err = OMX_EmptyThisBuffer(s->handle, buffer);
if (err != OMX_ErrorNone) {
append_buffer(&s->input_mutex, &s->input_cond, &s->num_free_in_buffers, s->free_in_buffers, buffer);
av_log(avctx, AV_LOG_ERROR, "OMX_EmptyThisBuffer failed: %x\n", err);
return AVERROR_UNKNOWN;
}
s->num_in_frames++;
}
while (!*got_packet && ret == 0) {
// Only wait for output if flushing and not all frames have been output
buffer = get_buffer(&s->output_mutex, &s->output_cond,
&s->num_done_out_buffers, s->done_out_buffers,
!frame && s->num_out_frames < s->num_in_frames);
if (!buffer)
break;
if (buffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG && avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
if ((ret = av_reallocp(&avctx->extradata, avctx->extradata_size + buffer->nFilledLen + AV_INPUT_BUFFER_PADDING_SIZE)) < 0) {
avctx->extradata_size = 0;
goto end;
}
memcpy(avctx->extradata + avctx->extradata_size, buffer->pBuffer + buffer->nOffset, buffer->nFilledLen);
avctx->extradata_size += buffer->nFilledLen;
memset(avctx->extradata + avctx->extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
} else {
if (buffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME)
s->num_out_frames++;
if (!(buffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) || !pkt->data) {
// If the output packet isn't preallocated, just concatenate everything in our
// own buffer
int newsize = s->output_buf_size + buffer->nFilledLen + AV_INPUT_BUFFER_PADDING_SIZE;
if ((ret = av_reallocp(&s->output_buf, newsize)) < 0) {
s->output_buf_size = 0;
goto end;
}
memcpy(s->output_buf + s->output_buf_size, buffer->pBuffer + buffer->nOffset, buffer->nFilledLen);
s->output_buf_size += buffer->nFilledLen;
if (buffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) {
if ((ret = av_packet_from_data(pkt, s->output_buf, s->output_buf_size)) < 0) {
av_freep(&s->output_buf);
s->output_buf_size = 0;
goto end;
}
s->output_buf = NULL;
s->output_buf_size = 0;
}
} else {
// End of frame, and the caller provided a preallocated frame
if ((ret = ff_alloc_packet(pkt, s->output_buf_size + buffer->nFilledLen)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size %d.\n",
(int)(s->output_buf_size + buffer->nFilledLen));
goto end;
}
memcpy(pkt->data, s->output_buf, s->output_buf_size);
memcpy(pkt->data + s->output_buf_size, buffer->pBuffer + buffer->nOffset, buffer->nFilledLen);
av_freep(&s->output_buf);
s->output_buf_size = 0;
}
if (buffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) {
ret = pkt->size;
pkt->pts = av_rescale_q(from_omx_ticks(buffer->nTimeStamp), AV_TIME_BASE_Q, avctx->time_base);
// We don't currently enable b-frames for the encoders, so set
// pkt->dts = pkt->pts. (The calling code behaves worse if the encoder
// doesn't set the dts).
pkt->dts = pkt->pts;
if (buffer->nFlags & OMX_BUFFERFLAG_SYNCFRAME)
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
}
}
end:
err = OMX_FillThisBuffer(s->handle, buffer);
if (err != OMX_ErrorNone) {
append_buffer(&s->output_mutex, &s->output_cond, &s->num_done_out_buffers, s->done_out_buffers, buffer);
av_log(avctx, AV_LOG_ERROR, "OMX_FillThisBuffer failed: %x\n", err);
ret = AVERROR_UNKNOWN;
}
}
return ret;
}
static av_cold int omx_encode_end(AVCodecContext *avctx)
{
OMXCodecContext *s = avctx->priv_data;
cleanup(s);
return 0;
}
#define OFFSET(x) offsetof(OMXCodecContext, x)
#define VDE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
{ "omx_libname", "OpenMAX library name", OFFSET(libname), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VDE },
{ "omx_libprefix", "OpenMAX library prefix", OFFSET(libprefix), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VDE },
{ "zerocopy", "Try to avoid copying input frames if possible", OFFSET(input_zerocopy), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ NULL }
};
static const enum AVPixelFormat omx_encoder_pix_fmts[] = {
AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE
};
static const AVClass omx_mpeg4enc_class = {
.class_name = "mpeg4_omx",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
};
AVCodec ff_mpeg4_omx_encoder = {
.name = "mpeg4_omx",
.long_name = NULL_IF_CONFIG_SMALL("OpenMAX IL MPEG4 video encoder"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_MPEG4,
.priv_data_size = sizeof(OMXCodecContext),
.init = omx_encode_init,
.encode2 = omx_encode_frame,
.close = omx_encode_end,
.pix_fmts = omx_encoder_pix_fmts,
.capabilities = AV_CODEC_CAP_DELAY,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
.priv_class = &omx_mpeg4enc_class,
};
static const AVClass omx_h264enc_class = {
.class_name = "h264_omx",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
};
AVCodec ff_h264_omx_encoder = {
.name = "h264_omx",
.long_name = NULL_IF_CONFIG_SMALL("OpenMAX IL H264 video encoder"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_H264,
.priv_data_size = sizeof(OMXCodecContext),
.init = omx_encode_init,
.encode2 = omx_encode_frame,
.close = omx_encode_end,
.pix_fmts = omx_encoder_pix_fmts,
.capabilities = AV_CODEC_CAP_DELAY,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
.priv_class = &omx_h264enc_class,
};
| darlyhellen/oto | NDKFFmpeg/jni/ffmpeg/libavcodec/omx.c | C | apache-2.0 | 37,337 | [
30522,
1013,
1008,
1008,
18168,
2595,
2678,
4372,
16044,
2099,
1008,
9385,
1006,
1039,
1007,
2249,
3235,
2358,
5668,
5558,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
21461,
8737,
13910,
1012,
1008,
1008,
21461,
8737,
13910,
2003,
2489,
4007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Hello, World
Tout framework digne de ce nom possède un exemple d'application "Hello World", alors ne dérogeons pas à la régle!
On commencera donc par décrire un "hello word" très très basique puis on détaillera les principes MVC appliqués à l'exemple.
## Au commencement il n'y avait rien...
La première chose à faire est de créer un controleur de telle sorte que Kohana puisse traiter une requête.
Créér le fichier `application/classes/controller/hello.php` dans votre répertoire application et ajoutez-y le code suivant:
<?php defined('SYSPATH') OR die('No Direct Script Access');
Class Controller_Hello extends Controller
{
function action_index()
{
echo 'hello, world!';
}
}
Voyons ce que signifient ces quelques lignes:
`<?php defined('SYSPATH') OR die('No Direct Script Access');`
: Vous devez sûrement reconnâitre le tag d'ouverture php (si ce n'est pas le cas alors il vous faut d'abord probablement vous [familiariser avec php](http://php.net)). Ce qui suit est un test permettant de s'assurer que le fichier est bien inclus par Kohana et lui seul. Cela permet d'interdire tout accès au fichier directement depuis une URL.
`Class Controller_Hello extends Controller`
: Cette ligne déclare notre controleur, chaque controleur doit être préfixé de `Controller_` et exprime un chemin vers le fichier ci-dessus où les répertoires sont séparés par des underscores (voir [Conventions et styles](about.conventions) pour plus d'informations). Chaque contrôleur doit hériter du controleur de base `Controller` qui fournit la structure standard de tout controleur.
`function action_index()`
: Cette ligne définit l'action "index" de notre controleur. Kohana essaiera d'appeler cette méthode si l'utilisateur n'en a spécifié aucune. (Voir [Routes, URLs et Liens](tutorials.urls))
`echo 'hello, world!';`
: Enfin cette dernière ligne magique affichera sous vos yeux ébahis le message souhaité!
Une fois le controleur créé, ouvrez voter navigateur préféré et rendez-vous à l'adresse `http://loaclhost/kohana/index.php/hello` et constatez le résultat:

## C'était pas mal, mais on peut faire mieux
Le chapitre précédent présente à quel point il est facile de créer une application extrêmement basique avec Kohana. Jusque-là tout va bien.
Si vous avez déjà entendu parler du concept MVC alors vous vous disez sans doute qu'afficher du contenu dans un controleur va à l'encontre du principe MVC.
La manière appropriée de coder avec un framework MVC est d'utiliser des _vues_ pour tout ce qui est lié à la présentation/forme de votre application et de laisser au controleur l'enchainement logique du traitement des requêtes.
Changeons donc le controleur:
<?php defined('SYSPATH') OR die('No Direct Script Access');
Class Controller_Hello extends Controller_Template
{
public $template = 'site';
function action_index()
{
$this->template->message = 'hello, world!';
}
}
`extends Controller_Template`
: nous héritons désormais du controleur template qui rend plus facile l'utilisation de vues au sein d'un controleur.
`public $template = 'site';`
: le controleur template doit connaitre le template que vous souhaitez utiliser. Il chargera alors automatiquement la vue en question et lui assignera l'objet Vue créé.
`$this->template->message = 'hello, world!';`
: `$this->template` est une référence vers l'objet Vue du template de notre site. Ce que l'on fait ici est assigner à la vue la variable "message" dont la valeur est "hello, world!".
Maintenant actualisez votre navigateur...
<div>{{userguide/examples/hello_world_error}}</div>
Kohana vous affiche une erreur au lieu du message fascinant qu'il devrait afficher. En regardant de plus près le message d'erreur on peut voir que la librairie View n'a pas été capable de trouver notre template, probablement parceque nous ne l'avons pas encore créé!
Créons donc notre vue en créant le fichier `application/views/site.php` avec le texte suivant:
<html>
<head>
<title>We've got a message for you!</title>
<style type="text/css">
body {font-family: Georgia;}
h1 {font-style: italic;}
</style>
</head>
<body>
<h1><?php echo $message; ?></h1>
<p>We just wanted to say it! :)</p>
</body>
</html>
Maintenant si vous ré-actualisez, vous devriez voir apparaitre ce qu'il faut:

## A moi la gloire et l'argent!
Dans ce tutorial on a abordé comment créer un controleur et utiliser une vue pour séparer la logique de la présentation.
Evidemment l'exemple choisi est une introduction basique à Kohana et n'effleure même pas les possibilités infinies de Kohana ;). | erosb/cyclonephp | tools/userguide/guide/fr-fr/tutorials.helloworld.md | Markdown | bsd-3-clause | 4,848 | [
30522,
1001,
7592,
1010,
2088,
2000,
4904,
7705,
10667,
2638,
2139,
8292,
2053,
2213,
25751,
3207,
4895,
4654,
6633,
10814,
1040,
1005,
4646,
1000,
7592,
2088,
1000,
1010,
2632,
5668,
11265,
4315,
23884,
5644,
14674,
1037,
2474,
19723,
2571... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#!/usr/bin/env python
# *-* coding: UTF-8 *-*
"""
Organizaţia Internaţională a Aviaţiei Civile propune un alfabet în care
fiecărei litere îi este asignat un cuvânt pentru a evita problemele în
înțelegerea mesajelor critice.
Pentru a se păstra un istoric al conversațiilor s-a decis transcrierea lor
conform următoarelor reguli:
- fiecare cuvânt este scris pe o singură linie
- literele din alfabet sunt separate de o virgulă
Următoarea sarcină ți-a fost asignată:
Scrie un program care să primească un fișier ce conține mesajul
brut (scris folosind alfabetul ICAO) și generează un fișier
numit icao_intrare ce va conține mesajul inițial.
Mai jos găsiți un dicționar ce conține o versiune a alfabetului ICAO:
"""
ICAO = {
'a': 'alfa', 'b': 'bravo', 'c': 'charlie', 'd': 'delta', 'e': 'echo',
'f': 'foxtrot', 'g': 'golf', 'h': 'hotel', 'i': 'india', 'j': 'juliett',
'k': 'kilo', 'l': 'lima', 'm': 'mike', 'n': 'november', 'o': 'oscar',
'p': 'papa', 'q': 'quebec', 'r': 'romeo', 's': 'sierra', 't': 'tango',
'u': 'uniform', 'v': 'victor', 'w': 'whiskey', 'x': 'x-ray', 'y': 'yankee',
'z': 'zulu'
}
def din_icao(fisier_intrare):
"""Funcția va primi calea către fișierul ce conține mesajul brut și
va genera un fișier numit icao_intrare ce va conține mesajul inițial.
"""
try:
in_file = open(fisier_intrare, 'r')
content = in_file.read()
in_file.close()
except IOError:
print "Error! Could not open file."
return
final_message = ''
for line in content.splitlines():
for word in line.split():
for key, value in ICAO.iteritems():
if value == word:
final_message += key
final_message += ' '
print final_message
if __name__ == "__main__":
din_icao("mesaj.icao")
| iulianbute/labs | python/solutii/iulian_andrei/icao/from_icao.py | Python | mit | 1,888 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
4372,
2615,
18750,
1001,
1008,
1011,
1008,
16861,
1024,
21183,
2546,
1011,
1022,
1008,
1011,
1008,
1000,
1000,
1000,
5812,
21335,
10711,
2248,
2050,
1037,
20704,
2401,
9515,
2072,
2942,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using System;
using System.IO;
using System.IO.Compression;
using System.Linq;
using Nancy;
using Nancy.Bootstrapper;
using NLog;
using NzbDrone.Common.EnvironmentInfo;
namespace Lidarr.Http.Extensions.Pipelines
{
public class GzipCompressionPipeline : IRegisterNancyPipeline
{
private readonly Logger _logger;
public int Order => 0;
private readonly Action<Action<Stream>, Stream> _writeGZipStream;
public GzipCompressionPipeline(Logger logger)
{
_logger = logger;
// On Mono GZipStream/DeflateStream leaks memory if an exception is thrown, use an intermediate buffer in that case.
_writeGZipStream = PlatformInfo.IsMono ? WriteGZipStreamMono : (Action<Action<Stream>, Stream>)WriteGZipStream;
}
public void Register(IPipelines pipelines)
{
pipelines.AfterRequest.AddItemToEndOfPipeline(CompressResponse);
}
private void CompressResponse(NancyContext context)
{
var request = context.Request;
var response = context.Response;
try
{
if (
response.Contents != Response.NoBody
&& !response.ContentType.Contains("image")
&& !response.ContentType.Contains("font")
&& request.Headers.AcceptEncoding.Any(x => x.Contains("gzip"))
&& !AlreadyGzipEncoded(response)
&& !ContentLengthIsTooSmall(response))
{
var contents = response.Contents;
response.Headers["Content-Encoding"] = "gzip";
response.Contents = responseStream => _writeGZipStream(contents, responseStream);
}
}
catch (Exception ex)
{
_logger.Error(ex, "Unable to gzip response");
throw;
}
}
private static void WriteGZipStreamMono(Action<Stream> innerContent, Stream targetStream)
{
using (var membuffer = new MemoryStream())
{
WriteGZipStream(innerContent, membuffer);
membuffer.Position = 0;
membuffer.CopyTo(targetStream);
}
}
private static void WriteGZipStream(Action<Stream> innerContent, Stream targetStream)
{
using (var gzip = new GZipStream(targetStream, CompressionMode.Compress, true))
using (var buffered = new BufferedStream(gzip, 8192))
{
innerContent.Invoke(buffered);
}
}
private static bool ContentLengthIsTooSmall(Response response)
{
var contentLength = response.Headers.TryGetValue("Content-Length", out var value) ? value : null;
if (contentLength != null && long.Parse(contentLength) < 1024)
{
return true;
}
return false;
}
private static bool AlreadyGzipEncoded(Response response)
{
var contentEncoding = response.Headers.TryGetValue("Content-Encoding", out var value) ? value : null;
if (contentEncoding == "gzip")
{
return true;
}
return false;
}
}
}
| lidarr/Lidarr | src/Lidarr.Http/Extensions/Pipelines/GZipPipeline.cs | C# | gpl-3.0 | 3,335 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
22834,
1025,
2478,
2291,
1012,
22834,
1012,
13379,
1025,
2478,
2291,
1012,
11409,
4160,
1025,
2478,
7912,
1025,
2478,
7912,
1012,
6879,
6494,
18620,
1025,
2478,
17953,
8649,
1025,
2478,
20008,
2497... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 Carlos Andres Jimenez <apps@carlosandresjimenez.co>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package co.carlosandresjimenez.android.gotit.api;
import java.util.ArrayList;
import co.carlosandresjimenez.android.gotit.beans.Answer;
import co.carlosandresjimenez.android.gotit.beans.Checkin;
import co.carlosandresjimenez.android.gotit.beans.Question;
import co.carlosandresjimenez.android.gotit.beans.User;
import retrofit.http.Body;
import retrofit.http.GET;
import retrofit.http.POST;
import retrofit.http.Query;
/**
* This interface defines an API for a GotItSvc. The
* interface is used to provide a contract for client/server
* interactions. The interface is annotated with Retrofit
* annotations so that clients can automatically convert the
* results into objects.
*
* @author Carlos Andres Jimenez
*/
public interface GotItSvcApi {
String ID_PARAMETER = "id";
String USER_PATH = "/user";
String REGISTER_PATH = USER_PATH + "/register";
String CHECKIN_BASE_PATH = "/checkin";
String CHECKIN_HISTORY_PATH = CHECKIN_BASE_PATH + "/history";
String CHECKIN_GRAPH_PATH = CHECKIN_BASE_PATH + "/graph";
String QUESTION_PATH = CHECKIN_BASE_PATH + "/question";
String ANSWER_PATH = CHECKIN_BASE_PATH + "/answer";
String FOLLOWING_BASE_PATH = "/following";
String FOLLOWING_LIST_PATH = FOLLOWING_BASE_PATH + "/list";
String FOLLOWING_TIMELINE_PATH = FOLLOWING_BASE_PATH + "/timeline";
String APPROVE_PARAMETER = "approved";
String FOLLOWBACK_PARAMETER = "followback";
String FOLLOW_BASE_PATH = "/follow";
String FOLLOW_REQUESTS_PATH = FOLLOW_BASE_PATH + "/requests";
String FOLLOW_APPROVE_PATH = FOLLOW_BASE_PATH + "/approve";
@GET(USER_PATH)
User getUserDetails(
@Query(ID_PARAMETER) String userId);
@POST(REGISTER_PATH)
String registerUser(@Body User u);
@GET(QUESTION_PATH)
ArrayList<Question> getAllQuestions();
@POST(ANSWER_PATH)
int saveAnswers(@Body ArrayList<Answer> answers);
@GET(CHECKIN_HISTORY_PATH)
ArrayList<Checkin> getCheckinHistory();
@GET(CHECKIN_BASE_PATH)
ArrayList<Question> getCheckinAnswers(@Query(ID_PARAMETER) String checkinId);
@GET(FOLLOWING_LIST_PATH)
ArrayList<User> getFollowingList();
@GET(FOLLOW_REQUESTS_PATH)
ArrayList<User> getFollowRequestsList();
@GET(FOLLOWING_TIMELINE_PATH)
ArrayList<Checkin> getFollowingTimeline();
@GET(FOLLOW_BASE_PATH)
int follow(@Query(ID_PARAMETER) String followEmail);
@GET(FOLLOW_APPROVE_PATH)
int changeFollowerStatus(@Query(ID_PARAMETER) String followerEmail,
@Query(APPROVE_PARAMETER) boolean approve,
@Query(FOLLOWBACK_PARAMETER) boolean followBack);
@GET(CHECKIN_GRAPH_PATH)
ArrayList<Answer> getGraphData(@Query(ID_PARAMETER) String email);
}
| crlsndrsjmnz/GotIt | app/src/main/java/co/carlosandresjimenez/android/gotit/api/GotItSvcApi.java | Java | mit | 3,932 | [
30522,
1013,
1008,
1008,
1996,
10210,
6105,
1006,
10210,
1007,
1008,
1008,
9385,
1006,
1039,
1007,
2325,
5828,
15614,
22790,
1026,
18726,
1030,
5828,
5685,
6072,
4478,
3549,
9351,
1012,
2522,
1028,
1008,
1008,
6656,
2003,
2182,
3762,
4379,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
if not exist client git clone -b next http://buildserver.urbackup.org/git/urbackup_frontend_wx client
cd client
git fetch
git checkout -b next origin/next
git checkout next
git reset --hard
git pull
| BlackHawkDesign/urbackup_backend | checkout_client.bat | Batchfile | gpl-3.0 | 210 | [
30522,
2065,
2025,
4839,
7396,
21025,
2102,
17598,
1011,
1038,
2279,
8299,
1024,
1013,
1013,
16473,
2121,
6299,
1012,
24471,
5963,
6279,
1012,
8917,
1013,
21025,
2102,
1013,
24471,
5963,
6279,
1035,
2392,
10497,
1035,
1059,
2595,
7396,
3729... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#
# Copyright (c) 2018 ITO SOFT DESIGN Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
<<-DOC
Here is a sample configuration.
Puts your configuration to config/plugins/ifttt.yml
web_hook_key: your_web_hook_key
events:
- name: event1
trigger:
device: M0
type: raise_and_fall
value_type: bool
params:
value1: error
value2: unit1
- name: event2
trigger:
device: D0
value: word
type: changed
params:
value1: temperature
value2: 値2
value3: 値3
- name: event3
trigger:
device: D2
value: dword
type: interval
time: 10.0
params:
value1: @value
value2: 値2
value3: 値3
DOC
require 'net/https'
module LadderDrive
module Emulator
class IftttPlugin < Plugin
def initialize plc
super #plc
return if disabled?
@values = {}
@times = {}
@worker_queue = Queue.new
setup
end
def run_cycle plc
return if disabled?
config[:events].each do |event|
begin
next unless self.triggered?(event)
v = trigger_state_for(event).value
@worker_queue.push event:event[:name], payload:event[:params].dup || {}, value:v
rescue => e
puts $!
puts $@
p e
end
end if config[:events]
end
def disabled?
return false unless super
unless config[:web_hook_key]
puts "ERROR: IftttPlugin requires web_hook_key."
false
else
super
end
end
private
def setup
Thread.start {
thread_proc
}
end
def thread_proc
while arg = @worker_queue.pop
begin
uri = URI.parse("https://maker.ifttt.com/trigger/#{arg[:event]}/with/key/#{config[:web_hook_key]}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
req = Net::HTTP::Post.new(uri.path)
payload = arg[:payload]
payload.keys.each do |key|
payload[key] = arg[:value] if payload[key] == "__value__"
end
req.set_form_data(payload)
http.request(req)
rescue => e
# TODO: Resend if it fails.
p e
end
end
end
end
end
end
def plugin_ifttt_init plc
@ifttt_plugin = LadderDrive::Emulator::IftttPlugin.new plc
end
def plugin_ifttt_exec plc
@ifttt_plugin.run_cycle plc
end
| ito-soft-design/escalator | plugins/ifttt_plugin.rb | Ruby | mit | 3,429 | [
30522,
1001,
1001,
9385,
1006,
1039,
1007,
2760,
23333,
3730,
2640,
4297,
1012,
1001,
1001,
6656,
2003,
2182,
3762,
4379,
1010,
2489,
1997,
3715,
1010,
2000,
2151,
2711,
11381,
1001,
1037,
6100,
1997,
2023,
4007,
1998,
3378,
12653,
6764,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
Copyright (C) 2013 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "filepropsdialog.h"
#include "ui_file-props.h"
#include "icontheme.h"
#include "utilities.h"
#include "fileoperation.h"
#include <QStringBuilder>
#include <QStringListModel>
#include <QMessageBox>
#include <qdial.h>
#include <sys/types.h>
#include <time.h>
#define DIFFERENT_UIDS ((uid)-1)
#define DIFFERENT_GIDS ((gid)-1)
#define DIFFERENT_PERMS ((mode_t)-1)
using namespace Fm;
enum {
ACCESS_NO_CHANGE = 0,
ACCESS_READ_ONLY,
ACCESS_READ_WRITE,
ACCESS_FORBID
};
FilePropsDialog::FilePropsDialog(FmFileInfoList* files, QWidget* parent, Qt::WindowFlags f):
QDialog(parent, f),
fileInfos_(fm_file_info_list_ref(files)),
singleType(fm_file_info_list_is_same_type(files)),
singleFile(fm_file_info_list_get_length(files) == 1 ? true:false),
fileInfo(fm_file_info_list_peek_head(files)),
mimeType(NULL) {
setAttribute(Qt::WA_DeleteOnClose);
ui = new Ui::FilePropsDialog();
ui->setupUi(this);
if(singleType) {
mimeType = fm_mime_type_ref(fm_file_info_get_mime_type(fileInfo));
}
FmPathList* paths = fm_path_list_new_from_file_info_list(files);
deepCountJob = fm_deep_count_job_new(paths, FM_DC_JOB_DEFAULT);
fm_path_list_unref(paths);
initGeneralPage();
initPermissionsPage();
}
FilePropsDialog::~FilePropsDialog() {
delete ui;
if(fileInfos_)
fm_file_info_list_unref(fileInfos_);
if(deepCountJob)
g_object_unref(deepCountJob);
if(fileSizeTimer) {
fileSizeTimer->stop();
delete fileSizeTimer;
fileSizeTimer = NULL;
}
}
void FilePropsDialog::initApplications() {
if(singleType && mimeType && !fm_file_info_is_dir(fileInfo)) {
ui->openWith->setMimeType(mimeType);
}
else {
ui->openWith->hide();
ui->openWithLabel->hide();
}
}
void FilePropsDialog::initPermissionsPage() {
// ownership handling
// get owner/group and mode of the first file in the list
uid = fm_file_info_get_uid(fileInfo);
gid = fm_file_info_get_gid(fileInfo);
mode_t mode = fm_file_info_get_mode(fileInfo);
ownerPerm = (mode & (S_IRUSR|S_IWUSR|S_IXUSR));
groupPerm = (mode & (S_IRGRP|S_IWGRP|S_IXGRP));
otherPerm = (mode & (S_IROTH|S_IWOTH|S_IXOTH));
execPerm = (mode & (S_IXUSR|S_IXGRP|S_IXOTH));
allNative = fm_file_info_is_native(fileInfo);
hasDir = S_ISDIR(mode);
// check if all selected files belongs to the same owner/group or have the same mode
// at the same time, check if all files are on native unix filesystems
GList* l;
for(l = fm_file_info_list_peek_head_link(fileInfos_)->next; l; l = l->next) {
FmFileInfo* fi = FM_FILE_INFO(l->data);
if(allNative && !fm_file_info_is_native(fi))
allNative = false; // not all of the files are native
mode_t fi_mode = fm_file_info_get_mode(fi);
if(S_ISDIR(fi_mode))
hasDir = true; // the files list contains dir(s)
if(uid != DIFFERENT_UIDS && uid != fm_file_info_get_uid(fi))
uid = DIFFERENT_UIDS; // not all files have the same owner
if(gid != DIFFERENT_GIDS && gid != fm_file_info_get_gid(fi))
gid = DIFFERENT_GIDS; // not all files have the same owner group
if(ownerPerm != DIFFERENT_PERMS && ownerPerm != (fi_mode & (S_IRUSR|S_IWUSR|S_IXUSR)))
ownerPerm = DIFFERENT_PERMS; // not all files have the same permission for owner
if(groupPerm != DIFFERENT_PERMS && groupPerm != (fi_mode & (S_IRGRP|S_IWGRP|S_IXGRP)))
groupPerm = DIFFERENT_PERMS; // not all files have the same permission for grop
if(otherPerm != DIFFERENT_PERMS && otherPerm != (fi_mode & (S_IROTH|S_IWOTH|S_IXOTH)))
otherPerm = DIFFERENT_PERMS; // not all files have the same permission for other
if(execPerm != DIFFERENT_PERMS && execPerm != (fi_mode & (S_IXUSR|S_IXGRP|S_IXOTH)))
execPerm = DIFFERENT_PERMS; // not all files have the same executable permission
}
// init owner/group
initOwner();
// if all files are of the same type, and some of them are dirs => all of the items are dirs
// rwx values have different meanings for dirs
// Let's make it clear for the users
// init combo boxes for file permissions here
QStringList comboItems;
comboItems.append("---"); // no change
if(singleType && hasDir) { // all files are dirs
comboItems.append(tr("View folder content"));
comboItems.append(tr("View and modify folder content"));
ui->executable->hide();
}
else { //not all of the files are dirs
comboItems.append(tr("Read"));
comboItems.append(tr("Read and write"));
}
comboItems.append(tr("Forbidden"));
QStringListModel* comboModel = new QStringListModel(comboItems, this);
ui->ownerPerm->setModel(comboModel);
ui->groupPerm->setModel(comboModel);
ui->otherPerm->setModel(comboModel);
// owner
ownerPermSel = ACCESS_NO_CHANGE;
if(ownerPerm != DIFFERENT_PERMS) { // permissions for owner are the same among all files
if(ownerPerm & S_IRUSR) { // can read
if(ownerPerm & S_IWUSR) // can write
ownerPermSel = ACCESS_READ_WRITE;
else
ownerPermSel = ACCESS_READ_ONLY;
}
else {
if((ownerPerm & S_IWUSR) == 0) // cannot read or write
ownerPermSel = ACCESS_FORBID;
}
}
ui->ownerPerm->setCurrentIndex(ownerPermSel);
// owner and group
groupPermSel = ACCESS_NO_CHANGE;
if(groupPerm != DIFFERENT_PERMS) { // permissions for owner are the same among all files
if(groupPerm & S_IRGRP) { // can read
if(groupPerm & S_IWGRP) // can write
groupPermSel = ACCESS_READ_WRITE;
else
groupPermSel = ACCESS_READ_ONLY;
}
else {
if((groupPerm & S_IWGRP) == 0) // cannot read or write
groupPermSel = ACCESS_FORBID;
}
}
ui->groupPerm->setCurrentIndex(groupPermSel);
// other
otherPermSel = ACCESS_NO_CHANGE;
if(otherPerm != DIFFERENT_PERMS) { // permissions for owner are the same among all files
if(otherPerm & S_IROTH) { // can read
if(otherPerm & S_IWOTH) // can write
otherPermSel = ACCESS_READ_WRITE;
else
otherPermSel = ACCESS_READ_ONLY;
}
else {
if((otherPerm & S_IWOTH) == 0) // cannot read or write
otherPermSel = ACCESS_FORBID;
}
}
ui->otherPerm->setCurrentIndex(otherPermSel);
// set the checkbox to partially checked state
// when owner, group, and other have different executable flags set.
// some of them have exec, and others do not have.
execCheckState = Qt::PartiallyChecked;
if(execPerm != DIFFERENT_PERMS) { // if all files have the same executable permission
// check if the files are all executable
if((mode & (S_IXUSR|S_IXGRP|S_IXOTH)) == (S_IXUSR|S_IXGRP|S_IXOTH)) {
// owner, group, and other all have exec permission.
execCheckState = Qt::Checked;
}
else if((mode & (S_IXUSR|S_IXGRP|S_IXOTH)) == 0) {
// owner, group, and other all have no exec permission
execCheckState = Qt::Unchecked;
}
}
ui->executable->setCheckState(execCheckState);
}
void FilePropsDialog::initGeneralPage() {
// update UI
if(singleType) { // all files are of the same mime-type
FmIcon* icon = NULL;
// FIXME: handle custom icons for some files
// FIXME: display special property pages for special files or
// some specified mime-types.
if(singleFile) { // only one file is selected.
icon = fm_file_info_get_icon(fileInfo);
}
if(mimeType) {
if(!icon) // get an icon from mime type if needed
icon = fm_mime_type_get_icon(mimeType);
ui->fileType->setText(QString::fromUtf8(fm_mime_type_get_desc(mimeType)));
ui->mimeType->setText(QString::fromUtf8(fm_mime_type_get_type(mimeType)));
}
if(icon) {
ui->iconButton->setIcon(IconTheme::icon(icon));
}
if(singleFile && fm_file_info_is_symlink(fileInfo)) {
ui->target->setText(QString::fromUtf8(fm_file_info_get_target(fileInfo)));
}
else {
ui->target->hide();
ui->targetLabel->hide();
}
} // end if(singleType)
else { // not singleType, multiple files are selected at the same time
ui->fileType->setText(tr("Files of different types"));
ui->target->hide();
ui->targetLabel->hide();
}
// FIXME: check if all files has the same parent dir, mtime, or atime
if(singleFile) { // only one file is selected
FmPath* parent_path = fm_path_get_parent(fm_file_info_get_path(fileInfo));
char* parent_str = parent_path ? fm_path_display_name(parent_path, true) : NULL;
ui->fileName->setText(QString::fromUtf8(fm_file_info_get_disp_name(fileInfo)));
if(parent_str) {
ui->location->setText(QString::fromUtf8(parent_str));
g_free(parent_str);
}
else
ui->location->clear();
ui->lastModified->setText(QString::fromUtf8(fm_file_info_get_disp_mtime(fileInfo)));
// FIXME: need to encapsulate this in an libfm API.
time_t atime;
struct tm tm;
atime = fm_file_info_get_atime(fileInfo);
localtime_r(&atime, &tm);
char buf[128];
strftime(buf, sizeof(buf), "%x %R", &tm);
ui->lastAccessed->setText(QString::fromUtf8(buf));
}
else {
ui->fileName->setText(tr("Multiple Files"));
ui->fileName->setEnabled(false);
}
initApplications(); // init applications combo box
// calculate total file sizes
fileSizeTimer = new QTimer(this);
connect(fileSizeTimer, SIGNAL(timeout()), SLOT(onFileSizeTimerTimeout()));
fileSizeTimer->start(600);
g_signal_connect(deepCountJob, "finished", G_CALLBACK(onDeepCountJobFinished), this);
fm_job_run_async(FM_JOB(deepCountJob));
}
/*static */ void FilePropsDialog::onDeepCountJobFinished(FmDeepCountJob* job, FilePropsDialog* pThis) {
pThis->onFileSizeTimerTimeout(); // update file size display
// free the job
g_object_unref(pThis->deepCountJob);
pThis->deepCountJob = NULL;
// stop the timer
if(pThis->fileSizeTimer) {
pThis->fileSizeTimer->stop();
delete pThis->fileSizeTimer;
pThis->fileSizeTimer = NULL;
}
}
void FilePropsDialog::onFileSizeTimerTimeout() {
if(deepCountJob && !fm_job_is_cancelled(FM_JOB(deepCountJob))) {
char size_str[128];
fm_file_size_to_str(size_str, sizeof(size_str), deepCountJob->total_size,
fm_config->si_unit);
// FIXME:
// OMG! It's really unbelievable that Qt developers only implement
// QObject::tr(... int n). GNU gettext developers are smarter and
// they use unsigned long instead of int.
// We cannot use Qt here to handle plural forms. So sad. :-(
QString str = QString::fromUtf8(size_str) %
QString(" (%1 B)").arg(deepCountJob->total_size);
// tr(" (%n) byte(s)", "", deepCountJob->total_size);
ui->fileSize->setText(str);
fm_file_size_to_str(size_str, sizeof(size_str), deepCountJob->total_ondisk_size,
fm_config->si_unit);
str = QString::fromUtf8(size_str) %
QString(" (%1 B)").arg(deepCountJob->total_ondisk_size);
// tr(" (%n) byte(s)", "", deepCountJob->total_ondisk_size);
ui->onDiskSize->setText(str);
}
}
void FilePropsDialog::accept() {
// applications
if(mimeType && ui->openWith->isChanged()) {
GAppInfo* currentApp = ui->openWith->selectedApp();
g_app_info_set_as_default_for_type(currentApp, fm_mime_type_get_type(mimeType), NULL);
}
// check if chown or chmod is needed
guint32 newUid = uidFromName(ui->owner->text());
guint32 newGid = gidFromName(ui->ownerGroup->text());
bool needChown = (newUid != uid || newGid != gid);
int newOwnerPermSel = ui->ownerPerm->currentIndex();
int newGroupPermSel = ui->groupPerm->currentIndex();
int newOtherPermSel = ui->otherPerm->currentIndex();
Qt::CheckState newExecCheckState = ui->executable->checkState();
bool needChmod = ((newOwnerPermSel != ownerPermSel) ||
(newGroupPermSel != groupPermSel) ||
(newOtherPermSel != otherPermSel) ||
(newExecCheckState != execCheckState));
if(needChmod || needChown) {
FmPathList* paths = fm_path_list_new_from_file_info_list(fileInfos_);
FileOperation* op = new FileOperation(FileOperation::ChangeAttr, paths);
fm_path_list_unref(paths);
if(needChown) {
// don't do chown if new uid/gid and the original ones are actually the same.
if(newUid == uid)
newUid = -1;
if(newGid == gid)
newGid = -1;
op->setChown(newUid, newGid);
}
if(needChmod) {
mode_t newMode = 0;
mode_t newModeMask = 0;
// FIXME: we need to make sure that folders with "r" permission also have "x"
// at the same time. Otherwise, it's not able to browse the folder later.
if(newOwnerPermSel != ownerPermSel && newOwnerPermSel != ACCESS_NO_CHANGE) {
// owner permission changed
newModeMask |= (S_IRUSR|S_IWUSR); // affect user bits
if(newOwnerPermSel == ACCESS_READ_ONLY)
newMode |= S_IRUSR;
else if(newOwnerPermSel == ACCESS_READ_WRITE)
newMode |= (S_IRUSR|S_IWUSR);
}
if(newGroupPermSel != groupPermSel && newGroupPermSel != ACCESS_NO_CHANGE) {
qDebug("newGroupPermSel: %d", newGroupPermSel);
// group permission changed
newModeMask |= (S_IRGRP|S_IWGRP); // affect group bits
if(newGroupPermSel == ACCESS_READ_ONLY)
newMode |= S_IRGRP;
else if(newGroupPermSel == ACCESS_READ_WRITE)
newMode |= (S_IRGRP|S_IWGRP);
}
if(newOtherPermSel != otherPermSel && newOtherPermSel != ACCESS_NO_CHANGE) {
// other permission changed
newModeMask |= (S_IROTH|S_IWOTH); // affect other bits
if(newOtherPermSel == ACCESS_READ_ONLY)
newMode |= S_IROTH;
else if(newOtherPermSel == ACCESS_READ_WRITE)
newMode |= (S_IROTH|S_IWOTH);
}
if(newExecCheckState != execCheckState && newExecCheckState != Qt::PartiallyChecked) {
// executable state changed
newModeMask |= (S_IXUSR|S_IXGRP|S_IXOTH);
if(newExecCheckState == Qt::Checked)
newMode |= (S_IXUSR|S_IXGRP|S_IXOTH);
}
op->setChmod(newMode, newModeMask);
if(hasDir) { // if there are some dirs in our selected files
QMessageBox::StandardButton r = QMessageBox::question(this,
tr("Apply changes"),
tr("Do you want to recursively apply these changes to all files and sub-folders?"),
QMessageBox::Yes|QMessageBox::No);
if(r == QMessageBox::Yes)
op->setRecursiveChattr(true);
}
}
op->setAutoDestroy(true);
op->run();
}
QDialog::accept();
}
void FilePropsDialog::initOwner() {
if(allNative) {
if(uid != DIFFERENT_UIDS)
ui->owner->setText(uidToName(uid));
if(gid != DIFFERENT_GIDS)
ui->ownerGroup->setText(gidToName(gid));
if(geteuid() != 0) { // on local filesystems, only root can do chown.
ui->owner->setEnabled(false);
ui->ownerGroup->setEnabled(false);
}
}
}
| MoonLightDE/MoonLightDE | src/file-manager/libfm-qt/filepropsdialog.cpp | C++ | gpl-3.0 | 15,744 | [
30522,
1013,
1008,
9385,
1006,
1039,
1007,
2286,
4291,
15419,
6300,
2063,
1006,
7473,
2386,
1007,
1026,
7473,
2386,
1012,
1056,
2860,
1030,
20917,
4014,
1012,
4012,
1028,
2023,
2565,
2003,
2489,
4007,
1025,
2017,
2064,
2417,
2923,
3089,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
define([], function() {
/**
* A specialized version of `_.map` for arrays without support for callback
* shorthands or `this` binding.
*
* @private
* @param {Array} array The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns the new mapped array.
*/
function arrayMap(array, iteratee) {
var index = -1,
length = array.length,
result = Array(length);
while (++index < length) {
result[index] = iteratee(array[index], index, array);
}
return result;
}
return arrayMap;
});
| tomek-f/shittets | require-js-amd/require-zepto-lodash/static/js/lib/lodash-amd/internal/arrayMap.js | JavaScript | mit | 609 | [
30522,
9375,
1006,
1031,
1033,
1010,
3853,
1006,
1007,
1063,
1013,
1008,
1008,
1008,
1037,
7772,
2544,
1997,
1036,
1035,
1012,
4949,
1036,
2005,
27448,
2302,
2490,
2005,
2655,
5963,
1008,
2460,
11774,
2015,
2030,
1036,
2023,
1036,
8031,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jQuery(function(){
'use strict';
var Test={};
var tests=[];
var messages={
success: 'Success',
failed: 'FAILED',
pending: 'Pending...'
};
var classes = {
success: 'success',
failed: 'danger',
pending: 'warning'
}
var row_id_prefix = 'tests_td_';
var textProperty = (document.createElement('span').textContent !== undefined) ? 'textContent' : 'innerText';
var row_template = document.createElement('tr');
row_template.appendChild(document.createElement('td'));
row_template.appendChild(document.createElement('td'));
row_template.appendChild(document.createElement('td'));
var tbody = document.getElementById('results_tbody');
Test.add = function(group, func){
var row;
tests.push({group: group, func: func});
row = row_template.cloneNode(true);
row.id = 'tests_td_' + (tests.length-1);
row.getElementsByTagName('td')[0][textProperty] = group;
tbody.appendChild(row);
};
function TestController(row){
this._row = row;
this._asserted = false;
this._status='pending';
}
var assertionFailed = {};
TestController.prototype._setStatus=function(status, extra){
var status_td = this._row.getElementsByTagName('td')[1];
var display_string = messages[status];
if(extra){
display_string += " (" + extra + ")";
}
status_td[textProperty] = display_string;
status_td.className = classes[status];
this._status = status;
};
TestController.prototype._setDescription=function(desc){
var desc_td = this._row.getElementsByTagName('td')[2];
desc_td[textProperty] = desc;
}
TestController.prototype.assert = function(value, desc){
this._asserted = true;
if(value !== true){
this._setStatus('failed');
this._setDescription('Assertion failed: ' + desc);
throw assertionFailed;
}
};
TestController.prototype.must_throw = function(func, desc){
var thrown = false;
if(!desc){
desc = 'expected to throw exception';
}
try{
func();
}catch(e){
thrown = true;
}
this.assert(thrown, desc);
};
TestController.prototype.must_not_be_called = function(desc){
var test_controller = this;
if(!desc){
desc = 'function is not called';
}
return function(){
test_controller.assert(false, desc);
};
}
Test.run = function(){
var i = 0, num_tests = tests.length;
var t;
for(; i< num_tests; ++i){
t = new TestController(document.getElementById('tests_td_' + i));
t._setStatus('pending');
try{
tests[i].func(t);
if(t._status === 'pending'){
if(t._asserted){
//Success all tests
t._setStatus('success');
}else{
t._setDescription('No assertion was given.');
}
}
}catch(e){
if(e !== assertionFailed){
t._setStatus('failed','exception');
t._setDescription(e.message);
}
}
}
};
window.Test=Test;
});
| jkr2255/grouped_callbacks | test_lib.js | JavaScript | mit | 2,809 | [
30522,
1046,
4226,
2854,
1006,
3853,
1006,
1007,
1063,
1005,
2224,
9384,
1005,
1025,
13075,
3231,
1027,
1063,
1065,
1025,
13075,
5852,
1027,
1031,
1033,
1025,
13075,
7696,
1027,
1063,
3112,
1024,
1005,
3112,
1005,
1010,
3478,
1024,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2005 JBoss Inc
*
* 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 org.drools.reteoo;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.List;
import org.drools.RuleBaseConfiguration;
import org.drools.base.ClassObjectType;
import org.drools.base.DroolsQuery;
import org.drools.base.ValueType;
import org.drools.builder.conf.LRUnlinkingOption;
import org.drools.common.AbstractRuleBase;
import org.drools.common.BaseNode;
import org.drools.common.DroolsObjectInputStream;
import org.drools.common.EventFactHandle;
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
import org.drools.common.Memory;
import org.drools.common.NodeMemory;
import org.drools.common.PropagationContextImpl;
import org.drools.common.UpdateContext;
import org.drools.core.util.Iterator;
import org.drools.core.util.ObjectHashSet;
import org.drools.core.util.ObjectHashSet.ObjectEntry;
import org.drools.marshalling.impl.MarshallerReaderContext;
import org.drools.marshalling.impl.MarshallerWriteContext;
import org.drools.marshalling.impl.PersisterEnums;
import org.drools.marshalling.impl.ProtobufMessages;
import org.drools.marshalling.impl.ProtobufMessages.Timers.ExpireTimer;
import org.drools.marshalling.impl.ProtobufMessages.Timers.Timer;
import org.drools.marshalling.impl.TimersInputMarshaller;
import org.drools.marshalling.impl.TimersOutputMarshaller;
import org.drools.reteoo.ReteooWorkingMemory.WorkingMemoryReteExpireAction;
import org.drools.reteoo.RuleRemovalContext.CleanupAdapter;
import org.drools.reteoo.builder.BuildContext;
import org.drools.reteoo.compiled.CompiledNetwork;
import org.drools.rule.Declaration;
import org.drools.rule.EntryPoint;
import org.drools.rule.EvalCondition;
import org.drools.spi.Constraint;
import org.drools.spi.ObjectType;
import org.drools.spi.PropagationContext;
import org.drools.time.Job;
import org.drools.time.JobContext;
import org.drools.time.JobHandle;
import org.drools.time.TimerService;
import org.drools.time.impl.DefaultJobHandle;
import org.drools.time.impl.PointInTimeTrigger;
/**
* <code>ObjectTypeNodes<code> are responsible for filtering and propagating the matching
* fact assertions propagated from the <code>Rete</code> node using <code>ObjectType</code> interface.
* <p/>
* The assert and retract methods do not attempt to filter as this is the role of the <code>Rete</code>
* node which builds up a cache of matching <code>ObjectTypdeNodes</code>s for each asserted object, using
* the <code>matches(Object object)</code> method. Incorrect propagation in these methods is not checked and
* will result in <code>ClassCastExpcections</code> later on in the network.
* <p/>
* Filters <code>Objects</code> coming from the <code>Rete</code> using a
* <code>ObjectType</code> semantic module.
*
* @see Rete
*/
public class ObjectTypeNode extends ObjectSource
implements
ObjectSink,
Externalizable,
NodeMemory
{
// ------------------------------------------------------------
// Instance members
// ------------------------------------------------------------
private static final long serialVersionUID = 510l;
/**
* The <code>ObjectType</code> semantic module.
*/
private ObjectType objectType;
private boolean objectMemoryEnabled;
private long expirationOffset = -1;
public static final transient ExpireJob job = new ExpireJob();
private boolean queryNode;
private CompiledNetwork compiledNetwork;
/* always dirty after serialisation */
private transient boolean dirty;
/* reset counter when dirty */
private transient int otnIdCounter;
public int getOtnIdCounter() {
return otnIdCounter;
}
/** @see LRUnlinkingOption */
private boolean lrUnlinkingEnabled = false;
public ObjectTypeNode() {
}
/**
* Construct given a semantic <code>ObjectType</code> and the provided
* unique id. All <code>ObjectTypdeNode</code> have node memory.
*
* @param id The unique id for the node.
* @param objectType The semantic object-type differentiator.
*/
public ObjectTypeNode(final int id,
final EntryPointNode source,
final ObjectType objectType,
final BuildContext context) {
super( id,
context.getPartitionId(),
context.getRuleBase().getConfiguration().isMultithreadEvaluation(),
source,
context.getRuleBase().getConfiguration().getAlphaNodeHashingThreshold() );
this.objectType = objectType;
this.lrUnlinkingEnabled = context.getRuleBase().getConfiguration().isLRUnlinkingEnabled();
setObjectMemoryEnabled( context.isObjectTypeNodeMemoryEnabled() );
if ( ClassObjectType.DroolsQuery_ObjectType.isAssignableFrom( objectType ) ) {
queryNode = true;
}
this.dirty = true;
}
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
super.readExternal( in );
objectType = (ObjectType) in.readObject();
// this is here as not all objectTypeNodes used ClassObjectTypes in packages (i.e. rules with those nodes did not exist yet)
// and thus have no wiring targets
if ( objectType instanceof ClassObjectType ) {
objectType = ((AbstractRuleBase) ((DroolsObjectInputStream) in).getRuleBase()).getClassFieldAccessorCache().getClassObjectType( (ClassObjectType) objectType );
}
objectMemoryEnabled = in.readBoolean();
expirationOffset = in.readLong();
lrUnlinkingEnabled = in.readBoolean();
queryNode = in.readBoolean();
dirty = true;
}
public void writeExternal(ObjectOutput out) throws IOException {
super.writeExternal( out );
out.writeObject( objectType );
out.writeBoolean( objectMemoryEnabled );
out.writeLong( expirationOffset );
out.writeBoolean( lrUnlinkingEnabled );
out.writeBoolean( queryNode );
}
/**
* Retrieve the semantic <code>ObjectType</code> differentiator.
*
* @return The semantic <code>ObjectType</code> differentiator.
*/
public ObjectType getObjectType() {
return this.objectType;
}
@Override
public long calculateDeclaredMask(List<String> settableProperties) {
return 0;
}
public boolean isAssignableFrom(final ObjectType objectType) {
return this.objectType.isAssignableFrom( objectType );
}
public void setCompiledNetwork(CompiledNetwork compiledNetwork) {
this.compiledNetwork = compiledNetwork;
this.compiledNetwork.setObjectTypeNode( this );
}
/**
* Propagate the <code>FactHandleimpl</code> through the <code>Rete</code> network. All
* <code>FactHandleImpl</code> should be remembered in the node memory, so that later runtime rule attachmnents
* can have the matched facts propagated to them.
*
* @param factHandle The fact handle.
* @param object The object to assert.
* @param workingMemory The working memory session.
*/
public void assertObject(final InternalFactHandle factHandle,
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
if ( dirty ) {
otnIdCounter = 0;
updateTupleSinkId( this, this );
dirty = false;
}
if ( objectMemoryEnabled && !(queryNode && !((DroolsQuery) factHandle.getObject()).isOpen()) ) {
final ObjectTypeNodeMemory memory = (ObjectTypeNodeMemory) workingMemory.getNodeMemory( this );
memory.memory.add( factHandle,
false );
}
if ( compiledNetwork != null ) {
compiledNetwork.assertObject( factHandle,
context,
workingMemory );
} else {
context.setCurrentPropagatingOTN( this );
this.sink.propagateAssertObject( factHandle,
context,
workingMemory );
}
if ( context.getReaderContext() == null && this.objectType.isEvent() && this.expirationOffset >= 0 && this.expirationOffset != Long.MAX_VALUE ) {
// schedule expiration
WorkingMemoryReteExpireAction expire = new WorkingMemoryReteExpireAction( factHandle,
this );
TimerService clock = workingMemory.getTimerService();
long nextTimestamp = Math.max( clock.getCurrentTime() + this.expirationOffset,
((EventFactHandle) factHandle).getStartTimestamp() + this.expirationOffset );
JobContext jobctx = new ExpireJobContext( expire,
workingMemory );
JobHandle handle = clock.scheduleJob( job,
jobctx,
new PointInTimeTrigger( nextTimestamp,
null,
null ) );
jobctx.setJobHandle( handle );
}
}
/**
* Retract the <code>FactHandleimpl</code> from the <code>Rete</code> network. Also remove the
* <code>FactHandleImpl</code> from the node memory.
*
* @param rightTuple The fact handle.
* @param object The object to assert.
* @param workingMemory The working memory session.
*/
public void retractObject(final InternalFactHandle factHandle,
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
if ( dirty ) {
otnIdCounter = 0;
updateTupleSinkId( this, this );
dirty = false;
}
if ( objectMemoryEnabled && !(queryNode && !((DroolsQuery) factHandle.getObject()).isOpen()) ) {
final ObjectTypeNodeMemory memory = (ObjectTypeNodeMemory) workingMemory.getNodeMemory( this );
memory.memory.remove( factHandle );
}
for ( RightTuple rightTuple = factHandle.getFirstRightTuple(); rightTuple != null; rightTuple = rightTuple.getHandleNext() ) {
rightTuple.getRightTupleSink().retractRightTuple( rightTuple,
context,
workingMemory );
}
factHandle.clearRightTuples();
for ( LeftTuple leftTuple = factHandle.getFirstLeftTuple(); leftTuple != null; leftTuple = leftTuple.getLeftParentNext() ) {
leftTuple.getLeftTupleSink().retractLeftTuple( leftTuple,
context,
workingMemory );
}
factHandle.clearLeftTuples();
}
public void modifyObject(InternalFactHandle factHandle,
ModifyPreviousTuples modifyPreviousTuples,
PropagationContext context,
InternalWorkingMemory workingMemory) {
if ( dirty ) {
otnIdCounter = 0;
updateTupleSinkId( this, this );
dirty = false;
}
context.setObjectType( objectType );
if ( compiledNetwork != null ) {
compiledNetwork.modifyObject( factHandle,
modifyPreviousTuples,
context,
workingMemory );
} else {
this.sink.propagateModifyObject( factHandle,
modifyPreviousTuples,
context,
workingMemory );
}
}
public void updateSink(final ObjectSink sink,
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
if ( lrUnlinkingEnabled ) {
// Update sink taking into account L&R unlinking peculiarities
updateLRUnlinking( sink, context, workingMemory );
} else {
// Regular updateSink
final ObjectTypeNodeMemory memory = (ObjectTypeNodeMemory) workingMemory.getNodeMemory( this );
Iterator it = memory.memory.iterator();
for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
sink.assertObject( (InternalFactHandle) entry.getValue(),
context,
workingMemory );
}
}
}
/**
* When L&R Unlinking is enabled, updateSink() is used to populate
* a node's memory, but it has to take into account if it's propagating.
*/
private void updateLRUnlinking(final ObjectSink sink,
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
final ObjectTypeNodeMemory memory = (ObjectTypeNodeMemory) workingMemory.getNodeMemory( this );
Iterator it = memory.memory.iterator();
InternalFactHandle ctxHandle = (InternalFactHandle) context.getFactHandle();
if ( !context.isPropagating( this ) ||
(context.isPropagating( this ) && context.shouldPropagateAll()) ) {
for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
// Assert everything
sink.assertObject( (InternalFactHandle) entry.getValue(),
context,
workingMemory );
}
} else {
for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
InternalFactHandle handle = (InternalFactHandle) entry.getValue();
// Exclude the current fact propagation
if ( handle.getId() != ctxHandle.getId() ) {
sink.assertObject( handle,
context,
workingMemory );
}
}
}
}
/**
* Rete needs to know that this ObjectTypeNode has been added
*/
public void attach( BuildContext context ) {
this.source.addObjectSink( this );
if (context == null) {
return;
}
// we need to call updateSink on Rete, because someone
// might have already added facts matching this ObjectTypeNode
// to working memories
for ( InternalWorkingMemory workingMemory : context.getWorkingMemories() ) {
final PropagationContextImpl propagationContext = new PropagationContextImpl( workingMemory.getNextPropagationIdCounter(),
PropagationContext.RULE_ADDITION,
null,
null,
null );
propagationContext.setEntryPoint( ((EntryPointNode) this.source).getEntryPoint() );
this.source.updateSink( this,
propagationContext,
workingMemory );
}
}
public void networkUpdated(UpdateContext updateContext) {
this.dirty = true;
}
private static void updateTupleSinkId( ObjectTypeNode otn,
ObjectSource source ) {
for ( ObjectSink sink : source.sink.getSinks() ) {
if ( sink instanceof BetaNode ) {
((BetaNode) sink).setRightInputOtnId( otn.nextOtnId() );
} else if ( sink instanceof LeftInputAdapterNode ) {
for ( LeftTupleSink liaChildSink : ((LeftInputAdapterNode) sink).getSinkPropagator().getSinks() ) {
liaChildSink.setLeftInputOtnId( otn.nextOtnId() );
}
} else if ( sink instanceof AlphaNode ) {
updateTupleSinkId( otn, (AlphaNode) sink );
}
}
}
public int nextOtnId() {
return otnIdCounter++;
}
/**
* OTN needs to override remove to avoid releasing the node ID, since OTN are
* never removed from the rulebase in the current implementation
*
* @inheritDoc
* @see org.drools.common.BaseNode#remove(org.drools.reteoo.RuleRemovalContext, org.drools.reteoo.ReteooBuilder, org.drools.common.BaseNode, org.drools.common.InternalWorkingMemory[])
*/
public void remove(RuleRemovalContext context,
ReteooBuilder builder,
BaseNode node,
InternalWorkingMemory[] workingMemories) {
doRemove( context,
builder,
node,
workingMemories );
}
/**
* OTN needs to override remove to avoid releasing the node ID, since OTN are
* never removed from the rulebase in the current implementation
*/
protected void doRemove(final RuleRemovalContext context,
final ReteooBuilder builder,
final BaseNode node,
final InternalWorkingMemory[] workingMemories) {
if ( context.getCleanupAdapter() != null ) {
for ( InternalWorkingMemory workingMemory : workingMemories ) {
CleanupAdapter adapter = context.getCleanupAdapter();
final ObjectTypeNodeMemory memory = (ObjectTypeNodeMemory) workingMemory.getNodeMemory( this );
Iterator it = memory.memory.iterator();
for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
InternalFactHandle handle = (InternalFactHandle) entry.getValue();
for ( LeftTuple leftTuple = handle.getFirstLeftTuple(); leftTuple != null; leftTuple = leftTuple.getLeftParentNext() ) {
adapter.cleanUp( leftTuple,
workingMemory );
}
}
}
context.setCleanupAdapter( null );
}
if ( !node.isInUse() ) {
removeObjectSink( (ObjectSink) node );
}
}
/**
* Creates memory for the node using PrimitiveLongMap as its optimised for storage and reteivals of Longs.
* However PrimitiveLongMap is not ideal for spase data. So it should be monitored incase its more optimal
* to switch back to a standard HashMap.
*/
public Memory createMemory(final RuleBaseConfiguration config) {
return new ObjectTypeNodeMemory();
}
public boolean isObjectMemoryEnabled() {
return this.objectMemoryEnabled;
}
public void setObjectMemoryEnabled(boolean objectMemoryEnabled) {
this.objectMemoryEnabled = objectMemoryEnabled;
}
public String toString() {
return "[ObjectTypeNode(" + this.id + ")::" + ((EntryPointNode) this.source).getEntryPoint() + " objectType=" + this.objectType + " expiration=" + this.expirationOffset + "ms ]";
}
/**
* Uses he hashCode() of the underlying ObjectType implementation.
*/
public int hashCode() {
return this.objectType.hashCode() ^ this.source.hashCode();
}
public boolean equals(final Object object) {
if ( this == object ) {
return true;
}
if ( object == null || !(object instanceof ObjectTypeNode) ) {
return false;
}
final ObjectTypeNode other = (ObjectTypeNode) object;
return this.objectType.equals( other.objectType ) && this.source.equals( other.source );
}
private boolean usesDeclaration(final Constraint[] constraints) {
boolean usesDecl = false;
for ( int i = 0; !usesDecl && i < constraints.length; i++ ) {
usesDecl = this.usesDeclaration( constraints[i] );
}
return usesDecl;
}
private boolean usesDeclaration(final Constraint constraint) {
boolean usesDecl = false;
final Declaration[] declarations = constraint.getRequiredDeclarations();
for ( int j = 0; !usesDecl && j < declarations.length; j++ ) {
usesDecl = (declarations[j].getPattern().getObjectType() == this.objectType);
}
return usesDecl;
}
private boolean usesDeclaration(final EvalCondition condition) {
boolean usesDecl = false;
final Declaration[] declarations = condition.getRequiredDeclarations();
for ( int j = 0; !usesDecl && j < declarations.length; j++ ) {
usesDecl = (declarations[j].getPattern().getObjectType() == this.objectType);
}
return usesDecl;
}
/**
* @return the entryPoint
*/
public EntryPoint getEntryPoint() {
return ((EntryPointNode) this.source).getEntryPoint();
}
public long getExpirationOffset() {
return expirationOffset;
}
public void setExpirationOffset(long expirationOffset) {
this.expirationOffset = expirationOffset;
if ( !this.objectType.getValueType().equals( ValueType.QUERY_TYPE ) ) {
if ( this.expirationOffset > 0 ) {
// override memory enabled settings
this.setObjectMemoryEnabled( true );
} else if ( this.expirationOffset == 0 ) {
// disable memory
this.setObjectMemoryEnabled( false );
}
}
}
public static class ExpireJob
implements
Job {
public void execute(JobContext ctx) {
ExpireJobContext context = (ExpireJobContext) ctx;
context.workingMemory.queueWorkingMemoryAction( context.expireAction );
}
}
public static class ExpireJobContext
implements
JobContext,
Externalizable {
public WorkingMemoryReteExpireAction expireAction;
public InternalWorkingMemory workingMemory;
public JobHandle handle;
/**
* @param workingMemory
* @param behavior
* @param behaviorContext
*/
public ExpireJobContext(WorkingMemoryReteExpireAction expireAction,
InternalWorkingMemory workingMemory) {
super();
this.expireAction = expireAction;
this.workingMemory = workingMemory;
}
public JobHandle getJobHandle() {
return this.handle;
}
public void setJobHandle(JobHandle jobHandle) {
this.handle = jobHandle;
}
public WorkingMemoryReteExpireAction getExpireAction() {
return expireAction;
}
public void setExpireAction(WorkingMemoryReteExpireAction expireAction) {
this.expireAction = expireAction;
}
public InternalWorkingMemory getWorkingMemory() {
return workingMemory;
}
public void setWorkingMemory(InternalWorkingMemory workingMemory) {
this.workingMemory = workingMemory;
}
public JobHandle getHandle() {
return handle;
}
public void setHandle(JobHandle handle) {
this.handle = handle;
}
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
//this.behavior = (O)
}
public void writeExternal(ObjectOutput out) throws IOException {
// TODO Auto-generated method stub
}
}
public static class ExpireJobContextTimerOutputMarshaller
implements
TimersOutputMarshaller {
public void write(JobContext jobCtx,
MarshallerWriteContext outputCtx) throws IOException {
outputCtx.writeShort( PersisterEnums.EXPIRE_TIMER );
// ExpireJob, no state
ExpireJobContext ejobCtx = (ExpireJobContext) jobCtx;
WorkingMemoryReteExpireAction expireAction = ejobCtx.getExpireAction();
outputCtx.writeInt( expireAction.getFactHandle().getId() );
outputCtx.writeUTF( expireAction.getNode().getEntryPoint().getEntryPointId() );
outputCtx.writeUTF( ((ClassObjectType) expireAction.getNode().getObjectType()).getClassType().getName() );
DefaultJobHandle jobHandle = (DefaultJobHandle) ejobCtx.getJobHandle();
PointInTimeTrigger trigger = (PointInTimeTrigger) jobHandle.getTimerJobInstance().getTrigger();
outputCtx.writeLong( trigger.hasNextFireTime().getTime() );
}
public ProtobufMessages.Timers.Timer serialize(JobContext jobCtx,
MarshallerWriteContext outputCtx) {
// ExpireJob, no state
ExpireJobContext ejobCtx = ( ExpireJobContext ) jobCtx;
WorkingMemoryReteExpireAction expireAction = ejobCtx.getExpireAction();
DefaultJobHandle jobHandle = ( DefaultJobHandle ) ejobCtx.getJobHandle();
PointInTimeTrigger trigger = ( PointInTimeTrigger ) jobHandle.getTimerJobInstance().getTrigger();
return ProtobufMessages.Timers.Timer.newBuilder()
.setType( ProtobufMessages.Timers.TimerType.EXPIRE )
.setExpire( ProtobufMessages.Timers.ExpireTimer.newBuilder()
.setHandleId( expireAction.getFactHandle().getId() )
.setEntryPointId( expireAction.getNode().getEntryPoint().getEntryPointId() )
.setClassName( ((ClassObjectType)expireAction.getNode().getObjectType()).getClassType().getName() )
.setNextFireTimestamp( trigger.hasNextFireTime().getTime() )
.build() )
.build();
}
}
public static class ExpireJobContextTimerInputMarshaller
implements
TimersInputMarshaller {
public void read(MarshallerReaderContext inCtx) throws IOException,
ClassNotFoundException {
InternalFactHandle factHandle = inCtx.handles.get( inCtx.readInt() );
String entryPointId = inCtx.readUTF();
EntryPointNode epn = ((ReteooRuleBase) inCtx.wm.getRuleBase()).getRete().getEntryPointNode( new EntryPoint( entryPointId ) );
String className = inCtx.readUTF();
Class< ? > cls = ((ReteooRuleBase) inCtx.wm.getRuleBase()).getRootClassLoader().loadClass( className );
ObjectTypeNode otn = epn.getObjectTypeNodes().get( new ClassObjectType( cls ) );
long nextTimeStamp = inCtx.readLong();
TimerService clock = inCtx.wm.getTimerService();
JobContext jobctx = new ExpireJobContext( new WorkingMemoryReteExpireAction( factHandle, otn ),
inCtx.wm );
JobHandle handle = clock.scheduleJob( job,
jobctx,
new PointInTimeTrigger( nextTimeStamp,
null,
null ) );
jobctx.setJobHandle( handle );
}
public void deserialize(MarshallerReaderContext inCtx,
Timer _timer) throws ClassNotFoundException {
ExpireTimer _expire = _timer.getExpire();
InternalFactHandle factHandle = inCtx.handles.get( _expire.getHandleId() );
EntryPointNode epn = ((ReteooRuleBase)inCtx.wm.getRuleBase()).getRete().getEntryPointNode( new EntryPoint( _expire.getEntryPointId() ) );
Class<?> cls = ((ReteooRuleBase)inCtx.wm.getRuleBase()).getRootClassLoader().loadClass( _expire.getClassName() );
ObjectTypeNode otn = epn.getObjectTypeNodes().get( new ClassObjectType( cls ) );
TimerService clock = inCtx.wm.getTimerService();
JobContext jobctx = new ExpireJobContext( new WorkingMemoryReteExpireAction(factHandle, otn),
inCtx.wm );
JobHandle handle = clock.scheduleJob( job,
jobctx,
new PointInTimeTrigger( _expire.getNextFireTimestamp(),
null,
null ) );
jobctx.setJobHandle( handle );
}
}
public void byPassModifyToBetaNode(InternalFactHandle factHandle,
ModifyPreviousTuples modifyPreviousTuples,
PropagationContext context,
InternalWorkingMemory workingMemory) {
throw new UnsupportedOperationException( "This should never get called, as the PropertyReactive first happens at the AlphaNode" );
}
public static class ObjectTypeNodeMemory implements Memory, Externalizable {
public ObjectHashSet memory = new ObjectHashSet();
public short getNodeType() {
return NodeTypeEnums.ObjectTypeNode;
}
public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject( memory );
}
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
memory = (ObjectHashSet) in.readObject();
}
}
}
| pperboires/PocDrools | drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java | Java | apache-2.0 | 31,600 | [
30522,
1013,
1008,
1008,
9385,
2384,
1046,
15853,
2015,
4297,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
1999,
12646,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Copyright (c) 1998 Cygnus Support
#
# The authors hereby grant permission to use, copy, modify, distribute,
# and license this software and its documentation for any purpose, provided
# that existing copyright notices are retained in all copies and that this
# notice is included verbatim in any distributions. No written agreement,
# license, or royalty fee is required for any of the authorized uses.
# Modifications to this software may be copyrighted by their authors
# and need not follow the licensing terms described here, provided that
# the new terms are clearly indicated on the first page of each file where
# they apply.
DESTDIR =
VPATH = ../../.././libgloss/libnosys
srcdir = ../../.././libgloss/libnosys
objdir = .
srcroot = $(srcdir)/../..
objroot = $(objdir)/../..
prefix = /usr/local
exec_prefix = ${prefix}
host_alias = arm-none-eabi
target_alias = arm-none-eabi
program_transform_name = s&^&arm-none-eabi-&
bindir = ${exec_prefix}/bin
libdir = ${exec_prefix}/lib
tooldir = $(exec_prefix)/$(target_alias)
# Multilib support variables.
# TOP is used instead of MULTI{BUILD,SRC}TOP.
MULTIDIRS =
MULTISUBDIR =
MULTIDO = true
MULTICLEAN = true
INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = /usr/bin/install -c
INSTALL_DATA = /usr/bin/install -c -m 644
SHELL = /bin/sh
CC = arm-none-eabi-gcc -B/sources/newlib/newlib-1.18.0/arm-none-eabi/newlib/ -isystem /sources/newlib/newlib-1.18.0/arm-none-eabi/newlib/targ-include -isystem /sources/newlib/newlib-1.18.0/newlib/libc/include -B/sources/newlib/newlib-1.18.0/arm-none-eabi/libgloss/arm -L/sources/newlib/newlib-1.18.0/arm-none-eabi/libgloss/libnosys -L/sources/newlib/newlib-1.18.0/libgloss/arm
#AS = arm-none-eabi-as
AS = `if [ -f ${objroot}/../gas/as-new ] ; \
then echo ${objroot}/../gas/as-new ; \
else echo as ; fi`
AR = arm-none-eabi-ar
#LD = arm-none-eabi-ld
LD = `if [ -f ${objroot}/../ld/ld-new ] ; \
then echo ${objroot}/../ld/ld-new ; \
else echo ld ; fi`
RANLIB = arm-none-eabi-ranlib
OBJDUMP = `if [ -f ${objroot}/../binutils/objdump ] ; \
then echo ${objroot}/../binutils/objdump ; \
else t='$(program_transform_name)'; echo objdump | sed -e $$t ; fi`
OBJCOPY = `if [ -f ${objroot}/../binutils/objcopy ] ; \
then echo ${objroot}/../binutils/objcopy ; \
else t='$(program_transform_name)'; echo objcopy | sed -e $$t ; fi`
# object files needed
OBJS = chown.o close.o environ.o errno.o execve.o fork.o fstat.o \
getpid.o gettod.o isatty.o kill.o link.o lseek.o open.o \
read.o readlink.o sbrk.o stat.o symlink.o times.o unlink.o \
wait.o write.o _exit.o
# Object files specific to particular targets.
EVALOBJS = ${OBJS}
GCC_LDFLAGS = `if [ -d ${objroot}/../gcc ] ; \
then echo -L${objroot}/../gcc ; fi`
OUTPUTS = libnosys.a
NEWLIB_CFLAGS = `if [ -d ${objroot}/newlib ]; then echo -I${objroot}/newlib/targ-include -I${srcroot}/newlib/libc/include; fi`
NEWLIB_LDFLAGS = `if [ -d ${objroot}/newlib ]; then echo -B${objroot}/newlib/ -L${objroot}/newlib/; fi`
INCLUDES = -I. -I$(srcdir)/..
# Note that when building the library, ${MULTILIB} is not the way multilib
# options are passed; they're passed in $(CFLAGS).
CFLAGS_FOR_TARGET = ${MULTILIB} ${INCLUDES} ${NEWLIB_CFLAGS}
LDFLAGS_FOR_TARGET = ${MULTILIB} ${NEWLIB_LDFLAGS}
AR_FLAGS = qc
.c.o:
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $<
.C.o:
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $<
.s.o:
$(AS) $(ASFLAGS_FOR_TARGET) $(INCLUDES) $(ASFLAGS) -o $*.o $<
#
# GCC knows to run the preprocessor on .S files before it assembles them.
#
.S.o:
$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) $(CFLAGS) -c $<
#
# this is a bogus target that'll produce an assembler from the
# C source with the right compiler options. this is so we can
# track down code generation or debug symbol bugs.
#
.c.s:
$(CC) $(CFLAGS_FOR_TARGET) -S $(INCLUDES) $(CFLAGS) $<
all: ${OUTPUTS}
#
# here's where we build the library for each target
#
libnosys.a: $(EVALOBJS)
${AR} ${ARFLAGS} $@ $(EVALOBJS)
${RANLIB} $@
doc:
clean mostlyclean:
rm -f $(OUTPUTS) *.i *~ *.o *-test *.srec *.dis *.map *.x
distclean maintainer-clean realclean: clean
rm -f Makefile config.status $(OUTPUTS)
.PHONY: install info install-info clean-info
install:
@for outputs in ${OUTPUTS}; do\
mkdir -p $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}; \
$(INSTALL_PROGRAM) $${outputs} $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}; \
done
info:
install-info:
clean-info:
Makefile: Makefile.in config.status ../../.././libgloss/libnosys/../config/default.mh
$(SHELL) config.status
config.status: configure
$(SHELL) config.status --recheck
| pavel-ruban/hldi_hardware | src/system/arm-none-eabi/libgloss/libnosys/Makefile | Makefile | gpl-2.0 | 4,584 | [
30522,
1001,
9385,
1006,
1039,
1007,
2687,
22330,
16206,
2271,
2490,
1001,
1001,
1996,
6048,
2182,
3762,
3946,
6656,
2000,
2224,
1010,
6100,
1010,
19933,
1010,
16062,
1010,
1001,
1998,
6105,
2023,
4007,
1998,
2049,
12653,
2005,
2151,
3800,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#include "gen-cpp/LogSender.h"
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/server/TNonblockingServer.h>
#include <thrift/transport/TServerSocket.h>
#include <thrift/transport/TBufferTransports.h>
#include <thrift/concurrency/PosixThreadFactory.h>
using namespace ::apache::thrift;
using namespace ::apache::thrift::protocol;
using namespace ::apache::thrift::transport;
using namespace ::apache::thrift::server;
using namespace ::apache::thrift::concurrency;
using boost::shared_ptr;
#define THREAD_NUM 5
std::map<std::string, std::string> logMap;
class LogSenderHandler : virtual public LogSenderIf {
public:
LogSenderHandler() {
// Your initialization goes here
}
void SendLog(const std::vector<LogInfo> & loglist) {
// Your implementation goes here
sleep(5);
time_t now = time(NULL);
printf("SendLog, now = %s\n", ctime(&now));
for (size_t i = 0; i < loglist.size(); ++i)
{
if (logMap.find(loglist[i].name) == logMap.end())
{
logMap.insert(std::make_pair(loglist[i].name, loglist[i].content));
}
}
}
void GetLog(std::string& _return, const std::string& logname) {
// Your implementation goes here
std::map<std::string,std::string>::iterator iter = logMap.find(logname);
if (iter != logMap.end())
{
_return = iter->second;
}
else
{
_return = "Not Found!";
}
}
};
int main(int argc, char **argv)
{
int port = 9090;
shared_ptr<LogSenderHandler> handler(new LogSenderHandler());
shared_ptr<TProcessor> processor(new LogSenderProcessor(handler));
shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(THREAD_NUM);
shared_ptr<PosixThreadFactory> threadFactory = shared_ptr<PosixThreadFactory> (new PosixThreadFactory());
threadManager->threadFactory(threadFactory);
threadManager->start();
TNonblockingServer server(processor, protocolFactory, port, threadManager);
server.serve();
return 0;
}
| opensource000/cnblogs | log_thrift/nonblock_server.cpp | C++ | apache-2.0 | 2,062 | [
30522,
1001,
2421,
1000,
8991,
1011,
18133,
2361,
1013,
15664,
10497,
2121,
1012,
1044,
1000,
1001,
2421,
1026,
16215,
16338,
1013,
8778,
1013,
26419,
3981,
2854,
21572,
3406,
25778,
1012,
1044,
1028,
1001,
2421,
1026,
16215,
16338,
1013,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// 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.
// ----------------------------------------------------------------------------------
using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Management.Compute;
using System;
using System.Management.Automation;
namespace Microsoft.Azure.Commands.Compute
{
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VMAccessExtension"),OutputType(typeof(VirtualMachineAccessExtensionContext))]
public class GetAzureVMAccessExtensionCommand : VirtualMachineExtensionBaseCmdlet
{
[Parameter(
Mandatory = true,
Position = 0,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The resource group name.")]
[ResourceGroupCompleter()]
[ValidateNotNullOrEmpty]
public string ResourceGroupName { get; set; }
[Alias("ResourceName")]
[Parameter(
Mandatory = true,
Position = 1,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The virtual machine name.")]
[ResourceNameCompleter("Microsoft.Compute/virtualMachines", "ResourceGroupName")]
[ValidateNotNullOrEmpty]
public string VMName { get; set; }
[Alias("ExtensionName")]
[Parameter(
Mandatory = true,
Position = 2,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The extension name.")]
[ResourceNameCompleter("Microsoft.Compute/virtualMachines/extensions", "ResourceGroupName", "VMName")]
[ValidateNotNullOrEmpty]
public string Name { get; set; }
[Parameter(
Position = 3,
ValueFromPipelineByPropertyName = true,
HelpMessage = "To show the status.")]
[ValidateNotNullOrEmpty]
public SwitchParameter Status { get; set; }
public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
ExecuteClientAction(() =>
{
if (Status.IsPresent)
{
var result = this.VirtualMachineExtensionClient.GetWithInstanceView(this.ResourceGroupName, this.VMName, this.Name);
var returnedExtension = result.ToPSVirtualMachineExtension(this.ResourceGroupName, this.VMName);
if (returnedExtension.Publisher.Equals(VirtualMachineAccessExtensionContext.ExtensionDefaultPublisher, StringComparison.InvariantCultureIgnoreCase) &&
returnedExtension.ExtensionType.Equals(VirtualMachineAccessExtensionContext.ExtensionDefaultName, StringComparison.InvariantCultureIgnoreCase))
{
WriteObject(new VirtualMachineAccessExtensionContext(returnedExtension));
}
else
{
WriteObject(null);
}
}
else
{
var result = this.VirtualMachineExtensionClient.Get(this.ResourceGroupName, this.VMName, this.Name);
var returnedExtension = result.ToPSVirtualMachineExtension(this.ResourceGroupName, this.VMName);
if (returnedExtension.Publisher.Equals(VirtualMachineAccessExtensionContext.ExtensionDefaultPublisher, StringComparison.InvariantCultureIgnoreCase) &&
returnedExtension.ExtensionType.Equals(VirtualMachineAccessExtensionContext.ExtensionDefaultName, StringComparison.InvariantCultureIgnoreCase))
{
WriteObject(new VirtualMachineAccessExtensionContext(returnedExtension));
}
else
{
WriteObject(null);
}
}
});
}
}
}
| ClogenyTechnologies/azure-powershell | src/ResourceManager/Compute/Commands.Compute/Extension/VMAccess/GetAzureVMAccessExtension.cs | C# | apache-2.0 | 4,615 | [
30522,
1013,
1013,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<h1>Welcome to FixMyStreet</h1>
<p>
Using this app you can report common street problems, like potholes or broken street lights, to councils throughout the UK.
</p>
<p>
It works online and offline, because we know that there isn't always a signal when you need one.
</p>
| Kagee/fixmystreet-mobile | src/templates/en/initial_help.html | HTML | agpl-3.0 | 272 | [
30522,
1026,
1044,
2487,
1028,
6160,
2000,
8081,
8029,
3367,
9910,
2102,
1026,
1013,
1044,
2487,
1028,
1026,
1052,
1028,
2478,
2023,
10439,
2017,
2064,
3189,
2691,
2395,
3471,
1010,
2066,
8962,
19990,
2030,
3714,
2395,
4597,
1010,
2000,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#!/usr/bin/env bash
set -e
ci_dir="$(dirname "$0")"
. "${ci_dir}/ci-common.sh"
git_download quickchick
if [ "$DOWNLOAD_ONLY" ]; then exit 0; fi
( cd "${CI_BUILD_DIR}/quickchick"
make
make install
make tests
)
| coq/coq | dev/ci/ci-quickchick.sh | Shell | lgpl-2.1 | 220 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
4372,
2615,
24234,
2275,
1011,
1041,
25022,
1035,
16101,
1027,
1000,
1002,
1006,
16101,
18442,
1000,
1002,
1014,
1000,
1007,
1000,
1012,
1000,
1002,
1063,
25022,
1035,
16101,
1065,
1013,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.42000
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
using NMF.Collections.Generic;
using NMF.Collections.ObjectModel;
using NMF.Expressions;
using NMF.Expressions.Linq;
using NMF.Models;
using NMF.Models.Collections;
using NMF.Models.Expressions;
using NMF.Models.Meta;
using NMF.Models.Repository;
using NMF.Serialization;
using NMF.Utilities;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using TTC2017.SmartGrids.CIM;
using TTC2017.SmartGrids.CIM.IEC61968.Assets;
using TTC2017.SmartGrids.CIM.IEC61968.Common;
using TTC2017.SmartGrids.CIM.IEC61970.ControlArea;
using TTC2017.SmartGrids.CIM.IEC61970.Core;
using TTC2017.SmartGrids.CIM.IEC61970.Informative.EnergyScheduling;
using TTC2017.SmartGrids.CIM.IEC61970.Informative.InfAssets;
using TTC2017.SmartGrids.CIM.IEC61970.Informative.InfERPSupport;
using TTC2017.SmartGrids.CIM.IEC61970.Informative.InfGMLSupport;
using TTC2017.SmartGrids.CIM.IEC61970.Informative.MarketOperations;
using TTC2017.SmartGrids.CIM.IEC61970.Informative.Reservation;
using TTC2017.SmartGrids.CIM.IEC61970.SCADA;
using TTC2017.SmartGrids.CIM.IEC61970.Wires;
namespace TTC2017.SmartGrids.CIM.IEC61970.Meas
{
/// <summary>
/// The default implementation of the Accumulator class
/// </summary>
[XmlNamespaceAttribute("http://iec.ch/TC57/2009/CIM-schema-cim14#Meas")]
[XmlNamespacePrefixAttribute("cimMeas")]
[ModelRepresentationClassAttribute("http://iec.ch/TC57/2009/CIM-schema-cim14#//IEC61970/Meas/Accumulator")]
[DebuggerDisplayAttribute("Accumulator {UUID}")]
public partial class Accumulator : Measurement, IAccumulator, IModelElement
{
/// <summary>
/// The backing field for the MaxValue property
/// </summary>
private int _maxValue;
private static Lazy<ITypedElement> _maxValueAttribute = new Lazy<ITypedElement>(RetrieveMaxValueAttribute);
private static Lazy<ITypedElement> _accumulatorValuesReference = new Lazy<ITypedElement>(RetrieveAccumulatorValuesReference);
/// <summary>
/// The backing field for the AccumulatorValues property
/// </summary>
private AccumulatorAccumulatorValuesCollection _accumulatorValues;
private static Lazy<ITypedElement> _limitSetsReference = new Lazy<ITypedElement>(RetrieveLimitSetsReference);
/// <summary>
/// The backing field for the LimitSets property
/// </summary>
private AccumulatorLimitSetsCollection _limitSets;
private static IClass _classInstance;
public Accumulator()
{
this._accumulatorValues = new AccumulatorAccumulatorValuesCollection(this);
this._accumulatorValues.CollectionChanging += this.AccumulatorValuesCollectionChanging;
this._accumulatorValues.CollectionChanged += this.AccumulatorValuesCollectionChanged;
this._limitSets = new AccumulatorLimitSetsCollection(this);
this._limitSets.CollectionChanging += this.LimitSetsCollectionChanging;
this._limitSets.CollectionChanged += this.LimitSetsCollectionChanged;
}
/// <summary>
/// The maxValue property
/// </summary>
[XmlElementNameAttribute("maxValue")]
[XmlAttributeAttribute(true)]
public virtual int MaxValue
{
get
{
return this._maxValue;
}
set
{
if ((this._maxValue != value))
{
int old = this._maxValue;
ValueChangedEventArgs e = new ValueChangedEventArgs(old, value);
this.OnMaxValueChanging(e);
this.OnPropertyChanging("MaxValue", e, _maxValueAttribute);
this._maxValue = value;
this.OnMaxValueChanged(e);
this.OnPropertyChanged("MaxValue", e, _maxValueAttribute);
}
}
}
/// <summary>
/// The AccumulatorValues property
/// </summary>
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)]
[XmlAttributeAttribute(true)]
[XmlOppositeAttribute("Accumulator")]
[ConstantAttribute()]
public virtual IOrderedSetExpression<IAccumulatorValue> AccumulatorValues
{
get
{
return this._accumulatorValues;
}
}
/// <summary>
/// The LimitSets property
/// </summary>
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)]
[XmlAttributeAttribute(true)]
[XmlOppositeAttribute("Measurements")]
[ConstantAttribute()]
public virtual IOrderedSetExpression<IAccumulatorLimitSet> LimitSets
{
get
{
return this._limitSets;
}
}
/// <summary>
/// Gets the referenced model elements of this model element
/// </summary>
public override IEnumerableExpression<IModelElement> ReferencedElements
{
get
{
return base.ReferencedElements.Concat(new AccumulatorReferencedElementsCollection(this));
}
}
/// <summary>
/// Gets the Class model for this type
/// </summary>
public new static IClass ClassInstance
{
get
{
if ((_classInstance == null))
{
_classInstance = ((IClass)(MetaRepository.Instance.Resolve("http://iec.ch/TC57/2009/CIM-schema-cim14#//IEC61970/Meas/Accumulator")));
}
return _classInstance;
}
}
/// <summary>
/// Gets fired before the MaxValue property changes its value
/// </summary>
public event System.EventHandler<ValueChangedEventArgs> MaxValueChanging;
/// <summary>
/// Gets fired when the MaxValue property changed its value
/// </summary>
public event System.EventHandler<ValueChangedEventArgs> MaxValueChanged;
private static ITypedElement RetrieveMaxValueAttribute()
{
return ((ITypedElement)(((ModelElement)(Accumulator.ClassInstance)).Resolve("maxValue")));
}
/// <summary>
/// Raises the MaxValueChanging event
/// </summary>
/// <param name="eventArgs">The event data</param>
protected virtual void OnMaxValueChanging(ValueChangedEventArgs eventArgs)
{
System.EventHandler<ValueChangedEventArgs> handler = this.MaxValueChanging;
if ((handler != null))
{
handler.Invoke(this, eventArgs);
}
}
/// <summary>
/// Raises the MaxValueChanged event
/// </summary>
/// <param name="eventArgs">The event data</param>
protected virtual void OnMaxValueChanged(ValueChangedEventArgs eventArgs)
{
System.EventHandler<ValueChangedEventArgs> handler = this.MaxValueChanged;
if ((handler != null))
{
handler.Invoke(this, eventArgs);
}
}
private static ITypedElement RetrieveAccumulatorValuesReference()
{
return ((ITypedElement)(((ModelElement)(Accumulator.ClassInstance)).Resolve("AccumulatorValues")));
}
/// <summary>
/// Forwards CollectionChanging notifications for the AccumulatorValues property to the parent model element
/// </summary>
/// <param name="sender">The collection that raised the change</param>
/// <param name="e">The original event data</param>
private void AccumulatorValuesCollectionChanging(object sender, NMF.Collections.ObjectModel.NotifyCollectionChangingEventArgs e)
{
this.OnCollectionChanging("AccumulatorValues", e, _accumulatorValuesReference);
}
/// <summary>
/// Forwards CollectionChanged notifications for the AccumulatorValues property to the parent model element
/// </summary>
/// <param name="sender">The collection that raised the change</param>
/// <param name="e">The original event data</param>
private void AccumulatorValuesCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
this.OnCollectionChanged("AccumulatorValues", e, _accumulatorValuesReference);
}
private static ITypedElement RetrieveLimitSetsReference()
{
return ((ITypedElement)(((ModelElement)(Accumulator.ClassInstance)).Resolve("LimitSets")));
}
/// <summary>
/// Forwards CollectionChanging notifications for the LimitSets property to the parent model element
/// </summary>
/// <param name="sender">The collection that raised the change</param>
/// <param name="e">The original event data</param>
private void LimitSetsCollectionChanging(object sender, NMF.Collections.ObjectModel.NotifyCollectionChangingEventArgs e)
{
this.OnCollectionChanging("LimitSets", e, _limitSetsReference);
}
/// <summary>
/// Forwards CollectionChanged notifications for the LimitSets property to the parent model element
/// </summary>
/// <param name="sender">The collection that raised the change</param>
/// <param name="e">The original event data</param>
private void LimitSetsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
this.OnCollectionChanged("LimitSets", e, _limitSetsReference);
}
/// <summary>
/// Resolves the given attribute name
/// </summary>
/// <returns>The attribute value or null if it could not be found</returns>
/// <param name="attribute">The requested attribute name</param>
/// <param name="index">The index of this attribute</param>
protected override object GetAttributeValue(string attribute, int index)
{
if ((attribute == "MAXVALUE"))
{
return this.MaxValue;
}
return base.GetAttributeValue(attribute, index);
}
/// <summary>
/// Gets the Model element collection for the given feature
/// </summary>
/// <returns>A non-generic list of elements</returns>
/// <param name="feature">The requested feature</param>
protected override System.Collections.IList GetCollectionForFeature(string feature)
{
if ((feature == "ACCUMULATORVALUES"))
{
return this._accumulatorValues;
}
if ((feature == "LIMITSETS"))
{
return this._limitSets;
}
return base.GetCollectionForFeature(feature);
}
/// <summary>
/// Sets a value to the given feature
/// </summary>
/// <param name="feature">The requested feature</param>
/// <param name="value">The value that should be set to that feature</param>
protected override void SetFeature(string feature, object value)
{
if ((feature == "MAXVALUE"))
{
this.MaxValue = ((int)(value));
return;
}
base.SetFeature(feature, value);
}
/// <summary>
/// Gets the Class for this model element
/// </summary>
public override IClass GetClass()
{
if ((_classInstance == null))
{
_classInstance = ((IClass)(MetaRepository.Instance.Resolve("http://iec.ch/TC57/2009/CIM-schema-cim14#//IEC61970/Meas/Accumulator")));
}
return _classInstance;
}
/// <summary>
/// The collection class to to represent the children of the Accumulator class
/// </summary>
public class AccumulatorReferencedElementsCollection : ReferenceCollection, ICollectionExpression<IModelElement>, ICollection<IModelElement>
{
private Accumulator _parent;
/// <summary>
/// Creates a new instance
/// </summary>
public AccumulatorReferencedElementsCollection(Accumulator parent)
{
this._parent = parent;
}
/// <summary>
/// Gets the amount of elements contained in this collection
/// </summary>
public override int Count
{
get
{
int count = 0;
count = (count + this._parent.AccumulatorValues.Count);
count = (count + this._parent.LimitSets.Count);
return count;
}
}
protected override void AttachCore()
{
this._parent.AccumulatorValues.AsNotifiable().CollectionChanged += this.PropagateCollectionChanges;
this._parent.LimitSets.AsNotifiable().CollectionChanged += this.PropagateCollectionChanges;
}
protected override void DetachCore()
{
this._parent.AccumulatorValues.AsNotifiable().CollectionChanged -= this.PropagateCollectionChanges;
this._parent.LimitSets.AsNotifiable().CollectionChanged -= this.PropagateCollectionChanges;
}
/// <summary>
/// Adds the given element to the collection
/// </summary>
/// <param name="item">The item to add</param>
public override void Add(IModelElement item)
{
IAccumulatorValue accumulatorValuesCasted = item.As<IAccumulatorValue>();
if ((accumulatorValuesCasted != null))
{
this._parent.AccumulatorValues.Add(accumulatorValuesCasted);
}
IAccumulatorLimitSet limitSetsCasted = item.As<IAccumulatorLimitSet>();
if ((limitSetsCasted != null))
{
this._parent.LimitSets.Add(limitSetsCasted);
}
}
/// <summary>
/// Clears the collection and resets all references that implement it.
/// </summary>
public override void Clear()
{
this._parent.AccumulatorValues.Clear();
this._parent.LimitSets.Clear();
}
/// <summary>
/// Gets a value indicating whether the given element is contained in the collection
/// </summary>
/// <returns>True, if it is contained, otherwise False</returns>
/// <param name="item">The item that should be looked out for</param>
public override bool Contains(IModelElement item)
{
if (this._parent.AccumulatorValues.Contains(item))
{
return true;
}
if (this._parent.LimitSets.Contains(item))
{
return true;
}
return false;
}
/// <summary>
/// Copies the contents of the collection to the given array starting from the given array index
/// </summary>
/// <param name="array">The array in which the elements should be copied</param>
/// <param name="arrayIndex">The starting index</param>
public override void CopyTo(IModelElement[] array, int arrayIndex)
{
IEnumerator<IModelElement> accumulatorValuesEnumerator = this._parent.AccumulatorValues.GetEnumerator();
try
{
for (
; accumulatorValuesEnumerator.MoveNext();
)
{
array[arrayIndex] = accumulatorValuesEnumerator.Current;
arrayIndex = (arrayIndex + 1);
}
}
finally
{
accumulatorValuesEnumerator.Dispose();
}
IEnumerator<IModelElement> limitSetsEnumerator = this._parent.LimitSets.GetEnumerator();
try
{
for (
; limitSetsEnumerator.MoveNext();
)
{
array[arrayIndex] = limitSetsEnumerator.Current;
arrayIndex = (arrayIndex + 1);
}
}
finally
{
limitSetsEnumerator.Dispose();
}
}
/// <summary>
/// Removes the given item from the collection
/// </summary>
/// <returns>True, if the item was removed, otherwise False</returns>
/// <param name="item">The item that should be removed</param>
public override bool Remove(IModelElement item)
{
IAccumulatorValue accumulatorValueItem = item.As<IAccumulatorValue>();
if (((accumulatorValueItem != null)
&& this._parent.AccumulatorValues.Remove(accumulatorValueItem)))
{
return true;
}
IAccumulatorLimitSet accumulatorLimitSetItem = item.As<IAccumulatorLimitSet>();
if (((accumulatorLimitSetItem != null)
&& this._parent.LimitSets.Remove(accumulatorLimitSetItem)))
{
return true;
}
return false;
}
/// <summary>
/// Gets an enumerator that enumerates the collection
/// </summary>
/// <returns>A generic enumerator</returns>
public override IEnumerator<IModelElement> GetEnumerator()
{
return Enumerable.Empty<IModelElement>().Concat(this._parent.AccumulatorValues).Concat(this._parent.LimitSets).GetEnumerator();
}
}
/// <summary>
/// Represents a proxy to represent an incremental access to the maxValue property
/// </summary>
private sealed class MaxValueProxy : ModelPropertyChange<IAccumulator, int>
{
/// <summary>
/// Creates a new observable property access proxy
/// </summary>
/// <param name="modelElement">The model instance element for which to create the property access proxy</param>
public MaxValueProxy(IAccumulator modelElement) :
base(modelElement, "maxValue")
{
}
/// <summary>
/// Gets or sets the value of this expression
/// </summary>
public override int Value
{
get
{
return this.ModelElement.MaxValue;
}
set
{
this.ModelElement.MaxValue = value;
}
}
}
}
}
| georghinkel/ttc2017smartGrids | solutions/NMF/Schema/IEC61970/Meas/Accumulator.cs | C# | mit | 20,284 | [
30522,
1013,
1013,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2011 by CardPuller, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*
* WARNING: This is generated code. Modify at your own risk and without support.
*/
#import <Foundation/Foundation.h>
#import "TiProxy.h"
#import "TiBlob.h"
// TODO: Support array-style access of bytes
/**
The class represents a buffer of bytes.
*/
@interface TiBuffer : TiProxy {
NSMutableData* data;
NSNumber* byteOrder;
}
/**
Provides access to raw data.
*/
@property(nonatomic, retain) NSMutableData* data;
// Public API
-(NSNumber*)append:(id)args;
-(NSNumber*)insert:(id)args;
-(NSNumber*)copy:(id)args;
-(TiBuffer*)clone:(id)args;
-(void)fill:(id)args;
-(void)clear:(id)_void;
-(void)release:(id)_void;
-(TiBlob*)toBlob:(id)_void;
-(NSString*)toString:(id)_void;
/**
Provides access to the buffer length.
*/
@property(nonatomic,assign) NSNumber* length;
/**
Provides access to the data byte order.
The byte order values are: 1 - little-endian, 2 - big-endian.
*/
@property(nonatomic,retain) NSNumber* byteOrder;
// SPECIAL NOTES:
// Ti.Buffer objects have an 'overloaded' Ti.Buffer[x] operation for x==int (making them behave like arrays).
// See the code for how this works.
@end
| PlebeianApps/CardPuller | build/iphone/Classes/TiBuffer.h | C | apache-2.0 | 1,353 | [
30522,
1013,
1008,
1008,
1008,
10439,
29109,
6906,
4263,
23431,
4684,
1008,
9385,
1006,
1039,
1007,
2268,
1011,
2249,
2011,
4003,
14289,
10820,
1010,
4297,
1012,
2035,
2916,
9235,
1012,
1008,
7000,
2104,
1996,
3408,
1997,
1996,
15895,
2270,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import { Feature } from 'core/feature';
import * as toolkitHelper from 'helpers/toolkit';
export class TargetBalanceWarning extends Feature {
constructor() {
super();
}
shouldInvoke() {
return toolkitHelper.getCurrentRouteName().indexOf('budget') !== -1;
}
invoke() {
$('.budget-table-row.is-sub-category').each((index, element) => {
const emberId = element.id;
const viewData = toolkitHelper.getEmberView(emberId).data;
const { subCategory } = viewData;
if (subCategory.get('goalType') === ynab.constants.SubCategoryGoalType.TargetBalance) {
const available = viewData.get('available');
const targetBalance = subCategory.get('targetBalance');
const currencyElement = $('.budget-table-cell-available .user-data.currency', element);
if (available < targetBalance && !currencyElement.hasClass('cautious')) {
if (currencyElement.hasClass('positive')) {
currencyElement.removeClass('positive');
}
currencyElement.addClass('cautious');
}
}
});
}
observe(changedNodes) {
if (!this.shouldInvoke()) return;
if (changedNodes.has('budget-table-cell-available-div user-data')) {
this.invoke();
}
}
onRouteChanged() {
if (!this.shouldInvoke()) return;
this.invoke();
}
}
| egens/toolkit-for-ynab | sauce/features/budget/target-balance-warning/index.js | JavaScript | mit | 1,342 | [
30522,
12324,
1063,
3444,
1065,
2013,
1005,
4563,
1013,
3444,
1005,
1025,
12324,
1008,
2004,
6994,
23615,
16001,
4842,
2013,
1005,
2393,
2545,
1013,
6994,
23615,
1005,
1025,
9167,
2465,
4539,
26657,
9028,
5582,
8908,
3444,
1063,
9570,
2953,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Fill out your copyright notice in the Description page of Project Settings.
#include "Chapter11.h"
#include "Chapter11GameMode.h"
| sunithshetty/Unreal-Engine-4-Scripting-with-CPlusPlus-Cookbook | Chapter11/Source/Chapter11/Chapter11GameMode.cpp | C++ | mit | 138 | [
30522,
1013,
30524,
1000,
3127,
14526,
1012,
1044,
1000,
1001,
2421,
1000,
3127,
14526,
16650,
5302,
3207,
1012,
1044,
1000,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
Copyright 2009-2022 Lianqi Wang <lianqiw-at-tmt-dot-org>
This file is part of Multithreaded Adaptive Optics Simulator (MAOS).
MAOS is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
MAOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
MAOS. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef __INTEL_COMPILER
#undef _GNU_SOURCE /*avoid compiling problem*/
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/file.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <time.h>
#include <stdarg.h>
#include <ctype.h>
#include <inttypes.h>
#include "io.h"
//static void write_timestamp(file_t *fp);
const char* myasctime(void){
static char st[64];
time_t a;
time(&a);
ctime_r(&a, st);
st[strlen(st)-1]='\0';
return st;
}
static int exist(const char* fn){
/**
Test whether a file exists.
*/
struct stat buf;
return !stat(fn, &buf);
}
/**
Compare two strings upto the length of b. if length of a is less than b,
return false. 1 means not equal.
*/
static int mystrcmp(const char* a, const char* b){
if(!a||!b) return 1;
int la=strlen(a);
int lb=strlen(b);
if(la==0||lb==0||la<lb){
return 1;
} else{
return strncmp(a, b, lb);
}
}
/**
Check the suffix of a file.
*/
static int check_suffix(const char* fn, const char* suffix){
if(!fn||!suffix) return 0;
int lfn=strlen(fn);
int lsu=strlen(suffix);
if(lfn<lsu) return 0;
if(mystrcmp(fn+lfn-lsu, suffix)){
return 0;
} else{
return 1;
}
}
/**
Make dirs recursively. like mkdir -p in bash
*/
void mymkdir(char* fn){
if(!fn) return;
while(fn[strlen(fn)-1]=='/')
fn[strlen(fn)-1]='\0';
if(mkdir(fn, 0777)==-1&&errno!=EEXIST){
perror("mkdir");
char* tmp=strrchr(fn, '/');
if(!tmp){
error("Unable to mkdir '%s'\n", fn);
}
tmp[0]='\0';
mymkdir(fn);
tmp[0]='/';
if(mkdir(fn, 0777)==-1&&errno!=EEXIST){
error("Unable to mkdir '%s'\n", fn);
}
}
}
/**
Obtain the dirname of a path. See mybasename().
*/
char* mydirname(const char* fn){
if(!fn||strlen(fn)==0) return NULL;
char fn2[PATH_MAX];
strncpy(fn2, fn, PATH_MAX-1);
/*If this is a folder, remove the last / */
if(fn2[strlen(fn2)-1]=='/')
fn2[strlen(fn2)-1]='\0';
char* sep=strrchr(fn2, '/');
if(!sep){
fn2[0]='.'; fn2[1]='\0';
} else{
sep[0]='\0';
}
return strdup(fn2);
}
/**
Test whether fn is a symbolic link
*/
static int islink(const char* fn){
if(!fn) return 0;
struct stat buf;
return !stat(fn, &buf)&&S_ISLNK(buf.st_mode);
}
static char* procfn(const char* fn, const char* mod){
if(!fn){
dbg("fn is empty\n");
return NULL;
}
char* fn2;
if(fn[0]=='~'){
char* HOME=getenv("HOME");
fn2=(char*)malloc(strlen(HOME)+strlen(fn)+16);
strcpy(fn2, HOME);
strcat(fn2, fn+1);
} else{
fn2=(char*)malloc(strlen(fn)+16);
strcpy(fn2, fn);
}
/*If there is no recognized suffix, add .bin in the end.*/
int nosuffix=0;
if(!check_suffix(fn2, ".bin")&&!check_suffix(fn2, ".bin.gz")
&&!check_suffix(fn2, ".fits")&&!check_suffix(fn2, ".fits.gz")){
strcat(fn2, ".bin");
nosuffix=1;
}
if(mod[0]=='r'||mod[0]=='a'){
if(!exist(fn2)){/*If does not exist.*/
if(!check_suffix(fn2, ".gz")){
strcat(fn2, ".gz");
} else if(check_suffix(fn, ".gz")){
/*ended with bin.gz, change to .bin*/
fn2[strlen(fn2)-3]='\0';
}
if(!exist(fn2)){
if(nosuffix){
fn2[strlen(fn2)-7]='\0';/*remove the added .bin, .gz*/
strcat(fn2, ".fits");/*replace with .fits*/
if(!exist(fn2)){
return NULL;
}
} else{
return NULL;
}
}
}
} else if(mod[0]=='w'){
if(islink(fn2)){
/*remove old file to avoid write over a symbolic link.*/
if(remove(fn2)){
dbg("Failed to remove %s\n", fn2);
return NULL;
}
} else{
char* fd=mydirname(fn2);
if(!exist(fd)){
mymkdir(fd);
}
free(fd);
}
} else{
error("Invalid mode\n");
}
return fn2;
}
/*stripped down version of io.c*/
file_t* zfopen(const char* fn, const char* mod){
char* fn2=procfn(fn, mod);
if(!fn2){
dbg("%s does not exist\n", fn);
return NULL;
}
file_t* fp=(file_t*)calloc(1, sizeof(file_t));
/*check fn instead of fn2. if end of .bin or .fits, disable compressing.*/
/*Now open the file to get a fd number that we can use to lock on the
file.*/
switch(mod[0]){
case 'r':/*read only */
fp->fd=open(fn2, O_RDONLY);
break;
case 'w':/*write */
case 'a':
fp->fd=open(fn2, O_RDWR|O_CREAT, 0600);
if(fp->fd!=-1&&flock(fp->fd, LOCK_EX|LOCK_NB)){
dbg("Trying to write to a file that is already opened for writing: %s\n", fn2);
close(fp->fd);
return NULL;
} else{
if(mod[0]=='w'&&ftruncate(fp->fd, 0)){/*Need to manually truncate the file. */
warning("Truncating %s failed\n", fn2);
}
}
break;
default:
dbg("Unknown mod=%s\n", mod);
return NULL;
}
if(fp->fd==-1){
dbg("Unable to open file %s\n", fn2);
return NULL;
}
if(mod[0]=='w'){
if(check_suffix(fn2, ".fits")){
fp->isgzip=0;
} else{
fp->isgzip=1;
}
} else{
uint16_t magic;
if(read(fp->fd, &magic, sizeof(uint16_t))!=sizeof(uint16_t)){
dbg("Read magic failed\n");
close(fp->fd); return NULL;
}
if(magic==0x8b1f){
fp->isgzip=1;
} else{
fp->isgzip=0;
}
lseek(fp->fd, 0, SEEK_SET);
}
if(fp->isgzip){
if(!(fp->p=gzdopen(fp->fd, mod))){
dbg("Error gzdopen for %s\n", fn2);
close(fp->fd); return NULL;
}
} else{
if(!(fp->p=fdopen(fp->fd, mod))){
dbg("Error fdopen for %s\n", fn2);
close(fp->fd); return NULL;
}
}
if(check_suffix(fn2, ".fits")||check_suffix(fn2, ".fits.gz")){
fp->isfits=1;
}
/*if(mod[0]=='w' && !fp->isfits){
write_timestamp(fp);
}*/
free(fn2);
return fp;
}
void zfclose(file_t* fp){
if(!fp) return;
if(fp->isgzip){
gzclose((gzFile)fp->p);
} else{
if(fclose((FILE*)fp->p)){
perror("fclose\n");
}
}
free(fp);
}
static inline void zfwrite_do(const void* ptr, const size_t size, const size_t nmemb, file_t* fp){
if(fp->isgzip){
if(gzwrite((gzFile)fp->p, ptr, size*nmemb)!=(long)(size*nmemb)){
zfclose(fp);
perror("gzwrite");
error("write failed\n");
}
} else{
if(fwrite(ptr, size, nmemb, (FILE*)fp->p)!=nmemb){
zfclose(fp);
perror("fwrite");
error("writefailed\n");
}
}
}
/**
Write to the file. If in gzip mode, calls gzwrite, otherwise, calls
fwrite. Follows the interface of fwrite.
*/
void zfwrite(const void* ptr, const size_t size, const size_t nmemb, file_t* fp){
/*a wrapper to call either fwrite or gzwrite based on flag of isgzip*/
if(fp->isfits&&size>1){
/* write a block of 2880 bytes each time, with big-endianness.*/
const int bs=2880;
char junk[bs];
int length=size*nmemb;
int nb=(length+bs-1)/bs;
char* in=(char*)ptr;
for(int ib=0; ib<nb; ib++){
int nd=length<bs?length:bs;
switch(size){
case 2:
for(int i=0; i<nd; i+=2){
junk[i]=in[i+1];
junk[i+1]=in[i];
}
break;
case 4:
for(int i=0; i<nd; i+=4){
junk[i]=in[i+3];
junk[i+1]=in[i+2];
junk[i+2]=in[i+1];
junk[i+3]=in[i];
}
break;
case 8:
case 16:
for(int i=0; i<nd; i+=8){
junk[i]=in[i+7];
junk[i+1]=in[i+6];
junk[i+2]=in[i+5];
junk[i+3]=in[i+4];
junk[i+4]=in[i+3];
junk[i+5]=in[i+2];
junk[i+6]=in[i+1];
junk[i+7]=in[i];
}
break;
default:
zfclose(fp);
error("Invalid\n");
}
/* use bs instead of nd to test tailing blanks*/
in+=bs; length-=bs;
if(length<0){
memset(junk+nd, 0, (bs-nd)*sizeof(char));
}
zfwrite_do(junk, sizeof(char), bs, fp);
}
} else{
zfwrite_do(ptr, size, nmemb, fp);
}
}
static inline int zfread_do(void* ptr, const size_t size, const size_t nmemb, file_t* fp){
if(fp->isgzip){
return gzread((gzFile)fp->p, ptr, size*nmemb)>0?0:-1;
} else{
return fread(ptr, size, nmemb, (FILE*)fp->p)==nmemb?0:-1;
}
}
/**
Read from the file. if in gzip mode, calls gzread, otherwise calls
fread. follows the interface of fread. It does byte ordering from big endian
to small endian in case we are reading fits file. */
int zfread2(void* ptr, const size_t size, const size_t nmemb, file_t* fp){
/*a wrapper to call either fwrite or gzwrite based on flag of isgzip*/
if(fp->isfits&&size>1){/*need to do byte swapping.*/
const long bs=2880;
char junk[bs];
long length=size*nmemb;
long nb=(length+bs-1)/bs;
char* out=(char*)ptr;
for(int ib=0; ib<nb; ib++){
if(zfread_do(junk, sizeof(char), bs, fp)) return -1;
int nd=length<bs?length:bs;
switch(size){
case 2:
for(int i=0; i<nd; i+=2){
out[i]=junk[i+1];
out[i+1]=junk[i];
}
break;
case 4:
for(int i=0; i<nd; i+=4){
out[i]=junk[i+3];
out[i+1]=junk[i+2];
out[i+2]=junk[i+1];
out[i+3]=junk[i];
}
break;
case 8:
case 16:
for(int i=0; i<nd; i+=8){
out[i]=junk[i+7];
out[i+1]=junk[i+6];
out[i+2]=junk[i+5];
out[i+3]=junk[i+4];
out[i+4]=junk[i+3];
out[i+5]=junk[i+2];
out[i+6]=junk[i+1];
out[i+7]=junk[i];
}
break;
default:
zfclose(fp);
error("Invalid\n");
}
out+=bs;
length-=bs;
}
return 0;
} else{
return zfread_do(ptr, size, nmemb, fp);
}
}
/**
Move the current position pointer, like fseek
*/
int zfseek(file_t* fp, long offset, int whence){
if(fp->isfits){/*in fits, we need to offset integer block of 2880.*/
const long bs=2880;
long nb=(offset+bs-1)/bs;
offset=nb*bs;
}
if(fp->isgzip){
return gzseek((gzFile)fp->p, offset, whence)==-1?-1:0;
} else{
return fseek((FILE*)fp->p, offset, whence);
}
}
long zftell(file_t* fp){
if(fp->isgzip){
return gztell((gzFile)fp->p);
} else{
return ftell((FILE*)fp->p);
}
}
int zfeof(file_t* fp){
return zfseek(fp, 1, SEEK_CUR);
}
/**
Write the magic into file. Also write a dummy header to make data alignment to 8 bytes.
*/
static void write_bin_magic(uint32_t magic, file_t* fp){
if(fp->isfits){
zfclose(fp);
error("fits file is not supported\n");
}
uint32_t magic2=M_SKIP;
zfwrite(&magic2, sizeof(uint32_t), 1, fp);
zfwrite(&magic, sizeof(uint32_t), 1, fp);
}
/**
Append to the file the header to the end of the file(or rather, the
tailer). First write magic number, then the length of the header, then the
header, then the length of the header again, then the magic number again. The
two set of strlen and header are used to identify the header from the end of
the file and also to verify that what we are reading are indeed header. The
header may be written multiple times. They will be concatenated when
read. The header should contain key=value entries just like the configuration
files. The entries should be separated by new line charactor. */
static void write_bin_header(const char* header, file_t* fp){
if(!header) return;
if(fp->isfits){
zfclose(fp);
error("fits file is not supported\n");
}
uint32_t magic=M_COMMENT;
uint64_t nlen=strlen(header)+1;
/*make header 8 byte alignment.*/
uint64_t nlen2=(nlen/8+1)*8;
char* header2=(char*)calloc(nlen2, sizeof(char));
memcpy(header2, header, nlen);
zfwrite(&magic, sizeof(uint32_t), 1, fp);
zfwrite(&nlen2, sizeof(uint64_t), 1, fp);
zfwrite(header2, 1, nlen2, fp);
zfwrite(&nlen2, sizeof(uint64_t), 1, fp);
zfwrite(&magic, sizeof(uint32_t), 1, fp);
free(header2);
}
/*static void write_timestamp(file_t *fp){
if(fp->isfits) error("Not supported\n");
char header[128];
snprintf(header,128, "Created by write on %s\n",
myasctime());
write_bin_header(header, fp);
}*/
/**
Obtain the current magic number. If it is a header, read it out if output of
header is not NULL. The header will be appended to the output header.*/
uint32_t read_bin_magic(file_t* fp, char** header){
uint32_t magic, magic2;
uint64_t nlen, nlen2;
if(fp->isfits){
zfclose(fp);
error("fits file is not supported\n");
}
while(1){
/*read the magic number.*/
if(zfread2(&magic, sizeof(uint32_t), 1, fp)) return 0;
/*If it is header, read or skip it.*/
if(magic==M_SKIP){
continue;
} else if(magic==M_COMMENT){
zfread(&nlen, sizeof(uint64_t), 1, fp);
if(nlen>0){
if(header){
char header2[nlen];
zfread(header2, 1, nlen, fp);
header2[nlen-1]='\0'; /*make sure it is NULL terminated.*/
if(*header){
*header=(char*)realloc(*header, sizeof(char)*(((*header)?strlen(*header):0)+strlen(header2)+1));
strncat(*header, header2, nlen);
} else{
*header=strdup(header2);
}
} else{
zfseek(fp, nlen, SEEK_CUR);
}
}
zfread(&nlen2, sizeof(uint64_t), 1, fp);
zfread(&magic2, sizeof(uint32_t), 1, fp);
if(magic!=magic2||nlen!=nlen2){
zfclose(fp);
error("Header verification failed: %u<>%u, %lu<>%lu\n", magic, magic2, (unsigned long)nlen, (unsigned long)nlen2);
}
} else{ /*otherwise return the magic number*/
return magic;
}
}/*while*/
}
/**
Write fits header. extra is extra header that will be put in fits comment
*/
static void
write_fits_header(file_t* fp, const char* str, uint32_t magic, uint64_t ndim, mwSize* dims){
int bitpix;
switch(magic){
case M_FLT:
bitpix=-32;
break;
case M_DBL:
case M_DSP64:
bitpix=-64;
break;
case M_INT64:
bitpix=64;
break;
case M_INT32:
bitpix=32;
break;
case M_INT16:
bitpix=16;
break;
case M_INT8:
bitpix=8;
break;
default:
bitpix=0;
zfclose(fp);
error("Data type magic=%x is not yet supported.\n", magic);
}
const int nh=36;
char header[nh][80];
memset(header, ' ', sizeof(char)*36*80);
int hc=0;
if(fp->isfits==1){
snprintf(header[hc], 80, "%-8s= %20s", "SIMPLE", "T"); header[hc][30]=' '; hc++;
fp->isfits++;
} else{
snprintf(header[hc], 80, "%-8s= %s", "XTENSION", "'IMAGE '"); header[hc][20]=' '; hc++;
}
snprintf(header[hc], 80, "%-8s= %20d", "BITPIX", bitpix); header[hc][30]=' '; hc++;
snprintf(header[hc], 80, "%-8s= %20ld", "NAXIS", (long)ndim); header[hc][30]=' '; hc++;
#define FLUSH_OUT /*write the block and reset */ \
if(hc==nh){ \
zfwrite(header, sizeof(char), 36*80, fp); \
memset(header, ' ', sizeof(char)*36*80); \
hc=0; \
}
for(unsigned long i=0; i<ndim; i++){
FLUSH_OUT;
snprintf(header[hc], 80, "%-5s%-3lu= %20ld", "NAXIS", i+1, (long)(dims[i])); header[hc][30]=' '; hc++;
}
if(fp->isfits==1){//Write the extend keyword which does not mendate extension to be present.
snprintf(header[hc], 80, "%-8s= %20s", "EXTEND", "T"); header[hc][30]=' '; hc++;
} else{
snprintf(header[hc], 80, "%-8s= %20s", "PCOUNT", "0"); header[hc][30]=' '; hc++;
snprintf(header[hc], 80, "%-8s= %20s", "GCOUNT", "1"); header[hc][30]=' '; hc++;
}
if(str){/*We wrap our header in COMMENT section to avoid dealing with name
* length limit*/
const char* str2=str+strlen(str);
while(str<str2){
const char* nl=strchr(str, '\n');
int length;
if(nl){
length=nl-str+1;
} else{
length=strlen(str);
}
if(length>70) length=70;
FLUSH_OUT;
strncpy(header[hc], "COMMENT ", 11);
strncpy(header[hc]+10, str, length);
if(nl){
header[hc][10+length-1]=';';
}
hc++;
str+=length;
}
}
FLUSH_OUT;
snprintf(header[hc], 80, "%-8s", "END"); header[hc][8]=' '; hc++;
zfwrite(header, sizeof(char), 36*80, fp);
#undef FLUSH_OUT
}
/**
Read fits header
*/
int read_fits_header(file_t* fp, char** str, uint32_t* magic, uint64_t* ndim, mwSize** dims){
char line[82];//extra space for \n and \0
int end=0;
int page=0;
int bitpix=0;
while(!end){
int start=0;
if(page==0){
/*First read mandatory fits headers.*/
if(zfread2(line, 1, 80, fp)) return -1;
start++;
line[80]='\0';
if(strncmp(line, "SIMPLE", 6)&&strncmp(line, "XTENSION= 'IMAGE", 16)){
dbg("Garbage in fits file at %ld:\n", zftell(fp));
dbg("%s\n", line);
return -1;
}
zfread(line, 1, 80, fp); line[80]='\0'; start++;
if(sscanf(line+10, "%20d", &bitpix)!=1){
zfclose(fp);
error("Unable to determine bitpix\n");
}
zfread(line, 1, 80, fp); line[80]='\0'; start++;
if(sscanf(line+10, "%"SCNu64, ndim)!=1){
zfclose(fp);
error("Unable to determine naxis\n");
}
if(*ndim>0){
*dims=(mwSize*)calloc(sizeof(mwSize), MAX(2, *ndim));
for(uint64_t idim=0; idim<*ndim; idim++){
do{
//skip illegal lines.
zfread(line, 1, 80, fp); line[80]='\0'; start++;
} while(strncmp(line, "NAXIS", 5));
if(sscanf(line+10, "%20lu", &((*dims)[idim]))!=1){
zfclose(fp);
error("Unable to determine nx\n");
}
}
}
}
for(int i=start; i<36; i++){
zfread(line, 1, 80, fp); line[80]='\0';
if(!strncmp(line, "END", 3)){
end=1;
} else{
char* hh=line;
int length=80;
int newline=1;
if(!strncmp(line, "EXTEND", 6)){
continue;
} else if(!strncmp(line, "PCOUNT", 6)){
continue;
} else if(!strncmp(line, "GCOUNT", 6)){
continue;
} else if(!strncmp(line, "COMMENT", 7)){
hh=line+10;
length-=10;
newline=0;
}
//Remove trailing space.
for(int j=length-1; j>=0; j--){
if(isspace((int)hh[j])){
hh[j]='\0';
length--;
} else{
if(newline){
hh[j+1]='\n';
hh[j+2]='\0';
}
break;
}
}
if(length>0){
if(*str){
*str=(char*)realloc(*str, (strlen(*str)+length+1+newline)*sizeof(char));
} else{
*str=(char*)malloc((length+1+newline)*sizeof(char)); (*str)[0]='\0';
}
strcat(*str, hh);
}
}
}
page++;
}
switch(bitpix){
case -32:
*magic=M_FLT;
break;
case -64:
*magic=M_DBL;
break;
case 64:
*magic=M_INT64;
break;
case 32:
*magic=M_INT32;
break;
case 16:
*magic=M_INT16;
break;
case 8:
*magic=M_INT8;
break;
default:
zfclose(fp);
error("bitpix=%d is not yet handled.\n", bitpix);
}
return 0;
}
/**
Write multiple long numbers into the file. To write three numbers, a, b, c,
call with zfwritelarr(fp, 3, &a, &b, &c); */
void zfwritelarr(file_t* fp, int count, ...){
va_list ap;
int i;
va_start(ap, count); /*Initialize the argument list. */
for(i=0; i<count; i++){
uint64_t* addr=va_arg(ap, uint64_t*); /*Get the next argument value. */
zfwrite(addr, sizeof(uint64_t), 1, fp);
}
va_end(ap); /* Clean up. */
}
/**
Read multiple long numbers from the file. To read three numbers, a, b, c,
call with zfreadlarr(fp, 3, &a, &b, &c);
*/
void zfreadlarr(file_t* fp, int count, ...){
va_list ap;
int i;
va_start(ap, count); /*Initialize the argument list. */
for(i=0; i<count; i++){
uint64_t* addr=va_arg(ap, uint64_t*); /*Get the next argument value. */
zfread(addr, sizeof(uint64_t), 1, fp);
}
va_end(ap); /* Clean up. */
}
/**
A unified header writing routine for .bin and .fits files. It write the array
information and string header if any. */
void write_header(const header_t* header, file_t* fp){
if(fp->isfits){
if(!iscell(header->magic)){
write_fits_header(fp, header->str, header->magic, header->ndim, header->dims);
}
} else{
if(header){
write_bin_header(header->str, fp);
}
write_bin_magic(header->magic, fp);
if(header->ndim>2){
warning("Third dimension and more will not be saved.\n");
}
if(header->dims){
zfwrite(header->dims, sizeof(uint64_t), 2, fp);
} else{
uint64_t temp[2]={0,0};
zfwrite(temp, sizeof(uint64_t), 2, fp);
}
}
}
/**
A unified header reading routine for .bin and .fits files. It read the array
information and string header if any. Return error signal.*/
int read_header2(header_t* header, file_t* fp){
int ans;
header->str=NULL;
if(fp->isfits){
ans=read_fits_header(fp, &header->str, &header->magic, &header->ndim, &header->dims);
} else{
header->magic=read_bin_magic(fp, &header->str);
if(header->magic==0){
ans=0;
} else{
ans=0;
header->ndim=2;
if(!header->dims) header->dims=(mwSize*)calloc(2, sizeof(mwSize));
zfread(header->dims, sizeof(mwSize), 2, fp);
}
}
header->ntot=header->ndim>0?1:0;
for(uint64_t idim=0; idim<header->ndim; idim++){
header->ntot*=header->dims[idim];
}
return ans;
}
/**
calls read_header2 and abort if error happens.*/
void read_header(header_t* header, file_t* fp){
if(read_header2(header, fp)){
zfclose(fp);
error("read_header failed\n");
}
}
/**
Parse an integer from header str
*/
int search_header_int(const char* str, const char* name){
if(!str||!name) return 0;
const char* tmp=strstr(str, name);
if(tmp){
return strtol(tmp+strlen(name), NULL, 10);
} else{
return 0;
}
}
/**
Parse an integer from header str
*/
double search_header_dbl(const char* str, const char* name){
const char* tmp=strstr(str, name);
if(tmp){
return strtod(tmp+strlen(name), NULL);
} else{
return 0;
}
}
| lianqiw/maos | mex/io.c | C | gpl-3.0 | 21,138 | [
30522,
1013,
1008,
9385,
2268,
1011,
16798,
2475,
22393,
2078,
14702,
7418,
1026,
22393,
2078,
14702,
2860,
1011,
2012,
1011,
1056,
20492,
1011,
11089,
1011,
8917,
1028,
2023,
5371,
2003,
2112,
1997,
4800,
2705,
16416,
5732,
19293,
21026,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// UserController for AngularJS
ecollabroApp.controller('userController', ['$scope', 'securityService', function ($scope, securityService) {
$scope.user = {};
$scope.activeRoles = [];
$scope.userId = 0;
//Method initialize
$scope.initialize = function (userId) {
$scope.userId = userId;
includeChangePassword($scope, securityService, 'admin');
$scope.loadUser();
};
//Method loadUser
$scope.loadUser = function () {
if ($scope.userId == 0) {
$scope.user.IsActive = true;
$scope.loadActiveRoles();
return;
}
securityService.getUser($scope.userId).then(function (resp) {
if (resp.businessException == null) {
$scope.user = resp.result;
$scope.loadActiveRoles();
}
else {
showMessage("divSummaryMessageUser", resp.businessException.ExceptionMessage, "danger");
}
});
};
//Method saveUser
$scope.saveUser = function () {
if (!$("#frmUser").valid()) {
return;
}
else {
if ($scope.user.UserRoles == null || $scope.user.UserRoles.length == 0) {
showMessage("divSummaryMessageUser", "Select at-least one role for user!", "danger");
return;
}
}
securityService.saveUser($scope.user).then(function (resp) {
if (resp.businessException == null) {
$scope.user.UserId = resp.result.Id;
var divUsers = document.getElementById("divUsers");
if (divUsers) {
showUsers(resp.result.Message); // calling parent's method
}
else {
showMessage("divSummaryMessageUser", resp.result.Message, "success");
}
}
else {
showMessage("divSummaryMessageUser", resp.businessException.ExceptionMessage, "danger");
}
});
};
//Method restPassword
$scope.resetPassword = function () {
bootbox.confirm("This will reset User's password and will send email with new credential? Are you sure to reset the password for selected User?", function (result) {
if (result) {
securityService.resetUserPassword($scope.user.UserId).then(function (resp) {
if (resp.businessException == null) {
showMessage("divSummaryMessageUser", resp.result, "success");
}
else {
showMessage("divSummaryMessageUser", resp.businessException.ExceptionMessage, "danger");
}
});
}
});
};
//Method confirmUser
$scope.confirmUser = function () {
securityService.confirmUser($scope.user.UserId).then(function (resp) {
if (resp.businessException == null) {
showMessage("divSummaryMessageUser", resp.result, "success");
$scope.user.IsConfirmed = true;
}
else {
showMessage("divSummaryMessageUser", resp.businessException.ExceptionMessage, "danger");
}
});
};
//Method unlockUser
$scope.unlockUser = function () {
securityService.unlockUser($scope.user.UserId).then(function (resp) {
if (resp.businessException == null) {
showMessage("divSummaryMessageUser", resp.result, "success");
$scope.user.IsLocked = false;
}
else {
showMessage("divSummaryMessageUser", resp.businessException.ExceptionMessage, "danger");
}
});
};
//Method approveUser
$scope.approveUser = function () {
securityService.approveUser($scope.user.UserId).then(function (resp) {
if (resp.businessException == null) {
showMessage("divSummaryMessageUser", resp.result, "success");
$scope.user.IsApproved = true;
}
else {
showMessage("divSummaryMessageUser", resp.businessException.ExceptionMessage, "danger");
}
});
};
//Method getActiveRole
$scope.getActiveRole = function (roleId) {
var activeRole = null;
for (var ctr = 0; ctr < $scope.activeRoles.length; ctr++) {
if ($scope.activeRoles[ctr].RoleId == roleId) {
activeRole = $scope.activeRoles[ctr];
break;
}
}
return activeRole;
}
// Method loadAactiveRoles
$scope.loadActiveRoles = function () {
securityService.getActiveRoles($scope.user).then(function (resp) {
if (resp.businessException == null) {
$scope.activeRoles = resp.result.data;
if ($scope.user.UserRoles != null && $scope.user.UserRoles.length > 0) {
var existingRoles = $scope.user.UserRoles;
$scope.user.UserRoles = [];
for (var ctr = 0; ctr < existingRoles.length; ctr++) {
var activeRole = $scope.getActiveRole(existingRoles[ctr].RoleId);
if (activeRole != null)
$scope.user.UserRoles.push(activeRole);
}
}
}
else {
showMessage("divSummaryMessageUser", resp.businessException.ExceptionMessage, "danger");
}
});
};
//method openUsers
$scope.openUsers = function () {
location.href = "/security/users";
};
}]); | eCollobro/eCollabro | eCollabro.Web/obj/Release/Package/PackageTmp/app/controllers/user/user.js | JavaScript | apache-2.0 | 5,849 | [
30522,
1013,
1013,
5310,
8663,
13181,
10820,
2005,
16108,
22578,
17338,
4571,
12618,
29098,
1012,
11486,
1006,
1005,
5310,
8663,
13181,
10820,
1005,
1010,
1031,
1005,
1002,
9531,
1005,
1010,
1005,
3036,
8043,
7903,
2063,
1005,
1010,
3853,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-return-list-item',
templateUrl: './return-list-item.component.html',
styleUrls: ['./return-list-item.component.css']
})
export class ReturnListItemComponent implements OnInit {
constructor() {}
ngOnInit() {}
}
| aviabird/angularspree | src/app/user/components/returns/return-list-item/return-list-item.component.ts | TypeScript | mit | 301 | [
30522,
12324,
1063,
6922,
1010,
2006,
5498,
2102,
1065,
2013,
1005,
1030,
16108,
1013,
4563,
1005,
1025,
1030,
6922,
1006,
1063,
27000,
1024,
1005,
10439,
1011,
2709,
1011,
2862,
1011,
8875,
1005,
1010,
23561,
3126,
2140,
1024,
1005,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "MovieSceneObjectManager.h"
#include "SequencerPossessedObject.h"
#include "SequencerMovieSceneObjectManager.generated.h"
/**
* Movie scene object manager used by Sequencer.
*/
UCLASS(BlueprintType, MinimalAPI)
class USequencerMovieSceneObjectManager
: public UObject
, public IMovieSceneObjectManager
{
GENERATED_UCLASS_BODY()
/** Virtual destructor. */
virtual ~USequencerMovieSceneObjectManager();
public:
// IMovieSceneObjectManager interface
virtual bool AllowsSpawnableObjects() const override;
virtual void BindPossessableObject(const FGuid& ObjectId, UObject& PossessedObject) override;
virtual bool CanPossessObject(UObject& Object) const override;
virtual void DestroyAllSpawnedObjects(UMovieScene& MovieScene) override;
virtual FGuid FindObjectId(const UMovieScene& MovieScene, UObject& Object) const override;
virtual UObject* FindObject(const FGuid& ObjectId) const override;
virtual void SpawnOrDestroyObjects(UMovieScene* MovieScene, bool DestroyAll) override;
virtual bool TryGetObjectDisplayName(const FGuid& ObjectId, FText& OutDisplayName) const override;
virtual void UnbindPossessableObjects(const FGuid& ObjectId) override;
protected:
/**
* Deselect all proxy actors in the Editor.
*
* @todo sequencer: remove Editor dependencies from this class
*/
SEQUENCER_API void DeselectAllActors();
/**
* Get the world that possessed actors belong to or where spawned actors should go.
*
* @return The world object.
* @todo sequencer: remove Editor dependencies from this class
*/
SEQUENCER_API UWorld* GetWorld() const;
private:
/** Handles changes of non-auto-keyed properties on any object. */
void HandlePropagateObjectChanges(UObject* Object);
/** Refresh either the reference actor or the data descriptor BP after its puppet proxy actor has been changed. */
void PropagateActorChanges(const FGuid& ObjectId, AActor* Actor);
private:
/** Collection of possessed objects. */
// @todo sequencer: gmp: need support for UStruct keys in TMap
UPROPERTY()
TMap<FString, FSequencerPossessedObject> PossessedObjects;
//TMap<FGuid, FSequencerBinding> Bindings;
/** The object change listener. */
TWeakPtr<ISequencerObjectChangeListener> ObjectChangeListener;
/** Collection of spawned proxy actors. */
TMap<FGuid, TWeakObjectPtr<AActor>> SpawnedActors;
};
| PopCap/GameIdea | Engine/Source/Editor/Sequencer/Private/SequencerMovieSceneObjectManager.h | C | bsd-2-clause | 2,416 | [
30522,
1013,
1013,
9385,
2687,
1011,
2325,
8680,
2399,
1010,
4297,
1012,
2035,
2916,
9235,
1012,
1001,
10975,
8490,
2863,
2320,
1001,
2421,
1000,
5691,
17968,
16429,
20614,
24805,
4590,
1012,
1044,
1000,
1001,
2421,
1000,
5537,
14536,
15094... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* =================================================================================================
* Copyright (C) 2015 Martin Albedinsky
* =================================================================================================
* Licensed under the Apache License, Version 2.0 or later (further "License" only).
* -------------------------------------------------------------------------------------------------
* You may use this file only in compliance with the License. More details and copy of this License
* you may obtain at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* You can redistribute, modify or publish any part of the code written within this file but as it
* is described in the License, the software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES or CONDITIONS OF ANY KIND.
*
* See the License for the specific language governing permissions and limitations under the License.
* =================================================================================================
*/
package com.albedinsky.android.intent;
import android.content.Intent;
import android.net.Uri;
/**
* @author Martin Albedinsky
*/
public final class PlayIntentTest extends IntentBaseTest<PlayIntent> {
@SuppressWarnings("unused")
private static final String TAG = "PlayIntentTest";
public PlayIntentTest() {
super(PlayIntent.class);
}
public void testDefaultPackageName() {
final String packageName = mIntent.packageName();
assertNotNull(packageName);
assertEquals(getActivity().getPackageName(), packageName);
}
public void testPackageName() {
mIntent.packageName("com.google.android.inbox");
assertEquals("com.google.android.inbox", mIntent.packageName());
}
public void testBuild() {
mIntent.packageName("com.google.android.inbox");
final Intent intent = mIntent.build();
assertNotNull(intent);
assertEquals(Intent.ACTION_VIEW, intent.getAction());
assertEquals(Uri.parse(PlayIntent.VIEW_URL_BASE + "com.google.android.inbox"), intent.getData());
}
public void testBuildWithInvalidPackageName() {
mIntent.packageName("");
assertBuildThrowsExceptionWithCause(
mIntent,
"No package name specified."
);
}
} | android-libraries/android_intents | library/src/androidTest/java/com/albedinsky/android/intent/PlayIntentTest.java | Java | apache-2.0 | 2,280 | [
30522,
1013,
1008,
1008,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
MIT License
Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer
For full license see LICENSE in the root directory of this project.
*/
using System;
using Sigma.Core.Utils;
namespace Sigma.Core.Monitors
{
public interface IMonitor : IDisposable
{
/// <summary>
/// This function will be called before the start of the monitor.
/// </summary>
void Initialise();
/// <summary>
/// Start this <see cref="IMonitor"/>.
/// If the <see cref="IMonitor"/> runs in a new <see cref="System.Threading.Thread"/>, this function should block until the monitor is completely up and running.
/// </summary>
void Start();
/// <summary>
/// Signal this <see cref="IMonitor"/> to stop. This method should call dispose.
/// This could for example stop the Sigma learning process (if mandatory), or clear up registry entries, resources ...
/// </summary>
void SignalStop();
/// <summary>
/// The sigma environment associated with this monitor.
/// </summary>
SigmaEnvironment Sigma { get; set; }
IRegistry Registry { get; set; }
}
}
| GreekDictionary/Sigma | Sigma.Core/Monitors/IMonitor.cs | C# | mit | 1,074 | [
30522,
1013,
1008,
10210,
6105,
9385,
1006,
1039,
1007,
2355,
1011,
2418,
29517,
14124,
2099,
1010,
2745,
5810,
2121,
2005,
2440,
6105,
2156,
6105,
1999,
1996,
7117,
14176,
1997,
2023,
2622,
1012,
1008,
1013,
2478,
2291,
1025,
2478,
13201,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* $Id$
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.struts2.osgi;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.struts2.osgi.host.OsgiHost;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Helper class that find resources and loads classes from the list of bundles
*/
public class DefaultBundleAccessor implements BundleAccessor {
private static DefaultBundleAccessor self;
private static final Logger LOG = LoggerFactory.getLogger(DefaultBundleAccessor.class);
private BundleContext bundleContext;
private Map<String, String> packageToBundle = new HashMap<String, String>();
private Map<Bundle, Set<String>> packagesByBundle = new HashMap<Bundle, Set<String>>();
private OsgiHost osgiHost;
public DefaultBundleAccessor() {
self = this;
}
public static DefaultBundleAccessor getInstance() {
return self;
}
public Object getService(ServiceReference ref) {
return bundleContext != null ? bundleContext.getService(ref) : null;
}
public ServiceReference getServiceReference(String className) {
return bundleContext != null ? bundleContext.getServiceReference(className) : null;
}
public ServiceReference[] getAllServiceReferences(String className) {
if (bundleContext != null) {
try {
return bundleContext.getServiceReferences(className, null);
} catch (InvalidSyntaxException e) {
//cannot happen we are passing null as the param
if (LOG.isErrorEnabled())
LOG.error("Invalid syntax for service lookup", e);
}
}
return null;
}
public ServiceReference[] getServiceReferences(String className, String params) throws InvalidSyntaxException {
return bundleContext != null ? bundleContext.getServiceReferences(className, params) : null;
}
/**
* Add as Bundle -> Package mapping
* @param bundle the bundle where the package was loaded from
* @param packageName the anme of the loaded package
*/
public void addPackageFromBundle(Bundle bundle, String packageName) {
this.packageToBundle.put(packageName, bundle.getSymbolicName());
Set<String> pkgs = packagesByBundle.get(bundle);
if (pkgs == null) {
pkgs = new HashSet<String>();
packagesByBundle.put(bundle, pkgs);
}
pkgs.add(packageName);
}
public Class<?> loadClass(String className) throws ClassNotFoundException {
Bundle bundle = getCurrentBundle();
if (bundle != null) {
Class cls = bundle.loadClass(className);
if (LOG.isTraceEnabled())
LOG.trace("Located class [#0] in bundle [#1]", className, bundle.getSymbolicName());
return cls;
}
throw new ClassNotFoundException("Unable to find class " + className);
}
private Bundle getCurrentBundle() {
ActionContext ctx = ActionContext.getContext();
String bundleName = (String) ctx.get(CURRENT_BUNDLE_NAME);
if (bundleName == null) {
ActionInvocation inv = ctx.getActionInvocation();
ActionProxy proxy = inv.getProxy();
ActionConfig actionConfig = proxy.getConfig();
bundleName = packageToBundle.get(actionConfig.getPackageName());
}
if (bundleName != null) {
return osgiHost.getActiveBundles().get(bundleName);
}
return null;
}
public List<URL> loadResources(String name) throws IOException {
return loadResources(name, false);
}
public List<URL> loadResources(String name, boolean translate) throws IOException {
Bundle bundle = getCurrentBundle();
if (bundle != null) {
List<URL> resources = new ArrayList<URL>();
Enumeration e = bundle.getResources(name);
if (e != null) {
while (e.hasMoreElements()) {
resources.add(translate ? OsgiUtil.translateBundleURLToJarURL((URL) e.nextElement(), getCurrentBundle()) : (URL) e.nextElement());
}
}
return resources;
}
return null;
}
public URL loadResourceFromAllBundles(String name) throws IOException {
for (Map.Entry<String, Bundle> entry : osgiHost.getActiveBundles().entrySet()) {
Enumeration e = entry.getValue().getResources(name);
if (e != null && e.hasMoreElements()) {
return (URL) e.nextElement();
}
}
return null;
}
public InputStream loadResourceFromAllBundlesAsStream(String name) throws IOException {
URL url = loadResourceFromAllBundles(name);
if (url != null) {
return url.openStream();
}
return null;
}
public URL loadResource(String name) {
return loadResource(name, false);
}
public URL loadResource(String name, boolean translate) {
Bundle bundle = getCurrentBundle();
if (bundle != null) {
URL url = bundle.getResource(name);
try {
return translate ? OsgiUtil.translateBundleURLToJarURL(url, getCurrentBundle()) : url;
} catch (Exception e) {
if (LOG.isErrorEnabled()) {
LOG.error("Unable to translate bundle URL to jar URL", e);
}
return null;
}
}
return null;
}
public Set<String> getPackagesByBundle(Bundle bundle) {
return packagesByBundle.get(bundle);
}
public InputStream loadResourceAsStream(String name) throws IOException {
URL url = loadResource(name);
if (url != null) {
return url.openStream();
}
return null;
}
public void setBundleContext(BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
public void setOsgiHost(OsgiHost osgiHost) {
this.osgiHost = osgiHost;
}
}
| WillJiang/WillJiang | src/plugins/osgi/src/main/java/org/apache/struts2/osgi/DefaultBundleAccessor.java | Java | apache-2.0 | 7,481 | [
30522,
1013,
1008,
1008,
1002,
30524,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
1008,
2030,
2062,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
1008,
5500,
2007,
2023,
2147,
2005,
3176,
2592,
1008,
4953,
9385,
6095,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package net.inpercima.runandfun.service;
import static net.inpercima.runandfun.runkeeper.constants.RunkeeperConstants.ACTIVITIES_MEDIA;
import static net.inpercima.runandfun.runkeeper.constants.RunkeeperConstants.ACTIVITIES_URL_PAGE_SIZE_ONE;
import static net.inpercima.runandfun.runkeeper.constants.RunkeeperConstants.ACTIVITIES_URL_SPECIFIED_PAGE_SIZE_NO_EARLIER_THAN;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.inject.Inject;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.RangeQueryBuilder;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.stereotype.Service;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.inpercima.restapi.service.RestApiService;
import net.inpercima.runandfun.app.model.AppActivity;
import net.inpercima.runandfun.runkeeper.model.RunkeeperActivities;
import net.inpercima.runandfun.runkeeper.model.RunkeeperActivityItem;
/**
* @author Marcel Jänicke
* @author Sebastian Peters
* @since 26.01.2015
*/
@NoArgsConstructor
@Service
@Slf4j
public class ActivitiesService {
// initial release in 2008 according to http://en.wikipedia.org/wiki/RunKeeper
private static final LocalDate INITIAL_RELEASE_OF_RUNKEEPER = LocalDate.of(2008, 01, 01);
@Inject
private AuthService authService;
@Inject
private RestApiService restApiService;
@Inject
private ActivityRepository repository;
@Inject
private ElasticsearchRestTemplate elasticsearchRestTemplate;
public int indexActivities(final String accessToken) {
final Collection<AppActivity> activities = new ArrayList<>();
final String username = authService.getAppState(accessToken).getUsername();
listActivities(accessToken, calculateFetchDate()).stream().filter(item -> !repository.existsById(item.getId()))
.forEach(item -> addActivity(item, username, activities));
log.info("new activities: {}", activities.size());
if (!activities.isEmpty()) {
repository.saveAll(activities);
}
return activities.size();
}
/**
* List activities live from runkeeper with an accessToken and a date. The full
* size will be determined every time but with the given date only the last
* items will be collected with a max. of the full size.
*
* @param accessToken
* @param from
* @return list of activity items
*/
private List<RunkeeperActivityItem> listActivities(final String accessToken, final LocalDate from) {
log.debug("list activities for token {} until {}", accessToken, from);
// get one item only to get full size
int pageSize = restApiService
.getForObject(ACTIVITIES_URL_PAGE_SIZE_ONE, ACTIVITIES_MEDIA, accessToken, RunkeeperActivities.class)
.getBody().getSize();
// list new activities from given date with max. full size
return restApiService.getForObject(
String.format(ACTIVITIES_URL_SPECIFIED_PAGE_SIZE_NO_EARLIER_THAN, pageSize,
from.format(DateTimeFormatter.ISO_LOCAL_DATE)),
ACTIVITIES_MEDIA, accessToken, RunkeeperActivities.class).getBody().getItemsAsList();
}
private LocalDate calculateFetchDate() {
final AppActivity activity = getLastActivity();
return activity == null ? INITIAL_RELEASE_OF_RUNKEEPER : activity.getDate().toLocalDate();
}
private void addActivity(final RunkeeperActivityItem item, final String username,
final Collection<AppActivity> activities) {
final AppActivity activity = new AppActivity(item.getId(), username, item.getType(), item.getDate(),
item.getDistance(), item.getDuration());
log.debug("prepare {}", activity);
activities.add(activity);
}
/**
* Get last activity from app repository.
*
* @return last activity
*/
public AppActivity getLastActivity() {
return repository.findTopByOrderByDateDesc();
}
/**
* Count activities from app repository.
*
* @return count
*/
public Long countActivities() {
return repository.count();
}
/**
* List activites from app repository.
*
* @param pageable
* @param types
* @param minDate
* @param maxDate
* @param minDistance
* @param maxDistance
* @param query
* @return
*/
public SearchHits<AppActivity> listActivities(final Pageable pageable, final String types, final LocalDate minDate,
final LocalDate maxDate, final Float minDistance, final Float maxDistance, final String query) {
final BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
if (!Strings.isNullOrEmpty(types)) {
final BoolQueryBuilder typesQuery = QueryBuilders.boolQuery();
for (final String type : Splitter.on(',').split(types)) {
typesQuery.should(QueryBuilders.termQuery(AppActivity.FIELD_TYPE, type));
}
queryBuilder.must(typesQuery);
}
if (minDate != null || maxDate != null) {
addDateQuery(queryBuilder, minDate, maxDate);
}
if (minDistance != null || maxDistance != null) {
addDistanceQuery(queryBuilder, minDistance, maxDistance);
}
if (!Strings.isNullOrEmpty(query)) {
addFulltextQuery(queryBuilder, query);
}
if (!queryBuilder.hasClauses()) {
queryBuilder.must(QueryBuilders.matchAllQuery());
}
log.info("{}", queryBuilder);
return elasticsearchRestTemplate.search(
new NativeSearchQueryBuilder().withPageable(pageable).withQuery(queryBuilder).build(),
AppActivity.class, IndexCoordinates.of("activity"));
}
private static void addFulltextQuery(final BoolQueryBuilder queryBuilder, final String query) {
queryBuilder.must(QueryBuilders.termQuery("_all", query.trim()));
}
private static void addDateQuery(final BoolQueryBuilder queryBuilder, final LocalDate minDate,
final LocalDate maxDate) {
final RangeQueryBuilder rangeQuery = QueryBuilders.rangeQuery(AppActivity.FIELD_DATE);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmss'Z'");
if (minDate != null) {
LocalDateTime minDateTime = minDate.atStartOfDay();
rangeQuery.gte(minDateTime.format(formatter));
}
if (maxDate != null) {
LocalDateTime maxDateTime = maxDate.atStartOfDay();
rangeQuery.lte(maxDateTime.format(formatter));
}
queryBuilder.must(rangeQuery);
}
private static void addDistanceQuery(final BoolQueryBuilder queryBuilder, final Float minDistance,
final Float maxDistance) {
final RangeQueryBuilder rangeQuery = QueryBuilders.rangeQuery(AppActivity.FIELD_DISTANCE);
if (minDistance != null) {
rangeQuery.gte(minDistance);
}
if (maxDistance != null) {
rangeQuery.lte(maxDistance);
}
queryBuilder.must(rangeQuery);
}
}
| inpercima/run-and-fun | server/src/main/java/net/inpercima/runandfun/service/ActivitiesService.java | Java | mit | 7,790 | [
30522,
7427,
5658,
1012,
1999,
4842,
6895,
2863,
1012,
2448,
5685,
11263,
2078,
1012,
2326,
1025,
12324,
10763,
5658,
1012,
1999,
4842,
6895,
2863,
1012,
2448,
5685,
11263,
2078,
1012,
2448,
13106,
1012,
5377,
2015,
1012,
2448,
13106,
8663,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#ifndef RECTANGLE_H
#define RECTANGLE_H
#include "Polygon.h"
class Rectangle : public Polygon
{
public:
Rectangle(int width, int height);
int getArea();
protected:
private:
};
#endif // RECTANGLE_H
| BlackSpirit96/learning_cpp | exercise_pack_1/exercise_5/include/Rectangle.h | C | mit | 228 | [
30522,
1001,
2065,
13629,
2546,
28667,
23395,
1035,
1044,
1001,
9375,
28667,
23395,
1035,
1044,
1001,
2421,
1000,
26572,
7446,
1012,
1044,
1000,
2465,
28667,
23395,
1024,
2270,
26572,
7446,
1063,
2270,
1024,
28667,
23395,
1006,
20014,
9381,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import shaven from 'shaven'
const svgNS = 'http://www.w3.org/2000/svg'
export default function (svg, config) {
const yDensity = 0.1
const yRange = config.max.value - config.min.value
const graphHeight = config.height * 0.8
const graphWidth = config.width * 0.95
const coSysHeight = config.height * 0.6
const coSysWidth = config.width * 0.85
const barchart = shaven(
['g', {
transform: 'translate(' +
[graphWidth * 0.1, graphHeight].join() +
')',
}], svgNS,
)[0]
const coordinateSystem = shaven(['g'], svgNS)[0]
const bars = shaven(['g'], svgNS)[0]
function buildCoordinateSystem () {
function ordinates () {
let cssClass
let index
for (index = 0; index < config.size; index++) {
cssClass = index === 0
? 'vectual_coordinate_axis_y'
: 'vectual_coordinate_lines_y'
shaven(
[coordinateSystem,
['line', {
class: cssClass,
x1: (coSysWidth / config.size) * index,
y1: '5',
x2: (coSysWidth / config.size) * index,
y2: -coSysHeight,
}],
['text', config.keys[index], {
class: 'vectual_coordinate_labels_x',
transform: 'rotate(40 ' +
((coSysWidth / config.size) * index) +
', 10)',
// eslint-disable-next-line id-length
x: (coSysWidth / config.size) * index,
y: 10, // eslint-disable-line id-length
}],
], svgNS,
)
}
}
function abscissas () {
let styleClass
let index
for (index = 0; index <= (yRange * yDensity); index++) {
styleClass = index === 0
? 'vectual_coordinate_axis_x'
: 'vectual_coordinate_lines_x'
shaven(
[coordinateSystem,
['line', {
class: styleClass,
x1: -5,
y1: -(coSysHeight / yRange) * (index / yDensity),
x2: coSysWidth,
y2: -(coSysHeight / yRange) * (index / yDensity),
}],
['text', String(index / yDensity + config.min.value), {
class: 'vectual_coordinate_labels_y',
x: -coSysWidth * 0.05, // eslint-disable-line id-length
// eslint-disable-next-line id-length
y: -(coSysHeight / yRange) * (index / yDensity),
}],
], svgNS,
)
}
}
abscissas()
ordinates()
}
function buildBars () {
function drawBar (element, index) {
const height = config.animations
? 0
: (config.values[index] - config.min.value) * (coSysHeight / yRange)
const bar = shaven(
['rect',
{
class: 'vectual_bar_bar',
// eslint-disable-next-line id-length
x: index * (coSysWidth / config.size),
// eslint-disable-next-line id-length
y: -(config.values[index] - config.min.value) *
(coSysHeight / yRange),
height: height,
width: 0.7 * (coSysWidth / config.size),
},
['title', config.keys[index] + ': ' + config.values[index]],
],
svgNS,
)[0]
function localSetAnimations () {
shaven(
[bar,
['animate', {
attributeName: 'height',
to: (config.values[index] - config.min.value) *
(coSysHeight / yRange),
begin: '0s',
dur: '1s',
fill: 'freeze',
}],
['animate', {
attributeName: 'y',
from: 0,
to: -(config.values[index] - config.min.value) *
(coSysHeight / yRange),
begin: '0s',
dur: '1s',
fill: 'freeze',
}],
['animate', {
attributeName: 'fill',
to: 'rgb(100,210,255)',
begin: 'mouseover',
dur: '100ms',
fill: 'freeze',
additive: 'replace',
}],
['animate', {
attributeName: 'fill',
to: 'rgb(0,150,250)',
begin: 'mouseout',
dur: '200ms',
fill: 'freeze',
additive: 'replace',
}],
], svgNS,
)
}
function localInject () {
shaven([bars, [bar]])
}
if (config.animations) localSetAnimations()
localInject()
}
config.data.forEach(drawBar)
}
function setAnimations () {
shaven(
[bars,
['animate', {
attributeName: 'opacity',
from: 0,
to: 0.8,
begin: '0s',
dur: '1s',
fill: 'freeze',
additive: 'replace',
}],
],
svgNS,
)
}
function inject () {
shaven(
[svg,
[barchart,
[coordinateSystem],
[bars],
],
],
)
}
buildCoordinateSystem()
buildBars()
if (config.animations) setAnimations()
inject()
return svg
}
| adius/vectual | src/javascript/bar.js | JavaScript | mit | 5,165 | [
30522,
12324,
27545,
2078,
2013,
1005,
27545,
2078,
1005,
9530,
3367,
17917,
16206,
2015,
1027,
1005,
8299,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
1012,
8917,
1013,
2456,
1013,
17917,
2290,
1005,
9167,
12398,
3853,
1006,
17917,
2290,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Copyright 2015 Google Inc.
#
# 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.
require 'google/apis/core/base_service'
require 'google/apis/core/json_representation'
require 'google/apis/core/hashable'
require 'google/apis/errors'
module Google
module Apis
module LifesciencesV2beta
# Cloud Life Sciences API
#
# Cloud Life Sciences is a suite of services and tools for managing, processing,
# and transforming life sciences data.
#
# @example
# require 'google/apis/lifesciences_v2beta'
#
# Lifesciences = Google::Apis::LifesciencesV2beta # Alias the module
# service = Lifesciences::CloudLifeSciencesService.new
#
# @see https://cloud.google.com/life-sciences
class CloudLifeSciencesService < Google::Apis::Core::BaseService
# @return [String]
# API key. Your API key identifies your project and provides you with API access,
# quota, and reports. Required unless you provide an OAuth 2.0 token.
attr_accessor :key
# @return [String]
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
attr_accessor :quota_user
def initialize
super('https://lifesciences.googleapis.com/', '')
@batch_path = 'batch'
end
# Gets information about a location.
# @param [String] name
# Resource name for the location.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::LifesciencesV2beta::Location] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::LifesciencesV2beta::Location]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_project_location(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v2beta/{+name}', options)
command.response_representation = Google::Apis::LifesciencesV2beta::Location::Representation
command.response_class = Google::Apis::LifesciencesV2beta::Location
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Lists information about the supported locations for this service.
# @param [String] name
# The resource that owns the locations collection, if applicable.
# @param [String] filter
# The standard list filter.
# @param [Fixnum] page_size
# The standard list page size.
# @param [String] page_token
# The standard list page token.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::LifesciencesV2beta::ListLocationsResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::LifesciencesV2beta::ListLocationsResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def list_project_locations(name, filter: nil, page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v2beta/{+name}/locations', options)
command.response_representation = Google::Apis::LifesciencesV2beta::ListLocationsResponse::Representation
command.response_class = Google::Apis::LifesciencesV2beta::ListLocationsResponse
command.params['name'] = name unless name.nil?
command.query['filter'] = filter unless filter.nil?
command.query['pageSize'] = page_size unless page_size.nil?
command.query['pageToken'] = page_token unless page_token.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Starts asynchronous cancellation on a long-running operation. The server makes
# a best effort to cancel the operation, but success is not guaranteed. Clients
# may use Operations.GetOperation or Operations.ListOperations to check whether
# the cancellation succeeded or the operation completed despite cancellation.
# Authorization requires the following [Google IAM](https://cloud.google.com/iam)
# permission: * `lifesciences.operations.cancel`
# @param [String] name
# The name of the operation resource to be cancelled.
# @param [Google::Apis::LifesciencesV2beta::CancelOperationRequest] cancel_operation_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::LifesciencesV2beta::Empty] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::LifesciencesV2beta::Empty]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def cancel_operation(name, cancel_operation_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v2beta/{+name}:cancel', options)
command.request_representation = Google::Apis::LifesciencesV2beta::CancelOperationRequest::Representation
command.request_object = cancel_operation_request_object
command.response_representation = Google::Apis::LifesciencesV2beta::Empty::Representation
command.response_class = Google::Apis::LifesciencesV2beta::Empty
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Gets the latest state of a long-running operation. Clients can use this method
# to poll the operation result at intervals as recommended by the API service.
# Authorization requires the following [Google IAM](https://cloud.google.com/iam)
# permission: * `lifesciences.operations.get`
# @param [String] name
# The name of the operation resource.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::LifesciencesV2beta::Operation] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::LifesciencesV2beta::Operation]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_project_location_operation(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v2beta/{+name}', options)
command.response_representation = Google::Apis::LifesciencesV2beta::Operation::Representation
command.response_class = Google::Apis::LifesciencesV2beta::Operation
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Lists operations that match the specified filter in the request. Authorization
# requires the following [Google IAM](https://cloud.google.com/iam) permission: *
# `lifesciences.operations.list`
# @param [String] name
# The name of the operation's parent resource.
# @param [String] filter
# A string for filtering Operations. The following filter fields are supported: *
# createTime: The time this job was created * events: The set of event (names)
# that have occurred while running the pipeline. The : operator can be used to
# determine if a particular event has occurred. * error: If the pipeline is
# running, this value is NULL. Once the pipeline finishes, the value is the
# standard Google error code. * labels.key or labels."key with space" where key
# is a label key. * done: If the pipeline is running, this value is false. Once
# the pipeline finishes, the value is true.
# @param [Fixnum] page_size
# The maximum number of results to return. The maximum value is 256.
# @param [String] page_token
# The standard list page token.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::LifesciencesV2beta::ListOperationsResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::LifesciencesV2beta::ListOperationsResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def list_project_location_operations(name, filter: nil, page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v2beta/{+name}/operations', options)
command.response_representation = Google::Apis::LifesciencesV2beta::ListOperationsResponse::Representation
command.response_class = Google::Apis::LifesciencesV2beta::ListOperationsResponse
command.params['name'] = name unless name.nil?
command.query['filter'] = filter unless filter.nil?
command.query['pageSize'] = page_size unless page_size.nil?
command.query['pageToken'] = page_token unless page_token.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Runs a pipeline. The returned Operation's metadata field will contain a google.
# cloud.lifesciences.v2beta.Metadata object describing the status of the
# pipeline execution. The response field will contain a google.cloud.
# lifesciences.v2beta.RunPipelineResponse object if the pipeline completes
# successfully. **Note:** Before you can use this method, the *Life Sciences
# Service Agent* must have access to your project. This is done automatically
# when the Cloud Life Sciences API is first enabled, but if you delete this
# permission you must disable and re-enable the API to grant the Life Sciences
# Service Agent the required permissions. Authorization requires the following [
# Google IAM](https://cloud.google.com/iam/) permission: * `lifesciences.
# workflows.run`
# @param [String] parent
# The project and location that this request should be executed against.
# @param [Google::Apis::LifesciencesV2beta::RunPipelineRequest] run_pipeline_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::LifesciencesV2beta::Operation] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::LifesciencesV2beta::Operation]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def run_pipeline(parent, run_pipeline_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v2beta/{+parent}/pipelines:run', options)
command.request_representation = Google::Apis::LifesciencesV2beta::RunPipelineRequest::Representation
command.request_object = run_pipeline_request_object
command.response_representation = Google::Apis::LifesciencesV2beta::Operation::Representation
command.response_class = Google::Apis::LifesciencesV2beta::Operation
command.params['parent'] = parent unless parent.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
protected
def apply_command_defaults(command)
command.query['key'] = key unless key.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
end
end
end
end
end
| googleapis/google-api-ruby-client | google-api-client/generated/google/apis/lifesciences_v2beta/service.rb | Ruby | apache-2.0 | 17,086 | [
30522,
1001,
9385,
2325,
8224,
4297,
1012,
1001,
1001,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1001,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
1999,
12646,
2007,
1996,
6105,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2003, 2010 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#include "core/html/HTMLParagraphElement.h"
#include "core/CSSPropertyNames.h"
#include "core/CSSValueKeywords.h"
#include "core/HTMLNames.h"
namespace blink {
using namespace HTMLNames;
inline HTMLParagraphElement::HTMLParagraphElement(Document& document)
: HTMLElement(pTag, document)
{
}
DEFINE_NODE_FACTORY(HTMLParagraphElement)
void HTMLParagraphElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style)
{
if (name == alignAttr) {
if (equalIgnoringCase(value, "middle") || equalIgnoringCase(value, "center"))
addPropertyToPresentationAttributeStyle(style, CSSPropertyTextAlign, CSSValueWebkitCenter);
else if (equalIgnoringCase(value, "left"))
addPropertyToPresentationAttributeStyle(style, CSSPropertyTextAlign, CSSValueWebkitLeft);
else if (equalIgnoringCase(value, "right"))
addPropertyToPresentationAttributeStyle(style, CSSPropertyTextAlign, CSSValueWebkitRight);
else
addPropertyToPresentationAttributeStyle(style, CSSPropertyTextAlign, value);
} else {
HTMLElement::collectStyleForPresentationAttribute(name, value, style);
}
}
} // namespace blink
| wuhengzhi/chromium-crosswalk | third_party/WebKit/Source/core/html/HTMLParagraphElement.cpp | C++ | bsd-3-clause | 2,197 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2639,
16357,
14161,
14511,
1006,
14161,
14511,
1030,
1047,
3207,
1012,
8917,
1007,
1008,
1006,
1039,
1007,
2639,
14405,
3775,
12849,
21997,
2080,
1006,
12849,
21997,
2080,
1030,
1047,
3207,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package org.openlmis.core.network.model;
import org.openlmis.core.model.Program;
import org.openlmis.core.model.User;
import java.util.List;
import lombok.Data;
@Data
public class UserResponse {
private User userInformation;
private List<Program> facilitySupportedPrograms;
}
| clintonhealthaccess/lmis-moz-mobile | app/src/main/java/org/openlmis/core/network/model/UserResponse.java | Java | agpl-3.0 | 288 | [
30522,
7427,
8917,
1012,
2330,
13728,
2483,
1012,
4563,
1012,
2897,
1012,
2944,
1025,
12324,
8917,
1012,
2330,
13728,
2483,
1012,
4563,
1012,
2944,
1012,
2565,
1025,
12324,
8917,
1012,
2330,
13728,
2483,
1012,
4563,
1012,
2944,
1012,
5310,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Copyright (c) 2003-present, Jodd Team (jodd.org). All Rights Reserved.
package jodd.util.collection;
import java.util.Arrays;
/**
* Storage for holding classes keys and values.
* It is <b>NOT</b> a <code>Map</code> instance. It is very fast
* on un-synchronized lookups, faster then <code>HashMap</code>.
* Uses identity for checking if <code>Class</code> keys are equal.
* <p>
* The initial version of this class was provided by @zqq90, from
* <a href="https://github.com/zqq90/webit-script/">WebIt-script</a>
* project. Thank you!
*/
public final class ClassMap<V> {
private static final int MAXIMUM_CAPACITY = 1 << 29;
private Entry<V>[] table;
private int threshold;
private int size;
/**
* Creates new map with given initial capacity.
*/
@SuppressWarnings("unchecked")
public ClassMap(int initialCapacity) {
int initlen;
if (initialCapacity > MAXIMUM_CAPACITY) {
initlen = MAXIMUM_CAPACITY;
}
else {
initlen = 16;
while (initlen < initialCapacity) {
initlen <<= 1;
}
}
this.table = new Entry[initlen];
this.threshold = (int) (initlen * 0.75f);
}
public ClassMap() {
this(64);
}
/**
* Returns total number of stored classes.
*/
public int size() {
return size;
}
/**
* Returns a value associated to a key in unsafe, but very fast way.
*/
public V unsafeGet(final Class key) {
final Entry<V>[] tab;
Entry<V> e = (tab = table)[key.hashCode() & (tab.length - 1)];
while (e != null) {
if (key == e.key) {
return e.value;
}
e = e.next;
}
return null;
}
/**
* Returns a value associated to a key in thread-safe way.
*/
public synchronized V get(Class key) {
return unsafeGet(key);
}
@SuppressWarnings("unchecked")
private void resize() {
if (size < threshold) {
return;
}
final Entry<V>[] oldTable = table;
final int oldCapacity = oldTable.length;
final int newCapacity = oldCapacity << 1;
if (newCapacity > MAXIMUM_CAPACITY) {
if (threshold == MAXIMUM_CAPACITY - 1) {
throw new IllegalStateException("Capacity exhausted");
}
threshold = MAXIMUM_CAPACITY - 1;
return;
}
final int newMark = newCapacity - 1;
final Entry<V>[] newTable = new Entry[newCapacity];
for (int i = oldCapacity; i-- > 0; ) {
int index;
for (Entry<V> old = oldTable[i], e; old != null; ) {
e = old;
old = old.next;
index = e.id & newMark;
e.next = newTable[index];
newTable[index] = e;
}
}
this.threshold = (int) (newCapacity * 0.75f);
// must be last
this.table = newTable;
}
/**
* Associates the specified value with the specified Class in this map.
* Returns the previous value associated with key, or <code>null</code>
* if there was no mapping for key.
*/
@SuppressWarnings("unchecked")
public synchronized V put(Class key, V value) {
final int id;
int index;
Entry<V>[] tab;
Entry<V> e = (tab = table)[index = (id = key.hashCode()) & (tab.length - 1)];
while (e != null) {
if (key == e.key) { // identity check
// key found, replace
V existing = e.value;
e.value = value;
return existing;
}
e = e.next;
}
if (size >= threshold) {
resize();
tab = table;
index = id & (tab.length - 1);
}
// creates the new entry
tab[index] = new Entry(id, key, value, tab[index]);
size++;
return null;
}
/**
* Clears the class map.
*/
public synchronized void clear() {
size = 0;
Arrays.fill(table, null);
}
/**
* Maps entry.
*/
private static final class Entry<V> {
final int id;
final Class key;
V value;
Entry<V> next;
private Entry(int id, Class key, V value, Entry<V> next) {
this.value = value;
this.id = id;
this.key = key;
this.next = next;
}
}
} | wsldl123292/jodd | jodd-core/src/main/java/jodd/util/collection/ClassMap.java | Java | bsd-3-clause | 3,740 | [
30522,
1013,
1013,
9385,
1006,
1039,
1007,
2494,
1011,
2556,
1010,
8183,
14141,
2136,
1006,
8183,
14141,
1012,
8917,
1007,
1012,
30524,
2003,
1026,
1038,
1028,
2025,
1026,
1013,
1038,
1028,
1037,
1026,
3642,
1028,
4949,
1026,
1013,
3642,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
label, input {
/* deinie la largeur globale des forms */
display: inline-table;
}
label {
width: 35%;
/* positionne les titres de chauqe formulaires à droite*/
text-align: right;
}
label + input {
width: 30%;
/* force les element a sur une nouvelle ligne a l'aide du marging */
margin: 0 30% 0 4%;
}
/* definition de couleurs pour le body*/
/* html puis body pour eviter des conflits avec le container invisible de bootstrap */
html, body {
height: 100%;
background-color: #303030;
}
/* container de bootstrap */
body {
color: #fff;
text-align: center;
text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
/* definition u style et de la couleur du footer contours arrondis et couleur orange*/
footer {
background-color: darkorange;
border-radius: 15px 50px;
}
/* definition des couleur du titre h2 */
h2 {
color: lightskyblue;
}
/* taille et couleur des separateurs*/
hr {
width: 60%;
border-color: #5f5f5f;
}
/* couleur des messages d'erreur sur la page d'accueil */
.errorlogin {
color: red;
}
/* classe attribué au logo */
.logo-wrapper {
display: table;
width: 100%; /* definition largeur maximale */
background-image: url("http://i.imgur.com/162DBwY.jpg"); /* image de fond */
border-radius: 15px 50px; /* bords arrondis */
-webkit-box-shadow: inset 0 0 100px rgba(0, 0, 0, 1); /* contours ombrés */
box-shadow: inset 0 0 100px rgba(0, 0, 0, 1); /* contours ombrés */
}
/* gros div dans le body qui engloble qui forme le body */
.ultimate-wrapper {
background-color: #4b4b4b; /* couleur */
border-radius: 15px 50px; /* bords arrondis */
}
.g-recaptcha {
padding-left: 15%; /* tentative pour centrer le recaptcha */
}
/*a partir d'ici tout est généré par bootstrap pour une template dont nous ne nous somme pas réelement servis*/
a,
a:focus,
a:hover {
color: #fff;
}
/* généré pas bootstrap couleur du text dans les boutons et autres zones de textes etc*/
input {
color: black;
}
/* généré pas bootstap */
div .inner .cover {
padding-top: 500px;
}
@media (min-width: 768px) {
.masthead-brand {
float: left;
}
.masthead-nav {
float: right;
}
}
.navbar {
background-color: #985f0d;
}
.btn-default,
.btn-default:hover,
.btn-default:focus {
color: #333;
text-shadow: none; /* Prevent inheritence from `body` */
background-color: #fff;
border: 1px solid #fff;
}
.col-lg-5 {
margin-left: auto;
margin-right: auto;
}
.site-wrapper-inner {
display: table-cell;
vertical-align: top;
}
.cover-container {
margin-right: auto;
margin-left: auto;
}
/* Padding for spacing */
.inner {
padding: 30px;
}
/*
* Header
*/
.masthead-brand {
margin-top: 10px;
margin-bottom: 10px;
}
.masthead-nav > li {
display: inline-block;
}
.masthead-nav > li + li {
margin-left: 20px;
}
.masthead-nav > li > a {
padding-right: 0;
padding-left: 0;
font-size: 16px;
font-weight: bold;
color: #fff; /* IE8 proofing */
color: rgba(255, 255, 255, .75);
border-bottom: 2px solid transparent;
}
.masthead-nav > li > a:hover,
.masthead-nav > li > a:focus {
background-color: transparent;
border-bottom-color: #a9a9a9;
border-bottom-color: rgba(255, 255, 255, .25);
}
.masthead-nav > .active > a,
.masthead-nav > .active > a:hover,
.masthead-nav > .active > a:focus {
color: #fff;
border-bottom-color: #fff;
}
.cover {
padding: 0 20px;
}
.cover .btn-lg {
padding: 10px 20px;
font-weight: bold;
}
.mastfoot {
color: #999; /* IE8 proofing */
color: rgba(255, 255, 255, .5);
}
/*
* Affix and center
*/
@media (min-width: 768px) {
/* Pull out the header and footer */
.masthead {
posion: fixed;
top: 0;
}
.mastfoot {
position: fixed;
bottom: 0;
}
/* Start the vertical centering */
.site-wrapper-inner {
vertical-align: middle;
}
/* Handle the widths */
.masthead,
.mastfoot,
.cover-container {
width: 100%; /* Must be percentage or pixels for horizontal alignment */
}
}
@media (min-width: 992px) {
.masthead,
.mastfoot,
.cover-container {
width: 700px;
}
}
.panel-body{
color: black;
}
| NicolasL76/Projet-WEB | css/cover.css | CSS | mit | 4,320 | [
30522,
3830,
1010,
7953,
1063,
1013,
1008,
14866,
8034,
2474,
2312,
3126,
3795,
2063,
4078,
3596,
1008,
1013,
4653,
1024,
23881,
1011,
2795,
1025,
1065,
3830,
1063,
9381,
1024,
3486,
1003,
1025,
1013,
1008,
2597,
2638,
4649,
14841,
19168,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
console.log("J U I loaded");
var timer;
var timer2;
var timer3;
var counter;
var cell;
var curCount = 0;
var gameLost = false;
var multiUp = 0;
var total = 10;
var score = 0;
var points = 100;
var board = [ 0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0];
var cellTypes = [
{name: "empty", color: "white"},
{name: "normal", color: "black"},
{name: "freeze", color: "blue"},
{name: "multi", color: "green"},
{name: "max", color: "yellow"},
{name: "super", color: "red"}
];
var WHITE = 0,
BLACK = 1,
BLUE = 2,
GREEN = 3,
YELLOW = 4,
RED = 5;
var randomType = function() {
var randomNum = Math.floor((Math.random() * 100) + 1);
if (randomNum < 88) return BLACK; // 88%
else if (randomNum < 91) return BLUE; // 3%
else if (randomNum < 94) return GREEN; // 3%
else if (randomNum < 97) return YELLOW; // 3%
else return RED; // 3%
};
// EFFECTS -------------------------------------------------------------
var freezeEffect = function() {
clearInterval(timer2);
setTimeout(function() {
timer2 = setInterval(tickCell, counter);
}, 2000);
};
var multiEffect = function() {
multiUp++;
points = Math.floor((1 + (multiUp * 0.1)) * points);
};
var maxEffect = function() {
total++;
};
var superEffect = function() {
for (var i = 0; i < board.length; i++) {
if (board[i] < 2) board[i] = 0;
};
};
// LOSING & PRINTSTATE ------------------------------------------------
var hasLost = function() {
var count = 0;
for (var i = 0; i < board.length; i++) {
if (board[i] > 0 && board[i] < 2) count++;
if (count > total) break;
};
curCount = count;
return count > total;
};
var printState = function() {
$("#max2").text(curCount);
$("#max4").text(total);
$("#score2").text(score);
};
// PICKCELL & FADE ----------------------------------------------------
var pickCell = function() {
var randomIndex;
do {
randomIndex = Math.floor(Math.random() * board.length);
}
while (board[randomIndex] !== 0);
board[randomIndex] = randomType();
var $fade = $("#cell" + randomIndex);
if (board[randomIndex] > BLACK) {
setTimeout(function() {
$fade.animate({backgroundColor: "white"}, 700);
setTimeout(function() {
board[randomIndex] = 0;
}, 690);
}, 1000);
};
};
// CLICK MOVE ---------------------------------------------------------
var click = function(evt) {
clickValue = parseInt(this.id.substr(4));
if (board[clickValue] > BLACK) {
$(this).stop()
.toggle("explode", {pieces:16})
.css({backgroundColor: "white"})
.fadeIn();
};
if (board[clickValue] === BLACK) score += points;
else if (board[clickValue] === BLUE) freezeEffect();
else if (board[clickValue] === GREEN) multiEffect();
else if (board[clickValue] === YELLOW) maxEffect();
else if (board[clickValue] === RED) superEffect();
board[clickValue] = 0;
render();
};
// RENDER -------------------------------------------------------------
var render = function() {
if (gameLost === false) renderBoard();
function renderBoard() {
board.forEach(function(cell, idx) {
var el = $('#cell' + idx);
el.css('background-color', cellTypes[cell].color);
});
};
};
// TICKS --------------------------------------------------------------
var tick = function() {
printState();
if (hasLost()) {
clearInterval(timer);
clearInterval(timer2);
gameLost = true;
var lose = function() {
$(".lose").css({opacity:1});
setTimeout(function() {
$(".lose").css({opacity:0});
}, 400);
};
timer3 = setInterval(lose, 800);
};
printState();
};
var tickCell = function() {
pickCell();
render();
clearInterval(timer2);
counter *= 0.99;
timer2 = setInterval(tickCell, counter);
};
// STARTGAME ----------------------------------------------------------
var startGame = function() {
for (var i = 0; i < board.length; i++) {
board[i] = 0;
};
curCount = 0;
gameLost = false;
multiUp = 0;
total = 10;
score = 0;
points = 100;
counter = 800;
printState();
render();
clearInterval(timer3);
clearInterval(timer2);
clearInterval(timer);
timer = setInterval(tick, 10);
timer2 = setInterval(tickCell, counter);
};
// BUTTONS ------------------------------------------------------------
$("#startgame").on('click', function() {
$(".one").css("display", "none");
$(".two").css("display","inline");
$(".three").css("display","none");
startGame();
});
$("#restart").on('click', function() {
startGame();
});
$("#mainmenu").on('click', function() {
$(".one").css("display", "inline");
$(".two").css("display","none");
$(".three").css("display","none");
});
$("#howtoplay").on('click', function() {
$(".one").css("display", "none");
$(".two").css("display","none");
$(".three").css("display","inline");
});
$("#mainmenu2").on('click', function() {
$(".one").css("display", "inline");
$(".two").css("display","none");
$(".three").css("display","none");
});
$("#startgame2").on('click', function() {
$(".one").css("display", "none");
$(".two").css("display","inline");
$(".three").css("display","none");
startGame();
});
var audio = document.getElementById("tomb");
var mute = document.getElementById('mute');
mute.onclick = function() {
audio.muted = !audio.muted;
};
audio.addEventListener('ended', function() {
this.currentTime = 0;
this.play();
}, false);
// EVENTLISTENERS -----------------------------------------------------
document.addEventListener("DOMContentLoaded", function(evt) {
var cellEls = document.querySelectorAll("td");
for (var i = 0; i < board.length; i++) {
cellEls[i].addEventListener("click", click);
};
});
| JYC422/JUI | js/main.js | JavaScript | mit | 6,021 | [
30522,
10122,
1012,
8833,
1006,
1000,
1046,
1057,
1045,
8209,
1000,
1007,
1025,
13075,
25309,
1025,
13075,
25309,
2475,
1025,
13075,
25309,
2509,
1025,
13075,
4675,
1025,
13075,
3526,
1025,
13075,
12731,
29566,
16671,
1027,
1014,
1025,
13075,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
from __future__ import absolute_import
input_name = '../examples/multi_physics/thermo_elasticity_ess.py'
output_name = 'test_thermo_elasticity_ess.vtk'
from tests_basic import TestInput
class Test(TestInput):
pass
| vlukes/sfepy | tests/test_input_thermo_elasticity_ess.py | Python | bsd-3-clause | 219 | [
30522,
2013,
1035,
1035,
2925,
1035,
1035,
12324,
7619,
1035,
12324,
7953,
1035,
2171,
1027,
1005,
1012,
1012,
1013,
4973,
1013,
4800,
1035,
5584,
1013,
1996,
10867,
2080,
1035,
21274,
3012,
1035,
9686,
2015,
1012,
1052,
2100,
1005,
6434,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.
return [
'beatmapsets' => [
'covers' => [
'regenerate' => 'Regenerer',
'regenerating' => 'Regenererer...',
'remove' => 'Fjern',
'removing' => 'Fjerner...',
'title' => 'Beatmapset covers',
],
'show' => [
'covers' => 'Administrer Beatmapset Covers',
'discussion' => [
'_' => 'Modding v2',
'activate' => 'aktiver',
'activate_confirm' => 'aktiver modding v2 for denne beatmap?',
'active' => 'aktiv',
'inactive' => 'inaktiv',
],
],
],
'forum' => [
'forum-covers' => [
'index' => [
'delete' => 'Fjern',
'forum-name' => 'Forum #:id: :name',
'no-cover' => 'Intet cover set',
'submit' => [
'save' => 'Gem',
'update' => 'Opdater',
],
'title' => 'Forum Covers Liste',
'type-title' => [
'default-topic' => 'Standard Topic Cover',
'main' => 'Forum Cover',
],
],
],
],
'logs' => [
'index' => [
'title' => 'Logbog',
],
],
'pages' => [
'root' => [
'sections' => [
'beatmapsets' => 'Beatmapset',
'forum' => 'Forum',
'general' => 'Generelt',
'store' => 'Butik',
],
],
],
'store' => [
'orders' => [
'index' => [
'title' => 'Ordre Katalogisering',
],
],
],
'users' => [
'restricted_banner' => [
'title' => 'Denne bruger er i øjeblikket begrænset.',
'message' => '(kun administratorer kan se dette)',
],
],
];
| nekodex/osu-web | resources/lang/da/admin.php | PHP | agpl-3.0 | 2,118 | [
30522,
1026,
1029,
25718,
1013,
1013,
9385,
1006,
1039,
1007,
4903,
2100,
13866,
2100,
5183,
1026,
3967,
1030,
4903,
2100,
1012,
14021,
1028,
1012,
7000,
2104,
1996,
27004,
21358,
7512,
2080,
2236,
2270,
6105,
1058,
2509,
1012,
1014,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Error for services to through when they encounter a problem with the request.
* Distinguishes between a bad service request and a general error
*/
function ServiceError(message) {
this.name = "ServiceError";
this.message = (message || "");
}
ServiceError.prototype = Object.create(Error.prototype, {
constructor: {value: ServiceError}
});
/**
* Error for when an item is not found
*/
function NotFoundError(message) {
this.name = "NotFoundError";
this.message = (message || "Not found");
}
NotFoundError.prototype = Object.create(ServiceError.prototype, {
constructor: { value: NotFoundError}
});
exports.ServiceError = ServiceError;
exports.NotFoundError = NotFoundError; | James-Tolley/Manny.js | src/services/errors.js | JavaScript | mit | 692 | [
30522,
1013,
1008,
1008,
1008,
7561,
2005,
2578,
2000,
2083,
2043,
2027,
8087,
1037,
3291,
2007,
1996,
5227,
1012,
1008,
27343,
2090,
1037,
2919,
2326,
5227,
1998,
1037,
2236,
7561,
1008,
1013,
3853,
2326,
2121,
29165,
1006,
4471,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# hard
[![experimental][stability-image]][stability-url]
## Why?
## Installation
```sh
$ npm install akileez\hard
```
## Usage
```js
```
## API
```js
```
## See Also
## License [![ISC license][license-img]][license-url]
[ISC](https://tldrlegal.com/license/-isc-license)
[stability-image]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square
[stability-url]: https://github.com/akileez/hard
[license-img]: https://img.shields.io/badge/license-ISC-blue.svg?style=flat-square
[license-url]: https://github.com/akileez/npinit/blob/master/license.md | akileez/hard | README.md | Markdown | isc | 584 | [
30522,
1001,
2524,
1031,
999,
1031,
6388,
1033,
1031,
9211,
1011,
3746,
1033,
1033,
1031,
9211,
1011,
24471,
2140,
1033,
1001,
1001,
2339,
1029,
1001,
1001,
8272,
1036,
1036,
1036,
14021,
1002,
27937,
2213,
16500,
17712,
9463,
9351,
1032,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<HTML>
<BODY BGCOLOR="white">
<PRE>
<FONT color="green">001</FONT> package org.apache.lucene.demo;<a name="line.1"></a>
<FONT color="green">002</FONT> <a name="line.2"></a>
<FONT color="green">003</FONT> /*<a name="line.3"></a>
<FONT color="green">004</FONT> * Licensed to the Apache Software Foundation (ASF) under one or more<a name="line.4"></a>
<FONT color="green">005</FONT> * contributor license agreements. See the NOTICE file distributed with<a name="line.5"></a>
<FONT color="green">006</FONT> * this work for additional information regarding copyright ownership.<a name="line.6"></a>
<FONT color="green">007</FONT> * The ASF licenses this file to You under the Apache License, Version 2.0<a name="line.7"></a>
<FONT color="green">008</FONT> * (the "License"); you may not use this file except in compliance with<a name="line.8"></a>
<FONT color="green">009</FONT> * the License. You may obtain a copy of the License at<a name="line.9"></a>
<FONT color="green">010</FONT> *<a name="line.10"></a>
<FONT color="green">011</FONT> * http://www.apache.org/licenses/LICENSE-2.0<a name="line.11"></a>
<FONT color="green">012</FONT> *<a name="line.12"></a>
<FONT color="green">013</FONT> * Unless required by applicable law or agreed to in writing, software<a name="line.13"></a>
<FONT color="green">014</FONT> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.14"></a>
<FONT color="green">015</FONT> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.15"></a>
<FONT color="green">016</FONT> * See the License for the specific language governing permissions and<a name="line.16"></a>
<FONT color="green">017</FONT> * limitations under the License.<a name="line.17"></a>
<FONT color="green">018</FONT> */<a name="line.18"></a>
<FONT color="green">019</FONT> <a name="line.19"></a>
<FONT color="green">020</FONT> import java.io.BufferedReader;<a name="line.20"></a>
<FONT color="green">021</FONT> import java.io.File;<a name="line.21"></a>
<FONT color="green">022</FONT> import java.io.FileInputStream;<a name="line.22"></a>
<FONT color="green">023</FONT> import java.io.IOException;<a name="line.23"></a>
<FONT color="green">024</FONT> import java.io.InputStreamReader;<a name="line.24"></a>
<FONT color="green">025</FONT> import java.util.Date;<a name="line.25"></a>
<FONT color="green">026</FONT> <a name="line.26"></a>
<FONT color="green">027</FONT> import org.apache.lucene.analysis.Analyzer;<a name="line.27"></a>
<FONT color="green">028</FONT> import org.apache.lucene.analysis.standard.StandardAnalyzer;<a name="line.28"></a>
<FONT color="green">029</FONT> import org.apache.lucene.document.Document;<a name="line.29"></a>
<FONT color="green">030</FONT> import org.apache.lucene.index.DirectoryReader;<a name="line.30"></a>
<FONT color="green">031</FONT> import org.apache.lucene.index.IndexReader;<a name="line.31"></a>
<FONT color="green">032</FONT> import org.apache.lucene.queryparser.classic.QueryParser;<a name="line.32"></a>
<FONT color="green">033</FONT> import org.apache.lucene.search.IndexSearcher;<a name="line.33"></a>
<FONT color="green">034</FONT> import org.apache.lucene.search.Query;<a name="line.34"></a>
<FONT color="green">035</FONT> import org.apache.lucene.search.ScoreDoc;<a name="line.35"></a>
<FONT color="green">036</FONT> import org.apache.lucene.search.TopDocs;<a name="line.36"></a>
<FONT color="green">037</FONT> import org.apache.lucene.store.FSDirectory;<a name="line.37"></a>
<FONT color="green">038</FONT> import org.apache.lucene.util.Version;<a name="line.38"></a>
<FONT color="green">039</FONT> <a name="line.39"></a>
<FONT color="green">040</FONT> /** Simple command-line based search demo. */<a name="line.40"></a>
<FONT color="green">041</FONT> public class SearchFiles {<a name="line.41"></a>
<FONT color="green">042</FONT> <a name="line.42"></a>
<FONT color="green">043</FONT> private SearchFiles() {}<a name="line.43"></a>
<FONT color="green">044</FONT> <a name="line.44"></a>
<FONT color="green">045</FONT> /** Simple command-line based search demo. */<a name="line.45"></a>
<FONT color="green">046</FONT> public static void main(String[] args) throws Exception {<a name="line.46"></a>
<FONT color="green">047</FONT> String usage =<a name="line.47"></a>
<FONT color="green">048</FONT> "Usage:\tjava org.apache.lucene.demo.SearchFiles [-index dir] [-field f] [-repeat n] [-queries file] [-query string] [-raw] [-paging hitsPerPage]\n\nSee http://lucene.apache.org/java/4_0/demo.html for details.";<a name="line.48"></a>
<FONT color="green">049</FONT> if (args.length > 0 && ("-h".equals(args[0]) || "-help".equals(args[0]))) {<a name="line.49"></a>
<FONT color="green">050</FONT> System.out.println(usage);<a name="line.50"></a>
<FONT color="green">051</FONT> System.exit(0);<a name="line.51"></a>
<FONT color="green">052</FONT> }<a name="line.52"></a>
<FONT color="green">053</FONT> <a name="line.53"></a>
<FONT color="green">054</FONT> String index = "index";<a name="line.54"></a>
<FONT color="green">055</FONT> String field = "contents";<a name="line.55"></a>
<FONT color="green">056</FONT> String queries = null;<a name="line.56"></a>
<FONT color="green">057</FONT> int repeat = 0;<a name="line.57"></a>
<FONT color="green">058</FONT> boolean raw = false;<a name="line.58"></a>
<FONT color="green">059</FONT> String queryString = null;<a name="line.59"></a>
<FONT color="green">060</FONT> int hitsPerPage = 10;<a name="line.60"></a>
<FONT color="green">061</FONT> <a name="line.61"></a>
<FONT color="green">062</FONT> for(int i = 0;i < args.length;i++) {<a name="line.62"></a>
<FONT color="green">063</FONT> if ("-index".equals(args[i])) {<a name="line.63"></a>
<FONT color="green">064</FONT> index = args[i+1];<a name="line.64"></a>
<FONT color="green">065</FONT> i++;<a name="line.65"></a>
<FONT color="green">066</FONT> } else if ("-field".equals(args[i])) {<a name="line.66"></a>
<FONT color="green">067</FONT> field = args[i+1];<a name="line.67"></a>
<FONT color="green">068</FONT> i++;<a name="line.68"></a>
<FONT color="green">069</FONT> } else if ("-queries".equals(args[i])) {<a name="line.69"></a>
<FONT color="green">070</FONT> queries = args[i+1];<a name="line.70"></a>
<FONT color="green">071</FONT> i++;<a name="line.71"></a>
<FONT color="green">072</FONT> } else if ("-query".equals(args[i])) {<a name="line.72"></a>
<FONT color="green">073</FONT> queryString = args[i+1];<a name="line.73"></a>
<FONT color="green">074</FONT> i++;<a name="line.74"></a>
<FONT color="green">075</FONT> } else if ("-repeat".equals(args[i])) {<a name="line.75"></a>
<FONT color="green">076</FONT> repeat = Integer.parseInt(args[i+1]);<a name="line.76"></a>
<FONT color="green">077</FONT> i++;<a name="line.77"></a>
<FONT color="green">078</FONT> } else if ("-raw".equals(args[i])) {<a name="line.78"></a>
<FONT color="green">079</FONT> raw = true;<a name="line.79"></a>
<FONT color="green">080</FONT> } else if ("-paging".equals(args[i])) {<a name="line.80"></a>
<FONT color="green">081</FONT> hitsPerPage = Integer.parseInt(args[i+1]);<a name="line.81"></a>
<FONT color="green">082</FONT> if (hitsPerPage <= 0) {<a name="line.82"></a>
<FONT color="green">083</FONT> System.err.println("There must be at least 1 hit per page.");<a name="line.83"></a>
<FONT color="green">084</FONT> System.exit(1);<a name="line.84"></a>
<FONT color="green">085</FONT> }<a name="line.85"></a>
<FONT color="green">086</FONT> i++;<a name="line.86"></a>
<FONT color="green">087</FONT> }<a name="line.87"></a>
<FONT color="green">088</FONT> }<a name="line.88"></a>
<FONT color="green">089</FONT> <a name="line.89"></a>
<FONT color="green">090</FONT> IndexReader reader = DirectoryReader.open(FSDirectory.open(new File(index)));<a name="line.90"></a>
<FONT color="green">091</FONT> IndexSearcher searcher = new IndexSearcher(reader);<a name="line.91"></a>
<FONT color="green">092</FONT> Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_40);<a name="line.92"></a>
<FONT color="green">093</FONT> <a name="line.93"></a>
<FONT color="green">094</FONT> BufferedReader in = null;<a name="line.94"></a>
<FONT color="green">095</FONT> if (queries != null) {<a name="line.95"></a>
<FONT color="green">096</FONT> in = new BufferedReader(new InputStreamReader(new FileInputStream(queries), "UTF-8"));<a name="line.96"></a>
<FONT color="green">097</FONT> } else {<a name="line.97"></a>
<FONT color="green">098</FONT> in = new BufferedReader(new InputStreamReader(System.in, "UTF-8"));<a name="line.98"></a>
<FONT color="green">099</FONT> }<a name="line.99"></a>
<FONT color="green">100</FONT> QueryParser parser = new QueryParser(Version.LUCENE_40, field, analyzer);<a name="line.100"></a>
<FONT color="green">101</FONT> while (true) {<a name="line.101"></a>
<FONT color="green">102</FONT> if (queries == null && queryString == null) { // prompt the user<a name="line.102"></a>
<FONT color="green">103</FONT> System.out.println("Enter query: ");<a name="line.103"></a>
<FONT color="green">104</FONT> }<a name="line.104"></a>
<FONT color="green">105</FONT> <a name="line.105"></a>
<FONT color="green">106</FONT> String line = queryString != null ? queryString : in.readLine();<a name="line.106"></a>
<FONT color="green">107</FONT> <a name="line.107"></a>
<FONT color="green">108</FONT> if (line == null || line.length() == -1) {<a name="line.108"></a>
<FONT color="green">109</FONT> break;<a name="line.109"></a>
<FONT color="green">110</FONT> }<a name="line.110"></a>
<FONT color="green">111</FONT> <a name="line.111"></a>
<FONT color="green">112</FONT> line = line.trim();<a name="line.112"></a>
<FONT color="green">113</FONT> if (line.length() == 0) {<a name="line.113"></a>
<FONT color="green">114</FONT> break;<a name="line.114"></a>
<FONT color="green">115</FONT> }<a name="line.115"></a>
<FONT color="green">116</FONT> <a name="line.116"></a>
<FONT color="green">117</FONT> Query query = parser.parse(line);<a name="line.117"></a>
<FONT color="green">118</FONT> System.out.println("Searching for: " + query.toString(field));<a name="line.118"></a>
<FONT color="green">119</FONT> <a name="line.119"></a>
<FONT color="green">120</FONT> if (repeat > 0) { // repeat & time as benchmark<a name="line.120"></a>
<FONT color="green">121</FONT> Date start = new Date();<a name="line.121"></a>
<FONT color="green">122</FONT> for (int i = 0; i < repeat; i++) {<a name="line.122"></a>
<FONT color="green">123</FONT> searcher.search(query, null, 100);<a name="line.123"></a>
<FONT color="green">124</FONT> }<a name="line.124"></a>
<FONT color="green">125</FONT> Date end = new Date();<a name="line.125"></a>
<FONT color="green">126</FONT> System.out.println("Time: "+(end.getTime()-start.getTime())+"ms");<a name="line.126"></a>
<FONT color="green">127</FONT> }<a name="line.127"></a>
<FONT color="green">128</FONT> <a name="line.128"></a>
<FONT color="green">129</FONT> doPagingSearch(in, searcher, query, hitsPerPage, raw, queries == null && queryString == null);<a name="line.129"></a>
<FONT color="green">130</FONT> <a name="line.130"></a>
<FONT color="green">131</FONT> if (queryString != null) {<a name="line.131"></a>
<FONT color="green">132</FONT> break;<a name="line.132"></a>
<FONT color="green">133</FONT> }<a name="line.133"></a>
<FONT color="green">134</FONT> }<a name="line.134"></a>
<FONT color="green">135</FONT> reader.close();<a name="line.135"></a>
<FONT color="green">136</FONT> }<a name="line.136"></a>
<FONT color="green">137</FONT> <a name="line.137"></a>
<FONT color="green">138</FONT> /**<a name="line.138"></a>
<FONT color="green">139</FONT> * This demonstrates a typical paging search scenario, where the search engine presents <a name="line.139"></a>
<FONT color="green">140</FONT> * pages of size n to the user. The user can then go to the next page if interested in<a name="line.140"></a>
<FONT color="green">141</FONT> * the next hits.<a name="line.141"></a>
<FONT color="green">142</FONT> * <a name="line.142"></a>
<FONT color="green">143</FONT> * When the query is executed for the first time, then only enough results are collected<a name="line.143"></a>
<FONT color="green">144</FONT> * to fill 5 result pages. If the user wants to page beyond this limit, then the query<a name="line.144"></a>
<FONT color="green">145</FONT> * is executed another time and all hits are collected.<a name="line.145"></a>
<FONT color="green">146</FONT> * <a name="line.146"></a>
<FONT color="green">147</FONT> */<a name="line.147"></a>
<FONT color="green">148</FONT> public static void doPagingSearch(BufferedReader in, IndexSearcher searcher, Query query, <a name="line.148"></a>
<FONT color="green">149</FONT> int hitsPerPage, boolean raw, boolean interactive) throws IOException {<a name="line.149"></a>
<FONT color="green">150</FONT> <a name="line.150"></a>
<FONT color="green">151</FONT> // Collect enough docs to show 5 pages<a name="line.151"></a>
<FONT color="green">152</FONT> TopDocs results = searcher.search(query, 5 * hitsPerPage);<a name="line.152"></a>
<FONT color="green">153</FONT> ScoreDoc[] hits = results.scoreDocs;<a name="line.153"></a>
<FONT color="green">154</FONT> <a name="line.154"></a>
<FONT color="green">155</FONT> int numTotalHits = results.totalHits;<a name="line.155"></a>
<FONT color="green">156</FONT> System.out.println(numTotalHits + " total matching documents");<a name="line.156"></a>
<FONT color="green">157</FONT> <a name="line.157"></a>
<FONT color="green">158</FONT> int start = 0;<a name="line.158"></a>
<FONT color="green">159</FONT> int end = Math.min(numTotalHits, hitsPerPage);<a name="line.159"></a>
<FONT color="green">160</FONT> <a name="line.160"></a>
<FONT color="green">161</FONT> while (true) {<a name="line.161"></a>
<FONT color="green">162</FONT> if (end > hits.length) {<a name="line.162"></a>
<FONT color="green">163</FONT> System.out.println("Only results 1 - " + hits.length +" of " + numTotalHits + " total matching documents collected.");<a name="line.163"></a>
<FONT color="green">164</FONT> System.out.println("Collect more (y/n) ?");<a name="line.164"></a>
<FONT color="green">165</FONT> String line = in.readLine();<a name="line.165"></a>
<FONT color="green">166</FONT> if (line.length() == 0 || line.charAt(0) == 'n') {<a name="line.166"></a>
<FONT color="green">167</FONT> break;<a name="line.167"></a>
<FONT color="green">168</FONT> }<a name="line.168"></a>
<FONT color="green">169</FONT> <a name="line.169"></a>
<FONT color="green">170</FONT> hits = searcher.search(query, numTotalHits).scoreDocs;<a name="line.170"></a>
<FONT color="green">171</FONT> }<a name="line.171"></a>
<FONT color="green">172</FONT> <a name="line.172"></a>
<FONT color="green">173</FONT> end = Math.min(hits.length, start + hitsPerPage);<a name="line.173"></a>
<FONT color="green">174</FONT> <a name="line.174"></a>
<FONT color="green">175</FONT> for (int i = start; i < end; i++) {<a name="line.175"></a>
<FONT color="green">176</FONT> if (raw) { // output raw format<a name="line.176"></a>
<FONT color="green">177</FONT> System.out.println("doc="+hits[i].doc+" score="+hits[i].score);<a name="line.177"></a>
<FONT color="green">178</FONT> continue;<a name="line.178"></a>
<FONT color="green">179</FONT> }<a name="line.179"></a>
<FONT color="green">180</FONT> <a name="line.180"></a>
<FONT color="green">181</FONT> Document doc = searcher.doc(hits[i].doc);<a name="line.181"></a>
<FONT color="green">182</FONT> String path = doc.get("path");<a name="line.182"></a>
<FONT color="green">183</FONT> if (path != null) {<a name="line.183"></a>
<FONT color="green">184</FONT> System.out.println((i+1) + ". " + path);<a name="line.184"></a>
<FONT color="green">185</FONT> String title = doc.get("title");<a name="line.185"></a>
<FONT color="green">186</FONT> if (title != null) {<a name="line.186"></a>
<FONT color="green">187</FONT> System.out.println(" Title: " + doc.get("title"));<a name="line.187"></a>
<FONT color="green">188</FONT> }<a name="line.188"></a>
<FONT color="green">189</FONT> } else {<a name="line.189"></a>
<FONT color="green">190</FONT> System.out.println((i+1) + ". " + "No path for this document");<a name="line.190"></a>
<FONT color="green">191</FONT> }<a name="line.191"></a>
<FONT color="green">192</FONT> <a name="line.192"></a>
<FONT color="green">193</FONT> }<a name="line.193"></a>
<FONT color="green">194</FONT> <a name="line.194"></a>
<FONT color="green">195</FONT> if (!interactive || end == 0) {<a name="line.195"></a>
<FONT color="green">196</FONT> break;<a name="line.196"></a>
<FONT color="green">197</FONT> }<a name="line.197"></a>
<FONT color="green">198</FONT> <a name="line.198"></a>
<FONT color="green">199</FONT> if (numTotalHits >= end) {<a name="line.199"></a>
<FONT color="green">200</FONT> boolean quit = false;<a name="line.200"></a>
<FONT color="green">201</FONT> while (true) {<a name="line.201"></a>
<FONT color="green">202</FONT> System.out.print("Press ");<a name="line.202"></a>
<FONT color="green">203</FONT> if (start - hitsPerPage >= 0) {<a name="line.203"></a>
<FONT color="green">204</FONT> System.out.print("(p)revious page, "); <a name="line.204"></a>
<FONT color="green">205</FONT> }<a name="line.205"></a>
<FONT color="green">206</FONT> if (start + hitsPerPage < numTotalHits) {<a name="line.206"></a>
<FONT color="green">207</FONT> System.out.print("(n)ext page, ");<a name="line.207"></a>
<FONT color="green">208</FONT> }<a name="line.208"></a>
<FONT color="green">209</FONT> System.out.println("(q)uit or enter number to jump to a page.");<a name="line.209"></a>
<FONT color="green">210</FONT> <a name="line.210"></a>
<FONT color="green">211</FONT> String line = in.readLine();<a name="line.211"></a>
<FONT color="green">212</FONT> if (line.length() == 0 || line.charAt(0)=='q') {<a name="line.212"></a>
<FONT color="green">213</FONT> quit = true;<a name="line.213"></a>
<FONT color="green">214</FONT> break;<a name="line.214"></a>
<FONT color="green">215</FONT> }<a name="line.215"></a>
<FONT color="green">216</FONT> if (line.charAt(0) == 'p') {<a name="line.216"></a>
<FONT color="green">217</FONT> start = Math.max(0, start - hitsPerPage);<a name="line.217"></a>
<FONT color="green">218</FONT> break;<a name="line.218"></a>
<FONT color="green">219</FONT> } else if (line.charAt(0) == 'n') {<a name="line.219"></a>
<FONT color="green">220</FONT> if (start + hitsPerPage < numTotalHits) {<a name="line.220"></a>
<FONT color="green">221</FONT> start+=hitsPerPage;<a name="line.221"></a>
<FONT color="green">222</FONT> }<a name="line.222"></a>
<FONT color="green">223</FONT> break;<a name="line.223"></a>
<FONT color="green">224</FONT> } else {<a name="line.224"></a>
<FONT color="green">225</FONT> int page = Integer.parseInt(line);<a name="line.225"></a>
<FONT color="green">226</FONT> if ((page - 1) * hitsPerPage < numTotalHits) {<a name="line.226"></a>
<FONT color="green">227</FONT> start = (page - 1) * hitsPerPage;<a name="line.227"></a>
<FONT color="green">228</FONT> break;<a name="line.228"></a>
<FONT color="green">229</FONT> } else {<a name="line.229"></a>
<FONT color="green">230</FONT> System.out.println("No such page");<a name="line.230"></a>
<FONT color="green">231</FONT> }<a name="line.231"></a>
<FONT color="green">232</FONT> }<a name="line.232"></a>
<FONT color="green">233</FONT> }<a name="line.233"></a>
<FONT color="green">234</FONT> if (quit) break;<a name="line.234"></a>
<FONT color="green">235</FONT> end = Math.min(numTotalHits, start + hitsPerPage);<a name="line.235"></a>
<FONT color="green">236</FONT> }<a name="line.236"></a>
<FONT color="green">237</FONT> }<a name="line.237"></a>
<FONT color="green">238</FONT> }<a name="line.238"></a>
<FONT color="green">239</FONT> }<a name="line.239"></a>
</PRE>
</BODY>
</HTML>
| dburgmann/fbRecommender | lib/lucene-4.0.0/docs/demo/src-html/org/apache/lucene/demo/SearchFiles.html | HTML | gpl-3.0 | 21,915 | [
30522,
30524,
1028,
25604,
1026,
1013,
15489,
1028,
7427,
8917,
1012,
15895,
1012,
19913,
2638,
1012,
9703,
1025,
1026,
1037,
2171,
1027,
1000,
2240,
1012,
1015,
1000,
1028,
1026,
1013,
1037,
1028,
1026,
15489,
3609,
1027,
1000,
2665,
1000,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
../README.md | rszabo/egalite | www/README.md | Markdown | mit | 12 | [
30522,
1012,
1012,
1013,
3191,
4168,
1012,
9108,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (C) 2005-2014 Team XBMC
* http://xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#include "system.h"
#if defined(HAVE_X11)
#include "video/videosync/VideoSyncDRM.h"
#include "xf86drm.h"
#include <sys/poll.h>
#include <sys/time.h>
#include "utils/TimeUtils.h"
#include "utils/MathUtils.h"
#include "windowing/WindowingFactory.h"
#include "guilib/GraphicContext.h"
#include "utils/log.h"
bool CVideoSyncDRM::Setup(PUPDATECLOCK func)
{
CLog::Log(LOGDEBUG, "CVideoSyncDRM::%s - setting up DRM", __FUNCTION__);
UpdateClock = func;
m_fd = open("/dev/dri/card0", O_RDWR, 0);
if (m_fd < 0)
{
CLog::Log(LOGERROR, "CVideoSyncDRM::%s - can't open /dev/dri/card0", __FUNCTION__);
return false;
}
drmVBlank vbl;
int ret;
vbl.request.type = DRM_VBLANK_RELATIVE;
vbl.request.sequence = 0;
ret = drmWaitVBlank(m_fd, &vbl);
if (ret != 0)
{
CLog::Log(LOGERROR, "CVideoSyncDRM::%s - drmWaitVBlank returned error", __FUNCTION__);
return false;
}
m_abort = false;
g_Windowing.Register(this);
return true;
}
void CVideoSyncDRM::Run(volatile bool& stop)
{
drmVBlank vbl;
VblInfo info;
int ret;
int crtc = g_Windowing.GetCrtc();
vbl.request.type = DRM_VBLANK_RELATIVE;
if (crtc == 1)
{
vbl.request.type = (drmVBlankSeqType)(vbl.request.type | DRM_VBLANK_SECONDARY);
}
else if (crtc > 1)
{
vbl.request.type = (drmVBlankSeqType)(vbl.request.type |
((crtc << DRM_VBLANK_HIGH_CRTC_SHIFT) & DRM_VBLANK_HIGH_CRTC_MASK));
}
vbl.request.sequence = 0;
ret = drmWaitVBlank(m_fd, &vbl);
if (ret != 0)
{
CLog::Log(LOGERROR, "CVideoSyncDRM::%s - drmWaitVBlank returned error", __FUNCTION__);
return;
}
info.start = CurrentHostCounter();
info.videoSync = this;
vbl.request.type = (drmVBlankSeqType)(DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT);
if (crtc == 1)
{
vbl.request.type = (drmVBlankSeqType)(vbl.request.type | DRM_VBLANK_SECONDARY);
}
else if (crtc > 1)
{
vbl.request.type = (drmVBlankSeqType)(vbl.request.type |
((crtc << DRM_VBLANK_HIGH_CRTC_SHIFT) & DRM_VBLANK_HIGH_CRTC_MASK));
}
vbl.request.sequence = 1;
vbl.request.signal = (unsigned long)&info;
ret = drmWaitVBlank(m_fd, &vbl);
if (ret != 0)
{
CLog::Log(LOGERROR, "CVideoSyncDRM::%s - drmWaitVBlank returned error", __FUNCTION__);
return;
}
drmEventContext evctx;
memset(&evctx, 0, sizeof evctx);
evctx.version = DRM_EVENT_CONTEXT_VERSION;
evctx.vblank_handler = EventHandler;
evctx.page_flip_handler = NULL;
timeval timeout;
fd_set fds;
FD_ZERO(&fds);
FD_SET(m_fd, &fds);
while (!stop && !m_abort)
{
timeout.tv_sec = 1;
timeout.tv_usec = 0;
ret = select(m_fd + 1, &fds, NULL, NULL, &timeout);
if (ret <= 0)
{
continue;
}
ret = drmHandleEvent(m_fd, &evctx);
if (ret != 0)
{
CLog::Log(LOGERROR, "CVideoSyncDRM::%s - drmHandleEvent returned error", __FUNCTION__);
break;
}
}
}
void CVideoSyncDRM::Cleanup()
{
close(m_fd);
g_Windowing.Unregister(this);
}
void CVideoSyncDRM::EventHandler(int fd, unsigned int frame, unsigned int sec,
unsigned int usec, void *data)
{
drmVBlank vbl;
struct timeval end;
VblInfo *info = (VblInfo*)data;
int crtc = g_Windowing.GetCrtc();
vbl.request.type = (drmVBlankSeqType)(DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT);
if (crtc == 1)
{
vbl.request.type = (drmVBlankSeqType)(vbl.request.type | DRM_VBLANK_SECONDARY);
}
else if (crtc > 1)
{
vbl.request.type = (drmVBlankSeqType)(vbl.request.type |
((crtc << DRM_VBLANK_HIGH_CRTC_SHIFT) & DRM_VBLANK_HIGH_CRTC_MASK));
}
vbl.request.sequence = 1;
vbl.request.signal = (unsigned long)data;
drmWaitVBlank(info->videoSync->m_fd, &vbl);
uint64_t now = CurrentHostCounter();
float diff = (float)(now - info->start)/CurrentHostFrequency();
int vblanks = MathUtils::round_int(diff * info->videoSync->m_fps);
info->start = now;
info->videoSync->UpdateClock(vblanks, now);
}
void CVideoSyncDRM::OnResetDevice()
{
m_abort = true;
}
float CVideoSyncDRM::GetFps()
{
m_fps = g_graphicsContext.GetFPS();
return m_fps;
}
#endif
| codesnake/xbmc | xbmc/video/videosync/VideoSyncDRM.cpp | C++ | gpl-2.0 | 4,875 | [
30522,
1013,
1008,
1008,
30524,
1008,
2009,
2104,
1996,
3408,
1997,
1996,
27004,
2236,
2270,
6105,
2004,
2405,
2011,
1008,
1996,
2489,
4007,
3192,
1025,
2593,
2544,
1016,
1010,
2030,
1006,
2012,
2115,
5724,
1007,
1008,
2151,
2101,
2544,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
---
layout: speaker
order: 13
title: How can Javascript improve your CSS mixins
image: /assets/speakers/sandrina.jpg
name: Sandrina Pereira
twitter: a_sandrina_p
github: sandrina-p
from: Porto, Portugal
decor: 1
social_card:
twitter_card_type: summary_large_image
description: Session by Sandrina Pereira
image: /assets/social-cards/speaker-sandrina.jpg
---
<div class="speaker-youtube">
<iframe src="https://www.youtube.com/embed/UUl0BZgjm3o?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
Open a new window of possibilities to CSS: Faster compilation time, advanced logic, better styles scalability with Unit Testing and more.
How can we use Javascript in order expand the potential of CSS? Why not bring Unit Testing to the table? PostCSS exposes a new world of possibilities for CSS with Javascript. Let's have a faster compilation time, a prettier and more advanced logic than `@if | @for`, access to values outside of the CSS files, and much more! Let's put your CSS to the test! | JSConfBp/2017.jsconfbp.com | _speakers/sandrina-pereira.md | Markdown | mit | 1,048 | [
30522,
1011,
1011,
1011,
9621,
1024,
5882,
2344,
1024,
2410,
2516,
1024,
2129,
2064,
9262,
22483,
5335,
2115,
20116,
2015,
4666,
7076,
3746,
1024,
1013,
7045,
1013,
7492,
1013,
5472,
11796,
1012,
16545,
2290,
2171,
1024,
5472,
11796,
23857,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#pragma once
// Created on 2015/08/18
// Including headers in common
#include "mongoExp/programs/mongoExpProgram.h"
#include "mongoExp/programs/mongoExpSub1.h"
#include "mongoExp/programs/mongoExpSub2.h"
| nickjhathaway/mongodbExp | src/mongoExp/programs.h | C | gpl-2.0 | 206 | [
30522,
1001,
10975,
8490,
2863,
2320,
1013,
1013,
2580,
2006,
2325,
1013,
5511,
1013,
2324,
1013,
1013,
2164,
20346,
2015,
1999,
2691,
1001,
2421,
1000,
12256,
3995,
10288,
2361,
1013,
3454,
1013,
12256,
3995,
10288,
9397,
3217,
13113,
1012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en" dir="ltr">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link rel="stylesheet" href="../codebase/default.css" type="text/css" media="screen" title="no title" charset="utf-8"><title>
dhtmlxwindows:event_oncontentloaded [DHX documentation]
</title></head>
<body>
<div class="dokuwiki">
<div class="stylehead">
<div class="header">
<a class="logo" href="http://dhtmlx.com" title="DHTMLX Home Page"></a>
<span class="tittle-dhtmlx">DHTMLX Docs & Samples Explorer</span>
<div class="search-field">
<form action="/dhtmlx/docs/doku.php" accept-charset="utf-8" id="dw__search"><div class="no"><input type="hidden" name="do" value="search" /><input type="text" id="qsearch__in" accesskey="f" name="id" title="Search" /><button type="submit"></button><div id="qsearch__out" class="ajax_qsearch JSpopup"></div></div></form> </div>
<div class="buttons">
<a class="doc"></a>
<a title="DHTMLX Samples homepage" href="../samples.html" class="sample"/></a>
</div>
<!-- <div class="pagename">
[[<a href="#" title="Backlinks">dhtmlxwindows:event_oncontentloaded</a>]]
</div>
<div class="logo">
<a href="/dhtmlx/docs/doku.php" name="dokuwiki__top" id="dokuwiki__top" accesskey="h" title="[H]">DHX documentation</a> </div>
<div class="clearer"></div>-->
</div>
<!-- <div class="bar" id="bar__top">
<div class="bar-left" id="bar__topleft">
<form class="button btn_edit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="" /><input type="hidden" name="id" value="dhtmlxwindows:event_oncontentloaded" /><input type="submit" value="Edit this page" class="button" accesskey="e" title="Edit this page [E]" /></div></form> <form class="button btn_revs" method="get" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="revisions" /><input type="hidden" name="id" value="dhtmlxwindows:event_oncontentloaded" /><input type="submit" value="Old revisions" class="button" accesskey="o" title="Old revisions [O]" /></div></form> </div>
<div class="bar-right" id="bar__topright">
<form class="button btn_recent" method="get" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="recent" /><input type="hidden" name="id" value="dhtmlxwindows:event_oncontentloaded" /><input type="submit" value="Recent changes" class="button" accesskey="r" title="Recent changes [R]" /></div></form> <form action="/dhtmlx/docs/doku.php" accept-charset="utf-8" id="dw__search"><div class="no"><input type="hidden" name="do" value="search" /><input type="text" id="qsearch__in" accesskey="f" name="id" title="Search" /><button type="submit"></button><div id="qsearch__out" class="ajax_qsearch JSpopup"></div></div></form>
</div>
<div class="clearer"></div>
</div> -->
<!-- <div class="breadcrumbs">
<span class="bchead">Trace:</span> <span class="bcsep">»</span> <span class="curid"><a href="/dhtmlx/docs/doku.php?id=dhtmlxwindows:event_oncontentloaded" class="breadcrumbs" title="dhtmlxwindows:event_oncontentloaded">event_oncontentloaded</a></span> </div>
-->
</div>
<div class="page">
<!-- wikipage start -->
<p>
<div class='backlinks'><div class='backlink last_backlink'><img src="icons___file.gif" class="media" alt="" /><a href="../index.html" class="wikilink1" title="start">Index</a></div><div class='arrow'></div><div class='backlink last_backlink'><img src="icons___windows.gif" class="media" alt="" /><a href=index.html class="wikilink1" title="dhtmlxwindows:toc">dhtmlxwindows</a></div><div class='arrow'></div><div class='backlink'><a href="dhtmlxwindows___event_handling.html" class="wikilink1" title="dhtmlxwindows:event_handling">Event Handling</a></div></div>
</p>
<h3><a name="oncontentloaded" id="oncontentloaded">onContentLoaded</a></h3>
<div class="level3">
<p>
occurs when the external page content is loaded into the window (attachURL() and attachURLAJAX() methods)
</p>
<pre class="code javascript"> dhxWins.<span class="me1">attachEvent</span><span class="br0">(</span><span class="st0">"onContentLoaded"</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">(</span>win<span class="br0">)</span><span class="br0">{</span>
<span class="co1">// code here</span>
<span class="br0">}</span><span class="br0">)</span>;</pre>
</div>
<div class="secedit"><form class="button btn_secedit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="lines" value="87-" /><input type="hidden" name="rev" value="1335474000" /><input type="hidden" name="id" value="dhtmlxwindows:event_oncontentloaded" /><input type="submit" value="Edit" class="button" title="onContentLoaded" /></div></form></div>
<!-- wikipage stop -->
</div>
<div class="clearer"> </div>
<div class="stylefoot">
<div class="meta">
<div class="user">
</div>
<!-- <div class="doc">
dhtmlxwindows/event_oncontentloaded.txt · Last modified: 2012/04/27 00:00 (external edit) </div>
</div>-->
<!--<div class="bar" id="bar__bottom">-->
<!--<div class="bar-left" id="bar__bottomleft">-->
<!--<form class="button btn_edit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="" /><input type="hidden" name="id" value="dhtmlxwindows:event_oncontentloaded" /><input type="submit" value="Edit this page" class="button" accesskey="e" title="Edit this page [E]" /></div></form>-->
<!--<form class="button btn_revs" method="get" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="revisions" /><input type="hidden" name="id" value="dhtmlxwindows:event_oncontentloaded" /><input type="submit" value="Old revisions" class="button" accesskey="o" title="Old revisions [O]" /></div></form>-->
<!--</div>-->
<!--<div class="bar-right" id="bar__bottomright">-->
<!---->
<!---->
<!---->
<!---->
<!---->
<!--<form class="button btn_index" method="get" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="index" /><input type="hidden" name="id" value="dhtmlxwindows:event_oncontentloaded" /><input type="submit" value="Index" class="button" accesskey="x" title="Index [X]" /></div></form>-->
<!--<a class="nolink" href="#dokuwiki__top"><input type="button" class="button" value="Back to top" onclick="window.scrollTo(0, 0)" title="Back to top" /></a> -->
<!--</div>-->
<!--<div class="clearer"></div>-->
<!--</div>-->
</div>
</div>
<div class="footerinc">
</div>
<div class="no"><img src="/dhtmlx/docs/lib/exe/indexer.php?id=dhtmlxwindows%3Aevent_oncontentloaded&1383917649" width="1" height="1" alt="" /></div>
<div class="footer">
<div class="footer-logo"></div>
<div class="copyright">Copyright © 2013 Dinamenta, UAB<br />All rights reserved.</div>
<form class="button btn_edit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="" /><input type="hidden" name="id" value="dhtmlxwindows:event_oncontentloaded" /><input type="submit" value="Edit this page" class="button" accesskey="e" title="Edit this page [E]" /></div></form> </div>
</body>
</html>
| ManageIQ/dhtmlx-rails | vendor/assets/dhtmlx/docsExplorer/dhtmlxwindows/dhtmlxwindows___event_oncontentloaded.html | HTML | gpl-2.0 | 8,079 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
1060,
11039,
19968,
1015,
1012,
1014,
9384,
1013,
1013,
4372,
1000,
1000,
8299,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#region License Header
// /*******************************************************************************
// * Open Behavioral Health Information Technology Architecture (OBHITA.org)
// *
// * Redistribution and use in source and binary forms, with or without
// * modification, are permitted provided that the following conditions are met:
// * * Redistributions of source code must retain the above copyright
// * notice, this list of conditions and the following disclaimer.
// * * Redistributions in binary form must reproduce the above copyright
// * notice, this list of conditions and the following disclaimer in the
// * documentation and/or other materials provided with the distribution.
// * * Neither the name of the <organization> nor the
// * names of its contributors may be used to endorse or promote products
// * derived from this software without specific prior written permission.
// *
// * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
// * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ******************************************************************************/
#endregion
namespace ProCenter.Domain.Psc
{
#region Using Statements
using System;
using Pillar.FluentRuleEngine;
using ProCenter.Domain.AssessmentModule;
using ProCenter.Domain.AssessmentModule.Rules;
#endregion
/// <summary>The PediatricSymptonChecklistRuleCollection rule collection class.</summary>
public class PediatricSymptonChecklistRuleCollection : AbstractAssessmentRuleCollection
{
private readonly IAssessmentDefinitionRepository _assessmentDefinitionRepository;
private static Guid? _pediatricSymptomCheckListAssessmentDefinitionKey;
#region Constructors and Destructors
/// <summary>Initializes a new instance of the <see cref="PediatricSymptonChecklistRuleCollection" /> class.</summary>
/// <param name="assessmentDefinitionRepository">The assessment definition repository.</param>
public PediatricSymptonChecklistRuleCollection(IAssessmentDefinitionRepository assessmentDefinitionRepository)
{
_assessmentDefinitionRepository = assessmentDefinitionRepository;
NewItemSkippingRule(() => SkipItem71250040)
.ForItemInstance<bool>("71250039")
.EqualTo(false)
.SkipItem(GetItemDefinition("71250040"));
NewRuleSet(() => ItemUpdatedRuleSet71250039, SkipItem71250040);
}
#endregion
#region Public Properties
/// <summary>
/// Gets or sets the skip item71250040.
/// </summary>
/// <value>
/// The skip item71250040.
/// </value>
public IItemSkippingRule SkipItem71250040 { get; set; }
/// <summary>
/// Gets or sets the item updated rule set71250039.
/// </summary>
/// <value>
/// The item updated rule set71250039.
/// </value>
public IRuleSet ItemUpdatedRuleSet71250039 { get; set; }
#endregion
/// <summary>
/// Gets the item definition.
/// </summary>
/// <param name="itemDefinitionCode">The item definition code.</param>
/// <returns>Returns and ItemDefinition for the itemDefinitionCode if found by key.</returns>
private ItemDefinition GetItemDefinition(string itemDefinitionCode)
{
if (!_pediatricSymptomCheckListAssessmentDefinitionKey.HasValue)
{
_pediatricSymptomCheckListAssessmentDefinitionKey = _assessmentDefinitionRepository.GetKeyByCode(PediatricSymptonChecklist.AssessmentCodedConcept.Code);
}
var assessmentDefinition = _assessmentDefinitionRepository.GetByKey(_pediatricSymptomCheckListAssessmentDefinitionKey.Value);
return assessmentDefinition.GetItemDefinitionByCode(itemDefinitionCode);
}
}
}
| OBHITA/PROCenter | ProCenter.Domain.Psc/PediatricSymptonChecklistRuleCollection.cs | C# | bsd-3-clause | 4,652 | [
30522,
1001,
2555,
6105,
20346,
1013,
1013,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2019, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
/** @file FindInstancesProcess.cpp
* @brief Implementation of the aiProcess_FindInstances postprocessing step
*/
#include "FindInstancesProcess.h"
#include <memory>
#include <stdio.h>
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
FindInstancesProcess::FindInstancesProcess()
: configSpeedFlag (false)
{}
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
FindInstancesProcess::~FindInstancesProcess()
{}
// ------------------------------------------------------------------------------------------------
// Returns whether the processing step is present in the given flag field.
bool FindInstancesProcess::IsActive( unsigned int pFlags) const
{
// FindInstances makes absolutely no sense together with PreTransformVertices
// fixme: spawn error message somewhere else?
return 0 != (pFlags & aiProcess_FindInstances) && 0 == (pFlags & aiProcess_PreTransformVertices);
}
// ------------------------------------------------------------------------------------------------
// Setup properties for the step
void FindInstancesProcess::SetupProperties(const Importer* pImp)
{
// AI_CONFIG_FAVOUR_SPEED
configSpeedFlag = (0 != pImp->GetPropertyInteger(AI_CONFIG_FAVOUR_SPEED,0));
}
// ------------------------------------------------------------------------------------------------
// Compare the bones of two meshes
bool CompareBones(const aiMesh* orig, const aiMesh* inst)
{
for (unsigned int i = 0; i < orig->mNumBones;++i) {
aiBone* aha = orig->mBones[i];
aiBone* oha = inst->mBones[i];
if (aha->mNumWeights != oha->mNumWeights ||
aha->mOffsetMatrix != oha->mOffsetMatrix) {
return false;
}
// compare weight per weight ---
for (unsigned int n = 0; n < aha->mNumWeights;++n) {
if (aha->mWeights[n].mVertexId != oha->mWeights[n].mVertexId ||
(aha->mWeights[n].mWeight - oha->mWeights[n].mWeight) < 10e-3f) {
return false;
}
}
}
return true;
}
// ------------------------------------------------------------------------------------------------
// Update mesh indices in the node graph
void UpdateMeshIndices(aiNode* node, unsigned int* lookup)
{
for (unsigned int n = 0; n < node->mNumMeshes;++n)
node->mMeshes[n] = lookup[node->mMeshes[n]];
for (unsigned int n = 0; n < node->mNumChildren;++n)
UpdateMeshIndices(node->mChildren[n],lookup);
}
// ------------------------------------------------------------------------------------------------
// Executes the post processing step on the given imported data.
void FindInstancesProcess::Execute( aiScene* pScene)
{
ASSIMP_LOG_DEBUG("FindInstancesProcess begin");
if (pScene->mNumMeshes) {
// use a pseudo hash for all meshes in the scene to quickly find
// the ones which are possibly equal. This step is executed early
// in the pipeline, so we could, depending on the file format,
// have several thousand small meshes. That's too much for a brute
// everyone-against-everyone check involving up to 10 comparisons
// each.
std::unique_ptr<uint64_t[]> hashes (new uint64_t[pScene->mNumMeshes]);
std::unique_ptr<unsigned int[]> remapping (new unsigned int[pScene->mNumMeshes]);
unsigned int numMeshesOut = 0;
for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
aiMesh* inst = pScene->mMeshes[i];
hashes[i] = GetMeshHash(inst);
// Find an appropriate epsilon
// to compare position differences against
float epsilon = ComputePositionEpsilon(inst);
epsilon *= epsilon;
for (int a = i-1; a >= 0; --a) {
if (hashes[i] == hashes[a])
{
aiMesh* orig = pScene->mMeshes[a];
if (!orig)
continue;
// check for hash collision .. we needn't check
// the vertex format, it *must* match due to the
// (brilliant) construction of the hash
if (orig->mNumBones != inst->mNumBones ||
orig->mNumFaces != inst->mNumFaces ||
orig->mNumVertices != inst->mNumVertices ||
orig->mMaterialIndex != inst->mMaterialIndex ||
orig->mPrimitiveTypes != inst->mPrimitiveTypes)
continue;
// up to now the meshes are equal. Now compare vertex positions, normals,
// tangents and bitangents using this epsilon.
if (orig->HasPositions()) {
if(!CompareArrays(orig->mVertices,inst->mVertices,orig->mNumVertices,epsilon))
continue;
}
if (orig->HasNormals()) {
if(!CompareArrays(orig->mNormals,inst->mNormals,orig->mNumVertices,epsilon))
continue;
}
if (orig->HasTangentsAndBitangents()) {
if (!CompareArrays(orig->mTangents,inst->mTangents,orig->mNumVertices,epsilon) ||
!CompareArrays(orig->mBitangents,inst->mBitangents,orig->mNumVertices,epsilon))
continue;
}
// use a constant epsilon for colors and UV coordinates
static const float uvEpsilon = 10e-4f;
{
unsigned int j, end = orig->GetNumUVChannels();
for(j = 0; j < end; ++j) {
if (!orig->mTextureCoords[j]) {
continue;
}
if(!CompareArrays(orig->mTextureCoords[j],inst->mTextureCoords[j],orig->mNumVertices,uvEpsilon)) {
break;
}
}
if (j != end) {
continue;
}
}
{
unsigned int j, end = orig->GetNumColorChannels();
for(j = 0; j < end; ++j) {
if (!orig->mColors[j]) {
continue;
}
if(!CompareArrays(orig->mColors[j],inst->mColors[j],orig->mNumVertices,uvEpsilon)) {
break;
}
}
if (j != end) {
continue;
}
}
// These two checks are actually quite expensive and almost *never* required.
// Almost. That's why they're still here. But there's no reason to do them
// in speed-targeted imports.
if (!configSpeedFlag) {
// It seems to be strange, but we really need to check whether the
// bones are identical too. Although it's extremely unprobable
// that they're not if control reaches here, we need to deal
// with unprobable cases, too. It could still be that there are
// equal shapes which are deformed differently.
if (!CompareBones(orig,inst))
continue;
// For completeness ... compare even the index buffers for equality
// face order & winding order doesn't care. Input data is in verbose format.
std::unique_ptr<unsigned int[]> ftbl_orig(new unsigned int[orig->mNumVertices]);
std::unique_ptr<unsigned int[]> ftbl_inst(new unsigned int[orig->mNumVertices]);
for (unsigned int tt = 0; tt < orig->mNumFaces;++tt) {
aiFace& f = orig->mFaces[tt];
for (unsigned int nn = 0; nn < f.mNumIndices;++nn)
ftbl_orig[f.mIndices[nn]] = tt;
aiFace& f2 = inst->mFaces[tt];
for (unsigned int nn = 0; nn < f2.mNumIndices;++nn)
ftbl_inst[f2.mIndices[nn]] = tt;
}
if (0 != ::memcmp(ftbl_inst.get(),ftbl_orig.get(),orig->mNumVertices*sizeof(unsigned int)))
continue;
}
// We're still here. Or in other words: 'inst' is an instance of 'orig'.
// Place a marker in our list that we can easily update mesh indices.
remapping[i] = remapping[a];
// Delete the instanced mesh, we don't need it anymore
delete inst;
pScene->mMeshes[i] = NULL;
break;
}
}
// If we didn't find a match for the current mesh: keep it
if (pScene->mMeshes[i]) {
remapping[i] = numMeshesOut++;
}
}
ai_assert(0 != numMeshesOut);
if (numMeshesOut != pScene->mNumMeshes) {
// Collapse the meshes array by removing all NULL entries
for (unsigned int real = 0, i = 0; real < numMeshesOut; ++i) {
if (pScene->mMeshes[i])
pScene->mMeshes[real++] = pScene->mMeshes[i];
}
// And update the node graph with our nice lookup table
UpdateMeshIndices(pScene->mRootNode,remapping.get());
// write to log
if (!DefaultLogger::isNullLogger()) {
ASSIMP_LOG_INFO_F( "FindInstancesProcess finished. Found ", (pScene->mNumMeshes - numMeshesOut), " instances" );
}
pScene->mNumMeshes = numMeshesOut;
} else {
ASSIMP_LOG_DEBUG("FindInstancesProcess finished. No instanced meshes found");
}
}
}
| Paulloz/godot | thirdparty/assimp/code/PostProcessing/FindInstancesProcess.cpp | C++ | mit | 12,218 | [
30522,
1013,
1008,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using CoreGlue.Middleware.CQRS.Settings;
using Microsoft.Extensions.Options;
using System.Collections.Generic;
namespace CoreGlue.CQRS.Query
{
public class QueryableStoreFactory : IQueryableStoreFactory
{
private IDictionary<string, IQueryableStore> QueryStores { get; set; } = new Dictionary<string, IQueryableStore>();
public QueryableStoreFactory(IOptions<QueryOptions> options)
{
ParameterValidation.IsNotNull(options, nameof(options));
QueryOptions queryStores = options.Value;
foreach (ConnectionOptions connection in queryStores.TableStorage)
{
this.QueryStores.Add(connection.Name, new TableQueryableStore(connection));
}
}
public IQueryableStore GetStore(string name)
{
return this.QueryStores[name];
}
}
}
| CoreGlue/coreglue-web | src/CoreGlue/Middleware/CQRS/Query/QueryableStoreFactory.cs | C# | mit | 880 | [
30522,
2478,
4563,
23296,
5657,
1012,
2690,
8059,
1012,
1039,
4160,
2869,
1012,
10906,
1025,
2478,
7513,
1012,
14305,
1012,
7047,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
3415,
15327,
4563,
23296,
5657,
1012,
1039,
4160,
2869,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* ****************************************************************************
* eID Middleware Project.
* Copyright (C) 2008-2009 FedICT.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version
* 3.0 as published by the Free Software Foundation.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, see
* http://www.gnu.org/licenses/.
**************************************************************************** */
#include "P15Correction.h"
using namespace eIDMW;
CP15Correction::~CP15Correction(){}
| 12019/svn.gov.pt | _src/eidmw/cardlayer/P15Correction.cpp | C++ | gpl-3.0 | 936 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using UnityEngine;
using System.Collections;
using TestingMe;
using UnityEngine.UI;
public class GrabData : MonoBehaviour {
// initializing some variables
string url = "http://www.felix.gullamolar.com/latest";
private DataStruct[] curArray;
WWW www;
Vector3[] vertices;
Color[] colors;
public Text textA;
public Text textB;
public Text textC;
public Text textD;
public Text textE;
public Text textF;
public GameObject VesselA;
public GameObject VesselB;
public GameObject VesselC;
public GameObject VesselD;
public GameObject VesselE;
public GameObject VesselF;
Mesh meshA;
Mesh meshB;
Mesh meshC;
Mesh meshD;
Mesh meshE;
Mesh meshF;
public void setUpdateRange(bool five) {
if (five) {
url = "http://www.felix.gullamolar.com/latest";
} else {
url = "http://www.felix.gullamolar.com/latestRow";
}
}
void Start() {
// initial assign of the Gameobject meshes
meshA = VesselA.GetComponent<MeshFilter> ().mesh;
meshB = VesselB.GetComponent<MeshFilter> ().mesh;
meshC = VesselC.GetComponent<MeshFilter> ().mesh;
meshD = VesselD.GetComponent<MeshFilter> ().mesh;
meshE = VesselE.GetComponent<MeshFilter> ().mesh;
meshF = VesselF.GetComponent<MeshFilter> ().mesh;
// Start a Coroutine which fetches the 5 last database rows and visualizes them
StartCoroutine ("getLatestFive");
}
// Fetches the 5 last database rows and visualizes them in 1s steps (infinite loop)
IEnumerator getLatestFive() {
while (true) {
www = new WWW(url);
while (!www.isDone) {
}
curArray = JsonHelper.getJsonArray<DataStruct> (www.text);
Debug.Log (curArray.Length);
for (int i = curArray.Length-1; i >= 0; i--) {
// update Vessel vertices
updateVesselColor (curArray [i].Unit1.Temp, curArray [i].Unit1.Level, meshA, 14.5f, 1.0f);
updateVesselColor (curArray [i].Unit2.Temp, curArray [i].Unit2.Level, meshB, 7.5f, 1.0f);
updateVesselColor (curArray [i].Unit3.Temp, curArray [i].Unit3.Level, meshC, 12.0f, 1.2f);
updateVesselColor (curArray [i].Unit4.Temp, curArray [i].Unit4.Level, meshD, 14.5f, 1.0f);
updateVesselColor (curArray [i].Unit5.Temp, curArray [i].Unit5.Level, meshE, 7.5f, 1.0f);
updateVesselColor (curArray [i].Unit6.Temp, curArray [i].Unit6.Level, meshF, 12.0f, 1.2f);
// update GUI text
textA.text = curArray [i].Unit1.buttonString ();
textB.text = curArray [i].Unit2.buttonString ();
textC.text = curArray [i].Unit3.buttonString ();
textD.text = curArray [i].Unit4.buttonString ();
textE.text = curArray [i].Unit5.buttonString ();
textF.text = curArray [i].Unit6.buttonString ();
yield return new WaitForSeconds(1);
}
}
}
// changes the color of all vertices of the model curMesh with respect to temperature and fill level
// the limit is for manually setting the highest Y coordinate of the mesh model
void updateVesselColor(int temp, int level, Mesh curMesh, float limit, float low) {
vertices = curMesh.vertices;
colors = new Color[vertices.Length];
// Color Mapping from temperature (0-100) to RGB values
float ratio = temp / 50.0f;
float b = Mathf.Max(0, 255 * (1 - ratio));
float r = Mathf.Max(0, 255 * (ratio - 1));
float g = (255 - b - r);
Color fillColor = new Color(r / 255.0f,g / 255.0f,b / 255.0f,1);
// assigns the color to all vertices that are below the measured fill level
int i = 0;
while (i < vertices.Length) {
if ((vertices [i].y >= low) && (vertices [i].y <= ((limit-low) * level * 0.01f + low))) { //
colors[i] = fillColor;
} else {
colors[i] = Color.gray;
}
i++;
}
curMesh.colors = colors;
}
// Update is called once per frame
void Update () {
}
}
| fix92/BrewerySimUnity3D | code/GrabData.cs | C# | apache-2.0 | 3,675 | [
30522,
2478,
8499,
13159,
3170,
1025,
2478,
2291,
1012,
6407,
1025,
2478,
5604,
4168,
1025,
2478,
8499,
13159,
3170,
1012,
21318,
1025,
2270,
2465,
6723,
2850,
2696,
1024,
18847,
4783,
3270,
25500,
3126,
1063,
1013,
1013,
3988,
6026,
2070,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
define('controllers/panel',['require','jquery','backbone','utils/metrics','utils/browser','utils/video-player','utils/pubsub','controllers/panel-display'],function(require) {
var $ = require('jquery'),
Backbone = require('backbone'),
Metrics = require('utils/metrics'),
Browser = require('utils/browser'),
VideoPlayer = require('utils/video-player'),
PubSub = require('utils/pubsub'),
PanelDisplay = require('controllers/panel-display')
;
var PanelView = Backbone.View.extend({
events: {
},
panelOn: false,
minWidth: 320,
minHeight: 180,
leftLimit: 100,
topLimit: 100,
offset: 10,
border: 5,
initialize: function() {
Browser.checkMobileTabletDevice();
this.logger = new eventsCore.util.Logger('PanelView');
this.panel1 = new PanelDisplay({el: '#panel1'}).render();
this.panel2 = new PanelDisplay({el: '#panel2'}).render();
//this.logger.info('initialize - panel1:%o panel2:%o', this.panel1, this.panel2);
this.on('route:change', this.checkPage);
this.listenTo(PubSub, 'video:playPanel', this.onPlayPanel);
this.listenTo(PubSub, 'video:exitPanel', this.onExitPanel);
this.listenTo(PubSub, 'video:resetHero', this.onResetHero);
this.listenTo(PubSub, 'video:resetVod', this.onResetVod);
this.listenTo(VideoPlayer, 'player:play', this.onPlayEvent);
this.listenTo(VideoPlayer, 'player:panelOpen', this.onPanelOpenEvent);
this.listenTo(VideoPlayer, 'player:panelClosed', this.onPanelClosedEvent);
},
render: function() {
return this;
},
/**
* checks state/position of each panel and updates initial mute status
* executes on play and route change
*/
checkVolume: function() {
this.logger.info('checkVolume - panel1:%o panel2:%o', this.panel1.state(), this.panel2.state());
if (this.panel1.state() != '' && this.panel2.state() == '') {
this.panel1.mute(false);
this.panel2.mute(true);
}
else if (this.panel2.state() != '' && this.panel1.state() == '') {
this.panel2.mute(false);
this.panel1.mute(true);
}
else if (this.panel1.state() == 'floatVideo' && this.panel2.state() == 'heroVideo') {
this.panel2.mute(false);
this.panel1.mute(true);
}
else if (this.panel1.state() == 'heroVideo' && this.panel2.state() == 'floatVideo') {
this.panel1.mute(false);
this.panel2.mute(true);
}
},
/**
* close any open hero panel
* - used for mobile internal ref to a different watch live channel
*/
onResetHero: function() {
if(this.panel1.state() === 'heroVideo') {
this.panel1.onPanelExit();
} else if(this.panel2.state() === 'heroVideo') {
this.panel2.onPanelExit();
}
},
/**
* close any open vod floated panel
*/
onResetVod: function() {
if(this.panel1.state() === 'floatVideo') {
this.panel1.onPanelExit();
} else if(this.panel2.state() === 'floatVideo') {
this.panel2.onPanelExit();
}
},
/**
* play video in a panel, check for channel existing in panel first and use existing if playing
* @param data - panel video data
* @param channel - this live video data
* @param options - options to be passed to video player, consisting of:
* floated - optional boolean indicating if should start in float mode
* vod - indicates if playing a vod
*/
onPlayPanel: function(data, channel, options) {
options = _.extend({ floated: false, vod: false }, options);
this.logger.info('onPlayPanel - panel1:%o chan1:%o panel2:%o chan2:%o data:%o', this.panel1.state(), this.panel1.channelId(), this.panel2.state(), this.panel2.channelId(), data);
//if panel1 floating and opening the same channel, close to hero (to force back to hero when return to live channel page)
// do not close if float is true, call is trying to open same channel in already open float panel
if (this.panel1.channelId() == data[0].id) {
// if panel has no state, reset it to play channel
if(this.panel1.state() === '') {
this.panel1.playPanel(data, channel, options);
} else if (this.panel1.state() == 'floatVideo' && !options.floated)
this.panel1.panelClose(data, false);
else
this.logger.warn('onPlayPanel - ignoring call, attempted to open same channel already active');
}
//if panel2 floating and opening the same channel, close to hero (to force back to hero when return to live channel page)
// do not close if float is true, call i trying to open same channel in already open float panel
else if (this.panel2.channelId() == data[0].id){
// if panel has no state, reset it to play channel
if(this.panel2.state() === '') {
this.panel2.playPanel(data, channel, options);
} else if (this.panel2.state() == 'floatVideo' && !options.floated)
this.panel2.panelClose(data, false);
else
this.logger.warn('onPlayPanel - ignoring call, attempted to open same channel to floating panel');
}
//if panel1 in hero use it, (if not playing this channel)
else if ((this.panel1.state() == 'heroVideo' || this.panel1.state() == '') && this.panel1.channelId() != data[0].id) {
this.panel1.playPanel(data, channel, options);
}
//else use panel2 (if not playing this channel)
else if (this.panel2.channelId() != data[0].id){
this.panel2.playPanel(data, channel, options);
}
},
/**
* exit video playing in panel, whichever panel is open
*/
onExitPanel: function() {
this.logger.info('onExitPanel - panel1:%o chan1:%o panel2:%o chan2:%o', this.panel1.state(), this.panel1.channelId(), this.panel2.state(), this.panel2.channelId());
// close whichever one is floated
if(this.panel1.state() === 'floatVideo') {
this.panel1.onPanelExit();
} else if(this.panel2.state() === 'floatVideo') {
this.panel2.onPanelExit();
}
},
/**
* on play, initiates check for setting initial mute
* @param data - event data with panel id
*/
onPlayEvent: function(data) {
//this.logger.info('onPlayEvent - data:%o', data.id);
if (data.id == 'panel1' || data.id == 'panel2')
this.checkVolume();
},
/**
* handle panel open event from video player
* triggers panel to transition to float state
* @param data - event data with panel id
*/
onPanelOpenEvent: function(data) {
this.logger.info('onPanelOpenEvent - panel1:%o panel2:%o id:%o', this.panel1.state(), this.panel2.state(), data.id);
if(data.id == 'panel1') {
if (this.panel2.state() == 'floatVideo') {
this.panel2.panelClose(null, false);
}
this.panel1.panelOpen();
}
else if(data.id == 'panel2') {
if (this.panel1.state() == 'floatVideo') {
this.panel1.panelClose(null, false);
}
this.panel2.panelOpen();
}
},
/**
* handle panel close event from video player
* triggers panel to return to hero state
* @param data - event data with panel id
*/
onPanelClosedEvent: function(data) {
this.logger.info('onPanelClosedEvent - panel1:%o panel2:%o id:%o', this.panel1.state(), this.panel2.state(), data.id);
if(data.id == 'panel1') {
this.panel1.panelClose(data, true);
if (this.panel2.state() == 'heroVideo') {
this.panel2.panelClose(data, false);
this.checkVolume();
}
}
else if(data.id == 'panel2') {
this.panel2.panelClose(data, true);
if (this.panel1.state() == 'heroVideo') {
this.panel1.panelClose(data, false);
this.checkVolume();
}
}
},
/**
* initiate page check for closing hero on route change
* also check volume on route change
*/
checkPage: function(){
var route = Backbone.history.getFragment();
this.panel1.checkPage(route);
this.panel2.checkPage(route);
this.checkVolume();
}
});
return PanelView;
})
;
| rlaj/tmc | source/dist/controllers/panel.js | JavaScript | mit | 9,409 | [
30522,
9375,
1006,
1005,
21257,
1013,
5997,
1005,
1010,
1031,
1005,
5478,
1005,
1010,
1005,
1046,
4226,
2854,
1005,
1010,
1005,
21505,
1005,
1010,
1005,
21183,
12146,
1013,
12046,
2015,
1005,
1010,
1005,
21183,
12146,
1013,
16602,
1005,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package leetcode;
/*
http://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/
*/
public class RemoveDuplicatesFromListII {
public static ListNode deleteDuplicates(ListNode root) {
if (root == null) {
return root;
}
ListNode ret = new ListNode(root.val);
ListNode prev = null;
ListNode retItr = ret;
root=root.next;
boolean duplicate = false;
while (root != null) {
if (root.val == retItr.val) {
duplicate = true;
} else {
if (duplicate) {
retItr = prev;
}
if(retItr==null) {
ret=new ListNode(root.val);
retItr=ret;
}else {
retItr.next = new ListNode(root.val);
prev = retItr;
retItr = retItr.next;
}
duplicate =false;
}
root=root.next;
}
if (duplicate) {
if(prev!=null) {
prev.next = null;
}else {
return null;
}
}
return ret;
}}
| rekbun/leetcode | src/leetcode/RemoveDuplicatesFromListII.java | Java | mit | 862 | [
30522,
7427,
3389,
13535,
10244,
1025,
1013,
1008,
8299,
1024,
1013,
1013,
1051,
3501,
1012,
3389,
13535,
10244,
1012,
4012,
1013,
3471,
1013,
6366,
1011,
24473,
2015,
1011,
2013,
1011,
19616,
1011,
2862,
1011,
2462,
1013,
1008,
1013,
2270,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* 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 com.intellij.codeInsight.template.macro;
import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.template.*;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.util.TypeConversionUtil;
import org.jetbrains.annotations.NotNull;
/**
* @author ven
*/
public class IterableComponentTypeMacro implements Macro {
public String getName() {
return "iterableComponentType";
}
public String getDescription() {
return CodeInsightBundle.message("macro.iterable.component.type");
}
public String getDefaultValue() {
return "a";
}
public Result calculateResult(@NotNull Expression[] params, ExpressionContext context) {
if (params.length != 1) return null;
final Result result = params[0].calculateResult(context);
if (result == null) return null;
Project project = context.getProject();
PsiDocumentManager.getInstance(project).commitAllDocuments();
PsiExpression expr = MacroUtil.resultToPsiExpression(result, context);
if (expr == null) return null;
PsiType type = expr.getType();
if (type instanceof PsiArrayType) {
return new PsiTypeResult(((PsiArrayType)type).getComponentType(), project);
}
if (type instanceof PsiClassType) {
PsiClassType.ClassResolveResult resolveResult = ((PsiClassType)type).resolveGenerics();
PsiClass aClass = resolveResult.getElement();
if (aClass != null) {
PsiClass iterableClass = JavaPsiFacade.getInstance(project).findClass("java.lang.Iterable", aClass.getResolveScope());
if (iterableClass != null) {
PsiSubstitutor substitutor = TypeConversionUtil.getClassSubstitutor(iterableClass, aClass, resolveResult.getSubstitutor());
if (substitutor != null) {
PsiType parameterType = substitutor.substitute(iterableClass.getTypeParameters()[0]);
if (parameterType instanceof PsiCapturedWildcardType) {
parameterType = ((PsiCapturedWildcardType)parameterType).getWildcard();
}
if (parameterType != null) {
if (parameterType instanceof PsiWildcardType) {
if (((PsiWildcardType)parameterType).isExtends()) {
return new PsiTypeResult(((PsiWildcardType)parameterType).getBound(), project);
}
else return null;
}
return new PsiTypeResult(parameterType, project);
}
}
}
}
}
return null;
}
public Result calculateQuickResult(@NotNull Expression[] params, ExpressionContext context) {
return calculateResult(params, context);
}
public LookupElement[] calculateLookupItems(@NotNull Expression[] params, ExpressionContext context) {
return LookupElement.EMPTY_ARRAY;
}
}
| joewalnes/idea-community | java/java-impl/src/com/intellij/codeInsight/template/macro/IterableComponentTypeMacro.java | Java | apache-2.0 | 3,485 | [
30522,
1013,
1008,
1008,
9385,
2456,
1011,
2268,
6892,
10024,
7076,
1055,
1012,
1054,
1012,
1051,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/**
* Template Name: Wide Page Template
*
* Description: A page template that provides a key component of WordPress as a CMS
* by meeting the need for a carefully crafted introductory page. The front page template
* in Twenty Twelve consists of a page content area for adding text, images, video --
* anything you'd like -- followed by front-page-only widgets in one or two columns.
*
* @package WordPress
* @subpackage Plum_Tree
* @since Plum Tree 0.1
*/
get_header(); ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
if ( (get_option('blog_spacer_bg_color') != '') && (get_option('blog_spacer_bg_color') != '#fff') ) {
$spacer_bg = 'style="background:'.get_option('blog_spacer_bg_color').';"';
} elseif ( get_option('blog_spacer_custom_pattern') != '' ) {
$spacer_bg = 'style="background: url('.get_option('blog_spacer_custom_pattern').') repeat;"';
} else {
$spacer_bg = 'style="background: url('.get_template_directory_uri().'/assets/spacer-'.get_option('blog_spacer_default_pattern').'.png) repeat;"';
}
?>
<div class="spacer" <?php echo $spacer_bg; ?> data-stellar-background-ratio="0.5">
<div class="container-fluid">
<div class="row-fluid">
<h1 class="spacer-title" data-stellar-ratio="0.93"><?php the_title(); ?></h1>
</div>
</div>
</div>
<section id="content" role="main" class="site-content"><!-- Main content -->
<div class="entry-content">
<?php the_content(); ?>
</div><!-- .entry-content -->
<?php endwhile; ?>
<?php endif; ?>
</section><!-- Main content -->
<?php get_footer(); ?>
| as1anhawk/ICT2_Team3 | wp-content/themes/clickboutique/page-templates/page-wide.php | PHP | gpl-2.0 | 1,843 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
23561,
2171,
1024,
2898,
3931,
23561,
1008,
1008,
6412,
1024,
1037,
3931,
23561,
2008,
3640,
1037,
3145,
6922,
1997,
2773,
20110,
2004,
1037,
4642,
2015,
1008,
2011,
3116,
1996,
2342,
2005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.