content
stringlengths 4
1.04M
| lang
stringclasses 358
values | score
int64 0
5
| repo_name
stringlengths 5
114
| repo_path
stringlengths 4
229
| repo_licenses
sequencelengths 1
8
|
---|---|---|---|---|---|
"""Huawei LTE sensor tests."""
import pytest
from homeassistant.components.huawei_lte import sensor
from homeassistant.const import (
SIGNAL_STRENGTH_DECIBELS,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
)
@pytest.mark.parametrize(
("value", "expected"),
(
("-71 dBm", (-71, SIGNAL_STRENGTH_DECIBELS_MILLIWATT)),
("15dB", (15, SIGNAL_STRENGTH_DECIBELS)),
(">=-51dBm", (-51, SIGNAL_STRENGTH_DECIBELS_MILLIWATT)),
),
)
def test_format_default(value, expected):
"""Test that default formatter copes with expected values."""
assert sensor.format_default(value) == expected
| Python | 4 | tbarbette/core | tests/components/huawei_lte/test_sensor.py | [
"Apache-2.0"
] |
import System.IO (hGetContents, stdin)
import qualified Lexer as Lexer
import qualified Parser as Parser
import DerpInterface
import Data.Set
-- This `main` allows us to generate a compiler binary, see cabal file
main :: IO ()
main = do code <- (hGetContents stdin)
let res = toList $ Parser.parseFile $ Lexer.lex code
case res of
[] -> putStrLn "#f"
x -> showNL x
| Haskell | 4 | adlerliu/500lines | incomplete/parser-and-lexer/src/PowParse.hs | [
"CC-BY-3.0"
] |
<?php
$key = $this->getParam('key', '');
$required = $this->getParam('required', '');
$namespace = $this->getParam('namespace', '');
?>
<textarea type="text" name="<?php echo $this->escape($key); ?>" data-forms-pell data-forms-text-direction data-ls-bind="{{<?php echo $this->escape($namespace); ?>}}"<?php if($required): ?> required<?php endif; ?>></textarea> | HTML+PHP | 3 | nakshatrasinghh/appwrite | app/views/console/database/rules/markdown.phtml | [
"BSD-3-Clause"
] |
CREATE DATABASE IF NOT EXISTS myapp DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE myapp;
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE IF EXISTS categories;
CREATE TABLE categories (
id int(11) NOT NULL AUTO_INCREMENT,
title varchar(255) NOT NULL,
position int(11) NOT NULL,
image_url varchar(255) NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
DROP TABLE IF EXISTS products;
CREATE TABLE products (
id int(11) NOT NULL AUTO_INCREMENT,
category_id int,
title varchar(255) NOT NULL,
image_url varchar(255) NOT NULL,
price decimal(10,2) NOT NULL,
description text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id),
FOREIGN KEY (category_id) REFERENCES categories(id)
);
SET FOREIGN_KEY_CHECKS = 1; | SQL | 4 | NeatNerdPrime/iris | _examples/database/mysql/migration/db.sql | [
"BSD-3-Clause"
] |
//define classes, interfaces et al
def some() void
{
g()
}
d=s;
class MyClass<X>(-n String, -m String)
{
a =6;
f=6;
def add(toAdd X) void {
d()
}
def do(n int) void
{
this.a= n**5
}
p=4
ompa = def () int { return 5
}
ompa = def () int { return 5 }
l= 5
l=0 ; l=r()
class inner{
}
}
class Singleton
{
}
if(a> 5)
{
}
else
{}
while(false){
a=4; g=y
}
while(false){
a=4; g=y
}
mmop = { 1->2, 4
-> 5}
a = [1,2
,3 ]
with(logging)
{
log("");
}
zzz = new A.C(2,3);
bobby List<Integer> = new List<Integer>(1);
a = actor MyClass<String>(3); | Web Ontology Language | 2 | michaeldesu/Concurnas | tests/com/concurnas/compiler/ast/testClassesNwlinesetc.owl | [
"MIT"
] |
/home/spinalvm/hdl/riscv-compliance/work//REM.elf: file format elf32-littleriscv
Disassembly of section .text.init:
80000000 <_start>:
80000000: 00001117 auipc sp,0x1
80000004: 00010113 mv sp,sp
80000008: 00000913 li s2,0
8000000c: 00000893 li a7,0
80000010: 031968b3 rem a7,s2,a7
80000014: 01112023 sw a7,0(sp) # 80001000 <codasip_signature_start>
80000018: 00000a13 li s4,0
8000001c: 00100993 li s3,1
80000020: 033a69b3 rem s3,s4,s3
80000024: 01312223 sw s3,4(sp)
80000028: 00000b13 li s6,0
8000002c: fff00a93 li s5,-1
80000030: 035b6ab3 rem s5,s6,s5
80000034: 01512423 sw s5,8(sp)
80000038: 00000c13 li s8,0
8000003c: 80000bb7 lui s7,0x80000
80000040: fffb8b93 addi s7,s7,-1 # 7fffffff <_end+0xffffef2f>
80000044: 037c6bb3 rem s7,s8,s7
80000048: 01712623 sw s7,12(sp)
8000004c: 00000d13 li s10,0
80000050: 80000cb7 lui s9,0x80000
80000054: 039d6cb3 rem s9,s10,s9
80000058: 01912823 sw s9,16(sp)
8000005c: 00001117 auipc sp,0x1
80000060: fb810113 addi sp,sp,-72 # 80001014 <test_2_res>
80000064: 00100e13 li t3,1
80000068: 00000d93 li s11,0
8000006c: 03be6db3 rem s11,t3,s11
80000070: 01b12023 sw s11,0(sp)
80000074: 00100f13 li t5,1
80000078: 00100e93 li t4,1
8000007c: 03df6eb3 rem t4,t5,t4
80000080: 01d12223 sw t4,4(sp)
80000084: 00100193 li gp,1
80000088: fff00f93 li t6,-1
8000008c: 03f1efb3 rem t6,gp,t6
80000090: 01f12423 sw t6,8(sp)
80000094: 00100413 li s0,1
80000098: 80000237 lui tp,0x80000
8000009c: fff20213 addi tp,tp,-1 # 7fffffff <_end+0xffffef2f>
800000a0: 02446233 rem tp,s0,tp
800000a4: 00412623 sw tp,12(sp)
800000a8: 00100593 li a1,1
800000ac: 800004b7 lui s1,0x80000
800000b0: 0295e4b3 rem s1,a1,s1
800000b4: 00912823 sw s1,16(sp)
800000b8: 00001117 auipc sp,0x1
800000bc: f7010113 addi sp,sp,-144 # 80001028 <test_3_res>
800000c0: fff00693 li a3,-1
800000c4: 00000613 li a2,0
800000c8: 02c6e633 rem a2,a3,a2
800000cc: 00c12023 sw a2,0(sp)
800000d0: fff00793 li a5,-1
800000d4: 00100713 li a4,1
800000d8: 02e7e733 rem a4,a5,a4
800000dc: 00e12223 sw a4,4(sp)
800000e0: fff00893 li a7,-1
800000e4: fff00813 li a6,-1
800000e8: 0308e833 rem a6,a7,a6
800000ec: 01012423 sw a6,8(sp)
800000f0: fff00993 li s3,-1
800000f4: 80000937 lui s2,0x80000
800000f8: fff90913 addi s2,s2,-1 # 7fffffff <_end+0xffffef2f>
800000fc: 0329e933 rem s2,s3,s2
80000100: 01212623 sw s2,12(sp)
80000104: fff00a93 li s5,-1
80000108: 80000a37 lui s4,0x80000
8000010c: 034aea33 rem s4,s5,s4
80000110: 01412823 sw s4,16(sp)
80000114: 00001117 auipc sp,0x1
80000118: f2810113 addi sp,sp,-216 # 8000103c <test_4_res>
8000011c: 80000bb7 lui s7,0x80000
80000120: fffb8b93 addi s7,s7,-1 # 7fffffff <_end+0xffffef2f>
80000124: 00000b13 li s6,0
80000128: 036beb33 rem s6,s7,s6
8000012c: 01612023 sw s6,0(sp)
80000130: 80000cb7 lui s9,0x80000
80000134: fffc8c93 addi s9,s9,-1 # 7fffffff <_end+0xffffef2f>
80000138: 00100c13 li s8,1
8000013c: 038cec33 rem s8,s9,s8
80000140: 01812223 sw s8,4(sp)
80000144: 80000db7 lui s11,0x80000
80000148: fffd8d93 addi s11,s11,-1 # 7fffffff <_end+0xffffef2f>
8000014c: fff00d13 li s10,-1
80000150: 03aded33 rem s10,s11,s10
80000154: 01a12423 sw s10,8(sp)
80000158: 80000eb7 lui t4,0x80000
8000015c: fffe8e93 addi t4,t4,-1 # 7fffffff <_end+0xffffef2f>
80000160: 80000e37 lui t3,0x80000
80000164: fffe0e13 addi t3,t3,-1 # 7fffffff <_end+0xffffef2f>
80000168: 03ceee33 rem t3,t4,t3
8000016c: 01c12623 sw t3,12(sp)
80000170: 80000fb7 lui t6,0x80000
80000174: ffff8f93 addi t6,t6,-1 # 7fffffff <_end+0xffffef2f>
80000178: 80000f37 lui t5,0x80000
8000017c: 03efef33 rem t5,t6,t5
80000180: 01e12823 sw t5,16(sp)
80000184: 00001117 auipc sp,0x1
80000188: ecc10113 addi sp,sp,-308 # 80001050 <test_5_res>
8000018c: 80000237 lui tp,0x80000
80000190: 00000193 li gp,0
80000194: 023261b3 rem gp,tp,gp
80000198: 00312023 sw gp,0(sp)
8000019c: 800004b7 lui s1,0x80000
800001a0: 00100413 li s0,1
800001a4: 0284e433 rem s0,s1,s0
800001a8: 00812223 sw s0,4(sp)
800001ac: 80000637 lui a2,0x80000
800001b0: fff00593 li a1,-1
800001b4: 02b665b3 rem a1,a2,a1
800001b8: 00b12423 sw a1,8(sp)
800001bc: 80000737 lui a4,0x80000
800001c0: 800006b7 lui a3,0x80000
800001c4: fff68693 addi a3,a3,-1 # 7fffffff <_end+0xffffef2f>
800001c8: 02d766b3 rem a3,a4,a3
800001cc: 00d12623 sw a3,12(sp)
800001d0: 80000837 lui a6,0x80000
800001d4: 800007b7 lui a5,0x80000
800001d8: 02f867b3 rem a5,a6,a5
800001dc: 00f12823 sw a5,16(sp)
800001e0: 00001517 auipc a0,0x1
800001e4: e2050513 addi a0,a0,-480 # 80001000 <codasip_signature_start>
800001e8: 00001597 auipc a1,0x1
800001ec: ee858593 addi a1,a1,-280 # 800010d0 <_end>
800001f0: f0100637 lui a2,0xf0100
800001f4: f2c60613 addi a2,a2,-212 # f00fff2c <_end+0x700fee5c>
800001f8 <complience_halt_loop>:
800001f8: 02b50663 beq a0,a1,80000224 <complience_halt_break>
800001fc: 00c52683 lw a3,12(a0)
80000200: 00d62023 sw a3,0(a2)
80000204: 00852683 lw a3,8(a0)
80000208: 00d62023 sw a3,0(a2)
8000020c: 00452683 lw a3,4(a0)
80000210: 00d62023 sw a3,0(a2)
80000214: 00052683 lw a3,0(a0)
80000218: 00d62023 sw a3,0(a2)
8000021c: 01050513 addi a0,a0,16
80000220: fd9ff06f j 800001f8 <complience_halt_loop>
80000224 <complience_halt_break>:
80000224: f0100537 lui a0,0xf0100
80000228: f2050513 addi a0,a0,-224 # f00fff20 <_end+0x700fee50>
8000022c: 00052023 sw zero,0(a0)
80000230: 0000 unimp
...
Disassembly of section .data:
80001000 <codasip_signature_start>:
80001000: ffff 0xffff
80001002: ffff 0xffff
80001004: ffff 0xffff
80001006: ffff 0xffff
80001008: ffff 0xffff
8000100a: ffff 0xffff
8000100c: ffff 0xffff
8000100e: ffff 0xffff
80001010: ffff 0xffff
80001012: ffff 0xffff
80001014 <test_2_res>:
80001014: ffff 0xffff
80001016: ffff 0xffff
80001018: ffff 0xffff
8000101a: ffff 0xffff
8000101c: ffff 0xffff
8000101e: ffff 0xffff
80001020: ffff 0xffff
80001022: ffff 0xffff
80001024: ffff 0xffff
80001026: ffff 0xffff
80001028 <test_3_res>:
80001028: ffff 0xffff
8000102a: ffff 0xffff
8000102c: ffff 0xffff
8000102e: ffff 0xffff
80001030: ffff 0xffff
80001032: ffff 0xffff
80001034: ffff 0xffff
80001036: ffff 0xffff
80001038: ffff 0xffff
8000103a: ffff 0xffff
8000103c <test_4_res>:
8000103c: ffff 0xffff
8000103e: ffff 0xffff
80001040: ffff 0xffff
80001042: ffff 0xffff
80001044: ffff 0xffff
80001046: ffff 0xffff
80001048: ffff 0xffff
8000104a: ffff 0xffff
8000104c: ffff 0xffff
8000104e: ffff 0xffff
80001050 <test_5_res>:
80001050: ffff 0xffff
80001052: ffff 0xffff
80001054: ffff 0xffff
80001056: ffff 0xffff
80001058: ffff 0xffff
8000105a: ffff 0xffff
8000105c: ffff 0xffff
8000105e: ffff 0xffff
80001060: ffff 0xffff
80001062: ffff 0xffff
80001064 <test_6_res>:
80001064: ffff 0xffff
80001066: ffff 0xffff
80001068: ffff 0xffff
8000106a: ffff 0xffff
8000106c: ffff 0xffff
8000106e: ffff 0xffff
80001070: ffff 0xffff
80001072: ffff 0xffff
80001074: ffff 0xffff
80001076: ffff 0xffff
80001078 <test_7_res>:
80001078: ffff 0xffff
8000107a: ffff 0xffff
8000107c: ffff 0xffff
8000107e: ffff 0xffff
80001080: ffff 0xffff
80001082: ffff 0xffff
80001084: ffff 0xffff
80001086: ffff 0xffff
80001088: ffff 0xffff
8000108a: ffff 0xffff
8000108c <test_8_res>:
8000108c: ffff 0xffff
8000108e: ffff 0xffff
80001090: ffff 0xffff
80001092: ffff 0xffff
80001094: ffff 0xffff
80001096: ffff 0xffff
80001098: ffff 0xffff
8000109a: ffff 0xffff
8000109c: ffff 0xffff
8000109e: ffff 0xffff
800010a0 <test_9_res>:
800010a0: ffff 0xffff
800010a2: ffff 0xffff
800010a4: ffff 0xffff
800010a6: ffff 0xffff
800010a8: ffff 0xffff
800010aa: ffff 0xffff
800010ac: ffff 0xffff
800010ae: ffff 0xffff
800010b0: ffff 0xffff
800010b2: ffff 0xffff
800010b4 <test_10_res>:
800010b4: ffff 0xffff
800010b6: ffff 0xffff
800010b8: ffff 0xffff
800010ba: ffff 0xffff
800010bc: ffff 0xffff
800010be: ffff 0xffff
800010c0: ffff 0xffff
800010c2: ffff 0xffff
800010c4: ffff 0xffff
800010c6: ffff 0xffff
...
| ObjDump | 3 | cbrune/VexRiscv | src/test/resources/asm/REM.elf.objdump | [
"MIT"
] |
# Makefile for GLU for VMS
# contributed by Jouk Jansen [email protected]
.first
define gl [-.include.gl]
.include [-]mms-config.
##### MACROS #####
VPATH = RCS
INCDIR = $disk2:[-.include]
LIBDIR = [-.lib]
CFLAGS = /include=$(INCDIR)/define=(FBIND=1)
SOURCES = glu.c mipmap.c nurbs.c nurbscrv.c nurbssrf.c nurbsutl.c \
project.c quadric.c tess.c tesselat.c polytest.c
OBJECTS =glu.obj,mipmap.obj,nurbs.obj,nurbscrv.obj,nurbssrf.obj,nurbsutl.obj,\
project.obj,quadric.obj,tess.obj,tesselat.obj,polytest.obj
##### RULES #####
##### TARGETS #####
# Make the library:
$(LIBDIR)$(GLU_LIB) : $(OBJECTS)
$(MAKELIB) $(GLU_LIB) $(OBJECTS)
rename $(GLU_LIB)* $(LIBDIR)
clean :
delete *.obj;*
purge
include mms_depend.
| Module Management System | 3 | srokicki/HybridDBT-benchmarks | Mediabench/mesa/src-glu/descrip.mms | [
"MIT"
] |
^^A asdasd
| TeX | 0 | IngoMeyer441/vimtex | test/test-syntax/test-core.dtx | [
"MIT"
] |
// @declaration: true
export enum Test {
A, B, C
}
export type TestType = typeof Test;
export const bar = (null as TestType[Extract<keyof TestType, string>][]); | TypeScript | 4 | nilamjadhav/TypeScript | tests/cases/compiler/declarationEmitNoNonRequiredParens.ts | [
"Apache-2.0"
] |
foo is a or b
| Dogescript | 0 | erinkeith/dogescript | test/spec/operators/or/assignment/source.djs | [
"MIT"
] |
// run-rustfix
#![allow(dead_code)]
struct RGB { r: f64, g: f64, b: f64 }
fn main() {
let (r, g, b): (f32, f32, f32) = (0., 0., 0.);
let _ = RGB { r, g, b };
//~^ ERROR mismatched types
//~| ERROR mismatched types
//~| ERROR mismatched types
}
| Rust | 3 | Eric-Arellano/rust | src/test/ui/suggestions/type-mismatch-struct-field-shorthand.rs | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] |
1.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -6.00
-1.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -92.00
0.00 1.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -20.00
0.00 -1.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -48.00
1.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -6.00
-1.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00
0.00 1.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -20.00
0.00 -1.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -87.00
1.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 -6.00
-1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 -21.00
0.00 1.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 -20.00
0.00 -1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 -68.00
1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 -6.00
-1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 -92.00
0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 -20.00
0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 -38.00
1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 -6.00
-1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 -46.00
0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 -20.00
0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 -42.00
0.00 0.00 1.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -92.00
0.00 0.00 -1.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00
0.00 0.00 0.00 1.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -48.00
0.00 0.00 0.00 -1.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -87.00
0.00 0.00 1.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 -92.00
0.00 0.00 -1.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 -21.00
0.00 0.00 0.00 1.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 -48.00
0.00 0.00 0.00 -1.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 -68.00
0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 -92.00
0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 -92.00
0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 -48.00
0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 -38.00
0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 -92.00
0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 -46.00
0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 -48.00
0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 -42.00
0.00 0.00 0.00 0.00 1.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00
0.00 0.00 0.00 0.00 -1.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 -21.00
0.00 0.00 0.00 0.00 0.00 1.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 -87.00
0.00 0.00 0.00 0.00 0.00 -1.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 -68.00
0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 -1.00
0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 -92.00
0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 -87.00
0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 -38.00
0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 -1.00
0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 -46.00
0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 -87.00
0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 -42.00
0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 -1.00 0.00 0.00 0.00 0.00 -21.00
0.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 1.00 0.00 0.00 0.00 0.00 -92.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 -1.00 0.00 0.00 0.00 -68.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 1.00 0.00 0.00 0.00 -38.00
0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 -1.00 0.00 0.00 -21.00
0.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 1.00 0.00 0.00 -46.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 -1.00 0.00 -68.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 1.00 0.00 -42.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 -1.00 0.00 0.00 -92.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 1.00 0.00 0.00 -46.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 -1.00 0.00 -38.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 1.00 0.00 -42.00
1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00 -6.00
0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00 -92.00
0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00 -1.00
0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 -1.00 -21.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 -1.00 -92.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 -1.00 -46.00
-1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 102.00
0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 74.00
0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 35.00
0.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 54.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 84.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -1.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 80.00
| Matlab | 0 | yinrun/LOPDC-Benchmarks | strippacking/matlab/sp-6-22-sqrt.matlab | [
"MIT"
] |
import locale from '../locale/he_IL';
export default locale;
| TypeScript | 1 | zchengsite/ant-design-vue | components/locale-provider/he_IL.ts | [
"MIT"
] |
python/cyber_py/cyber.py
============================
Defined in python/cyber_py/cyber.py
.. doxygenfunction:: cyber_py::cyber::init
:project: Cyber RT Documents
.. doxygenfunction:: cyber_py::cyber::ok
:project: Cyber RT Documents
.. doxygenfunction:: cyber_py::cyber::shutdown
:project: Cyber RT Documents
.. doxygenfunction:: cyber_py::cyber::is_shutdown
:project: Cyber RT Documents
.. doxygenfunction:: cyber_py::cyber::waitforshutdown
:project: Cyber RT Documents
.. doxygenclass:: cyber_py::cyber::Node
:members:
:project: Cyber RT Documents
.. doxygenclass:: cyber_py::cyber::Writer
:members:
:project: Cyber RT Documents
.. doxygenclass:: cyber_py::cyber::Reader
:members:
:project: Cyber RT Documents
.. doxygenclass:: cyber_py::cyber::Client
:members:
:project: Cyber RT Documents
.. doxygenclass:: cyber_py::cyber::ChannelUtils
:members:
:project: Cyber RT Documents
.. doxygenclass:: cyber_py::cyber::NodeUtils
:members:
:project: Cyber RT Documents
python/cyber_py/record.py
================================
Defined in python/cyber_py/record.py
.. doxygenclass:: cyber_py::record::RecordReader
:members:
:project: Cyber RT Documents
.. doxygenclass:: cyber_py::record::RecordWriter
:members:
:project: Cyber RT Documents
python/cyber_py/cyber_time.py
=================================
Defined in python/cyber_py/cyber_time.py
.. doxygenclass:: cyber_py::cyber_time::Duration
:members:
:project: Cyber RT Documents
.. doxygenclass:: cyber_py::cyber_time::Time
:members:
:project: Cyber RT Documents
.. doxygenclass:: cyber_py::cyber_time::Rate
:members:
:project: Cyber RT Documents
python/cyber_py/cyber_timer.py
==================================
Defined in python/cyber_py/cyber_timer.py
.. doxygenclass:: cyber_py::cyber_timer::Timer
:members:
:project: Cyber RT Documents
python/cyber_py/parameter.py
===============================
Defined in python/cyber_py/parameter.py
.. doxygenclass:: cyber_py::parameter::Parameter
:members:
:project: Cyber RT Documents
.. doxygenclass:: cyber_py::parameter::ParameterServer
:members:
:project: Cyber RT Documents
.. doxygenclass:: cyber_py::parameter::ParameterClient
:members:
:project: Cyber RT Documents
| reStructuredText | 3 | seeclong/apollo | cyber/doxy-docs/source/api/pythonapi.rst | [
"Apache-2.0"
] |
<p>Do you want to <a href="/account/login">log in</a>?</p>
| RHTML | 2 | andypohl/kent | src/hg/encode/hgEncodeSubmit/app/views/account/index.rhtml | [
"MIT"
] |
Feature: auto_vertical mode:
on, off
Scenario: auto_vertical on with small query
When we run dbcli with --auto-vertical-output
and we execute a small query
then we see small results in horizontal format
Scenario: auto_vertical on with large query
When we run dbcli with --auto-vertical-output
and we execute a large query
then we see large results in vertical format
| Cucumber | 3 | lyrl/mycli | test/features/auto_vertical.feature | [
"BSD-3-Clause"
] |
namespace Kernel
Main:
AH = 14
AL = 'H'
//! int 0x10
AL = 'e'
//! int 0x10
AL = 'l'
//! int 0x10
AL = 'l'
//! int 0x10
AL = 'o'
//! int 0x10
AL = ' '
//! int 0x10
AL = 'f'
//! int 0x10
AL = 'r'
//! int 0x10
AL = 'o'
//! int 0x10
AL = 'm'
//! int 0x10
AL = ' '
//! int 0x10
AL = 'X'
//! int 0x10
AL = '#'
//! int 0x10
Finished:
goto Finished
| XS | 1 | xccoreco/XSharp | samples/HelloWorld.Win32/Program.xs | [
"BSD-3-Clause"
] |
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.2
import QtQml 2.2
import QGroundControl 1.0
import QGroundControl.Airmap 1.0
import QGroundControl.Airspace 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.SettingsManager 1.0
Item {
id: _root
implicitHeight: detailCol.height
implicitWidth: detailCol.width
property real baseHeight: ScreenTools.defaultFontPixelHeight * 22
property real baseWidth: ScreenTools.defaultFontPixelWidth * 40
Column {
id: detailCol
spacing: ScreenTools.defaultFontPixelHeight * 0.25
Rectangle {
color: qgcPal.windowShade
anchors.right: parent.right
anchors.left: parent.left
height: detailsLabel.height + ScreenTools.defaultFontPixelHeight
QGCLabel {
id: detailsLabel
text: qsTr("Flight Details")
font.pointSize: ScreenTools.mediumFontPointSize
font.family: ScreenTools.demiboldFontFamily
anchors.centerIn: parent
}
}
Item { width: 1; height: ScreenTools.defaultFontPixelHeight * 0.5; }
Flickable {
clip: true
width: baseWidth
height: baseHeight
contentHeight: flContextCol.height
flickableDirection: Flickable.VerticalFlick
Column {
id: flContextCol
spacing: ScreenTools.defaultFontPixelHeight * 0.25
anchors.right: parent.right
anchors.left: parent.left
QGCLabel {
text: qsTr("Flight Date & Time")
}
Rectangle {
id: dateRect
color: qgcPal.windowShade
anchors.right: parent.right
anchors.left: parent.left
height: datePickerCol.height + (ScreenTools.defaultFontPixelHeight * 2)
Column {
id: datePickerCol
spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.right: parent.right
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
RowLayout {
spacing: ScreenTools.defaultFontPixelWidth * 0.5
anchors.right: parent.right
anchors.left: parent.left
QGCButton {
text: qsTr("Now")
checked: QGroundControl.airspaceManager.flightPlan.flightStartsNow
onClicked: {
QGroundControl.airspaceManager.flightPlan.flightStartsNow = !QGroundControl.airspaceManager.flightPlan.flightStartsNow
}
}
QGCButton {
text: {
var nowTime = new Date()
var setTime = QGroundControl.airspaceManager.flightPlan.flightStartTime
if(setTime.setHours(0,0,0,0) === nowTime.setHours(0,0,0,0)) {
return qsTr("Today")
} else {
return setTime.toLocaleDateString(Qt.locale())
}
}
Layout.fillWidth: true
enabled: !QGroundControl.airspaceManager.flightPlan.flightStartsNow
iconSource: "qrc:/airmap/expand.svg"
onClicked: {
datePicker.visible = true
}
}
}
QGCLabel {
text: qsTr("Flight Start Time")
}
Item {
anchors.right: parent.right
anchors.left: parent.left
height: timeSlider.height
visible: !QGroundControl.airspaceManager.flightPlan.flightStartsNow
QGCSlider {
id: timeSlider
width: parent.width - timeLabel.width - ScreenTools.defaultFontPixelWidth
stepSize: 1
enabled: !QGroundControl.airspaceManager.flightPlan.flightStartsNow
minimumValue: 0
maximumValue: 95 // 96 blocks of 15 minutes in 24 hours
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
onValueChanged: {
var today = QGroundControl.airspaceManager.flightPlan.flightStartTime
today.setHours(Math.floor(timeSlider.value * 0.25))
today.setMinutes((timeSlider.value * 15) % 60)
today.setSeconds(0)
today.setMilliseconds(0)
QGroundControl.airspaceManager.flightPlan.flightStartTime = today
}
Component.onCompleted: {
updateTime()
}
function updateTime() {
var today = QGroundControl.airspaceManager.flightPlan.flightStartTime
var val = (((today.getHours() * 60) + today.getMinutes()) * (96/1440)) + 1
if(val > 95) val = 95
timeSlider.value = Math.ceil(val)
}
}
QGCLabel {
id: timeLabel
text: ('00' + hour).slice(-2) + ":" + ('00' + minute).slice(-2)
width: ScreenTools.defaultFontPixelWidth * 5
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
property int hour: Math.floor(timeSlider.value * 0.25)
property int minute: (timeSlider.value * 15) % 60
}
}
QGCLabel {
text: qsTr("Now")
visible: QGroundControl.airspaceManager.flightPlan.flightStartsNow
anchors.horizontalCenter: parent.horizontalCenter
}
QGCLabel {
text: qsTr("Duration")
}
Item {
anchors.right: parent.right
anchors.left: parent.left
height: durationSlider.height
QGCSlider {
id: durationSlider
width: parent.width - durationLabel.width - ScreenTools.defaultFontPixelWidth
stepSize: 1
minimumValue: 1
maximumValue: 24 // 24 blocks of 15 minutes in 6 hours
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
onValueChanged: {
var hour = Math.floor(durationSlider.value * 0.25)
var minute = (durationSlider.value * 15) % 60
var seconds = (hour * 60 * 60) + (minute * 60)
QGroundControl.airspaceManager.flightPlan.flightDuration = seconds
}
Component.onCompleted: {
var val = ((QGroundControl.airspaceManager.flightPlan.flightDuration / 60) * (96/1440)) + 1
if(val > 24) val = 24
durationSlider.value = Math.ceil(val)
}
}
QGCLabel {
id: durationLabel
text: ('00' + hour).slice(-2) + ":" + ('00' + minute).slice(-2)
width: ScreenTools.defaultFontPixelWidth * 5
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
property int hour: Math.floor(durationSlider.value * 0.25)
property int minute: (durationSlider.value * 15) % 60
}
}
}
}
Item { width: 1; height: ScreenTools.defaultFontPixelHeight * 0.25; }
QGCLabel {
text: qsTr("Flight Context")
visible: QGroundControl.airspaceManager.flightPlan.briefFeatures.count > 0
}
Repeater {
model: QGroundControl.airspaceManager.flightPlan.briefFeatures
visible: QGroundControl.airspaceManager.flightPlan.briefFeatures.count > 0
delegate: FlightFeature {
feature: object
visible: object && object.type !== AirspaceRuleFeature.Unknown && object.description !== "" && object.name !== ""
anchors.right: parent.right
anchors.left: parent.left
}
}
}
}
}
Calendar {
id: datePicker
anchors.centerIn: parent
visible: false;
minimumDate: QGroundControl.airspaceManager.flightPlan.flightStartTime
onClicked: {
QGroundControl.airspaceManager.flightPlan.flightStartTime = datePicker.selectedDate
visible = false;
}
}
}
| QML | 3 | uav-operation-system/qgroundcontrol | src/Airmap/FlightDetails.qml | [
"Apache-2.0"
] |
# duplicates example
echo $info | from json
let info = "[{name: "John", lastname: "Doe"}, {name: "John", lastname: "Roe"}, {name: "Jane", lastname: "Soe"}]"
echo $info | from json | duplicates name
#duplicates files example
echo A | save A.txt
echo A | save B.txt
# note that if I used "echo B | save B.txt" the function will give a false positive
echo ABC | save C.txt
ls
duplicates files
rm A.txt B.txt C.txt --permanent | Nu | 4 | x3rAx/nu_scripts | duplicates/example.nu | [
"MIT"
] |
# Bootstrap Usage:
# rbx boot/load.rb boot/compiler/boot.fyc boot/compiler/compiler.fyc boot/compiler/command.fyc boot/compile.fyc -- <FILES_TO_COMPILE>
Fancy Compiler Command run: ARGV
| Fancy | 2 | bakkdoor/fancy | boot/compile.fy | [
"BSD-3-Clause"
] |
.line[data-v-756ebb70]{text-align:center} | CSS | 1 | yuanweikang2020/canal | admin/admin-web/src/main/resources/public/static/css/chunk-69386cf0.741ff14e.css | [
"Apache-2.0"
] |
******************************************************************************;
* Copyright (c) 2015 by SAS Institute Inc., Cary, NC 27513 USA *;
* *;
* 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. *;
******************************************************************************;
******************************************************************************;
* script used to create classify image patches using a deep neural network - *;
* to be used after threaded_tile.py or threaded_tile_r.py *;
* *;
* square images are imported from patches.csv *;
* random selection of patches are displayed to check import *;
* 3 layer neural network is trained on all imported images *;
* input patches are scored with predicted values or labels *;
* and saved to OUT_DIR *;
* score code with network weights is saved to OUT_DIR *;
* conditionally plots classified patches over original images *;
* *;
* CORE_COUNT - number of physical cores to use, int *;
* OUT_DIR - out (-o) directory created by Python script as unquoted string, *;
* must contain the generated csv files and is the directory in *;
* which to write the patches.sas7bdat set, the label file, *;
* DNN_labels.sas7bdat, and score code file, DNN_score.sas *;
* LABEL_FILE - csv file name as unquoted string, containing original image *;
* names and labels - must contain 2 columns with headers: *;
* orig_name, label *;
* DIM - side length of square patches in IN_SET, probably (-d) value from *;
* Python script, int *;
* HIDDEN_UNIT_LIST - number units in each layer, space separated list of *;
* 3 integers *;
* VALID_PROPORTION - proportion of patches to assign to a validation set for *;
* training neural network, float (0,1) *;
* STAT - error measure used to assess neural network *;
* unquoted string string: ASE or MISC *;
* PLOT_RESULTS - plot the classification results overlayed onto the original *;
* images, not suitable for many input images or extremely *;
* large input images, boolean int, 1 = true *;
******************************************************************************;
* TODO: user sets constants;
%let CORE_COUNT = 2;
%let OUT_DIR = ;
%let LABEL_FILE = ;
%let DIM = 25;
%let HIDDEN_UNIT_LIST = 100 50 10;
%let VALID_PROPORTION = 0.3;
%let STAT = MISC;
%let PLOT_RESULTS = 1;
* system options;
options threads;
ods html close;
ods listing;
* start timer;
%let start = %sysfunc(datetime());
*** import csv ***************************************************************;
* libref to OUT_DIR;
libname l "&OUT_DIR.";
* woring dir to OUT_DIR;
x "cd &OUT_DIR";
* import csv;
proc import
datafile="&OUT_DIR./patches.csv"
out=l.patches
dbms=csv
replace;
run;
proc sort; by orig_name; run;
*** view random patches *******************************************************;
* define gtl template;
ods path show;
ods path(prepend) work.templat(update);
proc template;
define statgraph contour;
dynamic _title;
begingraph;
entrytitle _title;
layout overlayequated / equatetype=square
commonaxisopts=(viewmin=0 viewmax=%eval(&DIM.-1)
tickvaluelist=(0 %eval(&DIM./2) &DIM.))
xaxisopts=(offsetmin=0 offsetmax=0)
yaxisopts=(offsetmin=0 offsetmax=0);
contourplotparm x=x y=y z=z /
contourtype=gradient nlevels=255
colormodel=twocolorramp;
endlayout;
endgraph;
end;
run;
* create random sample of patches;
proc surveyselect
data=l.patches
out=samp
method=srs
n=20;
run;
* convert random patches to contours;
data _xyz;
set samp;
array pixels pixel_:;
pic_ID = _n_;
do j=1 to %eval(&DIM*&DIM);
x = (j-&DIM*floor((j-1)/&DIM))-1;
y = (%eval(&DIM+1)-ceil(j/&DIM))-1;
z = 255-pixels[j];
output;
keep pic_ID x y z;
end;
run;
* render selected patches;
proc sgrender data=_xyz template=contour;
dynamic _title="Input Image";
by pic_ID;
run;
*** add labels ***************************************************************;
* import csv;
proc import
datafile="&LABEL_FILE"
out=labels
dbms=csv
replace;
run;
proc sort; by orig_name; run;
* join labels to patches;
data l.patches;
merge l.patches(in=_x) labels;
by orig_name;
if _x;
run;
*** create validation set ****************************************************;
data train valid;
set l.patches;
if ranuni(12345) < 1-&VALID_PROPORTION then output train;
else output valid;
run;
*** train 3-layer DNN ********************************************************;
* create necessary dmdb catalog;
proc dmdb
data=train
out=_
dmdbcat=work.patches_cat;
var pixel_:;
class label;
target label;
run;
* train a deep neural net classifier with 3 layers;
proc neural
data=train
validdata=valid
dmdbcat=work.patches_cat
random=44444;
performance compile details cpucount=&CORE_COUNT threads=yes;
nloptions noprint; /* noprint=do not show weight values */
netoptions decay=0.25; /* decay=L2 penalty */
archi MLP hidden=3; /* 5-layer network architecture */
hidden %scan(&HIDDEN_UNIT_LIST, 1, ' ') / id=h1;
hidden %scan(&HIDDEN_UNIT_LIST, 2, ' ') / id=h2;
hidden %scan(&HIDDEN_UNIT_LIST, 3, ' ') / id=h3;
input pixel_0-pixel_%eval(&DIM*&DIM-1) / std=no id=i level=int;
target label / std=no id=t level=nom;
/* initialize network */
/* infan reduces chances of neurons being saturated by random init */
initial infan=0.1;
/* pretrain layers seperately */
/* layer 1 */
freeze h1->h2;
freeze h2->h3;
train maxtime=3600 maxiter=1000;
/* layer 2 */
freeze i->h1;
thaw h1->h2;
train maxtime=3600 maxiter=1000;
/* layer 3 */
freeze h1->h2;
thaw h2->h3;
train maxtime=3600 maxiter=1000;
/* retrain all layers together */
thaw i->h1;
thaw h1->h2;
thaw h2->h3;
train
tech=congra
maxtime=7200
maxiter=2000
outest=weights_all
outfit=_fit
estiter=1;
save network=work._net.architecture;
run;
*** model selection **********************************************************;
* find best iteration;
proc sort
data=_fit(where=(_NAME_='OVERALL'));
by _V&STAT._;
run;
data _null_;
set _fit(obs=1);
call symput('_best_iter', _ITER_);
run;
* plot training error;
proc sort
data=_fit;
by _ITER_;
run;
proc sgplot
data=_fit (where=(_NAME_='OVERALL'));
series x=_ITER_ y=_&STAT._;
series x=_ITER_ y=_V&STAT._;
refline &_best_iter. / axis=x label="Best Validation Error";
xaxis label='Iteration';
title 'Iteration Plot';
run;
title;
* score l.patches and generate score code;
proc neural
data=l.patches
dmdbcat=work.patches_cat
network=work._net.architecture
random=44444;
* read best weights;
nloptions noprint;
initial inest=weights_all(where=(_ITER_=&_best_iter));
train tech=none;
* score l.patches;
score
data=l.patches
out=l.DNN_labels (keep=I_label orig_name x y size angle)
role=test;
* save score code;
code file="&OUT_DIR/DNN_score.sas";
quit;
*** conditionally plot classification results ********************************;
*** plot_labels ************************************************************;
* conditionally defines a graph template for each image;
* aligns patches in each class with the original image;
* plots results;
* label_var - name of variable containing class label;
%macro plot_labels(label_var=I_label);
* define a list of SAS/GRAPH colors;
%let color_list = red blue cream cyan gold green lilac lime magenta maroon
olive orange pink purple red rose salmon violet white
yellow;
* place original image names into macro variable array;
proc sql noprint;
create table image_names as
select distinct orig_name
from l.originals;
quit;
data _null_;
set image_names end=eof;
call symput('image'||strip(put(_n_, best.)), strip(orig_name));
if eof then call symput('n_images', strip(put(_n_, best.)));
run;
* loop for each original image;
%do j=1 %to &n_images;
proc sql;
* determine max x value of image;
select max(x) into: max_x
from l.originals
where orig_name = "&&image&j";
* determine max y value of image;
select max(y) into: max_y
from l.originals
where orig_name = "&&image&j";
* determine number of classes in image;
select max(&label_var.) into: n_label
from l.dnn_labels
where orig_name = "&&image&j";
quit;
* conditionally define gtl template based on image attributes;
ods path show;
ods path(prepend) work.templat(update);
proc template;
define statgraph contour;
dynamic _title;
begingraph;
entrytitle _title;
* assign consistent color to class labels across all images;
discreteattrmap name="class_colors";
%do i=1 %to &n_label;
%let color_index = %eval(%sysfunc(mod(%eval(&i-1), &n_label))+1);
%let _color = %scan(&color_list, &color_index, ' ');
value "&i" / markerattrs=(color=&_color symbol=circlefilled);
%end;
enddiscreteattrmap;
discreteattrvar attrvar=groupmarkers var=&label_var.
attrmap="class_colors";
* layout boundaries and axis attributes;
layout overlay / aspectratio=1
xaxisopts=(offsetmin=0 offsetmax=0 linearopts=(viewmin=0
viewmax=%eval(&max_x.-1) tickvaluelist=(0 %eval(&max_x./2)
%eval(&max_x.-1))))
yaxisopts=(offsetmin=0 offsetmax=0 linearopts=(viewmin=0
viewmax=%eval(&max_y.-1) tickvaluelist=(0 %eval(&max_y./2)
%eval(&max_y.-1))));
* contour plot of original image is bottom layer of layout;
contourplotparm x=x y=y z=z /
contourtype=gradient nlevels=255
colormodel=twocolorramp;
* a dense scatter plot of class patches is overlayed;
* onto contour plot of original image;
scatterplot x=scatter_x y=scatter_y /
group=groupmarkers name="class"
/* transparency needs to be adjusted for different image sizes */
markerattrs=(symbol=CircleFilled size=1px transparency=0.35);
endlayout;
endgraph;
end;
run;
* loop for each class;
%do k=1 %to &n_label;
* create x,y coordinates of class;
* accounting for size and rotation;
* sort into correct order to align with original image;
data tiles_label_expanded;
set l.dnn_labels (where=(&label_var.="&k." and orig_name="&&image&j"));
retain &label_var.;
_x = x;
_y = %eval(&max_y.-1) - y;
do i=0 to size-1;
do j=0 to size-1;
y = _y - i;
x = _x + j;
if angle ne 0 then do;
pi = constant("pi");
_angle = (angle/180)*pi;
x = floor(x*cos(_angle) - y*sin(_angle));
y = floor(x*sin(_angle) + y*cos(_angle));
end;
output;
end;
end;
keep x y orig_name &label_var.;
run;
proc sort nodupkey; by orig_name x y; run;
* if no class for this label, continue;
%let _rc = %sysfunc(open(tiles_label_expanded));
%let _nlobs = %sysfunc(attrn(&_rc, NLOBS));
%let _rc = %sysfunc(close(&_rc));
%if ^&_nlobs %then %goto continue;
* align labeled patches with original image;
data label_merge;
merge l.originals (where=(orig_name="&&image&j"))
tiles_label_expanded;
by orig_name x y;
* gtl requires a different name for different layout layer attributes;
if &label_var. ne . then do;
scatter_x = x;
scatter_y = y;
end;
run;
* render image;
proc sgrender data=label_merge template=contour;
dynamic _title="&&image&j label &k";
run;
%continue:
%end; /* end class loop */
%end; /* end image loop */
%mend;
*** plot *********************************************************************;
* simple utility macro to load originals.csv and conditionally execute;
* ploting if a classification task was performed;
%macro plot(_stat=&STAT, _plot_results=&PLOT_RESULTS);
%if "&_stat" = "MISC" %then %do;
%if &_plot_results %then %do;
* import original images;
proc import
datafile="&OUT_DIR.\originals.csv"
out=l.originals
dbms=csv
replace;
run;
proc sort
data=l.originals
sortsize=MAX;
by orig_name x y;
run;
%plot_labels;
%end;
%end;
%mend;
%plot;
* end timer;
%put NOTE: Total elapsed time: %sysfunc(putn(%sysevalf(%sysfunc(datetime())-&start), 10.2)) seconds.;
| SAS | 5 | mikiec84/enlighten-apply | SAS_Py_Patches_PatternRecognition/dnn_classifier.sas | [
"Apache-2.0"
] |
<html><body>foo</body></html>
| HTML | 1 | mm73628486283/cypress | system-tests/projects/todos/tests/_fixtures/trailing_new_line.html | [
"MIT"
] |
exec("swigtest.start", -1);
// Test truncating variables, constants, functions identifier names
// not truncated
gvar_identifier_name_set(-101);
checkequal(gvar_identifier_name_get(), -101, "gvar_identifier_name_get()");
checkequal(CONS_IDENTIFIER_NAME_get(), -11, "CONS_IDENTIFIER_NAME_get()");
checkequal(function_identifier_name(), -21, "function_identifier_name()");
// truncated
too_long_gvar_identi_set(101);
checkequal(too_long_gvar_identi_get(), 101, "too_long_variable_id_get()");
checkequal(TOO_LONG_CONST_IDENT_get(), 11, "TOO_LONG_CONST_IDENT_get()");
checkequal(too_long_function_identi(), 21, "too_long_function_identi()");
// Test truncating when %scilabconst mode is activated
checkequal(SC_CONST_IDENTIFIER_NAME, int32(-12), "SC_TOO_LONG_IDENTIF");
checkequal(SC_TOO_LONG_CONST_IDENTI, int32(14), "SC_TOO_LONG_IDENTIF");
// Test truncating in the case of struct
st = new_st();
st_m_identifier_name_set(st, 15);
checkequal(st_m_identifier_name_get(st), 15, "st_m_identifier_name_get(st)");
st_too_long_member_i_set(st, 25);
checkequal(st_too_long_member_i_get(st), 25, "st_too_long_member_i_get(st)");
delete_st(st);
exec("swigtest.quit", -1);
| Scilab | 4 | kyletanyag/LL-Smartcard | cacreader/swig-4.0.2/Examples/test-suite/scilab/scilab_identifier_name_runme.sci | [
"BSD-3-Clause"
] |
<%-
@title = "#{@page.plain_name} (Rev ##{@revision_number}#{@show_diff ? ', changes' : ''})".html_safe
-%>
<div id="revision">
<%- if @show_diff -%>
<p class="show_diff">
Showing changes from revision #<%= @revision_number - 1 %> to #<%= @revision_number %>:
<ins class="diffins">Added</ins> | <del class="diffdel">Removed</del> | <del class="diffmod">Chan</del><ins class="diffmod">ged</ins>
</p>
<%= @renderer.display_diff %>
<%- else -%>
<%= @renderer.display_content %>
<%- end -%>
</div> <!-- Revision -->
<div class="byline">
<%= "Revision from #{format_date(@revision.revised_at)} by" %>
<%= link_to_page @revision.author.purify %>
</div>
<div class="navigation navfoot">
<%= raw navigation_menu_for_revision.join(' | ') %>
<span class="views">
| View:
<%= link_to 'Source', {:web => @web.address, :action => 'source', :id => @page.name, :rev => @revision_number},
{:id => 'view_source', :rel => 'nofollow' } %>
</span>
<%= render :partial => 'inbound_links' %>
</div>
| RHTML | 3 | taskforce/instiki | app/views/wiki/revision.rhtml | [
"Ruby"
] |
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_HEAP_STRESS_SCAVENGE_OBSERVER_H_
#define V8_HEAP_STRESS_SCAVENGE_OBSERVER_H_
#include "src/heap/heap.h"
namespace v8 {
namespace internal {
class StressScavengeObserver : public AllocationObserver {
public:
explicit StressScavengeObserver(Heap* heap);
void Step(int bytes_allocated, Address soon_object, size_t size) override;
bool HasRequestedGC() const;
void RequestedGCDone();
// The maximum percent of the newspace capacity reached. This is tracked when
// specyfing --fuzzer-gc-analysis.
double MaxNewSpaceSizeReached() const;
private:
Heap* heap_;
int limit_percentage_;
bool has_requested_gc_;
double max_new_space_size_reached_;
int NextLimit(int min = 0);
};
} // namespace internal
} // namespace v8
#endif // V8_HEAP_STRESS_SCAVENGE_OBSERVER_H_
| C | 4 | rajeev02101987/arangodb | 3rdParty/V8/v7.9.317/src/heap/stress-scavenge-observer.h | [
"Apache-2.0"
] |
using Uno;
using Uno.UX;
public class UXGlobalTestClass
{
public string StringProp { get; set; }
}
public class DebugLogGlobalTestClass
{
UXGlobalTestClass _prop;
public UXGlobalTestClass Prop
{
get { return _prop; }
set
{
_prop = value;
debug_log("StringProp: " + value.StringProp);
}
}
}
| Uno | 4 | mortend/fuse-studio | Source/Simulator/Tests/UXFeaturesTestApp/UXGlobal/UXGlobal.uno | [
"MIT"
] |
:- object(bk(_X_, _Y_, _Z_)).
:- uses(coroutining, [when/2]).
:- public(n/1).
n(_X_).
n(_Y_).
n(_Z_).
:- public(node/2).
node(_X_, _Y_) :-
when(ground(_X_-_Y_), _X_ > _Y_).
node(_Y_, _Z_) :-
when(ground(_Y_-_Z_), _Y_ > _Z_).
:- end_object.
end_of_file.
?- bk(A,B,C)::(n(2), n(1), n(3), node(A,B), node(B,C)), bagof(X, bk(A,B,C)::n(X), L).
A = 3,
B = 2,
C = 1,
L = [3, 2, 1] ;
false.
| Logtalk | 3 | PaulBrownMagic/logtalk3 | examples/figures/backtracking.lgt | [
"Apache-2.0"
] |
<div>
{syntax asp}
<%$foo%>
{$notFoo}
<%/syntax%>
</div> | Latte | 1 | arusinha/incubator-netbeans | php/php.latte/test/unit/data/testfiles/lexer/top/syntax-asp.latte | [
"Apache-2.0"
] |
----------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2004 Dmitriy Anisimkov --
-- --
-- Open source license information is in the zlib.ads file. -- | Ada | 1 | s4-2/scancode-toolkit | tests/cluecode/data/ics/zlib-contrib-ada/buffer_demo.adb | [
"Apache-2.0",
"CC-BY-4.0"
] |
{{! Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef }}
CREATE TYPE [{{Schema}}].[udt{{EventOutboxTableName}}List] AS TABLE (
/*
* This is automatically generated; any changes will be lost.
*/
[EventId] UNIQUEIDENTIFIER,
[Subject] NVARCHAR(1024),
[Action] NVARCHAR(128) NULL,
[CorrelationId] NVARCHAR(64) NULL,
[TenantId] UNIQUEIDENTIFIER NULL,
[ValueType] NVARCHAR(1024),
[EventData] VARBINARY(MAX)
) | Harbour | 3 | ciaranodonnell/Beef | tools/Beef.CodeGen.Core/Templates/DbEobUdt_sql.hb | [
"MIT"
] |
h1. How to add project documentation
*Welcome to your project documentation page.*
You can edit it in @documentation@ folder of your project using "textile":http://en.wikipedia.org/wiki/Textile_%28markup_language%29 markup.
Every textile file in documentation folder will automatically be added to your documentation index. Just make sure you start it with some @h1.@ header, as it's being used as chapter name.
You can customize the way it looks by editing @template.html@ file, but it's not mandatory so you can remove this file if plain black on white page is ok for you.
h2. Export documentation to htmls
If you want to export your documentation just execute @play doc:export@ command in project root. This will generate zip file in @documentation@ folder with all your textile files rendered to html and files from @images@ and @files@ included.
| Textile | 4 | zxuu/playFrameworkTest | documentation/welcome.textile | [
"Apache-2.0"
] |
--TEST--
Bug #60825 (Segfault when running symfony 2 tests) (PHP7)
--DESCRIPTION--
run this with valgrind
--FILE--
<?php
class test {
public static $x;
public function __toString() {
self::$x = $this;
return __FILE__;
}
}
$a = new test;
require_once $a;
debug_zval_dump($a, test::$x);
?>
--EXPECTF--
object(test)#%d (0) refcount(%d){
}
object(test)#%d (0) refcount(%d){
}
| PHP | 3 | thiagooak/php-src | Zend/tests/bug60825.phpt | [
"PHP-3.01"
] |
"""Common fixtures and objects for the LG webOS integration tests."""
from unittest.mock import AsyncMock, Mock, patch
import pytest
from homeassistant.components.webostv.const import LIVE_TV_APP_ID
from homeassistant.helpers import entity_registry
from .const import CHANNEL_1, CHANNEL_2, CLIENT_KEY, FAKE_UUID, MOCK_APPS, MOCK_INPUTS
from tests.common import async_mock_service
@pytest.fixture
def calls(hass):
"""Track calls to a mock service."""
return async_mock_service(hass, "test", "automation")
@pytest.fixture(name="client")
def client_fixture():
"""Patch of client library for tests."""
with patch(
"homeassistant.components.webostv.WebOsClient", autospec=True
) as mock_client_class:
client = mock_client_class.return_value
client.hello_info = {"deviceUUID": FAKE_UUID}
client.software_info = {"major_ver": "major", "minor_ver": "minor"}
client.system_info = {"modelName": "TVFAKE"}
client.client_key = CLIENT_KEY
client.apps = MOCK_APPS
client.inputs = MOCK_INPUTS
client.current_app_id = LIVE_TV_APP_ID
client.channels = [CHANNEL_1, CHANNEL_2]
client.current_channel = CHANNEL_1
client.volume = 37
client.sound_output = "speaker"
client.muted = False
client.is_on = True
async def mock_state_update_callback():
await client.register_state_update_callback.call_args[0][0](client)
client.mock_state_update = AsyncMock(side_effect=mock_state_update_callback)
yield client
@pytest.fixture(name="client_entity_removed")
def client_entity_removed_fixture(hass):
"""Patch of client library, entity removed waiting for connect."""
with patch(
"homeassistant.components.webostv.WebOsClient", autospec=True
) as mock_client_class:
client = mock_client_class.return_value
client.hello_info = {"deviceUUID": FAKE_UUID}
client.connected = False
def mock_is_connected():
return client.connected
client.is_connected = Mock(side_effect=mock_is_connected)
async def mock_connected():
ent_reg = entity_registry.async_get(hass)
ent_reg.async_remove("media_player.webostv_some_secret")
client.connected = True
client.connect = AsyncMock(side_effect=mock_connected)
yield client
| Python | 5 | MrDelik/core | tests/components/webostv/conftest.py | [
"Apache-2.0"
] |
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IOutputChannelModelService, AbstractOutputChannelModelService } from 'vs/workbench/contrib/output/common/outputChannelModel';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IFileService } from 'vs/platform/files/common/files';
import { toLocalISOString } from 'vs/base/common/date';
import { dirname, joinPath } from 'vs/base/common/resources';
export class OutputChannelModelService extends AbstractOutputChannelModelService implements IOutputChannelModelService {
constructor(
@IInstantiationService instantiationService: IInstantiationService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IFileService fileService: IFileService,
) {
super(joinPath(dirname(environmentService.logFile), toLocalISOString(new Date()).replace(/-|:|\.\d+Z$/g, '')), fileService, instantiationService);
}
}
registerSingleton(IOutputChannelModelService, OutputChannelModelService);
| TypeScript | 4 | jgstern/vscode | src/vs/workbench/contrib/output/common/outputChannelModelService.ts | [
"MIT"
] |
grammar t053heteroTP15;
options {
language=JavaScript;
output=AST;
tokenVocab=t053heteroT15;
ASTLabelType=CommonTree;
}
tokens { ROOT; }
@header {
function V15(ttype) {
V15.superclass.constructor.call(this, new org.antlr.runtime.CommonToken(ttype));
};
org.antlr.lang.extend(V15, org.antlr.runtime.tree.CommonTree, {
toString: function() {
return t053heteroTP15Parser.tokenNames[this.getType()] + "<V>";
}
});
}
a : ID -> ROOT<V15> ID
;
| G-code | 4 | DanielMabadeje/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials | java/java2py/antlr-3.1.3/runtime/JavaScript/tests/functional/t053heteroTP15.g | [
"Apache-2.0"
] |
/**
*
*/
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;
extends OpenApi;
init(config: OpenApi.Config){
super(config);
@endpointRule = 'regional';
@endpointMap = {
cn-hangzhou = 'cas.aliyuncs.com',
ap-northeast-2-pop = 'cas.aliyuncs.com',
ap-southeast-1 = 'cas.aliyuncs.com',
ap-southeast-3 = 'cas.aliyuncs.com',
ap-southeast-5 = 'cas.aliyuncs.com',
cn-beijing = 'cas.aliyuncs.com',
cn-beijing-finance-1 = 'cas.aliyuncs.com',
cn-beijing-finance-pop = 'cas.aliyuncs.com',
cn-beijing-gov-1 = 'cas.aliyuncs.com',
cn-beijing-nu16-b01 = 'cas.aliyuncs.com',
cn-chengdu = 'cas.aliyuncs.com',
cn-edge-1 = 'cas.aliyuncs.com',
cn-fujian = 'cas.aliyuncs.com',
cn-haidian-cm12-c01 = 'cas.aliyuncs.com',
cn-hangzhou-bj-b01 = 'cas.aliyuncs.com',
cn-hangzhou-finance = 'cas.aliyuncs.com',
cn-hangzhou-internal-prod-1 = 'cas.aliyuncs.com',
cn-hangzhou-internal-test-1 = 'cas.aliyuncs.com',
cn-hangzhou-internal-test-2 = 'cas.aliyuncs.com',
cn-hangzhou-internal-test-3 = 'cas.aliyuncs.com',
cn-hangzhou-test-306 = 'cas.aliyuncs.com',
cn-hongkong = 'cas.aliyuncs.com',
cn-hongkong-finance-pop = 'cas.aliyuncs.com',
cn-huhehaote = 'cas.aliyuncs.com',
cn-north-2-gov-1 = 'cas.aliyuncs.com',
cn-qingdao = 'cas.aliyuncs.com',
cn-qingdao-nebula = 'cas.aliyuncs.com',
cn-shanghai = 'cas.aliyuncs.com',
cn-shanghai-et15-b01 = 'cas.aliyuncs.com',
cn-shanghai-et2-b01 = 'cas.aliyuncs.com',
cn-shanghai-finance-1 = 'cas.aliyuncs.com',
cn-shanghai-inner = 'cas.aliyuncs.com',
cn-shanghai-internal-test-1 = 'cas.aliyuncs.com',
cn-shenzhen = 'cas.aliyuncs.com',
cn-shenzhen-finance-1 = 'cas.aliyuncs.com',
cn-shenzhen-inner = 'cas.aliyuncs.com',
cn-shenzhen-st4-d01 = 'cas.aliyuncs.com',
cn-shenzhen-su18-b01 = 'cas.aliyuncs.com',
cn-wuhan = 'cas.aliyuncs.com',
cn-yushanfang = 'cas.aliyuncs.com',
cn-zhangbei-na61-b01 = 'cas.aliyuncs.com',
cn-zhangjiakou = 'cas.aliyuncs.com',
cn-zhangjiakou-na62-a01 = 'cas.aliyuncs.com',
cn-zhengzhou-nebula-1 = 'cas.aliyuncs.com',
eu-west-1 = 'cas.aliyuncs.com',
eu-west-1-oxs = 'cas.aliyuncs.com',
rus-west-1-pop = 'cas.aliyuncs.com',
us-east-1 = 'cas.aliyuncs.com',
us-west-1 = 'cas.aliyuncs.com',
};
checkConfig(config);
@endpoint = getEndpoint('cas', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}
function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
if (!Util.empty(endpoint)) {
return endpoint;
}
if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
return endpointMap[regionId];
}
return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model CreateClientCertificateRequest {
sanType?: int32(name='SanType'),
sanValue?: string(name='SanValue'),
commonName?: string(name='CommonName'),
algorithm?: string(name='Algorithm'),
days?: int32(name='Days'),
parentIdentifier?: string(name='ParentIdentifier'),
beforeTime?: long(name='BeforeTime'),
afterTime?: long(name='AfterTime'),
}
model CreateClientCertificateResponseBody = {
identifier?: string(name='Identifier'),
rootX509Certificate?: string(name='RootX509Certificate'),
parentX509Certificate?: string(name='ParentX509Certificate'),
requestId?: string(name='RequestId'),
x509Certificate?: string(name='X509Certificate'),
}
model CreateClientCertificateResponse = {
headers: map[string]string(name='headers'),
body: CreateClientCertificateResponseBody(name='body'),
}
async function createClientCertificateWithOptions(request: CreateClientCertificateRequest, runtime: Util.RuntimeOptions): CreateClientCertificateResponse {
Util.validateModel(request);
var query = {};
query["SanType"] = request.sanType;
query["SanValue"] = request.sanValue;
query["CommonName"] = request.commonName;
query["Algorithm"] = request.algorithm;
query["Days"] = request.days;
query["ParentIdentifier"] = request.parentIdentifier;
query["BeforeTime"] = request.beforeTime;
query["AfterTime"] = request.afterTime;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'CreateClientCertificate',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function createClientCertificate(request: CreateClientCertificateRequest): CreateClientCertificateResponse {
var runtime = new Util.RuntimeOptions{};
return createClientCertificateWithOptions(request, runtime);
}
model CreateClientCertificateWithCsrRequest {
csr?: string(name='Csr'),
sanType?: int32(name='SanType'),
sanValue?: string(name='SanValue'),
days?: int32(name='Days'),
parentIdentifier?: string(name='ParentIdentifier'),
beforeTime?: long(name='BeforeTime'),
afterTime?: long(name='AfterTime'),
}
model CreateClientCertificateWithCsrResponseBody = {
identifier?: string(name='Identifier'),
rootX509Certificate?: string(name='RootX509Certificate'),
parentX509Certificate?: string(name='ParentX509Certificate'),
requestId?: string(name='RequestId'),
x509Certificate?: string(name='X509Certificate'),
}
model CreateClientCertificateWithCsrResponse = {
headers: map[string]string(name='headers'),
body: CreateClientCertificateWithCsrResponseBody(name='body'),
}
async function createClientCertificateWithCsrWithOptions(request: CreateClientCertificateWithCsrRequest, runtime: Util.RuntimeOptions): CreateClientCertificateWithCsrResponse {
Util.validateModel(request);
var query = {};
query["Csr"] = request.csr;
query["SanType"] = request.sanType;
query["SanValue"] = request.sanValue;
query["Days"] = request.days;
query["ParentIdentifier"] = request.parentIdentifier;
query["BeforeTime"] = request.beforeTime;
query["AfterTime"] = request.afterTime;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'CreateClientCertificateWithCsr',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function createClientCertificateWithCsr(request: CreateClientCertificateWithCsrRequest): CreateClientCertificateWithCsrResponse {
var runtime = new Util.RuntimeOptions{};
return createClientCertificateWithCsrWithOptions(request, runtime);
}
model CreateRevokeClientCertificateRequest {
identifier?: string(name='Identifier'),
}
model CreateRevokeClientCertificateResponseBody = {
requestId?: string(name='RequestId'),
}
model CreateRevokeClientCertificateResponse = {
headers: map[string]string(name='headers'),
body: CreateRevokeClientCertificateResponseBody(name='body'),
}
async function createRevokeClientCertificateWithOptions(request: CreateRevokeClientCertificateRequest, runtime: Util.RuntimeOptions): CreateRevokeClientCertificateResponse {
Util.validateModel(request);
var query = {};
query["Identifier"] = request.identifier;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'CreateRevokeClientCertificate',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function createRevokeClientCertificate(request: CreateRevokeClientCertificateRequest): CreateRevokeClientCertificateResponse {
var runtime = new Util.RuntimeOptions{};
return createRevokeClientCertificateWithOptions(request, runtime);
}
model CreateRootCACertificateRequest {
organization?: string(name='Organization'),
organizationUnit?: string(name='OrganizationUnit'),
countryCode?: string(name='CountryCode'),
state?: string(name='State'),
locality?: string(name='Locality'),
commonName?: string(name='CommonName'),
algorithm?: string(name='Algorithm'),
years?: int32(name='Years'),
}
model CreateRootCACertificateResponseBody = {
identifier?: string(name='Identifier'),
requestId?: string(name='RequestId'),
}
model CreateRootCACertificateResponse = {
headers: map[string]string(name='headers'),
body: CreateRootCACertificateResponseBody(name='body'),
}
async function createRootCACertificateWithOptions(request: CreateRootCACertificateRequest, runtime: Util.RuntimeOptions): CreateRootCACertificateResponse {
Util.validateModel(request);
var query = {};
query["Organization"] = request.organization;
query["OrganizationUnit"] = request.organizationUnit;
query["CountryCode"] = request.countryCode;
query["State"] = request.state;
query["Locality"] = request.locality;
query["CommonName"] = request.commonName;
query["Algorithm"] = request.algorithm;
query["Years"] = request.years;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'CreateRootCACertificate',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function createRootCACertificate(request: CreateRootCACertificateRequest): CreateRootCACertificateResponse {
var runtime = new Util.RuntimeOptions{};
return createRootCACertificateWithOptions(request, runtime);
}
model CreateServerCertificateRequest {
domain?: string(name='Domain'),
commonName?: string(name='CommonName'),
algorithm?: string(name='Algorithm'),
days?: int32(name='Days'),
parentIdentifier?: string(name='ParentIdentifier'),
beforeTime?: long(name='BeforeTime'),
afterTime?: long(name='AfterTime'),
}
model CreateServerCertificateResponseBody = {
identifier?: string(name='Identifier'),
rootX509Certificate?: string(name='RootX509Certificate'),
parentX509Certificate?: string(name='ParentX509Certificate'),
requestId?: string(name='RequestId'),
x509Certificate?: string(name='X509Certificate'),
}
model CreateServerCertificateResponse = {
headers: map[string]string(name='headers'),
body: CreateServerCertificateResponseBody(name='body'),
}
async function createServerCertificateWithOptions(request: CreateServerCertificateRequest, runtime: Util.RuntimeOptions): CreateServerCertificateResponse {
Util.validateModel(request);
var query = {};
query["Domain"] = request.domain;
query["CommonName"] = request.commonName;
query["Algorithm"] = request.algorithm;
query["Days"] = request.days;
query["ParentIdentifier"] = request.parentIdentifier;
query["BeforeTime"] = request.beforeTime;
query["AfterTime"] = request.afterTime;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'CreateServerCertificate',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function createServerCertificate(request: CreateServerCertificateRequest): CreateServerCertificateResponse {
var runtime = new Util.RuntimeOptions{};
return createServerCertificateWithOptions(request, runtime);
}
model CreateServerCertificateWithCsrRequest {
csr?: string(name='Csr'),
domain?: string(name='Domain'),
days?: int32(name='Days'),
parentIdentifier?: string(name='ParentIdentifier'),
beforeTime?: long(name='BeforeTime'),
afterTime?: long(name='AfterTime'),
}
model CreateServerCertificateWithCsrResponseBody = {
identifier?: string(name='Identifier'),
rootX509Certificate?: string(name='RootX509Certificate'),
parentX509Certificate?: string(name='ParentX509Certificate'),
requestId?: string(name='RequestId'),
x509Certificate?: string(name='X509Certificate'),
}
model CreateServerCertificateWithCsrResponse = {
headers: map[string]string(name='headers'),
body: CreateServerCertificateWithCsrResponseBody(name='body'),
}
async function createServerCertificateWithCsrWithOptions(request: CreateServerCertificateWithCsrRequest, runtime: Util.RuntimeOptions): CreateServerCertificateWithCsrResponse {
Util.validateModel(request);
var query = {};
query["Csr"] = request.csr;
query["Domain"] = request.domain;
query["Days"] = request.days;
query["ParentIdentifier"] = request.parentIdentifier;
query["BeforeTime"] = request.beforeTime;
query["AfterTime"] = request.afterTime;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'CreateServerCertificateWithCsr',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function createServerCertificateWithCsr(request: CreateServerCertificateWithCsrRequest): CreateServerCertificateWithCsrResponse {
var runtime = new Util.RuntimeOptions{};
return createServerCertificateWithCsrWithOptions(request, runtime);
}
model CreateSubCACertificateRequest {
parentIdentifier?: string(name='ParentIdentifier'),
organization?: string(name='Organization'),
organizationUnit?: string(name='OrganizationUnit'),
countryCode?: string(name='CountryCode'),
state?: string(name='State'),
locality?: string(name='Locality'),
commonName?: string(name='CommonName'),
algorithm?: string(name='Algorithm'),
years?: int32(name='Years'),
}
model CreateSubCACertificateResponseBody = {
identifier?: string(name='Identifier'),
requestId?: string(name='RequestId'),
}
model CreateSubCACertificateResponse = {
headers: map[string]string(name='headers'),
body: CreateSubCACertificateResponseBody(name='body'),
}
async function createSubCACertificateWithOptions(request: CreateSubCACertificateRequest, runtime: Util.RuntimeOptions): CreateSubCACertificateResponse {
Util.validateModel(request);
var query = {};
query["ParentIdentifier"] = request.parentIdentifier;
query["Organization"] = request.organization;
query["OrganizationUnit"] = request.organizationUnit;
query["CountryCode"] = request.countryCode;
query["State"] = request.state;
query["Locality"] = request.locality;
query["CommonName"] = request.commonName;
query["Algorithm"] = request.algorithm;
query["Years"] = request.years;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'CreateSubCACertificate',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function createSubCACertificate(request: CreateSubCACertificateRequest): CreateSubCACertificateResponse {
var runtime = new Util.RuntimeOptions{};
return createSubCACertificateWithOptions(request, runtime);
}
model DeleteClientCertificateRequest {
identifier?: string(name='Identifier'),
}
model DeleteClientCertificateResponseBody = {
requestId?: string(name='RequestId'),
}
model DeleteClientCertificateResponse = {
headers: map[string]string(name='headers'),
body: DeleteClientCertificateResponseBody(name='body'),
}
async function deleteClientCertificateWithOptions(request: DeleteClientCertificateRequest, runtime: Util.RuntimeOptions): DeleteClientCertificateResponse {
Util.validateModel(request);
var query = {};
query["Identifier"] = request.identifier;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'DeleteClientCertificate',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function deleteClientCertificate(request: DeleteClientCertificateRequest): DeleteClientCertificateResponse {
var runtime = new Util.RuntimeOptions{};
return deleteClientCertificateWithOptions(request, runtime);
}
model DescribeCACertificateRequest {
identifier?: string(name='Identifier'),
}
model DescribeCACertificateResponseBody = {
requestId?: string(name='RequestId'),
certificate?: {
years?: int32(name='Years'),
status?: string(name='Status'),
serialNumber?: string(name='SerialNumber'),
certificateType?: string(name='CertificateType'),
algorithm?: string(name='Algorithm'),
state?: string(name='State'),
organization?: string(name='Organization'),
parentIdentifier?: string(name='ParentIdentifier'),
locality?: string(name='Locality'),
identifier?: string(name='Identifier'),
sans?: string(name='Sans'),
keySize?: int32(name='KeySize'),
x509Certificate?: string(name='X509Certificate'),
subjectDN?: string(name='SubjectDN'),
signAlgorithm?: string(name='SignAlgorithm'),
organizationUnit?: string(name='OrganizationUnit'),
afterDate?: long(name='AfterDate'),
sha2?: string(name='Sha2'),
commonName?: string(name='CommonName'),
md5?: string(name='Md5'),
countryCode?: string(name='CountryCode'),
beforeDate?: long(name='BeforeDate'),
}(name='Certificate'),
}
model DescribeCACertificateResponse = {
headers: map[string]string(name='headers'),
body: DescribeCACertificateResponseBody(name='body'),
}
async function describeCACertificateWithOptions(request: DescribeCACertificateRequest, runtime: Util.RuntimeOptions): DescribeCACertificateResponse {
Util.validateModel(request);
var query = {};
query["Identifier"] = request.identifier;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'DescribeCACertificate',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function describeCACertificate(request: DescribeCACertificateRequest): DescribeCACertificateResponse {
var runtime = new Util.RuntimeOptions{};
return describeCACertificateWithOptions(request, runtime);
}
model DescribeCACertificateCountResponseBody = {
totalCount?: int32(name='TotalCount'),
requestId?: string(name='RequestId'),
}
model DescribeCACertificateCountResponse = {
headers: map[string]string(name='headers'),
body: DescribeCACertificateCountResponseBody(name='body'),
}
async function describeCACertificateCountWithOptions(runtime: Util.RuntimeOptions): DescribeCACertificateCountResponse {
var req = new OpenApi.OpenApiRequest{};
var params = new OpenApi.Params{
action = 'DescribeCACertificateCount',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function describeCACertificateCount(): DescribeCACertificateCountResponse {
var runtime = new Util.RuntimeOptions{};
return describeCACertificateCountWithOptions(runtime);
}
model DescribeCACertificateListRequest {
currentPage?: int32(name='CurrentPage'),
showSize?: int32(name='ShowSize'),
}
model DescribeCACertificateListResponseBody = {
currentPage?: int32(name='CurrentPage'),
requestId?: string(name='RequestId'),
totalCount?: int32(name='TotalCount'),
pageCount?: int32(name='PageCount'),
showSize?: int32(name='ShowSize'),
certificateList?: [
{
years?: int32(name='Years'),
status?: string(name='Status'),
serialNumber?: string(name='SerialNumber'),
certificateType?: string(name='CertificateType'),
algorithm?: string(name='Algorithm'),
state?: string(name='State'),
organization?: string(name='Organization'),
parentIdentifier?: string(name='ParentIdentifier'),
locality?: string(name='Locality'),
identifier?: string(name='Identifier'),
sans?: string(name='Sans'),
keySize?: int32(name='KeySize'),
x509Certificate?: string(name='X509Certificate'),
subjectDN?: string(name='SubjectDN'),
signAlgorithm?: string(name='SignAlgorithm'),
organizationUnit?: string(name='OrganizationUnit'),
afterDate?: long(name='AfterDate'),
sha2?: string(name='Sha2'),
commonName?: string(name='CommonName'),
md5?: string(name='Md5'),
countryCode?: string(name='CountryCode'),
beforeDate?: long(name='BeforeDate'),
}
](name='CertificateList'),
}
model DescribeCACertificateListResponse = {
headers: map[string]string(name='headers'),
body: DescribeCACertificateListResponseBody(name='body'),
}
async function describeCACertificateListWithOptions(request: DescribeCACertificateListRequest, runtime: Util.RuntimeOptions): DescribeCACertificateListResponse {
Util.validateModel(request);
var query = {};
query["CurrentPage"] = request.currentPage;
query["ShowSize"] = request.showSize;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'DescribeCACertificateList',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function describeCACertificateList(request: DescribeCACertificateListRequest): DescribeCACertificateListResponse {
var runtime = new Util.RuntimeOptions{};
return describeCACertificateListWithOptions(request, runtime);
}
model DescribeClientCertificateRequest {
identifier?: string(name='Identifier'),
}
model DescribeClientCertificateResponseBody = {
requestId?: string(name='RequestId'),
certificate?: {
status?: string(name='Status'),
serialNumber?: string(name='SerialNumber'),
certificateType?: string(name='CertificateType'),
algorithm?: string(name='Algorithm'),
state?: string(name='State'),
organization?: string(name='Organization'),
parentIdentifier?: string(name='ParentIdentifier'),
locality?: string(name='Locality'),
identifier?: string(name='Identifier'),
sans?: string(name='Sans'),
days?: int32(name='Days'),
keySize?: int32(name='KeySize'),
x509Certificate?: string(name='X509Certificate'),
subjectDN?: string(name='SubjectDN'),
signAlgorithm?: string(name='SignAlgorithm'),
organizationUnit?: string(name='OrganizationUnit'),
afterDate?: long(name='AfterDate'),
sha2?: string(name='Sha2'),
commonName?: string(name='CommonName'),
md5?: string(name='Md5'),
countryCode?: string(name='CountryCode'),
beforeDate?: long(name='BeforeDate'),
}(name='Certificate'),
}
model DescribeClientCertificateResponse = {
headers: map[string]string(name='headers'),
body: DescribeClientCertificateResponseBody(name='body'),
}
async function describeClientCertificateWithOptions(request: DescribeClientCertificateRequest, runtime: Util.RuntimeOptions): DescribeClientCertificateResponse {
Util.validateModel(request);
var query = {};
query["Identifier"] = request.identifier;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'DescribeClientCertificate',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function describeClientCertificate(request: DescribeClientCertificateRequest): DescribeClientCertificateResponse {
var runtime = new Util.RuntimeOptions{};
return describeClientCertificateWithOptions(request, runtime);
}
model DescribeClientCertificateForSerialNumberRequest {
serialNumber?: string(name='SerialNumber'),
}
model DescribeClientCertificateForSerialNumberResponseBody = {
requestId?: string(name='RequestId'),
certificateList?: [
{
years?: int32(name='Years'),
status?: string(name='Status'),
serialNumber?: string(name='SerialNumber'),
algorithm?: string(name='Algorithm'),
state?: string(name='State'),
organization?: string(name='Organization'),
locality?: string(name='Locality'),
identifier?: string(name='Identifier'),
sans?: string(name='Sans'),
keySize?: int32(name='KeySize'),
x509Certificate?: string(name='X509Certificate'),
subjectDN?: string(name='SubjectDN'),
signAlgorithm?: string(name='SignAlgorithm'),
organizationUnit?: string(name='OrganizationUnit'),
afterDate?: string(name='AfterDate'),
sha2?: string(name='Sha2'),
commonName?: string(name='CommonName'),
md5?: string(name='Md5'),
countryCode?: string(name='CountryCode'),
beforeDate?: string(name='BeforeDate'),
}
](name='CertificateList'),
}
model DescribeClientCertificateForSerialNumberResponse = {
headers: map[string]string(name='headers'),
body: DescribeClientCertificateForSerialNumberResponseBody(name='body'),
}
async function describeClientCertificateForSerialNumberWithOptions(request: DescribeClientCertificateForSerialNumberRequest, runtime: Util.RuntimeOptions): DescribeClientCertificateForSerialNumberResponse {
Util.validateModel(request);
var query = {};
query["SerialNumber"] = request.serialNumber;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'DescribeClientCertificateForSerialNumber',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function describeClientCertificateForSerialNumber(request: DescribeClientCertificateForSerialNumberRequest): DescribeClientCertificateForSerialNumberResponse {
var runtime = new Util.RuntimeOptions{};
return describeClientCertificateForSerialNumberWithOptions(request, runtime);
}
model DescribeClientCertificateStatusRequest {
identifier?: string(name='Identifier'),
}
model DescribeClientCertificateStatusResponseBody = {
requestId?: string(name='RequestId'),
certificateStatus?: [
{
serialNumber?: string(name='SerialNumber'),
status?: string(name='Status'),
revokeTime?: long(name='RevokeTime'),
}
](name='CertificateStatus'),
}
model DescribeClientCertificateStatusResponse = {
headers: map[string]string(name='headers'),
body: DescribeClientCertificateStatusResponseBody(name='body'),
}
async function describeClientCertificateStatusWithOptions(request: DescribeClientCertificateStatusRequest, runtime: Util.RuntimeOptions): DescribeClientCertificateStatusResponse {
Util.validateModel(request);
var query = {};
query["Identifier"] = request.identifier;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'DescribeClientCertificateStatus',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function describeClientCertificateStatus(request: DescribeClientCertificateStatusRequest): DescribeClientCertificateStatusResponse {
var runtime = new Util.RuntimeOptions{};
return describeClientCertificateStatusWithOptions(request, runtime);
}
model DescribeClientCertificateStatusForSerialNumberRequest {
serialNumber?: string(name='SerialNumber'),
}
model DescribeClientCertificateStatusForSerialNumberResponseBody = {
requestId?: string(name='RequestId'),
certificateStatus?: [
{
serialNumber?: string(name='SerialNumber'),
status?: string(name='Status'),
revokeTime?: long(name='RevokeTime'),
}
](name='CertificateStatus'),
}
model DescribeClientCertificateStatusForSerialNumberResponse = {
headers: map[string]string(name='headers'),
body: DescribeClientCertificateStatusForSerialNumberResponseBody(name='body'),
}
async function describeClientCertificateStatusForSerialNumberWithOptions(request: DescribeClientCertificateStatusForSerialNumberRequest, runtime: Util.RuntimeOptions): DescribeClientCertificateStatusForSerialNumberResponse {
Util.validateModel(request);
var query = {};
query["SerialNumber"] = request.serialNumber;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'DescribeClientCertificateStatusForSerialNumber',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function describeClientCertificateStatusForSerialNumber(request: DescribeClientCertificateStatusForSerialNumberRequest): DescribeClientCertificateStatusForSerialNumberResponse {
var runtime = new Util.RuntimeOptions{};
return describeClientCertificateStatusForSerialNumberWithOptions(request, runtime);
}
model GetCAInstanceStatusRequest {
instanceId?: string(name='InstanceId'),
}
model GetCAInstanceStatusResponseBody = {
requestId?: string(name='RequestId'),
instanceStatusList?: [
{
certTotalCount?: int32(name='CertTotalCount'),
status?: string(name='Status'),
type?: string(name='Type'),
certIssuedCount?: int32(name='CertIssuedCount'),
beforeTime?: long(name='BeforeTime'),
identifier?: string(name='Identifier'),
afterTime?: long(name='AfterTime'),
instanceId?: string(name='InstanceId'),
useExpireTime?: long(name='UseExpireTime'),
}
](name='InstanceStatusList'),
}
model GetCAInstanceStatusResponse = {
headers: map[string]string(name='headers'),
body: GetCAInstanceStatusResponseBody(name='body'),
}
async function getCAInstanceStatusWithOptions(request: GetCAInstanceStatusRequest, runtime: Util.RuntimeOptions): GetCAInstanceStatusResponse {
Util.validateModel(request);
var query = {};
query["InstanceId"] = request.instanceId;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'GetCAInstanceStatus',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function getCAInstanceStatus(request: GetCAInstanceStatusRequest): GetCAInstanceStatusResponse {
var runtime = new Util.RuntimeOptions{};
return getCAInstanceStatusWithOptions(request, runtime);
}
model ListCACertificateLogRequest {
identifier?: string(name='Identifier'),
}
model ListCACertificateLogResponseBody = {
requestId?: string(name='RequestId'),
logList?: [
{
identifier?: string(name='Identifier'),
content?: string(name='Content'),
createTime?: long(name='CreateTime'),
opType?: string(name='OpType'),
}
](name='LogList'),
}
model ListCACertificateLogResponse = {
headers: map[string]string(name='headers'),
body: ListCACertificateLogResponseBody(name='body'),
}
async function listCACertificateLogWithOptions(request: ListCACertificateLogRequest, runtime: Util.RuntimeOptions): ListCACertificateLogResponse {
Util.validateModel(request);
var query = {};
query["Identifier"] = request.identifier;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'ListCACertificateLog',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function listCACertificateLog(request: ListCACertificateLogRequest): ListCACertificateLogResponse {
var runtime = new Util.RuntimeOptions{};
return listCACertificateLogWithOptions(request, runtime);
}
model ListClientCertificateRequest {
currentPage?: int32(name='CurrentPage'),
showSize?: int32(name='ShowSize'),
}
model ListClientCertificateResponseBody = {
currentPage?: int32(name='CurrentPage'),
requestId?: string(name='RequestId'),
totalCount?: int32(name='TotalCount'),
pageCount?: int32(name='PageCount'),
showSize?: int32(name='ShowSize'),
certificateList?: [
{
status?: string(name='Status'),
serialNumber?: string(name='SerialNumber'),
certificateType?: string(name='CertificateType'),
algorithm?: string(name='Algorithm'),
state?: string(name='State'),
organization?: string(name='Organization'),
parentIdentifier?: string(name='ParentIdentifier'),
locality?: string(name='Locality'),
identifier?: string(name='Identifier'),
sans?: string(name='Sans'),
days?: int32(name='Days'),
keySize?: int32(name='KeySize'),
x509Certificate?: string(name='X509Certificate'),
subjectDN?: string(name='SubjectDN'),
signAlgorithm?: string(name='SignAlgorithm'),
organizationUnit?: string(name='OrganizationUnit'),
afterDate?: long(name='AfterDate'),
sha2?: string(name='Sha2'),
commonName?: string(name='CommonName'),
md5?: string(name='Md5'),
countryCode?: string(name='CountryCode'),
beforeDate?: long(name='BeforeDate'),
}
](name='CertificateList'),
}
model ListClientCertificateResponse = {
headers: map[string]string(name='headers'),
body: ListClientCertificateResponseBody(name='body'),
}
async function listClientCertificateWithOptions(request: ListClientCertificateRequest, runtime: Util.RuntimeOptions): ListClientCertificateResponse {
Util.validateModel(request);
var query = {};
query["CurrentPage"] = request.currentPage;
query["ShowSize"] = request.showSize;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'ListClientCertificate',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function listClientCertificate(request: ListClientCertificateRequest): ListClientCertificateResponse {
var runtime = new Util.RuntimeOptions{};
return listClientCertificateWithOptions(request, runtime);
}
model ListRevokeCertificateRequest {
currentPage?: int32(name='CurrentPage'),
showSize?: int32(name='ShowSize'),
}
model ListRevokeCertificateResponseBody = {
currentPage?: int32(name='CurrentPage'),
requestId?: string(name='RequestId'),
totalCount?: int32(name='TotalCount'),
pageCount?: int32(name='PageCount'),
showSize?: int32(name='ShowSize'),
certificateList?: [
{
serialNumber?: string(name='SerialNumber'),
algorithm?: string(name='Algorithm'),
state?: string(name='State'),
organization?: string(name='Organization'),
locality?: string(name='Locality'),
revokeDate?: string(name='RevokeDate'),
identifier?: string(name='Identifier'),
sans?: string(name='Sans'),
keySize?: int32(name='KeySize'),
subjectDN?: string(name='SubjectDN'),
signAlgorithm?: string(name='SignAlgorithm'),
organizationUnit?: string(name='OrganizationUnit'),
afterDate?: string(name='AfterDate'),
sha2?: string(name='Sha2'),
commonName?: string(name='CommonName'),
md5?: string(name='Md5'),
countryCode?: string(name='CountryCode'),
beforeDate?: string(name='BeforeDate'),
}
](name='CertificateList'),
}
model ListRevokeCertificateResponse = {
headers: map[string]string(name='headers'),
body: ListRevokeCertificateResponseBody(name='body'),
}
async function listRevokeCertificateWithOptions(request: ListRevokeCertificateRequest, runtime: Util.RuntimeOptions): ListRevokeCertificateResponse {
Util.validateModel(request);
var query = {};
query["CurrentPage"] = request.currentPage;
query["ShowSize"] = request.showSize;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'ListRevokeCertificate',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function listRevokeCertificate(request: ListRevokeCertificateRequest): ListRevokeCertificateResponse {
var runtime = new Util.RuntimeOptions{};
return listRevokeCertificateWithOptions(request, runtime);
}
model UpdateCACertificateStatusRequest {
identifier?: string(name='Identifier'),
status?: string(name='Status'),
}
model UpdateCACertificateStatusResponseBody = {
requestId?: string(name='RequestId'),
}
model UpdateCACertificateStatusResponse = {
headers: map[string]string(name='headers'),
body: UpdateCACertificateStatusResponseBody(name='body'),
}
async function updateCACertificateStatusWithOptions(request: UpdateCACertificateStatusRequest, runtime: Util.RuntimeOptions): UpdateCACertificateStatusResponse {
Util.validateModel(request);
var query = {};
query["Identifier"] = request.identifier;
query["Status"] = request.status;
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
body = Util.toMap(request),
};
var params = new OpenApi.Params{
action = 'UpdateCACertificateStatus',
version = '2020-06-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'json',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function updateCACertificateStatus(request: UpdateCACertificateStatusRequest): UpdateCACertificateStatusResponse {
var runtime = new Util.RuntimeOptions{};
return updateCACertificateStatusWithOptions(request, runtime);
}
| Tea | 5 | aliyun/alibabacloud-sdk | cas-20200630/main.tea | [
"Apache-2.0"
] |
div .foo.svelte-xyz{color:red}div>.foo.svelte-xyz{font-weight:bold} | CSS | 3 | Theo-Steiner/svelte | test/css/samples/local-inside-global/expected.css | [
"MIT"
] |
use Getopt::Std;
use Datascope;
use atws_mwp ':all';
use Tk;
use Tk::LineGraph;
use Tk::LineGraphDataset;
my $curStation = 0;
my $tmpdatabase = "/tmp/mwp_DB";
my @stations;
my @chans;
my @starttimes = 0;
my @endtimes = 0;
my @sta_dat;
my @sta_mag;
my @sta_mom;
my @sta_xarr;
my @dat;
my @mag;
my @mom;
if($#ARGV == 1)
{
$database = $ARGV[0];
$orid = $ARGV[1];
}
elsif($#ARGV == 5)
{
$database = $ARGV[0];
$orid = $ARGV[1];
$stations[0] = $ARGV[2];
$chans[0] = $ARGV[3];
$starttimes[0] = $ARGV[4];
$endtimes[0] = $ARGV[5];
}
else
{
print "Wrong number of arguments supplied.\n";
print "You must supply DBPath, origin id, sta, chan, starttime, endtime.\n";
exit 0;
}
my $mw = MainWindow->new;
@db = dbopen($database,"r+");
dbcreate($tmpdatabase, "css3.0","/tmp/", 0, 0);
@tmpdb = dbopen($tmpdatabase,"r+");
if(!length($stations[0]))
{
@db_assoc = dblookup(@db, 0, "assoc", 0, 0);
@db_assoc = dbsubset(@db_assoc,"orid == $orid");
@db_arrival = dblookup(@db, 0, "arrival", 0, 0);
@dbs = dbjoin(@db_assoc, @db_arrival);
@dbs = dbsubset(@dbs, "chan != 'SHZ'");
@dbs = dbsort(@dbs, "delta");
$no_records_join = dbquery (@dbs,"dbRECORD_COUNT") ;
print "Records Found = $no_records_join\n";
for($i = 0; $i < $no_records_join; $i++)
{
$dbs[3]=$i;
($sta,$chn,$time, $dlt) = dbgetv(@dbs,"sta","chan","arrival.time", "delta");
$stations[$i] = $sta;
$chans[$i] = $chn;
$starttimes[$i] = int($time - 10);
$endtimes[$i] = int($time + 120);
$delta[$i] = sprintf(" Delta:%.1f", $dlt);
}
}
$x = 0;
foreach $sta (@stations)
{
@dbf = dblookup(@db, 0, "wfdisc", 0, 0);
@dbwf = dbsubset(@dbf,"sta == \"$sta\" && chan == \"${chans[$x]}\"");
$no_records_join = dbquery (@dbwf,"dbRECORD_COUNT") ;
print "Records Found = $no_records_join\n";
if($no_records_join < 1)
{
$x++;
print "No Records found for STA: $sta\n";
next;
}
(@values) = mwp_prepare($dbwf[0] ,$dbwf[1],$dbwf[2],$dbwf[3], $orid, $sta, $starttimes[$x],$endtimes[$x]);
$i = 0;
$nrecs = (scalar @values);
# print DBG "MWP run at ". now() . " for " . $chans[$x] . " times=${starttimes[$x]},${endtimes[$x]}\n";
for($i = 0; $i < $nrecs; undef)
{
# print DBG ($i / 3) . ", " . $values[$i + 0] . ", " . $values[$i + 1] . ", " . $values[$i + 2] . "\n";
push @{$sta_dat[$x]}, $values[$i];$i++;
$values[$i] = 0 if($values[$i] < 0);
push @{$sta_mag[$x]}, $values[$i];$i++;
push @{$sta_mom[$x]}, $values[$i];$i++;
push @{$sta_xarr[$x]}, ($i/3);
}
$stamwp[$x] = -999.0;
$stapnt[$x] = 0;
$x++;
}
for($x = 0; $x < scalar @sta_dat; $x++)
{
$num_mom = scalar @{$sta_mom[$x]};
$min_mom = 9e99;
$max_mom = -9e99;
if($num_mom == 1)
{
next;
}
for($i = 0; $i < $num_mom; $i++)
{
$min_mom = $sta_mom[$x][$i] if($sta_mom[$x][$i] < $min_mom);
$max_mom = $sta_mom[$x][$i] if($sta_mom[$x][$i] > $max_mom);
}
print "Moment = $min_mom -> $max_mom\n";
if(($min_mom > -9e99) && ($max_mom < 9e99))
{
$range = $max_mom - $min_mom;
$scale = ($range) ? 10.0 / ($max_mom - $min_mom) : 1;
}
else
{
$scale = 1;
}
# open(DBG, ">/tmp/mwp/${stations[$x]}_${orid}_dbg.txt");
for($i = 0; $i < $num_mom; $i++)
{
$sta_mom[$x][$i] -= $min_mom;
$sta_mom[$x][$i] *= $scale;
# print DBG "$i,${sta_mag[$x][$i]},${sta_mom[$x][$i]}\n";
}
# close(DBG);
}
my $cp = $mw->LineGraph
(
-height => 600,
-width => 800,
background => 'snow1',
)->grid;
$cp->Tk::bind("<Button-1>" , "" );
$cp->Tk::bind("<ButtonRelease-1>" , "" );
$cp->Tk::bind("<B1-Motion>" , "" );
$cp->Tk::bind("<Button-2>" , "" );
$cp->Tk::bind("<ButtonRelease-2>" , "" );
$cp->Tk::bind("<ButtonRelease-1>" , [ \&markMag, 1 ] );
$mw->Tk::bind("<Escape>" , [ sub {$mw->destroy}, 1 ] );
$cp->Tk::bind("<Button-2>" , [ \&Tk::LineGraph::zoom, 0 ] );
$cp->Tk::bind("<ButtonRelease-2>" , [ \&Tk::LineGraph::zoom, 1 ] );
$cp->Tk::bind("<B2-Motion>" , [ \&Tk::LineGraph::zoom, 2 ] );
my $ds1 = LineGraphDataset->new(-yData=>\@{$sta_dat[0]}, -xData=>\@{$sta_xarr[0]}, -yAxis=>"Y1", -name=>"velocity(nm/s)");
$cp->addDatasets(-dataset=>$ds1);
my $ds2 = LineGraphDataset->new(-yData=>\@{$sta_mag[0]}, -xData=>\@{$sta_xarr[0]}, -yAxis=>"Y", -name=>"magnitude");
$cp->addDatasets(-dataset=>$ds2);
my $ds3 = LineGraphDataset->new(-yData=>\@{$sta_mom[0]}, -xData=>\@{$sta_xarr[0]}, -yAxis=>"Y", -name=>"moment");
$cp->addDatasets(-dataset=>$ds3);
my $menubar = $mw->cget("-menu");
#my $fileMenu = $menubar->cascade(-label => 'File',-tearoff=>0);
if(scalar @stations > 1)
{
$menubar->command(-label=>'Back',-command=> [ \&prevSta, 0]);
$menubar->command(-label=>'Next',-command=> [ \&nextSta, 0]);
$menubar->command(-label=>'Save Netmag',-command=> [ \&saveNetMag, 0]);
}
else
{
$menubar->command(-label=>'Save Stamag',-command=> [ \&saveStaMag, 0]);
}
$menubar->command(-label=>'Quit',-command=> [ \&exit, 0]);
$starttimes[0] = sprintf("%.1f",$starttimes[0]);
$endtimes[0] = sprintf("%.1f",$endtimes[0]);
my $p = $cp->cget('-plotTitle');
$p->[0] = "Station " . ($curStation + 1) . "/" . (scalar @stations) . " --> ${stations[$curStation]}:${chans[$curStation]}${delta[$curStation]} from ${starttimes[$curStation]} to ${endtimes[$curStation]}";
$p->[1] = 4;
$cp->configure('-plotTitle' => $p);
$cp->configure('-xlabel' => "Sample Number");
$cp->configure('-ylabel' => "Magnitude");
$cp->configure('-y1label' => "Velocity nm/s");
$cp->plot();
MainLoop;
sub markMag
{
my $self = shift;
my $e = $cp->XEvent;
($xC,$yC) = ($e->x, $e->y);
my($xW, $yW, $y1W) = $cp->toWorldPoints($xC, $yC);
$xW = int($xW);
($lne) = $cp->find( "withtag", "pointer" );
$dp = $cp->{'-datasets'}[1]->get('-yData');
@ds = @{$dp};
$stamwp[$curStation] = sprintf("%01.3f", $ds[$xW]);
$stapnt[$curStation] = $e->x;
if(!defined($lne))
{
$cp->createLine($e->x, 25, $e->x, 500, -fill => 'black', -tags => 'pointer');
}
else
{
($oldx, $oldy) = $cp->coords("pointer");
$cp->move("pointer", ($e->x - $oldx), 0);
}
}
sub saveStaMag
{
if($stamwp[$curStation] > 0)
{
#print "Saving Sta Mag: $stamag\n";
@db_stamag = dblookup(@tmpdb, 0, "stamag", 0, 0);
@db_stamag2 = dbsubset(@db_stamag, "(orid == $orid && sta == '${stations[0]}' && magtype == 'Mwp')");
$no_records_join = dbquery (@db_stamag2,"dbRECORD_COUNT") ;
#print "Records Found = $no_records_join\n";
$name = getlogin;
if($no_records_join < 1)
{
dbaddv(@db_stamag, "magid", 0, "sta", "${stations[0]}", "orid", $orid, "magtype", "Mwp", "magnitude", $stamwp[$curStation], "auth", $name );
#print "Added New Record\n";
}
else
{
$recnum = dbfind(@db_stamag, "(orid == $orid && sta == '${stations[0]}' && magtype == 'Mwp')", -1);
if($recnum >= 0)
{
$db_stamag[3] = $recnum;
}
dbputv(@db_stamag, "magtype", "Mwp", "magnitude", $stamwp[$curStation], "auth", $name );
#print "Updated Existing Record\n";
}
exit;
}
}
sub saveNetMag
{
$mwpcnt = 0;
$mwpavg = 0;
$mwptot = 0;
$mwpdev = 0;
my %results;
@db_netmag = dblookup(@tmpdb, 0, "netmag", 0, 0);
@db_netmag2 = dbsubset(@db_netmag, "(orid == $orid && magtype == 'Mwp')");
$nrec = dbquery (@db_netmag2,"dbRECORD_COUNT");
if($nrec)
{
$db_netmag2[3] = 0;
($magid) = dbgetv(@db_netmag2,"magid");
$oldnetmag = 1;
}
else
{
$magid = dbnextid(@tmpdb, "magid");
$oldnetmag = 0;
}
@db_stamag = dblookup(@tmpdb, 0, "stamag", 0, 0);
@db_stamag2 = dbsubset(@db_stamag, "(orid == $orid && magid == $magid)");
$nrec = dbquery(@db_stamag2, "dbRECORD_COUNT");
for($x = 0; $x < $nrec; $x++)
{
$db_stamag2[3] = $x;
($sta, $mag, $auth) = dbgetv(@db_stamag2, "sta", "magnitude", "auth");
$results{$sta}{"mag"} = $mag;
$results{$sta}{"auth"} = $auth;
}
for ($x = 0; $x < scalar @stations; $x++)
{
if($stamwp[$x] > 0.0)
{
$results{$stations[$x]}{"mag"} = $stamwp[$x];
$results{$stations[$x]}{"auth"} = getlogin;
}
}
foreach $sta (keys %results)
{
print "Station $sta: Magnitude = ${results{$sta}{'mag'}}\n";
$mwpcnt++;
$mwptot += $results{$sta}{'mag'};
}
if($mwpcnt)
{
$mwpavg = sprintf("%01.3f", $mwptot / $mwpcnt);
foreach $sta (keys %results)
{
$mwpdev += (($mwpavg - $results{$sta}{'mag'}) * ($mwpavg - $results{$sta}{'mag'}));
}
$mwpdev = sprintf("%01.3f", sqrt($mwpdev / $mwpcnt));
}
print "Network Magnitude is $mwpavg from $mwpcnt Stations, Uncertainty = $mwpdev\n";
# find the event ID
@db_origin = dblookup(@db, 0, "origin", 0, 0);
@db_origin = dbsubset(@db_origin, "orid == $orid");
$db_origin[3] = 0;
($evid) = dbgetv(@db_origin, "evid");
#save netmag row
if ($oldnetmag)
{
$nm_rec = dbfind(@db_netmag, "magid == $magid", -1);
$db_netmag[3] = $nm_rec;
#print "Putting Netmag For $magid\@$nm_rec\n";
dbputv(@db_netmag, "magid", $magid, "orid", $orid, "evid", $evid, "magtype", "Mwp", "nsta", $mwpcnt, "magnitude", $mwpavg, "uncertainty", $mwpdev, "auth", getlogin);
}
else
{
dbaddv(@db_netmag,"magid", $magid, "orid", $orid, "evid", $evid, "magtype", "Mwp", "nsta", $mwpcnt, "magnitude", $mwpavg, "uncertainty", $mwpdev, "auth", getlogin);
}
foreach $sta (keys %results)
{
$nm_rec = dbfind(@db_stamag, "(orid == $orid && sta == '$sta' && magtype == 'Mwp')", -1);
if($nm_rec >= 0)
{
$db_stamag[3] = $nm_rec;
#print "Putting Stamag For $magid:$sta\@$nm_rec\n";
dbputv(@db_stamag, "magid", $magid, "orid", $orid, "evid", $evid, "magtype", "Mwp", "sta", $sta, "magnitude", $results{$sta}{'mag'}, "auth", $results{$sta}{'auth'});
}
else
{
dbaddv(@db_stamag, "magid", $magid, "orid", $orid, "evid", $evid, "magtype", "Mwp", "sta", $sta, "magnitude", $results{$sta}{'mag'}, "auth", $results{$sta}{'auth'});
}
}
}
sub prevSta
{
#print "curstation = $curStation (${stations[$curStation]})\n";
$curStation--;
$curStation = ((scalar @stations) - 1) if($curStation < 0);
$cp->{'-datasets'}[0]->set(-yData => \@{$sta_dat[$curStation]}, -xData=>\@{$sta_xarr[$curStation]});
$cp->{'-datasets'}[1]->set(-yData => \@{$sta_mag[$curStation]}, -xData=>\@{$sta_xarr[$curStation]});
$cp->{'-datasets'}[2]->set(-yData => \@{$sta_mom[$curStation]}, -xData=>\@{$sta_xarr[$curStation]});
my $p = $cp->cget('-plotTitle');
$p->[0] = "Station " . ($curStation + 1) . "/" . (scalar @stations) . " --> ${stations[$curStation]}:${chans[$curStation]}${delta[$curStation]} from ${starttimes[$curStation]} to ${endtimes[$curStation]}";
$p->[1] = 4;
$cp->configure('-plotTitle' => $p);
$cp->plot();
if($stapnt[$curStation])
{
$cp->createLine($stapnt[$curStation], 25, $stapnt[$curStation], 500, -fill => 'black', -tags => 'pointer');
}
#print "curstation = $curStation (${stations[$curStation]})\n";
}
sub nextSta
{
#print "curstation = $curStation (${stations[$curStation]})\n";
$curStation++;
$curStation = 0 if ($curStation == (scalar @stations));
$cp->{'-datasets'}[0]->set(-yData => \@{$sta_dat[$curStation]}, -xData=>\@{$sta_xarr[$curStation]});
$cp->{'-datasets'}[1]->set(-yData => \@{$sta_mag[$curStation]}, -xData=>\@{$sta_xarr[$curStation]});
$cp->{'-datasets'}[2]->set(-yData => \@{$sta_mom[$curStation]}, -xData=>\@{$sta_xarr[$curStation]});
my $p = $cp->cget('-plotTitle');
$p->[0] = "Station " . ($curStation + 1) . "/" . (scalar @stations) . " --> ${stations[$curStation]}:${chans[$curStation]}${delta[$curStation]} from ${starttimes[$curStation]} to ${endtimes[$curStation]}";
$p->[1] = 4;
$cp->configure('-plotTitle' => $p);
$cp->plot();
if($stapnt[$curStation])
{
$cp->createLine($stapnt[$curStation], 25, $stapnt[$curStation], 500, -fill => 'black', -tags => 'pointer');
}
#print "curstation = $curStation (${stations[$curStation]})\n";
}
| XProc | 4 | jreyes1108/antelope_contrib | bin/magnitude/atws_calc_mwp/atws_calc_mwp.xpl | [
"BSD-2-Clause",
"MIT"
] |
{% skip_file unless flag?(:preview_mt) %}
private SPEC_TIMEOUT = 15.seconds
Spec.around_each do |example|
done = Channel(Exception?).new
spawn(same_thread: true) do
begin
example.run
rescue e
done.send(e)
else
done.send(nil)
end
end
select
when res = done.receive
raise res if res
when timeout(SPEC_TIMEOUT)
_it = example.example
ex = Spec::AssertionFailed.new("spec timeout", _it.file, _it.line)
_it.parent.report(:fail, _it.description, _it.file, _it.line, SPEC_TIMEOUT, ex)
end
end
| Crystal | 3 | n00p3/crystal | spec/support/mt_abort_timeout.cr | [
"Apache-2.0"
] |
~
// Reading from Busses
In.ar(0, 1); // this will return an OutputProxy
In.ar(0, 4); // this will return an Array of 4 OutputProxys.
// Writing to Busses
// This throws an error. Can't write a control rate signal to an audio rate bus.
{ Out.ar(0, SinOsc.kr)}.play;
// The first busses are the output busses. On a stereo system, they are 0 and 1.
{ Out.ar(0, SinOsc.ar)}.play;
{ Out.ar(1, SinOsc.ar)}.play;
// Redirecting
// Randomly picking bus 18 (use Bus object to allocate for you).
// Note the order matters. If you run them in reverse order, you hear nothing.
{ Out.ar(0, In.ar(18)); }.play;
{ Out.ar(18, SinOsc.ar); }.play;
~s1 = SynthDef(\redirect_test, { Out.ar(0, In.ar(18)) });
~s1.add;
r = Synth(\redirect_test);
~s2 = SynthDef(\redirect_sound, { Out.ar(18, SinOsc.ar) });
~s2.after(~s1);
s = Synth(\redirect_sound);
//
// From a Gentle Introduction to SuperCollider
//
// Warning: use headphones to avoid feedback
{SoundIn.ar(0)}.play; // same as In.ar(8): takes sound from the first input bus
// Stereo version
{SoundIn.ar([0, 1])}.play; // first and second inputs
// Some reverb just for fun?
{FreeVerb.ar(SoundIn.ar([0, 1]), mix: 0.5, room: 0.9)}.play;
// The Bus object
// Run this first ('turn reverb on'−−you won't hear anything at first)
(
r = {
Out.ar(0, FreeVerb.ar(
In.ar(18, 2),
mix: 0.5,
room: 0.9,
mul: 0.4)
)}.play;
)
// Now run this second ('feed the busy tone into the reverb bus')
(
a = {
Out.ar(18,
SinOsc.ar([800, 880],
mul: LFPulse.ar(2)))
}.play;
)
a.free;
// now the same thing using a Bus object so we don't have to keep track of the Bus numbers ourself
// create the bus
~myBus = Bus.audio(s, 2);
// turn on the reverb: read fro myBus (source sound)
(
r = {
Out.ar(0, FreeVerb.ar(
In.ar(~myBus, 2),
mix: 0.5,
room: 0.9,
mul: 0.4))
}.play;
)
// feed the busy tone into ~myBus
(
b = {
Out.ar(~myBus, SinOsc.ar(
[800, 880],
mul: LFPulse.ar(2)))
}.play;
)
// free both synths
r.free; b.free;
// Reading from Busses
// The next busses are the input. On a stereo output system, the first two input indicies are 2 and 3.
{ [In.ar(2), In.ar(3)] }.scope;
// This will work as the audio rate signal is downsampled to control rate.
{ Out.kr(0, SinOsc.ar)}.scope;
//
// Using a bus to apply an effect to a signal coming from a bus.
//
// start the effect
(
f = {
Out.ar(0, BPF.ar(
in: In.ar(55),
freq: MouseY.kr(1000, 5000),
rq: 0.1)
)
}.play;
)
// start the source
~n1 = {Out.ar(55, WhiteNoise.ar(0.5))}.play();
~n2 = {Out.ar(55, SinOsc.ar(880, 0.5))}.play;
~n1.free
~n2.free
// When multiple Synths write to the same bus, their output is summed (i.e. mixed).
(
SynthDef("tutorial-args", { arg freq = 440, out = 0;
Out.ar(out, SinOsc.ar(freq, 0, 0.2));
}).add;
)
// both write to bus 1, and their output is mixed
x = Synth("tutorial-args", ["out", 1, "freq", 660]);
y = Synth("tutorial-args", ["out", 1, "freq", 770]);
free(x); free(y);
// Creating a Bus Object
// Using Bus objects frees you having having to manage bus indicies yourself.
b = Bus.control(s, 2); // Get a two channel control Bus
c = Bus.audio(s); // Get a one channel private audio Bus (one is the default)
(
SynthDef.new("tutorial-SinOsc-stereo", { var outArray;
outArray = [SinOsc.ar(440, 0, 0.2), SinOsc.ar(442, 0, 0.2)];
Out.ar(0, outArray); // writes to busses 0 and 1
}).play;
)
s.reboot; // restart the server and thus reset bus allocators
b = Bus.control(s, 2); // Get a two channel control Bus
b.index; // should be zero
b.numChannels;
c = Bus.control(s);
c.index; // should be 2, since b used 0 and 1 (it had 2 channels).
c.numChannels; // the default number of channels is 1
b.free; // free the indicies.
// Busses in Action
(
SynthDef("tutorial-Infreq", { arg bus, freqOffset = 0;
// this will add freqOffset to whatever is read in from the bus
Out.ar(0, SinOsc.ar(In.kr(bus) + freqOffset, 0, 0.5));
}).add;
SynthDef("tutorial-Outfreq", { arg freq = 400, bus;
Out.kr(bus, SinOsc.kr(1, 0, freq/40, freq));
}).add;
b = Bus.control(s, 1);
)
(
x = Synth.new("tutorial-Outfreq", [\bus, b]);
y = Synth.after(x, "tutorial-Infreq", [\bus, b]);
//z = Synth.after(x, "tutorial-Infreq", [\bus, b, \freqOffset, 200]);
)
x.free; y.free; z.free; b.free;
(
// the arg direct will control the proportion of direct to processed signal
SynthDef("tutorial-DecayPink", { arg outBus = 0, effectBus, direct = 0.5;
var source;
// Decaying pulses of PinkNoise. We'll add reverb later.
source = Decay2.ar(Impulse.ar(1, 0.25), 0.01, 0.2, PinkNoise.ar);
// this will be our main output
Out.ar(outBus, source * direct);
// this will be our effects output
Out.ar(effectBus, source * (1 - direct));
}).add;
SynthDef("tutorial-DecaySin", { arg outBus = 0, effectBus, direct = 0.5;
var source;
// Decaying pulses of a modulating sine wave. We'll add reverb later.
source = Decay2.ar(Impulse.ar(0.3, 0.25), 0.3, 1, SinOsc.ar(SinOsc.kr(0.2, 0, 110, 440)));
// this will be our main output
Out.ar(outBus, source * direct);
// this will be our effects output
Out.ar(effectBus, source * (1 - direct));
}).add;
SynthDef("tutorial-Reverb", { arg outBus = 0, inBus;
var input;
input = In.ar(inBus, 1);
// a low-rent reverb
// aNumber.do will evaluate its function argument a corresponding number of times
// {}.dup(n) will evaluate the function n times, and return an Array of the results
// The default for n is 2, so this makes a stereo reverb
16.do({ input = AllpassC.ar(input, 0.04, { Rand(0.001,0.04) }.dup, 3)});
Out.ar(outBus, input);
}).add;
b = Bus.audio(s,1); // this will be our effects bus
)
(
x = Synth.new("tutorial-Reverb", [\inBus, b]);
y = Synth.before(x, "tutorial-DecayPink", [\effectBus, b]);
z = Synth.before(x, "tutorial-DecaySin", [\effectBus, b, \outBus, 1]);
)
// Change the balance of wet to dry
y.set(\direct, 1); // only direct PinkNoise
z.set(\direct, 1); // only direct Sine wave
y.set(\direct, 0); // only reverberated PinkNoise
z.set(\direct, 0); // only reverberated Sine wave
x.free; y.free; z.free; b.free;
//
// Doug's Bus tests
//
s.reboot;
b = Bus.audio(s, 1);
{ Out.ar(b, [SinOsc.ar(440, 0, 0.5)]) }.play;
b.scope;
{ Out.ar(0, [In.ar(b)]) }.play;
b.free;
// Routing one bus to another
s.reboot;
(
SynthDef("doug-writer", { arg bus;
Out.ar(bus, SinOsc.ar());
}).add;
SynthDef("doug-reader-writer", { arg busRead, busWrite;
Out.ar(busWrite, In.ar(busRead));
}).add;
)
b = Bus.audio(s);
w = Synth.new("doug-writer", [\bus, b]);
r = Synth.new("doug-reader-writer", [\busRead, b, \busWrite, 0]);
w.free; r.free;
{ Out.ar(b, SinOsc.ar()); Out.ar(b); }.play;
{ Line.kr(); }.plot(1);
{ XLine.kr(); }.plot(1);
{ LFDNoise3.ar(XLine.ar(1000, 100, 0.1) ! 3) }.plot(0.1);
plot({ Line.kr(200,17000,10)});
plot({ XLine.kr(200,17000,10)});
play({ SinOsc.ar(XLine.kr(200,17000,10),0,0.1) });
{ LFPar.ar(XLine.kr(100,15000,6),0,0.1) }.scope(1, zoom: 4);
{ SinOsc.ar(SinOsc.kr(SinOsc.kr(0.2,0,8,10),0, 400,800),0,0.1) }.scope(1, zoom: 4);
{ SyncSaw.ar(100, MouseX.kr(100, 1000), 0.1) }.scope(1, zoom: 4);
{ LFPulse.ar(LFPulse.kr(LFPulse.kr(0.2,0,0.5,8,10),0,0.5, 400,800),0,0.5,0.1) }.scope(1, zoom: 4);
{ Decay.ar(LFPulse.ar(440, 0, 0.02/10, 0.5), 0.02); }.scope;
{ LFPar.ar(800,0,0.1) }.scope(1, zoom: 4);
{ LFPulse.ar(100,0,MouseY.kr(0,1),0.1) }.scope(1, zoom: 4);
{ Blip.ar(XLine.kr(20000,200,6),100,0.2) }.scope(1);
{ Blip.ar(200,Line.kr(1,100,20),0.2) }.scope(1);
| SuperCollider | 5 | drichardson/examples | SuperCollider/Busses.scd | [
"Unlicense"
] |
frequency,raw
20.00,-5.57
20.20,-5.54
20.40,-5.50
20.61,-5.44
20.81,-5.39
21.02,-5.35
21.23,-5.26
21.44,-5.22
21.66,-5.18
21.87,-5.13
22.09,-5.07
22.31,-5.01
22.54,-4.96
22.76,-4.90
22.99,-4.83
23.22,-4.79
23.45,-4.74
23.69,-4.69
23.92,-4.62
24.16,-4.57
24.40,-4.52
24.65,-4.48
24.89,-4.44
25.14,-4.39
25.39,-4.35
25.65,-4.30
25.91,-4.27
26.16,-4.22
26.43,-4.18
26.69,-4.14
26.96,-4.11
27.23,-4.06
27.50,-4.03
27.77,-4.00
28.05,-3.95
28.33,-3.92
28.62,-3.89
28.90,-3.86
29.19,-3.83
29.48,-3.80
29.78,-3.77
30.08,-3.73
30.38,-3.69
30.68,-3.66
30.99,-3.63
31.30,-3.60
31.61,-3.57
31.93,-3.54
32.24,-3.51
32.57,-3.47
32.89,-3.43
33.22,-3.40
33.55,-3.37
33.89,-3.34
34.23,-3.31
34.57,-3.28
34.92,-3.25
35.27,-3.21
35.62,-3.17
35.97,-3.14
36.33,-3.10
36.70,-3.06
37.06,-3.03
37.43,-2.97
37.81,-2.94
38.19,-2.89
38.57,-2.84
38.95,-2.79
39.34,-2.75
39.74,-2.69
40.14,-2.62
40.54,-2.58
40.94,-2.53
41.35,-2.47
41.76,-2.41
42.18,-2.38
42.60,-2.35
43.03,-2.32
43.46,-2.30
43.90,-2.26
44.33,-2.23
44.78,-2.20
45.23,-2.17
45.68,-2.14
46.13,-2.10
46.60,-2.08
47.06,-2.04
47.53,-2.04
48.01,-1.99
48.49,-1.98
48.97,-1.95
49.46,-1.94
49.96,-1.91
50.46,-1.90
50.96,-1.86
51.47,-1.84
51.99,-1.82
52.51,-1.79
53.03,-1.78
53.56,-1.73
54.10,-1.69
54.64,-1.66
55.18,-1.60
55.74,-1.54
56.29,-1.49
56.86,-1.42
57.42,-1.36
58.00,-1.29
58.58,-1.22
59.16,-1.14
59.76,-1.08
60.35,-1.02
60.96,-0.95
61.57,-0.89
62.18,-0.84
62.80,-0.78
63.43,-0.72
64.07,-0.69
64.71,-0.64
65.35,-0.61
66.01,-0.58
66.67,-0.56
67.33,-0.54
68.01,-0.52
68.69,-0.52
69.37,-0.52
70.07,-0.48
70.77,-0.48
71.48,-0.48
72.19,-0.48
72.91,-0.48
73.64,-0.48
74.38,-0.48
75.12,-0.48
75.87,-0.48
76.63,-0.48
77.40,-0.48
78.17,-0.48
78.95,-0.48
79.74,-0.48
80.54,-0.48
81.35,-0.48
82.16,-0.48
82.98,-0.48
83.81,-0.48
84.65,-0.45
85.50,-0.45
86.35,-0.45
87.22,-0.48
88.09,-0.48
88.97,-0.48
89.86,-0.48
90.76,-0.48
91.66,-0.48
92.58,-0.48
93.51,-0.52
94.44,-0.52
95.39,-0.52
96.34,-0.52
97.30,-0.52
98.28,-0.52
99.26,-0.52
100.25,-0.52
101.25,-0.52
102.27,-0.52
103.29,-0.53
104.32,-0.56
105.37,-0.56
106.42,-0.56
107.48,-0.56
108.56,-0.61
109.64,-0.61
110.74,-0.61
111.85,-0.61
112.97,-0.61
114.10,-0.61
115.24,-0.61
116.39,-0.61
117.55,-0.58
118.73,-0.56
119.92,-0.56
121.12,-0.56
122.33,-0.56
123.55,-0.56
124.79,-0.56
126.03,-0.56
127.29,-0.56
128.57,-0.56
129.85,-0.56
131.15,-0.58
132.46,-0.58
133.79,-0.58
135.12,-0.58
136.48,-0.58
137.84,-0.58
139.22,-0.58
140.61,-0.58
142.02,-0.58
143.44,-0.59
144.87,-0.61
146.32,-0.61
147.78,-0.61
149.26,-0.61
150.75,-0.61
152.26,-0.61
153.78,-0.61
155.32,-0.63
156.88,-0.63
158.44,-0.65
160.03,-0.65
161.63,-0.63
163.24,-0.63
164.88,-0.61
166.53,-0.61
168.19,-0.61
169.87,-0.61
171.57,-0.61
173.29,-0.61
175.02,-0.61
176.77,-0.61
178.54,-0.61
180.32,-0.61
182.13,-0.61
183.95,-0.61
185.79,-0.61
187.65,-0.61
189.52,-0.61
191.42,-0.61
193.33,-0.61
195.27,-0.61
197.22,-0.61
199.19,-0.61
201.18,-0.61
203.19,-0.61
205.23,-0.61
207.28,-0.61
209.35,-0.61
211.44,-0.61
213.56,-0.58
215.69,-0.57
217.85,-0.56
220.03,-0.56
222.23,-0.56
224.45,-0.56
226.70,-0.55
228.96,-0.52
231.25,-0.52
233.57,-0.52
235.90,-0.52
238.26,-0.50
240.64,-0.48
243.05,-0.48
245.48,-0.48
247.93,-0.48
250.41,-0.48
252.92,-0.48
255.45,-0.43
258.00,-0.43
260.58,-0.43
263.19,-0.43
265.82,-0.41
268.48,-0.39
271.16,-0.39
273.87,-0.36
276.61,-0.35
279.38,-0.35
282.17,-0.30
284.99,-0.30
287.84,-0.28
290.72,-0.26
293.63,-0.25
296.57,-0.22
299.53,-0.22
302.53,-0.22
305.55,-0.18
308.61,-0.17
311.69,-0.17
314.81,-0.17
317.96,-0.16
321.14,-0.13
324.35,-0.13
327.59,-0.13
330.87,-0.13
334.18,-0.15
337.52,-0.17
340.90,-0.17
344.30,-0.17
347.75,-0.22
351.23,-0.22
354.74,-0.24
358.28,-0.26
361.87,-0.26
365.49,-0.26
369.14,-0.26
372.83,-0.26
376.56,-0.22
380.33,-0.22
384.13,-0.18
387.97,-0.17
391.85,-0.13
395.77,-0.13
399.73,-0.09
403.72,-0.05
407.76,-0.04
411.84,0.00
415.96,0.01
420.12,0.04
424.32,0.07
428.56,0.09
432.85,0.09
437.18,0.09
441.55,0.09
445.96,0.06
450.42,0.01
454.93,-0.07
459.48,-0.18
464.07,-0.32
468.71,-0.49
473.40,-0.67
478.13,-0.89
482.91,-1.09
487.74,-1.31
492.62,-1.50
497.55,-1.67
502.52,-1.79
507.55,-1.90
512.62,-1.94
517.75,-1.93
522.93,-1.88
528.16,-1.82
533.44,-1.70
538.77,-1.60
544.16,-1.50
549.60,-1.40
555.10,-1.31
560.65,-1.21
566.25,-1.15
571.92,-1.07
577.64,-1.01
583.41,-0.95
589.25,-0.89
595.14,-0.82
601.09,-0.74
607.10,-0.65
613.17,-0.59
619.30,-0.48
625.50,-0.39
631.75,-0.32
638.07,-0.24
644.45,-0.19
650.89,-0.17
657.40,-0.17
663.98,-0.18
670.62,-0.24
677.32,-0.29
684.10,-0.35
690.94,-0.41
697.85,-0.45
704.83,-0.48
711.87,-0.50
718.99,-0.49
726.18,-0.48
733.44,-0.45
740.78,-0.41
748.19,-0.36
755.67,-0.30
763.23,-0.24
770.86,-0.19
778.57,-0.15
786.35,-0.09
794.22,-0.02
802.16,0.04
810.18,0.11
818.28,0.16
826.46,0.23
834.73,0.29
843.08,0.35
851.51,0.41
860.02,0.46
868.62,0.52
877.31,0.55
886.08,0.56
894.94,0.56
903.89,0.51
912.93,0.47
922.06,0.41
931.28,0.33
940.59,0.26
950.00,0.17
959.50,0.11
969.09,0.06
978.78,0.04
988.57,0.00
998.46,0.00
1008.44,0.00
1018.53,0.00
1028.71,0.00
1039.00,0.00
1049.39,-0.02
1059.88,-0.04
1070.48,-0.08
1081.19,-0.11
1092.00,-0.16
1102.92,-0.19
1113.95,-0.24
1125.09,-0.27
1136.34,-0.30
1147.70,-0.35
1159.18,-0.39
1170.77,-0.42
1182.48,-0.45
1194.30,-0.50
1206.25,-0.53
1218.31,-0.56
1230.49,-0.59
1242.80,-0.62
1255.22,-0.65
1267.78,-0.68
1280.45,-0.69
1293.26,-0.74
1306.19,-0.74
1319.25,-0.77
1332.45,-0.78
1345.77,-0.78
1359.23,-0.78
1372.82,-0.81
1386.55,-0.82
1400.41,-0.82
1414.42,-0.87
1428.56,-0.91
1442.85,-0.94
1457.28,-0.99
1471.85,-1.02
1486.57,-1.04
1501.43,-1.04
1516.45,-1.04
1531.61,-0.99
1546.93,-0.96
1562.40,-0.91
1578.02,-0.87
1593.80,-0.85
1609.74,-0.82
1625.84,-0.82
1642.10,-0.82
1658.52,-0.82
1675.10,-0.87
1691.85,-0.87
1708.77,-0.91
1725.86,-0.91
1743.12,-0.95
1760.55,-0.95
1778.15,-0.95
1795.94,-0.90
1813.90,-0.85
1832.03,-0.80
1850.36,-0.74
1868.86,-0.67
1887.55,-0.59
1906.42,-0.50
1925.49,-0.43
1944.74,-0.36
1964.19,-0.30
1983.83,-0.26
2003.67,-0.26
2023.71,-0.21
2043.94,-0.17
2064.38,-0.08
2085.03,0.06
2105.88,0.23
2126.94,0.47
2148.20,0.73
2169.69,1.03
2191.38,1.34
2213.30,1.65
2235.43,1.94
2257.78,2.22
2280.36,2.50
2303.17,2.75
2326.20,3.01
2349.46,3.27
2372.95,3.53
2396.68,3.78
2420.65,4.04
2444.86,4.30
2469.31,4.56
2494.00,4.79
2518.94,5.02
2544.13,5.23
2569.57,5.41
2595.27,5.58
2621.22,5.74
2647.43,5.89
2673.90,6.07
2700.64,6.24
2727.65,6.40
2754.93,6.57
2782.48,6.73
2810.30,6.89
2838.40,7.02
2866.79,7.14
2895.46,7.25
2924.41,7.37
2953.65,7.43
2983.19,7.51
3013.02,7.56
3043.15,7.60
3073.58,7.65
3104.32,7.71
3135.36,7.75
3166.72,7.80
3198.38,7.85
3230.37,7.90
3262.67,7.95
3295.30,7.99
3328.25,8.04
3361.53,8.06
3395.15,8.06
3429.10,8.05
3463.39,8.00
3498.03,7.95
3533.01,7.87
3568.34,7.80
3604.02,7.71
3640.06,7.63
3676.46,7.54
3713.22,7.45
3750.36,7.38
3787.86,7.30
3825.74,7.24
3864.00,7.18
3902.64,7.10
3941.66,7.01
3981.08,6.89
4020.89,6.77
4061.10,6.61
4101.71,6.43
4142.73,6.22
4184.15,6.00
4226.00,5.74
4268.26,5.47
4310.94,5.20
4354.05,4.92
4397.59,4.63
4441.56,4.32
4485.98,4.03
4530.84,3.74
4576.15,3.46
4621.91,3.24
4668.13,3.03
4714.81,2.86
4761.96,2.72
4809.58,2.62
4857.67,2.55
4906.25,2.49
4955.31,2.49
5004.87,2.55
5054.91,2.65
5105.46,2.79
5156.52,2.97
5208.08,3.20
5260.16,3.43
5312.77,3.68
5365.89,3.91
5419.55,4.10
5473.75,4.25
5528.49,4.36
5583.77,4.46
5639.61,4.53
5696.00,4.57
5752.96,4.61
5810.49,4.67
5868.60,4.73
5927.28,4.81
5986.56,4.89
6046.42,4.98
6106.89,5.05
6167.96,5.09
6229.64,5.11
6291.93,5.11
6354.85,5.11
6418.40,5.13
6482.58,5.16
6547.41,5.16
6612.88,5.16
6679.01,5.16
6745.80,5.16
6813.26,5.16
6881.39,5.11
6950.21,5.09
7019.71,5.06
7089.91,5.01
7160.81,4.93
7232.41,4.87
7304.74,4.79
7377.79,4.70
7451.56,4.64
7526.08,4.57
7601.34,4.55
7677.35,4.55
7754.13,4.59
7831.67,4.67
7909.98,4.77
7989.08,4.93
8068.98,5.10
8149.67,5.26
8231.16,5.39
8313.47,5.50
8396.61,5.48
8480.57,5.30
8565.38,4.95
8651.03,4.39
8737.54,3.62
8824.92,2.62
8913.17,1.36
9002.30,-0.04
9092.32,-1.55
9183.25,-3.12
9275.08,-4.60
9367.83,-5.86
9461.51,-6.84
9556.12,-7.49
9651.68,-7.77
9748.20,-7.50
9845.68,-7.00
9944.14,-6.32
10043.58,-5.57
10144.02,-4.80
10245.46,-4.13
10347.91,-3.61
10451.39,-3.26
10555.91,-3.05
10661.46,-3.03
10768.08,-3.14
10875.76,-3.30
10984.52,-3.47
11094.36,-3.58
11205.31,-3.61
11317.36,-3.50
11430.53,-3.32
11544.84,-3.08
11660.29,-2.78
11776.89,-2.47
11894.66,-2.21
12013.60,-1.99
12133.74,-1.85
12255.08,-1.84
12377.63,-1.92
12501.41,-2.02
12626.42,-2.19
12752.68,-2.37
12880.21,-2.59
13009.01,-2.81
13139.10,-3.09
13270.49,-3.39
13403.20,-3.75
13537.23,-4.20
13672.60,-4.73
13809.33,-5.44
13947.42,-6.27
14086.90,-7.27
14227.77,-8.45
14370.04,-9.77
14513.74,-11.09
14658.88,-12.34
14805.47,-13.41
14953.52,-14.17
15103.06,-14.66
15254.09,-14.66
15406.63,-14.22
15560.70,-13.55
15716.30,-12.62
15873.47,-11.55
16032.20,-10.36
16192.52,-9.20
16354.45,-8.08
16517.99,-7.05
16683.17,-6.15
16850.01,-5.41
17018.51,-4.89
17188.69,-4.59
17360.58,-4.66
17534.18,-5.00
17709.53,-5.48
17886.62,-6.08
18065.49,-6.69
18246.14,-7.27
18428.60,-7.77
18612.89,-8.14
18799.02,-8.38
18987.01,-8.55
19176.88,-8.62
19368.65,-8.62
19562.33,-8.59
19757.96,-8.54
19955.54,-8.58
| CSV | 1 | vinzmc/AutoEq | measurements/oratory1990/data/onear/HIFIMAN HE400i 2020/HIFIMAN HE400i 2020.csv | [
"MIT"
] |
-- @shouldFailWith CycleInTypeClassDeclaration
module CycleInSuperclasses where
import Prelude
class (Foo a) <= Bar a
class (Bar a) <= Foo a
instance barString :: Bar String
instance fooString :: Foo String
| PureScript | 2 | andys8/purescript | tests/purs/failing/Superclasses2.purs | [
"BSD-3-Clause"
] |
ASM=nasm
STAGERS=stager_sock_bind stager_sock_bind_ipv6 stager_sock_find stager_sock_reverse stager_sock_reverse_ipv6
STAGES=stage_tcp_shell
SINGLE=single_bind_tcp_shell single_exec single_find_tcp_shell single_reverse_libinject single_reverse_tcp_shell single_findsock single_reverse_tcp_shell_ipv6 single_bind_tcp_shell_ipv6
OBJS=${STAGERS} ${STAGES} ${SINGLE}
include ../../Makefile.incl
all:
@for i in ${OBJS}; ${BUILDASMBSD}; done
clean:
rm -f *.o *.hex ${OBJS} *.disasm
| Makefile | 3 | OsmanDere/metasploit-framework | external/source/shellcode/bsd/ia32/Makefile | [
"BSD-2-Clause",
"BSD-3-Clause"
] |
$(function () {
$('[data-toggle="tooltip"]').tooltip();
});
| HTML+PHP | 4 | lamasbr/AzuraCast | templates/frontend/public/podcast-episodes.js.phtml | [
"Apache-2.0"
] |
// Trivial Cobol test code (empty for now).
| COBOL | 0 | ouankou/rose | tests/nonsmoke/functional/CompileTests/experimental_cobol_tests/test.cobol | [
"BSD-3-Clause"
] |
choice
prompt "Target CPU"
depends on BR2_arc
default BR2_arc770d
help
Specific CPU to use
config BR2_arc750d
bool "ARC 750D"
config BR2_arc770d
bool "ARC 770D"
config BR2_archs38
bool "ARC HS38"
endchoice
# Choice of atomic instructions presence
config BR2_ARC_ATOMIC_EXT
bool "Atomic extension (LLOCK/SCOND instructions)"
default y if BR2_arc770d || BR2_archs38
config BR2_ARCH_HAS_ATOMICS
default y if BR2_ARC_ATOMIC_EXT
config BR2_ARCH
default "arc" if BR2_arcle
default "arceb" if BR2_arceb
config BR2_arc
bool
default y if BR2_arcle || BR2_arceb
config BR2_ENDIAN
default "LITTLE" if BR2_arcle
default "BIG" if BR2_arceb
config BR2_GCC_TARGET_CPU
default "arc700" if BR2_arc750d
default "arc700" if BR2_arc770d
default "archs" if BR2_archs38
| Arc | 4 | boudabass/noobs | buildroot/arch/Config.in.arc | [
"Unlicense"
] |
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local command = helpers.command
local expect = helpers.expect
local feed = helpers.feed
local insert = helpers.insert
describe('u CTRL-R g- g+', function()
before_each(clear)
local function create_history(num_steps)
if num_steps == 0 then return end
insert('1')
if num_steps == 1 then return end
feed('o2<esc>')
feed('o3<esc>')
feed('u')
if num_steps == 2 then return end
feed('o4<esc>')
if num_steps == 3 then return end
feed('u')
end
local function undo_and_redo(hist_pos, undo, redo, expect_str)
command('enew!')
create_history(hist_pos)
local cur_contents = helpers.curbuf_contents()
feed(undo)
expect(expect_str)
feed(redo)
expect(cur_contents)
end
-- TODO Look for message saying 'Already at oldest change'
it('does nothing when no changes have happened', function()
undo_and_redo(0, 'u', '<C-r>', '')
undo_and_redo(0, 'g-', 'g+', '')
end)
it('undoes a change when at a leaf', function()
undo_and_redo(1, 'u', '<C-r>', '')
undo_and_redo(1, 'g-', 'g+', '')
end)
it('undoes a change when in a non-leaf', function()
undo_and_redo(2, 'u', '<C-r>', '1')
undo_and_redo(2, 'g-', 'g+', '1')
end)
it('undoes properly around a branch point', function()
undo_and_redo(3, 'u', '<C-r>', [[
1
2]])
undo_and_redo(3, 'g-', 'g+', [[
1
2
3]])
end)
it('can find the previous sequence after undoing to a branch', function()
undo_and_redo(4, 'u', '<C-r>', '1')
undo_and_redo(4, 'g-', 'g+', '1')
end)
end)
| Lua | 5 | uga-rosa/neovim | test/functional/editor/undo_spec.lua | [
"Vim"
] |
#!/bin/bash
set -euxo pipefail
##
# @license Copyright 2020 The Lighthouse Authors. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
##
# Unarchives "lhr-data-*.tar.gz" files inside gcp-data folder, places
# them inside gcp-data/data.
DIRNAME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
LH_ROOT="$DIRNAME/../../.."
GCP_DATA="$DIRNAME/gcp-data"
OUTPUT_DIR="$GCP_DATA/data"
mkdir -p "$OUTPUT_DIR"
cd "$GCP_DATA"
rm -rf extract_failures.log
# Change this line if you want to extract trace data instead.
i=0
for f in lhr-data-*.tar.gz; do # change to traces-*.tar.gz if extracting trace data
echo "Extracting $f...\n"
tar -xzvf $f data || echo "Failed to extract $f\n" >> extract_failures.log
mv "$OUTPUT_DIR/urls.txt" "$OUTPUT_DIR/urls-$i.txt"
((i += 1))
done
echo "Run to analyze data:"
echo node "$DIRNAME/analyze-lhr-data.js" "$OUTPUT_DIR" '___AUDIT-ID-GOES-HERE___' > "$LH_ROOT/.tmp/analyze-results.json"
| Shell | 4 | todortotev/lighthouse | lighthouse-core/scripts/gcp-collection/extract-data.sh | [
"Apache-2.0"
] |
import * as api from './api/api';
import * as angular from 'angular';
{{#apiInfo}}
const apiModule = angular.module('api', [])
{{#apis}}
{{#operations}}
.service('{{classname}}', api.{{classname}})
{{/operations}}
{{/apis}}
export default apiModule;
{{/apiInfo}} | HTML+Django | 3 | MalcolmScoffable/openapi-generator | modules/openapi-generator/src/main/resources/typescript-angularjs/api.module.mustache | [
"Apache-2.0"
] |
DROP TABLE IF EXISTS sample_merge_tree;
CREATE TABLE sample_merge_tree (dt DateTime, x UInt64) ENGINE = MergeTree PARTITION BY toYYYYMMDD(dt) ORDER BY x SETTINGS min_merge_bytes_to_use_direct_io=1, index_granularity = 8192;
INSERT INTO sample_merge_tree VALUES (toDateTime('2018-10-31 05:05:00'), 0), (toDateTime('2018-10-31 06:06:00'), 10), (toDateTime('2018-10-28 10:00:00'), 20);
OPTIMIZE TABLE sample_merge_tree FINAL;
SELECT * FROM sample_merge_tree ORDER BY x;
DROP TABLE IF EXISTS sample_merge_tree;
| SQL | 4 | pdv-ru/ClickHouse | tests/queries/0_stateless/00750_merge_tree_merge_with_o_direct.sql | [
"Apache-2.0"
] |
CREATE TABLE hdb_catalog.hdb_schema_update_event (
id BIGSERIAL PRIMARY KEY,
instance_id uuid NOT NULL,
occurred_at timestamptz NOT NULL DEFAULT NOW()
);
CREATE FUNCTION hdb_catalog.hdb_schema_update_event_notifier() RETURNS trigger AS
$function$
DECLARE
instance_id uuid;
occurred_at timestamptz;
curr_rec record;
BEGIN
instance_id = NEW.instance_id;
occurred_at = NEW.occurred_at;
PERFORM pg_notify('hasura_schema_update', json_build_object(
'instance_id', instance_id,
'occurred_at', occurred_at
)::text);
RETURN curr_rec;
END;
$function$
LANGUAGE plpgsql;
CREATE TRIGGER hdb_schema_update_event_notifier AFTER INSERT ON hdb_catalog.hdb_schema_update_event
FOR EACH ROW EXECUTE PROCEDURE hdb_catalog.hdb_schema_update_event_notifier();
| SQL | 4 | gh-oss-contributor/graphql-engine-1 | server/src-rsr/migrations/10_to_11.sql | [
"Apache-2.0",
"MIT"
] |
/*++
Copyright (c) Microsoft Corporation
Licensed under the MIT license.
Class Name:
- GetWindowLayoutArgs.h
Abstract:
- This is a helper class for getting the window layout from a peasant.
Depending on if we are running on the monarch or on a peasant we might need
to switch what thread we are executing on. This gives us the option of
either returning the json result synchronously, or as a promise.
--*/
#pragma once
#include "GetWindowLayoutArgs.g.h"
namespace winrt::Microsoft::Terminal::Remoting::implementation
{
struct GetWindowLayoutArgs : public GetWindowLayoutArgsT<GetWindowLayoutArgs>
{
WINRT_PROPERTY(winrt::hstring, WindowLayoutJson, L"");
WINRT_PROPERTY(winrt::Windows::Foundation::IAsyncOperation<winrt::hstring>, WindowLayoutJsonAsync, nullptr)
};
}
namespace winrt::Microsoft::Terminal::Remoting::factory_implementation
{
BASIC_FACTORY(GetWindowLayoutArgs);
}
| C | 5 | by-memory/terminal | src/cascadia/Remoting/GetWindowLayoutArgs.h | [
"MIT"
] |
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
import os
import sys
import requests
BOT_URL = "https://tldr-bot.starbeamrainbowlabs.com"
COMMENT_ERROR = """
The [build](https://github.com/tldr-pages/tldr/actions/runs/{build_id}) for this PR failed with the following error(s):
```
{content}
```
Please fix the error(s) and push again.
"""
COMMENT_CHECK = """
Hello! I've noticed something unusual when checking this PR:
{content}
Is this intended? If so, just ignore this comment. Otherwise, please double-check the commits.
"""
################################################################################
def post_comment(pr_id, body, once):
endpoint = BOT_URL + "/comment"
if once:
endpoint += "/once"
data = {"pr_id": pr_id, "body": body}
try:
with requests.post(endpoint, json=data) as r:
if r.status_code != requests.codes.ok:
print(
"Error: tldr-bot responded with code",
r.status_code,
file=sys.stderr,
)
print(r.text, file=sys.stderr)
return False
except requests.exceptions.RequestException as e:
print("Error sending data to tldr-bot:", str(e), file=sys.stderr)
return False
return True
def main(action):
if action not in ("report-errors", "report-check-results"):
print("Unknown action:", action, file=sys.stderr)
sys.exit(1)
content = sys.stdin.read().strip()
if action == "report-errors":
comment_body = COMMENT_ERROR.format(build_id=BUILD_ID, content=content)
comment_once = False
elif action == "report-check-results":
comment_body = COMMENT_CHECK.format(content=content)
comment_once = True
if post_comment(PR_ID, comment_body, comment_once):
print("Success.")
else:
print("Error sending data to tldr-bot!", file=sys.stderr)
################################################################################
if __name__ == "__main__":
REPO_SLUG = os.environ.get("GITHUB_REPOSITORY")
PR_ID = os.environ.get("PULL_REQUEST_ID")
BUILD_ID = os.environ.get("GITHUB_RUN_ID")
if PR_ID is None or BUILD_ID is None or REPO_SLUG is None:
print("Needed environment variables are not set.", file=sys.stderr)
sys.exit(1)
if PR_ID is None or PR_ID == "false":
print("Not a pull request, refusing to run.", file=sys.stderr)
sys.exit(0)
if len(sys.argv) != 2:
print("Usage:", sys.argv[0], "<ACTION>", file=sys.stderr)
sys.exit(1)
main(sys.argv[1])
| Python | 4 | derNiklaas/tldr | scripts/send-to-bot.py | [
"CC-BY-4.0"
] |
$(OBJDIR)/growArray.cmi: $(OBJDIR)/pretty.cmi
| D | 1 | heechul/crest-z3 | cil/obj/.depend/growArray.di | [
"BSD-3-Clause"
] |
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {absoluteFrom, getFileSystem, PathManipulation} from '@angular/compiler-cli/src/ngtsc/file_system';
import {ɵmakeTemplateObject} from '@angular/localize';
import generate from '@babel/generator';
import {NodePath, TransformOptions, transformSync, types as t} from '../src/babel_core';
import template from '@babel/template';
import {isGlobalIdentifier, isNamedIdentifier, isStringLiteralArray, isArrayOfExpressions, unwrapStringLiteralArray, unwrapMessagePartsFromLocalizeCall, wrapInParensIfNecessary, buildLocalizeReplacement, unwrapSubstitutionsFromLocalizeCall, unwrapMessagePartsFromTemplateLiteral, getLocation} from '../src/source_file_utils';
import {runInNativeFileSystem} from './helpers';
runInNativeFileSystem(() => {
let fs: PathManipulation;
beforeEach(() => fs = getFileSystem());
describe('utils', () => {
describe('isNamedIdentifier()', () => {
it('should return true if the expression is an identifier with name `$localize`', () => {
const taggedTemplate = getTaggedTemplate('$localize ``;');
expect(isNamedIdentifier(taggedTemplate.get('tag'), '$localize')).toBe(true);
});
it('should return false if the expression is an identifier without the name `$localize`',
() => {
const taggedTemplate = getTaggedTemplate('other ``;');
expect(isNamedIdentifier(taggedTemplate.get('tag'), '$localize')).toBe(false);
});
it('should return false if the expression is not an identifier', () => {
const taggedTemplate = getTaggedTemplate('$localize() ``;');
expect(isNamedIdentifier(taggedTemplate.get('tag'), '$localize')).toBe(false);
});
});
describe('isGlobalIdentifier()', () => {
it('should return true if the identifier is at the top level and not declared', () => {
const taggedTemplate = getTaggedTemplate('$localize ``;');
expect(isGlobalIdentifier(taggedTemplate.get('tag') as NodePath<t.Identifier>)).toBe(true);
});
it('should return true if the identifier is in a block scope and not declared', () => {
const taggedTemplate = getTaggedTemplate('function foo() { $localize ``; } foo();');
expect(isGlobalIdentifier(taggedTemplate.get('tag') as NodePath<t.Identifier>)).toBe(true);
});
it('should return false if the identifier is declared locally', () => {
const taggedTemplate = getTaggedTemplate('function $localize() {} $localize ``;');
expect(isGlobalIdentifier(taggedTemplate.get('tag') as NodePath<t.Identifier>)).toBe(false);
});
it('should return false if the identifier is a function parameter', () => {
const taggedTemplate = getTaggedTemplate('function foo($localize) { $localize ``; }');
expect(isGlobalIdentifier(taggedTemplate.get('tag') as NodePath<t.Identifier>)).toBe(false);
});
});
describe('buildLocalizeReplacement', () => {
it('should interleave the `messageParts` with the `substitutions`', () => {
const messageParts = ɵmakeTemplateObject(['a', 'b', 'c'], ['a', 'b', 'c']);
const substitutions = [t.numericLiteral(1), t.numericLiteral(2)];
const expression = buildLocalizeReplacement(messageParts, substitutions);
expect(generate(expression).code).toEqual('"a" + 1 + "b" + 2 + "c"');
});
it('should wrap "binary expression" substitutions in parentheses', () => {
const messageParts = ɵmakeTemplateObject(['a', 'b'], ['a', 'b']);
const binary = t.binaryExpression('+', t.numericLiteral(1), t.numericLiteral(2));
const expression = buildLocalizeReplacement(messageParts, [binary]);
expect(generate(expression).code).toEqual('"a" + (1 + 2) + "b"');
});
});
describe('unwrapMessagePartsFromLocalizeCall', () => {
it('should return an array of string literals and locations from a direct call to a tag function',
() => {
const localizeCall = getLocalizeCall(`$localize(['a', 'b\\t', 'c'], 1, 2)`);
const [parts, locations] = unwrapMessagePartsFromLocalizeCall(localizeCall, fs);
expect(parts).toEqual(['a', 'b\t', 'c']);
expect(locations).toEqual([
{
start: {line: 0, column: 11},
end: {line: 0, column: 14},
file: absoluteFrom('/test/file.js'),
text: `'a'`,
},
{
start: {line: 0, column: 16},
end: {line: 0, column: 21},
file: absoluteFrom('/test/file.js'),
text: `'b\\t'`,
},
{
start: {line: 0, column: 23},
end: {line: 0, column: 26},
file: absoluteFrom('/test/file.js'),
text: `'c'`,
},
]);
});
it('should return an array of string literals and locations from a downleveled tagged template',
() => {
let localizeCall = getLocalizeCall(
`$localize(__makeTemplateObject(['a', 'b\\t', 'c'], ['a', 'b\\\\t', 'c']), 1, 2)`);
const [parts, locations] = unwrapMessagePartsFromLocalizeCall(localizeCall, fs);
expect(parts).toEqual(['a', 'b\t', 'c']);
expect(parts.raw).toEqual(['a', 'b\\t', 'c']);
expect(locations).toEqual([
{
start: {line: 0, column: 51},
end: {line: 0, column: 54},
file: absoluteFrom('/test/file.js'),
text: `'a'`,
},
{
start: {line: 0, column: 56},
end: {line: 0, column: 62},
file: absoluteFrom('/test/file.js'),
text: `'b\\\\t'`,
},
{
start: {line: 0, column: 64},
end: {line: 0, column: 67},
file: absoluteFrom('/test/file.js'),
text: `'c'`,
},
]);
});
it('should return an array of string literals and locations from a (Babel helper) downleveled tagged template',
() => {
let localizeCall = getLocalizeCall(
`$localize(babelHelpers.taggedTemplateLiteral(['a', 'b\\t', 'c'], ['a', 'b\\\\t', 'c']), 1, 2)`);
const [parts, locations] = unwrapMessagePartsFromLocalizeCall(localizeCall, fs);
expect(parts).toEqual(['a', 'b\t', 'c']);
expect(parts.raw).toEqual(['a', 'b\\t', 'c']);
expect(locations).toEqual([
{
start: {line: 0, column: 65},
end: {line: 0, column: 68},
file: absoluteFrom('/test/file.js'),
text: `'a'`,
},
{
start: {line: 0, column: 70},
end: {line: 0, column: 76},
file: absoluteFrom('/test/file.js'),
text: `'b\\\\t'`,
},
{
start: {line: 0, column: 78},
end: {line: 0, column: 81},
file: absoluteFrom('/test/file.js'),
text: `'c'`,
},
]);
});
it('should return an array of string literals and locations from a memoized downleveled tagged template',
() => {
let localizeCall = getLocalizeCall(`
var _templateObject;
$localize(_templateObject || (_templateObject = __makeTemplateObject(['a', 'b\\t', 'c'], ['a', 'b\\\\t', 'c'])), 1, 2)`);
const [parts, locations] = unwrapMessagePartsFromLocalizeCall(localizeCall, fs);
expect(parts).toEqual(['a', 'b\t', 'c']);
expect(parts.raw).toEqual(['a', 'b\\t', 'c']);
expect(locations).toEqual([
{
start: {line: 2, column: 105},
end: {line: 2, column: 108},
file: absoluteFrom('/test/file.js'),
text: `'a'`,
},
{
start: {line: 2, column: 110},
end: {line: 2, column: 116},
file: absoluteFrom('/test/file.js'),
text: `'b\\\\t'`,
},
{
start: {line: 2, column: 118},
end: {line: 2, column: 121},
file: absoluteFrom('/test/file.js'),
text: `'c'`,
},
]);
});
it('should return an array of string literals and locations from a memoized (inlined Babel helper) downleveled tagged template',
() => {
let localizeCall = getLocalizeCall(`
var e,t,n;
$localize(e ||
(
t=["a","b\t","c"],
n || (n=t.slice(0)),
e = Object.freeze(
Object.defineProperties(t, { raw: { value: Object.freeze(n) } })
)
),
1,2
)`);
const [parts, locations] = unwrapMessagePartsFromLocalizeCall(localizeCall, fs);
expect(parts).toEqual(['a', 'b\t', 'c']);
expect(parts.raw).toEqual(['a', 'b\t', 'c']);
expect(locations).toEqual([
{
start: {line: 4, column: 21},
end: {line: 4, column: 24},
file: absoluteFrom('/test/file.js'),
text: `"a"`,
},
{
start: {line: 4, column: 25},
end: {line: 4, column: 29},
file: absoluteFrom('/test/file.js'),
text: `"b\t"`,
},
{
start: {line: 4, column: 30},
end: {line: 4, column: 33},
file: absoluteFrom('/test/file.js'),
text: `"c"`,
},
]);
});
it('should return an array of string literals and locations from a lazy load template helper',
() => {
let localizeCall = getLocalizeCall(`
function _templateObject() {
var e = _taggedTemplateLiteral(['a', 'b\\t', 'c'], ['a', 'b\\\\t', 'c']);
return _templateObject = function() { return e }, e
}
$localize(_templateObject(), 1, 2)`);
const [parts, locations] = unwrapMessagePartsFromLocalizeCall(localizeCall, fs);
expect(parts).toEqual(['a', 'b\t', 'c']);
expect(parts.raw).toEqual(['a', 'b\\t', 'c']);
expect(locations).toEqual([
{
start: {line: 2, column: 61},
end: {line: 2, column: 64},
file: absoluteFrom('/test/file.js'),
text: `'a'`,
},
{
start: {line: 2, column: 66},
end: {line: 2, column: 72},
file: absoluteFrom('/test/file.js'),
text: `'b\\\\t'`,
},
{
start: {line: 2, column: 74},
end: {line: 2, column: 77},
file: absoluteFrom('/test/file.js'),
text: `'c'`,
},
]);
});
it('should remove a lazy load template helper', () => {
let localizeCall = getLocalizeCall(`
function _templateObject() {
var e = _taggedTemplateLiteral(['a', 'b', 'c'], ['a', 'b', 'c']);
return _templateObject = function() { return e }, e
}
$localize(_templateObject(), 1, 2)`);
const localizeStatement = localizeCall.parentPath as NodePath<t.ExpressionStatement>;
const statements = localizeStatement.container as object[];
expect(statements.length).toEqual(2);
unwrapMessagePartsFromLocalizeCall(localizeCall, fs);
expect(statements.length).toEqual(1);
expect(statements[0]).toBe(localizeStatement.node);
});
});
describe('unwrapSubstitutionsFromLocalizeCall', () => {
it('should return the substitutions and locations from a direct call to a tag function',
() => {
const call = getLocalizeCall(`$localize(['a', 'b\t', 'c'], 1, 2)`);
const [substitutions, locations] = unwrapSubstitutionsFromLocalizeCall(call, fs);
expect((substitutions as t.NumericLiteral[]).map(s => s.value)).toEqual([1, 2]);
expect(locations).toEqual([
{
start: {line: 0, column: 28},
end: {line: 0, column: 29},
file: absoluteFrom('/test/file.js'),
text: '1'
},
{
start: {line: 0, column: 31},
end: {line: 0, column: 32},
file: absoluteFrom('/test/file.js'),
text: '2'
},
]);
});
it('should return the substitutions and locations from a downleveled tagged template', () => {
const call = getLocalizeCall(
`$localize(__makeTemplateObject(['a', 'b', 'c'], ['a', 'b', 'c']), 1, 2)`);
const [substitutions, locations] = unwrapSubstitutionsFromLocalizeCall(call, fs);
expect((substitutions as t.NumericLiteral[]).map(s => s.value)).toEqual([1, 2]);
expect(locations).toEqual([
{
start: {line: 0, column: 66},
end: {line: 0, column: 67},
file: absoluteFrom('/test/file.js'),
text: '1'
},
{
start: {line: 0, column: 69},
end: {line: 0, column: 70},
file: absoluteFrom('/test/file.js'),
text: '2'
},
]);
});
});
describe('unwrapMessagePartsFromTemplateLiteral', () => {
it('should return a TemplateStringsArray built from the template literal elements', () => {
const taggedTemplate = getTaggedTemplate('$localize `a${1}b\\t${2}c`;');
expect(
unwrapMessagePartsFromTemplateLiteral(taggedTemplate.get('quasi').get('quasis'), fs)[0])
.toEqual(ɵmakeTemplateObject(['a', 'b\t', 'c'], ['a', 'b\\t', 'c']));
});
});
describe('wrapInParensIfNecessary', () => {
it('should wrap the expression in parentheses if it is binary', () => {
const ast = template.ast`a + b` as t.ExpressionStatement;
const wrapped = wrapInParensIfNecessary(ast.expression);
expect(t.isParenthesizedExpression(wrapped)).toBe(true);
});
it('should return the expression untouched if it is not binary', () => {
const ast = template.ast`a` as t.ExpressionStatement;
const wrapped = wrapInParensIfNecessary(ast.expression);
expect(t.isParenthesizedExpression(wrapped)).toBe(false);
});
});
describe('unwrapStringLiteralArray', () => {
it('should return an array of string from an array expression', () => {
const array = getFirstExpression(`['a', 'b', 'c']`);
const [expressions, locations] = unwrapStringLiteralArray(array, fs);
expect(expressions).toEqual(['a', 'b', 'c']);
expect(locations).toEqual([
{
start: {line: 0, column: 1},
end: {line: 0, column: 4},
file: absoluteFrom('/test/file.js'),
text: `'a'`,
},
{
start: {line: 0, column: 6},
end: {line: 0, column: 9},
file: absoluteFrom('/test/file.js'),
text: `'b'`,
},
{
start: {line: 0, column: 11},
end: {line: 0, column: 14},
file: absoluteFrom('/test/file.js'),
text: `'c'`,
},
]);
});
it('should throw an error if any elements of the array are not literal strings', () => {
const array = getFirstExpression(`['a', 2, 'c']`);
expect(() => unwrapStringLiteralArray(array, fs))
.toThrowError(
'Unexpected messageParts for `$localize` (expected an array of strings).');
});
});
describe('isStringLiteralArray()', () => {
it('should return true if the ast is an array of strings', () => {
const ast = template.ast`['a', 'b', 'c']` as t.ExpressionStatement;
expect(isStringLiteralArray(ast.expression)).toBe(true);
});
it('should return false if the ast is not an array', () => {
const ast = template.ast`'a'` as t.ExpressionStatement;
expect(isStringLiteralArray(ast.expression)).toBe(false);
});
it('should return false if at least on of the array elements is not a string', () => {
const ast = template.ast`['a', 1, 'b']` as t.ExpressionStatement;
expect(isStringLiteralArray(ast.expression)).toBe(false);
});
});
describe('isArrayOfExpressions()', () => {
it('should return true if all the nodes are expressions', () => {
const call = getFirstExpression<t.CallExpression>('foo(a, b, c);');
expect(isArrayOfExpressions(call.get('arguments'))).toBe(true);
});
it('should return false if any of the nodes is not an expression', () => {
const call = getFirstExpression<t.CallExpression>('foo(a, b, ...c);');
expect(isArrayOfExpressions(call.get('arguments'))).toBe(false);
});
});
describe('getLocation()', () => {
it('should return a plain object containing the start, end and file of a NodePath', () => {
const taggedTemplate = getTaggedTemplate('const x = $localize `message`;', {
filename: 'src/test.js',
sourceRoot: fs.resolve('/project'),
});
const location = getLocation(fs, taggedTemplate)!;
expect(location).toBeDefined();
expect(location.start).toEqual({line: 0, column: 10});
expect(location.start.constructor.name).toEqual('Object');
expect(location.end).toEqual({line: 0, column: 29});
expect(location.end?.constructor.name).toEqual('Object');
expect(location.file).toEqual(fs.resolve('/project/src/test.js'));
});
it('should return `undefined` if the NodePath has no filename', () => {
const taggedTemplate = getTaggedTemplate(
'const x = $localize ``;', {sourceRoot: fs.resolve('/project'), filename: undefined});
const location = getLocation(fs, taggedTemplate);
expect(location).toBeUndefined();
});
});
});
});
function getTaggedTemplate(
code: string, options?: TransformOptions): NodePath<t.TaggedTemplateExpression> {
return getExpressions<t.TaggedTemplateExpression>(code, options)
.find(e => e.isTaggedTemplateExpression())!;
}
function getFirstExpression<T extends t.Expression>(
code: string, options?: TransformOptions): NodePath<T> {
return getExpressions<T>(code, options)[0];
}
function getExpressions<T extends t.Expression>(
code: string, options?: TransformOptions): NodePath<T>[] {
const expressions: NodePath<t.Expression>[] = [];
transformSync(code, {
code: false,
filename: 'test/file.js',
cwd: '/',
plugins: [{
visitor: {
Expression: (path: NodePath<t.Expression>) => {
expressions.push(path);
}
}
}],
...options
});
return expressions as NodePath<T>[];
}
function getLocalizeCall(code: string): NodePath<t.CallExpression> {
let callPaths: NodePath<t.CallExpression>[] = [];
transformSync(code, {
code: false,
filename: 'test/file.js',
cwd: '/',
plugins: [{
visitor: {
CallExpression(path) {
callPaths.push(path);
}
}
}]
});
const localizeCall = callPaths.find(p => {
const callee = p.get('callee');
return (callee.isIdentifier() && callee.node.name === '$localize');
});
if (!localizeCall) {
throw new Error(`$localize cannot be found in ${code}`);
}
return localizeCall;
}
| TypeScript | 5 | John-Cassidy/angular | packages/localize/tools/test/source_file_utils_spec.ts | [
"MIT"
] |
# -*- Python -*-
from TwistedQuotes import webquoteresource
#__file__ is defined to be the name of this file; this is to
#get the sibling file "quotes.txt" which should be in the same directory
import os
quotefile = os.path.join(os.path.split(__file__)[0], "quotes.txt")
#ResourceScript requires us to define 'resource'.
#This resource is used to render the page.
resource = webquoteresource.QuoteResource([quotefile])
| Ren'Py | 4 | giadram/twisted | docs/core/howto/listings/TwistedQuotes/webquote.rpy | [
"MIT",
"Unlicense"
] |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.spark.sql.execution.streaming.sources
import org.apache.spark.sql._
import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
import org.apache.spark.sql.execution.streaming.Sink
import org.apache.spark.sql.streaming.DataStreamWriter
class ForeachBatchSink[T](batchWriter: (Dataset[T], Long) => Unit, encoder: ExpressionEncoder[T])
extends Sink {
override def addBatch(batchId: Long, data: DataFrame): Unit = {
val resolvedEncoder = encoder.resolveAndBind(
data.logicalPlan.output,
data.sparkSession.sessionState.analyzer)
val fromRow = resolvedEncoder.createDeserializer()
val rdd = data.queryExecution.toRdd.map[T](fromRow)(encoder.clsTag)
val ds = data.sparkSession.createDataset(rdd)(encoder)
batchWriter(ds, batchId)
}
override def toString(): String = "ForeachBatchSink"
}
/**
* Interface that is meant to be extended by Python classes via Py4J.
* Py4J allows Python classes to implement Java interfaces so that the JVM can call back
* Python objects. In this case, this allows the user-defined Python `foreachBatch` function
* to be called from JVM when the query is active.
* */
trait PythonForeachBatchFunction {
/** Call the Python implementation of this function */
def call(batchDF: DataFrame, batchId: Long): Unit
}
object PythonForeachBatchHelper {
def callForeachBatch(dsw: DataStreamWriter[Row], pythonFunc: PythonForeachBatchFunction): Unit = {
dsw.foreachBatch(pythonFunc.call _)
}
}
| Scala | 4 | kesavanvt/spark | sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/sources/ForeachBatchSink.scala | [
"BSD-2-Clause",
"Apache-2.0",
"CC0-1.0",
"MIT",
"MIT-0",
"ECL-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] |
Import rockout
Class Level
Global Number:Int
Global Name:String
Global StartLine:Int
Global Graphics:String
Global Shots:List <Shot>
Global Blocks:List <Block>
Global FallingBlocks:List <Block>
Global ScoreBubbles:List <ScoreBubble>
Global Gravity:Float
Method New ()
Shots = New List <Shot>
Blocks = New List <Block>
FallingBlocks = New List <Block>
ScoreBubbles = New List <ScoreBubble>
Timer.ShotReload = New Timer
Number = Number + 1
Name = "Level " + Number
End
' TEMP HACK LEVEL!
Function LoadLevel:Level ()
Local level:Level = New Level
Local levelstring:String = LoadString ("level" + level.Number + ".txt")
If levelstring
Local leveldata:String [] = levelstring.Split ("~n")
Local linecount:Int
For Local line:String = Eachin leveldata
linecount = linecount + 1
'Print "Line " + linecount + ": " + line
If line.ToLower.StartsWith ("start")
Level.StartLine = linecount
Endif
If line.ToLower.StartsWith ("gfx")
Level.Graphics = "TEMP"
Endif
' |01|01|01|01|01|01|01|01|01|01|01|01|01|01|01|01|01|01|01|01| (Length = 61)
' Test blocks...
For Local temp:Int = 0 To 2
New Block (DEFAULT_BLOCK, Rnd (VDeviceWidth), Rnd (VDeviceHeight) * 0.5, 0, 0, 1.0, 1.0)
Next
Next
If GameSession.CurrentLevel.Blocks.IsEmpty Then Error "No blocks found in level " + level.Number + "!"
Return level
Else
Error "No new level found!"
Endif
End
End
| Monkey | 3 | blitz-research/monkey | bananas/hitoro/rockout/imports/level.monkey | [
"Zlib"
] |
<%= greeting(@person) %>
<%= PersonView.handle(@reply.author) %> replied to you on Changelog News, saying:
<%= @reply.content %>
Reply here: <%= comment_url(@item, @reply) %>
Seen enough? Mute this discussion:
<%= PersonView.opt_out_url(Endpoint, @person, "news", @item.id) %>
Or disable reply notifications all together:
<%= PersonView.opt_out_url(Endpoint, @person, "setting", "email_on_comment_replies") %>
💚, Logbot
| HTML+EEX | 3 | PsOverflow/changelog.com | lib/changelog_web/templates/email/comment_reply.text.eex | [
"MIT"
] |
/*-------------------------------------------------------------*/
/* Connectionist-like NCL implementation of the XOR function */
/* (C) 1993 Zdravko Markov, II-BAS */
/*-------------------------------------------------------------*/
/*
This is a simple illustration of the spreading activation
mechanism in NCL. The classical connectionist example for the
XOR (exclusive-OR) function is used. The NCL program is a direct
implementation of the corresponding neural network if we assume
that a bound net-variable gives weight of connection 1 and a free
one - weight of connection -1. Then the spreading activation
nodes perform combining function summation and threshold function
unit step.
*/
/*-------------------------------------------------------------*/
/* XOR Inputs */
in1(X): in2(Y):
/* Hidden Layer */
node(X,~Y,1,x1(X)):
node(Y,~X,1,y1(Y)):
/* Output Layer */
x1(X1): y1(Y1):
node(X1,Y1,1,out(on)):
out(Z).
/*-------------------------------------------------------------*/
/* EXAMPLES: */
/*-------------------------------------------------------------*/
?- netmode(0). /* Breadth-first mode only ! */
/*
?- top(T),in1(on),spread(T),out(X). 1 XOR 0 = 1
X=on
?- top(T),in1(on),in2(on),spread(T),out(X). 1 XOR 1 = 0
X=_1
*/
| Logtalk | 5 | PaulBrownMagic/logtalk3 | examples/figures/xor.lgt | [
"Apache-2.0"
] |
<div>
<h2>Dealers</h2>
<jhi-alert></jhi-alert>
<div class="container-fluid">
<div class="row">
<div class="col-xs-4 no-padding-left">
<button class="btn btn-primary" ui-sref="dealer.new" >
<span class="glyphicon glyphicon-plus"></span>
<span >
Create new Dealer
</span>
</button>
</div>
</div>
</div>
<br/>
<div class="table-responsive">
<table class="jh-table table table-striped">
<thead>
<tr jh-sort="vm.predicate" ascending="vm.reverse" callback="vm.reset()">
<th jh-sort-by="id"><span>ID</span> <span class="glyphicon glyphicon-sort"></span></th>
<th jh-sort-by="name"><span>Name</span> <span class="glyphicon glyphicon-sort"></span></th>
<th jh-sort-by="address"><span>Address</span> <span class="glyphicon glyphicon-sort"></span></th>
<th></th>
</tr>
</thead>
<tbody infinite-scroll="vm.loadPage(vm.page + 1)" infinite-scroll-disabled="vm.page >= vm.links['last']">
<tr ng-repeat="dealer in vm.dealers track by dealer.id">
<td><a ui-sref="dealer-detail({id:dealer.id})">{{dealer.id}}</a></td>
<td>{{dealer.name}}</td>
<td>{{dealer.address}}</td>
<td class="text-right">
<div class="btn-group flex-btn-group-container">
<button type="submit"
ui-sref="dealer-detail({id:dealer.id})"
class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-eye-open"></span>
<span class="hidden-sm-down"></span>
</button>
<button type="submit"
ui-sref="dealer.edit({id:dealer.id})"
class="btn btn-primary btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
<span class="hidden-sm-down"></span>
</button>
<button type="submit"
ui-sref="dealer.delete({id:dealer.id})"
class="btn btn-danger btn-sm">
<span class="glyphicon glyphicon-remove-circle"></span>
<span class="hidden-sm-down"></span>
</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
| HTML | 4 | zeesh49/tutorials | jhipster/jhipster-microservice/gateway-app/src/main/webapp/app/entities/dealer/dealers.html | [
"MIT"
] |
; RUN: %swift-llvm-opt -swift-llvm-arc-optimize %s > /dev/null
target datalayout = "e-p:64:64:64-S128-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f16:16:16-f32:32:32-f64:64:64-f128:128:128-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-apple-macosx10.9"
%swift.refcounted = type { %swift.heapmetadata*, i64 }
%swift.heapmetadata = type { i64 (%swift.refcounted*)*, i64 (%swift.refcounted*)* }
declare { i8*, i64, %swift.refcounted* } @_Tsop1pFT3lhsNs6String3rhsS__S_(i8*, i64, %swift.refcounted*, i8*, i64, %swift.refcounted*)
declare { i8*, i64, %swift.refcounted* } @_TNs6String24convertFromStringLiteralFT3valp_S_(i8*)
declare void @swift_release(%swift.refcounted* nocapture)
@0 = private unnamed_addr constant [3 x i8] c"So\00"
@1 = private unnamed_addr constant [3 x i8] c"me\00"
; rdar://11558546
define void @release_past_extract() {
entry:
%0 = call { i8*, i64, %swift.refcounted* } @_TNs6String24convertFromStringLiteralFT3valp_S_(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @0, i32 0, i32 0))
%1 = extractvalue { i8*, i64, %swift.refcounted* } %0, 0
%2 = extractvalue { i8*, i64, %swift.refcounted* } %0, 1
%3 = extractvalue { i8*, i64, %swift.refcounted* } %0, 2
%4 = call { i8*, i64, %swift.refcounted* } @_TNs6String24convertFromStringLiteralFT3valp_S_(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @1, i32 0, i32 0))
%5 = extractvalue { i8*, i64, %swift.refcounted* } %4, 0
%6 = extractvalue { i8*, i64, %swift.refcounted* } %4, 1
%7 = extractvalue { i8*, i64, %swift.refcounted* } %4, 2
%8 = call { i8*, i64, %swift.refcounted* } @_Tsop1pFT3lhsNs6String3rhsS__S_(i8* %1, i64 %2, %swift.refcounted* %3, i8* %5, i64 %6, %swift.refcounted* %7)
%9 = extractvalue { i8*, i64, %swift.refcounted* } %8, 0
%10 = extractvalue { i8*, i64, %swift.refcounted* } %8, 1
%11 = extractvalue { i8*, i64, %swift.refcounted* } %8, 2
call void @swift_release(%swift.refcounted* null) nounwind
call void @swift_release(%swift.refcounted* %11) nounwind
ret void
}
| LLVM | 3 | lwhsu/swift | test/LLVMPasses/crash.ll | [
"Apache-2.0"
] |
import json
import logging
import re
from requests.models import Request
from localstack.services.generic_proxy import ProxyListener
from localstack.utils.analytics import event_publisher
from localstack.utils.aws import aws_stack
from localstack.utils.aws.aws_responses import set_response_content
from localstack.utils.common import to_str
LOG = logging.getLogger(__name__)
SM_ARN_REGEX = r'(arn:aws:states):([^:]+):([^:]+:(stateMachine|execution)):((([^_]+)_)?([^"]+))'
default_region = "us-east-1"
class ProxyListenerStepFunctions(ProxyListener):
def forward_request(self, method, path, data, headers):
if method == "OPTIONS":
return 200
data = json.loads(to_str(data or "{}"))
region_name = aws_stack.get_region()
if data.get("name"):
# inject region name as prefix, as StepFunctions is currently not capable of handling multi-region requests
data["name"] = f"{region_name}_{data['name']}"
data = json.dumps(data)
replace = r"\1:%s:\3:\2_\5" % default_region
data_replaced = re.sub(SM_ARN_REGEX, replace, data)
return Request(method=method, data=data_replaced, headers=headers)
def return_response(self, method, path, data, headers, response):
data = json.loads(to_str(data or "{}"))
name = data.get("name") or (data.get("stateMachineArn") or "").split(":")[-1]
target = headers.get("X-Amz-Target", "").split(".")[-1]
# publish event
if target == "CreateStateMachine":
event_publisher.fire_event(
event_publisher.EVENT_STEPFUNCTIONS_CREATE_SM,
payload={"m": event_publisher.get_hash(name)},
)
elif target == "DeleteStateMachine":
event_publisher.fire_event(
event_publisher.EVENT_STEPFUNCTIONS_DELETE_SM,
payload={"m": event_publisher.get_hash(name)},
)
content = to_str(response.content or "") or "{}"
replace = r"\1:\7:\3:\8"
content = re.sub(SM_ARN_REGEX, replace, content)
content = json.loads(content)
def fix_name(obj):
if obj.get("name"):
obj["name"] = re.sub(r"^([^_]+)_(.*)", r"\2", obj["name"])
fix_name(content)
machines = content.get("stateMachines")
if machines:
region_part = ":%s:" % aws_stack.get_region()
machines = [sm for sm in machines if region_part in sm["stateMachineArn"]]
for machine in machines:
fix_name(machine)
content["stateMachines"] = machines
content = json.dumps(content)
set_response_content(response, content)
# instantiate listener
UPDATE_STEPFUNCTIONS = ProxyListenerStepFunctions()
| Python | 5 | suryatmodulus/localstack | localstack/services/stepfunctions/stepfunctions_listener.py | [
"Apache-2.0"
] |
# frozen_string_literal: true
module ActiveSupport
module NumberHelper
extend ActiveSupport::Autoload
eager_autoload do
autoload :NumberConverter
autoload :RoundingHelper
autoload :NumberToRoundedConverter
autoload :NumberToDelimitedConverter
autoload :NumberToHumanConverter
autoload :NumberToHumanSizeConverter
autoload :NumberToPhoneConverter
autoload :NumberToCurrencyConverter
autoload :NumberToPercentageConverter
end
extend self
# Formats a +number+ into a phone number (US by default e.g., (555)
# 123-9876). You can customize the format in the +options+ hash.
#
# ==== Options
#
# * <tt>:area_code</tt> - Adds parentheses around the area code.
# * <tt>:delimiter</tt> - Specifies the delimiter to use
# (defaults to "-").
# * <tt>:extension</tt> - Specifies an extension to add to the
# end of the generated number.
# * <tt>:country_code</tt> - Sets the country code for the phone
# number.
# * <tt>:pattern</tt> - Specifies how the number is divided into three
# groups with the custom regexp to override the default format.
# ==== Examples
#
# number_to_phone(5551234) # => "555-1234"
# number_to_phone('5551234') # => "555-1234"
# number_to_phone(1235551234) # => "123-555-1234"
# number_to_phone(1235551234, area_code: true) # => "(123) 555-1234"
# number_to_phone(1235551234, delimiter: ' ') # => "123 555 1234"
# number_to_phone(1235551234, area_code: true, extension: 555) # => "(123) 555-1234 x 555"
# number_to_phone(1235551234, country_code: 1) # => "+1-123-555-1234"
# number_to_phone('123a456') # => "123a456"
#
# number_to_phone(1235551234, country_code: 1, extension: 1343, delimiter: '.')
# # => "+1.123.555.1234 x 1343"
#
# number_to_phone(75561234567, pattern: /(\d{1,4})(\d{4})(\d{4})$/, area_code: true)
# # => "(755) 6123-4567"
# number_to_phone(13312345678, pattern: /(\d{3})(\d{4})(\d{4})$/)
# # => "133-1234-5678"
def number_to_phone(number, options = {})
NumberToPhoneConverter.convert(number, options)
end
# Formats a +number+ into a currency string (e.g., $13.65). You
# can customize the format in the +options+ hash.
#
# The currency unit and number formatting of the current locale will be used
# unless otherwise specified in the provided options. No currency conversion
# is performed. If the user is given a way to change their locale, they will
# also be able to change the relative value of the currency displayed with
# this helper. If your application will ever support multiple locales, you
# may want to specify a constant <tt>:locale</tt> option or consider
# using a library capable of currency conversion.
#
# ==== Options
#
# * <tt>:locale</tt> - Sets the locale to be used for formatting
# (defaults to current locale).
# * <tt>:precision</tt> - Sets the level of precision (defaults
# to 2).
# * <tt>:round_mode</tt> - Determine how rounding is performed
# (defaults to :default. See BigDecimal::mode)
# * <tt>:unit</tt> - Sets the denomination of the currency
# (defaults to "$").
# * <tt>:separator</tt> - Sets the separator between the units
# (defaults to ".").
# * <tt>:delimiter</tt> - Sets the thousands delimiter (defaults
# to ",").
# * <tt>:format</tt> - Sets the format for non-negative numbers
# (defaults to "%u%n"). Fields are <tt>%u</tt> for the
# currency, and <tt>%n</tt> for the number.
# * <tt>:negative_format</tt> - Sets the format for negative
# numbers (defaults to prepending a hyphen to the formatted
# number given by <tt>:format</tt>). Accepts the same fields
# than <tt>:format</tt>, except <tt>%n</tt> is here the
# absolute value of the number.
# * <tt>:strip_insignificant_zeros</tt> - If +true+ removes
# insignificant zeros after the decimal separator (defaults to
# +false+).
#
# ==== Examples
#
# number_to_currency(1234567890.50) # => "$1,234,567,890.50"
# number_to_currency(1234567890.506) # => "$1,234,567,890.51"
# number_to_currency(1234567890.506, precision: 3) # => "$1,234,567,890.506"
# number_to_currency(1234567890.506, locale: :fr) # => "1 234 567 890,51 €"
# number_to_currency('123a456') # => "$123a456"
#
# number_to_currency(-0.456789, precision: 0)
# # => "$0"
# number_to_currency(-1234567890.50, negative_format: '(%u%n)')
# # => "($1,234,567,890.50)"
# number_to_currency(1234567890.50, unit: '£', separator: ',', delimiter: '')
# # => "£1234567890,50"
# number_to_currency(1234567890.50, unit: '£', separator: ',', delimiter: '', format: '%n %u')
# # => "1234567890,50 £"
# number_to_currency(1234567890.50, strip_insignificant_zeros: true)
# # => "$1,234,567,890.5"
# number_to_currency(1234567890.50, precision: 0, round_mode: :up)
# # => "$1,234,567,891"
def number_to_currency(number, options = {})
NumberToCurrencyConverter.convert(number, options)
end
# Formats a +number+ as a percentage string (e.g., 65%). You can
# customize the format in the +options+ hash.
#
# ==== Options
#
# * <tt>:locale</tt> - Sets the locale to be used for formatting
# (defaults to current locale).
# * <tt>:precision</tt> - Sets the precision of the number
# (defaults to 3). Keeps the number's precision if +nil+.
# * <tt>:round_mode</tt> - Determine how rounding is performed
# (defaults to :default. See BigDecimal::mode)
# * <tt>:significant</tt> - If +true+, precision will be the number
# of significant_digits. If +false+, the number of fractional
# digits (defaults to +false+).
# * <tt>:separator</tt> - Sets the separator between the
# fractional and integer digits (defaults to ".").
# * <tt>:delimiter</tt> - Sets the thousands delimiter (defaults
# to "").
# * <tt>:strip_insignificant_zeros</tt> - If +true+ removes
# insignificant zeros after the decimal separator (defaults to
# +false+).
# * <tt>:format</tt> - Specifies the format of the percentage
# string The number field is <tt>%n</tt> (defaults to "%n%").
#
# ==== Examples
#
# number_to_percentage(100) # => "100.000%"
# number_to_percentage('98') # => "98.000%"
# number_to_percentage(100, precision: 0) # => "100%"
# number_to_percentage(1000, delimiter: '.', separator: ',') # => "1.000,000%"
# number_to_percentage(302.24398923423, precision: 5) # => "302.24399%"
# number_to_percentage(1000, locale: :fr) # => "1000,000%"
# number_to_percentage(1000, precision: nil) # => "1000%"
# number_to_percentage('98a') # => "98a%"
# number_to_percentage(100, format: '%n %') # => "100.000 %"
# number_to_percentage(302.24398923423, precision: 5, round_mode: :down) # => "302.24398%"
def number_to_percentage(number, options = {})
NumberToPercentageConverter.convert(number, options)
end
# Formats a +number+ with grouped thousands using +delimiter+
# (e.g., 12,324). You can customize the format in the +options+
# hash.
#
# ==== Options
#
# * <tt>:locale</tt> - Sets the locale to be used for formatting
# (defaults to current locale).
# * <tt>:delimiter</tt> - Sets the thousands delimiter (defaults
# to ",").
# * <tt>:separator</tt> - Sets the separator between the
# fractional and integer digits (defaults to ".").
# * <tt>:delimiter_pattern</tt> - Sets a custom regular expression used for
# deriving the placement of delimiter. Helpful when using currency formats
# like INR.
#
# ==== Examples
#
# number_to_delimited(12345678) # => "12,345,678"
# number_to_delimited('123456') # => "123,456"
# number_to_delimited(12345678.05) # => "12,345,678.05"
# number_to_delimited(12345678, delimiter: '.') # => "12.345.678"
# number_to_delimited(12345678, delimiter: ',') # => "12,345,678"
# number_to_delimited(12345678.05, separator: ' ') # => "12,345,678 05"
# number_to_delimited(12345678.05, locale: :fr) # => "12 345 678,05"
# number_to_delimited('112a') # => "112a"
# number_to_delimited(98765432.98, delimiter: ' ', separator: ',')
# # => "98 765 432,98"
# number_to_delimited("123456.78",
# delimiter_pattern: /(\d+?)(?=(\d\d)+(\d)(?!\d))/)
# # => "1,23,456.78"
def number_to_delimited(number, options = {})
NumberToDelimitedConverter.convert(number, options)
end
# Formats a +number+ with the specified level of
# <tt>:precision</tt> (e.g., 112.32 has a precision of 2 if
# +:significant+ is +false+, and 5 if +:significant+ is +true+).
# You can customize the format in the +options+ hash.
#
# ==== Options
#
# * <tt>:locale</tt> - Sets the locale to be used for formatting
# (defaults to current locale).
# * <tt>:precision</tt> - Sets the precision of the number
# (defaults to 3). Keeps the number's precision if +nil+.
# * <tt>:round_mode</tt> - Determine how rounding is performed
# (defaults to :default. See BigDecimal::mode)
# * <tt>:significant</tt> - If +true+, precision will be the number
# of significant_digits. If +false+, the number of fractional
# digits (defaults to +false+).
# * <tt>:separator</tt> - Sets the separator between the
# fractional and integer digits (defaults to ".").
# * <tt>:delimiter</tt> - Sets the thousands delimiter (defaults
# to "").
# * <tt>:strip_insignificant_zeros</tt> - If +true+ removes
# insignificant zeros after the decimal separator (defaults to
# +false+).
#
# ==== Examples
#
# number_to_rounded(111.2345) # => "111.235"
# number_to_rounded(111.2345, precision: 2) # => "111.23"
# number_to_rounded(13, precision: 5) # => "13.00000"
# number_to_rounded(389.32314, precision: 0) # => "389"
# number_to_rounded(111.2345, significant: true) # => "111"
# number_to_rounded(111.2345, precision: 1, significant: true) # => "100"
# number_to_rounded(13, precision: 5, significant: true) # => "13.000"
# number_to_rounded(13, precision: nil) # => "13"
# number_to_rounded(389.32314, precision: 0, round_mode: :up) # => "390"
# number_to_rounded(111.234, locale: :fr) # => "111,234"
#
# number_to_rounded(13, precision: 5, significant: true, strip_insignificant_zeros: true)
# # => "13"
#
# number_to_rounded(389.32314, precision: 4, significant: true) # => "389.3"
# number_to_rounded(1111.2345, precision: 2, separator: ',', delimiter: '.')
# # => "1.111,23"
def number_to_rounded(number, options = {})
NumberToRoundedConverter.convert(number, options)
end
# Formats the bytes in +number+ into a more understandable
# representation (e.g., giving it 1500 yields 1.46 KB). This
# method is useful for reporting file sizes to users. You can
# customize the format in the +options+ hash.
#
# See <tt>number_to_human</tt> if you want to pretty-print a
# generic number.
#
# ==== Options
#
# * <tt>:locale</tt> - Sets the locale to be used for formatting
# (defaults to current locale).
# * <tt>:precision</tt> - Sets the precision of the number
# (defaults to 3).
# * <tt>:round_mode</tt> - Determine how rounding is performed
# (defaults to :default. See BigDecimal::mode)
# * <tt>:significant</tt> - If +true+, precision will be the number
# of significant_digits. If +false+, the number of fractional
# digits (defaults to +true+)
# * <tt>:separator</tt> - Sets the separator between the
# fractional and integer digits (defaults to ".").
# * <tt>:delimiter</tt> - Sets the thousands delimiter (defaults
# to "").
# * <tt>:strip_insignificant_zeros</tt> - If +true+ removes
# insignificant zeros after the decimal separator (defaults to
# +true+)
#
# ==== Examples
#
# number_to_human_size(123) # => "123 Bytes"
# number_to_human_size(1234) # => "1.21 KB"
# number_to_human_size(12345) # => "12.1 KB"
# number_to_human_size(1234567) # => "1.18 MB"
# number_to_human_size(1234567890) # => "1.15 GB"
# number_to_human_size(1234567890123) # => "1.12 TB"
# number_to_human_size(1234567890123456) # => "1.1 PB"
# number_to_human_size(1234567890123456789) # => "1.07 EB"
# number_to_human_size(1234567, precision: 2) # => "1.2 MB"
# number_to_human_size(483989, precision: 2) # => "470 KB"
# number_to_human_size(483989, precision: 2, round_mode: :up) # => "480 KB"
# number_to_human_size(1234567, precision: 2, separator: ',') # => "1,2 MB"
# number_to_human_size(1234567890123, precision: 5) # => "1.1228 TB"
# number_to_human_size(524288000, precision: 5) # => "500 MB"
def number_to_human_size(number, options = {})
NumberToHumanSizeConverter.convert(number, options)
end
# Pretty prints (formats and approximates) a number in a way it
# is more readable by humans (e.g.: 1200000000 becomes "1.2
# Billion"). This is useful for numbers that can get very large
# (and too hard to read).
#
# See <tt>number_to_human_size</tt> if you want to print a file
# size.
#
# You can also define your own unit-quantifier names if you want
# to use other decimal units (e.g.: 1500 becomes "1.5
# kilometers", 0.150 becomes "150 milliliters", etc). You may
# define a wide range of unit quantifiers, even fractional ones
# (centi, deci, mili, etc).
#
# ==== Options
#
# * <tt>:locale</tt> - Sets the locale to be used for formatting
# (defaults to current locale).
# * <tt>:precision</tt> - Sets the precision of the number
# (defaults to 3).
# * <tt>:round_mode</tt> - Determine how rounding is performed
# (defaults to :default. See BigDecimal::mode)
# * <tt>:significant</tt> - If +true+, precision will be the number
# of significant_digits. If +false+, the number of fractional
# digits (defaults to +true+)
# * <tt>:separator</tt> - Sets the separator between the
# fractional and integer digits (defaults to ".").
# * <tt>:delimiter</tt> - Sets the thousands delimiter (defaults
# to "").
# * <tt>:strip_insignificant_zeros</tt> - If +true+ removes
# insignificant zeros after the decimal separator (defaults to
# +true+)
# * <tt>:units</tt> - A Hash of unit quantifier names. Or a
# string containing an i18n scope where to find this hash. It
# might have the following keys:
# * *integers*: <tt>:unit</tt>, <tt>:ten</tt>,
# <tt>:hundred</tt>, <tt>:thousand</tt>, <tt>:million</tt>,
# <tt>:billion</tt>, <tt>:trillion</tt>,
# <tt>:quadrillion</tt>
# * *fractionals*: <tt>:deci</tt>, <tt>:centi</tt>,
# <tt>:mili</tt>, <tt>:micro</tt>, <tt>:nano</tt>,
# <tt>:pico</tt>, <tt>:femto</tt>
# * <tt>:format</tt> - Sets the format of the output string
# (defaults to "%n %u"). The field types are:
# * %u - The quantifier (ex.: 'thousand')
# * %n - The number
#
# ==== Examples
#
# number_to_human(123) # => "123"
# number_to_human(1234) # => "1.23 Thousand"
# number_to_human(12345) # => "12.3 Thousand"
# number_to_human(1234567) # => "1.23 Million"
# number_to_human(1234567890) # => "1.23 Billion"
# number_to_human(1234567890123) # => "1.23 Trillion"
# number_to_human(1234567890123456) # => "1.23 Quadrillion"
# number_to_human(1234567890123456789) # => "1230 Quadrillion"
# number_to_human(489939, precision: 2) # => "490 Thousand"
# number_to_human(489939, precision: 4) # => "489.9 Thousand"
# number_to_human(489939, precision: 2
# , round_mode: :down) # => "480 Thousand"
# number_to_human(1234567, precision: 4,
# significant: false) # => "1.2346 Million"
# number_to_human(1234567, precision: 1,
# separator: ',',
# significant: false) # => "1,2 Million"
#
# number_to_human(500000000, precision: 5) # => "500 Million"
# number_to_human(12345012345, significant: false) # => "12.345 Billion"
#
# Non-significant zeros after the decimal separator are stripped
# out by default (set <tt>:strip_insignificant_zeros</tt> to
# +false+ to change that):
#
# number_to_human(12.00001) # => "12"
# number_to_human(12.00001, strip_insignificant_zeros: false) # => "12.0"
#
# ==== Custom Unit Quantifiers
#
# You can also use your own custom unit quantifiers:
# number_to_human(500000, units: { unit: 'ml', thousand: 'lt' }) # => "500 lt"
#
# If in your I18n locale you have:
#
# distance:
# centi:
# one: "centimeter"
# other: "centimeters"
# unit:
# one: "meter"
# other: "meters"
# thousand:
# one: "kilometer"
# other: "kilometers"
# billion: "gazillion-distance"
#
# Then you could do:
#
# number_to_human(543934, units: :distance) # => "544 kilometers"
# number_to_human(54393498, units: :distance) # => "54400 kilometers"
# number_to_human(54393498000, units: :distance) # => "54.4 gazillion-distance"
# number_to_human(343, units: :distance, precision: 1) # => "300 meters"
# number_to_human(1, units: :distance) # => "1 meter"
# number_to_human(0.34, units: :distance) # => "34 centimeters"
def number_to_human(number, options = {})
NumberToHumanConverter.convert(number, options)
end
end
end
| Ruby | 5 | jstncarvalho/rails | activesupport/lib/active_support/number_helper.rb | [
"MIT"
] |
# RUN: llc -mtriple=arm64-apple-ios11.0.0 -o - -run-pass none %s | FileCheck %s
...
---
name: namedVRegFunc
body: |
bb.0:
liveins: $x0, $w0, $d0, $d1
%0:fpr64 = COPY $d0
%1:fpr64 = COPY $d1
;CHECK: %foo:gpr32 = COPY $w0
;CHECK: %bar:gpr32 = COPY $x0
;CHECK: %foobar:gpr32 = COPY %foo
;CHECK: COPY %foobar
;CHECK: %baz:gpr32 = COPY
;CHECK: $w0 = COPY %baz
%foo:gpr32 = COPY $w0
%bar:gpr32 = COPY $x0
%foobar:gpr32 = COPY %foo
%2:gpr32 = COPY %foobar
%baz:gpr32 = COPY %2
$w0 = COPY %baz
RET_ReallyLR implicit $w0
...
| Mirah | 4 | medismailben/llvm-project | llvm/test/CodeGen/MIR/AArch64/namedvregs.mir | [
"Apache-2.0"
] |
CNoise noise => AmbPan3 pan => dac;
0.1 => noise.gain;
"pink" => noise.mode;
// W X Y Z R S T U V K L M N O P Q
[0, 1, 2, 7, 8, 9, 10, 3, 4,11,12,13, 14, 15, 5, 6] => pan.channelMap;
0 => pan.elevation;
pi/2 => pan.azimuth;
while(true)
{
//pan.azimuth()+pi/1024 => pan.azimuth;
pan.elevation() + pi/1024 => pan.elevation;
5::ms => now;
}
| ChucK | 3 | ccdarabundit/chugins | AmbPan/AmbPan3-CCRMA.ck | [
"MIT"
] |
CopyStmt: COPY opt_binary qualified_name opt_column_list opt_oids
copy_from opt_program copy_file_name copy_delimiter opt_with copy_options
{
PGCopyStmt *n = makeNode(PGCopyStmt);
n->relation = $3;
n->query = NULL;
n->attlist = $4;
n->is_from = $6;
n->is_program = $7;
n->filename = $8;
if (n->is_program && n->filename == NULL)
ereport(ERROR,
(errcode(PG_ERRCODE_SYNTAX_ERROR),
errmsg("STDIN/STDOUT not allowed with PROGRAM"),
parser_errposition(@8)));
n->options = NIL;
/* Concatenate user-supplied flags */
if ($2)
n->options = lappend(n->options, $2);
if ($5)
n->options = lappend(n->options, $5);
if ($9)
n->options = lappend(n->options, $9);
if ($11)
n->options = list_concat(n->options, $11);
$$ = (PGNode *)n;
}
| COPY '(' PreparableStmt ')' TO opt_program copy_file_name opt_with copy_options
{
PGCopyStmt *n = makeNode(PGCopyStmt);
n->relation = NULL;
n->query = $3;
n->attlist = NIL;
n->is_from = false;
n->is_program = $6;
n->filename = $7;
n->options = $9;
if (n->is_program && n->filename == NULL)
ereport(ERROR,
(errcode(PG_ERRCODE_SYNTAX_ERROR),
errmsg("STDIN/STDOUT not allowed with PROGRAM"),
parser_errposition(@5)));
$$ = (PGNode *)n;
}
;
copy_from:
FROM { $$ = true; }
| TO { $$ = false; }
;
copy_delimiter:
opt_using DELIMITERS Sconst
{
$$ = makeDefElem("delimiter", (PGNode *)makeString($3), @2);
}
| /*EMPTY*/ { $$ = NULL; }
;
copy_generic_opt_arg_list:
copy_generic_opt_arg_list_item
{
$$ = list_make1($1);
}
| copy_generic_opt_arg_list ',' copy_generic_opt_arg_list_item
{
$$ = lappend($1, $3);
}
;
opt_using:
USING {}
| /*EMPTY*/ {}
;
opt_as: AS {}
| /* EMPTY */ {}
;
opt_program:
PROGRAM { $$ = true; }
| /* EMPTY */ { $$ = false; }
;
copy_options: copy_opt_list { $$ = $1; }
| '(' copy_generic_opt_list ')' { $$ = $2; }
;
copy_generic_opt_arg:
opt_boolean_or_string { $$ = (PGNode *) makeString($1); }
| NumericOnly { $$ = (PGNode *) $1; }
| '*' { $$ = (PGNode *) makeNode(PGAStar); }
| '(' copy_generic_opt_arg_list ')' { $$ = (PGNode *) $2; }
| /* EMPTY */ { $$ = NULL; }
;
copy_generic_opt_elem:
ColLabel copy_generic_opt_arg
{
$$ = makeDefElem($1, $2, @1);
}
;
opt_oids:
WITH OIDS
{
$$ = makeDefElem("oids", (PGNode *)makeInteger(true), @1);
}
| /*EMPTY*/ { $$ = NULL; }
;
copy_opt_list:
copy_opt_list copy_opt_item { $$ = lappend($1, $2); }
| /* EMPTY */ { $$ = NIL; }
;
opt_binary:
BINARY
{
$$ = makeDefElem("format", (PGNode *)makeString("binary"), @1);
}
| /*EMPTY*/ { $$ = NULL; }
;
copy_opt_item:
BINARY
{
$$ = makeDefElem("format", (PGNode *)makeString("binary"), @1);
}
| OIDS
{
$$ = makeDefElem("oids", (PGNode *)makeInteger(true), @1);
}
| FREEZE
{
$$ = makeDefElem("freeze", (PGNode *)makeInteger(true), @1);
}
| DELIMITER opt_as Sconst
{
$$ = makeDefElem("delimiter", (PGNode *)makeString($3), @1);
}
| NULL_P opt_as Sconst
{
$$ = makeDefElem("null", (PGNode *)makeString($3), @1);
}
| CSV
{
$$ = makeDefElem("format", (PGNode *)makeString("csv"), @1);
}
| HEADER_P
{
$$ = makeDefElem("header", (PGNode *)makeInteger(true), @1);
}
| QUOTE opt_as Sconst
{
$$ = makeDefElem("quote", (PGNode *)makeString($3), @1);
}
| ESCAPE opt_as Sconst
{
$$ = makeDefElem("escape", (PGNode *)makeString($3), @1);
}
| FORCE QUOTE columnList
{
$$ = makeDefElem("force_quote", (PGNode *)$3, @1);
}
| FORCE QUOTE '*'
{
$$ = makeDefElem("force_quote", (PGNode *)makeNode(PGAStar), @1);
}
| FORCE NOT NULL_P columnList
{
$$ = makeDefElem("force_not_null", (PGNode *)$4, @1);
}
| FORCE NULL_P columnList
{
$$ = makeDefElem("force_null", (PGNode *)$3, @1);
}
| ENCODING Sconst
{
$$ = makeDefElem("encoding", (PGNode *)makeString($2), @1);
}
;
copy_generic_opt_arg_list_item:
opt_boolean_or_string { $$ = (PGNode *) makeString($1); }
;
copy_file_name:
Sconst { $$ = $1; }
| STDIN { $$ = NULL; }
| STDOUT { $$ = NULL; }
;
copy_generic_opt_list:
copy_generic_opt_elem
{
$$ = list_make1($1);
}
| copy_generic_opt_list ',' copy_generic_opt_elem
{
$$ = lappend($1, $3);
}
;
| Yacc | 4 | AldoMyrtaj/duckdb | third_party/libpg_query/grammar/statements/copy.y | [
"MIT"
] |
import Debug "mo:base/Debug";
import Text "mo:base/Text";
import Blob "mo:base/Blob";
import Iter "mo:base/Iter";
import Char "mo:base/Char";
import Order "mo:base/Order";
import Array "mo:base/Array";
import Nat32 "mo:base/Nat32";
import Suite "mo:matchers/Suite";
import M "mo:matchers/Matchers";
import T "mo:matchers/Testable";
let {run;test;suite} = Suite;
func charT(c : Char): T.TestableItem<Char> = {
item = c;
display = Text.fromChar;
equals = Char.equal;
};
func blobT(b : Blob): T.TestableItem<Blob> = {
item = b;
display = func(b : Blob) : Text { debug_show(b) };
equals = Blob.equal;
};
func ordT(o : Order.Order): T.TestableItem<Order.Order> = {
item = o;
display = func (o : Order.Order) : Text { debug_show(o) };
equals = Order.equal;
};
func optTextT(ot : ?Text): T.TestableItem<?Text> = T.optional(T.textTestable, ot);
// TODO: generalize and move to Iter.mo
func iterT(c : [Char]): T.TestableItem<Iter.Iter<Char>> = {
item = c.vals();
display = Text.fromIter; // not this will only print the remainder of cs1 below
equals = func (cs1 : Iter.Iter<Char>, cs2 : Iter.Iter<Char>) : Bool {
loop {
switch (cs1.next(), cs2.next()) {
case (null,null) return true;
case (? c1, ? c2)
if (c1 != c2) return false;
case (_, _) return false;
}
}
};
};
// TODO: generalize and move to Iter.mo
func textIterT(c : [Text]): T.TestableItem<Iter.Iter<Text>> = {
item = c.vals();
display = func (ts: Iter.Iter<Text>) : Text { Text.join(",", ts) };
// not this will only print the remainder of cs1 below
equals = func (ts1 : Iter.Iter<Text>, ts2 : Iter.Iter<Text>) : Bool {
loop {
switch (ts1.next(), ts2.next()) {
case (null,null) return true;
case (? t1, ? t2)
if (t1 != t2) return false;
case (_, _) return false;
}
}
};
};
run(suite("size",
[
test(
"size-0",
Text.size(""),
M.equals(T.nat 0)),
test(
"size-1",
Text.size("a"),
M.equals(T.nat 1)),
test(
"size-2",
Text.size("abcdefghijklmnopqrstuvwxyz"),
M.equals(T.nat 26)),
test(
"size-3",
Text.size("☃"),
M.equals(T.nat 1)),
test(
"size-4",
Text.size("☃☃"),
M.equals(T.nat 2)),
]));
run(suite("toIter",
[
test(
"toIter-0",
Text.toIter(""),
M.equals(iterT([]))),
test(
"toIter-1",
Text.toIter("a"),
M.equals(iterT (['a']))),
test(
"toIter-2",
Text.toIter("abc"),
M.equals(iterT (['a','b','c']))),
do {
let a = Array.tabulate<Char>(1000, func i = Char.fromNat32(65+%Nat32.fromIntWrap(i % 26)));
test(
"fromIter-2",
Text.toIter(Text.join("", Array.map(a, Char.toText).vals())),
M.equals(iterT a))
},
]));
run(suite("fromIter",
[
test(
"fromIter-0",
Text.fromIter(([].vals())),
M.equals(T.text(""))),
test(
"fromIter-1",
Text.fromIter((['a'].vals())),
M.equals(T.text "a")),
test(
"fromIter-2",
Text.fromIter((['a', 'b', 'c'].vals())),
M.equals(T.text "abc")),
do {
let a = Array.tabulate<Char>(1000, func i = Char.fromNat32(65+%Nat32.fromIntWrap(i % 26)));
test(
"fromIter-3",
Text.fromIter(a.vals()),
M.equals(T.text (Text.join("", Array.map(a, Char.toText).vals()))))
},
]));
run(suite("concat",
[
test(
"concat-0",
Text.concat("",""),
M.equals(T.text(""))),
test(
"concat-1",
Text.concat("","b"),
M.equals(T.text "b")),
test(
"concat-2",
Text.concat("a","b"),
M.equals(T.text "ab")),
test(
"concat-3",
Text.concat("abcdefghijklmno","pqrstuvwxyz"),
M.equals(T.text "abcdefghijklmnopqrstuvwxyz")),
]));
run(suite("join",
[
test(
"join-0",
Text.join("", (["",""].vals())),
M.equals(T.text(""))),
test(
"join-1",
Text.join("", (["","b"].vals())),
M.equals(T.text "b")),
test(
"join-2",
Text.join("", (["a","bb","ccc","dddd"].vals())),
M.equals(T.text "abbcccdddd")),
do {
let a = Array.tabulate<Char>(1000, func i = Char.fromNat32(65+%Nat32.fromIntWrap(i % 26)));
test(
"join-3",
Text.join("", Array.map(a, Char.toText).vals()),
M.equals(T.text (Text.fromIter(a.vals()))))
},
test(
"join-4",
Text.join("", ([].vals())),
M.equals(T.text "")),
test(
"join-5",
Text.join("", (["aaa"].vals())),
M.equals(T.text "aaa")),
]));
run(suite("join",
[
test(
"join-0",
Text.join(",", (["",""].vals())),
M.equals(T.text(","))),
test(
"join-1",
Text.join(",", (["","b"].vals())),
M.equals(T.text ",b")),
test(
"join-2",
Text.join(",", (["a","bb","ccc","dddd"].vals())),
M.equals(T.text "a,bb,ccc,dddd")),
do {
let a = Array.tabulate<Char>(1000, func i = Char.fromNat32(65+%Nat32.fromIntWrap(i % 26)));
test(
"join-3",
Text.join("", Array.map(a, Char.toText).vals()),
M.equals(T.text (Text.fromIter(a.vals()))))
},
test(
"join-4",
Text.join(",", ([].vals())),
M.equals(T.text "")),
test(
"join-5",
Text.join(",", (["aaa"].vals())),
M.equals(T.text "aaa")),
]));
run(suite("split",
[
test(
"split-char-empty",
Text.split("", #char ';'),
M.equals(textIterT([]))),
test(
"split-char-none",
Text.split("abc", #char ';'),
M.equals(textIterT(["abc"]))),
test(
"split-char-empties2",
Text.split(";", #char ';'),
M.equals(textIterT(["",""]))),
test(
"split-char-empties3",
Text.split(";;", #char ';'),
M.equals(textIterT(["","",""]))),
test(
"split-char-singles",
Text.split("a;b;;c;;;d", #char ';'),
M.equals(textIterT(["a","b","","c","","","d"]))),
test(
"split-char-mixed",
Text.split("a;;;ab;;abc;", #char ';'),
M.equals(textIterT(["a","","","ab","","abc",""]))),
do {
let a = Array.tabulate<Text>(1000,func _ = "abc");
let t = Text.join(";", a.vals());
test(
"split-char-large",
Text.split(t, #char ';'),
M.equals(textIterT a))
},
do {
let a = Array.tabulate<Text>(100000,func _ = "abc");
let t = Text.join(";", a.vals());
test(
"split-char-very-large",
Text.split(t, #char ';'),
M.equals(textIterT a))
},
]));
do {
let pat : Text.Pattern = #predicate (func (c : Char) : Bool { c == ';' or c == '!' }) ;
run(suite("split",
[
test(
"split-pred-empty",
Text.split("", pat),
M.equals(textIterT([]))),
test(
"split-pred-none",
Text.split("abc", pat),
M.equals(textIterT(["abc"]))),
test(
"split-pred-empties2",
Text.split(";", pat),
M.equals(textIterT(["",""]))),
test(
"split-pred-empties3",
Text.split(";!", pat),
M.equals(textIterT(["","",""]))),
test(
"split-pred-singles",
Text.split("a;b;!c!;;d", pat),
M.equals(textIterT(["a","b","","c","","","d"]))),
test(
"split-pred-mixed",
Text.split("a;!;ab;!abc;", pat),
M.equals(textIterT(["a","","","ab","","abc",""]))),
do {
let a = Array.tabulate<Text>(1000,func _ = "abc");
let t = Text.join(";", a.vals());
test(
"split-pred-large",
Text.split(t, pat),
M.equals(textIterT a))
},
do {
let a = Array.tabulate<Text>(10000,func _ = "abc");
let t = Text.join(";", a.vals());
test(
"split-pred-very-large",
Text.split(t, pat),
M.equals(textIterT a))
},
]))
};
do {
let pat : Text.Pattern = #text "PAT" ;
run(suite("split",
[
test(
"split-pat-empty",
Text.split("", pat),
M.equals(textIterT([]))),
test(
"split-pat-none",
Text.split("abc", pat),
M.equals(textIterT(["abc"]))),
test(
"split-pat-empties2",
Text.split("PAT", pat),
M.equals(textIterT(["",""]))),
test(
"split-pat-empties3",
Text.split("PATPAT", pat),
M.equals(textIterT(["","",""]))),
test(
"split-pat-singles",
Text.split("aPATbPATPATcPATPATPATd", pat),
M.equals(textIterT(["a","b","","c","","","d"]))),
test(
"split-pat-mixed",
Text.split("aPATPATPATabPATPATabcPAT", pat),
M.equals(textIterT(["a","","","ab","","abc",""]))),
do {
let a = Array.tabulate<Text>(1000,func _ = "abc");
let t = Text.join("PAT", a.vals());
test(
"split-pat-large",
Text.split(t, pat),
M.equals(textIterT a))
},
do {
let a = Array.tabulate<Text>(10000,func _ = "abc");
let t = Text.join("PAT", a.vals());
test(
"split-pat-very-large",
Text.split(t, pat),
M.equals(textIterT a))
},
]))
};
run(suite("tokens",
[
test(
"tokens-char-empty",
Text.tokens("", #char ';'),
M.equals(textIterT([]))),
test(
"tokens-char-none",
Text.tokens("abc", #char ';'),
M.equals(textIterT(["abc"]))),
test(
"tokens-char-empties2",
Text.tokens(";", #char ';'),
M.equals(textIterT([]))),
test(
"tokens-char-empties3",
Text.tokens(";;", #char ';'),
M.equals(textIterT([]))),
test(
"tokens-char-singles",
Text.tokens("a;b;;c;;;d", #char ';'),
M.equals(textIterT(["a","b","c","d"]))),
test(
"tokens-char-mixed",
Text.tokens("a;;;ab;;abc;", #char ';'),
M.equals(textIterT(["a","ab","abc"]))),
do {
let a = Array.tabulate<Text>(1000,func _ = "abc");
let t = Text.join(";;", a.vals());
test(
"tokens-char-large",
Text.tokens(t, #char ';'),
M.equals(textIterT a))
},
do {
let a = Array.tabulate<Text>(100000,func _ = "abc");
let t = Text.join(";;", a.vals());
test(
"tokens-char-very-large",
Text.tokens(t, #char ';'),
M.equals(textIterT a))
},
]));
run(suite("startsWith",
[
test(
"startsWith-both-empty",
Text.startsWith("", #text ""),
M.equals(T.bool true)),
test(
"startsWith-empty-text",
Text.startsWith("", #text "abc"),
M.equals(T.bool false)),
test(
"startsWith-empty-pat",
Text.startsWith("abc", #text ""),
M.equals(T.bool true)),
test(
"startsWith-1",
Text.startsWith("a", #text "b"),
M.equals(T.bool false)),
test(
"startsWith-2",
Text.startsWith("abc", #text "abc"),
M.equals(T.bool true)),
test(
"startsWith-3",
Text.startsWith("abcd", #text "ab"),
M.equals(T.bool true)),
test(
"startsWith-4",
Text.startsWith("abcdefghijklmnopqrstuvwxyz",#text "abcdefghijklmno"),
M.equals(T.bool true)),
]));
run(suite("endsWith",
[
test(
"endsWith-both-empty",
Text.endsWith("", #text ""),
M.equals(T.bool true)),
test(
"endsWith-empty-text",
Text.endsWith("", #text "abc"),
M.equals(T.bool false)),
test(
"endsWith-empty-pat",
Text.endsWith("abc", #text ""),
M.equals(T.bool true)),
test(
"endsWith-1",
Text.endsWith("a", #text "b"),
M.equals(T.bool false)),
test(
"endsWith-2",
Text.endsWith("abc", #text "abc"),
M.equals(T.bool true)),
test(
"endsWith-3",
Text.endsWith("abcd", #text "cd"),
M.equals(T.bool true)),
test(
"endsWith-4",
Text.endsWith("abcdefghijklmnopqrstuvwxyz",#text "pqrstuvwxyz"),
M.equals(T.bool true)),
]));
run(suite("contains",
[
test(
"contains-start",
Text.contains("abcd", #text "ab"),
M.equals(T.bool true)),
test(
"contains-empty",
Text.contains("abc", #text ""),
M.equals(T.bool true)),
test(
"contains-false",
Text.contains("ab", #text "bc" ),
M.equals(T.bool false)),
test(
"contains-exact",
Text.contains("abc", #text "abc"),
M.equals(T.bool true)),
test(
"contains-within",
Text.contains("abcdefghijklmnopqrstuvwxyz", #text "qrst"),
M.equals(T.bool true)),
test(
"contains-front",
Text.contains("abcdefghijklmnopqrstuvwxyz", #text "abcdefg"),
M.equals(T.bool true)),
test(
"contains-end",
Text.contains("abcdefghijklmnopqrstuvwxyz", #text "xyz"),
M.equals(T.bool true)),
test(
"contains-false",
Text.contains("abcdefghijklmnopqrstuvwxyz", #text "lkj"),
M.equals(T.bool false)),
test(
"contains-empty-nonempty",
Text.contains("", #text "xyz"),
M.equals(T.bool false)),
]));
run(suite("replace",
[
test(
"replace-start",
Text.replace("abcd", #text "ab", "AB"),
M.equals(T.text "ABcd")),
test(
"replace-empty",
Text.replace("abc", #text "", "AB"),
M.equals(T.text "ABaABbABcAB")),
test(
"replace-none",
Text.replace("ab", #text "bc", "AB"),
M.equals(T.text "ab")),
test(
"replace-exact",
Text.replace("ab", #text "ab", "AB"),
M.equals(T.text "AB")),
test(
"replace-several",
Text.replace("abcdabghijabmnopqrstuabwxab", #text "ab", "AB"),
M.equals(T.text "ABcdABghijABmnopqrstuABwxAB")),
test(
"replace-delete",
Text.replace("abcdabghijabmnopqrstuabwxab", #text "ab", ""),
M.equals(T.text "cdghijmnopqrstuwx")),
test(
"replace-pred",
Text.replace("abcdefghijklmnopqrstuvwxyz", #predicate (func (c : Char) : Bool { c < 'm'}), ""),
M.equals(T.text "mnopqrstuvwxyz")),
test(
"replace-partial",
Text.replace("123", #text "124", "ABC"),
M.equals(T.text "123")),
test(
"replace-partial-2",
Text.replace("12341235124", #text "124", "ABC"),
M.equals(T.text "12341235ABC")),
test(
"replace-partial-3",
Text.replace("111234123511124", #text "124", "ABC"),
M.equals(T.text "111234123511ABC")),
]));
run(suite("stripStart",
[
test(
"stripStart-none",
Text.stripStart("cd", #text "ab"),
M.equals(optTextT (null))),
test(
"stripStart-one",
Text.stripStart("abcd", #text "ab"),
M.equals(optTextT (?"cd"))),
test(
"stripStart-two",
Text.stripStart("abababcd", #text "ab", ),
M.equals(optTextT (?"ababcd"))),
test(
"stripStart-only",
Text.stripStart("ababababab", #text "ab", ),
M.equals(optTextT (?"abababab"))),
test(
"stripStart-empty",
Text.stripStart("abcdef", #text ""),
M.equals(optTextT(?"abcdef"))),
test(
"stripStart-tooshort",
Text.stripStart("abcdef", #text "abcdefg"),
M.equals(optTextT(null))),
]));
run(suite("stripEnd",
[
test(
"stripEnd-exact",
Text.stripEnd("cd", #text "cd"),
M.equals(optTextT (?""))),
test(
"stripEnd-one",
Text.stripEnd("abcd", #text "cd"),
M.equals(optTextT (?"ab"))),
test(
"stripEnd-three",
Text.stripEnd("abcdcdcd", #text "cd", ),
M.equals(optTextT (?"abcdcd"))),
test(
"stripEnd-many",
Text.stripEnd("cdcdcdcdcdcdcd", #text "cd", ),
M.equals(optTextT (?"cdcdcdcdcdcd"))),
test(
"stripEnd-empty-pat",
Text.stripEnd("abcdef", #text ""),
M.equals(optTextT (?"abcdef"))),
test(
"stripEnd-empty",
Text.stripEnd("", #text "cd"),
M.equals(optTextT null)),
test(
"stripEnd-tooshort",
Text.stripEnd("bcdef", #text "abcdef"),
M.equals(optTextT null)),
]));
run(suite("trimStart",
[
test(
"trimStart-none",
Text.trimStart("cd", #text "ab"),
M.equals(T.text "cd")),
test(
"trimStart-one",
Text.trimStart("abcd", #text "ab"),
M.equals(T.text "cd")),
test(
"trimStart-two",
Text.trimStart("abababcd", #text "ab", ),
M.equals(T.text "cd")),
test(
"trimStart-only",
Text.trimStart("ababababab", #text "ab", ),
M.equals(T.text "")),
test(
"trimStart-empty",
Text.trimStart("abcdef", #text ""),
M.equals(T.text "abcdef")),
]));
run(suite("trimEnd",
[
test(
"trimEnd-exact",
Text.trimEnd("cd", #text "cd"),
M.equals(T.text "")),
test(
"trimEnd-one",
Text.trimEnd("abcd", #text "cd"),
M.equals(T.text "ab")),
test(
"trimEnd-three",
Text.trimEnd("abcdcdcd", #text "cd", ),
M.equals(T.text "ab")),
test(
"trimEnd-many",
Text.trimEnd("cdcdcdcdcdcdcd", #text "cd", ),
M.equals(T.text "")),
test(
"trimEnd-empty-pat",
Text.trimEnd("abcdef", #text ""),
M.equals(T.text "abcdef")),
test(
"trimEnd-empty",
Text.trimEnd("", #text "cd"),
M.equals(T.text "")),
]));
run(suite("trim",
[
test(
"trim-exact",
Text.trim("cd", #text "cd"),
M.equals(T.text "")),
test(
"trim-one",
Text.trim("cdabcd", #text "cd"),
M.equals(T.text "ab")),
test(
"trim-three",
Text.trim("cdcdcdabcdcdcd", #text "cd", ),
M.equals(T.text "ab")),
test(
"trim-many",
Text.trim("cdcdcdcdcdcdcd", #text "cd", ),
M.equals(T.text "")),
test(
"trim-empty-pat",
Text.trim("abcdef", #text ""),
M.equals(T.text "abcdef")),
test(
"trim-empty",
Text.trim("", #text "cd"),
M.equals(T.text "")),
]));
do {
let cmp = Char.compare;
run(suite("compareWith",
[
test(
"compareWith-empties",
Text.compareWith("", "", cmp),
M.equals(ordT (#equal))),
test(
"compareWith-empty",
Text.compareWith("abc", "", cmp),
M.equals(ordT (#greater))),
test(
"compareWith-equal-nonempty",
Text.compareWith("abc", "abc", cmp ),
M.equals(ordT (#equal))),
test(
"compareWith-less-nonempty",
Text.compareWith("abc", "abd", cmp),
M.equals(ordT (#less))),
test(
"compareWith-less-nonprefix",
Text.compareWith("abc", "abcd", cmp),
M.equals(ordT (#less))),
test(
"compareWith-empty-nonempty",
Text.compareWith("", "abcd", cmp),
M.equals(ordT (#less))),
test(
"compareWith-prefix",
Text.compareWith("abcd", "abc", cmp),
M.equals(ordT (#greater)))
]))
};
do {
let cmp = func (c1 : Char, c2 : Char) : Order.Order {
switch (Char.compare (c1, c2)) {
case (#less) #greater;
case (#equal) #equal;
case (#greater) #less;
};
};
run(suite("compareWith-flip",
[
test(
"compareWith-flip-greater",
Text.compareWith("abc", "abd", cmp),
M.equals(ordT (#greater))),
test(
"compareWith-flip-less",
Text.compareWith("abd", "abc", cmp),
M.equals(ordT (#less)))
]))
};
run(suite("utf8",
[
test(
"encode-literal",
Text.encodeUtf8("FooBär☃"),
M.equals(blobT("FooBär☃"))),
test(
"encode-concat",
Text.encodeUtf8("Foo" # "Bär" # "☃"),
M.equals(blobT("FooBär☃"))),
test(
"decode-literal-good",
Text.decodeUtf8("FooBär☃"),
M.equals(optTextT(?"FooBär☃"))),
test(
"decode-literal-bad1",
Text.decodeUtf8("\FF"),
M.equals(optTextT(null))),
test(
"decode-literal-bad2",
Text.decodeUtf8("\D8\00t d"),
M.equals(optTextT(null))),
]));
| Modelica | 4 | nomeata/motoko-base | test/textTest.mo | [
"Apache-2.0"
] |
@import <Foundation/Foundation.j>
@implementation CSGPort : CPObject <CPCoding>
{
CPString portName @accessors(getter=name);
BOOL isInport @accessors(getter=isInport);
CGSize portSize;
}
+ (id)inportWithName:(CPString)name
{
return [[self alloc] initWithName:name isInport:YES];
}
+ (id)outportWithName:(CPString)name
{
return [[self alloc] initWithName:name isInport:NO];
}
- (id)initWithName:(CPString)name isInport:(BOOL)flag
{
if(self = [super init])
{
portName = name;
isInport = flag;
portSize = CGSizeMakeZero();
}
return self;
}
//
// Implement CPCoding protocol for serialization
//
- (id)initWithCoder:(CPCoder)coder
{
self = [super init];
if (self) {
portName = [coder decodeObjectForKey:@"portName"];
isInport = [coder decodeBoolForKey:@"isInport"];
portSize = CGSizeMakeZero();
}
return self;
}
- (void)encodeWithCoder:(CPCoder)coder
{
[coder encodeObject:portName forKey:@"portName"];
[coder encodeBool:isInport forKey:@"isInport"];
}
@end | Jasmin | 4 | gabrielcercel/calvin-base | calvinextras/CalvinGUI/CSGPort.j | [
"Apache-2.0"
] |
abstract class Foo
{
abstract const Str? a
virtual const Str? b
} | Fantom | 2 | fanx-dev/fanx | compiler/testCompilerx/res/inherit/testConstOverridesErrors3.fan | [
"AFL-3.0"
] |
single_case_Partition := module()
uses Domain, Domain_Type;
export SimplName := "Single case partition";
export SimplOrder := 11;
export ModuleApply := proc(vs :: DomBound, sh :: DomShape, $)
subsindets(sh, DomSplit, x->do_simp(op(x)));
end proc;
local do_simp := proc(p:: Partition,$)::DomShape;
local r := Partition:-Simpl:-single_nonzero_piece_cps(
proc(c,v) if v::DomConstrain then DConstrain(conv_bool(c),op(v)) else p end if
end proc,p,_testzero=(x->x=DSum()));
if r :: Partition then DSplit(r) else r end if;
end proc;
local conv_bool := proc(r, $)
if r :: {specfunc(`And`), `and`} then
op(map(conv_bool,r))
else
r
end if;
end proc;
end module;
Partition_simpl := module()
uses Domain, Domain_Type;
export SimplName := "Partition simpl";
export SimplOrder := (10+1/2);
local TRY := proc(bnds, kb, kb_rn, as, pr)
local r, ns;
r := subs(kb_rn, op(1,pr));
ns := op(1,bnds);
ns := select(b->op(3,b) in {`Int`,`Ints`}, ns);
ns := map(curry(op,1), ns);
r := Partition:-Simpl(r, kb, _name_cands=ns, _testequal=`=`) assuming op(as);
if not r :: Partition then r else DSplit(r) end if;
end proc;
export ModuleApply := proc(vs :: DomBound, sh :: DomShape, $)
local as := Domain:-Bound:-toConstraints(vs, 'bound_types');
subsindets(sh, DomSplit, curry(TRY,vs, op(Domain:-Bound:-toKB(vs)),as));
end proc;
end module;
| Maple | 4 | vmchale/hakaru | maple/Domain/Improve/Partitions.mpl | [
"BSD-3-Clause"
] |
package gw.lang.annotations
enhancement HasShortCircuitingPropertiesEnhancement : gw.lang.annotations.HasShortCircuitingProperties {
function callShortCircuitingIntPropInEnhancement() : int {
return this?.Chained?.ShortCircuitIntProperty
}
@ShortCircuitingProperty
property get ShortCircuitIntPropertyEnh() : int {
return 11
}
function callCountMethodOnList() : Object {
return this?.AList?.Count
}
function callCountMethodOnArray() : Object {
return this?.AnArray?.Count
}
}
| Gosu | 4 | tcmoore32/sheer-madness | gosu-test/src/test/gosu/gw/lang/annotations/HasShortCircuitingPropertiesEnhancement.gsx | [
"Apache-2.0"
] |
.Group {
transition: all ease-in-out 250ms;
}
.Rect {
cursor: pointer;
stroke: var(--color-background);
transition: all ease-in-out 250ms;
}
.ForeignObject {
pointer-events: none;
transition: all ease-in-out 250ms;
}
.Div {
pointer-events: none;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
font-family: var(--font-family-sans);
font-size: var(--font-size-sans-normal);
margin-left: 0.25rem;
margin-right: 0.25rem;
line-height: 1.5;
padding: 0 0 0;
font-weight: 400;
color: var(--color-commit-gradient-text);
text-align: left;
transition: all ease-in-out 250ms;
}
| CSS | 3 | vegYY/react | packages/react-devtools-shared/src/devtools/views/Profiler/ChartNode.css | [
"MIT"
] |
{
"@context": {
"@vocab": "http://example.com/subdir/",
"vocab/date": { "@type": "vocab/types/dateTime" }
}
}
| JSONLD | 2 | fsteeg/json-ld-api | tests/compact/0021-context.jsonld | [
"W3C"
] |
#pragma once
// We want to allow 128-bit wide SIMD if either NEON is available (as
// detected by GEMMLOWP_NEON), or whether SSE4.2 and Clang is
// available (in which case we will use the neon_sse.h library to
// share source between the two implementations). We use SSE4.2 to
// ensure we can use the full neon2sse library, and we use Clang as
// GCC has issues correctly compiling some parts of the neon2sse
// library.
// Otherwise, the INT8_NEON_SIMD variable will be undefined.
#include "gemmlowp/fixedpoint/fixedpoint.h"
#include "gemmlowp/public/gemmlowp.h"
#ifdef GEMMLOWP_NEON
#define INT8_NEON_SIMD
#endif
#if defined(__SSE4_2__) && defined(__clang__)
#include "NEON_2_SSE.h"
#define INT8_NEON_SIMD
#endif
| C | 4 | Hacky-DH/pytorch | caffe2/operators/quantized/int8_simd.h | [
"Intel"
] |
#version 330
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord;
in vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform sampler2D mask;
uniform int frame;
// Output fragment color
out vec4 finalColor;
void main()
{
vec4 maskColour = texture(mask, fragTexCoord + vec2(sin(-frame/150.0)/10.0, cos(-frame/170.0)/10.0));
if (maskColour.r < 0.25) discard;
vec4 texelColor = texture(texture0, fragTexCoord + vec2(sin(frame/90.0)/8.0, cos(frame/60.0)/8.0));
finalColor = texelColor*maskColour;
}
| F# | 4 | chrisws/raylib | examples/shaders/resources/shaders/glsl330/mask.fs | [
"Zlib"
] |
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2003, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// CIE (x,y) chromaticities, and conversions between
// RGB tiples and CIE XYZ tristimulus values.
//
//-----------------------------------------------------------------------------
#include <ImfChromaticities.h>
#include "ImfNamespace.h"
#include <string.h>
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
Chromaticities::Chromaticities (const IMATH_NAMESPACE::V2f &red,
const IMATH_NAMESPACE::V2f &green,
const IMATH_NAMESPACE::V2f &blue,
const IMATH_NAMESPACE::V2f &white)
:
red (red),
green (green),
blue (blue),
white (white)
{
// empty
}
bool
Chromaticities::operator == (const Chromaticities & c) const
{
return red == c.red && green == c.green && blue == c.blue;
}
bool
Chromaticities::operator != (const Chromaticities & c) const
{
return red != c.red || green != c.green || blue != c.blue;
}
IMATH_NAMESPACE::M44f
RGBtoXYZ (const Chromaticities chroma, float Y)
{
//
// For an explanation of how the color conversion matrix is derived,
// see Roy Hall, "Illumination and Color in Computer Generated Imagery",
// Springer-Verlag, 1989, chapter 3, "Perceptual Response"; and
// Charles A. Poynton, "A Technical Introduction to Digital Video",
// John Wiley & Sons, 1996, chapter 7, "Color science for video".
//
//
// X and Z values of RGB value (1, 1, 1), or "white"
//
float X = chroma.white.x * Y / chroma.white.y;
float Z = (1 - chroma.white.x - chroma.white.y) * Y / chroma.white.y;
//
// Scale factors for matrix rows
//
float d = chroma.red.x * (chroma.blue.y - chroma.green.y) +
chroma.blue.x * (chroma.green.y - chroma.red.y) +
chroma.green.x * (chroma.red.y - chroma.blue.y);
float Sr = (X * (chroma.blue.y - chroma.green.y) -
chroma.green.x * (Y * (chroma.blue.y - 1) +
chroma.blue.y * (X + Z)) +
chroma.blue.x * (Y * (chroma.green.y - 1) +
chroma.green.y * (X + Z))) / d;
float Sg = (X * (chroma.red.y - chroma.blue.y) +
chroma.red.x * (Y * (chroma.blue.y - 1) +
chroma.blue.y * (X + Z)) -
chroma.blue.x * (Y * (chroma.red.y - 1) +
chroma.red.y * (X + Z))) / d;
float Sb = (X * (chroma.green.y - chroma.red.y) -
chroma.red.x * (Y * (chroma.green.y - 1) +
chroma.green.y * (X + Z)) +
chroma.green.x * (Y * (chroma.red.y - 1) +
chroma.red.y * (X + Z))) / d;
//
// Assemble the matrix
//
IMATH_NAMESPACE::M44f M;
M[0][0] = Sr * chroma.red.x;
M[0][1] = Sr * chroma.red.y;
M[0][2] = Sr * (1 - chroma.red.x - chroma.red.y);
M[1][0] = Sg * chroma.green.x;
M[1][1] = Sg * chroma.green.y;
M[1][2] = Sg * (1 - chroma.green.x - chroma.green.y);
M[2][0] = Sb * chroma.blue.x;
M[2][1] = Sb * chroma.blue.y;
M[2][2] = Sb * (1 - chroma.blue.x - chroma.blue.y);
return M;
}
IMATH_NAMESPACE::M44f
XYZtoRGB (const Chromaticities chroma, float Y)
{
return RGBtoXYZ (chroma, Y).inverse();
}
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
| C++ | 4 | thisisgopalmandal/opencv | 3rdparty/openexr/IlmImf/ImfChromaticities.cpp | [
"BSD-3-Clause"
] |
; macros to read and parse CLI args (for slient installation)
!include FileFunc.nsh
!insertmacro GetParameters
!insertmacro GetOptions
Var ARGV
Function "ParseCLI"
${GetParameters} $ARGV
Call DoParseCLI
FunctionEnd
| NSIS | 3 | JeroenOortwijn/gocd | installers/windows/cli-helpers.nsi | [
"Apache-2.0"
] |
package com.baeldung.testloglevel;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.system.OutputCaptureRule;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD;
@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD)
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = TestLogLevelApplication.class)
@EnableAutoConfiguration(exclude = SecurityAutoConfiguration.class)
@ActiveProfiles("logback-test2")
public class LogbackMultiProfileTestLogLevelIntegrationTest {
@Autowired
private TestRestTemplate restTemplate;
@Rule
public OutputCaptureRule outputCapture = new OutputCaptureRule();
private String baseUrl = "/testLogLevel";
@Test
public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenPrintTraceLogsForOurPackage() {
ResponseEntity<String> response = restTemplate.getForEntity(baseUrl, String.class);
assertThat(response.getStatusCode().value()).isEqualTo(200);
assertThatOutputContainsLogForOurPackage("TRACE");
}
@Test
public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenNoTraceLogsForOtherPackages() {
ResponseEntity<String> response = restTemplate.getForEntity(baseUrl, String.class);
assertThat(response.getStatusCode().value()).isEqualTo(200);
assertThatOutputDoesntContainLogForOtherPackages("TRACE");
}
@Test
public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenPrintErrorLogs() {
ResponseEntity<String> response = restTemplate.getForEntity(baseUrl, String.class);
assertThat(response.getStatusCode().value()).isEqualTo(200);
assertThatOutputContainsLogForOurPackage("ERROR");
assertThatOutputContainsLogForOtherPackages("ERROR");
}
private void assertThatOutputContainsLogForOurPackage(String level) {
assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*");
}
private void assertThatOutputDoesntContainLogForOtherPackages(String level) {
assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level);
}
private void assertThatOutputContainsLogForOtherPackages(String level) {
assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level);
}
}
| Java | 5 | DBatOWL/tutorials | spring-boot-modules/spring-boot-testing-2/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java | [
"MIT"
] |
@import "../Common.scss";
.data_dropdown_wrapper {
display: inline-block;
width: 100%;
.dataDropdown {
position: relative;
width: 100%;
.dropdown_wrapper {
border-radius: 5px;
width: auto;
position: absolute;
padding-inline-start: 0px;
box-shadow: 7px 7px 20px 0 rgba(0, 0, 0, 0.32);
background-color: #ffffff;
color: yellow;
-webkit-padding-start: 0px;
z-index: 10;
li {
display: flex;
align-items: center;
list-style-type: none;
color: #303030;
text-align: left;
padding: 10px 15px;
border-bottom: 1px solid #ededed;
button {
margin-right: 5px;
}
// &:hover {
// background-color: #eee;
// }
}
li:last-child {
border-bottom: none;
}
}
.dropdownRight {
top: -12px;
left: 35px;
}
.dropdownBottom {
top: 32px;
left: 0;
}
.dropdownRight:before,
.dropdownBottom:before {
content: "";
position: absolute;
border: solid 5px transparent;
z-index: 10000;
}
.dropdownRight:before {
border-right-color: white;
left: -10px;
top: 17px;
}
.dropdownBottom:before {
border-bottom-color: white;
top: -10px;
left: 20px;
}
}
}
| SCSS | 3 | gh-oss-contributor/graphql-engine-1 | console/src/components/Common/Dropdown/Dropdown.scss | [
"Apache-2.0",
"MIT"
] |
#import <ATen/native/metal/MetalConvParams.h>
#include <cmath>
namespace at {
namespace native {
namespace metal {
Conv2DParams::Conv2DParams(
c10::IntArrayRef inputSizes,
c10::IntArrayRef weightSizes,
c10::IntArrayRef padding,
c10::IntArrayRef stride,
c10::IntArrayRef dilation,
int64_t groups)
: N(inputSizes[0]),
C(inputSizes[1]),
H(inputSizes[2]),
W(inputSizes[3]),
OC(weightSizes[0]),
IC(weightSizes[1]),
KH(weightSizes[2]),
KW(weightSizes[3]),
SY(stride[0]),
SX(stride[1]),
PY(padding[0]),
PX(padding[1]),
DY(dilation[0]),
DX(dilation[1]),
G(groups) {
OH = std::floor((H + 2 * PY - DY * (KH - 1) - 1) / SY + 1);
OW = std::floor((W + 2 * PX - DX * (KW - 1) - 1) / SX + 1);
};
}
}
}
| Objective-C++ | 4 | Hacky-DH/pytorch | aten/src/ATen/native/metal/MetalConvParams.mm | [
"Intel"
] |
---
dlurDefaultDefPrimDlusName: 1.3.6.1.2.1.34.5.1.1.1.5
dlurNondisDlusDlurSessDeactSup: 1.3.6.1.2.1.34.5.1.1.1.7
dlurPuSscpSuppliedName: 1.3.6.1.2.1.34.5.1.2.1.1.2
dlurDlusEntry: 1.3.6.1.2.1.34.5.1.3.1.1
dlurDlusName: 1.3.6.1.2.1.34.5.1.3.1.1.1
dlurMultiSubnetSupport: 1.3.6.1.2.1.34.5.1.1.1.4
dlurNetworkNameForwardingSupport: 1.3.6.1.2.1.34.5.1.1.1.6
dlurDefaultDefBackupDlusEntry: 1.3.6.1.2.1.34.5.1.1.2.1
dlurDefaultDefBackupDlusIndex: 1.3.6.1.2.1.34.5.1.1.2.1.1
dlurPuEntry: 1.3.6.1.2.1.34.5.1.2.1.1
dlurPuAnsSupport: 1.3.6.1.2.1.34.5.1.2.1.1.4
dlurCompliances: 1.3.6.1.2.1.34.5.2.1
dlurReleaseLevel: 1.3.6.1.2.1.34.5.1.1.1.2
dlurNodeInfo: 1.3.6.1.2.1.34.5.1.1
dlurPuName: 1.3.6.1.2.1.34.5.1.2.1.1.1
dlurDlusInfo: 1.3.6.1.2.1.34.5.1.3
dlurDlusTable: 1.3.6.1.2.1.34.5.1.3.1
dlurGroups: 1.3.6.1.2.1.34.5.2.2
dlurObjects: 1.3.6.1.2.1.34.5.1
dlurPuTable: 1.3.6.1.2.1.34.5.1.2.1
dlurPuDefBackupDlusTable: 1.3.6.1.2.1.34.5.1.2.2
dlurPuDefBackupDlusEntry: 1.3.6.1.2.1.34.5.1.2.2.1
dlurPuDefBackupDlusIndex: 1.3.6.1.2.1.34.5.1.2.2.1.2
dlurMIB: 1.3.6.1.2.1.34.5
dlurPuActiveDlusName: 1.3.6.1.2.1.34.5.1.2.1.1.8
dlurConformance: 1.3.6.1.2.1.34.5.2
dlurDefaultDefBackupDlusName: 1.3.6.1.2.1.34.5.1.1.2.1.2
dlurPuInfo: 1.3.6.1.2.1.34.5.1.2
dlurPuStatus: 1.3.6.1.2.1.34.5.1.2.1.1.3
dlurNodeCapabilities: 1.3.6.1.2.1.34.5.1.1.1
dlurAnsSupport: 1.3.6.1.2.1.34.5.1.1.1.3
dlurDefaultDefBackupDlusTable: 1.3.6.1.2.1.34.5.1.1.2
dlurPuDefPrimDlusName: 1.3.6.1.2.1.34.5.1.2.1.1.9
dlurPuDefBackupDlusName: 1.3.6.1.2.1.34.5.1.2.2.1.3
dlurDlusSessnStatus: 1.3.6.1.2.1.34.5.1.3.1.1.2
dlurPuDlusSessnStatus: 1.3.6.1.2.1.34.5.1.2.1.1.7
dlurPuDefBackupDlusPuName: 1.3.6.1.2.1.34.5.1.2.2.1.1
dlurNodeCpName: 1.3.6.1.2.1.34.5.1.1.1.1
dlurPuLocation: 1.3.6.1.2.1.34.5.1.2.1.1.5
dlurPuLsName: 1.3.6.1.2.1.34.5.1.2.1.1.6
| YAML | 1 | OsmanDere/metasploit-framework | data/snmp/mibs/APPN-DLUR-MIB.yaml | [
"BSD-2-Clause",
"BSD-3-Clause"
] |
extends Spatial
# The size of the quad mesh itself.
var quad_mesh_size
# Used for checking if the mouse is inside the Area
var is_mouse_inside = false
# Used for checking if the mouse was pressed inside the Area
var is_mouse_held = false
# The last non-empty mouse position. Used when dragging outside of the box.
var last_mouse_pos3D = null
# The last processed input touch/mouse event. To calculate relative movement.
var last_mouse_pos2D = null
onready var node_viewport = $Viewport
onready var node_quad = $Quad
onready var node_area = $Quad/Area
func _ready():
node_area.connect("mouse_entered", self, "_mouse_entered_area")
# If the material is NOT set to use billboard settings, then avoid running billboard specific code
if node_quad.get_surface_material(0).params_billboard_mode == 0:
set_process(false)
if OS.get_current_video_driver() == OS.VIDEO_DRIVER_GLES2:
# Required to prevent the texture from being too dark when using GLES2.
# This should be left to `true` in GLES3 to prevent the texture from looking
# washed out there.
node_quad.get_surface_material(0).flags_albedo_tex_force_srgb = false
func _process(_delta):
# NOTE: Remove this function if you don't plan on using billboard settings.
rotate_area_to_billboard()
func _mouse_entered_area():
is_mouse_inside = true
func _unhandled_input(event):
# Check if the event is a non-mouse/non-touch event
var is_mouse_event = false
for mouse_event in [InputEventMouseButton, InputEventMouseMotion, InputEventScreenDrag, InputEventScreenTouch]:
if event is mouse_event:
is_mouse_event = true
break
# If the event is a mouse/touch event and/or the mouse is either held or inside the area, then
# we need to do some additional processing in the handle_mouse function before passing the event to the viewport.
# If the event is not a mouse/touch event, then we can just pass the event directly to the viewport.
if is_mouse_event and (is_mouse_inside or is_mouse_held):
handle_mouse(event)
elif not is_mouse_event:
node_viewport.input(event)
# Handle mouse events inside Area. (Area.input_event had many issues with dragging)
func handle_mouse(event):
# Get mesh size to detect edges and make conversions. This code only support PlaneMesh and QuadMesh.
quad_mesh_size = node_quad.mesh.size
# Detect mouse being held to mantain event while outside of bounds. Avoid orphan clicks
if event is InputEventMouseButton or event is InputEventScreenTouch:
is_mouse_held = event.pressed
# Find mouse position in Area
var mouse_pos3D = find_mouse(event.global_position)
# Check if the mouse is outside of bounds, use last position to avoid errors
# NOTE: mouse_exited signal was unrealiable in this situation
is_mouse_inside = mouse_pos3D != null
if is_mouse_inside:
# Convert click_pos from world coordinate space to a coordinate space relative to the Area node.
# NOTE: affine_inverse accounts for the Area node's scale, rotation, and translation in the scene!
mouse_pos3D = node_area.global_transform.affine_inverse() * mouse_pos3D
last_mouse_pos3D = mouse_pos3D
else:
mouse_pos3D = last_mouse_pos3D
if mouse_pos3D == null:
mouse_pos3D = Vector3.ZERO
# TODO: adapt to bilboard mode or avoid completely
# convert the relative event position from 3D to 2D
var mouse_pos2D = Vector2(mouse_pos3D.x, -mouse_pos3D.y)
# Right now the event position's range is the following: (-quad_size/2) -> (quad_size/2)
# We need to convert it into the following range: 0 -> quad_size
mouse_pos2D.x += quad_mesh_size.x / 2
mouse_pos2D.y += quad_mesh_size.y / 2
# Then we need to convert it into the following range: 0 -> 1
mouse_pos2D.x = mouse_pos2D.x / quad_mesh_size.x
mouse_pos2D.y = mouse_pos2D.y / quad_mesh_size.y
# Finally, we convert the position to the following range: 0 -> viewport.size
mouse_pos2D.x = mouse_pos2D.x * node_viewport.size.x
mouse_pos2D.y = mouse_pos2D.y * node_viewport.size.y
# We need to do these conversions so the event's position is in the viewport's coordinate system.
# Set the event's position and global position.
event.position = mouse_pos2D
event.global_position = mouse_pos2D
# If the event is a mouse motion event...
if event is InputEventMouseMotion:
# If there is not a stored previous position, then we'll assume there is no relative motion.
if last_mouse_pos2D == null:
event.relative = Vector2(0, 0)
# If there is a stored previous position, then we'll calculate the relative position by subtracting
# the previous position from the new position. This will give us the distance the event traveled from prev_pos
else:
event.relative = mouse_pos2D - last_mouse_pos2D
# Update last_mouse_pos2D with the position we just calculated.
last_mouse_pos2D = mouse_pos2D
# Finally, send the processed input event to the viewport.
node_viewport.input(event)
func find_mouse(global_position):
var camera = get_viewport().get_camera()
# From camera center to the mouse position in the Area
var from = camera.project_ray_origin(global_position)
var dist = find_further_distance_to(camera.transform.origin)
var to = from + camera.project_ray_normal(global_position) * dist
# Manually raycasts the are to find the mouse position
var result = get_world().direct_space_state.intersect_ray(from, to, [], node_area.collision_layer,false,true) #for 3.1 changes
if result.size() > 0:
return result.position
else:
return null
func find_further_distance_to(origin):
# Find edges of collision and change to global positions
var edges = []
edges.append(node_area.to_global(Vector3(quad_mesh_size.x / 2, quad_mesh_size.y / 2, 0)))
edges.append(node_area.to_global(Vector3(quad_mesh_size.x / 2, -quad_mesh_size.y / 2, 0)))
edges.append(node_area.to_global(Vector3(-quad_mesh_size.x / 2, quad_mesh_size.y / 2, 0)))
edges.append(node_area.to_global(Vector3(-quad_mesh_size.x / 2, -quad_mesh_size.y / 2, 0)))
# Get the furthest distance between the camera and collision to avoid raycasting too far or too short
var far_dist = 0
var temp_dist
for edge in edges:
temp_dist = origin.distance_to(edge)
if temp_dist > far_dist:
far_dist = temp_dist
return far_dist
func rotate_area_to_billboard():
var billboard_mode = node_quad.get_surface_material(0).params_billboard_mode
# Try to match the area with the material's billboard setting, if enabled
if billboard_mode > 0:
# Get the camera
var camera = get_viewport().get_camera()
# Look in the same direction as the camera
var look = camera.to_global(Vector3(0, 0, -100)) - camera.global_transform.origin
look = node_area.translation + look
# Y-Billboard: Lock Y rotation, but gives bad results if the camera is tilted.
if billboard_mode == 2:
look = Vector3(look.x, 0, look.z)
node_area.look_at(look, Vector3.UP)
# Rotate in the Z axis to compensate camera tilt
node_area.rotate_object_local(Vector3.BACK, camera.rotation.z)
| GDScript | 5 | jonbonazza/godot-demo-projects | viewport/gui_in_3d/gui_3d.gd | [
"MIT"
] |
import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { waitFor } from 'next-test-utils'
import webdriver from 'next-webdriver'
describe('getServerSideProps returns notFound: true', () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: {
'pages/index.js': `
const Home = () => null
export default Home
export function getServerSideProps() {
console.log("gssp called")
return { notFound: true }
}
`,
},
dependencies: {},
})
})
afterAll(() => next.destroy())
it('should not poll indefinitely', async () => {
const browser = await webdriver(next.appPort, '/')
await waitFor(3000)
await browser.close()
const logOccurrences = next.cliOutput.split('gssp called').length - 1
expect(logOccurrences).toBe(1)
})
})
| TypeScript | 4 | christopherklint97/next.js | test/development/gssp-notfound/index.test.ts | [
"MIT"
] |
; CLW file contains information for the MFC ClassWizard
[General Info]
Version=1
LastClass=CHeapMfcDlg
LastTemplate=CDialog
NewFileInclude1=#include "stdafx.h"
NewFileInclude2=#include "heapmfc.h"
LastPage=0
ClassCount=3
Class1=CHeapMfcApp
Class2=CAboutDlg
Class3=CHeapMfcDlg
ResourceCount=2
Resource1=IDD_ABOUTBOX (English (U.S.))
Resource2=IDD_HEAPMFC_DIALOG (English (U.S.))
[CLS:CHeapMfcApp]
Type=0
BaseClass=CWinApp
HeaderFile=HeapMfc.h
ImplementationFile=HeapMfc.cpp
[CLS:CAboutDlg]
Type=0
BaseClass=CDialog
HeaderFile=HeapMfcDlg.cpp
ImplementationFile=HeapMfcDlg.cpp
LastObject=CAboutDlg
[CLS:CHeapMfcDlg]
Type=0
BaseClass=CDialog
HeaderFile=HeapMfcDlg.h
ImplementationFile=HeapMfcDlg.cpp
Filter=D
VirtualFilter=dWC
LastObject=IDC_EDIT_SIZE
[DLG:IDD_ABOUTBOX]
Type=1
Class=CAboutDlg
[DLG:IDD_HEAPMFC_DIALOG]
Type=1
Class=CHeapMfcDlg
[DLG:IDD_HEAPMFC_DIALOG (English (U.S.))]
Type=1
Class=CHeapMfcDlg
ControlCount=4
Control1=IDNEW,button,1342242817
Control2=IDCANCEL,button,1342242816
Control3=IDC_LIST1,listbox,1352728833
Control4=IDC_EDIT_SIZE,edit,1350631552
[DLG:IDD_ABOUTBOX (English (U.S.))]
Type=1
Class=?
ControlCount=4
Control1=IDC_STATIC,static,1342177283
Control2=IDC_STATIC,static,1342308480
Control3=IDC_STATIC,static,1342308352
Control4=IDOK,button,1342373889
| Clarion | 1 | oudream/ccxx | test/dump/swdbgbk_src/chap23/HeapMfc/HeapMfc.clw | [
"MIT"
] |
--TEST--
Test array_unshift() function : usage variations - all possible values for 'var' argument
--FILE--
<?php
/*
* Testing array_unshift() by giving all the possible values for $var argument
*/
echo "*** Testing array_unshift() : all possible values for \$var argument ***\n";
// array to be passed to $array argument
$array = array('f' => "first", "s" => 'second', 1, 2.222);
// get a class
class classA
{
public function __toString() {
return "Class A object";
}
}
// get a resource variable
$fp = fopen(__FILE__, "r");
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// get an unset variable
$unset_var = 10;
unset ($unset_var);
// different types of values to be passed to $var argument
$vars = array(
// int data
/*1*/ 0,
1,
12345,
-2345,
// float data
/*5*/ 10.5,
-10.5,
12.3456789000e10,
12.3456789000E-10,
.5,
// array data
/*10*/ array(),
array(0),
array(1),
array(1, 2),
array('color' => 'red', 'item' => 'pen'),
// null data
/*15*/ NULL,
null,
// boolean data
/*17*/ true,
false,
TRUE,
FALSE,
// empty data
/*21*/ "",
'',
// string data
/*23*/ "string",
'string',
$heredoc,
// object data
/*26*/ new classA(),
// undefined data
@$undefined_var,
// unset data
@$unset_var,
// resource variable
/*29*/ $fp
);
// loop through each element of $vars to check the functionality of array_unshift()
$iterator = 1;
foreach($vars as $var) {
echo "-- Iteration $iterator --\n";
$temp_array = $array;
/* with default argument */
// returns element count in the resulting array after arguments are pushed to
// beginning of the given array
var_dump( array_unshift($temp_array, $var) );
// dump the resulting array
var_dump($temp_array);
/* with optional arguments */
// returns element count in the resulting array after arguments are pushed to
// beginning of the given array
$temp_array = $array;
var_dump( array_unshift($temp_array, $var, "hello", 'world') );
// dump the resulting array
var_dump($temp_array);
$iterator++;
}
// close the file resource used
fclose($fp);
echo "Done";
?>
--EXPECTF--
*** Testing array_unshift() : all possible values for $var argument ***
-- Iteration 1 --
int(5)
array(5) {
[0]=>
int(0)
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
int(0)
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 2 --
int(5)
array(5) {
[0]=>
int(1)
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
int(1)
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 3 --
int(5)
array(5) {
[0]=>
int(12345)
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
int(12345)
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 4 --
int(5)
array(5) {
[0]=>
int(-2345)
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
int(-2345)
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 5 --
int(5)
array(5) {
[0]=>
float(10.5)
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
float(10.5)
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 6 --
int(5)
array(5) {
[0]=>
float(-10.5)
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
float(-10.5)
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 7 --
int(5)
array(5) {
[0]=>
float(123456789000)
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
float(123456789000)
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 8 --
int(5)
array(5) {
[0]=>
float(1.23456789E-9)
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
float(1.23456789E-9)
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 9 --
int(5)
array(5) {
[0]=>
float(0.5)
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
float(0.5)
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 10 --
int(5)
array(5) {
[0]=>
array(0) {
}
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
array(0) {
}
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 11 --
int(5)
array(5) {
[0]=>
array(1) {
[0]=>
int(0)
}
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
array(1) {
[0]=>
int(0)
}
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 12 --
int(5)
array(5) {
[0]=>
array(1) {
[0]=>
int(1)
}
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
array(1) {
[0]=>
int(1)
}
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 13 --
int(5)
array(5) {
[0]=>
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 14 --
int(5)
array(5) {
[0]=>
array(2) {
["color"]=>
string(3) "red"
["item"]=>
string(3) "pen"
}
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
array(2) {
["color"]=>
string(3) "red"
["item"]=>
string(3) "pen"
}
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 15 --
int(5)
array(5) {
[0]=>
NULL
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
NULL
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 16 --
int(5)
array(5) {
[0]=>
NULL
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
NULL
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 17 --
int(5)
array(5) {
[0]=>
bool(true)
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
bool(true)
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 18 --
int(5)
array(5) {
[0]=>
bool(false)
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
bool(false)
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 19 --
int(5)
array(5) {
[0]=>
bool(true)
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
bool(true)
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 20 --
int(5)
array(5) {
[0]=>
bool(false)
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
bool(false)
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 21 --
int(5)
array(5) {
[0]=>
string(0) ""
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
string(0) ""
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 22 --
int(5)
array(5) {
[0]=>
string(0) ""
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
string(0) ""
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 23 --
int(5)
array(5) {
[0]=>
string(6) "string"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
string(6) "string"
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 24 --
int(5)
array(5) {
[0]=>
string(6) "string"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
string(6) "string"
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 25 --
int(5)
array(5) {
[0]=>
string(11) "hello world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
string(11) "hello world"
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 26 --
int(5)
array(5) {
[0]=>
object(classA)#%d (0) {
}
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
object(classA)#%d (0) {
}
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 27 --
int(5)
array(5) {
[0]=>
NULL
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
NULL
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 28 --
int(5)
array(5) {
[0]=>
NULL
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
NULL
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
-- Iteration 29 --
int(5)
array(5) {
[0]=>
resource(%d) of type (stream)
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[1]=>
int(1)
[2]=>
float(2.222)
}
int(7)
array(7) {
[0]=>
resource(%d) of type (stream)
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
["f"]=>
string(5) "first"
["s"]=>
string(6) "second"
[3]=>
int(1)
[4]=>
float(2.222)
}
Done
| PHP | 5 | NathanFreeman/php-src | ext/standard/tests/array/array_unshift_variation2.phpt | [
"PHP-3.01"
] |
import io.vertx.ceylon.platform {
Verticle,
Container
}
import io.vertx.ceylon.core {
Vertx
}
import io.vertx.ceylon.core.http {
HttpClientResponse
}
shared class ClientExample() extends Verticle() {
shared actual void start(Vertx vertx, Container container) {
value client = vertx.createHttpClient();
client.ssl = true;
client.trustAll = true;
client.port = 4443;
client.host = "localhost";
value resp = client.get("/").end().response;
resp.onComplete((HttpClientResponse resp) =>
resp.stream.dataHandler(print)
);
}
}
| Ceylon | 3 | vietj/vertx-examples | src/raw/ceylon/https/ClientExample.ceylon | [
"Apache-2.0"
] |
# multiarch.m4 serial 7
dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
# Determine whether the compiler is or may be producing universal binaries.
#
# On Mac OS X 10.5 and later systems, the user can create libraries and
# executables that work on multiple system types--known as "fat" or
# "universal" binaries--by specifying multiple '-arch' options to the
# compiler but only a single '-arch' option to the preprocessor. Like
# this:
#
# ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
# CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
# CPP="gcc -E" CXXCPP="g++ -E"
#
# Detect this situation and set APPLE_UNIVERSAL_BUILD accordingly.
AC_DEFUN_ONCE([gl_MULTIARCH],
[
dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN.
gl_cv_c_multiarch=no
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#ifndef __APPLE_CC__
not a universal capable compiler
#endif
typedef int dummy;
]])],
[
dnl Check for potential -arch flags. It is not universal unless
dnl there are at least two -arch flags with different values.
arch=
prev=
for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
if test -n "$prev"; then
case $word in
i?86 | x86_64 | ppc | ppc64)
if test -z "$arch" || test "$arch" = "$word"; then
arch="$word"
else
gl_cv_c_multiarch=yes
fi
;;
esac
prev=
else
if test "x$word" = "x-arch"; then
prev=arch
fi
fi
done
])
if test $gl_cv_c_multiarch = yes; then
APPLE_UNIVERSAL_BUILD=1
else
APPLE_UNIVERSAL_BUILD=0
fi
AC_SUBST([APPLE_UNIVERSAL_BUILD])
])
| M4 | 5 | YuPf1989/BGAQRCode-Android | zbar/src/main/jni/libiconv-1.15/srcm4/multiarch.m4 | [
"Apache-2.0"
] |
{include "ui/{$UI}/page.latte"} | Latte | 2 | arusinha/incubator-netbeans | php/php.latte/test/unit/data/testfiles/lexer/top/testIssue240146_01.latte | [
"Apache-2.0"
] |
radius = 0.01;
height = 0.1;
$fn = 50;
module tip() {
rotate([0, -10, 0])
translate([0, -radius, -3*radius])
cube([radius, 2*radius, 3*radius], center=false);
}
difference() {
difference() {
difference() {
union() {
cylinder(center=false, h=height, r=radius);
sphere(radius);
};
translate([0, 0, 0.9*height])
rotate_extrude()
polygon([[0.8*radius, 0], [1.8*radius, -0.577*radius], [1.8*radius, 0.577*radius]]);
}
cylinder(center=false, h=height, r=0.3*radius);
}
for (i = [1:6]) {
rotate([0, 0, 360/6*i])
translate([-1.1*radius, 0.0, -0.2*height])
cylinder(center=false, h=1.1*height, r=0.2*radius);
}
}
union() {
difference() {
translate([0, 0, height])
cylinder(center=false, h=height, r=0.3*radius);
translate([0, 0, 1.71*height + 3*radius])
union() {
tip();
mirror ([1, 0, 0]) tip();
}
}
cylinder(center=false, h=height, r=0.3*radius);
}
| OpenSCAD | 3 | clazaro/sfepy | doc/preprocessing/screwdriver_full.scad | [
"BSD-3-Clause"
] |
void main () {
}
| Vala | 0 | kira78/meson | test cases/vala/23 thread flags/prog.vala | [
"Apache-2.0"
] |
it("should include a chunk nested in an empty chunk", (done) => {
require.ensure(["./a"], () => {
require.ensure([], () => {
require.ensure(["./a"], () => {
require.ensure([], () => {
const b = require("./b");
expect(b).toBe(42);
done();
});
});
});
});
});
| JavaScript | 2 | 1shenxi/webpack | test/cases/chunks/nested-in-empty/index.js | [
"MIT"
] |
# Copyright 2018 The TensorFlow Authors All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""A circular buffer where each element is a list of tensors.
Each element of the buffer is a list of tensors. An example use case is a replay
buffer in reinforcement learning, where each element is a list of tensors
representing the state, action, reward etc.
New elements are added sequentially, and once the buffer is full, we
start overwriting them in a circular fashion. Reading does not remove any
elements, only adding new elements does.
"""
import collections
import numpy as np
import tensorflow as tf
import gin.tf
@gin.configurable
class CircularBuffer(object):
"""A circular buffer where each element is a list of tensors."""
def __init__(self, buffer_size=1000, scope='replay_buffer'):
"""Circular buffer of list of tensors.
Args:
buffer_size: (integer) maximum number of tensor lists the buffer can hold.
scope: (string) variable scope for creating the variables.
"""
self._buffer_size = np.int64(buffer_size)
self._scope = scope
self._tensors = collections.OrderedDict()
with tf.variable_scope(self._scope):
self._num_adds = tf.Variable(0, dtype=tf.int64, name='num_adds')
self._num_adds_cs = tf.CriticalSection(name='num_adds')
@property
def buffer_size(self):
return self._buffer_size
@property
def scope(self):
return self._scope
@property
def num_adds(self):
return self._num_adds
def _create_variables(self, tensors):
with tf.variable_scope(self._scope):
for name in tensors.keys():
tensor = tensors[name]
self._tensors[name] = tf.get_variable(
name='BufferVariable_' + name,
shape=[self._buffer_size] + tensor.get_shape().as_list(),
dtype=tensor.dtype,
trainable=False)
def _validate(self, tensors):
"""Validate shapes of tensors."""
if len(tensors) != len(self._tensors):
raise ValueError('Expected tensors to have %d elements. Received %d '
'instead.' % (len(self._tensors), len(tensors)))
if self._tensors.keys() != tensors.keys():
raise ValueError('The keys of tensors should be the always the same.'
'Received %s instead %s.' %
(tensors.keys(), self._tensors.keys()))
for name, tensor in tensors.items():
if tensor.get_shape().as_list() != self._tensors[
name].get_shape().as_list()[1:]:
raise ValueError('Tensor %s has incorrect shape.' % name)
if not tensor.dtype.is_compatible_with(self._tensors[name].dtype):
raise ValueError(
'Tensor %s has incorrect data type. Expected %s, received %s' %
(name, self._tensors[name].read_value().dtype, tensor.dtype))
def add(self, tensors):
"""Adds an element (list/tuple/dict of tensors) to the buffer.
Args:
tensors: (list/tuple/dict of tensors) to be added to the buffer.
Returns:
An add operation that adds the input `tensors` to the buffer. Similar to
an enqueue_op.
Raises:
ValueError: If the shapes and data types of input `tensors' are not the
same across calls to the add function.
"""
return self.maybe_add(tensors, True)
def maybe_add(self, tensors, condition):
"""Adds an element (tensors) to the buffer based on the condition..
Args:
tensors: (list/tuple of tensors) to be added to the buffer.
condition: A boolean Tensor controlling whether the tensors would be added
to the buffer or not.
Returns:
An add operation that adds the input `tensors` to the buffer. Similar to
an maybe_enqueue_op.
Raises:
ValueError: If the shapes and data types of input `tensors' are not the
same across calls to the add function.
"""
if not isinstance(tensors, dict):
names = [str(i) for i in range(len(tensors))]
tensors = collections.OrderedDict(zip(names, tensors))
if not isinstance(tensors, collections.OrderedDict):
tensors = collections.OrderedDict(
sorted(tensors.items(), key=lambda t: t[0]))
if not self._tensors:
self._create_variables(tensors)
else:
self._validate(tensors)
#@tf.critical_section(self._position_mutex)
def _increment_num_adds():
# Adding 0 to the num_adds variable is a trick to read the value of the
# variable and return a read-only tensor. Doing this in a critical
# section allows us to capture a snapshot of the variable that will
# not be affected by other threads updating num_adds.
return self._num_adds.assign_add(1) + 0
def _add():
num_adds_inc = self._num_adds_cs.execute(_increment_num_adds)
current_pos = tf.mod(num_adds_inc - 1, self._buffer_size)
update_ops = []
for name in self._tensors.keys():
update_ops.append(
tf.scatter_update(self._tensors[name], current_pos, tensors[name]))
return tf.group(*update_ops)
return tf.contrib.framework.smart_cond(condition, _add, tf.no_op)
def get_random_batch(self, batch_size, keys=None, num_steps=1):
"""Samples a batch of tensors from the buffer with replacement.
Args:
batch_size: (integer) number of elements to sample.
keys: List of keys of tensors to retrieve. If None retrieve all.
num_steps: (integer) length of trajectories to return. If > 1 will return
a list of lists, where each internal list represents a trajectory of
length num_steps.
Returns:
A list of tensors, where each element in the list is a batch sampled from
one of the tensors in the buffer.
Raises:
ValueError: If get_random_batch is called before calling the add function.
tf.errors.InvalidArgumentError: If this operation is executed before any
items are added to the buffer.
"""
if not self._tensors:
raise ValueError('The add function must be called before get_random_batch.')
if keys is None:
keys = self._tensors.keys()
latest_start_index = self.get_num_adds() - num_steps + 1
empty_buffer_assert = tf.Assert(
tf.greater(latest_start_index, 0),
['Not enough elements have been added to the buffer.'])
with tf.control_dependencies([empty_buffer_assert]):
max_index = tf.minimum(self._buffer_size, latest_start_index)
indices = tf.random_uniform(
[batch_size],
minval=0,
maxval=max_index,
dtype=tf.int64)
if num_steps == 1:
return self.gather(indices, keys)
else:
return self.gather_nstep(num_steps, indices, keys)
def gather(self, indices, keys=None):
"""Returns elements at the specified indices from the buffer.
Args:
indices: (list of integers or rank 1 int Tensor) indices in the buffer to
retrieve elements from.
keys: List of keys of tensors to retrieve. If None retrieve all.
Returns:
A list of tensors, where each element in the list is obtained by indexing
one of the tensors in the buffer.
Raises:
ValueError: If gather is called before calling the add function.
tf.errors.InvalidArgumentError: If indices are bigger than the number of
items in the buffer.
"""
if not self._tensors:
raise ValueError('The add function must be called before calling gather.')
if keys is None:
keys = self._tensors.keys()
with tf.name_scope('Gather'):
index_bound_assert = tf.Assert(
tf.less(
tf.to_int64(tf.reduce_max(indices)),
tf.minimum(self.get_num_adds(), self._buffer_size)),
['Index out of bounds.'])
with tf.control_dependencies([index_bound_assert]):
indices = tf.convert_to_tensor(indices)
batch = []
for key in keys:
batch.append(tf.gather(self._tensors[key], indices, name=key))
return batch
def gather_nstep(self, num_steps, indices, keys=None):
"""Returns elements at the specified indices from the buffer.
Args:
num_steps: (integer) length of trajectories to return.
indices: (list of rank num_steps int Tensor) indices in the buffer to
retrieve elements from for multiple trajectories. Each Tensor in the
list represents the indices for a trajectory.
keys: List of keys of tensors to retrieve. If None retrieve all.
Returns:
A list of list-of-tensors, where each element in the list is obtained by
indexing one of the tensors in the buffer.
Raises:
ValueError: If gather is called before calling the add function.
tf.errors.InvalidArgumentError: If indices are bigger than the number of
items in the buffer.
"""
if not self._tensors:
raise ValueError('The add function must be called before calling gather.')
if keys is None:
keys = self._tensors.keys()
with tf.name_scope('Gather'):
index_bound_assert = tf.Assert(
tf.less_equal(
tf.to_int64(tf.reduce_max(indices) + num_steps),
self.get_num_adds()),
['Trajectory indices go out of bounds.'])
with tf.control_dependencies([index_bound_assert]):
indices = tf.map_fn(
lambda x: tf.mod(tf.range(x, x + num_steps), self._buffer_size),
indices,
dtype=tf.int64)
batch = []
for key in keys:
def SampleTrajectories(trajectory_indices, key=key,
num_steps=num_steps):
trajectory_indices.set_shape([num_steps])
return tf.gather(self._tensors[key], trajectory_indices, name=key)
batch.append(tf.map_fn(SampleTrajectories, indices,
dtype=self._tensors[key].dtype))
return batch
def get_position(self):
"""Returns the position at which the last element was added.
Returns:
An int tensor representing the index at which the last element was added
to the buffer or -1 if no elements were added.
"""
return tf.cond(self.get_num_adds() < 1,
lambda: self.get_num_adds() - 1,
lambda: tf.mod(self.get_num_adds() - 1, self._buffer_size))
def get_num_adds(self):
"""Returns the number of additions to the buffer.
Returns:
An int tensor representing the number of elements that were added.
"""
def num_adds():
return self._num_adds.value()
return self._num_adds_cs.execute(num_adds)
def get_num_tensors(self):
"""Returns the number of tensors (slots) in the buffer."""
return len(self._tensors)
| Python | 5 | 873040/Abhishek | research/efficient-hrl/agents/circular_buffer.py | [
"Apache-2.0"
] |
var D = {1..10 by 3};
var A: [D] int = D;
writeln(A);
D = {5..8 by 1};
writeln(A);
| Chapel | 3 | jhh67/chapel | test/domains/deitz/test_domain_reassign3.chpl | [
"ECL-2.0",
"Apache-2.0"
] |
# #565, check multi-file rules that don't create their contents
ninja_required_version = 1.5
build test : phony a b
rule CUSTOM_COMMAND
command = $COMMAND
build a b : CUSTOM_COMMAND
COMMAND = cd
| Ninja | 3 | srid/shake | src/Test/Ninja/test7.ninja | [
"BSD-3-Clause"
] |
Added support for HTTPS proxies to the extent CPython's
:py:mod:`asyncio` supports it -- by :user:`bmbouter`,
:user:`jborean93` and :user:`webknjaz`.
| Cucumber | 0 | loven-doo/aiohttp | CHANGES/5992.feature | [
"Apache-2.0"
] |
-@ val googleAnalyticsScript: String
-@ val bodyText: String
-@ val topMenu: Map[String,String]
-@ val menuKeys: List[String]
-@ val lvamoMap: scala.collection.immutable.TreeMap[String,String]
-@ val lvsolMap: scala.collection.immutable.TreeMap[String,String]
%html
%head
%title Matemātikas pulciņš
%meta{"http-equiv"=>"content-type", :content=>"text/html;charset=utf-8"}
%link{:rel=>"stylesheet", :type=>"text/css", :href=>"style1.css"}
%body
- render("nav.scaml")
%div = unescape(bodyText)
%script = unescape(googleAnalyticsScript)
| Scaml | 3 | kapsitis/ddgatve-stat | src/main/resources/default.scaml | [
"Apache-2.0"
] |
:orphan:
mlflow_example
~~~~~~~~~~~~~~
.. literalinclude:: /../../python/ray/tune/examples/mlflow_example.py
| reStructuredText | 2 | firebolt55439/ray | doc/source/tune/examples/mlflow_example.rst | [
"Apache-2.0"
] |
{{>licenseInfo}}
{{#models}}{{#model}}
#include "{{classname}}.h"
#include <string>
#include <sstream>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
using boost::property_tree::ptree;
using boost::property_tree::read_json;
using boost::property_tree::write_json;
{{#modelNamespaceDeclarations}}
namespace {{this}} {
{{/modelNamespaceDeclarations}}
{{classname}}::{{classname}}()
{
{{#vars}}{{#isNotContainer}}{{#isPrimitiveType}}m_{{name}} = {{{defaultValue}}};
{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isString}}m_{{name}} = {{{defaultValue}}};
{{/isString}}{{#isDateTime}}m_{{name}} = {{{defaultValue}}};
{{/isDateTime}}{{/isPrimitiveType}}{{/isNotContainer}}{{/vars}}
}
{{classname}}::~{{classname}}()
{
}
std::string {{classname}}::toJsonString()
{
std::stringstream ss;
ptree pt;
{{#vars}}
{{#isNotContainer}}
{{#isPrimitiveType}}
pt.put("{{name}}", m_{{name}});
{{/isPrimitiveType}}
{{^isPrimitiveType}}
{{#isString}}
pt.put("{{name}}", m_{{name}});
{{/isString}}
{{#isDateTime}}
pt.put("{{name}}", m_{{name}});
{{/isDateTime}}
{{/isPrimitiveType}}
{{/isNotContainer}}
{{/vars}}
write_json(ss, pt, false);
return ss.str();
}
void {{classname}}::fromJsonString(std::string const& jsonString)
{
std::stringstream ss(jsonString);
ptree pt;
read_json(ss,pt);
{{#vars}}
{{#isNotContainer}}
{{#isPrimitiveType}}
m_{{name}} = pt.get("{{name}}", {{{defaultValue}}});
{{/isPrimitiveType}}
{{^isPrimitiveType}}
{{#isString}}
m_{{name}} = pt.get("{{name}}", {{{defaultValue}}});
{{/isString}}
{{#isDateTime}}
m_{{name}} = pt.get("{{name}}", {{{defaultValue}}});
{{/isDateTime}}
{{/isPrimitiveType}}
{{/isNotContainer}}
{{/vars}}
}
{{#vars}}
{{{datatype}}} {{classname}}::{{getter}}() const
{
return m_{{name}};
}
void {{classname}}::{{setter}}({{{datatype}}} value)
{
m_{{name}} = value;
}
{{/vars}}
{{#modelNamespaceDeclarations}}
}
{{/modelNamespaceDeclarations}}
{{/model}}
{{/models}}
| HTML+Django | 4 | derBiggi/swagger-codegen | modules/swagger-codegen/src/main/resources/restbed/model-source.mustache | [
"Apache-2.0"
] |