hexsha
stringlengths 40
40
| size
int64 5
1.05M
| ext
stringclasses 98
values | lang
stringclasses 21
values | max_stars_repo_path
stringlengths 3
945
| max_stars_repo_name
stringlengths 4
118
| max_stars_repo_head_hexsha
stringlengths 40
78
| max_stars_repo_licenses
sequencelengths 1
10
| max_stars_count
int64 1
368k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 3
945
| max_issues_repo_name
stringlengths 4
118
| max_issues_repo_head_hexsha
stringlengths 40
78
| max_issues_repo_licenses
sequencelengths 1
10
| max_issues_count
int64 1
134k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 3
945
| max_forks_repo_name
stringlengths 4
135
| max_forks_repo_head_hexsha
stringlengths 40
78
| max_forks_repo_licenses
sequencelengths 1
10
| max_forks_count
int64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 5
1.05M
| avg_line_length
float64 1
1.03M
| max_line_length
int64 2
1.03M
| alphanum_fraction
float64 0
1
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
123a2f48941c40045169cdd80a53cef08b9e8d53 | 2,500 | h | C | sdk/rmsauth_sdk/rmsauth/rmsauth/Authenticator.h | AzureAD/rms-sdk-for-cpp | 0e5d54a030008c5c0f70d8d3d0695fa0722b6ab6 | [
"MIT"
] | 30 | 2015-06-22T23:59:02.000Z | 2021-09-12T05:51:34.000Z | sdk/rmsauth_sdk/rmsauth/rmsauth/Authenticator.h | AnthonyCSheehy/rms-sdk-for-cpp | 42985c0b5d93da5bef6bd6c847ddced4be008843 | [
"MIT"
] | 115 | 2015-06-22T18:26:34.000Z | 2022-03-24T16:57:46.000Z | sdk/rmsauth_sdk/rmsauth/rmsauth/Authenticator.h | AnthonyCSheehy/rms-sdk-for-cpp | 42985c0b5d93da5bef6bd6c847ddced4be008843 | [
"MIT"
] | 32 | 2015-06-22T08:39:29.000Z | 2022-03-24T16:49:20.000Z | /*
* ======================================================================
* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
* Licensed under the MIT License.
* See LICENSE.md in the project root for license information.
* ======================================================================
*/
#ifndef AUTHENTICATOR_H
#define AUTHENTICATOR_H
#include "types.h"
#include "AuthorityType.h"
#include "Guid.h"
#include "CallState.h"
#include "Exceptions.h"
#include "AuthenticatorTemplateList.h"
#include "Constants.h"
#include "utils.h"
#include "Url.h"
namespace rmsauth {
class Authenticator
{
static const String& Tag() {static const String tag="Authenticator"; return tag;}
static const String tenantlessTenantName();
static AuthenticatorTemplateList authenticatorTemplateList;
bool updatedFromTemplate_ = false;
bool validateAuthority_;
bool default_ = true;
String authority_;
AuthorityType authorityType_;
bool isTenantless_;
String authorizationUri_;
String tokenUri_;
String userRealmUri_;
String selfSignedJwtAudience_;
Guid correlationId_;
public:
Authenticator():default_(true){}
Authenticator(const String& authority, bool validateAuthority);
const String& authority() const {return authority_;}
const AuthorityType& authorityType() const {return authorityType_;}
bool validateAuthority() const {return validateAuthority_;}
bool isTenantless() const {return isTenantless_;}
const String& authorizationUri() const {return authorizationUri_;}
const String& tokenUri() const {return tokenUri_;}
const String& userRealmUri() const {return userRealmUri_;}
const String& selfSignedJwtAudience() const {return selfSignedJwtAudience_;}
const Guid& correlationId() const {return correlationId_;}
void correlationId(const Guid& val) {correlationId_ = val;}
void updateFromTemplateAsync(CallStatePtr callState);
void updateTenantId(const String& tenantId);
private:
static AuthorityType detectAuthorityType(const String& authority);
static String canonicalizeUri(const String& uri);
static String replaceTenantlessTenant(const String& authority, const String& tenantId);
static bool isAdfsAuthority(const String& firstPath);
};
using AuthenticatorPtr = ptr<Authenticator>;
} // namespace rmsauth {
#endif // AUTHENTICATOR_H
| 33.333333 | 91 | 0.68 |
0bae78fa6080de85a0feb221980172f577f30cf7 | 42,674 | py | Python | packstack/plugins/neutron_350.py | melroyr/havana-packstack | 72cdb0e5e29df4cccb81844ec8b365dfededf4f7 | [
"Apache-2.0"
] | null | null | null | packstack/plugins/neutron_350.py | melroyr/havana-packstack | 72cdb0e5e29df4cccb81844ec8b365dfededf4f7 | [
"Apache-2.0"
] | null | null | null | packstack/plugins/neutron_350.py | melroyr/havana-packstack | 72cdb0e5e29df4cccb81844ec8b365dfededf4f7 | [
"Apache-2.0"
] | null | null | null | """
Installs and configures neutron
"""
import logging
import os
import re
import uuid
from packstack.installer import utils
from packstack.installer import validators
from packstack.installer.utils import split_hosts
from packstack.modules.ospluginutils import getManifestTemplate, appendManifestFile
# Controller object will be initialized from main flow
controller = None
# Plugin name
PLUGIN_NAME = "OS-NEUTRON"
logging.debug("plugin %s loaded", __name__)
def initConfig(controllerObject):
global controller
controller = controllerObject
logging.debug("Adding OpenStack Neutron configuration")
conf_params = {
"NEUTRON" : [
{"CMD_OPTION" : "neutron-server-host",
"USAGE" : "The IP addresses of the server on which to install the Neutron server",
"PROMPT" : "Enter the IP address of the Neutron server",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_ip, validators.validate_ssh],
"DEFAULT_VALUE" : utils.get_localhost_ip(),
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_NEUTRON_SERVER_HOST",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-ks-password",
"USAGE" : "The password to use for Neutron to authenticate with Keystone",
"PROMPT" : "Enter the password for Neutron Keystone access",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : uuid.uuid4().hex[:16],
"MASK_INPUT" : True,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_NEUTRON_KS_PW",
"USE_DEFAULT" : True,
"NEED_CONFIRM" : True,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-db-password",
"USAGE" : "The password to use for Neutron to access DB",
"PROMPT" : "Enter the password for Neutron DB access",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : uuid.uuid4().hex[:16],
"MASK_INPUT" : True,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_NEUTRON_DB_PW",
"USE_DEFAULT" : True,
"NEED_CONFIRM" : True,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-l3-hosts",
"USAGE" : "A comma separated list of IP addresses on which to install Neutron L3 agent",
"PROMPT" : "Enter a comma separated list of IP addresses on which to install the Neutron L3 agent",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_multi_ssh],
"DEFAULT_VALUE" : utils.get_localhost_ip(),
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_NEUTRON_L3_HOSTS",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-l3-ext-bridge",
"USAGE" : "The name of the bridge that the Neutron L3 agent will use for external traffic, or 'provider' if using provider networks",
"PROMPT" : "Enter the bridge the Neutron L3 agent will use for external traffic, or 'provider' if using provider networks",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : "br-ex",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_NEUTRON_L3_EXT_BRIDGE",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-dhcp-hosts",
"USAGE" : "A comma separated list of IP addresses on which to install Neutron DHCP agent",
"PROMPT" : "Enter a comma separated list of IP addresses on which to install Neutron DHCP agent",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_multi_ssh],
"DEFAULT_VALUE" : utils.get_localhost_ip(),
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_NEUTRON_DHCP_HOSTS",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-lbaas-hosts",
"USAGE" : "A comma separated list of IP addresses on which to install Neutron LBaaS agent",
"PROMPT" : "Enter a comma separated list of IP addresses on which to install Neutron LBaaS agent",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_multi_ssh],
"DEFAULT_VALUE" : "",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_NEUTRON_LBAAS_HOSTS",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-l2-plugin",
"USAGE" : "The name of the L2 plugin to be used with Neutron",
"PROMPT" : "Enter the name of the L2 plugin to be used with Neutron",
"OPTION_LIST" : ["linuxbridge", "openvswitch", "ml2"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "openvswitch",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_NEUTRON_L2_PLUGIN",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-metadata-hosts",
"USAGE" : "A comma separated list of IP addresses on which to install Neutron metadata agent",
"PROMPT" : "Enter a comma separated list of IP addresses on which to install the Neutron metadata agent",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_multi_ssh],
"DEFAULT_VALUE" : utils.get_localhost_ip(),
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_NEUTRON_METADATA_HOSTS",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-metadata-pw",
"USAGE" : "A comma separated list of IP addresses on which to install Neutron metadata agent",
"PROMPT" : "Enter a comma separated list of IP addresses on which to install the Neutron metadata agent",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : uuid.uuid4().hex[:16],
"MASK_INPUT" : True,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_NEUTRON_METADATA_PW",
"USE_DEFAULT" : True,
"NEED_CONFIRM" : True,
"CONDITION" : False },
],
"NEUTRON_LB_PLUGIN" : [
{"CMD_OPTION" : "neutron-lb-tenant-network-type",
"USAGE" : "The type of network to allocate for tenant networks (eg. vlan, local)",
"PROMPT" : "Enter the type of network to allocate for tenant networks",
"OPTION_LIST" : ["local", "vlan"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "local",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_NEUTRON_LB_TENANT_NETWORK_TYPE",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-lb-vlan-ranges",
"USAGE" : "A comma separated list of VLAN ranges for the Neutron linuxbridge plugin (eg. physnet1:1:4094,physnet2,physnet3:3000:3999)",
"PROMPT" : "Enter a comma separated list of VLAN ranges for the Neutron linuxbridge plugin",
"OPTION_LIST" : [],
"VALIDATORS" : [],
"DEFAULT_VALUE" : "",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_NEUTRON_LB_VLAN_RANGES",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
],
"NEUTRON_LB_PLUGIN_AND_AGENT" : [
{"CMD_OPTION" : "neutron-lb-interface-mappings",
"USAGE" : "A comma separated list of interface mappings for the Neutron linuxbridge plugin (eg. physnet1:br-eth1,physnet2:br-eth2,physnet3:br-eth3)",
"PROMPT" : "Enter a comma separated list of interface mappings for the Neutron linuxbridge plugin",
"OPTION_LIST" : [],
"VALIDATORS" : [],
"DEFAULT_VALUE" : "",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_NEUTRON_LB_INTERFACE_MAPPINGS",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
],
"NEUTRON_OVS_PLUGIN" : [
{"CMD_OPTION" : "neutron-ovs-tenant-network-type",
"USAGE" : "Type of network to allocate for tenant networks (eg. vlan, local, gre, vxlan)",
"PROMPT" : "Enter the type of network to allocate for tenant networks",
"OPTION_LIST" : ["local", "vlan", "gre", "vxlan"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "local",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_NEUTRON_OVS_TENANT_NETWORK_TYPE",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-ovs-vlan-ranges",
"USAGE" : "A comma separated list of VLAN ranges for the Neutron openvswitch plugin (eg. physnet1:1:4094,physnet2,physnet3:3000:3999)",
"PROMPT" : "Enter a comma separated list of VLAN ranges for the Neutron openvswitch plugin",
"OPTION_LIST" : [],
"VALIDATORS" : [],
"DEFAULT_VALUE" : "",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_NEUTRON_OVS_VLAN_RANGES",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
],
"NEUTRON_OVS_PLUGIN_AND_AGENT" : [
{"CMD_OPTION" : "neutron-ovs-bridge-mappings",
"USAGE" : "A comma separated list of bridge mappings for the Neutron openvswitch plugin (eg. physnet1:br-eth1,physnet2:br-eth2,physnet3:br-eth3)",
"PROMPT" : "Enter a comma separated list of bridge mappings for the Neutron openvswitch plugin",
"OPTION_LIST" : [],
"VALIDATORS" : [],
"DEFAULT_VALUE" : "",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-ovs-bridge-interfaces",
"USAGE" : "A comma separated list of colon-separated OVS bridge:interface pairs. The interface will be added to the associated bridge.",
"PROMPT" : "Enter a comma separated list of OVS bridge:interface pairs for the Neutron openvswitch plugin",
"OPTION_LIST" : [],
"VALIDATORS" : [],
"DEFAULT_VALUE" : "",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_NEUTRON_OVS_BRIDGE_IFACES",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
],
"NEUTRON_OVS_PLUGIN_TUNNEL" : [
{"CMD_OPTION" : "neutron-ovs-tunnel-ranges",
"USAGE" : "A comma separated list of tunnel ranges for the Neutron openvswitch plugin (eg. 1:1000)",
"PROMPT" : "Enter a comma separated list of tunnel ranges for the Neutron openvswitch plugin",
"OPTION_LIST" : [],
"VALIDATORS" : [],
"DEFAULT_VALUE" : "",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_NEUTRON_OVS_TUNNEL_RANGES",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
],
"NEUTRON_OVS_PLUGIN_AND_AGENT_TUNNEL" : [
{"CMD_OPTION" : "neutron-ovs-tunnel-if",
"USAGE" : "The interface for the OVS tunnel. Packstack will override the IP address used for tunnels on this hypervisor to the IP found on the specified interface. (eg. eth1) ",
"PROMPT" : "Enter interface with IP to override the default tunnel local_ip",
"OPTION_LIST" : [],
"VALIDATORS" : [],
"DEFAULT_VALUE" : "",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_NEUTRON_OVS_TUNNEL_IF",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
],
"NEUTRON_OVS_PLUGIN_AND_AGENT_VXLAN" : [
{"CMD_OPTION" : "neutron-ovs-vxlan-udp-port",
"CONF_NAME" : "CONFIG_NEUTRON_OVS_VXLAN_UDP_PORT",
"USAGE" : "VXLAN UDP port",
"PROMPT" : "Enter VXLAN UDP port number",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_port],
"DEFAULT_VALUE" : 4789,
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
],
"NEUTRON_ML2_PLUGIN" : [
{"CMD_OPTION" : "neutron-ml2-type-drivers",
"CONF_NAME" : "CONFIG_NEUTRON_ML2_TYPE_DRIVERS",
"USAGE" : ("A comma separated list of network type "
"driver entrypoints to be loaded from the "
"neutron.ml2.type_drivers namespace."),
"PROMPT" : ("Enter a comma separated list of network "
"type driver entrypoints"),
"OPTION_LIST" : ["local", "flat", "vlan", "gre", "vxlan"],
"VALIDATORS" : [validators.validate_multi_options],
"DEFAULT_VALUE" : "local",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-ml2-tenant-network-types",
"CONF_NAME" : "CONFIG_NEUTRON_ML2_TENANT_NETWORK_TYPES",
"USAGE" : ("A comma separated ordered list of "
"network_types to allocate as tenant "
"networks. The value 'local' is only useful "
"for single-box testing but provides no "
"connectivity between hosts."),
"PROMPT" : ("Enter a comma separated ordered list of "
"network_types to allocate as tenant "
"networks"),
"OPTION_LIST" : ["local", "vlan", "gre", "vxlan"],
"VALIDATORS" : [validators.validate_multi_options],
"DEFAULT_VALUE" : "local",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-ml2-mechanism-drivers",
"CONF_NAME" : "CONFIG_NEUTRON_ML2_MECHANISM_DRIVERS",
"USAGE" : ("A comma separated ordered list of "
"networking mechanism driver entrypoints "
"to be loaded from the "
"neutron.ml2.mechanism_drivers namespace."),
"PROMPT" : ("Enter a comma separated ordered list of "
"networking mechanism driver entrypoints"),
"OPTION_LIST" : ["logger", "test", "linuxbridge",
"openvswitch", "hyperv", "ncs", "arista",
"cisco_nexus", "l2population"],
"VALIDATORS" : [validators.validate_multi_options],
"DEFAULT_VALUE" : "openvswitch",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-ml2-flat-networks",
"CONF_NAME" : "CONFIG_NEUTRON_ML2_FLAT_NETWORKS",
"USAGE" : ("A comma separated list of physical_network"
" names with which flat networks can be "
"created. Use * to allow flat networks with "
"arbitrary physical_network names."),
"PROMPT" : ("Enter a comma separated list of "
"physical_network names with which flat "
"networks can be created"),
"OPTION_LIST" : [],
"VALIDATORS" : [],
"DEFAULT_VALUE" : "*",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-ml2-vlan-ranges",
"CONF_NAME" : "CONFIG_NEUTRON_ML2_VLAN_RANGES",
"USAGE" : ("A comma separated list of "
"<physical_network>:<vlan_min>:<vlan_max> "
"or <physical_network> specifying "
"physical_network names usable for VLAN "
"provider and tenant networks, as well as "
"ranges of VLAN tags on each available for "
"allocation to tenant networks."),
"PROMPT" : ("Enter a comma separated list of "
"physical_network names usable for VLAN"),
"OPTION_LIST" : [],
"VALIDATORS" : [],
"DEFAULT_VALUE" : "",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-ml2-tunnel-id-ranges",
"CONF_NAME" : "CONFIG_NEUTRON_ML2_TUNNEL_ID_RANGES",
"USAGE" : ("A comma separated list of <tun_min>:"
"<tun_max> tuples enumerating ranges of GRE "
"tunnel IDs that are available for tenant "
"network allocation. Should be an array with"
" tun_max +1 - tun_min > 1000000"),
"PROMPT" : ("Enter a comma separated list of <tun_min>:"
"<tun_max> tuples enumerating ranges of GRE "
"tunnel IDs that are available for tenant "
"network allocation"),
"OPTION_LIST" : [],
"VALIDATORS" : [],
"DEFAULT_VALUE" : "",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-ml2-vxlan-group",
"CONF_NAME" : "CONFIG_NEUTRON_ML2_VXLAN_GROUP",
"USAGE" : ("Multicast group for VXLAN. If unset, "
"disables VXLAN enable sending allocate "
"broadcast traffic to this multicast group. "
"When left unconfigured, will disable "
"multicast VXLAN mode. Should be an "
"Multicast IP (v4 or v6) address."),
"PROMPT" : "Enter a multicast group for VXLAN",
"OPTION_LIST" : [],
"VALIDATORS" : [],
"DEFAULT_VALUE" : "",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-ml2-vni-ranges",
"CONF_NAME" : "CONFIG_NEUTRON_ML2_VNI_RANGES",
"USAGE" : ("A comma separated list of <vni_min>:"
"<vni_max> tuples enumerating ranges of "
"VXLAN VNI IDs that are available for tenant"
" network allocation. Min value is 0 and Max"
" value is 16777215."),
"PROMPT" : ("Enter a comma separated list of <vni_min>:"
"<vni_max> tuples enumerating ranges of "
"VXLAN VNI IDs that are available for tenant"
" network allocation"),
"OPTION_LIST" : [],
"VALIDATORS" : [],
"DEFAULT_VALUE" : "",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "neutron-l2-agent", # We need to ask for this only in case of ML2 plugins
"USAGE" : "The name of the L2 agent to be used with Neutron",
"PROMPT" : "Enter the name of the L2 agent to be used with Neutron",
"OPTION_LIST" : ["linuxbridge", "openvswitch"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "openvswitch",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_NEUTRON_L2_AGENT",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
],
}
conf_groups = [
{ "GROUP_NAME" : "NEUTRON",
"DESCRIPTION" : "Neutron config",
"PRE_CONDITION" : "CONFIG_NEUTRON_INSTALL",
"PRE_CONDITION_MATCH" : "y",
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True },
{ "GROUP_NAME" : "NEUTRON_ML2_PLUGIN",
"DESCRIPTION" : "Neutron ML2 plugin config",
"PRE_CONDITION" : use_ml2_plugin,
"PRE_CONDITION_MATCH" : True,
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True },
{ "GROUP_NAME" : "NEUTRON_LB_PLUGIN",
"DESCRIPTION" : "Neutron LB plugin config",
"PRE_CONDITION" : use_linuxbridge_plugin,
"PRE_CONDITION_MATCH" : True,
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True },
{ "GROUP_NAME" : "NEUTRON_LB_PLUGIN_AND_AGENT",
"DESCRIPTION" : "Neutron LB agent config",
"PRE_CONDITION" : use_linuxbridge_agent,
"PRE_CONDITION_MATCH" : True,
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True },
{ "GROUP_NAME" : "NEUTRON_OVS_PLUGIN",
"DESCRIPTION" : "Neutron OVS plugin config",
"PRE_CONDITION" : use_openvswitch_plugin,
"PRE_CONDITION_MATCH" : True,
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True },
{ "GROUP_NAME" : "NEUTRON_OVS_PLUGIN_AND_AGENT",
"DESCRIPTION" : "Neutron OVS agent config",
"PRE_CONDITION" : use_openvswitch_agent,
"PRE_CONDITION_MATCH" : True,
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True },
{ "GROUP_NAME" : "NEUTRON_OVS_PLUGIN_TUNNEL",
"DESCRIPTION" : "Neutron OVS plugin config for tunnels",
"PRE_CONDITION" : use_openvswitch_plugin_tunnel,
"PRE_CONDITION_MATCH" : True,
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True },
{ "GROUP_NAME" : "NEUTRON_OVS_PLUGIN_AND_AGENT_TUNNEL",
"DESCRIPTION" : "Neutron OVS agent config for tunnels",
"PRE_CONDITION" : use_openvswitch_agent_tunnel,
"PRE_CONDITION_MATCH" : True,
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True },
{ "GROUP_NAME" : "NEUTRON_OVS_PLUGIN_AND_AGENT_VXLAN",
"DESCRIPTION" : "Neutron OVS agent config for VXLAN",
"PRE_CONDITION" : use_openvswitch_vxlan,
"PRE_CONDITION_MATCH" : True,
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True },
]
for group in conf_groups:
paramList = conf_params[group["GROUP_NAME"]]
controller.addGroup(group, paramList)
def use_ml2_plugin(config):
return (config['CONFIG_NEUTRON_INSTALL'] == 'y' and
config['CONFIG_NEUTRON_L2_PLUGIN'] == 'ml2')
def use_linuxbridge_plugin(config):
result = (config['CONFIG_NEUTRON_INSTALL'] == 'y' and
config['CONFIG_NEUTRON_L2_PLUGIN'] == 'linuxbridge')
if result:
config["CONFIG_NEUTRON_L2_AGENT"] = 'linuxbridge'
return result
def use_linuxbridge_agent(config):
ml2_used = (use_ml2_plugin(config) and
config["CONFIG_NEUTRON_L2_AGENT"] == 'linuxbridge')
return use_linuxbridge_plugin(config) or ml2_used
def use_openvswitch_plugin(config):
result = (config['CONFIG_NEUTRON_INSTALL'] == 'y' and
config['CONFIG_NEUTRON_L2_PLUGIN'] == 'openvswitch')
if result:
config["CONFIG_NEUTRON_L2_AGENT"] = 'openvswitch'
return result
def use_openvswitch_plugin_tunnel(config):
tun_types = ('gre', 'vxlan')
return (use_openvswitch_plugin(config) and
config['CONFIG_NEUTRON_OVS_TENANT_NETWORK_TYPE'] in tun_types)
def use_ml2_with_ovs(config):
return (use_ml2_plugin(config) and
config["CONFIG_NEUTRON_L2_AGENT"] == 'openvswitch')
def use_openvswitch_agent(config):
return use_openvswitch_plugin(config) or use_ml2_with_ovs(config)
def use_openvswitch_agent_tunnel(config):
return use_openvswitch_plugin_tunnel(config) or use_ml2_with_ovs(config)
def use_openvswitch_vxlan(config):
return ((use_openvswitch_plugin_tunnel(config) and
config['CONFIG_NEUTRON_OVS_TENANT_NETWORK_TYPE'] == 'vxlan')
or
(use_ml2_with_ovs(config) and
'vxlan' in config['CONFIG_NEUTRON_ML2_TYPE_DRIVERS']))
def use_openvswitch_gre(config):
ovs_vxlan = (
use_openvswitch_plugin_tunnel(config) and
config['CONFIG_NEUTRON_OVS_TENANT_NETWORK_TYPE'] == 'gre'
)
ml2_vxlan = (
use_ml2_with_ovs(config) and
'gre' in config['CONFIG_NEUTRON_ML2_TENANT_NETWORK_TYPES']
)
return ovs_vxlan or ml2_vxlan
def get_if_driver(config):
agent = config['CONFIG_NEUTRON_L2_AGENT']
if agent == "openvswitch":
return 'neutron.agent.linux.interface.OVSInterfaceDriver'
elif agent == 'linuxbridge':
return 'neutron.agent.linux.interface.BridgeInterfaceDriver'
def initSequences(controller):
config = controller.CONF
if config['CONFIG_NEUTRON_INSTALL'] != 'y':
return
if config['CONFIG_NEUTRON_L2_PLUGIN'] == 'openvswitch':
plugin_db = 'ovs_neutron'
plugin_path = ('neutron.plugins.openvswitch.ovs_neutron_plugin.'
'OVSNeutronPluginV2')
elif config['CONFIG_NEUTRON_L2_PLUGIN'] == 'linuxbridge':
plugin_db = 'neutron_linux_bridge'
plugin_path = ('neutron.plugins.linuxbridge.lb_neutron_plugin.'
'LinuxBridgePluginV2')
elif config['CONFIG_NEUTRON_L2_PLUGIN'] == 'ml2':
plugin_db = 'neutron'
plugin_path = 'neutron.plugins.ml2.plugin.Ml2Plugin'
# values modification
for key in ('CONFIG_NEUTRON_ML2_TYPE_DRIVERS',
'CONFIG_NEUTRON_ML2_TENANT_NETWORK_TYPES',
'CONFIG_NEUTRON_ML2_MECHANISM_DRIVERS',
'CONFIG_NEUTRON_ML2_FLAT_NETWORKS',
'CONFIG_NEUTRON_ML2_VLAN_RANGES',
'CONFIG_NEUTRON_ML2_TUNNEL_ID_RANGES',
'CONFIG_NEUTRON_ML2_VNI_RANGES'):
config[key] = str([i.strip() for i in config[key].split(',') if i])
key = 'CONFIG_NEUTRON_ML2_VXLAN_GROUP'
config[key] = "'%s'" % config[key] if config[key] else 'undef'
config['CONFIG_NEUTRON_L2_DBNAME'] = plugin_db
config['CONFIG_NEUTRON_CORE_PLUGIN'] = plugin_path
global api_hosts, l3_hosts, dhcp_hosts, lbaas_hosts, compute_hosts, meta_hosts, q_hosts
api_hosts = split_hosts(config['CONFIG_NEUTRON_SERVER_HOST'])
l3_hosts = split_hosts(config['CONFIG_NEUTRON_L3_HOSTS'])
dhcp_hosts = split_hosts(config['CONFIG_NEUTRON_DHCP_HOSTS'])
lbaas_hosts = split_hosts(config['CONFIG_NEUTRON_LBAAS_HOSTS'])
meta_hosts = split_hosts(config['CONFIG_NEUTRON_METADATA_HOSTS'])
compute_hosts = set()
if config['CONFIG_NOVA_INSTALL'] == 'y':
compute_hosts = split_hosts(config['CONFIG_NOVA_COMPUTE_HOSTS'])
q_hosts = api_hosts | l3_hosts | dhcp_hosts | lbaas_hosts | compute_hosts | meta_hosts
neutron_steps = [
{'title': 'Adding Neutron API manifest entries',
'functions': [create_manifests]},
{'title': 'Adding Neutron Keystone manifest entries',
'functions': [create_keystone_manifest]},
{'title': 'Adding Neutron L3 manifest entries',
'functions': [create_l3_manifests]},
{'title': 'Adding Neutron L2 Agent manifest entries',
'functions': [create_l2_agent_manifests]},
{'title': 'Adding Neutron DHCP Agent manifest entries',
'functions': [create_dhcp_manifests]},
{'title': 'Adding Neutron LBaaS Agent manifest entries',
'functions': [create_lbaas_manifests]},
{'title': 'Adding Neutron Metadata Agent manifest entries',
'functions': [create_metadata_manifests]},
]
controller.addSequence("Installing OpenStack Neutron", [], [],
neutron_steps)
def create_manifests(config):
global q_hosts
service_plugins = []
if config['CONFIG_NEUTRON_LBAAS_HOSTS']:
service_plugins.append(
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin'
)
if config['CONFIG_NEUTRON_L2_PLUGIN'] == 'ml2':
# ML2 uses the L3 Router service plugin to implement l3 agent
service_plugins.append(
'neutron.services.l3_router.l3_router_plugin.L3RouterPlugin'
)
config['SERVICE_PLUGINS'] = (str(service_plugins) if service_plugins
else 'undef')
if config['CONFIG_NEUTRON_L2_PLUGIN'] == 'openvswitch':
nettype = config.get("CONFIG_NEUTRON_OVS_TENANT_NETWORK_TYPE", "local")
plugin_manifest = 'neutron_ovs_plugin_%s.pp' % nettype
elif config['CONFIG_NEUTRON_L2_PLUGIN'] == 'linuxbridge':
plugin_manifest = 'neutron_lb_plugin.pp'
elif config['CONFIG_NEUTRON_L2_PLUGIN'] == 'ml2':
plugin_manifest = 'neutron_ml2_plugin.pp'
# host to which allow neutron server
allowed_hosts = set(q_hosts)
if config['CONFIG_CLIENT_INSTALL'] == 'y':
allowed_hosts.add(config['CONFIG_OSCLIENT_HOST'])
if config['CONFIG_HORIZON_INSTALL'] == 'y':
allowed_hosts.add(config['CONFIG_HORIZON_HOST'])
if config['CONFIG_NOVA_INSTALL'] == 'y':
allowed_hosts.add(config['CONFIG_NOVA_API_HOST'])
for host in q_hosts:
manifest_file = "%s_neutron.pp" % (host,)
manifest_data = getManifestTemplate("neutron.pp")
appendManifestFile(manifest_file, manifest_data, 'neutron')
if host in api_hosts:
manifest_file = "%s_neutron.pp" % (host,)
manifest_data = getManifestTemplate("neutron_api.pp")
# Firewall Rules
for f_host in allowed_hosts:
config['FIREWALL_SERVICE_NAME'] = "neutron server"
config['FIREWALL_PORTS'] = "'9696'"
config['FIREWALL_CHAIN'] = "INPUT"
config['FIREWALL_PROTOCOL'] = 'tcp'
config['FIREWALL_ALLOWED'] = "'%s'" % f_host
config['FIREWALL_SERVICE_ID'] = "neutron_server_%s_%s" % (host, f_host)
manifest_data += getManifestTemplate("firewall.pp")
appendManifestFile(manifest_file, manifest_data, 'neutron')
# Set up any l2 plugin configs we need anywhere we install neutron
# XXX I am not completely sure about this, but it seems necessary:
manifest_data = getManifestTemplate(plugin_manifest)
# We also need to open VXLAN/GRE port for agent
if use_openvswitch_vxlan(config) or use_openvswitch_gre(config):
if use_openvswitch_vxlan(config):
config['FIREWALL_PROTOCOL'] = 'udp'
tunnel_port = ("'%s'"
% config['CONFIG_NEUTRON_OVS_VXLAN_UDP_PORT'])
else:
config['FIREWALL_PROTOCOL'] = 'gre'
tunnel_port = 'undef'
config['FIREWALL_ALLOWED'] = "'ALL'"
config['FIREWALL_SERVICE_NAME'] = "neutron tunnel port"
config['FIREWALL_SERVICE_ID'] = ("neutron_tunnel")
config['FIREWALL_PORTS'] = tunnel_port
config['FIREWALL_CHAIN'] = "INPUT"
manifest_data += getManifestTemplate('firewall.pp')
appendManifestFile(manifest_file, manifest_data, 'neutron')
def create_keystone_manifest(config):
manifestfile = "%s_keystone.pp" % config['CONFIG_KEYSTONE_HOST']
manifestdata = getManifestTemplate("keystone_neutron.pp")
appendManifestFile(manifestfile, manifestdata)
def find_mapping(haystack, needle):
return needle in [x.split(':')[1].strip() for x in get_values(haystack)]
def create_l3_manifests(config):
global l3_hosts
plugin = config['CONFIG_NEUTRON_L2_PLUGIN']
if config['CONFIG_NEUTRON_L3_EXT_BRIDGE'] == 'provider':
config['CONFIG_NEUTRON_L3_EXT_BRIDGE'] = ''
for host in l3_hosts:
config['CONFIG_NEUTRON_L3_HOST'] = host
config['CONFIG_NEUTRON_L3_INTERFACE_DRIVER'] = get_if_driver(config)
manifestdata = getManifestTemplate("neutron_l3.pp")
manifestfile = "%s_neutron.pp" % (host,)
appendManifestFile(manifestfile, manifestdata + '\n')
if (config['CONFIG_NEUTRON_L2_PLUGIN'] == 'openvswitch' and
config['CONFIG_NEUTRON_L3_EXT_BRIDGE'] and
not find_mapping(config['CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS'],
config['CONFIG_NEUTRON_L3_EXT_BRIDGE'])):
config['CONFIG_NEUTRON_OVS_BRIDGE'] = config['CONFIG_NEUTRON_L3_EXT_BRIDGE']
manifestdata = getManifestTemplate('neutron_ovs_bridge.pp')
appendManifestFile(manifestfile, manifestdata + '\n')
def create_dhcp_manifests(config):
global dhcp_hosts
plugin = config['CONFIG_NEUTRON_L2_PLUGIN']
for host in dhcp_hosts:
config["CONFIG_NEUTRON_DHCP_HOST"] = host
config['CONFIG_NEUTRON_DHCP_INTERFACE_DRIVER'] = get_if_driver(config)
manifest_data = getManifestTemplate("neutron_dhcp.pp")
manifest_file = "%s_neutron.pp" % (host,)
# Firewall Rules
config['FIREWALL_PROTOCOL'] = 'tcp'
for f_host in q_hosts:
config['FIREWALL_ALLOWED'] = "'%s'" % f_host
config['FIREWALL_SERVICE_NAME'] = "neutron dhcp in"
config['FIREWALL_SERVICE_ID'] = "neutron_dhcp_in_%s_%s" % (host, f_host)
config['FIREWALL_PORTS'] = "'67'"
config['FIREWALL_CHAIN'] = "INPUT"
manifest_data += getManifestTemplate("firewall.pp")
config['FIREWALL_SERVICE_NAME'] = "neutron dhcp out"
config['FIREWALL_SERVICE_ID'] = "neutron_dhcp_out_%s_%s" % (host, f_host)
config['FIREWALL_PORTS'] = "'68'"
config['FIREWALL_CHAIN'] = "OUTPUT"
manifest_data += getManifestTemplate("firewall.pp")
appendManifestFile(manifest_file, manifest_data, 'neutron')
def create_lbaas_manifests(config):
global lbaas_hosts
for host in lbaas_hosts:
controller.CONF['CONFIG_NEUTRON_LBAAS_INTERFACE_DRIVER'] = get_if_driver(config)
manifestdata = getManifestTemplate("neutron_lbaas.pp")
manifestfile = "%s_neutron.pp" % (host,)
appendManifestFile(manifestfile, manifestdata + "\n")
def get_values(val):
return [x.strip() for x in val.split(',')] if val else []
def get_agent_type(config):
# The only real use case I can think of for multiples right now is to list
# "vlan,gre" or "vlan,vxlan" so that VLANs are used if available,
# but tunnels are used if not.
tenant_types = config.get('CONFIG_NEUTRON_ML2_TENANT_NETWORK_TYPES',
"['local']").strip('[]')
tenant_types = [i.strip('"\'') for i in tenant_types.split(',')]
for i in ['gre', 'vxlan', 'vlan']:
if i in tenant_types:
return i
return tenant_types[0]
def create_l2_agent_manifests(config):
global api_hosts, compute_hosts, dhcp_host, l3_hosts
plugin = config['CONFIG_NEUTRON_L2_PLUGIN']
agent = config["CONFIG_NEUTRON_L2_AGENT"]
if agent == "openvswitch":
host_var = 'CONFIG_NEUTRON_OVS_HOST'
if plugin == agent:
# monolithic plugin installation
ovs_type = 'CONFIG_NEUTRON_OVS_TENANT_NETWORK_TYPE'
ovs_type = config.get(ovs_type, 'local')
elif plugin == 'ml2':
ovs_type = get_agent_type(config)
else:
raise RuntimeError('Invalid combination of plugin and agent.')
template_name = "neutron_ovs_agent_%s.pp" % ovs_type
bm_arr = get_values(config["CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS"])
iface_arr = get_values(config["CONFIG_NEUTRON_OVS_BRIDGE_IFACES"])
# The CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS parameter contains a
# comma-separated list of bridge mappings. Since the puppet module
# expects this parameter to be an array, this parameter must be properly
# formatted by packstack, then consumed by the puppet module.
# For example, the input string 'A, B, C' should formatted as '['A','B','C']'.
config["CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS"] = str(bm_arr)
elif agent == "linuxbridge":
host_var = 'CONFIG_NEUTRON_LB_HOST'
template_name = 'neutron_lb_agent.pp'
else:
raise KeyError("Unknown layer2 agent")
# Install l2 agents on every compute host in addition to any hosts listed
# specifically for the l2 agent
for host in api_hosts | compute_hosts | dhcp_hosts | l3_hosts:
config[host_var] = host
manifestfile = "%s_neutron.pp" % (host,)
manifestdata = getManifestTemplate(template_name)
appendManifestFile(manifestfile, manifestdata + "\n")
# neutron ovs port only on network hosts
if (
agent == "openvswitch" and (
(host in l3_hosts and ovs_type in ['vxlan', 'gre'])
or ovs_type == 'vlan')
):
bridge_key = 'CONFIG_NEUTRON_OVS_BRIDGE'
iface_key = 'CONFIG_NEUTRON_OVS_IFACE'
for if_map in iface_arr:
config[bridge_key], config[iface_key] = if_map.split(':')
manifestdata = getManifestTemplate("neutron_ovs_port.pp")
appendManifestFile(manifestfile, manifestdata + "\n")
# Additional configurations required for compute hosts and
# network hosts.
manifestdata = getManifestTemplate('neutron_bridge_module.pp')
appendManifestFile(manifestfile, manifestdata + '\n')
def create_metadata_manifests(config):
global meta_hosts
if config.get('CONFIG_NOVA_INSTALL') == 'n':
return
for host in meta_hosts:
controller.CONF['CONFIG_NEUTRON_METADATA_HOST'] = host
manifestdata = getManifestTemplate('neutron_metadata.pp')
manifestfile = "%s_neutron.pp" % (host,)
appendManifestFile(manifestfile, manifestdata + "\n")
| 49.334104 | 200 | 0.552819 |
b1d80ab7be63babb5d736539f972647c426e6b2f | 5,003 | h | C | device/EFM32GG11B/Include/efm32gg11b_perpriv_register.h | Bucknalla/coprocessor-sdk | 1e70d54a77d8c342580189f0e34ebf1e86d030fd | [
"Apache-2.0"
] | 8 | 2019-04-15T08:56:49.000Z | 2020-08-19T10:50:55.000Z | device/EFM32GG11B/Include/efm32gg11b_perpriv_register.h | Bucknalla/coprocessor-sdk | 1e70d54a77d8c342580189f0e34ebf1e86d030fd | [
"Apache-2.0"
] | 21 | 2019-03-05T21:04:22.000Z | 2021-02-04T11:47:43.000Z | device/EFM32GG11B/Include/efm32gg11b_perpriv_register.h | Bucknalla/coprocessor-sdk | 1e70d54a77d8c342580189f0e34ebf1e86d030fd | [
"Apache-2.0"
] | 7 | 2019-03-14T15:09:01.000Z | 2021-03-11T19:00:14.000Z | /**************************************************************************//**
* @file efm32gg11b_perpriv_register.h
* @brief EFM32GG11B_PERPRIV_REGISTER register and bit field definitions
* @version 5.2.1
******************************************************************************
* # License
* <b>Copyright 2017 Silicon Laboratories, Inc. http://www.silabs.com</b>
******************************************************************************
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software.@n
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.@n
* 3. This notice may not be removed or altered from any source distribution.
*
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Laboratories, Inc.
* has no obligation to support this Software. Silicon Laboratories, Inc. is
* providing the Software "AS IS", with no express or implied warranties of any
* kind, including, but not limited to, any implied warranties of
* merchantability or fitness for any particular purpose or warranties against
* infringement of any proprietary rights of a third party.
*
* Silicon Laboratories, Inc. will not be liable for any consequential,
* incidental, or special damages, or any other relief, or for any claim by
* any third party, arising from your use of this Software.
*
*****************************************************************************/
#if defined(__ICCARM__)
#pragma system_include /* Treat file as system include file. */
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#pragma clang system_header /* Treat file as system include file. */
#endif
/**************************************************************************//**
* @addtogroup Parts
* @{
******************************************************************************/
/**************************************************************************//**
* @defgroup EFM32GG11B_PERPRIV_REGISTER Peripheral Privilege Register
* @{
*****************************************************************************/
/** PERPRIV_REGISTER Register Declaration */
typedef struct
{
/* Note! Use of double __IOM (volatile) qualifier to ensure that both */
/* pointer and referenced memory are declared volatile. */
__IOM int TIMER0 : 1;
__IOM int TIMER1 : 1;
__IOM int TIMER2 : 1;
__IOM int TIMER3 : 1;
__IOM int TIMER4 : 1;
__IOM int TIMER5 : 1;
__IOM int TIMER6 : 1;
__IOM int WTIMER0 : 1;
__IOM int WTIMER1 : 1;
__IOM int WTIMER2 : 1;
__IOM int WTIMER3 : 1;
__IOM int USART0 : 1;
__IOM int USART1 : 1;
__IOM int USART2 : 1;
__IOM int USART3 : 1;
__IOM int USART4 : 1;
__IOM int USART5 : 1;
__IOM int UART0 : 1;
__IOM int UART1 : 1;
__IOM int CAN0 : 1;
__IOM int CAN1 : 1;
__IOM int RESERVED0 : 1; /**< Reserved for future use **/
__IOM int RESERVED1 : 1; /**< Reserved for future use **/
__IOM int TRNG0 : 1;
__IOM int MSC : 1;
__IOM int EBI : 1;
__IOM int ETH : 1;
__IOM int LDMA : 1;
__IOM int FPUEH : 1;
__IOM int GPCRC : 1;
__IOM int QSPI0 : 1;
__IOM int USB : 1;
__IOM int SMU : 1;
__IOM int ACMP0 : 1;
__IOM int ACMP1 : 1;
__IOM int ACMP2 : 1;
__IOM int ACMP3 : 1;
__IOM int I2C0 : 1;
__IOM int I2C1 : 1;
__IOM int I2C2 : 1;
__IOM int ADC0 : 1;
__IOM int ADC1 : 1;
__IOM int CRYOTIMER : 1;
__IOM int VDAC0 : 1;
__IOM int IDAC0 : 1;
__IOM int CSEN : 1;
__IOM int RESERVED2 : 1; /**< Reserved for future use **/
__IOM int APB_RSYNC_COMB : 1;
__IOM int GPIO : 1;
__IOM int PRS : 1;
__IOM int EMU : 1;
__IOM int RMU : 1;
__IOM int CMU : 1;
__IOM int PCNT0 : 1;
__IOM int PCNT1 : 1;
__IOM int PCNT2 : 1;
__IOM int LEUART0 : 1;
__IOM int LEUART1 : 1;
__IOM int LETIMER0 : 1;
__IOM int LETIMER1 : 1;
__IOM int WDOG0 : 1;
__IOM int WDOG1 : 1;
__IOM int LESENSE : 1;
__IOM int LCD : 1;
__IOM int RTC : 1;
__IOM int RTCC : 1;
} PERPRIV_REGISTER_TypeDef; /**< @} */
/** @} End of group Parts */
| 40.024 | 80 | 0.503898 |
e3f151b351ec317694b6731310ca6beff746b40a | 789 | go | Go | services/autoscaling/put_scheduled_update_group_action_request.go | lee-yongtak/ncloud-sdk-go-v2 | 36bb842331ba5a144dfa7a477501bc4980f44a5e | [
"MIT"
] | null | null | null | services/autoscaling/put_scheduled_update_group_action_request.go | lee-yongtak/ncloud-sdk-go-v2 | 36bb842331ba5a144dfa7a477501bc4980f44a5e | [
"MIT"
] | null | null | null | services/autoscaling/put_scheduled_update_group_action_request.go | lee-yongtak/ncloud-sdk-go-v2 | 36bb842331ba5a144dfa7a477501bc4980f44a5e | [
"MIT"
] | null | null | null | /*
* autoscaling
*
* <br/>https://ncloud.apigw.ntruss.com/autoscaling/v2
*
* API version: 2018-08-07T06:47:31Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package autoscaling
type PutScheduledUpdateGroupActionRequest struct {
// 오토스케일링그룹명
AutoScalingGroupName *string `json:"autoScalingGroupName"`
// 기대용량치
DesiredCapacity *int32 `json:"desiredCapacity,omitempty"`
// 반복스케쥴종료시간
EndTime *string `json:"endTime,omitempty"`
// 최대사이즈
MaxSize *int32 `json:"maxSize,omitempty"`
// 최소사이즈
MinSize *int32 `json:"minSize,omitempty"`
// 반복스케줄설정
RecurrenceInKST *string `json:"recurrenceInKST,omitempty"`
// 스케쥴액션명
ScheduledActionName *string `json:"scheduledActionName"`
// 스케쥴시작시간
StartTime *string `json:"startTime,omitempty"`
}
| 20.763158 | 85 | 0.746515 |
0c865092d1b024900a20974bf4805c2c027168ad | 1,337 | asm | Assembly | src/primes.asm | rprouse/8088 | 7cba221d5dd515144afa0d7bdd875f914e0e8c9a | [
"MIT"
] | null | null | null | src/primes.asm | rprouse/8088 | 7cba221d5dd515144afa0d7bdd875f914e0e8c9a | [
"MIT"
] | null | null | null | src/primes.asm | rprouse/8088 | 7cba221d5dd515144afa0d7bdd875f914e0e8c9a | [
"MIT"
] | null | null | null | ; Calculate primes using the Sieve of Eratosthenes
cpu 8086
bits 16
org 0x0100
table: equ 0x8000
table_size: equ 1000
jmp start
%include 'library.inc'
start:
mov bx,table
mov cx,table_size
mov al,0
; Initialize the memory in the table to zero
.zero_loop:
mov [bx],al ; Write AL to the address pointed to by BX
inc bx
loop .zero_loop ; Decrease CX and jump if non-zero
mov ax,2 ; Start at first prime, 2. AX is the prime we are testing
.check_prime:
mov bx,table ; Set BX to the table address
add bx,ax ; Add the last prime to BX
cmp byte [bx],0 ; Is it a prime? If it is still 0, we haven't marked it as a multiple
jne .next
push ax ; This is a prime, display it
call display_number
mov al,','
call chout
pop ax
mov bx,table
add bx,ax
.mark_multiples:
add bx,ax ; Next multiple of AX
cmp bx,table+table_size
jg .next ; Make sure we're not at the end of the table
mov byte [bx],1 ; Set the value as not-prime in the table
jmp .mark_multiples ; Back and multiply again
.next:
inc ax ; Increment AX to the next number to check
cmp ax,table_size ; Make sure we are not at the end
jne .check_prime
jmp exit | 25.711538 | 93 | 0.615557 |
284b2688717d354ae6e7444f223b3fae0698eee2 | 1,513 | rb | Ruby | lib/cute_print/formatter.rb | wconrad/cute_print | 9df8f056579324d329030ef0bd6621b3f0fa2aa8 | [
"MIT"
] | 2 | 2015-06-19T17:31:24.000Z | 2017-09-27T19:44:50.000Z | lib/cute_print/formatter.rb | wconrad/cute_print | 9df8f056579324d329030ef0bd6621b3f0fa2aa8 | [
"MIT"
] | 5 | 2015-02-25T20:51:57.000Z | 2018-03-13T19:29:21.000Z | lib/cute_print/formatter.rb | wconrad/cute_print | 9df8f056579324d329030ef0bd6621b3f0fa2aa8 | [
"MIT"
] | null | null | null | require "pp"
require "stringio"
require_relative "format"
require_relative "labeler"
require_relative "location"
require_relative "location_label"
require_relative "source_label"
require_relative "values"
module CutePrint
# @api private
class Formatter
def initialize(opts = {})
@method = opts.fetch(:method)
@out = opts.fetch(:out)
@block = opts.fetch(:block, nil)
@args = opts.fetch(:values, [])
@values = Values.new(@args, @block)
@width = opts.fetch(:width)
@location_label = nil
end
def write
if @values.empty? && !label.empty?
write_line label.chomp(": ")
else
@values.each do |value|
labeler = Labeler.new(@format, @width, label, value)
write_lines labeler.labeled
end
end
end
def with_location(format_key)
location = Location.find
@location_label = LocationLabel.make(format_key, location)
end
def inspect
@format = Format::Inspect.new
end
def pretty_print
@format = Format::PrettyPrint.new
end
private
def write_lines(lines)
lines.each do |line|
write_line line
end
end
def write_line(line)
line += "\n" unless line =~ /\n\Z/
@out.print line
end
def label
@label ||= make_label
end
def make_label
[
(@location_label.to_s if @location_label),
(SourceLabel.new(@block, @method) if @block),
].compact.join
end
end
end
| 20.173333 | 64 | 0.611368 |
85e1c083470ceaa2b265d2be23bb03565c65d78c | 8,569 | c | C | src/Setup/ExpressionSetup.c | ScrimpyCat/CommonGameK | 47ad7a22140bfac86f36d6e426cb105f21df4277 | [
"BSD-2-Clause"
] | 9 | 2016-11-07T14:54:17.000Z | 2021-11-14T20:37:22.000Z | src/Setup/ExpressionSetup.c | ScrimpyCat/CommonGameK | 47ad7a22140bfac86f36d6e426cb105f21df4277 | [
"BSD-2-Clause"
] | 8 | 2017-03-18T23:55:09.000Z | 2018-03-18T13:46:57.000Z | src/Setup/ExpressionSetup.c | ScrimpyCat/CommonGameK | 47ad7a22140bfac86f36d6e426cb105f21df4277 | [
"BSD-2-Clause"
] | 2 | 2018-04-13T00:59:50.000Z | 2020-06-07T16:03:25.000Z | //This file is automatically generated, modifications will be lost!
#define CC_QUICK_COMPILE
#include "ExpressionSetup.h"
#include "ExpressionEvaluator.h"
#include "MacroExpressions.h"
#include "EntityExpressions.h"
#include "TypeExpressions.h"
#include "IOExpressions.h"
#include "MessageExpressions.h"
#include "MathExpressions.h"
#include "StringExpressions.h"
#include "EqualityExpressions.h"
#include "ColourExpressions.h"
#include "AssetExpressions.h"
#include "DebugExpressions.h"
#include "StateExpressions.h"
#include "GraphicsExpressions.h"
#include "BitwiseExpressions.h"
#include "WindowExpressions.h"
#include "ControlFlowExpressions.h"
#include "FontExpressions.h"
#include "ListExpressions.h"
#include "ComponentExpressions.h"
#include "TextExpressions.h"
#include "GUIExpression.h"
void CCExpressionSetup(void)
{
CCExpressionEvaluatorRegister(CC_STRING("quote"), CCMacroExpressionQuote);
CCExpressionEvaluatorRegister(CC_STRING("unquote"), CCMacroExpressionUnquote);
CCExpressionEvaluatorRegister(CC_STRING("entity"), CCEntityExpressionEntity);
CCExpressionEvaluatorRegister(CC_STRING("entity-lookup"), CCEntityExpressionEntityLookup);
CCExpressionEvaluatorRegister(CC_STRING("type"), CCTypeExpressionGetType);
CCExpressionEvaluatorRegister(CC_STRING("integer->float"), CCTypeExpressionIntegerToFloat);
CCExpressionEvaluatorRegister(CC_STRING("float->integer"), CCTypeExpressionFloatToInteger);
CCExpressionEvaluatorRegister(CC_STRING("print"), CCIOExpressionPrint);
CCExpressionEvaluatorRegister(CC_STRING("search"), CCIOExpressionSearch);
CCExpressionEvaluatorRegister(CC_STRING("eval"), CCIOExpressionEval);
CCExpressionEvaluatorRegister(CC_STRING("component-router"), CCMessageExpressionComponentRouter);
CCExpressionEvaluatorRegister(CC_STRING("entity-component-router"), CCMessageExpressionEntityComponentRouter);
CCExpressionEvaluatorRegister(CC_STRING("message"), CCMessageExpressionMessage);
CCExpressionEvaluatorRegister(CC_STRING("+"), CCMathExpressionAddition);
CCExpressionEvaluatorRegister(CC_STRING("-"), CCMathExpressionSubtract);
CCExpressionEvaluatorRegister(CC_STRING("*"), CCMathExpressionMultiply);
CCExpressionEvaluatorRegister(CC_STRING("/"), CCMathExpressionDivide);
CCExpressionEvaluatorRegister(CC_STRING("min"), CCMathExpressionMinimum);
CCExpressionEvaluatorRegister(CC_STRING("max"), CCMathExpressionMaximum);
CCExpressionEvaluatorRegister(CC_STRING("random"), CCMathExpressionRandom);
CCExpressionEvaluatorRegister(CC_STRING("round"), CCMathExpressionRound);
CCExpressionEvaluatorRegister(CC_STRING("prefix"), CCStringExpressionPrefix);
CCExpressionEvaluatorRegister(CC_STRING("suffix"), CCStringExpressionSuffix);
CCExpressionEvaluatorRegister(CC_STRING("filename"), CCStringExpressionFilename);
CCExpressionEvaluatorRegister(CC_STRING("replace"), CCStringExpressionReplace);
CCExpressionEvaluatorRegister(CC_STRING("cat"), CCStringExpressionConcatenate);
CCExpressionEvaluatorRegister(CC_STRING("length"), CCStringExpressionLength);
CCExpressionEvaluatorRegister(CC_STRING("insert"), CCStringExpressionInsert);
CCExpressionEvaluatorRegister(CC_STRING("remove"), CCStringExpressionRemove);
CCExpressionEvaluatorRegister(CC_STRING("chop"), CCStringExpressionChop);
CCExpressionEvaluatorRegister(CC_STRING("format"), CCStringExpressionFormat);
CCExpressionEvaluatorRegister(CC_STRING("separate"), CCStringExpressionSeparate);
CCExpressionEvaluatorRegister(CC_STRING("="), CCEqualityExpressionEqual);
CCExpressionEvaluatorRegister(CC_STRING("!="), CCEqualityExpressionNotEqual);
CCExpressionEvaluatorRegister(CC_STRING("<="), CCEqualityExpressionLessThanEqual);
CCExpressionEvaluatorRegister(CC_STRING(">="), CCEqualityExpressionGreaterThanEqual);
CCExpressionEvaluatorRegister(CC_STRING("<"), CCEqualityExpressionLessThan);
CCExpressionEvaluatorRegister(CC_STRING(">"), CCEqualityExpressionGreaterThan);
CCExpressionEvaluatorRegister(CC_STRING("not"), CCEqualityExpressionNot);
CCExpressionEvaluatorRegister(CC_STRING("lighten"), CCColourExpressionLighten);
CCExpressionEvaluatorRegister(CC_STRING("darken"), CCColourExpressionDarken);
CCExpressionEvaluatorRegister(CC_STRING("shader"), CCAssetExpressionShader);
CCExpressionEvaluatorRegister(CC_STRING("texture"), CCAssetExpressionTexture);
CCExpressionEvaluatorRegister(CC_STRING("font"), CCAssetExpressionFont);
CCExpressionEvaluatorRegister(CC_STRING("library"), CCAssetExpressionLibrary);
CCExpressionEvaluatorRegister(CC_STRING("source"), CCAssetExpressionLibrarySource);
CCExpressionEvaluatorRegister(CC_STRING("asset"), CCAssetExpressionAsset);
CCExpressionEvaluatorRegister(CC_STRING("inspect"), CCDebugExpressionInspect);
CCExpressionEvaluatorRegister(CC_STRING("break"), CCDebugExpressionBreak);
CCExpressionEvaluatorRegister(CC_STRING("measure"), CCDebugExpressionMeasure);
CCExpressionEvaluatorRegister(CC_STRING("state!"), CCStateExpressionCreateState);
CCExpressionEvaluatorRegister(CC_STRING("namespace!"), CCStateExpressionCreateNamespace);
CCExpressionEvaluatorRegister(CC_STRING("enum!"), CCStateExpressionCreateEnum);
CCExpressionEvaluatorRegister(CC_STRING("super"), CCStateExpressionSuper);
CCExpressionEvaluatorRegister(CC_STRING("strict-super"), CCStateExpressionStrictSuper);
CCExpressionEvaluatorRegister(CC_STRING("render-rect"), CCGraphicsExpressionRenderRect);
CCExpressionEvaluatorRegister(CC_STRING("render-text"), CCGraphicsExpressionRenderText);
CCExpressionEvaluatorRegister(CC_STRING("and"), CCBitwiseExpressionAnd);
CCExpressionEvaluatorRegister(CC_STRING("or"), CCBitwiseExpressionOr);
CCExpressionEvaluatorRegister(CC_STRING("xor"), CCBitwiseExpressionXor);
CCExpressionEvaluatorRegister(CC_STRING("window-percent-width"), CCWindowExpressionPercentageWidth);
CCExpressionEvaluatorRegister(CC_STRING("window-percent-height"), CCWindowExpressionPercentageHeight);
CCExpressionEvaluatorRegister(CC_STRING("window-width"), CCWindowExpressionWidth);
CCExpressionEvaluatorRegister(CC_STRING("window-height"), CCWindowExpressionHeight);
CCExpressionEvaluatorRegister(CC_STRING("window-resized?"), CCWindowExpressionWindowResized);
CCExpressionEvaluatorRegister(CC_STRING("frame-changed?"), CCWindowExpressionFrameChanged);
CCExpressionEvaluatorRegister(CC_STRING("begin"), CCControlFlowExpressionBegin);
CCExpressionEvaluatorRegister(CC_STRING("if"), CCControlFlowExpressionBranch);
CCExpressionEvaluatorRegister(CC_STRING("cond"), CCControlFlowExpressionCond);
CCExpressionEvaluatorRegister(CC_STRING("loop"), CCControlFlowExpressionLoop);
CCExpressionEvaluatorRegister(CC_STRING("repeat"), CCControlFlowExpressionRepeat);
CCExpressionEvaluatorRegister(CC_STRING("loop!"), CCControlFlowExpressionLoopPersist);
CCExpressionEvaluatorRegister(CC_STRING("repeat!"), CCControlFlowExpressionRepeatPersist);
CCExpressionEvaluatorRegister(CC_STRING("any?"), CCControlFlowExpressionAny);
CCExpressionEvaluatorRegister(CC_STRING("all?"), CCControlFlowExpressionAll);
CCExpressionEvaluatorRegister(CC_STRING("font-line-height"), CCFontExpressionGetLineHeight);
CCExpressionEvaluatorRegister(CC_STRING("get"), CCListExpressionGetter);
CCExpressionEvaluatorRegister(CC_STRING("set"), CCListExpressionSetter);
CCExpressionEvaluatorRegister(CC_STRING("drop"), CCListExpressionDrop);
CCExpressionEvaluatorRegister(CC_STRING("flatten"), CCListExpressionFlatten);
CCExpressionEvaluatorRegister(CC_STRING("parts"), CCListExpressionParts);
CCExpressionEvaluatorRegister(CC_STRING("split"), CCListExpressionSplit);
CCExpressionEvaluatorRegister(CC_STRING("count"), CCListExpressionCount);
CCExpressionEvaluatorRegister(CC_STRING("component"), CCComponentExpressionComponent);
CCExpressionEvaluatorRegister(CC_STRING("text-visible-length"), CCTextExpressionGetVisibleLength);
CCExpressionEvaluatorRegister(CC_STRING("text-cursor-position"), CCTextExpressionGetCursorPosition);
CCExpressionEvaluatorRegister(CC_STRING("text-cursor-offset"), CCTextExpressionGetCursorOffset);
CCExpressionEvaluatorRegister(CC_STRING("gui"), GUIExpressionRegisterObject);
CCExpressionEvaluatorRegister(CC_STRING("percent-width"), GUIExpressionPercentWidth);
CCExpressionEvaluatorRegister(CC_STRING("percent-height"), GUIExpressionPercentHeight);
CCExpressionEvaluatorRegister(CC_STRING("on"), GUIExpressionOnEvent);
}
| 70.237705 | 114 | 0.826234 |
1a645c19448d1b78ea29333b1560e2b45f19d31e | 2,406 | lua | Lua | Code/['World']['Global']['Xls']['BowInfoXlsModule'].ModuleScript.lua | lilith-avatar/Social-island | 009e43118a112c03dea77ec3e43899da9fbde32e | [
"MIT"
] | 3 | 2021-04-20T09:39:11.000Z | 2021-05-06T06:46:22.000Z | Code/['World']['Global']['Xls']['BowInfoXlsModule'].ModuleScript.lua | lilith-avatar/Social-island | 009e43118a112c03dea77ec3e43899da9fbde32e | [
"MIT"
] | 1 | 2021-04-12T13:00:53.000Z | 2021-04-12T13:00:53.000Z | Code/['World']['Global']['Xls']['BowInfoXlsModule'].ModuleScript.lua | lilith-avatar/Social-island | 009e43118a112c03dea77ec3e43899da9fbde32e | [
"MIT"
] | 1 | 2021-05-12T09:51:41.000Z | 2021-05-12T09:51:41.000Z | --- This file is generated by ava-x2l.exe,
--- Don't change it manaully.
--- @copyright Lilith Games, Project Da Vinci(Avatar Team)
--- @see https://www.projectdavinci.com/
--- @see https://github.com/endaye/avatar-ava-xls2lua
--- source file: .//GameHunting.xlsx
local BowInfoXls = {
[1] = {
Id = 1,
Ico = 'Ico_Bow_01',
Modle = 'M_Bow_01',
Offset = Vector3(0, 0, 0),
AniSpeed = 1,
Bullet = 'M_Arrow_01',
HitEffect = 'bulinbulin',
CanCharge = true,
MinSpeed = 5.0,
MaxSpeed = 10.0,
Range = 0.0,
AfterEffect = 'onfire',
AfterEffectKeep = 3.0,
Huntable = true,
HitAni = 'Hit'
},
[2] = {
Id = 2,
Ico = 'Ico_Bow_02',
Modle = 'M_Bow_02',
Offset = Vector3(0, 0, 0),
AniSpeed = 1,
Bullet = 'M_Arrow_02',
HitEffect = 'bulinbulin',
CanCharge = true,
MinSpeed = 5.0,
MaxSpeed = 10.0,
Range = 0.0,
AfterEffect = 'onfire',
AfterEffectKeep = 3.0,
Huntable = true,
HitAni = 'Hit'
},
[3] = {
Id = 3,
Ico = 'Ico_Bow_03',
Modle = 'M_Bow_03',
Offset = Vector3(0, 0, 0),
AniSpeed = 1,
Bullet = 'M_Arrow_03',
HitEffect = 'bulinbulin',
CanCharge = true,
MinSpeed = 5.0,
MaxSpeed = 10.0,
Range = 0.0,
AfterEffect = 'onfire',
AfterEffectKeep = 3.0,
Huntable = true,
HitAni = 'Hit'
},
[4] = {
Id = 4,
Ico = 'Ico_Bow_04',
Modle = 'M_Bow_04',
Offset = Vector3(0, 0, 0),
AniSpeed = 1,
Bullet = 'M_Arrow_04',
HitEffect = 'bulinbulin',
CanCharge = true,
MinSpeed = 5.0,
MaxSpeed = 10.0,
Range = 0.0,
AfterEffect = 'onfire',
AfterEffectKeep = 3.0,
Huntable = true,
HitAni = 'Hit'
},
[5] = {
Id = 5,
Ico = 'Ico_Bow_05',
Modle = 'M_Bow_05',
Offset = Vector3(0, 0, 0),
AniSpeed = 3,
Bullet = 'M_Arrow_05',
HitEffect = 'bulinbulin',
CanCharge = true,
MinSpeed = 5.0,
MaxSpeed = 10.0,
Range = 0.0,
AfterEffect = 'onfire',
AfterEffectKeep = 3.0,
Huntable = true,
HitAni = 'Hit'
}
}
return BowInfoXls
| 24.804124 | 58 | 0.476725 |
9c3480bb3d3bf65d3d1391fe49f56590ba6a6c37 | 1,312 | js | JavaScript | src/utils/getEmblems.js | FabriSilve/bookclub | 2fab40cd83a34b319bcc0ba0ceeb6361e0f3ac09 | [
"MIT"
] | null | null | null | src/utils/getEmblems.js | FabriSilve/bookclub | 2fab40cd83a34b319bcc0ba0ceeb6361e0f3ac09 | [
"MIT"
] | null | null | null | src/utils/getEmblems.js | FabriSilve/bookclub | 2fab40cd83a34b319bcc0ba0ceeb6361e0f3ac09 | [
"MIT"
] | null | null | null | import none from '../images/emblems/none.png';
import ajax from '../images/emblems/ajax.png';
import arsenal from '../images/emblems/arsenal.png';
import madrid from '../images/emblems/madrid.png';
import leverkusen from '../images/emblems/leverkusen.png';
import chelsea from '../images/emblems/chelsea.png';
import everton from '../images/emblems/everton.png';
import inter from '../images/emblems/inter.png';
import lazio from '../images/emblems/lazio.png';
import manchester from '../images/emblems/manchester.png';
import milan from '../images/emblems/milan.png';
import napoli from '../images/emblems/napoli.png';
import lyonnaise from '../images/emblems/lyonnais.png';
import roma from '../images/emblems/roma.png';
import tottenham from '../images/emblems/tottenham.png';
import valencia from '../images/emblems/valencia.png';
const emblems = {
'ajax': ajax,
'arsenal': arsenal,
'madrid': madrid,
'leverkusen': leverkusen,
'chelsea': chelsea,
'everton': everton,
'inter': inter,
'lazio': lazio,
'manchester': manchester,
'milan': milan,
'napoli': napoli,
'lyonnais': lyonnaise,
'roma': roma,
'tottenham': tottenham,
'valencia': valencia,
};
const getEmblem = (team) => {
const logo = emblems[team];
if (logo) return logo;
return none;
};
export default getEmblem;
| 29.818182 | 58 | 0.707317 |
12af8e6739106beee60537c14f2e92b431b2e9ca | 672 | h | C | CustomerSystem-ios/HelpDeskUI/HDUIKit/3rdparty/HDMJRefresh/Base/HDMJRefreshFooter.h | dujiepeng/kefu-ios-demo | 3e43fd76d0ea51ba53da0ca5ca2e699da1be86d4 | [
"MIT"
] | null | null | null | CustomerSystem-ios/HelpDeskUI/HDUIKit/3rdparty/HDMJRefresh/Base/HDMJRefreshFooter.h | dujiepeng/kefu-ios-demo | 3e43fd76d0ea51ba53da0ca5ca2e699da1be86d4 | [
"MIT"
] | null | null | null | CustomerSystem-ios/HelpDeskUI/HDUIKit/3rdparty/HDMJRefresh/Base/HDMJRefreshFooter.h | dujiepeng/kefu-ios-demo | 3e43fd76d0ea51ba53da0ca5ca2e699da1be86d4 | [
"MIT"
] | null | null | null | // HDMJRefreshFooter.h
// HDMJRefreshExample
//
// Created by MJ Lee on 15/3/5.
#import "HDMJRefreshComponent.h"
@interface HDMJRefreshFooter : HDMJRefreshComponent
+ (instancetype)footerWithRefreshingBlock:(HDMJRefreshComponentRefreshingBlock)refreshingBlock;
+ (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action;
- (void)endRefreshingWithNoMoreData;
- (void)noticeNoMoreData HDMJRefreshDeprecated("Please use endRefreshingWithNoMoreData");
- (void)resetNoMoreData;
@property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetBottom;
@property (assign, nonatomic, getter=isAutomaticallyHidden) BOOL automaticallyHidden;
@end
| 32 | 95 | 0.825893 |
f40b33f0f7b0ecfdde0645cd9570314811b4f8d9 | 4,855 | sql | SQL | database/demo/demo_script/03_demo_utl_xml_parsequery.sql | bjtp/plscope-utils | 4d62d54701dc35eca7b7c4941a0205936484f797 | [
"Apache-2.0"
] | null | null | null | database/demo/demo_script/03_demo_utl_xml_parsequery.sql | bjtp/plscope-utils | 4d62d54701dc35eca7b7c4941a0205936484f797 | [
"Apache-2.0"
] | null | null | null | database/demo/demo_script/03_demo_utl_xml_parsequery.sql | bjtp/plscope-utils | 4d62d54701dc35eca7b7c4941a0205936484f797 | [
"Apache-2.0"
] | null | null | null | -- 1. parse a select statement using sys.utl_xml.parsequery
SELECT parse_util.parse_query(
in_parse_user => user,
in_query => q'[
SELECT /*+ordered */ d.deptno, d.dname, SUM(e.sal + NVL(e.comm, 0)) AS sal
FROM dept d
LEFT JOIN (SELECT * FROM emp WHERE hiredate > DATE '1980-01-01') e
ON e.deptno = d.deptno
GROUP BY d.deptno, d.dname
]'
)
FROM dual;
-- 2. parse an insert statement using sys.utl_xml.parsequery
SELECT parse_util.parse_query(
in_parse_user => user,
in_query => q'[
INSERT INTO deptsal (dept_no, dept_name, salary)
SELECT /*+ordered */ d.deptno, d.dname, SUM(e.sal + NVL(e.comm, 0)) AS sal
FROM dept d
LEFT JOIN (SELECT * FROM emp WHERE hiredate > DATE '1980-01-01') e
ON e.deptno = d.deptno
GROUP BY d.deptno, d.dname
]'
)
FROM dual;
-- 3. parse an update statement using sys.utl_xml.parsequery
SELECT parse_util.parse_query(
in_parse_user => user,
in_query => q'[
UPDATE deptsal
SET salary = salary + 10
WHERE dept_no = (SELECT deptno
FROM dept
WHERE dname = 'SALES')
]'
)
FROM dual;
-- 4. parse a delete statement using sys.util_xml_parsequery
SELECT parse_util.parse_query(
in_parse_user => user,
in_parse_query => q'[
DELETE deptsal
WHERE dept_no = (SELECT deptno
FROM dept
WHERE dname = 'SALES')
]'
)
FROM dual;
-- 5. parse a merge statement using sys.util_xml_parsequery
SELECT parse_util.parse_query(
in_parse_user => user,
in_query => q'[
MERGE INTO deptsal t
USING (
SELECT /*+ordered */ d.deptno, d.dname, SUM(e.sal + NVL(e.comm, 0)) AS sal
FROM dept d
LEFT JOIN (SELECT * FROM emp WHERE hiredate > DATE '1980-01-01') e
ON e.deptno = d.deptno
GROUP BY d.deptno, d.dname
) s
ON (t.dept_no = s.deptno)
WHEN MATCHED THEN
UPDATE SET t.salary = s.sal * 0.1
WHEN NOT MATCHED THEN
INSERT (t.dept_no, t.dept_name, t.salary)
VALUES (s.deptno, s.dname, s.sal * 0.1)
]'
)
FROM dual;
-- 6. parse an anonymous PL/SQL block using sys.util_xml_parsequery - empty!
SELECT parse_util.parse_query(
in_parse_user => user,
in_parse_query => q'[
BEGIN
INSERT INTO deptsal (dept_no, dept_name, salary)
SELECT /*+ordered */ d.deptno, d.dname, SUM(e.sal + NVL(e.comm, 0)) AS sal
FROM dept d
LEFT JOIN (SELECT * FROM emp WHERE hiredate > DATE '1980-01-01') e
ON e.deptno = d.deptno
GROUP BY d.deptno, d.dname; -- avoid premature statement termination in SQL*Plus et al.
END; -- avoid premature statement termination in SQL*Plus et al.
]'
)
FROM dual;
-- 7. parse a select statement with a function using sys.utl_xml.parsequery - empty!
SELECT parse_util.parse_query(
in_parse_user => user,
in_query => q'[
WITH
FUNCTION my_add(in_a IN NUMBER, in_b IN NUMBER) RETURN NUMBER IS
BEGIN
RETURN NVL(in_a, 0) + NVL(in_b, 0); -- avoid premature statement termination in SQL*Plus et al.
END my_add; -- avoid premature statement termination in SQL*Plus et al.
SELECT /*+ordered */ d.deptno, d.dname, SUM(my_add(e.sal, e.comm)) AS sal
FROM dept d
LEFT JOIN (SELECT * FROM emp WHERE hiredate > DATE '1980-01-01') e
ON e.deptno = d.deptno
GROUP BY d.deptno, d.dname
]'
)
FROM dual;
-- 8. parse a select statement with a 12.2 features using sys.utl_xml.parsequer
SELECT parse_util.parse_query(
in_parse_user => user,
in_query => q'[
SELECT CAST('x' AS NUMBER DEFAULT 0 ON CONVERSION ERROR) AS cast_col,
VALIDATE_CONVERSION('$29.99' AS BINARY_FLOAT, '$99D99') AS validate_col,
LISTAGG(
ename || ' (' || job || ')',
', ' ON OVERFLOW TRUNCATE '...' WITH COUNT
) WITHIN GROUP (ORDER BY deptno) AS enames
FROM emp
]'
)
FROM dual;
| 39.471545 | 114 | 0.508342 |
d86919b31fe48ca967fedadbefafa62b35da669e | 96 | sql | SQL | popx/stub/migrations/transactional/20200831110752000018_identity_verifiable_address_remove_code.sqlite3.down.sql | svrakitin/x | 37110c95b9fb5e9b007a6b4369aaefb2d612bd02 | [
"Apache-2.0"
] | 33 | 2018-10-08T12:12:00.000Z | 2022-03-29T11:40:24.000Z | popx/stub/migrations/transactional/20200831110752000018_identity_verifiable_address_remove_code.sqlite3.down.sql | svrakitin/x | 37110c95b9fb5e9b007a6b4369aaefb2d612bd02 | [
"Apache-2.0"
] | 118 | 2018-10-20T16:00:42.000Z | 2022-03-24T17:54:17.000Z | popx/stub/migrations/transactional/20200831110752000018_identity_verifiable_address_remove_code.sqlite3.down.sql | svrakitin/x | 37110c95b9fb5e9b007a6b4369aaefb2d612bd02 | [
"Apache-2.0"
] | 64 | 2018-10-14T03:00:10.000Z | 2022-03-11T07:19:21.000Z | UPDATE identity_verifiable_addresses SET expires_at = CURRENT_TIMESTAMP WHERE expires_at IS NULL | 96 | 96 | 0.895833 |
d0a08b690b245a58617ea8e5fa62c2e25b9c2a55 | 118 | lua | Lua | apps/vmq_diversity/test/bcrypt_test.lua | joskwanten/vernemq | 67640325ce3321d035ed9191e3d313d0def43507 | [
"Apache-2.0"
] | 1,588 | 2015-05-27T19:13:50.000Z | 2018-11-02T08:07:56.000Z | apps/vmq_diversity/test/bcrypt_test.lua | joskwanten/vernemq | 67640325ce3321d035ed9191e3d313d0def43507 | [
"Apache-2.0"
] | 900 | 2018-11-02T09:20:24.000Z | 2022-03-31T17:13:58.000Z | apps/vmq_diversity/test/bcrypt_test.lua | joskwanten/vernemq | 67640325ce3321d035ed9191e3d313d0def43507 | [
"Apache-2.0"
] | 212 | 2018-11-14T09:12:42.000Z | 2022-03-24T05:10:17.000Z | salt = bcrypt.gen_salt()
hash = bcrypt.hashpw("my-password", salt)
assert(bcrypt.hashpw("my-password", hash) == hash)
| 29.5 | 50 | 0.711864 |
0ce5d95f10a05417cb3b6fc154c24d7adc27cf45 | 1,877 | py | Python | scripts/baxter_find_tf.py | mkrizmancic/qlearn_baxter | 0498315212cacb40334cbb97a858c6ba317f52a3 | [
"MIT"
] | 4 | 2017-11-11T18:16:22.000Z | 2018-11-08T13:31:09.000Z | scripts/baxter_find_tf.py | mkrizmancic/qlearn_baxter | 0498315212cacb40334cbb97a858c6ba317f52a3 | [
"MIT"
] | null | null | null | scripts/baxter_find_tf.py | mkrizmancic/qlearn_baxter | 0498315212cacb40334cbb97a858c6ba317f52a3 | [
"MIT"
] | 2 | 2019-09-04T12:28:58.000Z | 2021-09-27T13:02:48.000Z | #!/usr/bin/env python
"""Calculate transformation matrices and broadcast transform from robot's base to head markers."""
import rospy
import tf
import math
from PyKDL import Vector, Frame, Rotation
if __name__ == '__main__':
rospy.init_node('baxter_find_transformation')
listener = tf.TransformListener()
br = tf.TransformBroadcaster()
rate = rospy.Rate(50)
while not rospy.is_shutdown():
try:
(trans_OH, rot_OH) = listener.lookupTransform('/optitrack', '/bax_head', rospy.Time(0))
(trans_OA, rot_OA) = listener.lookupTransform('/optitrack', '/bax_arm', rospy.Time(0))
(trans_BG, rot_BG) = listener.lookupTransform('/base', '/left_gripper_base', rospy.Time(0))
except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException):
continue
# Rotations
rot_OH = Rotation.Quaternion(*rot_OH)
rot_OA = Rotation.Quaternion(*rot_OA)
rot_BG = Rotation.Quaternion(*rot_BG)
rot_AG = Rotation.RPY(math.pi / 2, -math.pi, math.pi / 2)
# Creating Frames
T_OH = Frame(rot_OH, Vector(*trans_OH))
T_OA = Frame(rot_OA, Vector(*trans_OA))
T_BG = Frame(rot_BG, Vector(*trans_BG))
T_AG = Frame(rot_AG, Vector(0, 0, 0))
# Finding right transformation
T_HB = T_OH.Inverse() * T_OA * T_AG * T_BG.Inverse()
T_empty_p = Vector(0, 0, 0)
T_empty_Q = Rotation.Quaternion(0, 0, 0, 1)
T_empty = Frame(T_empty_Q, T_empty_p)
# Broadcast new transformations
br.sendTransform(T_HB.p, T_HB.M.GetQuaternion(), rospy.Time.now(), 'base', 'bax_head')
br.sendTransform(T_HB.p, T_HB.M.GetQuaternion(), rospy.Time.now(), 'reference/base', 'bax_head')
br.sendTransform(T_empty.p, T_empty.M.GetQuaternion(), rospy.Time.now(), 'world', 'base')
rate.sleep()
| 39.93617 | 104 | 0.64731 |
ade1192e66419a4f1a0f70babfae972e654e2cc0 | 13,712 | lua | Lua | 3DreamEngine/loader/dae.lua | sewbacca/3DreamEngine | d688b7d04fd7ffdbedaa55b0d26785e78304bbca | [
"MIT"
] | 209 | 2019-04-01T20:58:05.000Z | 2022-03-30T20:02:26.000Z | 3DreamEngine/loader/dae.lua | sewbacca/3DreamEngine | d688b7d04fd7ffdbedaa55b0d26785e78304bbca | [
"MIT"
] | 54 | 2019-03-30T23:58:34.000Z | 2022-02-01T14:20:57.000Z | 3DreamEngine/loader/dae.lua | sewbacca/3DreamEngine | d688b7d04fd7ffdbedaa55b0d26785e78304bbca | [
"MIT"
] | 12 | 2019-03-31T09:50:25.000Z | 2022-03-03T09:52:04.000Z | --[[
#dae - COLLADA
--]]
--load space seperated arrays as floats or as strings
local function loadFloatArray(arr)
local t = { }
for w in arr:gmatch("%S+") do
t[#t+1] = tonumber(w)
end
return t
end
local function loadArray(arr)
local t = { }
for w in arr:gmatch("%S+") do
t[#t+1] = w
end
return t
end
--load entire tree and index all IDs
local indices
local localToGlobal
local function indexTree(node)
for key,child in pairs(node) do
if type(child) == "table" and key ~= "_attr" then
indexTree(child)
end
end
if node._attr and node._attr.id then
indices[node._attr.id] = node
indices["#" .. node._attr.id] = node
if node._attr.sid then
localToGlobal[node._attr.sid] = node._attr.id
end
end
end
return function(self, obj, path)
local xml2lua = require(self.root .. "/libs/xml2lua/xml2lua")
local handler = require(self.root .. "/libs/xml2lua/tree"):new()
--parse
local file = love.filesystem.read(path)
xml2lua.parser(handler):parse(file)
local correction = mat4:getRotateX(-math.pi/2)
local root = handler.root.COLLADA[1]
--get id indices
indices = { }
localToGlobal = { }
indexTree(root)
--load armatures and vertex weights
local armatures = { }
local controllers = { }
if root.library_controllers then
for d,s in ipairs(root.library_controllers[1].controller) do
if s.skin then
local name = s.skin[1]._attr.source:sub(2)
local a = {
weights = { },
joints = { },
jointIDs = { },
}
armatures[name] = a
controllers[s._attr.id] = name
--load sources
local weights = { }
for i,v in ipairs(s.skin[1].source) do
local typ = v.technique_common[1].accessor[1].param[1]._attr.name
if typ == "JOINT" then
a.jointIDs = loadArray(v.Name_array[1][1])
for d,s in ipairs(a.jointIDs) do
a.jointIDs[d] = localToGlobal[s] or s
end
elseif typ == "WEIGHT" then
weights = loadFloatArray(v.float_array[1][1])
end
end
--load weights
local vw = s.skin[1].vertex_weights[1]
local vcount = vw.vcount and loadFloatArray(vw.vcount[1][1]) or { }
local ids = loadFloatArray(vw.v[1][1])
local count = tonumber(vw._attr.count)
local fields = #vw.input
for _,input in ipairs(vw.input) do
local typ = input._attr.semantic
local offset = 1 + tonumber(input._attr.offset)
if typ == "JOINT" then
local ci = 1
for i = 1, count do
local verts = vcount[i] or 1
a.joints[i] = { }
for v = 1, verts do
local id = ids[(ci-1)*fields+offset]
a.joints[i][v] = id+1
ci = ci + 1
end
end
elseif typ == "WEIGHT" then
local ci = 1
for i = 1, count do
local verts = vcount[i] or 1
a.weights[i] = { }
for v = 1, verts do
local id = ids[(ci-1)*fields+offset]
a.weights[i][v] = weights[id+1]
ci = ci + 1
end
end
end
end
--normalize weights and limit to 4 (GPU limit)
for i = 1, #a.weights do
while #a.weights[i] > 4 do
local min, best = math.huge, 1
for d,s in ipairs(a.weights[i]) do
if s < min then
min = s
best = d
end
end
table.remove(a.joints[i], best)
table.remove(a.weights[i], best)
end
--normalize
local sum = 0
for d,s in ipairs(a.weights[i]) do
sum = sum + s
end
if sum > 0 then
for d,s in ipairs(a.weights[i]) do
a.weights[i][d] = s / sum
end
end
end
end
end
end
--load materials
if root.library_materials then
for _,mat in ipairs(root.library_materials[1].material) do
local name = mat._attr.name
local material = self:newMaterial(name)
obj.materials[name] = material
indices[mat._attr.id] = material
--load
if mat.instance_effect then
local effect = indices[mat.instance_effect[1]._attr.url]
--get first profile
local profile
for d,s in pairs(effect) do
profile = s[1]
end
--parse data
if profile then
for step, dataArr in pairs(profile.technique[1]) do
if step ~= "_attr" then
local data = dataArr[1]
if data.emission then
local e = data.emission[1]
if e.color then
local color = loadFloatArray( e.color[1][1] )
material.emission = {color[1] * color[4], color[2] * color[4], color[3] * color[4]}
end
end
if data.diffuse then
local d = data.diffuse[1]
if d.color then
local color = loadFloatArray( d.color[1][1] )
material.color = color
end
end
if data.specular then
local s = data.specular[1]
if s.color then
local color = loadFloatArray( s.color[1][1] )
material.specular = math.sqrt(color[1]^2 + color[2]^2 + color[3]^2)
end
end
if data.shininess then
material.glossiness = tonumber( data.shininess[1].float[1][1] )
end
if data.index_of_refraction then
material.ior = tonumber( data.index_of_refraction[1].float[1][1] )
end
end
end
end
end
end
end
--load main geometry
local meshData = { }
for d,geo in ipairs(root.library_geometries[1].geometry) do
local mesh = geo.mesh[1]
local id = geo._attr.id
meshData[id] = meshData[id] or { }
--translation table
local translate = {
["VERTEX"] = "vertices",
["NORMAL"] = "normals",
["TEXCOORD"] = "texCoords",
["COLOR"] = "colors",
}
--parse vertices
local o
local lastMaterial
local index = 0
local edges = { }
for typ = 1, 3 do
local list
if typ == 1 then
list = mesh.triangles
elseif typ == 2 then
list = mesh.polylist
else
list = mesh.polygons
end
if list then
for _,l in ipairs(list) do
local mat = indices[l._attr.material] or obj.materials.None
local material = self.materialLibrary[mat.name] or mat
if obj.args.splitMaterials then
o = self:newSubObject(geo._attr.id, obj, material)
meshData[id][#meshData[id]+1] = o
index = 0
elseif not o then
o = self:newSubObject(geo._attr.id, obj, material)
meshData[id][#meshData[id]+1] = o
end
--connect with armature
if armatures[o.name] and not o.weights then
o.weights = { }
o.joints = { }
o.jointIDs = armatures[o.name].jointIDs
end
--ids of source components per vertex
local ids
local vcount
if typ == 3 then
ids = { }
vcount = { }
--combine polygons
for _,p in ipairs(l.p) do
local a = loadFloatArray(p[1])
for _,v in ipairs(a) do
ids[#ids+1] = v
end
vcount[#vcount+1] = #a
end
else
ids = loadFloatArray(l.p[1][1])
vcount = l.vcount and loadFloatArray(l.vcount[1][1]) or { }
end
--get max offset
local fields = 0
for d,input in ipairs(l.input) do
fields = tonumber(input._attr.offset) + 1
end
--parse data arrays
local verticeIndex = { }
for d,input in ipairs(l.input) do
local f = translate[input._attr.semantic]
if f then
local s = loadFloatArray( (indices[input._attr.source].input and indices[ indices[input._attr.source].input[1]._attr.source ] or indices[input._attr.source]).float_array[1][1] )
for i = 1, #ids / fields do
local id = ids[(i-1)*fields + tonumber(input._attr.offset) + 1]
if f == "texCoords" then
--xy vector
o[f][index+i] = {
s[id*2+1],
1.0-s[id*2+2],
}
elseif f == "colors" then
--rgba vector
o[f][index+i] = {
s[id*4+1],
s[id*4+2],
s[id*4+3],
s[id*4+4],
}
else
--xyz vectors
o[f][index+i] = {
s[id*3+1],
s[id*3+2],
s[id*3+3]
}
if f == "vertices" then
verticeIndex[index+i] = id
end
--also connect weight and joints
if f == "vertices" and o.weights then
o.weights[index+i] = armatures[o.name].weights[id+1]
o.joints[index+i] = armatures[o.name].joints[id+1]
o.materials[index+i] = material
end
end
end
end
end
--parse polygons
local count = l._attr.count
local i = index+1
for face = 1, count do
local verts = vcount[face] or 3
--store edges
for v = 1, verts do
local a, b = i + v - 1, v == verts and i or (i + v)
local min = math.min(verticeIndex[a], verticeIndex[b])
local max = math.max(verticeIndex[a], verticeIndex[b])
local id = min * 65536 + max
if not edges[id] then
edges[id] = true
o.edges[#o.edges+1] = {a, b}
end
end
if verts == 3 then
--tris
o.faces[#o.faces+1] = {i, i+1, i+2}
else
--triangulates, fan style
for f = 1, verts-2 do
o.faces[#o.faces+1] = {i, i+f, i+f+1}
end
end
i = i + verts
end
index = #o.vertices
end
end
end
end
--load light
local lightIDs = { }
if root.library_lights then
for d,light in ipairs(root.library_lights[1].light) do
local l = self:newLight()
lightIDs[light._attr.id] = l
if light.extra and light.extra[1] and light.extra[1].technique and light.extra[1].technique[1] then
local dat = light.extra[1].technique[1]
l:setColor(dat.red and tonumber(dat.red[1][1]) or 1.0, dat.green and tonumber(dat.green[1][1]) or 1.0, dat.blue and tonumber(dat.blue[1][1]) or 1.0)
l:setBrightness(dat.energy and tonumber(dat.energy[1][1]) or 1.0)
end
table.insert(obj.lights, l)
end
end
local function addObject(name, mesh, transform)
for _,subObject in ipairs(meshData[mesh]) do
local id = name
if obj.args.splitMaterials then
id = id .. "_" .. subObject.material.name
end
obj.objects[id] = subObject:clone()
obj.objects[id].name = name
obj.objects[id].transform = correction * transform
end
end
--load scene
for d,s in ipairs(root.library_visual_scenes[1].visual_scene[1].node) do
obj.joints = { }
if s.instance_geometry then
--object
local id = s.instance_geometry[1]._attr.url:sub(2)
local name = s._attr.name or s._attr.id
local transform = mat4(loadFloatArray(s.matrix[1][1]))
addObject(name, id, transform)
elseif s.instance_light then
local transform = correction * mat4(loadFloatArray(s.matrix[1][1]))
local l = lightIDs[s.instance_light[1]._attr.url:sub(2)]
l:setPosition(transform[4], transform[8], transform[12])
elseif s._attr.name == "Armature" then
--propably an armature
--TODO: not a proper way to identify armature nodes
local function skeletonLoader(nodes, parentTransform)
local skel = { }
for d,s in ipairs(nodes) do
if s.instance_controller then
--object associated with skeleton
local id = s.instance_controller[1]._attr.url:sub(2)
local mesh = controllers[id]
local name = s._attr.name or s._attr.id
local transform = mat4(loadFloatArray(s.matrix[1][1]))
addObject(name, mesh, transform)
end
if s._attr.type == "JOINT" then
local name = s._attr.id
local m = mat4(loadFloatArray(s.matrix[1][1]))
local bindTransform = parentTransform and parentTransform * m or m
skel[name] = {
name = name,
bindTransform = m,
inverseBindTransform = bindTransform:invert(),
}
obj.joints[name] = skel[name]
if s.node then
skel[name].children = skeletonLoader(s.node, bindTransform)
end
end
end
return skel
end
obj.skeleton = skeletonLoader(s.node)
break
end
end
--load animations
if root.library_animations then
local animations = { }
local function loadAnimation(anim)
for _,a in ipairs(anim) do
if a.animation then
loadAnimation(a.animation)
else
local keyframes = { }
local name = a.channel[1]._attr.target:sub(1, -11)
--parse sources
local sources = { }
for d,s in ipairs(a.source) do
sources[s._attr.id] = s.float_array and loadFloatArray(s.float_array[1][1]) or s.Name_array and loadArray(s.Name_array[1][1])
end
for d,s in ipairs(a.sampler[1].input) do
sources[s._attr.semantic] = sources[s._attr.source:sub(2)]
end
--get matrices
local frames = { }
local positions = { }
for i = 1, #sources.OUTPUT / 16 do
local m = mat4(unpack(sources.OUTPUT, i*16-15, i*16))
frames[#frames+1] = {
time = sources.INPUT[i],
--interpolation = sources.INTERPOLATION[i],
rotation = quat.fromMatrix(m:subm()),
position = vec3(m[4], m[8], m[12]),
}
end
--pack
animations[name] = frames
end
end
end
loadAnimation(root.library_animations[1].animation)
--split animations
if obj.args.animations then
obj.animations = { }
obj.animationLengths = { }
for anim, time in pairs(obj.args.animations) do
obj.animations[anim] = { }
obj.animationLengths[anim] = time[2] - time[1]
for joint, frames in pairs(animations) do
local newFrames = { }
for i, frame in ipairs(frames) do
if frame.time >= time[1] and frame.time <= time[2] then
table.insert(newFrames, frame)
end
end
obj.animations[anim][joint] = newFrames
end
end
else
obj.animations = {
default = animations,
}
obj.animationLengths = {
default = animations[#animations].time,
}
end
end
end | 26.573643 | 184 | 0.589192 |
f051fa84986a7c9f1470f505282adadb784afefe | 5,289 | py | Python | ibmsecurity/isam/base/fips.py | zone-zero/ibmsecurity | 7d3e38104b67e1b267e18a44845cb756a5302c3d | [
"Apache-2.0"
] | 46 | 2017-03-21T21:08:59.000Z | 2022-02-20T22:03:46.000Z | ibmsecurity/isam/base/fips.py | zone-zero/ibmsecurity | 7d3e38104b67e1b267e18a44845cb756a5302c3d | [
"Apache-2.0"
] | 201 | 2017-03-21T21:25:52.000Z | 2022-03-30T21:38:20.000Z | ibmsecurity/isam/base/fips.py | zone-zero/ibmsecurity | 7d3e38104b67e1b267e18a44845cb756a5302c3d | [
"Apache-2.0"
] | 91 | 2017-03-22T16:25:36.000Z | 2022-02-04T04:36:29.000Z | import logging
import ibmsecurity.utilities.tools
import time
logger = logging.getLogger(__name__)
requires_model = "Appliance"
def get(isamAppliance, check_mode=False, force=False):
"""
Retrieving the current FIPS Mode configuration
"""
return isamAppliance.invoke_get("Retrieving the current FIPS Mode configuration",
"/fips_cfg", requires_model=requires_model)
def set(isamAppliance, fipsEnabled=True, tlsv10Enabled=True, tlsv11Enabled=False, check_mode=False, force=False):
"""
Updating the FIPS Mode configuration
"""
obj = _check(isamAppliance, fipsEnabled, tlsv10Enabled, tlsv11Enabled)
if force is True or obj['value'] is False:
if check_mode is True:
return isamAppliance.create_return_object(changed=True, warnings=obj['warnings'])
else:
return isamAppliance.invoke_put(
"Updating the FIPS Mode configuration",
"/fips_cfg",
{
"fipsEnabled": fipsEnabled,
"tlsv10Enabled": tlsv10Enabled,
"tlsv11Enabled": tlsv11Enabled
},
requires_model=requires_model
)
return isamAppliance.create_return_object(warnings=obj['warnings'])
def restart(isamAppliance, check_mode=False, force=False):
"""
Rebooting and enabling the FIPS Mode configuration
:param isamAppliance:
:param check_mode:
:param force:
:return:
"""
if check_mode is True:
return isamAppliance.create_return_object(changed=True)
else:
return isamAppliance.invoke_put(
"Rebooting and enabling the FIPS Mode configuration",
"/fips_cfg/restart",
{}, requires_model=requires_model
)
def restart_and_wait(isamAppliance, wait_time=300, check_freq=5, check_mode=False, force=False):
"""
Restart after FIPS configuration changes
:param isamAppliance:
:param wait_time:
:param check_freq:
:param check_mode:
:param force:
:return:
"""
if isamAppliance.facts['model'] != "Appliance":
return isamAppliance.create_return_object(
warnings="API invoked requires model: {0}, appliance is of deployment model: {1}.".format(
requires_model, isamAppliance.facts['model']))
warnings = []
if check_mode is True:
return isamAppliance.create_return_object(changed=True)
else:
firmware = ibmsecurity.isam.base.firmware.get(isamAppliance, check_mode=check_mode, force=force)
ret_obj = restart(isamAppliance)
if ret_obj['rc'] == 0:
sec = 0
# Now check if it is up and running
while 1:
ret_obj = ibmsecurity.isam.base.firmware.get(isamAppliance, check_mode=check_mode, force=force,
ignore_error=True)
# check partition last_boot time
if ret_obj['rc'] == 0 and isinstance(ret_obj['data'], list) and len(ret_obj['data']) > 0 and \
(('last_boot' in ret_obj['data'][0] and ret_obj['data'][0]['last_boot'] != firmware['data'][0][
'last_boot'] and ret_obj['data'][0]['active'] == True) or (
'last_boot' in ret_obj['data'][1] and ret_obj['data'][1]['last_boot'] !=
firmware['data'][1]['last_boot'] and ret_obj['data'][1]['active'] == True)):
logger.info("Server is responding and has a different boot time!")
return isamAppliance.create_return_object(warnings=warnings)
else:
time.sleep(check_freq)
sec += check_freq
logger.debug(
"Server is not responding yet. Waited for {0} secs, next check in {1} secs.".format(sec,
check_freq))
if sec >= wait_time:
warnings.append(
"The FIPS restart not detected or completed, exiting... after {0} seconds".format(sec))
break
return isamAppliance.create_return_object(warnings=warnings)
def _check(isamAppliance, fipsEnabled, tlsv10Enabled, tlsv11Enabled):
obj = {'value': True, 'warnings': ""}
ret_obj = get(isamAppliance)
obj['warnings'] = ret_obj['warnings']
if ret_obj['data']['fipsEnabled'] != fipsEnabled:
logger.info("fipsEnabled change to {0}".format(fipsEnabled))
obj['value'] = False
return obj
if ret_obj['data']['tlsv10Enabled'] != tlsv10Enabled:
logger.info("TLS v1.0 change to {0}".format(tlsv10Enabled))
obj['value'] = False
return obj
if ret_obj['data']['tlsv11Enabled'] != tlsv11Enabled:
logger.info("TLS v1.1 change to {0}".format(tlsv11Enabled))
obj['value'] = False
return obj
return obj
def compare(isamAppliance1, isamAppliance2):
ret_obj1 = get(isamAppliance1)
ret_obj2 = get(isamAppliance2)
return ibmsecurity.utilities.tools.json_compare(ret_obj1, ret_obj2, deleted_keys=[])
| 36.729167 | 120 | 0.592362 |
ba03b0c7e0b235ff3e8bc748446df2c28c5457c7 | 551 | sql | SQL | migrations/first.sql | andrewfromfly/rdo | 30dd303c83ef11e758b4b548042920a3653a3ba7 | [
"Unlicense"
] | 2 | 2020-03-20T17:22:40.000Z | 2020-04-14T02:26:04.000Z | migrations/first.sql | andrewarrow/feedback | ecdfe98eb179b7bcd6a531afd49da9ef42d6647f | [
"Unlicense"
] | null | null | null | migrations/first.sql | andrewarrow/feedback | ecdfe98eb179b7bcd6a531afd49da9ef42d6647f | [
"Unlicense"
] | null | null | null |
CREATE TABLE users (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
email varchar(255),
phrase varchar(255),
flavor varchar(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY unique_email (email)
) ENGINE InnoDB;
CREATE TABLE inboxes (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
sent_to varchar(255),
sent_from varchar(255),
subject varchar(255),
is_spam int,
spam_score float,
body text,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
KEY sent_key (sent_to)
) ENGINE InnoDB;
| 25.045455 | 51 | 0.713249 |
74c131707b54dc87bc91c433708564a5e067e24e | 5,628 | js | JavaScript | docs/build/p-m5afxxug.entry.js | christian-fleckenstein/LernwortTrainer | 417d4d5c09c040bb0f1fdbc6363d79c2f34b4f1f | [
"MIT"
] | null | null | null | docs/build/p-m5afxxug.entry.js | christian-fleckenstein/LernwortTrainer | 417d4d5c09c040bb0f1fdbc6363d79c2f34b4f1f | [
"MIT"
] | 1 | 2020-02-05T03:51:33.000Z | 2020-02-05T03:51:33.000Z | docs/build/p-m5afxxug.entry.js | christian-fleckenstein/LernwortTrainer | 417d4d5c09c040bb0f1fdbc6363d79c2f34b4f1f | [
"MIT"
] | null | null | null | import{r as t,h as i}from"./p-6da8d263.js";const e=class{constructor(i){t(this,i),this.zielWert=3,this.toggle=0,this.wortListe=[],this.abfrageListe=[],this.eingabeDavor="",this.loesungAnzeigen=!1,this.vorherigesloesungAnzeigen=!1,this.synth=window.speechSynthesis,this.voices=[],this.currentVoice=0}abfrageListeNeuAufbauen(){var t=this.zielWert;this.wortListe.map(i=>{i.richtig<t?(t=i.richtig,this.abfrageListe=[],this.abfrageListe.push(i)):i.richtig==t&&this.zielWert>i.richtig&&this.abfrageListe.push(i)});for(var i,e=this.abfrageListe.length;e>0;){i=Math.floor(Math.random()*e);var s=this.abfrageListe[e-=1];this.abfrageListe[e]=this.abfrageListe[i],this.abfrageListe[i]=s}}vorlesen(t,i){var e;if(0==this.voices.length)for(this.voices=this.synth.getVoices(),e=0;e<this.voices.length;e++)"de-DE"!=this.voices[e].lang&&(this.voices[e]=this.voices[this.voices.length-1],this.voices.pop(),e--);0==this.voices.length&&alert("Dieser Webbrowser kann nicht in Deutsch vorlesen - bitte einen anderen verwenden!"),i&&(this.currentVoice+=1,this.currentVoice>=this.voices.length&&(this.currentVoice=0));var s=new SpeechSynthesisUtterance(t);s.voice=this.voices[this.currentVoice],s.pitch=1,s.rate=1,this.synth.speak(s)}zielwertGeaendert(t){this.zielWert=t.target.value}woertListeGeaendert(t){this.eingabeWortliste=t.target.value}woerterUebernehmen(t){if(t.preventDefault(),void 0===this.eingabeWortliste)return-1;var i=this.eingabeWortliste.split("\n");this.wortListe=[];for(const[n,r]of i.entries()){var e=r.trim();if(-1!=e.indexOf('"')&&e.indexOf('"')+2<e.lastIndexOf('"'))e=e.substring(e.indexOf('"')+1,e.lastIndexOf('"'));else{var s=0;r.split(" ").forEach(t=>{t.length>s&&(s=t.length,e=t)})}var h={wort:r.trim(),richtig:0,index:n,antwort:e};r.trim().length>1&&this.wortListe.push(h)}this.abfrageListeNeuAufbauen(),this.vorlesen(this.abfrageListe[0].wort,!1)}eingabeAbgeben(t){t.preventDefault(),this.abfrageListe.length>0&&this.vorlesen(this.abfrageListe[0].wort,!1),""==this.eingabeDavor||this.eingabeDavor!=this.eingabeJetzt?this.eingabeDavor=this.eingabeJetzt:(this.loesungAnzeigen=!0,this.abfrageListe[0].richtig=0)}eingabeEingeben(t){return this.eingabeJetzt=t.target.value,this.loesungAnzeigen=!1,this.vorherigesloesungAnzeigen=!1,this.abfrageListe[0].antwort==this.eingabeJetzt&&(this.vorlesen("richtig!",!1),this.eingabeDavor=this.eingabeJetzt,this.eingabeJetzt="",this.abfrageListe[0].richtig++,this.abfrageListe.shift(),this.vorherigesloesungAnzeigen=!0,0==this.abfrageListe.length&&this.abfrageListeNeuAufbauen(),this.abfrageListe.length>0&&this.vorlesen(this.abfrageListe[0].wort,!1)),-1}render(){return this.toggle=1-this.toggle,0==this.wortListe.length?i("div",{class:"app-home"},i("header",null,i("h1",null,"Lernwort Quiz"),i("button",{onClick:()=>this.vorlesen("Hallo, verstehst Du mich gut?",!0)},"Stimme wechseln!")),i("p",null,"Bitte hier eine die abzufragenden Wörter eingeben.",i("br",null),"Werden mehrere Wörter pro Zeile eingegeben, so wird alles vorgelesen, aber nicht so genau geprüft.",i("br",null),"D.h. es reicht, das längste Wort richtig einzugeben."),i("datalist",{id:"1bis5"},i("option",{value:"1"}),i("option",{value:"2"}),i("option",{value:"3"}),i("option",{value:"4"}),i("option",{value:"5"})),i("form",{onSubmit:t=>this.woerterUebernehmen(t)},i("label",null,"Benötigte richtige Antworten:",i("input",{type:"number",width:1,min:1,max:5,value:this.zielWert,list:"1bis5",size:1,onInput:t=>this.zielwertGeaendert(t)})),i("br",null),i("textarea",{onInput:t=>this.woertListeGeaendert(t),cols:30,rows:10,minlength:5+this.toggle,spellcheck:!0,autoFocus:!0}),i("br",null),i("input",{type:"Submit",value:"Übernehmen"}))):this.abfrageListe.length>0?i("div",{class:"app-home"},i("header",null,i("h1",null,"Lernwort Quiz"),i("button",{onClick:()=>this.vorlesen(this.abfrageListe[0].wort,!0)},"Stimme wechseln!")),i("p",null,i("div",null,i("form",{onSubmit:t=>this.eingabeAbgeben(t)},i("p",null,"Antwort:",i("input",{type:"text",width:20,value:this.eingabeJetzt,autoFocus:!0,minLength:0*this.toggle,onInput:t=>this.eingabeEingeben(t)}),this.loesungAnzeigen||this.vorherigesloesungAnzeigen?this.loesungAnzeigen?this.abfrageListe[0].antwort:""+this.vorherigesloesungAnzeigen?this.eingabeDavor:"":""))))):(this.vorlesen("Du hast alle Lernwörter "+this.zielWert+" mal richtig gehabt. Super!",!1),i("div",{class:"app-home"},i("header",null,i("h1",null,"Lernwort Quiz")),i("div",null,i("p",{class:"richtig"},"Geschafft!"))))}static get style(){return".app-home{padding:10px}button,input{background:#3737b8}button,input,textarea{color:#fff;margin:8px;border:none;font-size:13px;font-weight:700;padding:16px 5px;border-radius:2px;-webkit-box-shadow:0 8px 16px rgba(0,0,0,.1),0 3px 6px rgba(0,0,0,.08);box-shadow:0 8px 16px rgba(0,0,0,.1),0 3px 6px rgba(0,0,0,.08);outline:0;letter-spacing:.04em;-webkit-transition:all .15s ease;transition:all .15s ease;cursor:pointer}textarea{background:#ffc}button:hover,input:focus{-webkit-box-shadow:0 3px 6px rgba(0,0,0,.1),0 1px 3px rgba(0,0,0,.1);box-shadow:0 3px 6px rgba(0,0,0,.1),0 1px 3px rgba(0,0,0,.1);-webkit-transform:translateY(1px);transform:translateY(1px)}header{background:#5851ff;color:#fff}.richtig,header{height:56px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-webkit-box-shadow:0 2px 5px 0 rgba(0,0,0,.26);box-shadow:0 2px 5px 0 rgba(0,0,0,.26)}.richtig{background:#ff2;color:#000}h1{color:#fff}h1,p{font-size:1.7rem;font-weight:500;padding:0 12px}p{color:#000}label,textarea{padding:16 12px}input,label,textarea{font-size:1.7rem;font-weight:500;color:#000}input{background:#ffa;padding:16 px;border:none}"}};export{e as app_home}; | 5,628 | 5,628 | 0.746624 |
c62c59722e177b9f46cc044c639a7d8328bba139 | 189 | rb | Ruby | app/jobs/term_stat_update_job.rb | EOL/publishing | f0076291521a1b3dbeba2d565b2bbb653f504028 | [
"MIT"
] | 21 | 2016-10-05T03:52:57.000Z | 2021-09-09T14:38:45.000Z | app/jobs/term_stat_update_job.rb | EOL/publishing | f0076291521a1b3dbeba2d565b2bbb653f504028 | [
"MIT"
] | 61 | 2016-12-22T18:02:25.000Z | 2021-09-09T14:16:42.000Z | app/jobs/term_stat_update_job.rb | EOL/publishing | f0076291521a1b3dbeba2d565b2bbb653f504028 | [
"MIT"
] | 5 | 2018-03-06T18:34:34.000Z | 2019-09-02T20:00:32.000Z | class TermStatUpdateJob < ApplicationJob
def perform
Rails.logger.info("START TermStatUpdater.run")
TermStatUpdater.run
Rails.logger.info("END TermStatUpdater.run")
end
end
| 23.625 | 50 | 0.761905 |
a1a1482378c71a2a2a06620d98f2d8b25e74906d | 79 | go | Go | models/usersettingapi.go | Romaindu35/PufferPanel | fd470944774fb251405ad5b9ff76eb1be4a03cd8 | [
"Apache-2.0"
] | 829 | 2015-01-01T11:20:52.000Z | 2022-03-31T14:05:33.000Z | models/usersettingapi.go | noyzys/PufferPanel | f3e27033af509a639621de262685fcc4a3c69202 | [
"Apache-2.0"
] | 690 | 2015-01-01T01:15:47.000Z | 2022-03-24T15:04:34.000Z | models/usersettingapi.go | noyzys/PufferPanel | f3e27033af509a639621de262685fcc4a3c69202 | [
"Apache-2.0"
] | 301 | 2015-01-03T07:42:02.000Z | 2022-03-26T22:12:44.000Z | package models
type ChangeUserSetting struct {
Value string `json:"value"`
}
| 13.166667 | 31 | 0.759494 |
b772f9360a770d0262c7f22d349b3bd48343ad40 | 384 | sql | SQL | bemyndigelsesservice/src/main/resources/db/manual/metadata_update_ajourfoering_indlaeggelse_rollback.sql | trifork/bemyndigelsesregister | 8d2b6e1981245da04ab68ae4b294017d83c2f288 | [
"MIT"
] | null | null | null | bemyndigelsesservice/src/main/resources/db/manual/metadata_update_ajourfoering_indlaeggelse_rollback.sql | trifork/bemyndigelsesregister | 8d2b6e1981245da04ab68ae4b294017d83c2f288 | [
"MIT"
] | null | null | null | bemyndigelsesservice/src/main/resources/db/manual/metadata_update_ajourfoering_indlaeggelse_rollback.sql | trifork/bemyndigelsesregister | 8d2b6e1981245da04ab68ae4b294017d83c2f288 | [
"MIT"
] | null | null | null | UPDATE `bemyndigelse`.`rettighed` SET beskrivelse = 'Suspender/frigiv medicinkort' where kode = 'Suspendering';
UPDATE `bemyndigelse`.`rettighed` SET beskrivelse = 'Sæt markering for medicinafstemning' where kode = 'Afstemning';
UPDATE `bemyndigelse`.`rettighed` SET beskrivelse = 'Opretning tilknytning til en enhed (F.eks. tilknytning til hjemmepleje)' where kode = 'Tilknytning';
| 76.8 | 153 | 0.78125 |
10f8b1ccffda51eae61ac786487bbd04d6547580 | 9,367 | kt | Kotlin | ui/src/main/java/ru/tinkoff/acquiring/sdk/ui/activities/ThreeDsActivity.kt | safchemist/AcquiringSdkAndroid | 5a678c88d43bf120edb3444f159258b182189e77 | [
"Apache-2.0"
] | null | null | null | ui/src/main/java/ru/tinkoff/acquiring/sdk/ui/activities/ThreeDsActivity.kt | safchemist/AcquiringSdkAndroid | 5a678c88d43bf120edb3444f159258b182189e77 | [
"Apache-2.0"
] | null | null | null | ui/src/main/java/ru/tinkoff/acquiring/sdk/ui/activities/ThreeDsActivity.kt | safchemist/AcquiringSdkAndroid | 5a678c88d43bf120edb3444f159258b182189e77 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright © 2020 Tinkoff Bank
*
* 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 ru.tinkoff.acquiring.sdk.ui.activities
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.Point
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.lifecycle.Observer
import org.json.JSONObject
import ru.tinkoff.acquiring.sdk.R
import ru.tinkoff.acquiring.sdk.exceptions.AcquiringSdkException
import ru.tinkoff.acquiring.sdk.models.*
import ru.tinkoff.acquiring.sdk.models.ScreenState
import ru.tinkoff.acquiring.sdk.models.options.screen.BaseAcquiringOptions
import ru.tinkoff.acquiring.sdk.models.result.AsdkResult
import ru.tinkoff.acquiring.sdk.network.AcquiringApi
import ru.tinkoff.acquiring.sdk.network.AcquiringApi.COMPLETE_3DS_METHOD_V2
import ru.tinkoff.acquiring.sdk.network.AcquiringApi.SUBMIT_3DS_AUTHORIZATION
import ru.tinkoff.acquiring.sdk.network.AcquiringApi.SUBMIT_3DS_AUTHORIZATION_V2
import ru.tinkoff.acquiring.sdk.responses.Check3dsVersionResponse
import ru.tinkoff.acquiring.sdk.utils.Base64
import ru.tinkoff.acquiring.sdk.utils.getTimeZoneOffsetInMinutes
import ru.tinkoff.acquiring.sdk.viewmodel.*
import java.lang.IllegalStateException
import java.net.URLEncoder
import java.util.*
internal class ThreeDsActivity : BaseAcquiringActivity() {
private lateinit var wvThreeDs: WebView
private lateinit var viewModel: ThreeDsViewModel
private lateinit var data: ThreeDsData
private var termUrl: String? = null
companion object {
const val RESULT_DATA = "result_data"
const val ERROR_DATA = "result_error"
const val RESULT_ERROR = 564
const val THREE_DS_DATA = "three_ds_data"
private const val OPTIONS = "options"
private const val THREE_DS_CALLED_FLAG = "Y"
private const val THREE_DS_NOT_CALLED_FLAG = "N"
private const val WINDOW_SIZE_CODE = "05"
private const val MESSAGE_TYPE = "CReq"
private val TERM_URL = "${AcquiringApi.getUrl(SUBMIT_3DS_AUTHORIZATION)}/$SUBMIT_3DS_AUTHORIZATION"
private val TERM_URL_V2 = "${AcquiringApi.getUrl(SUBMIT_3DS_AUTHORIZATION_V2)}/$SUBMIT_3DS_AUTHORIZATION_V2"
private val NOTIFICATION_URL = "${AcquiringApi.getUrl(COMPLETE_3DS_METHOD_V2)}/$COMPLETE_3DS_METHOD_V2"
private val cancelActions = arrayOf("cancel.do", "cancel=true")
fun createIntent(context: Context, options: BaseAcquiringOptions, data: ThreeDsData): Intent {
val intent = Intent(context, ThreeDsActivity::class.java)
intent.putExtra(THREE_DS_DATA, data)
intent.putExtra(OPTIONS, options)
return intent
}
fun collectData(context: Context, response: Check3dsVersionResponse?): MutableMap<String, String> {
var threeDSCompInd = THREE_DS_NOT_CALLED_FLAG
if (response != null) {
val hiddenWebView = WebView(context)
val threeDsMethodData = JSONObject().apply {
put("threeDSMethodNotificationURL", NOTIFICATION_URL)
put("threeDSServerTransID", response.serverTransId)
}
val dataBase64 = Base64.encodeToString(threeDsMethodData.toString().toByteArray(), Base64.DEFAULT).trim()
val params = "threeDSMethodData=${URLEncoder.encode(dataBase64, "UTF-8")}"
hiddenWebView.postUrl(response.threeDsMethodUrl, params.toByteArray())
threeDSCompInd = THREE_DS_CALLED_FLAG
}
val display = (context.getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay
val point = Point()
display.getSize(point)
return mutableMapOf<String, String>().apply {
put("threeDSCompInd", threeDSCompInd)
put("language", Locale.getDefault().toString().replace("_", "-"))
put("timezone", getTimeZoneOffsetInMinutes())
put("screen_height", "${point.y}")
put("screen_width", "${point.x}")
put("cresCallbackUrl", TERM_URL_V2)
}
}
}
@SuppressLint("SetJavaScriptEnabled")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.acq_activity_3ds)
wvThreeDs = findViewById(R.id.acq_3ds_wv)
wvThreeDs.run {
visibility = View.GONE
webViewClient = ThreeDsWebViewClient()
settings.domStorageEnabled = true
settings.javaScriptEnabled = true
settings.javaScriptCanOpenWindowsAutomatically = true
}
progressBar = findViewById(R.id.acq_progressbar)
content = wvThreeDs
data = intent.getSerializableExtra(THREE_DS_DATA) as ThreeDsData
viewModel = provideViewModel(ThreeDsViewModel::class.java) as ThreeDsViewModel
observeLiveData()
start3Ds()
}
override fun setSuccessResult(result: AsdkResult) {
val intent = Intent()
intent.putExtra(RESULT_DATA, result)
setResult(Activity.RESULT_OK, intent)
}
override fun setErrorResult(throwable: Throwable) {
val intent = Intent()
intent.putExtra(ERROR_DATA, throwable)
setResult(RESULT_ERROR, intent)
}
override fun handleLoadState(loadState: LoadState) {
when (loadState) {
is LoadingState -> {
progressBar?.visibility = View.VISIBLE
content?.visibility = View.INVISIBLE
}
}
}
private fun observeLiveData() {
viewModel.run {
loadStateLiveData.observe(this@ThreeDsActivity, Observer { handleLoadState(it) })
screenStateLiveData.observe(this@ThreeDsActivity, Observer { handleScreenState(it) })
resultLiveData.observe(this@ThreeDsActivity, Observer { finishWithSuccess(it) })
}
}
private fun handleScreenState(screenState: ScreenState) {
when (screenState) {
is ErrorScreenState -> finishWithError(AcquiringSdkException(IllegalStateException(screenState.message)))
is FinishWithErrorScreenState -> finishWithError(screenState.error)
}
}
private fun start3Ds() {
val url = data.acsUrl
val params: String?
if (data.is3DsVersion2) {
termUrl = TERM_URL_V2
val base64Creq = prepareCreqParams()
params = "creq=${URLEncoder.encode(base64Creq, "UTF-8")}"
} else {
termUrl = TERM_URL
params = "PaReq=${URLEncoder.encode(data.paReq, "UTF-8")}" +
"&MD=${URLEncoder.encode(data.md, "UTF-8")}" +
"&TermUrl=${URLEncoder.encode(termUrl, "UTF-8")}"
}
wvThreeDs.postUrl(url, params.toByteArray())
}
private fun prepareCreqParams(): String {
val creqData = JSONObject().apply {
put("threeDSServerTransID", data.tdsServerTransId)
put("acsTransID", data.acsTransId)
put("messageVersion", data.version)
put("challengeWindowSize", WINDOW_SIZE_CODE)
put("messageType", MESSAGE_TYPE)
}
return Base64.encodeToString(creqData.toString().toByteArray(), Base64.DEFAULT).trim()
}
private fun requestState() {
if (data.isPayment) {
viewModel.requestPaymentState(data.paymentId)
} else if (data.isAttaching) {
viewModel.requestAddCardState(data.requestKey)
}
}
private inner class ThreeDsWebViewClient : WebViewClient() {
private var canceled = false
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
content?.visibility = View.INVISIBLE
progressBar?.visibility = View.VISIBLE
}
override fun onPageFinished(view: WebView, url: String) {
super.onPageFinished(view, url)
cancelActions.forEach {
if (url.contains(it)) {
canceled = true
(view.context as Activity).run {
setResult(Activity.RESULT_CANCELED)
finish()
}
}
}
if (termUrl == url) {
view.visibility = View.INVISIBLE
if (!canceled) {
requestState()
}
} else {
progressBar?.visibility = View.GONE
view.visibility = View.VISIBLE
}
}
}
} | 37.468 | 121 | 0.654852 |
e78f6bb0b846cc332e66a7fac265da7ba17efcef | 507 | js | JavaScript | plugin/attributesCount.js | phuu/flight-static-analysis | a89e6acaa14b7635a334dc9ebfff6445cea95cb2 | [
"MIT"
] | 3 | 2015-02-21T12:23:17.000Z | 2015-04-26T13:56:34.000Z | plugin/attributesCount.js | phuu/flight-static-analysis | a89e6acaa14b7635a334dc9ebfff6445cea95cb2 | [
"MIT"
] | null | null | null | plugin/attributesCount.js | phuu/flight-static-analysis | a89e6acaa14b7635a334dc9ebfff6445cea95cb2 | [
"MIT"
] | null | null | null | /**
* Counting New Attributes Usage
*/
var u = require('../plugin-util');
module.exports = function (file, node, data, argv) {
if (u.isCallTo(node, 'this', 'attributes')) {
var attributes = data.for('attributes');
attributes.for('summary').inc('count');
if (argv.instances) {
var instances = attributes.get('instances') || [];
instances.push({
name: 'attributes',
loc: node.loc
});
attributes.set('instances', instances);
}
}
}; | 26.684211 | 58 | 0.568047 |
6049fb9928ee15555928833d25111284eb369369 | 22 | html | HTML | google/index.html | clstokes/instance-metadata-examples | c837237843ac6de4573fb42d1347039fec54550b | [
"Apache-2.0"
] | 22 | 2016-08-08T09:54:46.000Z | 2017-10-24T04:40:09.000Z | google/index.html | clstokes/instance-metadata-examples | c837237843ac6de4573fb42d1347039fec54550b | [
"Apache-2.0"
] | 4 | 2016-08-09T05:20:06.000Z | 2020-02-18T18:54:22.000Z | google/index.html | clstokes/instance-metadata-examples | c837237843ac6de4573fb42d1347039fec54550b | [
"Apache-2.0"
] | 3 | 2016-08-08T13:56:01.000Z | 2021-08-09T05:14:35.000Z | 0.1/
computeMetadata/
| 7.333333 | 16 | 0.772727 |
f024f2d1468cd63a89d1e5336dc2508a4542b04f | 1,476 | py | Python | Stack/10-stack-special-design-and-implement.py | mahmutcankurt/DataStructures_Python | bfb81e3530b535c4e48c07548dc4a4f9a648bab2 | [
"MIT"
] | 1 | 2022-01-25T22:17:55.000Z | 2022-01-25T22:17:55.000Z | Stack/10-stack-special-design-and-implement.py | mahmutcankurt/DataStructures_Python | bfb81e3530b535c4e48c07548dc4a4f9a648bab2 | [
"MIT"
] | null | null | null | Stack/10-stack-special-design-and-implement.py | mahmutcankurt/DataStructures_Python | bfb81e3530b535c4e48c07548dc4a4f9a648bab2 | [
"MIT"
] | null | null | null | class Stack:
def __init__(self):
self.array = []
self.top = -1
self.max = 100
def isEmpty(self):
if(self.top == -1):
return True
else:
return False
def isFull(self):
if(self.top == self.max -1):
return True
else:
return False
def push(self, data):
if(self.isFull()):
print("Stack Overflow")
return
else:
self.top += 1
self.array.append(data)
def pop(self):
if(self.isEmpty()):
print("Stack Underflow")
return
else:
self.top -= 1
return(self.array.pop())
class SpecialStack(Stack):
def __init__(self):
super().__init__()
self.Min = Stack()
def push(self, x):
if(self.isEmpty):
super().push(x)
self.Min.push(x)
else:
super().push(x)
y = self.Min.pop()
self.Min.push(y)
if(x <= y):
self.Min.push(x)
else:
self.Min.push(y)
def pop(self):
x = super().pop()
self.Min.pop()
return x
def getMin(self):
x = self.Min.pop()
self.Min.push(x)
return x
if __name__ == "__main__":
s = SpecialStack()
s.push(10)
s.push(20)
s.push(30)
print(s.getMin())
s.push(5)
print(s.getMin()) | 20.219178 | 36 | 0.443767 |
5c67a13c25c05a800c9dc9a5a6d454d4ead9cd53 | 3,385 | h | C | hns_data.h | handshake-org/libhns | 5cc63093ac4832bcdf9bcb1d46f331c0746a93c1 | [
"MIT"
] | 18 | 2018-08-02T16:58:49.000Z | 2022-03-05T22:34:51.000Z | hns_data.h | jilky/libhns | 5cc63093ac4832bcdf9bcb1d46f331c0746a93c1 | [
"MIT"
] | 2 | 2018-10-04T23:09:50.000Z | 2020-06-26T17:20:37.000Z | hns_data.h | jilky/libhns | 5cc63093ac4832bcdf9bcb1d46f331c0746a93c1 | [
"MIT"
] | 4 | 2019-09-22T10:16:46.000Z | 2022-03-05T22:34:51.000Z |
/* Copyright (C) 2009-2013 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
typedef enum {
HNS_DATATYPE_UNKNOWN = 1, /* unknown data type - introduced in 1.7.0 */
HNS_DATATYPE_SRV_REPLY, /* struct hns_srv_reply - introduced in 1.7.0 */
HNS_DATATYPE_TXT_REPLY, /* struct hns_txt_reply - introduced in 1.7.0 */
HNS_DATATYPE_TXT_EXT, /* struct hns_txt_ext - introduced in 1.11.0 */
HNS_DATATYPE_ADDR_NODE, /* struct hns_addr_node - introduced in 1.7.1 */
HNS_DATATYPE_MX_REPLY, /* struct hns_mx_reply - introduced in 1.7.2 */
HNS_DATATYPE_NAPTR_REPLY, /* struct hns_naptr_reply - introduced in 1.7.6 */
HNS_DATATYPE_SOA_REPLY, /* struct hns_soa_reply - introduced in 1.9.0 */
HNS_DATATYPE_SSHFP_REPLY, /* struct hns_sshfp_reply */
HNS_DATATYPE_DANE_REPLY, /* struct hns_dane_reply */
HNS_DATATYPE_OPENPGPKEY_REPLY, /* struct hns_openpgpkey_reply */
#if 0
HNS_DATATYPE_ADDR6TTL, /* struct hns_addrttl */
HNS_DATATYPE_ADDRTTL, /* struct hns_addr6ttl */
HNS_DATATYPE_HOSTENT, /* struct hostent */
HNS_DATATYPE_OPTIONS, /* struct hns_options */
#endif
HNS_DATATYPE_ADDR_PORT_NODE, /* struct hns_addr_port_node - introduced in 1.11.0 */
HNS_DATATYPE_LAST /* not used - introduced in 1.7.0 */
} hns_datatype;
#define HNS_DATATYPE_MARK 0xbead
/*
* hns_data struct definition is internal to hns and shall not
* be exposed by the public API in order to allow future changes
* and extensions to it without breaking ABI. This will be used
* internally by hns as the container of multiple types of data
* dynamically allocated for which a reference will be returned
* to the calling application.
*
* hns API functions returning a pointer to hns internally
* allocated data will actually be returning an interior pointer
* into this hns_data struct.
*
* All this is 'invisible' to the calling application, the only
* requirement is that this kind of data must be free'ed by the
* calling application using hns_free_data() with the pointer
* it has received from a previous hns function call.
*/
struct hns_data {
hns_datatype type; /* Actual data type identifier. */
unsigned int mark; /* Private hns_data signature. */
union {
struct hns_txt_reply txt_reply;
struct hns_txt_ext txt_ext;
struct hns_srv_reply srv_reply;
struct hns_addr_node addr_node;
struct hns_addr_port_node addr_port_node;
struct hns_mx_reply mx_reply;
struct hns_naptr_reply naptr_reply;
struct hns_soa_reply soa_reply;
struct hns_sshfp_reply sshfp_reply;
struct hns_dane_reply dane_reply;
struct hns_openpgpkey_reply openpgpkey_reply;
} data;
};
void *hns_malloc_data(hns_datatype type);
| 42.848101 | 85 | 0.731758 |
4751be4c1616132b2718fc1e706dbc4399c3b26a | 510 | asm | Assembly | libsrc/_DEVELOPMENT/adt/p_forward_list_alt/c/sccz80/p_forward_list_alt_push_front.asm | jpoikela/z88dk | 7108b2d7e3a98a77de99b30c9a7c9199da9c75cb | [
"ClArtistic"
] | 640 | 2017-01-14T23:33:45.000Z | 2022-03-30T11:28:42.000Z | libsrc/_DEVELOPMENT/adt/p_forward_list_alt/c/sccz80/p_forward_list_alt_push_front.asm | jpoikela/z88dk | 7108b2d7e3a98a77de99b30c9a7c9199da9c75cb | [
"ClArtistic"
] | 1,600 | 2017-01-15T16:12:02.000Z | 2022-03-31T12:11:12.000Z | libsrc/_DEVELOPMENT/adt/p_forward_list_alt/c/sccz80/p_forward_list_alt_push_front.asm | jpoikela/z88dk | 7108b2d7e3a98a77de99b30c9a7c9199da9c75cb | [
"ClArtistic"
] | 215 | 2017-01-17T10:43:03.000Z | 2022-03-23T17:25:02.000Z |
; void p_forward_list_alt_push_front(p_forward_list_alt_t *list, void *item)
SECTION code_clib
SECTION code_adt_p_forward_list_alt
PUBLIC p_forward_list_alt_push_front
EXTERN asm_p_forward_list_alt_push_front
p_forward_list_alt_push_front:
pop af
pop de
pop bc
push bc
push de
push af
jp asm_p_forward_list_alt_push_front
; SDCC bridge for Classic
IF __CLASSIC
PUBLIC _p_forward_list_alt_push_front
defc _p_forward_list_alt_push_front = p_forward_list_alt_push_front
ENDIF
| 17.586207 | 76 | 0.82549 |
8eb23d312e8fd6d27c4535a62b69f37e29c74c63 | 1,285 | rb | Ruby | lib/user.rb | darkhelmet/TinderizerApp | ead515a946b2556bf21574f3a2d0582696e4ad91 | [
"Apache-2.0"
] | 2 | 2015-11-05T08:55:45.000Z | 2016-03-01T22:14:51.000Z | lib/user.rb | darkhelmet/TinderizerApp | ead515a946b2556bf21574f3a2d0582696e4ad91 | [
"Apache-2.0"
] | null | null | null | lib/user.rb | darkhelmet/TinderizerApp | ead515a946b2556bf21574f3a2d0582696e4ad91 | [
"Apache-2.0"
] | null | null | null | require 'redis'
require 'mail'
require 'json'
require 'postmark'
module User
Config = JSON.parse(File.read('config/config.json'))
Lua = <<-LUA
local value = redis('get', KEYS[1])
if value ~= nil then return {err='limited'} end
redis('set', KEYS[1], 'locked')
redis('expire', KEYS[1], tonumber(ARGV[1]))
return {ok='locked'}
LUA
class << self
def mail(email, title, url, mobi)
m = Mail.new
m.delivery_method(Mail::Postmark, api_key: Config['postmark'])
m.from(Config['email']['from'])
m.to(email)
m.subject('convert')
m.body("Straight to your Kindle! #{title}: #{url}")
m.postmark_attachments = [File.open(mobi)]
m.deliver!
end
def notify(redis, key, message)
failed = false
redis.multi do
redis.set(key, message)
redis.expire(key, 30)
end
rescue SystemCallError => boom
unless failed
failed = true
retry
end
end
def limit(redis, email, time)
redis.eval(Lua, 1, Digest::SHA1.hexdigest(email), time)
rescue RuntimeError => limited
{
message: "Sorry, but there's a rate-limit, and you've hit it! Try again in a minute.",
limited: true
}.to_json
else
yield
end
end
end
| 24.245283 | 94 | 0.592996 |
c542d3a9de0d2db46c50db8ba8650e0ec9ab04a2 | 7,118 | sql | SQL | comuna11/agrupar_mzas_adys.sql | manureta/segmentacion | 74f67dbd0f84189d620e95a9ba777f3aa6f65f4b | [
"MIT"
] | 1 | 2019-06-05T12:21:43.000Z | 2019-06-05T12:21:43.000Z | comuna11/agrupar_mzas_adys.sql | manureta/segmentacion | 74f67dbd0f84189d620e95a9ba777f3aa6f65f4b | [
"MIT"
] | 9 | 2019-06-05T18:20:10.000Z | 2019-11-20T20:04:49.000Z | comuna11/agrupar_mzas_adys.sql | manureta/segmentacion | 74f67dbd0f84189d620e95a9ba777f3aa6f65f4b | [
"MIT"
] | 3 | 2016-12-06T21:07:41.000Z | 2019-06-04T20:59:44.000Z | /*
titulo: agrupar_mzas_adys.sql
descripción
genera una tabla o vista con grupos de mzas adys
fecha: 2019-05-22 Mi
autor: -h
*/
create view adyacencias_orden_1 as
select frac, radio, mza, vivs_mza,
mza || array_agg(distinct mza_ady order by mza_ady) as ady_ord_1
from adyacencias_mzas
natural join conteos_manzanas
group by frac, radio, mza, vivs_mza
having vivs_mza < 30
order by frac, radio, mza
;
/*
select * from adyacencias_orden_1
order by frac, radio, mza
limit 10;
frac | radio | mza | vivs_mza | ady_ord_1
------+-------+-----+----------+---------------------------
1 | 1 | 11 | 15 | {11,8}
1 | 2 | 12 | 1 | {12,13}
1 | 2 | 14 | 19 | {14,13,15,17}
1 | 2 | 33 | 8 | {33,31,34}
1 | 10 | 74 | 21 | {74,73,84}
1 | 11 | 80 | 12 | {80,81,91}
1 | 11 | 86 | 1 | {86,87,88}
1 | 12 | 62 | 21 | {62,63,65}
1 | 12 | 64 | 1 | {64,65,78}
1 | 12 | 65 | 2 | {65,62,63,64,67,68,76,77}
*/
create or replace function costo(vivs bigint) returns float as $$
select abs($1 - 40)::float
$$
language sql
;
drop view desigualdad_triangular;
create view desigualdad_triangular as
select distinct l.frac, l.radio,
array[m.mza] as mza, m.vivs_mza, costo(m.vivs_mza) as costo_mza,
array[a.mza] as ady, a.vivs_mza as vivs_ady, costo(a.vivs_mza) as costo_ady,
array[m.mza, a.mza] as par, m.vivs_mza + a.vivs_mza as vivs_par, costo(m.vivs_mza + a.vivs_mza) as costo_par
from adyacencias_mzas l
natural join conteos_manzanas m
join conteos_manzanas a
on m.frac = a.frac and m.radio=a.radio and l.mza_ady = a.mza
where m.vivs_mza < 35 and a.vivs_mza < 35
and costo(m.vivs_mza + a.vivs_mza) < costo(m.vivs_mza) + costo(a.vivs_mza)
order by l.frac, l.radio, array[m.mza], array[a.mza]
;
/*
select * from desigualdad_triangular limit 10;
frac | radio | mza | vivs_mza | costo_mza | ady | vivs_ady | costo_ady | par | vivs_par | costo_par
------+-------+------+----------+-----------+------+----------+-----------+---------+----------+-----------
1 | 1 | {8} | 30 | 10 | {11} | 15 | 25 | {8,11} | 45 | 5
1 | 1 | {11} | 15 | 25 | {8} | 30 | 10 | {11,8} | 45 | 5
1 | 2 | {12} | 1 | 39 | {13} | 33 | 7 | {12,13} | 34 | 6
1 | 2 | {13} | 33 | 7 | {12} | 1 | 39 | {13,12} | 34 | 6
1 | 2 | {13} | 33 | 7 | {14} | 19 | 21 | {13,14} | 52 | 12
1 | 2 | {14} | 19 | 21 | {13} | 33 | 7 | {14,13} | 52 | 12
1 | 12 | {62} | 21 | 19 | {65} | 2 | 38 | {62,65} | 23 | 17
1 | 12 | {64} | 1 | 39 | {65} | 2 | 38 | {64,65} | 3 | 37
1 | 12 | {64} | 1 | 39 | {78} | 5 | 35 | {64,78} | 6 | 34
1 | 12 | {65} | 2 | 38 | {62} | 21 | 19 | {65,62} | 23 | 17
(10 rows)
*/
drop view conjunto_de_mzas;
create view conjunto_de_mzas as
select frac, radio, min(par) as par,
vivs_par as vivs,
costo_par as costo
from desigualdad_triangular
group by frac, radio, vivs_par, costo_par
order by frac, radio
;
/*
select * from conjunto_de_mzas limit 10;
frac | radio | min | vivs | costo
------+-------+---------+------+-------
1 | 1 | {8,11} | 45 | 5
1 | 2 | {12,13} | 34 | 6
1 | 2 | {13,14} | 52 | 12
1 | 12 | {64,65} | 3 | 37
1 | 12 | {64,78} | 6 | 34
1 | 12 | {65,68} | 20 | 20
1 | 12 | {62,65} | 23 | 17
2 | 1 | {7,8} | 33 | 7
2 | 7 | {61,61} | 38 | 2
2 | 9 | {87,96} | 31 | 9
(10 rows)
*/
create view conjuntos_a_iterar as
select frac, radio, par
from conjunto_de_mzas
where (frac, radio) in (
select frac, radio
from conjunto_de_mzas
group by frac, radio
having count(*) > 1)
;
/*
select * from conjuntos_a_iterar limit 10;
frac | radio | par
------+-------+-----------
1 | 2 | {12,13}
1 | 2 | {13,14}
1 | 12 | {64,65}
1 | 12 | {64,78}
1 | 12 | {65,68}
1 | 12 | {62,65}
2 | 9 | {87,96}
2 | 9 | {87,88}
2 | 11 | {108,109}
2 | 11 | {109,111}
(10 rows)
*/
select frac, radio, count(*)
from conjuntos_a_iterar
group by frac, radio
having count(*) > 1
;
/*
frac | radio | count
------+-------+-------
1 | 2 | 2
1 | 12 | 4
2 | 9 | 2
2 | 11 | 3
4 | 3 | 4
4 | 4 | 2
4 | 5 | 3
4 | 9 | 5
5 | 8 | 5
5 | 10 | 2
11 | 1 | 2
(11 rows)
*/
select count(*) as radios_de_muestra_comuna11
from (select distinct frac, radio from adyacencias_mzas) as radios
;
/*
radios_de_muestra_comuna11
----------------------------
223
se necesita iterar en 11 de 223 radios
para esta muestra representa el 5%
*/
/*
select frac, radio, count(*)
from conjunto_de_mzas
group by frac, radio
;
frac | radio | count
------+-------+-------
1 | 1 | 1
1 | 2 | 2
1 | 12 | 4
2 | 1 | 1
2 | 7 | 1
2 | 9 | 2
2 | 10 | 1
2 | 11 | 3
4 | 3 | 4
4 | 4 | 2
4 | 5 | 3
4 | 6 | 1
4 | 8 | 1
4 | 9 | 5
5 | 4 | 1
5 | 8 | 5
5 | 9 | 1
5 | 10 | 2
10 | 10 | 1
11 | 1 | 2
(20 rows)
*/
------------------------------
-- setear segmento en listado comuna11
---------------------------------------
create view mzas_a_agrupar as
with radios_con_un_solo_par as (
select frac, radio
from conjunto_de_mzas
group by frac, radio
having count(*) = 1
),
pares as (
select frac, radio, unnest(par) as mza
from conjunto_de_mzas
where (frac, radio) in (select * from radios_con_un_solo_par)
)
select * from pares;
;
alter table comuna11 add column sgm_grp_mzas integer default Null;
update comuna11
set sgm_grp_mzas = 1
where (frac, radio, mza) in (
select frac, radio, mza from mzas_a_agrupar
)
;
/*
select frac, radio, mza, sgm_mza_grd, sgm_mza_eq, sgm_grp_mzas, sgm
from comuna11
order by frac, radio, mza
;
.
.
.
11 | 9 | 44 | | | | 3
11 | 9 | 47 | | | | 6
12 | 1 | 4 | 1 | 1 | | 3
12 | 1 | 5 | 4 | 3 | | 4
12 | 1 | 5 | 4 | 4 | | 4
.
.
.
TODO: revisar secuencia de corrida para generar sgm_mza_grd y sgm_mza_eq
no deberían dar resultados null, y de donde sale sgm?
*/
update comuna11
set sgm = 101 where sgm_grp_mzas is not Null
;
| 27.589147 | 113 | 0.445209 |
4379bf01e7ab20c82e823c6156654986ead3974f | 2,090 | go | Go | license/licpol/pdp.go | mariotoffia/gojwtlic | f7e36658a68a034b6bacb77d2f14ee1f9aa14b59 | [
"Apache-2.0"
] | null | null | null | license/licpol/pdp.go | mariotoffia/gojwtlic | f7e36658a68a034b6bacb77d2f14ee1f9aa14b59 | [
"Apache-2.0"
] | null | null | null | license/licpol/pdp.go | mariotoffia/gojwtlic | f7e36658a68a034b6bacb77d2f14ee1f9aa14b59 | [
"Apache-2.0"
] | null | null | null | package licpol
import (
"fmt"
"reflect"
"strconv"
)
// PDPMessage is a standar PDP message.
//
// .Example Invocation
// [source,json]
// ----
// {
// "type": "invoke", // <1>
// "method": ["path","to","method-name"], // <2>
// "sc": {
// "oidc": { // <3>
// "aud": "https://nordvestor.api.crossbreed.se",
// "iss": "https://iss.crossbreed.se",
// "sub": "[email protected]",
// "exp": 1927735782,
// "iat": 1612375782,
// "nbf": 1612375782,
// "jti": "fcd2174b-664a-11eb-afe1-1629c910062f",
// "client_id": "my-client-id",
// "scope": "oid::r::999 oid::rw::1234"
// }
// },
// "body": { // <4>
// "name": "my-param",
// "dir": "inbound"
// }
// }
// ----
// <1> About to invoke function
// <2> The action, i.e. path to method
// <3> The security context, in this case the _OpenID Connect_ token
// <4> Body do contain the function parameters marshalled to _JSON_
type PDPMessage struct {
Type string `json:"type"`
Method []string `json:"method"`
SecurityContext map[string]interface{} `json:"sc,omitempty"`
Body map[string]interface{} `json:"body,omitempty"`
}
// PDP is the Policy Decision Point implementation
type PDP struct {
}
func (pdp *PDP) Register(f interface{}) {
rf := reflect.TypeOf(f)
if rf.Kind() != reflect.Func {
panic("expects a function")
}
numIn := rf.NumIn() //Count inbound parameters
numOut := rf.NumOut() //Count outbounding parameters
fmt.Println("Method:", rf.String())
fmt.Println("Variadic:", rf.IsVariadic()) // Used (<type> ...) ?
fmt.Println("Package:", rf.PkgPath())
for i := 0; i < numIn; i++ {
inV := rf.In(i)
in_Kind := inV.Kind()
fmt.Println(inV)
fmt.Printf("\nParameter IN: "+strconv.Itoa(i)+"\nKind: %v\nName: %v\n-----------", in_Kind, inV.Name())
}
for o := 0; o < numOut; o++ {
returnV := rf.Out(0)
return_Kind := returnV.Kind()
fmt.Printf("\nParameter OUT: "+strconv.Itoa(o)+"\nKind: %v\nName: %v\n", return_Kind, returnV.Name())
}
}
| 25.802469 | 105 | 0.561244 |
a1a2300c1cce61195b9234156b446c0752339a3e | 920 | go | Go | main.go | afshin/sleuth-echo-client | 24e9fe0e34d657b02fda126f9861b2f8f6e520f4 | [
"MIT"
] | null | null | null | main.go | afshin/sleuth-echo-client | 24e9fe0e34d657b02fda126f9861b2f8f6e520f4 | [
"MIT"
] | null | null | null | main.go | afshin/sleuth-echo-client | 24e9fe0e34d657b02fda126f9861b2f8f6e520f4 | [
"MIT"
] | 1 | 2020-09-02T07:25:35.000Z | 2020-09-02T07:25:35.000Z | package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"time"
"github.com/ursiform/sleuth"
)
func main() {
service := "echo-service"
// In the real world, the Interface field of the sleuth.Config object
// should be set so that all services are on the same subnet.
config := &sleuth.Config{Interface: "en0", LogLevel: "debug"}
client, err := sleuth.New(config)
client.Timeout = time.Second * 5
if err != nil {
panic(err.Error())
}
defer client.Close()
client.WaitFor(service)
input := "This is the value I am inputting."
body := bytes.NewBuffer([]byte(input))
request, _ := http.NewRequest("POST", "sleuth://"+service+"/", body)
response, err := client.Do(request)
if err != nil {
print(err.(*sleuth.Error).Codes)
panic(err.Error())
}
output, _ := ioutil.ReadAll(response.Body)
if string(output) == input {
fmt.Println("It works.")
} else {
fmt.Println("It doesn't work.")
}
}
| 23 | 70 | 0.659783 |
0be80710e2e1cb0528efac3a214390ad4c82f2b5 | 559 | js | JavaScript | es6-features/15-js-modules/app.js | vitorjsls30/spotify-wrapper-player | 12f6a5bb03e577e25fb4e60712fa83ddfac80376 | [
"MIT"
] | null | null | null | es6-features/15-js-modules/app.js | vitorjsls30/spotify-wrapper-player | 12f6a5bb03e577e25fb4e60712fa83ddfac80376 | [
"MIT"
] | null | null | null | es6-features/15-js-modules/app.js | vitorjsls30/spotify-wrapper-player | 12f6a5bb03e577e25fb4e60712fa83ddfac80376 | [
"MIT"
] | null | null | null | // import method from library
// * loads all lib content
// as => alias for the given method (a new name for it)
import { union as gatherAll, uniq as exclusiveItems } from 'ramda';
import sum, { sub, multiply, div, PI } from './utils';
const arr1 = [1, 1, 1, 2, 2, 3, 4, 5, 6, 6];
const arr2 = [5, 6, 6, 6, 7, 7, 8, 9, 10, 1];
const arr3 = gatherAll(arr1, arr2);
const arr4 = exclusiveItems(arr1);
console.log(arr3);
console.log(arr4);
console.log(sum(3, 5));
console.log(sub(5, 3));
console.log(multiply(7, 2));
console.log(div(4, 2));
console.log(PI);
| 25.409091 | 67 | 0.644007 |
1271d813e97df08823fabe6f996d8dc8a2741893 | 2,300 | h | C | IntactMiddleware/MembershipManagerConnection.h | intact-software-systems/cpp-software-patterns | e463fc7eeba4946b365b5f0b2eecf3da0f4c895b | [
"MIT"
] | 1 | 2020-09-03T07:23:11.000Z | 2020-09-03T07:23:11.000Z | IntactMiddleware/MembershipManagerConnection.h | intact-software-systems/cpp-software-patterns | e463fc7eeba4946b365b5f0b2eecf3da0f4c895b | [
"MIT"
] | null | null | null | IntactMiddleware/MembershipManagerConnection.h | intact-software-systems/cpp-software-patterns | e463fc7eeba4946b365b5f0b2eecf3da0f4c895b | [
"MIT"
] | null | null | null | #ifndef IntactMiddleware_MembershipManagerConnection_h_IsIncluded
#define IntactMiddleware_MembershipManagerConnection_h_IsIncluded
#include"IntactMiddleware/IncludeExtLibs.h"
#include"IntactMiddleware/MembershipManagerBase.h"
#include"IntactMiddleware/Export.h"
namespace IntactMiddleware
{
// --------------------------------------------------------
// struct MembershipManagerConnectionConfig
// --------------------------------------------------------
struct MembershipManagerConnectionConfig
{
static int membershipManagerPort;
};
// --------------------------------------------------------
// class MembershipManagerConnection
// --------------------------------------------------------
/**
* Class MembershipManagerConnection logs in the component.
*/
class DLL_STATE MembershipManagerConnection : protected Thread
{
private:
MembershipManagerConnection(const HostInformation &info, InterfaceHandle handle, bool autorStart = true);
virtual ~MembershipManagerConnection();
public:
static MembershipManagerConnection *GetOrCreate(InterfaceHandle *membershipHandle = NULL);
public:
bool Login();
void Logout();
HostInformation GetHostInformation() const;
bool IsLoggedIn();
bool StopConnection(bool wait = true);
bool WaitConnected(bool wait = true);
void WaitForTermination() { Thread::wait(); }
private:
virtual void run();
bool login();
void logout();
private:
inline bool runThread() const { MutexLocker lock(&classMutex_); return runThread_; }
inline bool automaticLogin() const { MutexLocker lock(&classMutex_); return automaticLogin_; }
inline void lock() { classMutex_.lock(); }
inline void unlock() { classMutex_.unlock(); }
inline void wakeAll() { classCondition_.wakeAll(); }
inline bool lockedAndUnlockedWait(int64 ms)
{
lock();
bool wokenUp = classCondition_.wait(&classMutex_, ms);
unlock();
return wokenUp;
}
private:
MembershipManagerClient *membershipManagerProxy_;
HostInformation myHostInformation_;
InterfaceHandle membershipManagerHandle_;
bool isLoggedIn_;
bool automaticLogin_;
bool runThread_;
private:
mutable Mutex classMutex_;
WaitCondition classCondition_;
private:
static MembershipManagerConnection *membershipManagerConnection_;
};
} // namespace IntactMiddleware
#endif
| 26.436782 | 106 | 0.703043 |
cf6938aaefe4c86a359a2bf340ef28f94c665f6c | 1,451 | sql | SQL | assets/update_tabel/m_tindakan.sql | Dmenk123/odontogram | 87996281ade92ef6f46103813c14871282dcaf5f | [
"MIT"
] | 1 | 2022-01-28T11:31:56.000Z | 2022-01-28T11:31:56.000Z | assets/update_tabel/m_tindakan.sql | Dmenk123/odontogram | 87996281ade92ef6f46103813c14871282dcaf5f | [
"MIT"
] | null | null | null | assets/update_tabel/m_tindakan.sql | Dmenk123/odontogram | 87996281ade92ef6f46103813c14871282dcaf5f | [
"MIT"
] | null | null | null | /*
Navicat Premium Data Transfer
Source Server : sql local
Source Server Type : MySQL
Source Server Version : 100414
Source Host : localhost:3306
Source Schema : odontogram
Target Server Type : MySQL
Target Server Version : 100414
File Encoding : 65001
Date: 09/09/2020 15:09:35
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for m_tindakan
-- ----------------------------
DROP TABLE IF EXISTS `m_tindakan`;
CREATE TABLE `m_tindakan` (
`id_tindakan` int(32) NOT NULL AUTO_INCREMENT,
`kode_tindakan` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`nama_tindakan` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`harga` int(255) NULL DEFAULT NULL,
`created_at` datetime(0) NULL DEFAULT NULL,
`updated_at` datetime(0) NULL DEFAULT NULL,
`deleted_at` datetime(0) NULL DEFAULT NULL,
PRIMARY KEY (`id_tindakan`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of m_tindakan
-- ----------------------------
INSERT INTO `m_tindakan` VALUES (1, 'T001', 'Operasi', 100000, NULL, NULL, NULL);
INSERT INTO `m_tindakan` VALUES (2, 'T002', 'Penambalan Gigi Cuy', 50000, '2020-09-09 14:35:45', '2020-09-09 15:05:11', NULL);
SET FOREIGN_KEY_CHECKS = 1;
| 34.547619 | 126 | 0.661613 |
1fc6ca66cd41c7d3e05189bd6056fc0f8f33972b | 2,614 | html | HTML | public_goods_game/Test.html | chenyuyou/Behavior-template | ca3949a2765becd63992d2fbbd4f65ac1e5af8f0 | [
"MIT"
] | null | null | null | public_goods_game/Test.html | chenyuyou/Behavior-template | ca3949a2765becd63992d2fbbd4f65ac1e5af8f0 | [
"MIT"
] | null | null | null | public_goods_game/Test.html | chenyuyou/Behavior-template | ca3949a2765becd63992d2fbbd4f65ac1e5af8f0 | [
"MIT"
] | null | null | null | {{ extends "global/Page.html" }}
{{ block title }}问题测试{{ endblock }}
{{ block content }}
<script>
// 获取输入框内容
window.onload = function() {
var A_income_0 = document.getElementById("A_income_0");
var B_income_0 = document.getElementById("B_income_0");
var A_income_80 = document.getElementById("A_income_80");
var B_income_80 = document.getElementById("B_income_80");
// 获取提交按钮
var btn_submit = document.getElementById("btn_submit");
function check() {
var A_income_0_value = A_income_0.value;
var B_income_0_value = B_income_0.value;
var A_income_80_value = A_income_80.value;
var B_income_80_value = B_income_80.value;
// 必填项验证
if (""==A_income_0_value) {
alert("该输入项不能为空");
return false;
}
if (B_income_0_value == null || B_income_0_value=="") {
alert("该输入项不能为空");
return false;
}
if (A_income_80_value == null || A_income_80_value=="") {
alert("该输入项不能为空");
return false;
}
if (B_income_80_value == null || B_income_80_value =="") {
alert("该输入项不能为空");
return false;
}
if (A_income_0_value != 80 ) {
alert("第一个答案错误,请输入正确答案");
return false;
}
if (B_income_0_value != 80 ) {
alert("第二个答案错误,请输入正确答案");
return false;
}
if (A_income_80_value != 128) {
alert("第三个答案错误,请输入正确答案");
return false;
}
if (B_income_80_value != 128 ) {
alert("第四个答案错误,请输入正确答案");
return false;
}
// 错误信息清空
msg.innerHTML = "";
return true;
};
btn_submit.onclick = check;
}
</script>
<p>以下是一些练习,可帮助您了解决策情况。</p>
<form name="test" onsubmit="return validateForm()" method="post">
<ol>
<li>两个人都往公共池中存入0点,那么A的收入是:<input type="text" class="form-control-sm" id="A_income_0" placeholder="请输入正确答案"><span id="msg"></span>,B的收入是:<input type="text" class="form-control-sm" id="B_income_0"placeholder="请输入正确答案"><span id="msg"></span>。</li>
<li>两个人都往公共池中存了80点,那么A的收入是<input type="text" class="form-control-sm" id="A_income_80"placeholder="请输入正确答案"><span id="msg"></span>,B的收入是<input type="text" class="form-control-sm" id="B_income_80"placeholder="请输入正确答案"><span id="msg"></span>。</li>
</ol>
<input type="submit" class="btn btn-primary" value="验证答案" id="btn_submit">
</form>
{{ endblock }}
| 29.370787 | 252 | 0.561209 |
End of preview. Expand
in Dataset Viewer.
README.md exists but content is empty.
Use the Edit dataset card button to edit it.
- Downloads last month
- 35