hexsha
stringlengths 40
40
| size
int64 5
1.05M
| ext
stringclasses 98
values | lang
stringclasses 21
values | max_stars_repo_path
stringlengths 3
945
| max_stars_repo_name
stringlengths 4
118
| max_stars_repo_head_hexsha
stringlengths 40
78
| max_stars_repo_licenses
sequencelengths 1
10
| max_stars_count
int64 1
368k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 3
945
| max_issues_repo_name
stringlengths 4
118
| max_issues_repo_head_hexsha
stringlengths 40
78
| max_issues_repo_licenses
sequencelengths 1
10
| max_issues_count
int64 1
134k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 3
945
| max_forks_repo_name
stringlengths 4
135
| max_forks_repo_head_hexsha
stringlengths 40
78
| max_forks_repo_licenses
sequencelengths 1
10
| max_forks_count
int64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 5
1.05M
| avg_line_length
float64 1
1.03M
| max_line_length
int64 2
1.03M
| alphanum_fraction
float64 0
1
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
59b71c8d8bfa5615ca987228b5b4a9a560a53d59 | 262 | swift | Swift | CatsAndDogs/CatsAndDogsApp.swift | agescura/CatsAndDogs | 1387fad87c773efd9c757c995aebd47a140cc8c6 | [
"MIT"
] | null | null | null | CatsAndDogs/CatsAndDogsApp.swift | agescura/CatsAndDogs | 1387fad87c773efd9c757c995aebd47a140cc8c6 | [
"MIT"
] | null | null | null | CatsAndDogs/CatsAndDogsApp.swift | agescura/CatsAndDogs | 1387fad87c773efd9c757c995aebd47a140cc8c6 | [
"MIT"
] | null | null | null | //
// CatsAndDogsApp.swift
// CatsAndDogs
//
// Created by Albert Gil Escura on 18/4/21.
//
import SwiftUI
@main
struct CatsAndDogsApp: App {
var body: some Scene {
WindowGroup {
ContentView(viewModel: ViewModel())
}
}
}
| 14.555556 | 47 | 0.599237 |
9c2c6934b051cac5b324dedeb4d067ff93ca745e | 215 | js | JavaScript | lib/modules/validators/validators/existence/not_null.js | xcorail/meteor-astronomy | 61c0649bb9769b46234e6304a7d4e4584e00dca5 | [
"MIT"
] | 723 | 2015-04-03T13:35:52.000Z | 2022-03-07T11:17:32.000Z | lib/modules/validators/validators/existence/not_null.js | xcorail/meteor-astronomy | 61c0649bb9769b46234e6304a7d4e4584e00dca5 | [
"MIT"
] | 710 | 2015-04-10T04:42:25.000Z | 2022-03-18T22:26:39.000Z | lib/modules/validators/validators/existence/not_null.js | xcorail/meteor-astronomy | 61c0649bb9769b46234e6304a7d4e4584e00dca5 | [
"MIT"
] | 93 | 2015-04-10T22:56:30.000Z | 2022-01-26T19:30:14.000Z | import Validator from '../../validator.js';
Validator.create({
name: 'notNull',
isValid({ value }) {
return value !== null;
},
resolveError({ name }) {
return `"${name}" should not be null`;
}
}); | 19.545455 | 43 | 0.576744 |
e8e227fac1aeb6cb15d17a60f96b91194af13f7f | 639 | py | Python | api/cueSearch/migrations/0005_searchcardtemplate_connectiontype.py | cuebook/CueSearch | 8bf047de273b27bba41b8bf4e266aac1eee7f81a | [
"Apache-2.0"
] | 3 | 2022-02-10T17:00:19.000Z | 2022-03-29T14:31:25.000Z | api/cueSearch/migrations/0005_searchcardtemplate_connectiontype.py | cuebook/CueSearch | 8bf047de273b27bba41b8bf4e266aac1eee7f81a | [
"Apache-2.0"
] | null | null | null | api/cueSearch/migrations/0005_searchcardtemplate_connectiontype.py | cuebook/CueSearch | 8bf047de273b27bba41b8bf4e266aac1eee7f81a | [
"Apache-2.0"
] | null | null | null | # Generated by Django 3.2.5 on 2022-02-18 08:20
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("dataset", "0001_initial"),
("cueSearch", "0004_auto_20220217_0217"),
]
operations = [
migrations.AddField(
model_name="searchcardtemplate",
name="connectionType",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="dataset.connectiontype",
),
),
]
| 24.576923 | 61 | 0.57277 |
4f680db7ab4526fdd8bb5a92326eef967e2f43dc | 373 | kt | Kotlin | app/src/main/java/com/alirezaafkar/phuzei/data/model/Filters.kt | alirezaafkar/Phuzei | 81129034cfb7e625b09320c6e0397e2c4e51a883 | [
"Apache-2.0"
] | 17 | 2018-10-21T06:17:28.000Z | 2021-07-31T19:49:40.000Z | app/src/main/java/com/alirezaafkar/phuzei/data/model/Filters.kt | alirezaafkar/Phuzei | 81129034cfb7e625b09320c6e0397e2c4e51a883 | [
"Apache-2.0"
] | 6 | 2018-10-23T20:35:00.000Z | 2022-02-25T21:08:08.000Z | app/src/main/java/com/alirezaafkar/phuzei/data/model/Filters.kt | alirezaafkar/Phuzei | 81129034cfb7e625b09320c6e0397e2c4e51a883 | [
"Apache-2.0"
] | 3 | 2019-04-04T22:00:29.000Z | 2020-09-14T14:36:11.000Z | package com.alirezaafkar.phuzei.data.model
/**
* Created by Alireza Afkar on 5/21/20.
*/
data class Filters(
val featureFilter: FeatureFilter? = null,
val contentFilter: ContentFilter? = null
)
data class FeatureFilter(val includedFeatures: List<String>)
data class ContentFilter(val includedContentCategories: List<String>)
const val FAVORITES = "FAVORITES"
| 23.3125 | 69 | 0.761394 |
b2f264acc957c78592942a789c9b0334224d0fdd | 604 | py | Python | testing/forms/products.py | Miki761000/storage_podari_s_luibov | a82caccfd40391f6a2609538e4e629d3b113aca9 | [
"MIT"
] | null | null | null | testing/forms/products.py | Miki761000/storage_podari_s_luibov | a82caccfd40391f6a2609538e4e629d3b113aca9 | [
"MIT"
] | null | null | null | testing/forms/products.py | Miki761000/storage_podari_s_luibov | a82caccfd40391f6a2609538e4e629d3b113aca9 | [
"MIT"
] | null | null | null | from django import forms
from warehouse.models import Product, ProductAdditionalInformation
class ProductForm(forms.ModelForm):
class Meta:
model = Product
fields = '__all__'
field_order = [
'product_name',
'product_code',
'product_quantity',
'product_type',
'product_id',
]
product_code = forms.CharField(disabled=True)
class ProductAdditionalInformationForm(forms.ModelForm):
class Meta:
model = ProductAdditionalInformation
exclude = ['product']
fields = '__all__' | 25.166667 | 66 | 0.622517 |
f05d0c3401f69142c582ade92cb02f323289bd68 | 183 | py | Python | dingomata/config/__init__.py | tigershadowclaw/discord-dingomata | 0b20d7b75a0af3387b19b17c336e5e14356d2f14 | [
"MIT"
] | null | null | null | dingomata/config/__init__.py | tigershadowclaw/discord-dingomata | 0b20d7b75a0af3387b19b17c336e5e14356d2f14 | [
"MIT"
] | null | null | null | dingomata/config/__init__.py | tigershadowclaw/discord-dingomata | 0b20d7b75a0af3387b19b17c336e5e14356d2f14 | [
"MIT"
] | null | null | null | from .bot import GuildConfig, ServiceConfig, get_logging_config, service_config
__all__ = [
"ServiceConfig",
"GuildConfig",
"get_logging_config",
"service_config",
]
| 20.333333 | 79 | 0.721311 |
f01944d27e76d31f7d24bb6d6aee8d5e5c5f6995 | 10,940 | py | Python | todo_app/display.py | WeaverDyl/python-todo | 80c533b79c6170ba9ba4923ba78f4900fece8339 | [
"MIT"
] | 3 | 2020-01-16T09:39:11.000Z | 2021-11-15T08:38:52.000Z | todo_app/display.py | WeaverDyl/python-todo | 80c533b79c6170ba9ba4923ba78f4900fece8339 | [
"MIT"
] | null | null | null | todo_app/display.py | WeaverDyl/python-todo | 80c533b79c6170ba9ba4923ba78f4900fece8339 | [
"MIT"
] | null | null | null | import os
import math
import shutil
import textwrap
from datetime import datetime
from terminaltables import AsciiTable
class Display:
def __init__(self):
self.colors = {
'RED': '\033[38;5;196m',
'ORANGE': '\033[38;5;220m',
'GREEN': '\033[38;5;46m',
'BOLD': '\u001b[1m',
'UNDERLINE': '\u001b[4m',
'RESET': '\033[0m'
}
# Defines where to insert newlines in case of
# situations where one task has some long columns
self.max_col_widths = {
'ID': 4,
'Added': 10,
'Title': 30,
'Description': 30,
'Due': 10,
'Finished': 1
}
def color_message(self, message, *args):
""" Sets a message to be a specific color from the colors dict before resetting """
args_list = [str(color) for color in args]
colors = ''.join([self.colors[i] for i in args_list])
return ''.join([colors, message, self.colors['RESET']])
def print_error(self, message):
""" Prints a message in bold, red characters """
print(self.color_message(message, 'BOLD', 'RED'))
def print_success(self, message):
""" Prints a message in bold, green characters """
print(self.color_message(message, 'BOLD', 'GREEN'))
def print_message(self, message):
""" Prints a message in bold characters """
print(self.color_message(message, 'BOLD'))
@staticmethod
def clear_terminal():
""" Clears a terminal to prepare for output """
os.system('cls' if os.name == 'nt' else 'clear')
def print_welcome(self):
""" Prints a simple welcome message. """
Display.clear_terminal()
self.print_message('Welcome to python-todo!\n')
def print_commands(self):
""" Prints a list of available commands to run the program with.
Shown when the user has an empty task list """
commands = [[self.color_message(i, 'BOLD') for i in ['Commands', 'Description']],
['-a/--add', 'Add a new element to a task list'],
['-r/--remove', 'Remove an element from a task list'],
['-f/--finish', 'Finish a task in a task list'],
['-u/--unfinish', 'Unfinish a task in a task list'],
['-c/--change', 'Change parts of an existing task'],
['-v/--view', 'View the whole task list']]
table_data = commands
table = AsciiTable(table_data)
table.inner_row_border = True
if not self.check_table_fit(table):
self.print_message('Try adding a task to your list! just call `python-todo -a`')
else:
self.print_message('Try adding a task to your list! Here\'s the available commands:')
print(table.table)
@staticmethod
def check_table_fit(table):
""" Returns true if a terminaltable will fit within the width of
the current terminal width"""
term_width = shutil.get_terminal_size().columns
table_width = table.table_width
if table_width > term_width:
return False
return True
def format_row(self, tasks):
""" Performs formatting tasks such as changing task completions from (0,1) to (X/✓) """
formatted_tasks = []
for task in tasks:
# Format specific columns
title = task['Title']
description = task['Description']
timestamp = task['Added']
finished = task['Finished?']
due = task['Due']
formatted_timestamp = self.format_time(timestamp)
formatted_finished = self.color_message('✓', 'GREEN', 'BOLD') if finished == 1 else self.color_message('X', 'BOLD', 'RED')
formatted_due = self.format_due_date(due, finished)
# Wrap long lines in the title or description
formatted_title = self.format_long_lines(title, 'Title')
formatted_description = self.format_long_lines(description, 'Description')
task['Title'] = formatted_title
task['Description'] = formatted_description
task['Added'] = formatted_timestamp
task['Finished?'] = formatted_finished
task['Due'] = formatted_due
formatted_tasks.append(task)
return formatted_tasks
@staticmethod
def format_time(timestamp):
""" Returns a nice timestamp telling the user how old a task is.
Returns strings such as '1d ago' """
timestamp_datetime = datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S')
curr_time = datetime.now()
total_time_diff = curr_time - timestamp_datetime
# Time Constants
SECONDS_IN_MIN = 60
SECONDS_IN_HOUR = 3600
SECONDS_IN_DAY = 86400
SECONDS_IN_WEEK = 604800
SECONDS_IN_MONTH = 2592000
SECONDS_IN_YEAR = 31536000
# Print out formatted time difference
if total_time_diff.total_seconds() < 10:
return f'just now'
if total_time_diff.total_seconds() < SECONDS_IN_MIN:
seconds_passed = math.floor(total_time_diff.total_seconds())
return f'{seconds_passed}s ago'
if total_time_diff.total_seconds() < SECONDS_IN_HOUR:
minutes_passed = math.floor(total_time_diff.total_seconds() / SECONDS_IN_MIN)
return f'{minutes_passed}m ago'
if total_time_diff.total_seconds() < SECONDS_IN_DAY:
hours_passed = math.floor(total_time_diff.total_seconds() / SECONDS_IN_HOUR)
return f'{hours_passed}h ago'
if total_time_diff.total_seconds() < SECONDS_IN_WEEK:
days_passed = math.floor(total_time_diff.total_seconds() / SECONDS_IN_DAY)
return f'{days_passed}d ago'
if total_time_diff.total_seconds() < SECONDS_IN_MONTH:
weeks_passed = math.floor(total_time_diff.total_seconds() / SECONDS_IN_WEEK)
return f'{weeks_passed}w ago'
if total_time_diff.total_seconds() < SECONDS_IN_YEAR:
months_passed = math.floor(total_time_diff.total_seconds() / SECONDS_IN_MONTH)
return f'{months_passed}mo ago'
years_passed = math.floor(total_time_diff.total_seconds() / SECONDS_IN_YEAR)
return f'{years_passed}yr ago'
@staticmethod
def validate_date(date_str):
""" Ensures that the date given is in an acceptable format """
for date_format in ('%m/%d/%Y', '%m-%d-%Y'):
try:
if datetime.strptime(date_str, date_format):
return True
except ValueError:
pass
return False
def format_due_date(self, due_date, finished):
""" Formats the due date column to be colored based on how close
the task is to its due date. (Red = overdue, etc...)"""
# Don't format tasks that don't have a due date or are finished
if due_date == '' or finished == 1:
return due_date
curr_time = datetime.now()
try:
due_date_time = datetime.strptime(due_date, '%m-%d-%Y')
except ValueError:
due_date_time = datetime.strptime(due_date, '%m/%d/%Y')
time_until_due = due_date_time - curr_time
SECONDS_IN_DAY = 86400
# Overdue tasks are colored red
if int(time_until_due.total_seconds()) < 0:
return self.color_message(due_date, 'RED', 'BOLD')
# Tasks due in 24 hours or less are colored orange
if int(time_until_due.total_seconds()) < SECONDS_IN_DAY:
return self.color_message(due_date, 'ORANGE', 'BOLD')
return due_date
def format_long_lines(self, long_text, element):
wrapper = textwrap.TextWrapper(width=self.max_col_widths[element])
return '\n'.join(wrapper.wrap(text=long_text))
def print_task_list_formatted(self, rows):
""" Prints each formatted task to the terminal in the form
of a table """
header = [self.color_message(i, 'BOLD') for i in ['ID', 'Added', 'Title', 'Description', 'Due', 'Finished?']]
table_data = [task.values() for task in rows]
table_data.insert(0, header) # The column headers are the first element of the list
table = AsciiTable(table_data) # Create the table -- but test width before printing
table.inner_row_border = True # Separates each task
if not self.check_table_fit(table):
max_width_table = table.table_width
term_width = shutil.get_terminal_size().columns
self.print_message(f'The task list has a width of {max_width_table} and cannot fit in the terminal of width {term_width}.')
return
# The table fits and we can print it
self.print_message('Here are your current tasks:')
print(table.table)
# Methods for ADDING tasks
def ask_user_title(self):
""" Asks the user for the title of the task """
title = ''
while title == '':
title = input(self.color_message('Give your task a name: ', 'BOLD'))
if title == '':
self.print_error('The title can\'t be an empty string!')
return title
def ask_user_description(self):
""" Gets an optional description from the user """
description = input(self.color_message('Optionally, give your task a description: ', 'BOLD'))
return description
def ask_user_due(self):
""" Gets an optional due date for the task from the user """
date = ''
asked = False
while not asked or not self.validate_date(date):
date = input(self.color_message('Optionally, give your task a due date (\'mm/dd/yyyy\' or \'mm-dd-yyyy\'): ', 'BOLD'))
asked = True
if date == '':
return date
if not self.validate_date(date):
self.print_error('That\'s not a valid date format!')
return date
def ask_user_finished(self):
""" Asks a user if a task is finished """
valid_responses = {
'yes': True,
'y': True,
'no': False,
'n': False
}
default_resp = False
while True:
user_resp = input(self.color_message('Is the task already finished? (y/N): ', 'BOLD')).lower()
if user_resp in valid_responses:
return valid_responses[user_resp]
if user_resp == '':
return default_resp
self.print_error('That\'s not a valid answer! Answer (y/N).')
def ask_user_id(self, action):
""" Ask the user for a task ID to remove/finish/unfinish/update """
row_id = input(self.color_message(f'What task would you like to {action}? (Enter an ID or `-1` to cancel): ', 'BOLD'))
return row_id
| 39.927007 | 135 | 0.599543 |
38b475e356c9257cf2acb6108f75db0b7ba6093f | 4,462 | h | C | Common/Renderers/EPlotRenderer.h | achilex/MgDev | f7baf680a88d37659af32ee72b9a2046910b00d8 | [
"PHP-3.0"
] | 2 | 2017-04-19T01:38:30.000Z | 2020-07-31T03:05:32.000Z | Common/Renderers/EPlotRenderer.h | achilex/MgDev | f7baf680a88d37659af32ee72b9a2046910b00d8 | [
"PHP-3.0"
] | null | null | null | Common/Renderers/EPlotRenderer.h | achilex/MgDev | f7baf680a88d37659af32ee72b9a2046910b00d8 | [
"PHP-3.0"
] | 1 | 2021-12-29T10:46:12.000Z | 2021-12-29T10:46:12.000Z | //
// Copyright (C) 2004-2011 by Autodesk, Inc.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of version 2.1 of the GNU Lesser
// General Public License as published by the Free Software Foundation.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
#ifndef EPLOTRENDERER_H
#define EPLOTRENDERER_H
#include "DWFRenderer.h"
namespace DWFToolkit
{
class DWFEPlotSection;
class DWFPackageWriter;
};
namespace DWFCore
{
class DWFUUID;
}
using namespace DWFCore;
///<summary>
/// Specialization of DWFRenderer for EPlot output.
/// An EPlotRenderer needs to be initialized with
/// page size and units settings
///</summary>
class EPlotRenderer : public DWFRenderer
{
public:
RENDERERS_API EPlotRenderer(const RS_String& filename,
double pageWidth,
double pageHeight,
const RS_String& pageUnits);
RENDERERS_API virtual ~EPlotRenderer();
///////////////////////////////////////////////////////////////////
// DWFRenderer overloads
//
RENDERERS_API virtual void StartMap(RS_MapUIInfo* mapInfo,
RS_Bounds& extents,
double mapScale,
double dpi,
double metersPerUnit,
CSysTransformer* xformToLL = NULL);
RENDERERS_API virtual void EndMap();
RENDERERS_API virtual void StartLayer(RS_LayerUIInfo* layerInfo,
RS_FeatureClassInfo* classInfo);
RENDERERS_API virtual void EndLayer();
RENDERERS_API virtual void Done();
////////////////////////////////////////////////
// SE_Renderer overloads
//
virtual bool OptimizeGeometry();
///////////////////////////////////////////////////////////////////
// EPlot specific stuff
//
RENDERERS_API void SetPageWidth(double width);
RENDERERS_API void SetPageHeight(double height);
RENDERERS_API void SetPageSizeUnits(std::wstring units);
RENDERERS_API void SetMapWidth(double width);
RENDERERS_API void SetMapHeight(double height);
RENDERERS_API void EnableLayoutPlot();
inline double & mapWidth()
{
return m_dMapWidth;
}
inline double & mapHeight()
{
return m_dMapHeight;
}
inline double & mapOffsetX()
{
return m_dMapOffsetX;
}
inline double & mapOffsetY()
{
return m_dMapOffsetY;
}
inline double & mapBoundsHeight()
{
return m_dMapBoundsHeight;
}
bool IsLayoutPlot();
private:
// Hidden copy constructor and assignment operator.
EPlotRenderer(const EPlotRenderer&);
EPlotRenderer& operator=(const EPlotRenderer&);
std::wstring m_dwfFilename;
std::wstring m_pageUnits;
double m_dPageWidth;
double m_dPageHeight;
DWFToolkit::DWFPackageWriter* m_dwfPackageWriter;
bool m_bFirst;
DWFUUID* m_uuid;
double m_dMapWidth; // the width of the map in page units
double m_dMapHeight; // the height of the map in page units
double m_dMapOffsetX; // the X offset of the map in page units
double m_dMapOffsetY; // the Y offset of the map in page units
double m_dMapBoundsHeight; // the height of the map bounds on the page
bool m_bLayoutPlot;
stream_list m_lSectionStreams;
stream_list m_lSectionLabelStreams;
stream_list m_lSectionLayoutStreams;
stream_list m_lSectionLayoutLabelStreams;
void AddW2DResource(DWFCore::DWFBufferOutputStream* w2dStream,
DWFToolkit::DWFObjectDefinitionResource* objdefs,
const double* transform,
const double* clip,
const wchar_t* role,
const wchar_t* name);
};
#endif
| 28.420382 | 78 | 0.606455 |
50747307412ebf31f4af2dc62517f1e3db94dea8 | 6,223 | go | Go | src/sippy/rtp_proxy_client_opts.go | voiceip/go-b2bua | 71427be1b452e169c3ed8ca88a88abe26ccee56e | [
"BSD-2-Clause"
] | 49 | 2016-03-29T09:44:56.000Z | 2022-03-09T01:51:08.000Z | src/sippy/rtp_proxy_client_opts.go | voiceip/go-b2bua | 71427be1b452e169c3ed8ca88a88abe26ccee56e | [
"BSD-2-Clause"
] | 7 | 2017-10-23T14:54:51.000Z | 2019-12-27T11:06:03.000Z | src/sippy/rtp_proxy_client_opts.go | voiceip/go-b2bua | 71427be1b452e169c3ed8ca88a88abe26ccee56e | [
"BSD-2-Clause"
] | 11 | 2017-01-07T08:52:34.000Z | 2021-03-24T10:18:56.000Z | // Copyright (c) 2003-2005 Maxim Sobolev. All rights reserved.
// Copyright (c) 2006-2014 Sippy Software, Inc. All rights reserved.
// Copyright (c) 2016 Andriy Pylypenko. All rights reserved.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation and/or
// other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package sippy
import (
"net"
"strings"
"time"
"sippy/conf"
"sippy/log"
"sippy/net"
"sippy/types"
)
type rtpProxyClientOpts struct {
no_version_check bool
nworkers *int
hrtb_retr_ival time.Duration
hrtb_ival time.Duration
rtpp_class func(sippy_types.RtpProxyClient, sippy_conf.Config, net.Addr, *sippy_net.HostPort) (rtp_proxy_transport, error)
rtppaddr net.Addr
config sippy_conf.Config
logger sippy_log.ErrorLogger
proxy_address string
bind_address *sippy_net.HostPort
}
func NewRtpProxyClientOpts(spath string, bind_address *sippy_net.HostPort, config sippy_conf.Config, logger sippy_log.ErrorLogger) (*rtpProxyClientOpts, error) {
self := &rtpProxyClientOpts{
hrtb_retr_ival : 60 * time.Second,
hrtb_ival : 1 * time.Second,
no_version_check : false,
logger : logger,
config : config,
bind_address : bind_address,
}
var err error
if strings.HasPrefix(spath, "udp:") {
tmp := strings.SplitN(spath, ":", 3)
if len(tmp) == 2 {
self.rtppaddr, err = net.ResolveUDPAddr("udp", tmp[1] + ":22222")
} else {
self.rtppaddr, err = net.ResolveUDPAddr("udp", tmp[1] + ":" + tmp[2])
}
if err != nil { return nil, err }
self.proxy_address, _, err = net.SplitHostPort(self.rtppaddr.String())
if err != nil { return nil, err }
self.rtpp_class = newRtp_proxy_client_udp
} else if strings.HasPrefix(spath, "udp6:") {
tmp := strings.SplitN(spath, ":", 2)
spath := tmp[1]
rtp_proxy_host, rtp_proxy_port := spath, "22222"
if spath[len(spath)-1] != ']' {
idx := strings.LastIndexByte(spath, ':')
if idx < 0 {
rtp_proxy_host = spath
} else {
rtp_proxy_host, rtp_proxy_port = spath[:idx], spath[idx+1:]
}
}
if rtp_proxy_host[0] != '[' {
rtp_proxy_host = "[" + rtp_proxy_host + "]"
}
self.rtppaddr, err = net.ResolveUDPAddr("udp", rtp_proxy_host + ":" + rtp_proxy_port)
if err != nil { return nil, err }
self.proxy_address, _, err = net.SplitHostPort(self.rtppaddr.String())
if err != nil { return nil, err }
self.rtpp_class = newRtp_proxy_client_udp
} else if strings.HasPrefix(spath, "tcp:") {
tmp := strings.SplitN(spath, ":", 3)
if len(tmp) == 2 {
self.rtppaddr, err = net.ResolveTCPAddr("tcp", tmp[1] + ":22222")
} else {
self.rtppaddr, err = net.ResolveTCPAddr("tcp", tmp[1] + ":" + tmp[2])
}
if err != nil { return nil, err }
self.proxy_address, _, err = net.SplitHostPort(self.rtppaddr.String())
if err != nil { return nil, err }
self.rtpp_class = newRtp_proxy_client_stream
} else if strings.HasPrefix(spath, "tcp6:") {
tmp := strings.SplitN(spath, ":", 2)
spath := tmp[1]
rtp_proxy_host, rtp_proxy_port := spath, "22222"
if spath[len(spath)-1] != ']' {
idx := strings.LastIndexByte(spath, ':')
if idx < 0 {
rtp_proxy_host = spath
} else {
rtp_proxy_host, rtp_proxy_port = spath[:idx], spath[idx+1:]
}
}
if rtp_proxy_host[0] != '[' {
rtp_proxy_host = "[" + rtp_proxy_host + "]"
}
self.rtppaddr, err = net.ResolveTCPAddr("tcp", rtp_proxy_host + ":" + rtp_proxy_port)
if err != nil { return nil, err }
self.proxy_address, _, err = net.SplitHostPort(self.rtppaddr.String())
if err != nil { return nil, err }
self.rtpp_class = newRtp_proxy_client_stream
} else {
if strings.HasPrefix(spath, "unix:") {
self.rtppaddr, err = net.ResolveUnixAddr("unix", spath[5:])
} else if strings.HasPrefix(spath, "cunix:") {
self.rtppaddr, err = net.ResolveUnixAddr("unix", spath[6:])
} else {
self.rtppaddr, err = net.ResolveUnixAddr("unix", spath)
}
if err != nil { return nil, err }
self.proxy_address = self.config.SipAddress().String()
self.rtpp_class = newRtp_proxy_client_stream
}
return self, nil
}
func (self *rtpProxyClientOpts) SetHeartbeatInterval(ival time.Duration) {
self.hrtb_ival = ival
}
func (self *rtpProxyClientOpts) SetHeartbeatRetryInterval(ival time.Duration) {
self.hrtb_retr_ival = ival
}
func (self *rtpProxyClientOpts) GetNWorkers() *int {
return self.nworkers
}
| 40.673203 | 161 | 0.621404 |
bfc1d3f360b9862c9e8d9656ba48ff2e72ff8281 | 146 | lua | Lua | res/npc/npc_roy/dl_npc_roy.lua | tizian/Cendric2 | 5b0438c73a751bcc0d63c3af839af04ab0fb21a3 | [
"MIT"
] | 279 | 2015-05-06T19:04:07.000Z | 2022-03-21T21:33:38.000Z | res/npc/npc_roy/dl_npc_roy.lua | tizian/Cendric2 | 5b0438c73a751bcc0d63c3af839af04ab0fb21a3 | [
"MIT"
] | 222 | 2016-10-26T15:56:25.000Z | 2021-10-03T15:30:18.000Z | res/npc/npc_roy/dl_npc_roy.lua | tizian/Cendric2 | 5b0438c73a751bcc0d63c3af839af04ab0fb21a3 | [
"MIT"
] | 49 | 2015-10-01T21:23:03.000Z | 2022-03-19T20:11:31.000Z | -- Dialogue for NPC "npc_roy"
loadDialogue = function(DL)
DL:setRoot(1)
DL:createNPCNode(1, -1, "DL_Roy_Nothing") -- ...
DL:addNode()
end | 14.6 | 49 | 0.657534 |
950f065ca47ba40784879320eb5979ad7faff4b4 | 429 | css | CSS | src/components/Content/carousel.css | alarivan/pizza | 7eb7fb9416e4258a8a3cc568bb2c6ba22d7c66d7 | [
"MIT"
] | null | null | null | src/components/Content/carousel.css | alarivan/pizza | 7eb7fb9416e4258a8a3cc568bb2c6ba22d7c66d7 | [
"MIT"
] | null | null | null | src/components/Content/carousel.css | alarivan/pizza | 7eb7fb9416e4258a8a3cc568bb2c6ba22d7c66d7 | [
"MIT"
] | null | null | null | .BrainhubCarousel .BrainhubCarousel__trackContainer .BrainhubCarousel__track {
padding: 2rem 0;
position: relative;
}
.BrainhubCarousel__customArrows {
position: absolute;
z-index: 100;
top: 50%;
transform: translateY(-50%);
}
.BrainhubCarousel__customArrows.BrainhubCarousel__custom-arrowLeft {
left: 50px;
}
.BrainhubCarousel__customArrows.BrainhubCarousel__custom-arrowRight {
right: 50px;
} | 22.578947 | 78 | 0.755245 |
f01db4ce612793fa6669b67b17c501ac73c893ec | 6,037 | py | Python | eslearn/machine_learning/classfication/el_classify_sensitive_person_test.py | dongmengshi/easylearn | df528aaa69c3cf61f5459a04671642eb49421dfb | [
"MIT"
] | null | null | null | eslearn/machine_learning/classfication/el_classify_sensitive_person_test.py | dongmengshi/easylearn | df528aaa69c3cf61f5459a04671642eb49421dfb | [
"MIT"
] | null | null | null | eslearn/machine_learning/classfication/el_classify_sensitive_person_test.py | dongmengshi/easylearn | df528aaa69c3cf61f5459a04671642eb49421dfb | [
"MIT"
] | 1 | 2021-01-11T08:21:35.000Z | 2021-01-11T08:21:35.000Z | # -*- coding: utf-8 -*-
"""
Created on 2020/03/16
Feature selection: Relief-based feature selection algorithm.
------
@author: LI Chao
"""
import numpy as np
from sklearn import preprocessing
import os
from sklearn.externals import joblib
from el_classify_sensitive_person_train_validation import ClassifyFourKindOfPersonTrain
from eslearn.utils.lc_evaluation_model_performances import eval_performance
class ClassifyFourKindOfPersonTest():
"""
This class is used to testing classification model for 2 kind of sensitive person identification.
Parameters
----------
data_test_file: path str
Path of the dataset
label_test_file: path str
Path of the label
path_out :
Path to save results
is_feature_selection : bool
if perfrome feature selection.
is_showfig_finally: bool
If show figure after all iteration finished.
Returns
-------
Save all classification results and figures to local disk.
"""
def __init__(selftest,
data_test_file=None,
label_test_file=None,
data_train_file=None,
models_path=None,
path_out=None,
is_feature_selection=False,
is_showfig_finally=True):
selftest.data_test_file = data_test_file
selftest.label_test_file = label_test_file
selftest.data_train_file = data_train_file
selftest.path_out = path_out
selftest.models_path = models_path
selftest.is_feature_selection = is_feature_selection
selftest.is_showfig_finally = is_showfig_finally
def main_function(selftest):
"""
"""
print('Training model and testing...\n')
# load data and mask
mask_lassocv = joblib.load(os.path.join(selftest.path_out, 'mask_selected_features_lassocv.pkl'))
model_feature_selection = joblib.load(os.path.join(selftest.models_path, 'model_feature_selection.pkl'))
model_classification = joblib.load(os.path.join(selftest.models_path, 'model_classification.pkl'))
feature_test, selftest.label_test, feature_train = selftest._load_data()
# Age encoding
feature_test[:,2] = ClassifyFourKindOfPersonTrain().age_encodeing(feature_train[:,2], feature_test[:,2])
# Feature selection
if selftest.is_feature_selection:
feature_test = feature_test[:, mask_lassocv != 0]
# Testting
selftest.prediction, selftest.decision = selftest.testing(model_classification, feature_test)
# Evaluating classification performances
selftest.accuracy, selftest.sensitivity, selftest.specificity, selftest.AUC = eval_performance(selftest.label_test, selftest.prediction, selftest.decision,
accuracy_kfold=None, sensitivity_kfold=None, specificity_kfold=None, AUC_kfold=None,
verbose=1, is_showfig=0)
# Save results and fig to local path
selftest.save_results()
selftest.save_fig()
print("--" * 10 + "Done!" + "--" * 10 )
return selftest
def _load_data(selftest):
"""
Load data
"""
data_test = np.load(selftest.data_test_file)
label_test = np.load(selftest.label_test_file)
data_train = np.load(selftest.data_train_file)
return data_test, label_test, data_train
def testing(selftest, model, test_X):
predict = model.predict(test_X)
decision = model.decision_function(test_X)
return predict, decision
def save_results(selftest):
# Save performances and others
import pandas as pd
performances_to_save = np.array([selftest.accuracy, selftest.sensitivity, selftest.specificity, selftest.AUC]).reshape(1,4)
de_pred_label_to_save = np.vstack([selftest.decision.T, selftest.prediction.T, selftest.label_test.T]).T
performances_to_save = pd.DataFrame(performances_to_save, columns=[['Accuracy','Sensitivity', 'Specificity', 'AUC']])
de_pred_label_to_save = pd.DataFrame(de_pred_label_to_save, columns=[['Decision','Prediction', 'Sorted_Real_Label']])
performances_to_save.to_csv(os.path.join(selftest.path_out, 'test_Performances.txt'), index=False, header=True)
de_pred_label_to_save.to_csv(os.path.join(selftest.path_out, 'test_Decision_prediction_label.txt'), index=False, header=True)
def save_fig(selftest):
# Save ROC and Classification 2D figure
acc, sens, spec, auc = eval_performance(selftest.label_test, selftest.prediction, selftest.decision,
selftest.accuracy, selftest.sensitivity, selftest.specificity, selftest.AUC,
verbose=0, is_showfig=selftest.is_showfig_finally, is_savefig=1,
out_name=os.path.join(selftest.path_out, 'Classification_performances_test.pdf'),
legend1='Healthy', legend2='Unhealthy')
#
if __name__ == '__main__':
# =============================================================================
# All inputs
data_file = r'D:\workstation_b\Fundation\给黎超.xlsx'
path_out = r'D:\workstation_b\Fundation'
models_path = r'D:\workstation_b\Fundation'
# =============================================================================
selftest = ClassifyFourKindOfPersonTest(data_test_file=r'D:\workstation_b\Fundation\feature_test.npy',
label_test_file=r'D:\workstation_b\Fundation\label_test.npy',
data_train_file=r'D:\workstation_b\Fundation\feature_train.npy',
path_out=path_out,
models_path=models_path,
is_feature_selection=1)
selftest.main_function()
| 41.349315 | 164 | 0.630777 |
b37825a0a956dd041e3f7b1c03b5244e3fd218ee | 151 | sql | SQL | borrower1.sql | open-risk/Academy-Course-DAT31063 | c47baa401e990dfb2caa137c2d20e397429793f5 | [
"Apache-2.0"
] | null | null | null | borrower1.sql | open-risk/Academy-Course-DAT31063 | c47baa401e990dfb2caa137c2d20e397429793f5 | [
"Apache-2.0"
] | null | null | null | borrower1.sql | open-risk/Academy-Course-DAT31063 | c47baa401e990dfb2caa137c2d20e397429793f5 | [
"Apache-2.0"
] | null | null | null | -- Single Table Inheritance
CREATE TABLE Borrower1 (
Name varchar(255),
MarketCapitalisation numeric (10,3),
AnnualIncome numeric (10,3)
); | 25.166667 | 40 | 0.715232 |
cbceba42e10e3afe0aed2933b2128c9458c9324d | 2,833 | go | Go | slice_test.go | belfinor/slice | 62822543bddc6a32b215506d4a8e0a38656018f5 | [
"MIT"
] | 2 | 2019-11-04T19:16:06.000Z | 2019-11-04T19:24:12.000Z | slice_test.go | belfinor/slice | 62822543bddc6a32b215506d4a8e0a38656018f5 | [
"MIT"
] | 4 | 2019-10-01T07:14:50.000Z | 2019-10-01T08:31:12.000Z | slice_test.go | belfinor/slice | 62822543bddc6a32b215506d4a8e0a38656018f5 | [
"MIT"
] | null | null | null | package slice
// @author Mikhail Kirillov <[email protected]>
// @version 1.003
// @date 2019-10-01
import (
"fmt"
"testing"
)
func TestSlice(t *testing.T) {
orig := []int{1, 2, 3, 4, 5}
Reverse(orig)
if len(orig) != 5 {
t.Fatal("slice.Reverse corrupt data")
}
for i, v := range orig {
if v != 5-i {
t.Fatal("slice.Reverse not work")
}
}
Shuffle(orig)
if len(orig) != 5 {
t.Fatal("slice.Shuffle corrupt data")
}
}
func TestContain(t *testing.T) {
tF := func(list interface{}, obj interface{}, has bool, place int) {
rh, rp := Contain(list, obj)
if rh != has {
t.Fatal(fmt.Sprintf("Wrong result slice %v obj %v", list, obj))
}
if rp != place {
t.Fatal(fmt.Sprintf("Wrong index slice %v obj %v", list, obj))
}
}
tF([]string{"1", "2", "3", "10", "12", "13"}, "2", true, 1)
tF([]string{"1", "2", "3", "10", "12", "13"}, "9", false, -1)
tF([]string{"1", "2", "3", "10", "12", "13"}, "12", true, 4)
var list []string
tF(list, "12", false, -1)
tF(nil, "12", false, -1)
tF([]int{1, 2, 3, 4, 5, 6}, 4, true, 3)
tF([]int{1, 2, 3, 4, 5, 6}, 0, false, -1)
}
func TestEqual(t *testing.T) {
tF := func(l1 interface{}, l2 interface{}, wait bool) {
if Equal(l1, l2) != wait {
t.Fatal(fmt.Sprintf("Equal failed on %v and %v", l1, l2))
}
}
var list []string
list = append(list, "1", "3", "5", "7")
tF(nil, nil, true)
tF(nil, []string{}, true)
tF(nil, "", false)
tF([]string{}, nil, true)
tF(0, nil, false)
tF([]string{}, []string{}, true)
tF([]int{}, []int{}, true)
tF([]int{1, 2, 3}, []int{1, 2, 3}, true)
tF([]int{1, 2, 3}, []int{1, 2, 4}, false)
tF([]int{1, 2, 3}, []int{1, 2, 3, 4}, false)
tF([]string{"1", "3", "5", "7"}, []string{"1", "3", "5", "7"}, true)
tF(list, []string{"1", "3", "5", "7"}, true)
tF(list, []string{"1", "3", "6", "7"}, false)
}
func TestAppendNewValue(t *testing.T) {
var list []string
AppendNewValue(&list, "")
if !Equal(list, []string{""}) {
t.Fatal("Add \"\" failed")
}
AppendNewValue(&list, "")
if !Equal(list, []string{""}) {
t.Fatal("Add \"\" failed")
}
AppendNewValue(&list, "1")
if !Equal(list, []string{"", "1"}) {
t.Fatal("Add \"1\" failed")
}
AppendNewValue(&list, "2")
if !Equal(list, []string{"", "1", "2"}) {
t.Fatal("Add \"2\" failed")
}
AppendNewValue(&list, "0")
if !Equal(list, []string{"", "1", "2", "0"}) {
t.Fatal("Add \"0\" failed")
}
AppendNewValue(&list, "2")
if !Equal(list, []string{"", "1", "2", "0"}) {
t.Fatal("Add \"2\" failed")
}
AppendNewValue(nil, 12)
AppendNewValue("12", 12)
var i int
AppendNewValue(&i, 12)
ilist := []int{5, 8, 9, 13}
AppendNewValue(&ilist, 2)
if !Equal(ilist, []int{5, 8, 9, 13, 2}) {
t.Fatal("Add 2 failed")
}
AppendNewValue(&ilist, 8)
if !Equal(ilist, []int{5, 8, 9, 13, 2}) {
t.Fatal("Add 8 failed")
}
}
| 19.950704 | 69 | 0.534416 |
dbcaa08b9f43a74fff5aa00fc5fe41b86749fff6 | 53 | sql | SQL | regmgr/migrations/0005-section.sql | benclifford/MSE | 3a3b0d5da255e7c799c6e8c08296f2386860e2dd | [
"FSFAP"
] | 1 | 2021-01-10T17:52:09.000Z | 2021-01-10T17:52:09.000Z | regmgr/migrations/0005-section.sql | benclifford/MSE | 3a3b0d5da255e7c799c6e8c08296f2386860e2dd | [
"FSFAP"
] | null | null | null | regmgr/migrations/0005-section.sql | benclifford/MSE | 3a3b0d5da255e7c799c6e8c08296f2386860e2dd | [
"FSFAP"
] | null | null | null | ALTER TABLE regmgr_attendee ADD COLUMN section TEXT;
| 26.5 | 52 | 0.849057 |
a8dbe5bd998d90d98e3c8c88c85874a068d84095 | 5,205 | rs | Rust | rs/replicated_state/src/page_map/tests.rs | audieleon/ic | 35dd8f93dec82662ed4df35664a9c0be6dbf203a | [
"Apache-2.0"
] | 1 | 2021-07-20T21:44:44.000Z | 2021-07-20T21:44:44.000Z | rs/replicated_state/src/page_map/tests.rs | AmoretAaron/ic | d9202bc7f6d16b2777d4e092ee1b7ad5899aae2b | [
"Apache-2.0"
] | null | null | null | rs/replicated_state/src/page_map/tests.rs | AmoretAaron/ic | d9202bc7f6d16b2777d4e092ee1b7ad5899aae2b | [
"Apache-2.0"
] | 1 | 2022-01-13T13:37:41.000Z | 2022-01-13T13:37:41.000Z | use super::{allocate_pages, checkpoint::Checkpoint, Buffer, PageDelta, PageIndex, PageMap};
use ic_sys::PAGE_SIZE;
use std::fs::OpenOptions;
#[test]
fn can_debug_display_a_page_map() {
let page_map = PageMap::new();
assert_eq!(format!("{:?}", page_map), "{}");
}
#[test]
fn can_create_an_empty_checkpoint() {
let checkpoint = Checkpoint::empty();
let empty_page = vec![0; *PAGE_SIZE];
let first_page = checkpoint.get_page(PageIndex::from(1));
assert_eq!(&empty_page[..], first_page);
}
#[test]
fn empty_page_map_returns_zeroed_pages() {
let page_map = PageMap::new();
let page = page_map.get_page(PageIndex::from(1));
assert_eq!(page.len(), *PAGE_SIZE);
assert!(page.iter().all(|b| *b == 0));
}
#[test]
fn can_update_a_page_map() {
let mut page_map = PageMap::new();
let ones = vec![1u8; *PAGE_SIZE];
let twos = vec![2u8; *PAGE_SIZE];
let delta = PageDelta::from(
&[
(PageIndex::from(1), &ones[..]),
(PageIndex::from(2), &twos[..]),
][..],
);
page_map.update(delta);
for (num, contents) in &[(1, 1), (2, 2), (3, 0)] {
assert!(page_map
.get_page(PageIndex::from(*num))
.iter()
.all(|b| *b == *contents));
}
}
#[test]
fn can_allocate_pages() {
let page = vec![5; *PAGE_SIZE];
let tracked_pages = allocate_pages(&[&page[..]]);
assert_eq!(tracked_pages.len(), 1);
assert_eq!(tracked_pages[0].contents(), page.as_slice());
}
#[test]
fn can_make_page_deltas() {
let page = vec![5u8; *PAGE_SIZE];
let page_delta = PageDelta::from(&[(PageIndex::from(5), &page[..])][..]);
assert_eq!(page_delta.len(), 1);
assert_eq!(page_delta.get_page(PageIndex::from(5)).unwrap(), &page[..])
}
#[test]
fn left_delta_wins_in_extend() {
let page_1 = vec![1u8; *PAGE_SIZE];
let page_2 = vec![2u8; *PAGE_SIZE];
let delta_1 = PageDelta::from(&[(PageIndex::from(1), &page_1[..])][..]);
let delta_2 = PageDelta::from(&[(PageIndex::from(1), &page_2[..])][..]);
let union_12 = delta_1.extend(delta_2);
assert_eq!(union_12.len(), 1);
assert_eq!(union_12.get_page(PageIndex::from(1)).unwrap(), &page_1[..]);
}
#[test]
fn persisted_map_is_equivalent_to_the_original() {
let tmp = tempfile::Builder::new()
.prefix("checkpoints")
.tempdir()
.unwrap();
let heap_file = tmp.path().join("heap");
let page_1 = vec![1u8; *PAGE_SIZE];
let page_3 = vec![3u8; *PAGE_SIZE];
let delta = PageDelta::from(
&[
(PageIndex::from(1), &page_1[..]),
(PageIndex::from(3), &page_3[..]),
][..],
);
let mut original_map = PageMap::default();
original_map.update(delta);
original_map.persist_delta(&heap_file).unwrap();
let persisted_map = PageMap::open(&heap_file).unwrap();
assert_eq!(persisted_map, original_map);
}
#[test]
fn can_persist_and_load_an_empty_page_map() {
let tmp = tempfile::Builder::new()
.prefix("checkpoints")
.tempdir()
.unwrap();
let heap_file = tmp.path().join("heap");
let original_map = PageMap::default();
original_map.persist_delta(&heap_file).unwrap();
let persisted_map = PageMap::open(&heap_file).expect("opening an empty page map must succeed");
assert_eq!(original_map, persisted_map);
}
#[test]
fn returns_an_error_if_file_size_is_not_a_multiple_of_page_size() {
use std::io::Write;
let tmp = tempfile::Builder::new()
.prefix("checkpoints")
.tempdir()
.unwrap();
let heap_file = tmp.path().join("heap");
OpenOptions::new()
.write(true)
.create(true)
.open(&heap_file)
.unwrap()
.write_all(&vec![1; *PAGE_SIZE / 2])
.unwrap();
match PageMap::open(&heap_file) {
Err(err) => assert!(
err.is_invalid_heap_file(),
"Expected invalid heap file error, got {:?}",
err
),
Ok(_) => panic!("Expected a invalid heap file error, got Ok(_)"),
}
}
#[test]
fn can_use_buffer_to_modify_page_map() {
let page_1 = vec![1u8; *PAGE_SIZE];
let page_3 = vec![3u8; *PAGE_SIZE];
let delta = PageDelta::from(
&[
(PageIndex::from(1), &page_1[..]),
(PageIndex::from(3), &page_3[..]),
][..],
);
let mut page_map = PageMap::default();
page_map.update(delta);
let n = 4 * *PAGE_SIZE;
let mut vec_buf = vec![0u8; n];
vec_buf[*PAGE_SIZE..2 * *PAGE_SIZE].copy_from_slice(&page_1);
vec_buf[3 * *PAGE_SIZE..4 * *PAGE_SIZE].copy_from_slice(&page_3);
let mut buf = Buffer::new(page_map);
let mut read_buf = vec![0u8; n];
buf.read(&mut read_buf[..], 0);
assert_eq!(read_buf, vec_buf);
for offset in 0..n {
let mut len = 1;
while (offset + len) < n {
let b = ((offset + len) % 15) as u8;
for dst in vec_buf.iter_mut().skip(offset).take(len) {
*dst = b;
}
buf.write(&vec_buf[offset..offset + len], offset);
buf.read(&mut read_buf[..], 0);
assert_eq!(read_buf, vec_buf);
len *= 2;
}
}
}
| 27.68617 | 99 | 0.578866 |
c16548b0cd4a0920d60ac3974f0ba3ac5f7880bd | 817 | kt | Kotlin | app/src/test/java/com/igorwojda/integer/reverse/Reverse.kt | sunyal/kotlin-coding-puzzle | 66ca5d90d523613e04a9664be70e934ce1f0b2cf | [
"MIT"
] | 3 | 2021-02-09T18:17:07.000Z | 2021-07-19T05:44:54.000Z | app/src/test/java/com/igorwojda/integer/reverse/Reverse.kt | Shabinder/kotlin-coding-puzzle | 84201833df722ca5aea9853ddc0842c8c200427f | [
"MIT"
] | null | null | null | app/src/test/java/com/igorwojda/integer/reverse/Reverse.kt | Shabinder/kotlin-coding-puzzle | 84201833df722ca5aea9853ddc0842c8c200427f | [
"MIT"
] | null | null | null | package com.igorwojda.integer.reverse
import org.amshove.kluent.shouldEqual
import org.junit.Test
private fun reverseInt(i: Int): Int {
TODO("not implemented")
}
class ReverseIntTest {
@Test
fun `ReverseInt handles 0 as an input`() {
reverseInt(0) shouldEqual 0
}
@Test
fun `ReverseInt flips a positive number`() {
reverseInt(5) shouldEqual 5
reverseInt(15) shouldEqual 51
reverseInt(90) shouldEqual 9
reverseInt(700) shouldEqual 7
reverseInt(2359) shouldEqual 9532
}
@Test
fun `ReverseInt flips a negative number`() {
reverseInt(-5) shouldEqual -5
reverseInt(-15) shouldEqual -51
reverseInt(-90) shouldEqual -9
reverseInt(-700) shouldEqual -7
reverseInt(-2359) shouldEqual -9532
}
}
| 24.029412 | 48 | 0.649939 |
2eb8f590d8c00b548c8509294e05b99266da7c8c | 278 | swift | Swift | RAWG-GameCatalogue/Domain/Interfaces/Repositories/ProfileRepository.swift | ddiffa/RAWG-GameCatalogue | b0c9464338f84ff9761a46eeeba6e3853f8f1700 | [
"MIT"
] | 1 | 2021-09-06T08:58:11.000Z | 2021-09-06T08:58:11.000Z | RAWG-GameCatalogue/Domain/Interfaces/Repositories/ProfileRepository.swift | ddiffa/RAWG-GameCatalogue | b0c9464338f84ff9761a46eeeba6e3853f8f1700 | [
"MIT"
] | null | null | null | RAWG-GameCatalogue/Domain/Interfaces/Repositories/ProfileRepository.swift | ddiffa/RAWG-GameCatalogue | b0c9464338f84ff9761a46eeeba6e3853f8f1700 | [
"MIT"
] | null | null | null | //
// ProfileRepository.swift
// RAWG-GameCatalogue
//
// Created by Diffa Desyawan on 04/09/21.
//
import Foundation
protocol ProfileRepository {
func fetch(completion: @escaping (Profile?) -> Void)
func save(profile: Profile, completion: @escaping () -> Void)
}
| 19.857143 | 66 | 0.690647 |
4a4085480b511d79405f3cf144fc815ba6cba3b6 | 22,130 | js | JavaScript | ProtoKameo1/ProtoKameo1/engine.js | neoranga55/kamelo | b5da2dc4731481698f738e3c9137beb36f2e3b8b | [
"CC-BY-3.0",
"MIT"
] | null | null | null | ProtoKameo1/ProtoKameo1/engine.js | neoranga55/kamelo | b5da2dc4731481698f738e3c9137beb36f2e3b8b | [
"CC-BY-3.0",
"MIT"
] | null | null | null | ProtoKameo1/ProtoKameo1/engine.js | neoranga55/kamelo | b5da2dc4731481698f738e3c9137beb36f2e3b8b | [
"CC-BY-3.0",
"MIT"
] | null | null | null |
EngineClass = Class.extend({
player0: null,
entities: [],
factory: {},
_deferredKill: [],
sprites_loaded: 0, // 0 means not loaded, 1 and 2 loaded
flyes_alive: 0,
max_flyes_alive: 15,
last_fly_created: 0,
total_fly_counter: 0,
cheer_up_goal: 4,
scrore_frames: 0,
instructions_canvas: null,
bar_canvas: null,
//-----------------------------
setup: function () {
// Prepare game instructions once to render later multiple times
this.instructions_canvas = document.createElement("canvas");
this.instructions_canvas.width = canvas.width;
this.instructions_canvas.height = canvas.height;
var instructions_context = this.instructions_canvas.getContext('2d');
var zoom_inst_offset = 0;
instructions_context.textAlign = 'left';
if (screen.width < 1920) { // Show zooming instructions when game canvases do not fit in screen
var percent_res = screen.width / 1920;
zoom_inst_offset = 120;
var font_size = 38 * percent_res;
instructions_context.font = 'bold '+ font_size +'pt ' + game_font;
instructions_context.fillStyle = 'rgba(255, 0, 0, 1)'; // red
instructions_context.fillText(' Warning! Adjust ZOOM of the game with:', 10, font_size * 4);
instructions_context.fillStyle = 'rgba(0, 0, 200, 1)'; // green
instructions_context.fillText('"Ctrl" key & mouse wheel OR "Ctrl" key & "-" key', 10, font_size * 7);
}
instructions_context.textAlign = 'center';
instructions_context.font = 'bold 70pt ' + game_font;
instructions_context.fillStyle = 'rgba(0, 155, 0, 1)'; // green
instructions_context.fillText('Move with ← left and right →', canvas.width / 2, (canvas.height / 2) - 140 + zoom_inst_offset);
instructions_context.fillStyle = 'rgba(235, 135, 0, 1)'; // orange
instructions_context.fillText('Mouse click to catch flies', canvas.width / 2, (canvas.height / 2) + zoom_inst_offset);
instructions_context.fillStyle = 'rgba(255, 40, 40, 1)'; // red
instructions_context.fillText('Prevent Kame from starving', canvas.width / 2, (canvas.height / 2) + 140 + zoom_inst_offset);
instructions_context.fillStyle = 'rgba(200, 0, 0, 1)'; // dark red
instructions_context.font = 'bold 15pt ' + game_font;
instructions_context.fillText('Made with Love By Sebastian Lobato Genco & Jose Carlos Tapiador Carretero', canvas.width / 2, (canvas.height / 2) + 420);
// Create a loading bar
this.bar_canvas = document.createElement("canvas");
var ctx = this.bar_canvas.getContext("2d");
ctx.fillStyle = "#EE0000";
ctx.fillRect(0, 0, 100, 20);
// Start atmosphere sound => while playing equals true, I will trigger the atmosphere background sound
sound_atmos.play('atmos');
sound_atmos_active = true;
// Call our input setup method to bind our keys to actions and set the event listeners.
gInput.setup();
// Create game entities
this.player0 = gEngine.spawnEntity("Player", 250, 680); // Create player with initial position in canvas
this.player0.spritename = 'kami-walk-00';
},
spawnEntity: function (typename, x, y) {
var entityClass = gEngine.factory[typename];
var ent = new (entityClass)(x, y);
gEngine.entities.push(ent);
return ent;
},
endGame: function () {
end = true;
game_music.fadeOut(0.0, 5000, null); // Disable any background music
sound_atmos.fadeOut(0.0, 5000, null); // Disable any background music
kami_death.fadeOut(0.0, 5000, null); // Disable any background music
},
activateMusic: function () { // Activate action music and disable background music
sound_atmos.fadeOut(0.0, 4000, function () { sound_atmos_active = false; });
game_music.stop();
game_music.fadeIn(0.6, 0, function () { game_music_active = true; });
},
activateAtmosMusic: function () { // Activate background music and disable action music
game_music.fadeOut(0.0, 4000, function () { game_music_active = false; });
sound_atmos.stop();
sound_atmos.fadeIn(0.1, 2000, function () { sound_atmos_active = true; }); // Fade in
},
updateBackground: function () {
sun_angle += 0.002; // Sun rotation speed
},
drawBackground: function () { // Draw background with moving sun and score
if (this.sprites_loaded == 1) { // Draw only when images are loaded
this.sprites_loaded = 2; // Never draw it again
var tree_context = document.getElementById('TreeCanvas').getContext('2d');
drawSprite('tree.png', 1100, 420, 0, tree_context); // Draw tree on top of future score text
}
dynamic_background_context.clearRect(0, 0, dynamic_background_canvas.width, dynamic_background_canvas.height); // Clear background
// Draw sun on top of circular glow
drawSprite('sol.png', 1420, 170, sun_angle, dynamic_background_context); // Draw sun
// Draw Score
if (this.scrore_frames > 0) {
dynamic_background_context.font = 'bold 500pt ' + game_font;
var points_color = Math.round(this.player0.points * 255 / end_of_game_points);
dynamic_background_context.fillStyle = 'rgba(' + points_color + ',0,' + (255 - points_color) + ',1)';
dynamic_background_context.textAlign = 'center';
dynamic_background_context.fillText(this.player0.points, canvas.width / 2, canvas.height / 2 + 200);
this.scrore_frames = (this.scrore_frames + 1) % (FPS + 2); // Show for one second
if (victory) {
this.scrore_frames = (FPS + 1);
}
}
},
update: function () { // Update player position of player and flies, create and delete flies as the born and die
/// Control game intro ///
if ((introFrame >= introSeconds * FPS) && play_game_intro) {
play_game_intro = false;
}
if (game_instructions) { // Stop showing initial instructions
if (gInput.actions['fire-mouse'] || gInput.actions['move-left'] || gInput.actions['move-right']) {
game_instructions = false;
}
}
/// This clousure is full of SHIT to generate the flies ;-) ///
if ((this.flyes_alive < this.max_flyes_alive) && // Create flies until the maximum is reached
!play_game_intro){ // only after game intro finishes
var flyID = Math.floor(Math.random() * 3);
var seconds = (new Date()).getTime() / 1000;
// Choose randomly to not create a fly or create fly model 1 or 2 but only after a few seconds (periodically)
if ((flyID > 0) && (seconds - this.last_fly_created > 2)) {
var new_pos = { x: Math.floor(Math.random() * 1600), y: Math.floor(Math.random() * 700)};
var entFly = gEngine.spawnEntity("Fly", new_pos.x, new_pos.y);
entFly.spritename = 'fly-00' + flyID;
entFly.count_id = ++this.total_fly_counter;
if (this.total_fly_counter > 100000) { // Reset ID counter to avoid problems
this.total_fly_counter = 0;
}
entFly.speed = Math.floor(Math.random() * 500) + 50;
entFly.zindex += Math.floor(Math.random() * 20);
if (new_pos.x % 11 == 0) { // Turn the fly into an evil monster!
entFly.evil = true;
}
this.last_fly_created = seconds;
this.flyes_alive++;
// Play soft bubble sound
launchBubbleSound();
// Play fly sound
launchFlySound();
}
}
// Loop through the entities and call that entity's 'update' method, but only do it if that entity's '_killed' flag is set to true.
for (var i = 0; i < gEngine.entities.length; i++) {
var ent = gEngine.entities[i];
if (!ent._killed) {
ent.update();
} else { // Otherwise, push that entity onto the '_deferredKill' list defined above.
gEngine._deferredKill.push(ent);
if (ent.id == "Fly") {
this.flyes_alive--;
}
}
}
gEngine.updatePhysics(); /// Physics engine plus manual collision detections take place here ///
// Loop through the '_deferredKill' list and remove each entity in it from the 'entities' list.
for (var j = 0; j < gEngine._deferredKill.length; j++) {
gEngine.entities.erase(gEngine._deferredKill[j]);
}
gEngine._deferredKill = []; // Once you're done looping through '_deferredKill', set it back to the empty array, indicating all entities in it have been removed from the 'entities' list.
},
updatePhysics: function () {
if (typeof gPhysicsEngine !== 'undefined') {
gPhysicsEngine.update(); // Update physics
}
for (var i = 0; i < gEngine.entities.length; i++) { // Update entities with physics calculations
var ent = gEngine.entities[i];
if (ent.physBody) {
if (ent.id == "Fly") { // Only flies follow the physics system
ent.pos = ent.physBody.GetPosition(); // Update position
if ((ent.angle != 'undetermined') && (ent.angle != null)) {
ent.angle = ent.physBody.GetAngle(); // Update angle
}
} else if (ent.id == "Player") { // Update physical body position from manual movement
ent.physBody.SetPosition(new Vec2(ent.pos.x, ent.pos.y));
}
}
/// Fly hunting method when tongue animation reaches target ///
if ((ent.id == "Fly") && (!this.player0.miss_in_da_face) && !victory &&
(this.player0.tongue_frame == max_tongue_frames - 1) && !this.player0.dead) {
if (ent.updateCatch(this.player0.tong_fire_pos.x, this.player0.tong_fire_pos.y)) { // Points for death
if (ent.evil) { // Eat an evil poisoned fly!
launchBurpSound(); // Kami burps when catching an evil fly
console.log("Ate a posioned fly!!!");
if (this.player0.health > 190) {
this.player0.health -= 100;
} else if (this.player0.health > 130) {
this.player0.health -= 50;
} else {
this.player0.health = 80;
}
this.player0.yellow_filter.intensity = 1.0; // Turn yellow
} else {
launchDrySlapSound(); // Catch sound
this.player0.points++;
if (cheating) { // Cheating option to complete the game in one catch
this.player0.points += end_of_game_points;
}
this.player0.volatile_points++;
if (this.player0.health < 255) {
this.player0.health += 30;
if (this.player0.health < 130) {
this.player0.yellow_filter.intensity = 0.0; // Remove poison
} else {
this.player0.yellow_filter.intensity -= 0.2;
}
}
console.log("Points:" + this.player0.points);
if ((this.player0.points >= this.cheer_up_goal) || (this.player0.points >= end_of_game_points)) {
launchSound('cheer'); // Cheer up the user
this.cheer_up_goal += Math.round(this.cheer_up_goal * 0.4); // Adjust next target to a little bit more difficult
this.scrore_frames = 1; // Enable drawing score
if (this.player0.points >= end_of_game_points) { // Victory trigger
victory = true;
createFirework(); // Player has win, show victory animation
}
}
}
}
}
}
},
//----- Draw all entities in the game engine
draw: function () {
context.clearRect(0, 0, canvas.width, canvas.height); // First clean up screen
// Bucket entities by zIndex
var fudgeVariance = 128;
var zIndex_array = [];
var entities_bucketed_by_zIndex = {};
gEngine.entities.forEach(function (entity) {
//only draw entities that are in the screen
if (entity.pos.x <= canvas.width + (entity.size.width / 2) &&
entity.pos.x >= -(entity.size.width / 2) &&
entity.pos.y >= -(entity.size.height / 2) &&
entity.pos.y <= canvas.height + (entity.size.height / 2)) {
// Bucket the entities in the entities list by their zindex property.
if (!entities_bucketed_by_zIndex[entity.zindex]) {
entities_bucketed_by_zIndex[entity.zindex] = [];
}
entities_bucketed_by_zIndex[entity.zindex].push(entity);
if (!zIndex_array[entity.zindex]) {
zIndex_array[entity.zindex] = entity.zindex;
}
}
});
// Draw entities sorted by zIndex
zIndex_array.forEach(function (zindex) {
entities_bucketed_by_zIndex[zindex].forEach(function (entity) {
entity.draw();
});
});
if (victory || end) {
context.fillStyle = "rgba(0, 0, 0, 0.4)"; // Dark everything behind player when winning or game ends
context.fillRect(0, 0, canvas.width, canvas.height);
}
},
});
/// External facing functions ///
var animateBackground = function () {
setTimeout(function() {
if (!end) {
gEngine.updateBackground();
gEngine.drawBackground();
}
requestAnimationFrame(animateBackground);
}, 1000 / (FPS / 2)); // Dynamic background drawn half times than foreground
};
var animate = function () {
setTimeout(function () {
if (!end) {
if (background_loaded) { /// Main game update loop /// - This is where all the shit happens to attract the flies
gEngine.update();
gEngine.draw();
// Create Intro radial gradient in foreground while everything loads in the background
if (play_game_intro) {
introFrame++; // Start fading out loading screen
drawLoadingScreen(); // Still draw instructions for a few seconds while gradient is disolving
}
if (game_instructions) { // Show gameplay instructions until the user presses any of the game keys
game_context.drawImage(gEngine.instructions_canvas, 0, 0, canvas.width, canvas.height, 0, 0, canvas.width, canvas.height);
} else if ((!play_game_intro) && (game_context != null)) { // No intro and no game instructions -> Clean and Remove canvas context reference
game_context.clearRect(0, 0, canvas.width, canvas.height); // Clean up screen
game_context = null; // Not drawing anymore, only receiving input
}
}
} else {
dynamic_background_context.font = 'bold 250pt ' + game_font;
dynamic_background_context.fillStyle = 'rgba(0, 50, 255, 1)';
dynamic_background_context.textAlign = 'center';
dynamic_background_context.fillText('The End', canvas.width / 2, canvas.height / 2);
}
requestAnimationFrame(animate); // Call again on next possible frame
}, 1000 / FPS);
};
var drawLoadingScreen = function () {
game_context.clearRect(0, 0, canvas.width, canvas.height); // First clean up screen
var external_r = 20000 - (introFrame * introFrame * 2);
var grd = game_context.createRadialGradient(1420, 170, 200 - introFrame, 1420, 170, external_r); // Shrinking radius
var opacity = 1.05 - (introFrame / (introSeconds * FPS)); // Disolve slowly
grd.addColorStop(1, 'transparent');
grd.addColorStop(0, 'rgba(250,250,120,' + opacity + ')');
game_context.fillStyle = grd;
game_context.fillRect(0, 0, canvas.width, canvas.height);
if (game_instructions || !background_loaded) { // Show gameplay instructions until the user presses any of the game keys and the background loads
game_context.drawImage(gEngine.instructions_canvas, 0, 0, canvas.width, canvas.height, 0, 0, canvas.width, canvas.height);
}
if (!background_loaded) {
for (var i = 0; i < loading_bars; i++) { // Draw loading bar only while background image has not been loaded
game_context.drawImage(gEngine.bar_canvas, 0, 0, 100, 20, canvas.width / 2 - 300 + (200 * i), (canvas.height / 2) + 300, 100, 20);
}
window.setTimeout(function(){
if (!background_loaded) { // Keep drawing instructions plus loading bars only until background is loaded
loading_bars++;
drawLoadingScreen();
}
}, 500);
}
};
//-----------------------------------------
// External-facing function to get sprite based on the sprite name (ie. "kami-001.png")
var getSprite = function (spritename) {
// Walk through all our spritesheets defined in 'gSpriteSheets' and for each sheet...
for (var sheetName in gSpriteSheets) {
// Use the getStats method of the spritesheet to find if a sprite with name 'spritename' exists in that sheet...
var sheet = gSpriteSheets[sheetName];
var sprite = sheet.getStats(spritename);
if (sprite === null) {
continue;
}
// We assume there isn't another sprite of the given 'spritename' that we want to draw, so we return!
return sprite;
}
return null;
};
//-----------------------------------------
// External-facing function for drawing sprites based on the sprite name (ie. "kami-001.png", and the position on the canvas to draw to.
var drawSprite = function (spritename, posX, posY, angle, draw_context) {
// Walk through all our spritesheets defined in 'gSpriteSheets' and for each sheet...
for (var sheetName in gSpriteSheets) {
// Use the getStats method of the spritesheet to find if a sprite with name 'spritename' exists in that sheet...
var sheet = gSpriteSheets[sheetName];
var sprite = sheet.getStats(spritename);
// If we find the appropriate sprite, call '__drawSpriteInternal' with parameters as described below. Otherwise, continue with the loop...
if (sprite === null) {
continue;
}
__drawSpriteInternal(sprite, sheet, posX, posY, angle, draw_context);
// We assume there isn't another sprite of the given 'spritename' that we want to draw, so we return!
return;
}
};
//-----------------------------------------
// External-facing function for drawing sprites based on the sprite object stored in the 'sprites Array, the 'SpriteSheetClass' object stored in the 'gSpriteSheets' dictionary, and the position on canvas to draw to.
var __drawSpriteInternal = function (spt, sheet, posX, posY, angle, draw_context) {
if (spt === null || sheet === null) {
return;
}
// Call the drawImage method of our canvas context using the full drawImage API. drawImage takes, in order:
//
// 1) the Image object to draw, this is our entire spritesheet.
// 2) (From:) the x-coordinate we are drawing from in the spritesheet.
// 3) (From:) the y-coordinate we are drawing from in the spritesheet.
// 4) (From:) the width of the sprite we are drawing from our spritesheet.
// 5) (From:) the height of the sprite we are drawing from our spritesheet.
// 6) (To:) the x-coordinate we are drawing to in our canvas.
// 7) (To:) the y-coordinate we are drawing to in our canvas.
// 8) (To:) the width we are drawing in our canvas. This is in case we want to scale the image we are drawing to the canvas. In our case, we don't.
// 9) (To:) the height we are drawing in our canvas. This is in case we want to scale the image we are drawing to the canvas. In our case, we don't.
var hlf = {
x: spt.cx,
y: spt.cy
};
if ((typeof draw_context === 'undefined') || (draw_context == null)) {
draw_context = context; // Use default drawing canvas if no other is defined
}
if ((typeof flipped === 'undefined') || (flipped == null)) {
flipped = false; // By default don't mirror
}
if ((typeof angle !== 'undefined') && (angle != null)) { // Paint rotated object
draw_context.translate(posX, posY);
draw_context.rotate(angle);
if (spt.canvasCache != null) { // Rendering precalculated canvas
draw_context.drawImage(spt.canvasCache, 0, 0, spt.w, spt.h, hlf.x, hlf.y, spt.w, spt.h);
} else {
draw_context.drawImage(sheet.img, spt.x, spt.y, spt.w, spt.h, hlf.x, hlf.y, spt.w, spt.h);
}
draw_context.rotate(-angle);
draw_context.translate(-posX, -posY);
} else {
if (spt.canvasCache != null) { // Rendering precalculated canvas
draw_context.drawImage(spt.canvasCache, 0, 0, spt.w, spt.h, posX + hlf.x, posY + hlf.y, spt.w, spt.h);
} else {
draw_context.drawImage(sheet.img, spt.x, spt.y, spt.w, spt.h, posX + hlf.x, posY + hlf.y, spt.w, spt.h);
}
}
};
var gEngine = new EngineClass();
console.log("Engine loaded!");
| 50.873563 | 215 | 0.582422 |
0ed5ea68728e08696297ed81875294964630c001 | 15,097 | h | C | slprj/_sfprj/Demo_GazeFWaveIdleRand/_self/sfun/src/c1_Demo_GazeFWaveIdleRand.h | maryamsab/realact | 90fbf3fcb4696353c8a14d76797e5908126a9525 | [
"BSD-3-Clause"
] | 1 | 2020-12-02T21:41:36.000Z | 2020-12-02T21:41:36.000Z | slprj/_sfprj/Demo_GazeFWaveIdleRand/_self/sfun/src/c1_Demo_GazeFWaveIdleRand.h | maryamsab/realact | 90fbf3fcb4696353c8a14d76797e5908126a9525 | [
"BSD-3-Clause"
] | null | null | null | slprj/_sfprj/Demo_GazeFWaveIdleRand/_self/sfun/src/c1_Demo_GazeFWaveIdleRand.h | maryamsab/realact | 90fbf3fcb4696353c8a14d76797e5908126a9525 | [
"BSD-3-Clause"
] | 1 | 2018-06-23T11:59:06.000Z | 2018-06-23T11:59:06.000Z | #ifndef __c1_Demo_GazeFWaveIdleRand_h__
#define __c1_Demo_GazeFWaveIdleRand_h__
/* Include files */
#include "sf_runtime/sfc_sf.h"
#include "sf_runtime/sfc_mex.h"
#include "rtwtypes.h"
#include "multiword_types.h"
/* Type Definitions */
#ifndef typedef_SFc1_Demo_GazeFWaveIdleRandInstanceStruct
#define typedef_SFc1_Demo_GazeFWaveIdleRandInstanceStruct
typedef struct {
SimStruct *S;
ChartInfoStruct chartInfo;
uint32_T chartNumber;
uint32_T instanceNumber;
int32_T c1_sfEvent;
uint8_T c1_tp_envChangeWait;
uint8_T c1_tp_sendBMLbyPriority;
uint8_T c1_tp_sendH;
uint8_T c1_tp_init;
uint8_T c1_tp_checkHighPriority;
uint8_T c1_tp_sendM;
uint8_T c1_tp_Mid;
uint8_T c1_tp_sendL;
uint8_T c1_tp_low;
uint8_T c1_tp_RPSGameImitateSmileBrad;
uint8_T c1_tp_setDistanceIfUserMoves;
uint8_T c1_tp_waveBack;
uint8_T c1_tp_smile;
uint8_T c1_tp_Gaze;
uint8_T c1_tp_idlePoseBrad;
boolean_T c1_isStable;
uint8_T c1_is_active_c1_Demo_GazeFWaveIdleRand;
uint8_T c1_is_active_envChangeWait;
uint8_T c1_is_sendBMLbyPriority;
uint8_T c1_is_active_sendBMLbyPriority;
uint8_T c1_is_active_RPSGameImitateSmileBrad;
uint8_T c1_is_active_setDistanceIfUserMoves;
uint8_T c1_is_active_waveBack;
uint8_T c1_is_active_smile;
uint8_T c1_is_active_Gaze;
uint8_T c1_is_active_idlePoseBrad;
real_T c1_smileN;
real_T c1_t1;
real_T c1_t2;
real_T c1_newBmlA;
real_T c1_hEmpty;
real_T c1_newBmlsH[1280];
real_T c1_newBmlsL[1280];
real_T c1_lEmpty;
real_T c1_newBmlsM[1280];
real_T c1_mEmpty;
SimStruct *c1_subchartSimstruct;
SimStruct *c1_b_subchartSimstruct;
SimStruct *c1_c_subchartSimstruct;
SimStruct *c1_d_subchartSimstruct;
SimStruct *c1_e_subchartSimstruct;
SimStruct *c1_f_subchartSimstruct;
SimStruct *c1_g_subchartSimstruct;
uint8_T c1_doSetSimStateSideEffects;
const mxArray *c1_setSimStateSideEffectsInfo;
real_T (*c1_BML_address)[256];
int32_T c1_BML_index;
real_T (*c1_BML1_address)[256];
int32_T c1_BML1_index;
real_T (*c1_BML2_address)[256];
int32_T c1_BML2_index;
real_T *c1_BORED_address;
int32_T c1_BORED_index;
real_T *c1_BOREDOM_THRESHOLD_address;
int32_T c1_BOREDOM_THRESHOLD_index;
real_T *c1_CONTEMPT_address;
int32_T c1_CONTEMPT_index;
real_T *c1_EXCITE_address;
int32_T c1_EXCITE_index;
real_T *c1_FEAR_address;
int32_T c1_FEAR_index;
real_T *c1_FRUST_address;
int32_T c1_FRUST_index;
real_T *c1_GAZE_GUI_address;
int32_T c1_GAZE_GUI_index;
real_T *c1_GAZE_SOFTEYE_address;
int32_T c1_GAZE_SOFTEYE_index;
real_T *c1_GAZE_USER_HAND_address;
int32_T c1_GAZE_USER_HAND_index;
real_T *c1_GAZE_WIN_address;
int32_T c1_GAZE_WIN_index;
real_T *c1_HAPPY_address;
int32_T c1_HAPPY_index;
real_T *c1_IDLE_address;
int32_T c1_IDLE_index;
real_T *c1_P_address;
int32_T c1_P_index;
real_T *c1_SAD_address;
int32_T c1_SAD_index;
real_T *c1_STATE_BEFORE_address;
int32_T c1_STATE_BEFORE_index;
real_T *c1_STATE_GO_address;
int32_T c1_STATE_GO_index;
real_T *c1_STATE_HAND_address;
int32_T c1_STATE_HAND_index;
real_T *c1_STATE_OVER_address;
int32_T c1_STATE_OVER_index;
real_T *c1_STATE_READY_address;
int32_T c1_STATE_READY_index;
real_T *c1_STATE_RESULT_address;
int32_T c1_STATE_RESULT_index;
real_T *c1_STATE_WAIT_address;
int32_T c1_STATE_WAIT_index;
real_T *c1_avert_address;
int32_T c1_avert_index;
real_T *c1_bHand_address;
int32_T c1_bHand_index;
real_T (*c1_bmlsH_address)[1280];
int32_T c1_bmlsH_index;
real_T (*c1_bmlsL_address)[1280];
int32_T c1_bmlsL_index;
real_T (*c1_bmlsM_address)[1280];
int32_T c1_bmlsM_index;
real_T *c1_boredom_address;
int32_T c1_boredom_index;
real_T *c1_changeFlag_address;
int32_T c1_changeFlag_index;
real_T *c1_diff_address;
int32_T c1_diff_index;
real_T *c1_fileID_address;
int32_T c1_fileID_index;
real_T *c1_gazing_address;
int32_T c1_gazing_index;
real_T *c1_interest_address;
int32_T c1_interest_index;
real_T (*c1_n_address)[256];
int32_T c1_n_index;
real_T *c1_pa_address;
int32_T c1_pa_index;
real_T *c1_pr_address;
int32_T c1_pr_index;
real_T *c1_r_address;
int32_T c1_r_index;
real_T *c1_randAvertGazeChance_address;
int32_T c1_randAvertGazeChance_index;
real_T *c1_randGazeDur_address;
int32_T c1_randGazeDur_index;
real_T *c1_randPoseChance_address;
int32_T c1_randPoseChance_index;
real_T *c1_randSlowPose_address;
int32_T c1_randSlowPose_index;
real_T *c1_randSmile_address;
int32_T c1_randSmile_index;
real_T *c1_s_address;
int32_T c1_s_index;
real_T *c1_t_address;
int32_T c1_t_index;
real_T *c1_temp_address;
int32_T c1_temp_index;
real_T *c1_uHand_address;
int32_T c1_uHand_index;
} SFc1_Demo_GazeFWaveIdleRandInstanceStruct;
#endif /*typedef_SFc1_Demo_GazeFWaveIdleRandInstanceStruct*/
/* Named Constants */
/* Variable Declarations */
/* Variable Definitions */
/* Function Declarations */
extern const mxArray
*sf_c1_Demo_GazeFWaveIdleRand_get_eml_resolved_functions_info(void);
extern void sf_exported_auto_gatewayc10_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_gatewayc5_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_gatewayc8_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_gatewayc20_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_gatewayc11_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_gatewayc9_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_gatewayc4_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_activate_c10_Demo_GazeFWaveIdleRand_secs(SimStruct *
c1_S);
extern void sf_exported_auto_activate_c5_Demo_GazeFWaveIdleRand_secs(SimStruct
*c1_S);
extern void sf_exported_auto_activate_c8_Demo_GazeFWaveIdleRand_secs(SimStruct
*c1_S);
extern void sf_exported_auto_activate_c20_Demo_GazeFWaveIdleRand_secs(SimStruct *
c1_S);
extern void sf_exported_auto_activate_c11_Demo_GazeFWaveIdleRand_secs(SimStruct *
c1_S);
extern void sf_exported_auto_activate_c9_Demo_GazeFWaveIdleRand_secs(SimStruct
*c1_S);
extern void sf_exported_auto_activate_c4_Demo_GazeFWaveIdleRand_secs(SimStruct
*c1_S);
extern void
sf_exported_auto_incrementTemporalCounter_c10_Demo_GazeFWaveIdleRand_secs
(SimStruct *c1_S);
extern void
sf_exported_auto_incrementTemporalCounter_c5_Demo_GazeFWaveIdleRand_secs
(SimStruct *c1_S);
extern void
sf_exported_auto_incrementTemporalCounter_c8_Demo_GazeFWaveIdleRand_secs
(SimStruct *c1_S);
extern void
sf_exported_auto_incrementTemporalCounter_c20_Demo_GazeFWaveIdleRand_secs
(SimStruct *c1_S);
extern void
sf_exported_auto_incrementTemporalCounter_c11_Demo_GazeFWaveIdleRand_secs
(SimStruct *c1_S);
extern void
sf_exported_auto_incrementTemporalCounter_c9_Demo_GazeFWaveIdleRand_secs
(SimStruct *c1_S);
extern void
sf_exported_auto_incrementTemporalCounter_c4_Demo_GazeFWaveIdleRand_secs
(SimStruct *c1_S);
extern void
sf_exported_auto_resetTemporalCounter_c10_Demo_GazeFWaveIdleRand_secs
(SimStruct *c1_S);
extern void sf_exported_auto_resetTemporalCounter_c5_Demo_GazeFWaveIdleRand_secs
(SimStruct *c1_S);
extern void sf_exported_auto_resetTemporalCounter_c8_Demo_GazeFWaveIdleRand_secs
(SimStruct *c1_S);
extern void
sf_exported_auto_resetTemporalCounter_c20_Demo_GazeFWaveIdleRand_secs
(SimStruct *c1_S);
extern void
sf_exported_auto_resetTemporalCounter_c11_Demo_GazeFWaveIdleRand_secs
(SimStruct *c1_S);
extern void sf_exported_auto_resetTemporalCounter_c9_Demo_GazeFWaveIdleRand_secs
(SimStruct *c1_S);
extern void sf_exported_auto_resetTemporalCounter_c4_Demo_GazeFWaveIdleRand_secs
(SimStruct *c1_S);
extern void sf_exported_auto_deactivate_c10_Demo_GazeFWaveIdleRand_secs
(SimStruct *c1_S);
extern void sf_exported_auto_deactivate_c5_Demo_GazeFWaveIdleRand_secs(SimStruct
*c1_S);
extern void sf_exported_auto_deactivate_c8_Demo_GazeFWaveIdleRand_secs(SimStruct
*c1_S);
extern void sf_exported_auto_deactivate_c20_Demo_GazeFWaveIdleRand_secs
(SimStruct *c1_S);
extern void sf_exported_auto_deactivate_c11_Demo_GazeFWaveIdleRand_secs
(SimStruct *c1_S);
extern void sf_exported_auto_deactivate_c9_Demo_GazeFWaveIdleRand_secs(SimStruct
*c1_S);
extern void sf_exported_auto_deactivate_c4_Demo_GazeFWaveIdleRand_secs(SimStruct
*c1_S);
extern void sf_exported_auto_stepBuffersc10_Demo_GazeFWaveIdleRand(SimStruct
*c1_S);
extern void sf_exported_auto_stepBuffersc5_Demo_GazeFWaveIdleRand(SimStruct
*c1_S);
extern void sf_exported_auto_stepBuffersc8_Demo_GazeFWaveIdleRand(SimStruct
*c1_S);
extern void sf_exported_auto_stepBuffersc20_Demo_GazeFWaveIdleRand(SimStruct
*c1_S);
extern void sf_exported_auto_stepBuffersc11_Demo_GazeFWaveIdleRand(SimStruct
*c1_S);
extern void sf_exported_auto_stepBuffersc9_Demo_GazeFWaveIdleRand(SimStruct
*c1_S);
extern void sf_exported_auto_stepBuffersc4_Demo_GazeFWaveIdleRand(SimStruct
*c1_S);
extern void sf_exported_auto_enterc10_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_duringc10_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_enterc5_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_duringc5_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_enterc8_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_duringc8_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_enterc20_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_duringc20_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_enterc11_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_duringc11_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_enterc9_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_duringc9_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_enterc4_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_duringc4_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_enablec10_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_enablec5_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_enablec8_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_enablec20_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_enablec11_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_enablec9_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_enablec4_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_disablec10_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_disablec5_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_disablec8_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_disablec20_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_disablec11_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_disablec9_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_disablec4_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void
sf_exported_auto_check_state_inconsistency_c10_Demo_GazeFWaveIdleRand
(SimStruct *c1_S);
extern void sf_exported_auto_check_state_inconsistency_c5_Demo_GazeFWaveIdleRand
(SimStruct *c1_S);
extern void sf_exported_auto_check_state_inconsistency_c8_Demo_GazeFWaveIdleRand
(SimStruct *c1_S);
extern void
sf_exported_auto_check_state_inconsistency_c20_Demo_GazeFWaveIdleRand
(SimStruct *c1_S);
extern void
sf_exported_auto_check_state_inconsistency_c11_Demo_GazeFWaveIdleRand
(SimStruct *c1_S);
extern void sf_exported_auto_check_state_inconsistency_c9_Demo_GazeFWaveIdleRand
(SimStruct *c1_S);
extern void sf_exported_auto_check_state_inconsistency_c4_Demo_GazeFWaveIdleRand
(SimStruct *c1_S);
extern const mxArray *sf_exported_auto_getSimstatec10_Demo_GazeFWaveIdleRand
(SimStruct *c1_S);
extern const mxArray *sf_exported_auto_getSimstatec5_Demo_GazeFWaveIdleRand
(SimStruct *c1_S);
extern const mxArray *sf_exported_auto_getSimstatec8_Demo_GazeFWaveIdleRand
(SimStruct *c1_S);
extern const mxArray *sf_exported_auto_getSimstatec20_Demo_GazeFWaveIdleRand
(SimStruct *c1_S);
extern const mxArray *sf_exported_auto_getSimstatec11_Demo_GazeFWaveIdleRand
(SimStruct *c1_S);
extern const mxArray *sf_exported_auto_getSimstatec9_Demo_GazeFWaveIdleRand
(SimStruct *c1_S);
extern const mxArray *sf_exported_auto_getSimstatec4_Demo_GazeFWaveIdleRand
(SimStruct *c1_S);
extern void sf_exported_auto_setSimstatec10_Demo_GazeFWaveIdleRand(SimStruct
*c1_S, const mxArray *c1_input);
extern void sf_exported_auto_setSimstatec5_Demo_GazeFWaveIdleRand(SimStruct
*c1_S, const mxArray *c1_input);
extern void sf_exported_auto_setSimstatec8_Demo_GazeFWaveIdleRand(SimStruct
*c1_S, const mxArray *c1_input);
extern void sf_exported_auto_setSimstatec20_Demo_GazeFWaveIdleRand(SimStruct
*c1_S, const mxArray *c1_input);
extern void sf_exported_auto_setSimstatec11_Demo_GazeFWaveIdleRand(SimStruct
*c1_S, const mxArray *c1_input);
extern void sf_exported_auto_setSimstatec9_Demo_GazeFWaveIdleRand(SimStruct
*c1_S, const mxArray *c1_input);
extern void sf_exported_auto_setSimstatec4_Demo_GazeFWaveIdleRand(SimStruct
*c1_S, const mxArray *c1_input);
extern void sf_exported_auto_initc10_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_initc5_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_initc8_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_initc20_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_initc11_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_initc9_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_initc4_Demo_GazeFWaveIdleRand(SimStruct *c1_S);
extern void sf_exported_auto_initBuffersc10_Demo_GazeFWaveIdleRand(SimStruct
*c1_S);
extern void sf_exported_auto_initBuffersc5_Demo_GazeFWaveIdleRand(SimStruct
*c1_S);
extern void sf_exported_auto_initBuffersc8_Demo_GazeFWaveIdleRand(SimStruct
*c1_S);
extern void sf_exported_auto_initBuffersc20_Demo_GazeFWaveIdleRand(SimStruct
*c1_S);
extern void sf_exported_auto_initBuffersc11_Demo_GazeFWaveIdleRand(SimStruct
*c1_S);
extern void sf_exported_auto_initBuffersc9_Demo_GazeFWaveIdleRand(SimStruct
*c1_S);
extern void sf_exported_auto_initBuffersc4_Demo_GazeFWaveIdleRand(SimStruct
*c1_S);
/* Function Definitions */
extern void sf_c1_Demo_GazeFWaveIdleRand_get_check_sum(mxArray *plhs[]);
extern void c1_Demo_GazeFWaveIdleRand_method_dispatcher(SimStruct *S, int_T
method, void *data);
#endif
| 41.70442 | 93 | 0.837849 |
540cbe162ae7777c50f3795a38844631b75c2c22 | 345 | go | Go | support/module_test.go | appist/appy | 82828f32b1d12a45f9faf1ef2f723ba35609b42c | [
"MIT"
] | 129 | 2018-07-21T15:42:34.000Z | 2022-03-25T09:54:02.000Z | support/module_test.go | appist/appy | 82828f32b1d12a45f9faf1ef2f723ba35609b42c | [
"MIT"
] | 238 | 2018-07-08T07:51:56.000Z | 2022-01-24T06:34:34.000Z | support/module_test.go | appist/appy | 82828f32b1d12a45f9faf1ef2f723ba35609b42c | [
"MIT"
] | 15 | 2019-10-07T09:33:20.000Z | 2022-01-24T09:35:47.000Z | package support
import (
"os"
"testing"
"github.com/appist/appy/test"
)
type moduleSuite struct {
test.Suite
}
func (s *moduleSuite) TestModuleName() {
s.Equal("", ModuleName())
err := os.Chdir("..")
s.Nil(err)
s.Equal("github.com/appist/appy", ModuleName())
}
func TestModuleSuite(t *testing.T) {
test.Run(t, new(moduleSuite))
}
| 13.8 | 48 | 0.666667 |
1666de49837e070bb0f886abfea682baa7347963 | 40,983 | c | C | cups/tls-openssl.c | michaelrsweet/cups | 2c7064f2efa6279f5200b4cee5a047b3e3b8c2d6 | [
"Apache-2.0"
] | null | null | null | cups/tls-openssl.c | michaelrsweet/cups | 2c7064f2efa6279f5200b4cee5a047b3e3b8c2d6 | [
"Apache-2.0"
] | null | null | null | cups/tls-openssl.c | michaelrsweet/cups | 2c7064f2efa6279f5200b4cee5a047b3e3b8c2d6 | [
"Apache-2.0"
] | null | null | null | /*
* TLS support code for CUPS using OpenSSL/LibreSSL.
*
* Copyright © 2020-2022 by OpenPrinting
* Copyright © 2007-2019 by Apple Inc.
* Copyright © 1997-2007 by Easy Software Products, all rights reserved.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
*/
/**** This file is included from tls.c ****/
/*
* Include necessary headers...
*/
#include <sys/stat.h>
#include <openssl/x509v3.h>
/*
* Local functions...
*/
static long http_bio_ctrl(BIO *h, int cmd, long arg1, void *arg2);
static int http_bio_free(BIO *data);
static int http_bio_new(BIO *h);
static int http_bio_puts(BIO *h, const char *str);
static int http_bio_read(BIO *h, char *buf, int size);
static int http_bio_write(BIO *h, const char *buf, int num);
static X509 *http_create_credential(http_credential_t *credential);
static const char *http_default_path(char *buffer, size_t bufsize);
static time_t http_get_date(X509 *cert, int which);
//static void http_load_crl(void);
static const char *http_make_path(char *buffer, size_t bufsize, const char *dirname, const char *filename, const char *ext);
static void http_x509_add_san(X509 *cert, const char *name);
/*
* Local globals...
*/
static int tls_auto_create = 0;
/* Auto-create self-signed certs? */
static BIO_METHOD *tls_bio_method = NULL;
/* OpenSSL BIO method */
static char *tls_common_name = NULL;
/* Default common name */
//static X509_CRL *tls_crl = NULL;/* Certificate revocation list */
static char *tls_keypath = NULL;
/* Server cert keychain path */
static cups_mutex_t tls_mutex = CUPS_MUTEX_INITIALIZER;
/* Mutex for keychain/certs */
static int tls_options = -1,/* Options for TLS connections */
tls_min_version = _HTTP_TLS_1_0,
tls_max_version = _HTTP_TLS_MAX;
/*
* 'cupsMakeServerCredentials()' - Make a self-signed certificate and private key pair.
*/
int // O - 1 on success, 0 on failure
cupsMakeServerCredentials(
const char *path, // I - Path to keychain/directory
const char *common_name, // I - Common name
int num_alt_names, // I - Number of subject alternate names
const char **alt_names, // I - Subject Alternate Names
time_t expiration_date) // I - Expiration date
{
int result = 0; // Return value
EVP_PKEY *pkey; // Private key
RSA *rsa; // RSA key pair
X509 *cert; // Certificate
cups_lang_t *language; // Default language info
time_t curtime; // Current time
X509_NAME *name; // Subject/issuer name
BIO *bio; // Output file
char temp[1024], // Temporary directory name
crtfile[1024], // Certificate filename
keyfile[1024]; // Private key filename
const char *common_ptr; // Pointer into common name
DEBUG_printf(("cupsMakeServerCredentials(path=\"%s\", common_name=\"%s\", num_alt_names=%d, alt_names=%p, expiration_date=%d)", path, common_name, num_alt_names, alt_names, (int)expiration_date));
// Filenames...
if (!path)
path = http_default_path(temp, sizeof(temp));
if (!path || !common_name)
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
return (0);
}
http_make_path(crtfile, sizeof(crtfile), path, common_name, "crt");
http_make_path(keyfile, sizeof(keyfile), path, common_name, "key");
// Create the encryption key...
DEBUG_puts("1cupsMakeServerCredentials: Creating key pair.");
if ((rsa = RSA_generate_key(2048, RSA_F4, NULL, NULL)) == NULL)
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to create key pair."), 1);
return (0);
}
if ((pkey = EVP_PKEY_new()) == NULL)
{
RSA_free(rsa);
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to create private key."), 1);
return (0);
}
EVP_PKEY_assign_RSA(pkey, rsa);
DEBUG_puts("1cupsMakeServerCredentials: Key pair created.");
// Create the X.509 certificate...
DEBUG_puts("1cupsMakeServerCredentials: Generating self-signed X.509 certificate.");
if ((cert = X509_new()) == NULL)
{
EVP_PKEY_free(pkey);
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to create X.509 certificate."), 1);
return (0);
}
curtime = time(NULL);
language = cupsLangDefault();
ASN1_TIME_set(X509_get_notBefore(cert), curtime);
ASN1_TIME_set(X509_get_notAfter(cert), expiration_date);
ASN1_INTEGER_set(X509_get_serialNumber(cert), (int)curtime);
X509_set_pubkey(cert, pkey);
name = X509_get_subject_name(cert);
if (strlen(language->language) == 5)
X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC, (unsigned char *)language->language + 3, -1, -1, 0);
else
X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC, (unsigned char *)"US", -1, -1, 0);
X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC, (unsigned char *)"Unknown", -1, -1, 0);
X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, (unsigned char *)common_name, -1, -1, 0);
X509_set_issuer_name(cert, name);
http_x509_add_san(cert, common_name);
if ((common_ptr = strstr(common_name, ".local")) == NULL)
{
// Add common_name.local to the list, too...
char localname[256], // hostname.local
*localptr; // Pointer into localname
strlcpy(localname, common_name, sizeof(localname));
if ((localptr = strchr(localname, '.')) != NULL)
*localptr = '\0';
strlcat(localname, ".local", sizeof(localname));
http_x509_add_san(cert, localname);
}
if (num_alt_names > 0)
{
int i; // Looping var...
for (i = 0; i < num_alt_names; i ++)
{
if (strcmp(alt_names[i], "localhost"))
http_x509_add_san(cert, alt_names[i]);
}
}
X509_sign(cert, pkey, EVP_sha256());
// Save them...
if ((bio = BIO_new_file(keyfile, "wb")) == NULL)
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
goto done;
}
if (!PEM_write_bio_PrivateKey(bio, pkey, NULL, NULL, 0, NULL, NULL))
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to write private key."), 1);
BIO_free(bio);
goto done;
}
BIO_free(bio);
if ((bio = BIO_new_file(crtfile, "wb")) == NULL)
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
goto done;
}
if (!PEM_write_bio_X509(bio, cert))
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to write X.509 certificate."), 1);
BIO_free(bio);
goto done;
}
BIO_free(bio);
result = 1;
DEBUG_puts("1cupsMakeServerCredentials: Successfully created credentials.");
// Cleanup...
done:
X509_free(cert);
EVP_PKEY_free(pkey);
return (result);
}
/*
* 'cupsSetServerCredentials()' - Set the default server credentials.
*
* Note: The server credentials are used by all threads in the running process.
* This function is threadsafe.
*/
int // O - 1 on success, 0 on failure
cupsSetServerCredentials(
const char *path, // I - Path to keychain/directory
const char *common_name, // I - Default common name for server
int auto_create) // I - 1 = automatically create self-signed certificates
{
char temp[1024]; // Default path buffer
DEBUG_printf(("cupsSetServerCredentials(path=\"%s\", common_name=\"%s\", auto_create=%d)", path, common_name, auto_create));
/*
* Use defaults as needed...
*/
if (!path)
path = http_default_path(temp, sizeof(temp));
/*
* Range check input...
*/
if (!path || !common_name)
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
return (0);
}
cupsMutexLock(&tls_mutex);
/*
* Free old values...
*/
if (tls_keypath)
_cupsStrFree(tls_keypath);
if (tls_common_name)
_cupsStrFree(tls_common_name);
/*
* Save the new values...
*/
tls_keypath = _cupsStrAlloc(path);
tls_auto_create = auto_create;
tls_common_name = _cupsStrAlloc(common_name);
cupsMutexUnlock(&tls_mutex);
return (1);
}
/*
* 'httpCopyCredentials()' - Copy the credentials associated with the peer in
* an encrypted connection.
*/
int // O - Status of call (0 = success)
httpCopyCredentials(
http_t *http, // I - Connection to server
cups_array_t **credentials) // O - Array of credentials
{
STACK_OF(X509) *chain; // Certificate chain
DEBUG_printf(("httpCopyCredentials(http=%p, credentials=%p)", http, credentials));
if (credentials)
*credentials = NULL;
if (!http || !http->tls || !credentials)
return (-1);
*credentials = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL);
chain = SSL_get_peer_cert_chain(http->tls);
DEBUG_printf(("1httpCopyCredentials: chain=%p", chain));
if (chain)
{
int i, // Looping var
count; // Number of certs
for (i = 0, count = sk_X509_num(chain); i < count; i ++)
{
X509 *cert = sk_X509_value(chain, i);
// Current certificate
BIO *bio = BIO_new(BIO_s_mem());
// Memory buffer for cert
if (bio)
{
long bytes; // Number of bytes
char *buffer; // Pointer to bytes
if (PEM_write_bio_X509(bio, cert))
{
bytes = BIO_get_mem_data(bio, &buffer);
httpAddCredential(*credentials, buffer, (int)bytes);
}
BIO_free(bio);
}
}
}
return (0);
}
/*
* '_httpCreateCredentials()' - Create credentials in the internal format.
*/
http_tls_credentials_t // O - Internal credentials
_httpCreateCredentials(
cups_array_t *credentials) // I - Array of credentials
{
(void)credentials;
return (NULL);
}
/*
* '_httpFreeCredentials()' - Free internal credentials.
*/
void
_httpFreeCredentials(
http_tls_credentials_t credentials) // I - Internal credentials
{
X509_free(credentials);
}
/*
* 'httpCredentialsAreValidForName()' - Return whether the credentials are valid for the given name.
*/
int // O - 1 if valid, 0 otherwise
httpCredentialsAreValidForName(
cups_array_t *credentials, // I - Credentials
const char *common_name) // I - Name to check
{
X509 *cert; // Certificate
int result = 0; // Result
cert = http_create_credential((http_credential_t *)cupsArrayGetFirst(credentials));
if (cert)
{
result = X509_check_host(cert, common_name, strlen(common_name), 0, NULL);
X509_free(cert);
}
return (result);
}
/*
* 'httpCredentialsGetTrust()' - Return the trust of credentials.
*/
http_trust_t // O - Level of trust
httpCredentialsGetTrust(
cups_array_t *credentials, // I - Credentials
const char *common_name) // I - Common name for trust lookup
{
http_trust_t trust = HTTP_TRUST_OK; // Trusted?
X509 *cert; // Certificate
cups_array_t *tcreds = NULL; // Trusted credentials
_cups_globals_t *cg = _cupsGlobals(); // Per-thread globals
if (!common_name)
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("No common name specified."), 1);
return (HTTP_TRUST_UNKNOWN);
}
if ((cert = http_create_credential((http_credential_t *)cupsArrayGetFirst(credentials))) == NULL)
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to create credentials from array."), 1);
return (HTTP_TRUST_UNKNOWN);
}
if (cg->any_root < 0)
{
_cupsSetDefaults();
// http_load_crl();
}
// Look this common name up in the default keychains...
httpLoadCredentials(NULL, &tcreds, common_name);
if (tcreds)
{
char credentials_str[1024], /* String for incoming credentials */
tcreds_str[1024]; /* String for saved credentials */
httpCredentialsString(credentials, credentials_str, sizeof(credentials_str));
httpCredentialsString(tcreds, tcreds_str, sizeof(tcreds_str));
if (strcmp(credentials_str, tcreds_str))
{
// Credentials don't match, let's look at the expiration date of the new
// credentials and allow if the new ones have a later expiration...
if (!cg->trust_first)
{
// Do not trust certificates on first use...
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Trust on first use is disabled."), 1);
trust = HTTP_TRUST_INVALID;
}
else if (httpCredentialsGetExpiration(credentials) <= httpCredentialsGetExpiration(tcreds))
{
// The new credentials are not newly issued...
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("New credentials are older than stored credentials."), 1);
trust = HTTP_TRUST_INVALID;
}
else if (!httpCredentialsAreValidForName(credentials, common_name))
{
// The common name does not match the issued certificate...
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("New credentials are not valid for name."), 1);
trust = HTTP_TRUST_INVALID;
}
else if (httpCredentialsGetExpiration(tcreds) < time(NULL))
{
// Save the renewed credentials...
trust = HTTP_TRUST_RENEWED;
httpSaveCredentials(NULL, credentials, common_name);
}
}
httpFreeCredentials(tcreds);
}
else if (cg->validate_certs && !httpCredentialsAreValidForName(credentials, common_name))
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("No stored credentials, not valid for name."), 1);
trust = HTTP_TRUST_INVALID;
}
else if (!cg->trust_first)
{
// See if we have a site CA certificate we can compare...
if (!httpLoadCredentials(NULL, &tcreds, "site"))
{
if (cupsArrayGetCount(credentials) != (cupsArrayGetCount(tcreds) + 1))
{
// Certificate isn't directly generated from the CA cert...
trust = HTTP_TRUST_INVALID;
}
else
{
// Do a tail comparison of the two certificates...
http_credential_t *a, *b; // Certificates
for (a = (http_credential_t *)cupsArrayGetFirst(tcreds), b = (http_credential_t *)cupsArrayGetElement(credentials, 1); a && b; a = (http_credential_t *)cupsArrayGetNext(tcreds), b = (http_credential_t *)cupsArrayGetNext(credentials))
{
if (a->datalen != b->datalen || memcmp(a->data, b->data, a->datalen))
break;
}
if (a || b)
trust = HTTP_TRUST_INVALID;
}
if (trust != HTTP_TRUST_OK)
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Credentials do not validate against site CA certificate."), 1);
}
else
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Trust on first use is disabled."), 1);
trust = HTTP_TRUST_INVALID;
}
}
if (trust == HTTP_TRUST_OK && !cg->expired_certs)
{
time_t curtime; // Current date/time
time(&curtime);
if (curtime < http_get_date(cert, 0) || curtime > http_get_date(cert, 1))
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Credentials have expired."), 1);
trust = HTTP_TRUST_EXPIRED;
}
}
if (trust == HTTP_TRUST_OK && !cg->any_root && cupsArrayGetCount(credentials) == 1)
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Self-signed credentials are blocked."), 1);
trust = HTTP_TRUST_INVALID;
}
X509_free(cert);
return (trust);
}
/*
* 'httpCredentialsGetExpiration()' - Return the expiration date of the credentials.
*/
time_t // O - Expiration date of credentials
httpCredentialsGetExpiration(
cups_array_t *credentials) // I - Credentials
{
time_t result = 0; // Result
X509 *cert; // Certificate
if ((cert = http_create_credential((http_credential_t *)cupsArrayGetFirst(credentials))) != NULL)
{
result = http_get_date(cert, 1);
X509_free(cert);
}
return (result);
}
/*
* 'httpCredentialsString()' - Return a string representing the credentials.
*/
size_t // O - Total size of credentials string
httpCredentialsString(
cups_array_t *credentials, // I - Credentials
char *buffer, // I - Buffer
size_t bufsize) // I - Size of buffer
{
http_credential_t *first; // First certificate
X509 *cert; // Certificate
DEBUG_printf(("httpCredentialsString(credentials=%p, buffer=%p, bufsize=" CUPS_LLFMT ")", credentials, buffer, CUPS_LLCAST bufsize));
if (!buffer)
return (0);
if (bufsize > 0)
*buffer = '\0';
first = (http_credential_t *)cupsArrayGetFirst(credentials);
cert = http_create_credential(first);
if (cert)
{
char name[256], // Common name associated with cert
issuer[256], // Issuer associated with cert
expdate[256]; // Expiration data as string
time_t expiration; // Expiration date of cert
const char *sigalg; // Signature algorithm
unsigned char md5_digest[16]; // MD5 result
X509_NAME_get_text_by_NID(X509_get_subject_name(cert), NID_commonName, name, sizeof(name));
X509_NAME_get_text_by_NID(X509_get_issuer_name(cert), NID_commonName, issuer, sizeof(issuer));
expiration = http_get_date(cert, 1);
switch (X509_get_signature_nid(cert))
{
case NID_ecdsa_with_SHA1 :
sigalg = "SHA1WithECDSAEncryption";
break;
case NID_ecdsa_with_SHA224 :
sigalg = "SHA224WithECDSAEncryption";
break;
case NID_ecdsa_with_SHA256 :
sigalg = "SHA256WithECDSAEncryption";
break;
case NID_ecdsa_with_SHA384 :
sigalg = "SHA384WithECDSAEncryption";
break;
case NID_ecdsa_with_SHA512 :
sigalg = "SHA512WithECDSAEncryption";
break;
case NID_sha1WithRSAEncryption :
sigalg = "SHA1WithRSAEncryption";
break;
case NID_sha224WithRSAEncryption :
sigalg = "SHA224WithRSAEncryption";
break;
case NID_sha256WithRSAEncryption :
sigalg = "SHA256WithRSAEncryption";
break;
case NID_sha384WithRSAEncryption :
sigalg = "SHA384WithRSAEncryption";
break;
case NID_sha512WithRSAEncryption :
sigalg = "SHA512WithRSAEncryption";
break;
default :
sigalg = "Unknown";
break;
}
cupsHashData("md5", first->data, first->datalen, md5_digest, sizeof(md5_digest));
snprintf(buffer, bufsize, "%s (issued by %s) / %s / %s / %02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", name, issuer, httpGetDateString(expiration, expdate, sizeof(expdate)), sigalg, md5_digest[0], md5_digest[1], md5_digest[2], md5_digest[3], md5_digest[4], md5_digest[5], md5_digest[6], md5_digest[7], md5_digest[8], md5_digest[9], md5_digest[10], md5_digest[11], md5_digest[12], md5_digest[13], md5_digest[14], md5_digest[15]);
X509_free(cert);
}
DEBUG_printf(("1httpCredentialsString: Returning \"%s\".", buffer));
return (strlen(buffer));
}
/*
* 'httpLoadCredentials()' - Load X.509 credentials from a keychain file.
*/
int // O - 0 on success, -1 on error
httpLoadCredentials(
const char *path, // I - Keychain/PKCS#12 path
cups_array_t **credentials, // IO - Credentials
const char *common_name) // I - Common name for credentials
{
cups_file_t *fp; // Certificate file
char filename[1024], // filename.crt
temp[1024], // Temporary string
line[256]; // Base64-encoded line
unsigned char *data = NULL; // Buffer for cert data
size_t alloc_data = 0, // Bytes allocated
num_data = 0, // Bytes used
decoded; // Bytes decoded
int in_certificate = 0;
// In a certificate?
if (!credentials || !common_name)
return (-1);
if (!path)
path = http_default_path(temp, sizeof(temp));
if (!path)
return (-1);
http_make_path(filename, sizeof(filename), path, common_name, "crt");
if ((fp = cupsFileOpen(filename, "r")) == NULL)
return (-1);
while (cupsFileGets(fp, line, sizeof(line)))
{
if (!strcmp(line, "-----BEGIN CERTIFICATE-----"))
{
if (in_certificate)
{
/*
* Missing END CERTIFICATE...
*/
httpFreeCredentials(*credentials);
*credentials = NULL;
break;
}
in_certificate = 1;
}
else if (!strcmp(line, "-----END CERTIFICATE-----"))
{
if (!in_certificate || !num_data)
{
/*
* Missing data...
*/
httpFreeCredentials(*credentials);
*credentials = NULL;
break;
}
if (!*credentials)
*credentials = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL);
if (httpAddCredential(*credentials, data, num_data))
{
httpFreeCredentials(*credentials);
*credentials = NULL;
break;
}
num_data = 0;
in_certificate = 0;
}
else if (in_certificate)
{
if (alloc_data == 0)
{
data = malloc(2048);
alloc_data = 2048;
if (!data)
break;
}
else if ((num_data + strlen(line)) >= alloc_data)
{
unsigned char *tdata = realloc(data, alloc_data + 1024);
/* Expanded buffer */
if (!tdata)
{
httpFreeCredentials(*credentials);
*credentials = NULL;
break;
}
data = tdata;
alloc_data += 1024;
}
decoded = alloc_data - num_data;
httpDecode64((char *)data + num_data, &decoded, line);
num_data += (size_t)decoded;
}
}
cupsFileClose(fp);
if (in_certificate)
{
/*
* Missing END CERTIFICATE...
*/
httpFreeCredentials(*credentials);
*credentials = NULL;
}
if (data)
free(data);
return (*credentials ? 0 : -1);
}
/*
* 'httpSaveCredentials()' - Save X.509 credentials to a keychain file.
*/
int // O - -1 on error, 0 on success
httpSaveCredentials(
const char *path, // I - Keychain/PKCS#12 path
cups_array_t *credentials, // I - Credentials
const char *common_name) // I - Common name for credentials
{
cups_file_t *fp; // Certificate file
char filename[1024], // filename.crt
nfilename[1024],// filename.crt.N
temp[1024], // Temporary string
line[256]; // Base64-encoded line
const unsigned char *ptr; // Pointer into certificate
ssize_t remaining; // Bytes left
http_credential_t *cred; // Current credential
if (!credentials || !common_name)
return (-1);
if (!path)
path = http_default_path(temp, sizeof(temp));
if (!path)
return (-1);
http_make_path(filename, sizeof(filename), path, common_name, "crt");
snprintf(nfilename, sizeof(nfilename), "%s.N", filename);
if ((fp = cupsFileOpen(nfilename, "w")) == NULL)
return (-1);
#ifndef _WIN32
fchmod(cupsFileNumber(fp), 0600);
#endif // !_WIN32
for (cred = (http_credential_t *)cupsArrayGetFirst(credentials);
cred;
cred = (http_credential_t *)cupsArrayGetNext(credentials))
{
cupsFilePuts(fp, "-----BEGIN CERTIFICATE-----\n");
for (ptr = cred->data, remaining = (ssize_t)cred->datalen; remaining > 0; remaining -= 45, ptr += 45)
{
httpEncode64(line, sizeof(line), (char *)ptr, remaining > 45 ? 45 : remaining);
cupsFilePrintf(fp, "%s\n", line);
}
cupsFilePuts(fp, "-----END CERTIFICATE-----\n");
}
cupsFileClose(fp);
return (rename(nfilename, filename));
}
/*
* '_httpTLSInitialize()' - Initialize the TLS stack.
*/
void
_httpTLSInitialize(void)
{
// OpenSSL no longer requires explicit initialization...
}
/*
* '_httpTLSPending()' - Return the number of pending TLS-encrypted bytes.
*/
size_t // O - Bytes available
_httpTLSPending(http_t *http) // I - HTTP connection
{
return ((size_t)SSL_pending(http->tls));
}
/*
* '_httpTLSRead()' - Read from a SSL/TLS connection.
*/
int // O - Bytes read
_httpTLSRead(http_t *http, // I - Connection to server
char *buf, // I - Buffer to store data
int len) // I - Length of buffer
{
return (SSL_read((SSL *)(http->tls), buf, len));
}
/*
* '_httpTLSSetOptions()' - Set TLS protocol and cipher suite options.
*/
void
_httpTLSSetOptions(int options, // I - Options
int min_version, // I - Minimum TLS version
int max_version) // I - Maximum TLS version
{
if (!(options & _HTTP_TLS_SET_DEFAULT) || tls_options < 0)
{
tls_options = options;
tls_min_version = min_version;
tls_max_version = max_version;
}
}
/*
* '_httpTLSStart()' - Set up SSL/TLS support on a connection.
*/
int // O - 0 on success, -1 on failure
_httpTLSStart(http_t *http) // I - Connection to server
{
BIO *bio; // Basic input/output context
SSL_CTX *context; // Encryption context
char hostname[256], // Hostname
cipherlist[256]; // List of cipher suites
unsigned long error; // Error code, if any
static const int versions[] = // SSL/TLS versions
{
TLS1_VERSION, // No more SSL support in OpenSSL
TLS1_VERSION, // TLS/1.0
TLS1_1_VERSION, // TLS/1.1
TLS1_2_VERSION, // TLS/1.2
#ifdef TLS1_3_VERSION
TLS1_3_VERSION, // TLS/1.3
TLS1_3_VERSION // TLS/1.3 (max)
#else
TLS1_2_VERSION, // TLS/1.2
TLS1_2_VERSION // TLS/1.2 (max)
#endif // TLS1_3_VERSION
};
DEBUG_printf(("3_httpTLSStart(http=%p)", http));
if (tls_options < 0)
{
DEBUG_puts("4_httpTLSStart: Setting defaults.");
_cupsSetDefaults();
DEBUG_printf(("4_httpTLSStart: tls_options=%x", tls_options));
}
if (http->mode == _HTTP_MODE_SERVER && !tls_keypath)
{
DEBUG_puts("4_httpTLSStart: cupsSetServerCredentials not called.");
http->error = errno = EINVAL;
http->status = HTTP_STATUS_ERROR;
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Server credentials not set."), 1);
return (-1);
}
if (http->mode == _HTTP_MODE_CLIENT)
{
// Negotiate a TLS connection as a client...
context = SSL_CTX_new(TLS_client_method());
}
else
{
// Negotiate a TLS connection as a server
char crtfile[1024], // Certificate file
keyfile[1024]; // Private key file
const char *cn, // Common name to lookup
*cnptr; // Pointer into common name
int have_creds = 0; // Have credentials?
context = SSL_CTX_new(TLS_server_method());
// Find the TLS certificate...
if (http->fields[HTTP_FIELD_HOST])
{
// Use hostname for TLS upgrade...
strlcpy(hostname, http->fields[HTTP_FIELD_HOST], sizeof(hostname));
}
else
{
// Resolve hostname from connection address...
http_addr_t addr; // Connection address
socklen_t addrlen; // Length of address
addrlen = sizeof(addr);
if (getsockname(http->fd, (struct sockaddr *)&addr, &addrlen))
{
// Unable to get local socket address so use default...
DEBUG_printf(("4_httpTLSStart: Unable to get socket address: %s", strerror(errno)));
hostname[0] = '\0';
}
else if (httpAddrLocalhost(&addr))
{
// Local access top use default...
hostname[0] = '\0';
}
else
{
// Lookup the socket address...
httpAddrLookup(&addr, hostname, sizeof(hostname));
DEBUG_printf(("4_httpTLSStart: Resolved socket address to \"%s\".", hostname));
}
}
if (isdigit(hostname[0] & 255) || hostname[0] == '[')
hostname[0] = '\0'; // Don't allow numeric addresses
if (hostname[0])
cn = hostname;
else
cn = tls_common_name;
if (cn)
{
// First look in the CUPS keystore...
http_make_path(crtfile, sizeof(crtfile), tls_keypath, cn, "crt");
http_make_path(keyfile, sizeof(keyfile), tls_keypath, cn, "key");
if (access(crtfile, R_OK) || access(keyfile, R_OK))
{
// No CUPS-managed certs, look for CA certs...
char cacrtfile[1024], cakeyfile[1024]; // CA cert files
snprintf(cacrtfile, sizeof(cacrtfile), "/etc/letsencrypt/live/%s/fullchain.pem", cn);
snprintf(cakeyfile, sizeof(cakeyfile), "/etc/letsencrypt/live/%s/privkey.pem", cn);
if ((access(cacrtfile, R_OK) || access(cakeyfile, R_OK)) && (cnptr = strchr(cn, '.')) != NULL)
{
// Try just domain name...
cnptr ++;
if (strchr(cnptr, '.'))
{
snprintf(cacrtfile, sizeof(cacrtfile), "/etc/letsencrypt/live/%s/fullchain.pem", cnptr);
snprintf(cakeyfile, sizeof(cakeyfile), "/etc/letsencrypt/live/%s/privkey.pem", cnptr);
}
}
if (!access(cacrtfile, R_OK) && !access(cakeyfile, R_OK))
{
// Use the CA certs...
strlcpy(crtfile, cacrtfile, sizeof(crtfile));
strlcpy(keyfile, cakeyfile, sizeof(keyfile));
}
}
have_creds = !access(crtfile, R_OK) && !access(keyfile, R_OK);
}
if (!have_creds && tls_auto_create && cn)
{
DEBUG_printf(("4_httpTLSStart: Auto-create credentials for \"%s\".", cn));
if (!cupsMakeServerCredentials(tls_keypath, cn, 0, NULL, time(NULL) + 365 * 86400))
{
DEBUG_puts("4_httpTLSStart: cupsMakeServerCredentials failed.");
http->error = errno = EINVAL;
http->status = HTTP_STATUS_ERROR;
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to create server credentials."), 1);
SSL_CTX_free(context);
return (-1);
}
}
SSL_CTX_use_PrivateKey_file(context, keyfile, SSL_FILETYPE_PEM);
SSL_CTX_use_certificate_file(context, crtfile, SSL_FILETYPE_PEM);
}
// Set TLS options...
strlcpy(cipherlist, "HIGH:!DH:+DHE", sizeof(cipherlist));
if ((tls_options & _HTTP_TLS_ALLOW_RC4) && http->mode == _HTTP_MODE_CLIENT)
strlcat(cipherlist, ":+RC4", sizeof(cipherlist));
else
strlcat(cipherlist, ":!RC4", sizeof(cipherlist));
if (tls_options & _HTTP_TLS_DENY_CBC)
strlcat(cipherlist, ":!SHA1:!SHA256:!SHA384", sizeof(cipherlist));
strlcat(cipherlist, ":@STRENGTH", sizeof(cipherlist));
SSL_CTX_set_min_proto_version(context, versions[tls_min_version]);
SSL_CTX_set_max_proto_version(context, versions[tls_max_version]);
SSL_CTX_set_cipher_list(context, cipherlist);
// Setup a TLS session
cupsMutexLock(&tls_mutex);
if (!tls_bio_method)
{
tls_bio_method = BIO_meth_new(BIO_get_new_index(), "http");
BIO_meth_set_ctrl(tls_bio_method, http_bio_ctrl);
BIO_meth_set_create(tls_bio_method, http_bio_new);
BIO_meth_set_destroy(tls_bio_method, http_bio_free);
BIO_meth_set_read(tls_bio_method, http_bio_read);
BIO_meth_set_puts(tls_bio_method, http_bio_puts);
BIO_meth_set_write(tls_bio_method, http_bio_write);
}
cupsMutexUnlock(&tls_mutex);
bio = BIO_new(tls_bio_method);
BIO_ctrl(bio, BIO_C_SET_FILE_PTR, 0, (char *)http);
http->tls = SSL_new(context);
SSL_set_bio(http->tls, bio, bio);
if (http->mode == _HTTP_MODE_CLIENT)
{
// Negotiate as a server...
if (SSL_connect(http->tls) < 1)
{
// Failed
if ((error = ERR_get_error()) != 0)
_cupsSetError(IPP_STATUS_ERROR_CUPS_PKI, ERR_error_string(error, NULL), 0);
http->status = HTTP_STATUS_ERROR;
http->error = EPIPE;
SSL_CTX_free(context);
SSL_free(http->tls);
http->tls = NULL;
return (-1);
}
}
else
{
// Negotiate as a server...
if (SSL_accept(http->tls) < 1)
{
// Failed
if ((error = ERR_get_error()) != 0)
_cupsSetError(IPP_STATUS_ERROR_CUPS_PKI, ERR_error_string(error, NULL), 0);
http->status = HTTP_STATUS_ERROR;
http->error = EPIPE;
SSL_CTX_free(context);
SSL_free(http->tls);
http->tls = NULL;
return (-1);
}
}
return (0);
}
/*
* '_httpTLSStop()' - Shut down SSL/TLS on a connection.
*/
void
_httpTLSStop(http_t *http) // I - Connection to server
{
SSL_CTX *context; // Context for encryption
context = SSL_get_SSL_CTX(http->tls);
SSL_shutdown(http->tls);
SSL_CTX_free(context);
SSL_free(http->tls);
}
/*
* '_httpTLSWrite()' - Write to a SSL/TLS connection.
*/
int // O - Bytes written
_httpTLSWrite(http_t *http, // I - Connection to server
const char *buf, // I - Buffer holding data
int len) // I - Length of buffer
{
return (SSL_write(http->tls, buf, len));
}
/*
* 'http_bio_ctrl()' - Control the HTTP connection.
*/
static long // O - Result/data
http_bio_ctrl(BIO *h, // I - BIO data
int cmd, // I - Control command
long arg1, // I - First argument
void *arg2) // I - Second argument
{
switch (cmd)
{
default :
return (0);
case BIO_CTRL_RESET :
BIO_set_data(h, NULL);
return (0);
case BIO_C_SET_FILE_PTR :
BIO_set_data(h, arg2);
BIO_set_init(h, 1);
return (1);
case BIO_C_GET_FILE_PTR :
if (arg2)
{
*((void **)arg2) = BIO_get_data(h);
return (1);
}
else
return (0);
case BIO_CTRL_DUP :
case BIO_CTRL_FLUSH :
return (1);
}
}
/*
* 'http_bio_free()' - Free OpenSSL data.
*/
static int // O - 1 on success, 0 on failure
http_bio_free(BIO *h) // I - BIO data
{
if (!h)
return (0);
if (BIO_get_shutdown(h))
BIO_set_init(h, 0);
return (1);
}
/*
* 'http_bio_new()' - Initialize an OpenSSL BIO structure.
*/
static int // O - 1 on success, 0 on failure
http_bio_new(BIO *h) // I - BIO data
{
if (!h)
return (0);
BIO_set_init(h, 0);
BIO_set_data(h, NULL);
return (1);
}
/*
* 'http_bio_puts()' - Send a string for OpenSSL.
*/
static int // O - Bytes written
http_bio_puts(BIO *h, // I - BIO data
const char *str) // I - String to write
{
#ifdef WIN32
return (send(((http_t *)BIO_get_data(h))->fd, str, (int)strlen(str), 0));
#else
return ((int)send(((http_t *)BIO_get_data(h))->fd, str, strlen(str), 0));
#endif // WIN32
}
/*
* 'http_bio_read()' - Read data for OpenSSL.
*/
static int // O - Bytes read
http_bio_read(BIO *h, // I - BIO data
char *buf, // I - Buffer
int size) // I - Number of bytes to read
{
http_t *http; // HTTP connection
http = (http_t *)BIO_get_data(h);
if (!http->blocking)
{
/*
* Make sure we have data before we read...
*/
if (!_httpWait(http, 10000, 0))
{
#ifdef WIN32
http->error = WSAETIMEDOUT;
#else
http->error = ETIMEDOUT;
#endif // WIN32
return (-1);
}
}
return ((int)recv(http->fd, buf, (size_t)size, 0));
}
/*
* 'http_bio_write()' - Write data for OpenSSL.
*/
static int // O - Bytes written
http_bio_write(BIO *h, // I - BIO data
const char *buf, // I - Buffer to write
int num) // I - Number of bytes to write
{
return (send(((http_t *)BIO_get_data(h))->fd, buf, num, 0));
}
/*
* 'http_create_credential()' - Create a single credential in the internal format.
*/
static X509 * // O - Certificate
http_create_credential(
http_credential_t *credential) // I - Credential
{
X509 *cert = NULL; // Certificate
BIO *bio; // Basic I/O for string
if (!credential)
return (NULL);
if ((bio = BIO_new_mem_buf(credential->data, credential->datalen)) == NULL)
return (NULL);
PEM_read_bio_X509(bio, &cert, NULL, (void *)"");
BIO_free(bio);
return (cert);
}
/*
* 'http_default_path()' - Get the default credential store path.
*/
static const char * // O - Path or NULL on error
http_default_path(
char *buffer, // I - Path buffer
size_t bufsize) // I - Size of path buffer
{
_cups_globals_t *cg = _cupsGlobals();
// Pointer to library globals
#ifdef _WIN32
if (cg->home)
#else
if (cg->home && getuid())
#endif // _WIN32
{
snprintf(buffer, bufsize, "%s/.cups", cg->home);
if (access(buffer, 0))
{
DEBUG_printf(("1http_default_path: Making directory \"%s\".", buffer));
if (mkdir(buffer, 0700))
{
DEBUG_printf(("1http_default_path: Failed to make directory: %s", strerror(errno)));
return (NULL);
}
}
snprintf(buffer, bufsize, "%s/.cups/ssl", cg->home);
if (access(buffer, 0))
{
DEBUG_printf(("1http_default_path: Making directory \"%s\".", buffer));
if (mkdir(buffer, 0700))
{
DEBUG_printf(("1http_default_path: Failed to make directory: %s", strerror(errno)));
return (NULL);
}
}
}
else
strlcpy(buffer, CUPS_SERVERROOT "/ssl", bufsize);
DEBUG_printf(("1http_default_path: Using default path \"%s\".", buffer));
return (buffer);
}
//
// 'http_get_date()' - Get the notBefore or notAfter date of a certificate.
//
static time_t // O - UNIX time in seconds
http_get_date(X509 *cert, // I - Certificate
int which) // I - 0 for notBefore, 1 for notAfter
{
unsigned char *expiration; // Expiration date of cert
struct tm exptm; // Expiration date components
if (which)
ASN1_STRING_to_UTF8(&expiration, X509_get0_notAfter(cert));
else
ASN1_STRING_to_UTF8(&expiration, X509_get0_notBefore(cert));
memset(&exptm, 0, sizeof(exptm));
if (strlen((char *)expiration) > 13)
{
// 4-digit year
exptm.tm_year = (expiration[0] - '0') * 1000 + (expiration[1] - '0') * 100 + (expiration[2] - '0') * 10 + expiration[3] - '0' - 1900;
exptm.tm_mon = (expiration[4] - '0') * 10 + expiration[5] - '0' - 1;
exptm.tm_mday = (expiration[6] - '0') * 10 + expiration[7] - '0';
exptm.tm_hour = (expiration[8] - '0') * 10 + expiration[9] - '0';
exptm.tm_min = (expiration[10] - '0') * 10 + expiration[11] - '0';
exptm.tm_sec = (expiration[12] - '0') * 10 + expiration[13] - '0';
}
else
{
// 2-digit year
exptm.tm_year = 100 + (expiration[0] - '0') * 10 + expiration[1] - '0';
exptm.tm_mon = (expiration[2] - '0') * 10 + expiration[3] - '0' - 1;
exptm.tm_mday = (expiration[4] - '0') * 10 + expiration[5] - '0';
exptm.tm_hour = (expiration[6] - '0') * 10 + expiration[7] - '0';
exptm.tm_min = (expiration[8] - '0') * 10 + expiration[9] - '0';
exptm.tm_sec = (expiration[10] - '0') * 10 + expiration[11] - '0';
}
OPENSSL_free(expiration);
return (mktime(&exptm));
}
#if 0
/*
* 'http_load_crl()' - Load the certificate revocation list, if any.
*/
static void
http_load_crl(void)
{
cupsMutexLock(&tls_mutex);
if (!openssl_x509_crl_init(&tls_crl))
{
cups_file_t *fp; // CRL file
char filename[1024], // site.crl
line[256]; // Base64-encoded line
unsigned char *data = NULL; // Buffer for cert data
size_t alloc_data = 0, // Bytes allocated
num_data = 0; // Bytes used
int decoded; // Bytes decoded
openssl_datum_t datum; // Data record
http_make_path(filename, sizeof(filename), CUPS_SERVERROOT, "site", "crl");
if ((fp = cupsFileOpen(filename, "r")) != NULL)
{
while (cupsFileGets(fp, line, sizeof(line)))
{
if (!strcmp(line, "-----BEGIN X509 CRL-----"))
{
if (num_data)
{
/*
* Missing END X509 CRL...
*/
break;
}
}
else if (!strcmp(line, "-----END X509 CRL-----"))
{
if (!num_data)
{
/*
* Missing data...
*/
break;
}
datum.data = data;
datum.size = num_data;
openssl_x509_crl_import(tls_crl, &datum, GNUTLS_X509_FMT_PEM);
num_data = 0;
}
else
{
if (alloc_data == 0)
{
data = malloc(2048);
alloc_data = 2048;
if (!data)
break;
}
else if ((num_data + strlen(line)) >= alloc_data)
{
unsigned char *tdata = realloc(data, alloc_data + 1024);
// Expanded buffer
if (!tdata)
break;
data = tdata;
alloc_data += 1024;
}
decoded = alloc_data - num_data;
httpDecode64((char *)data + num_data, &decoded, line);
num_data += (size_t)decoded;
}
}
cupsFileClose(fp);
if (data)
free(data);
}
}
cupsMutexUnlock(&tls_mutex);
}
#endif // 0
/*
* 'http_make_path()' - Format a filename for a certificate or key file.
*/
static const char * // O - Filename
http_make_path(
char *buffer, // I - Filename buffer
size_t bufsize, // I - Size of buffer
const char *dirname, // I - Directory
const char *filename, // I - Filename (usually hostname)
const char *ext) // I - Extension
{
char *bufptr, // Pointer into buffer
*bufend = buffer + bufsize - 1; // End of buffer
snprintf(buffer, bufsize, "%s/", dirname);
bufptr = buffer + strlen(buffer);
while (*filename && bufptr < bufend)
{
if (_cups_isalnum(*filename) || *filename == '-' || *filename == '.')
*bufptr++ = *filename;
else
*bufptr++ = '_';
filename ++;
}
if (bufptr < bufend && filename[-1] != '.')
*bufptr++ = '.';
strlcpy(bufptr, ext, (size_t)(bufend - bufptr + 1));
return (buffer);
}
//
// 'http_x509_add_san()' - Add a subjectAltName extension to an X.509 certificate.
//
static void
http_x509_add_san(X509 *cert, // I - Certificate
const char *name) // I - Hostname
{
char dns_name[1024]; // DNS: prefixed hostname
X509_EXTENSION *san_ext; // Extension for subjectAltName
ASN1_OCTET_STRING *san_asn1; // ASN1 string
// The subjectAltName value for DNS names starts with a DNS: prefix...
snprintf(dns_name, sizeof(dns_name), "DNS: %s", name);
if ((san_asn1 = ASN1_OCTET_STRING_new()) == NULL)
return;
ASN1_OCTET_STRING_set(san_asn1, (unsigned char *)dns_name, strlen(dns_name));
if ((san_ext = X509_EXTENSION_create_by_NID(NULL, NID_subject_alt_name, 0, san_asn1)) == NULL)
{
ASN1_OCTET_STRING_free(san_asn1);
return;
}
X509_add_ext(cert, san_ext, -1);
X509_EXTENSION_free(san_ext);
ASN1_OCTET_STRING_free(san_asn1);
}
| 25.955035 | 453 | 0.634653 |
b1d5604baff766c97790ec9f0387614857694e9d | 2,318 | h | C | quantum/keymap_extras/keymap_dvorak.h | crisalm29/niu-mini-layout | d71b92928c643aeb6efcf88fe37dac7fbd44ed68 | [
"MIT"
] | 2 | 2019-05-13T05:19:02.000Z | 2021-11-29T09:07:43.000Z | quantum/keymap_extras/keymap_dvorak.h | crisalm29/niu-mini-layout | d71b92928c643aeb6efcf88fe37dac7fbd44ed68 | [
"MIT"
] | null | null | null | quantum/keymap_extras/keymap_dvorak.h | crisalm29/niu-mini-layout | d71b92928c643aeb6efcf88fe37dac7fbd44ed68 | [
"MIT"
] | null | null | null | /* Copyright 2015-2016 Jack Humbert
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEYMAP_DVORAK_H
#define KEYMAP_DVORAK_H
#include "keymap.h"
// Normal characters
#define DV_GRV KC_GRV
#define DV_1 KC_1
#define DV_2 KC_2
#define DV_3 KC_3
#define DV_4 KC_4
#define DV_5 KC_5
#define DV_6 KC_6
#define DV_7 KC_7
#define DV_8 KC_8
#define DV_9 KC_9
#define DV_0 KC_0
#define DV_LBRC KC_MINS
#define DV_RBRC KC_EQL
#define DV_QUOT KC_Q
#define DV_COMM KC_W
#define DV_DOT KC_E
#define DV_P KC_R
#define DV_Y KC_T
#define DV_F KC_Y
#define DV_G KC_U
#define DV_C KC_I
#define DV_R KC_O
#define DV_L KC_P
#define DV_SLSH KC_LBRC
#define DV_EQL KC_RBRC
#define DV_BSLS KC_BSLS
#define DV_A KC_A
#define DV_O KC_S
#define DV_E KC_D
#define DV_U KC_F
#define DV_I KC_G
#define DV_D KC_H
#define DV_H KC_J
#define DV_T KC_K
#define DV_N KC_L
#define DV_S KC_SCLN
#define DV_MINS KC_QUOT
#define DV_SCLN KC_Z
#define DV_Q KC_X
#define DV_J KC_C
#define DV_K KC_V
#define DV_X KC_B
#define DV_B KC_N
#define DV_M KC_M
#define DV_W KC_COMM
#define DV_V KC_DOT
#define DV_Z KC_SLSH
// Shifted characters
#define DV_TILD LSFT(DV_GRV)
#define DV_EXLM LSFT(DV_1)
#define DV_AT LSFT(DV_2)
#define DV_HASH LSFT(DV_3)
#define DV_DLR LSFT(DV_4)
#define DV_PERC LSFT(DV_5)
#define DV_CIRC LSFT(DV_6)
#define DV_AMPR LSFT(DV_7)
#define DV_ASTR LSFT(DV_8)
#define DV_LPRN LSFT(DV_9)
#define DV_RPRN LSFT(DV_0)
#define DV_LCBR LSFT(DV_LBRC)
#define DV_RCBR LSFT(DV_RBRC)
#define DV_DQUO LSFT(DV_QUOT)
#define DV_LABK LSFT(DV_COMM)
#define DV_RABK LSFT(DV_DOT)
#define DV_QUES LSFT(DV_SLSH)
#define DV_PLUS LSFT(DV_EQL)
#define DV_PIPE LSFT(DV_BSLS)
#define DV_UNDS LSFT(DV_MINS)
#define DV_COLN LSFT(DV_SCLN)
#endif
| 22.950495 | 72 | 0.773943 |
50677f69903cb8a8a4be9204d7afc8ce794f51eb | 595 | go | Go | src/code.cloudfoundry.org/vendor/code.cloudfoundry.org/locket/models/models.go | cloudfoundry-incubator/cf-networking | 1197c5d4f357dacd7772b009ee4e49e948357a9e | [
"Apache-2.0"
] | 21 | 2018-01-12T16:54:53.000Z | 2022-03-04T13:04:02.000Z | src/code.cloudfoundry.org/vendor/code.cloudfoundry.org/locket/models/models.go | cloudfoundry-incubator/cf-networking | 1197c5d4f357dacd7772b009ee4e49e948357a9e | [
"Apache-2.0"
] | 159 | 2018-01-05T01:04:34.000Z | 2022-03-31T14:11:57.000Z | src/code.cloudfoundry.org/vendor/code.cloudfoundry.org/locket/models/models.go | cloudfoundry-incubator/cf-networking | 1197c5d4f357dacd7772b009ee4e49e948357a9e | [
"Apache-2.0"
] | 57 | 2018-02-26T06:36:44.000Z | 2022-03-18T14:59:54.000Z | package models
import (
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
)
//go:generate bash ../scripts/generate_protos.sh
//go:generate counterfeiter . LocketClient
const PresenceType = "presence"
const LockType = "lock"
var ErrLockCollision = grpc.Errorf(codes.AlreadyExists, "lock-collision")
var ErrInvalidTTL = grpc.Errorf(codes.InvalidArgument, "invalid-ttl")
var ErrInvalidOwner = grpc.Errorf(codes.InvalidArgument, "invalid-owner")
var ErrResourceNotFound = grpc.Errorf(codes.NotFound, "resource-not-found")
var ErrInvalidType = grpc.Errorf(codes.NotFound, "invalid-type")
| 31.315789 | 75 | 0.781513 |
b3bee11248ba9f49dd126527614d9a35067efb6b | 65 | rb | Ruby | spec/decorators/check_vote_decorator_spec.rb | corselia/suikoden-election-2018 | 02a71c87a3c3c18193c99bcd358c872ca5acb1c3 | [
"MIT"
] | null | null | null | spec/decorators/check_vote_decorator_spec.rb | corselia/suikoden-election-2018 | 02a71c87a3c3c18193c99bcd358c872ca5acb1c3 | [
"MIT"
] | 54 | 2018-05-19T06:34:08.000Z | 2018-07-10T10:11:54.000Z | spec/decorators/check_vote_decorator_spec.rb | corselia/suikoden-election-2018 | 02a71c87a3c3c18193c99bcd358c872ca5acb1c3 | [
"MIT"
] | null | null | null | require 'rails_helper'
RSpec.describe CheckVoteDecorator do
end
| 13 | 36 | 0.846154 |
3c99bb420781c58783e71c33ac57d68f044efbbe | 596 | rs | Rust | build.rs | elniallo/tokio-experiment | 547e0ec0029605bfa12910ce200ab0c356555d97 | [
"MIT"
] | 2 | 2019-03-28T07:00:15.000Z | 2019-05-24T08:38:11.000Z | build.rs | elniallo/tokio-experiment | 547e0ec0029605bfa12910ce200ab0c356555d97 | [
"MIT"
] | 22 | 2019-03-25T07:51:12.000Z | 2019-04-26T02:36:37.000Z | build.rs | elniallo/tokio-experiment | 547e0ec0029605bfa12910ce200ab0c356555d97 | [
"MIT"
] | 1 | 2019-02-19T13:13:00.000Z | 2019-02-19T13:13:00.000Z | extern crate protoc_rust_no_elision;
fn main() {
println!("Building...");
protoc_rust_no_elision::run(protoc_rust_no_elision::Args {
out_dir: "src/serialization",
input: &[
"src/proto/block.proto",
"src/proto/blockHeader.proto",
"src/proto/network.proto",
"src/proto/peer.proto",
"src/proto/state.proto",
"src/proto/tx.proto",
],
includes: &["src/proto/"],
customize: protoc_rust_no_elision::Customize {
..Default::default()
},
}).expect("protoc");
}
| 28.380952 | 62 | 0.548658 |
5b2e98e1d113798845d917c625bb6b059fa2a18c | 1,166 | h | C | Src/Common/WorkDirectoryHandler.h | microsoft/Simplygon-DCC-Integrations | 0da743b02c12e67e71cd71fc575e402e401de1ef | [
"MIT"
] | 14 | 2021-11-29T05:17:44.000Z | 2022-02-10T07:09:26.000Z | Src/Common/WorkDirectoryHandler.h | microsoft/Simplygon-DCC-Integrations | 0da743b02c12e67e71cd71fc575e402e401de1ef | [
"MIT"
] | null | null | null | Src/Common/WorkDirectoryHandler.h | microsoft/Simplygon-DCC-Integrations | 0da743b02c12e67e71cd71fc575e402e401de1ef | [
"MIT"
] | 1 | 2021-12-16T03:13:53.000Z | 2021-12-16T03:13:53.000Z | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include <tchar.h>
#include <string>
class WorkDirectoryHandler
{
public:
WorkDirectoryHandler();
~WorkDirectoryHandler();
std::basic_string<TCHAR> GetWorkDirectory();
std::basic_string<TCHAR> GetSimplygonAppDataPath();
std::basic_string<TCHAR> GetOriginalTexturesPath();
std::basic_string<TCHAR> GetBakedTexturesPath();
void SetTextureOutputDirectoryOverride( std::basic_string<TCHAR> tOutputDirectory );
std::basic_string<TCHAR> WorkDirectoryHandler::GetTextureOutputDirectoryOverride();
std::basic_string<TCHAR> GetImportWorkDirectory();
std::basic_string<TCHAR> GetExportWorkDirectory();
std::basic_string<TCHAR> GetExportTexturesPath();
void SetImportWorkDirectory( std::basic_string<TCHAR> tImportDirectory );
void SetExportWorkDirectory( std::basic_string<TCHAR> tExportDirectory );
private:
std::basic_string<TCHAR> WorkDirectory;
std::basic_string<TCHAR> OutputTextureDirectoryOverride;
std::basic_string<TCHAR> ImportWorkDirectory;
std::basic_string<TCHAR> ExportWorkDirectory;
void RecursiveDelete( std::basic_string<TCHAR> rootPath );
};
| 31.513514 | 85 | 0.801887 |
0b3f444aab07f3ace7008a9a2f44f279835a4a8e | 25,437 | py | Python | analyses/seasonality_paper_st/lai_only/shap_interaction/model_analysis_shap_interaction_1.py | akuhnregnier/wildfire-analysis | a04deada145cec864051d2fb15aec1a53a0246b9 | [
"MIT"
] | null | null | null | analyses/seasonality_paper_st/lai_only/shap_interaction/model_analysis_shap_interaction_1.py | akuhnregnier/wildfire-analysis | a04deada145cec864051d2fb15aec1a53a0246b9 | [
"MIT"
] | null | null | null | analyses/seasonality_paper_st/lai_only/shap_interaction/model_analysis_shap_interaction_1.py | akuhnregnier/wildfire-analysis | a04deada145cec864051d2fb15aec1a53a0246b9 | [
"MIT"
] | null | null | null | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
from pathlib import Path
from wildfires.utils import handle_array_job_args
try:
# This will only work after the path modification carried out in the job script.
from specific import (
CACHE_DIR,
SimpleCache,
get_model,
data_split_cache,
get_shap_values,
)
except ImportError:
"""Not running as an HPC job yet."""
def func():
# Used to re-compute specific failed jobs, `None` otherwise.
indices = [
0,
1,
2,
3,
4,
7,
8,
9,
15,
61,
62,
63,
64,
65,
66,
68,
69,
73,
75,
76,
77,
78,
79,
80,
81,
82,
83,
92,
93,
102,
103,
119,
120,
121,
122,
123,
128,
129,
130,
132,
169,
170,
171,
172,
174,
175,
176,
177,
178,
179,
180,
181,
182,
183,
184,
185,
188,
189,
200,
201,
208,
209,
229,
230,
231,
232,
233,
235,
236,
237,
242,
260,
261,
275,
276,
277,
278,
280,
281,
283,
284,
285,
286,
287,
288,
289,
290,
291,
292,
302,
303,
333,
334,
335,
336,
337,
345,
346,
347,
349,
366,
367,
382,
383,
384,
385,
390,
391,
397,
401,
402,
403,
404,
405,
406,
407,
408,
409,
419,
420,
446,
447,
448,
449,
450,
456,
457,
458,
465,
479,
480,
488,
489,
490,
491,
492,
493,
499,
500,
501,
502,
503,
505,
506,
507,
508,
509,
520,
521,
532,
533,
548,
549,
550,
551,
552,
553,
554,
555,
556,
561,
562,
563,
564,
579,
580,
595,
596,
601,
602,
603,
604,
606,
608,
620,
621,
646,
647,
648,
649,
651,
652,
653,
654,
655,
664,
665,
666,
667,
680,
681,
698,
699,
704,
705,
706,
707,
708,
709,
717,
718,
735,
736,
737,
738,
739,
740,
741,
742,
743,
751,
752,
753,
754,
768,
769,
801,
802,
808,
809,
810,
811,
814,
815,
823,
824,
856,
857,
858,
859,
860,
861,
862,
863,
864,
868,
869,
870,
871,
892,
893,
936,
937,
946,
947,
948,
949,
950,
951,
966,
967,
977,
978,
1001,
1002,
1003,
1004,
1005,
1006,
1008,
1009,
1010,
1013,
1014,
1015,
1016,
1049,
1050,
1054,
1055,
1056,
1057,
1058,
1059,
1064,
1065,
1073,
1074,
1086,
1087,
1088,
1089,
1090,
1091,
1094,
1095,
1096,
1100,
1101,
1102,
1104,
1126,
1128,
1129,
1130,
1131,
1132,
1133,
1139,
1140,
1147,
1148,
1163,
1164,
1165,
1166,
1167,
1168,
1170,
1171,
1172,
1173,
1174,
1201,
1202,
1203,
1204,
1205,
1206,
1207,
1217,
1218,
1230,
1231,
1241,
1242,
1243,
1244,
1245,
1246,
1247,
1248,
1249,
1250,
1251,
1252,
1267,
1268,
1275,
1276,
1277,
1281,
1282,
1283,
1284,
1286,
1287,
1294,
1295,
1306,
1307,
1308,
1309,
1310,
1311,
1312,
1313,
1314,
1324,
1325,
1332,
1333,
1334,
1335,
1336,
1337,
1338,
1339,
1340,
1345,
1346,
1360,
1361,
1362,
1363,
1366,
1367,
1368,
1369,
1370,
1380,
1381,
1393,
1394,
1395,
1398,
1403,
1404,
1405,
1406,
1407,
1408,
1411,
1412,
1426,
1427,
1428,
1429,
1430,
1438,
1439,
1449,
1450,
1451,
1452,
1454,
1455,
1456,
1457,
1458,
1459,
1462,
1463,
1471,
1472,
1473,
1474,
1475,
1485,
1486,
1494,
1496,
1497,
1498,
1503,
1504,
1505,
1506,
1507,
1508,
1514,
1515,
1521,
1522,
1529,
1530,
1531,
1536,
1537,
1538,
1540,
1541,
1562,
1564,
1565,
1566,
1572,
1574,
1575,
1576,
1577,
1578,
1579,
1584,
1585,
1591,
1592,
1604,
1605,
1606,
1616,
1617,
1618,
1619,
1620,
1643,
1644,
1645,
1646,
1658,
1659,
1660,
1661,
1662,
1663,
1664,
1672,
1673,
1677,
1678,
1689,
1690,
1691,
1706,
1707,
1708,
1709,
1710,
1737,
1740,
1741,
1742,
1750,
1751,
1752,
1753,
1754,
1755,
1756,
1764,
1765,
1769,
1770,
1776,
1781,
1782,
1791,
1792,
1793,
1794,
1795,
1826,
1827,
1828,
1829,
1836,
1837,
1838,
1839,
1840,
1843,
1844,
1851,
1852,
1855,
1856,
1862,
1863,
1864,
1876,
1877,
1878,
1879,
1880,
1901,
1903,
1904,
1905,
1914,
1915,
1916,
1917,
1918,
1919,
1920,
1927,
1928,
1939,
1940,
1957,
1958,
1959,
1962,
1964,
1965,
1966,
1971,
1972,
1973,
1974,
1975,
1976,
1977,
1981,
1982,
2004,
2005,
2027,
2028,
2051,
2053,
2054,
2056,
2059,
2060,
2061,
2073,
2074,
2075,
2076,
2077,
2078,
2079,
2095,
2096,
2102,
2103,
2131,
2132,
2133,
2134,
2185,
2187,
2188,
2189,
2192,
2193,
2194,
2201,
2202,
2203,
2204,
2205,
2206,
2207,
2222,
2225,
2226,
2235,
2236,
2255,
2256,
2257,
2258,
2313,
2316,
2317,
2320,
2323,
2324,
2326,
2336,
2337,
2338,
2339,
2340,
2341,
2342,
2345,
2350,
2351,
2364,
2365,
2387,
2388,
2389,
2390,
2433,
2435,
2436,
2437,
2439,
2440,
2443,
2449,
2450,
2451,
2452,
2453,
2454,
2455,
2461,
2465,
2466,
2470,
2471,
2487,
2488,
2489,
2490,
2533,
2536,
2537,
2538,
2540,
2541,
2542,
2546,
2547,
2548,
2549,
2550,
2551,
2552,
2563,
2566,
2567,
2572,
2573,
2588,
2589,
2590,
2591,
2640,
2641,
2642,
2643,
2644,
2646,
2647,
2648,
2657,
2658,
2659,
2660,
2661,
2662,
2663,
2671,
2674,
2675,
2681,
2682,
2704,
2705,
2706,
2707,
2750,
2752,
2753,
2754,
2755,
2756,
2757,
2758,
2762,
2763,
2764,
2765,
2766,
2767,
2768,
2773,
2778,
2779,
2791,
2792,
2817,
2818,
2819,
2820,
2842,
2845,
2846,
2847,
2848,
2849,
2850,
2851,
2854,
2855,
2856,
2858,
2859,
2860,
2863,
2869,
2870,
2882,
2883,
2895,
2896,
2897,
2898,
2899,
2903,
2920,
2924,
2925,
2926,
2927,
2928,
2929,
2930,
2933,
2934,
2935,
2936,
2937,
2940,
2944,
2945,
2948,
2949,
2959,
2960,
2973,
2974,
2975,
2976,
2977,
2980,
3013,
3016,
3017,
3018,
3019,
3020,
3021,
3022,
3024,
3027,
3028,
3029,
3032,
3034,
3038,
3046,
3047,
3052,
3053,
3057,
3058,
3074,
3075,
3076,
3077,
3078,
3089,
3123,
3125,
3126,
3127,
3128,
3129,
3130,
3131,
3132,
3138,
3139,
3140,
3141,
3142,
3144,
3145,
3146,
3150,
3151,
3159,
3160,
3179,
3180,
3181,
3182,
3183,
3190,
3230,
3232,
3233,
3234,
3235,
3236,
3237,
3238,
3239,
3240,
3245,
3246,
3247,
3248,
3249,
3250,
3254,
3255,
3258,
3259,
3266,
3267,
3300,
3301,
3302,
3303,
3304,
3305,
3309,
3331,
3332,
3333,
3334,
3335,
3337,
3338,
3340,
3341,
3343,
3345,
3346,
3347,
3348,
3349,
3350,
3357,
3358,
3361,
3362,
3370,
3371,
3400,
3401,
3402,
3403,
3404,
3405,
3415,
3456,
3458,
3459,
3460,
3461,
3463,
3464,
3466,
3467,
3468,
3472,
3473,
3474,
3475,
3476,
3477,
3479,
3480,
3482,
3483,
3488,
3489,
3506,
3508,
3509,
3510,
3511,
3512,
3513,
3524,
3556,
3557,
3558,
3559,
3560,
3563,
3564,
3565,
3566,
3567,
3571,
3572,
3573,
3575,
3576,
3578,
3588,
3589,
3592,
3593,
3599,
3600,
3622,
3624,
3625,
3626,
3627,
3628,
3629,
3646,
3676,
3677,
3678,
3679,
3680,
3681,
3682,
3683,
3685,
3686,
3687,
3692,
3693,
3694,
3695,
3696,
3698,
3701,
3708,
3709,
3714,
3715,
3718,
3719,
3740,
3741,
3743,
3745,
3746,
3747,
3748,
3749,
3759,
3791,
3792,
3793,
3794,
3795,
3796,
3798,
3799,
3800,
3801,
3802,
3811,
3812,
3813,
3814,
3815,
3816,
3818,
3826,
3827,
3829,
3830,
3839,
3840,
3856,
3857,
3858,
3859,
3860,
3861,
3872,
3904,
3905,
3907,
3908,
3909,
3910,
3911,
3912,
3913,
3914,
3915,
3916,
3922,
3923,
3924,
3925,
3926,
3927,
3929,
3933,
3934,
3935,
3940,
3941,
3946,
3947,
3969,
3970,
3971,
3972,
3973,
3974,
3975,
3985,
4017,
4020,
4021,
4022,
4023,
4024,
4025,
4026,
4027,
4028,
4029,
4034,
4035,
4036,
4037,
4038,
4039,
4042,
4050,
4051,
4052,
4053,
4054,
4058,
4059,
4069,
4071,
4072,
4073,
4074,
4075,
4076,
4082,
4100,
4102,
4103,
4104,
4105,
4106,
4108,
4109,
4112,
4113,
4114,
4115,
4116,
4117,
4118,
4119,
4120,
4121,
4122,
4127,
4128,
4129,
4130,
4131,
4144,
4145,
4158,
4160,
4161,
4162,
4163,
4164,
4165,
4166,
4172,
4175,
4177,
4178,
4201,
4202,
4203,
4204,
4205,
4206,
4207,
4208,
4210,
4211,
4212,
4213,
4214,
4223,
4224,
4225,
4226,
4227,
4228,
4229,
4234,
4235,
4236,
4237,
4238,
4248,
4261,
4263,
4264,
4265,
4266,
4267,
4268,
4269,
4270,
4285,
4288,
4292,
4298,
4299,
4318,
4322,
4323,
4324,
4325,
4326,
4329,
4330,
4333,
4334,
4336,
4338,
4339,
4340,
4341,
4342,
4345,
4350,
4351,
4352,
4353,
4354,
4366,
4367,
4380,
4382,
4387,
4388,
4389,
4390,
4391,
4392,
4393,
4399,
4403,
4411,
4415,
4416,
4426,
4427,
4444,
4445,
4446,
4447,
4448,
4449,
4450,
4451,
4452,
4453,
4457,
4458,
4459,
4460,
4462,
4464,
4466,
4467,
4475,
4476,
4477,
4478,
4479,
4498,
4499,
4507,
4509,
4510,
4511,
4512,
4513,
4514,
4515,
4524,
4525,
4526,
4533,
4539,
4540,
4549,
4550,
4563,
4566,
4568,
4569,
4570,
4571,
4573,
4574,
4575,
4576,
4578,
4582,
4583,
4584,
4585,
4586,
4587,
4588,
4596,
4597,
4598,
4599,
4600,
4601,
4609,
4610,
4624,
4626,
4627,
4628,
4629,
4630,
4631,
4632,
4638,
4646,
4652,
4653,
4659,
4660,
4669,
4672,
4673,
4674,
4675,
4677,
4678,
4681,
4682,
4683,
4687,
4688,
4689,
4690,
4691,
4692,
4693,
4702,
4703,
4704,
4705,
4706,
4707,
4708,
4723,
4724,
4737,
4739,
4740,
4741,
4742,
4743,
4744,
4745,
4746,
4759,
4768,
4772,
4773,
4779,
4795,
4801,
4802,
4803,
4804,
4806,
4807,
4809,
4810,
4812,
4820,
4821,
4822,
4823,
4825,
4826,
4828,
4829,
4838,
4839,
4840,
4841,
4842,
4843,
4844,
4845,
4858,
4859,
4890,
4891,
4892,
4894,
4895,
4896,
4897,
4898,
4899,
4900,
4911,
4912,
4913,
4915,
4921,
4924,
4925,
4935,
4936,
4957,
4959,
4960,
4961,
4962,
4964,
4965,
4966,
4967,
4969,
4970,
4973,
4977,
4978,
4979,
4980,
4981,
4982,
4990,
4991,
4992,
4993,
4994,
4996,
4997,
4998,
5025,
5028,
5031,
5032,
5033,
5034,
5035,
5036,
5037,
5045,
5046,
5047,
5049,
5054,
5055,
5059,
5060,
5071,
5072,
5105,
5107,
5108,
5109,
5110,
5116,
5118,
5119,
5120,
5122,
5123,
5124,
5126,
5127,
5128,
5137,
5138,
5139,
5140,
5141,
5142,
5143,
5144,
5174,
5176,
5178,
5179,
5180,
5181,
5182,
5183,
5184,
5188,
5189,
5195,
5200,
5201,
5202,
5205,
5206,
5207,
5208,
5213,
5214,
5232,
5233,
5234,
5235,
5236,
5237,
5238,
5239,
5240,
5241,
5242,
5245,
5248,
5249,
5250,
5253,
5254,
5256,
5260,
5261,
5262,
5263,
5264,
5266,
5267,
5268,
5289,
5290,
5292,
5293,
5294,
5295,
5296,
5297,
5298,
5299,
5300,
5306,
5308,
5309,
5310,
5319,
5320,
5327,
5328,
5339,
5340,
5352,
5353,
5354,
5355,
5356,
5357,
5358,
5359,
5361,
5366,
5367,
5368,
5369,
5370,
5371,
5376,
5380,
5381,
5382,
5383,
5384,
5385,
5386,
5387,
5418,
5419,
5421,
5422,
5423,
5424,
5425,
5426,
5427,
5430,
5431,
5438,
5439,
5440,
5441,
5448,
5449,
5454,
5455,
5460,
5461,
5482,
5483,
5484,
5485,
5486,
5488,
5489,
5490,
5491,
5499,
5500,
5501,
5502,
5503,
5504,
5511,
5515,
5516,
5517,
5518,
5519,
5520,
5521,
5522,
5538,
5556,
5557,
5559,
5560,
5561,
5562,
5563,
5564,
5565,
5570,
5571,
5577,
5579,
5580,
5582,
5587,
5588,
5592,
5593,
5601,
5627,
5628,
5629,
5630,
5631,
5633,
5634,
5635,
5636,
5639,
5640,
5641,
5643,
5644,
5645,
5652,
5653,
5654,
5655,
5656,
5657,
5658,
5659,
5660,
5672,
5696,
5697,
5698,
5700,
5701,
5702,
5703,
5704,
5705,
5706,
5710,
5711,
5715,
5716,
5717,
5719,
5723,
5724,
5727,
5728,
5738,
5764,
5765,
5766,
5767,
5769,
5770,
5771,
5772,
5782,
5783,
5784,
5786,
5787,
5788,
5794,
5798,
5799,
5800,
5801,
5802,
5803,
5804,
5805,
5815,
5816,
5837,
5838,
5839,
5840,
5842,
5843,
5844,
5845,
5846,
5847,
5848,
5850,
5851,
5855,
5857,
5858,
5860,
5871,
5872,
5874,
5875,
5899,
5900,
5901,
5902,
5905,
5906,
5907,
5908,
5913,
5914,
5915,
5916,
5917,
5918,
5920,
5926,
5927,
5928,
5929,
5930,
5931,
5932,
5933,
5940,
5941,
5963,
5964,
5965,
5966,
5967,
5968,
5969,
5970,
5972,
5973,
5974,
5975,
5976,
5978,
5979,
5982,
5983,
5990,
5994,
5995,
5997,
]
index = int(os.environ["PBS_ARRAY_INDEX"])
if indices is not None:
index = indices[index]
print("Index:", index)
X_train, X_test, y_train, y_test = data_split_cache.load()
rf = get_model()
job_samples = 50
tree_path_dependent_shap_interact_cache = SimpleCache(
f"tree_path_dependent_shap_interact_{index}_{job_samples}",
cache_dir=os.path.join(CACHE_DIR, "shap_interaction"),
)
@tree_path_dependent_shap_interact_cache
def cached_get_interact_shap_values(model, X):
return get_shap_values(model, X, interaction=True)
cached_get_interact_shap_values(
rf, X_train[index * job_samples : (index + 1) * job_samples]
)
if __name__ == "__main__":
handle_array_job_args(
Path(__file__).resolve(),
func,
ncpus=1,
mem="7gb",
walltime="11:00:00",
max_index=1734,
)
| 14.16314 | 84 | 0.298306 |
bf2cbeaf4d7ae3e39c1981a99ad67ffec3f6a0fe | 64 | rs | Rust | src/request/mod.rs | bububa/jos-rs | b34e5adcc3565b7df618cdf4d579d93ab6df1e14 | [
"Apache-2.0"
] | null | null | null | src/request/mod.rs | bububa/jos-rs | b34e5adcc3565b7df618cdf4d579d93ab6df1e14 | [
"Apache-2.0"
] | null | null | null | src/request/mod.rs | bububa/jos-rs | b34e5adcc3565b7df618cdf4d579d93ab6df1e14 | [
"Apache-2.0"
] | null | null | null | pub mod account;
pub mod bean;
pub mod brand;
pub mod category;
| 12.8 | 17 | 0.75 |
5f9d0d447851cf979bbbfbb54a990ef1e3b4eeea | 68 | c | C | foo/foo.c | BH1SCW/wrap-syscall | d2bae98c4be0e43ebdfb5aea44b94665c78b74d2 | [
"Apache-2.0"
] | null | null | null | foo/foo.c | BH1SCW/wrap-syscall | d2bae98c4be0e43ebdfb5aea44b94665c78b74d2 | [
"Apache-2.0"
] | null | null | null | foo/foo.c | BH1SCW/wrap-syscall | d2bae98c4be0e43ebdfb5aea44b94665c78b74d2 | [
"Apache-2.0"
] | null | null | null | #include <stdio.h>
int foo() {
printf("foo\n");
return 0;
}
| 11.333333 | 20 | 0.529412 |
3ca0c242449e4375c52625e44ca63237de5c155d | 158 | rs | Rust | 13_code_blocks/src/main.rs | foxx3r/learn_rust | 2aab6ea99b5e7a8ef081908618659ccc2d44555e | [
"MIT"
] | null | null | null | 13_code_blocks/src/main.rs | foxx3r/learn_rust | 2aab6ea99b5e7a8ef081908618659ccc2d44555e | [
"MIT"
] | null | null | null | 13_code_blocks/src/main.rs | foxx3r/learn_rust | 2aab6ea99b5e7a8ef081908618659ccc2d44555e | [
"MIT"
] | null | null | null | fn main() {
let x = 20;
{
let y = 40;
println!("20 X 40 = {}", x * y);
}
let y = 80;
println!("20 X 80 = {}", x * y);
}
| 13.166667 | 40 | 0.329114 |
bc6e0cccd9d93755d3ff2fed14536799f6f36d38 | 1,424 | sql | SQL | test/fixtures/rules/create.sql | benny-medflyt/pg-query-parser | 2888c2e099325e7280258def73dd16492530c2d9 | [
"BSD-3-Clause"
] | 60 | 2019-02-01T13:46:07.000Z | 2022-03-28T02:43:05.000Z | test/fixtures/rules/create.sql | benny-medflyt/pg-query-parser | 2888c2e099325e7280258def73dd16492530c2d9 | [
"BSD-3-Clause"
] | 50 | 2020-06-05T00:01:31.000Z | 2022-03-23T06:59:47.000Z | packages/pgsql-parser/__fixtures__/rules/create.sql | pgql/pg | 76de825da0512a1d596482b28b4287b8fa1a56e2 | [
"MIT"
] | 13 | 2019-12-24T07:00:57.000Z | 2022-02-17T22:43:32.000Z | CREATE RULE collections_ins_protect AS ON INSERT TO dbs.collections
DO INSTEAD
NOTHING;
CREATE RULE collections_upd_protect AS ON UPDATE
TO dbs.collections
DO INSTEAD
NOTHING;
CREATE RULE collections_del_protect AS ON DELETE TO dbs.collections
DO INSTEAD
NOTHING;
CREATE RULE shoelace_upd AS ON UPDATE TO shoelace
DO INSTEAD
UPDATE shoelace_data
SET sl_name = NEW.sl_name,
sl_avail = NEW.sl_avail,
sl_color = NEW.sl_color,
sl_len = NEW.sl_len,
sl_unit = NEW.sl_unit
WHERE sl_name = OLD.sl_name;
CREATE RULE shoelace_del AS ON DELETE TO shoelace
DO INSTEAD
DELETE FROM shoelace_data
WHERE sl_name = OLD.sl_name;
CREATE RULE "_RETURN" AS
ON SELECT TO t2
DO INSTEAD
SELECT * FROM t1;
CREATE RULE log_shoelace AS ON UPDATE TO shoelace_data
WHERE NEW.sl_avail <> OLD.sl_avail
DO INSERT INTO shoelace_log VALUES (
NEW.sl_name,
NEW.sl_avail,
current_user,
current_timestamp
);
CREATE RULE shoelace_ins AS ON INSERT TO shoelace
DO INSTEAD
INSERT INTO shoelace_data VALUES (
NEW.sl_name,
NEW.sl_avail,
NEW.sl_color,
NEW.sl_len,
NEW.sl_unit
);
| 26.37037 | 67 | 0.589888 |
125bc15a3495c02b00bad80e2d80b66c067f2390 | 3,176 | c | C | example.c | zqad/crc16-ccitt | 06691c08bb491165d6f8d7fcf934bfc9407480f4 | [
"MIT"
] | 12 | 2015-09-28T13:29:47.000Z | 2022-02-18T18:45:23.000Z | example.c | zqad/crc16-ccitt | 06691c08bb491165d6f8d7fcf934bfc9407480f4 | [
"MIT"
] | null | null | null | example.c | zqad/crc16-ccitt | 06691c08bb491165d6f8d7fcf934bfc9407480f4 | [
"MIT"
] | 3 | 2015-09-10T18:42:57.000Z | 2019-12-08T21:41:22.000Z | /*
* Copyright (c) 2014 Jonas Eriksson
*
* 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.
*/
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
uint16_t crc_calculate_table(const void *data, const size_t len);
uint16_t crc_calculate_algorithm(const void *data, const size_t len);
int main(void) {
int i;
size_t datalen;
uint16_t crc_algorithm;
uint16_t crc_table;
uint16_t crc_check_algorithm;
uint16_t crc_check_table;
/* Use the examples from
* http://srecord.sourceforge.net/crc16-ccitt.html */
char *testdata[] = {
/* Empty string */
"",
"A",
"123456789",
/* 256 x "A" */
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
NULL
};
uint8_t temp_buffer[300];
for (i = 0; testdata[i]; i++) {
printf("Data: '%s'\n", testdata[i]);
/* Calculate the CRCs */
datalen = strlen(testdata[i]);
crc_algorithm = crc_calculate_algorithm(testdata[i], datalen);
printf("Algorithm-based CRC: 0x%04hX\n", crc_algorithm);
crc_table = crc_calculate_table(testdata[i], datalen);
printf("Table-based CRC: 0x%04hX\n", crc_table);
/* Add the algorithm CRC after the data, note the big endian
* byte order */
memcpy(temp_buffer, testdata[i], datalen);
temp_buffer[datalen] = crc_algorithm >> 8;
temp_buffer[datalen + 1] = crc_algorithm & 0xFF;
/* Re-run the CRC check, but include the CRC */
crc_check_algorithm = crc_calculate_algorithm(temp_buffer,
datalen + 2);
printf("Algorithm-based CRC check: 0x%04hX\n",
crc_check_algorithm);
/* Repeat for the table-based CRC function, the first section
* of temp_buffer is still intact */
temp_buffer[datalen] = crc_table >> 8;
temp_buffer[datalen + 1] = crc_table & 0xFF;
crc_check_table = crc_calculate_table(temp_buffer,
datalen + 2);
printf("Table-based CRC check: 0x%04hX\n", crc_check_table);
printf("\n");
}
return 0;
}
| 34.150538 | 80 | 0.732368 |
1bb88e728ab36a24bc67d0d6904c1ad54404a0b4 | 930 | sql | SQL | benchmarks/htap/schemas/s64da_native_enhanced/primary-keys.sql | a-masterov/s64da-benchmark-toolkit | b1af60c6a1c7d4c62ae9fb5ce04e2c7b59002b0b | [
"MIT"
] | 15 | 2020-03-27T09:40:12.000Z | 2022-03-25T19:55:53.000Z | benchmarks/htap/schemas/s64da_native_enhanced/primary-keys.sql | a-masterov/s64da-benchmark-toolkit | b1af60c6a1c7d4c62ae9fb5ce04e2c7b59002b0b | [
"MIT"
] | 43 | 2020-03-25T10:03:11.000Z | 2021-06-02T01:15:17.000Z | benchmarks/htap/schemas/s64da_native_enhanced/primary-keys.sql | a-masterov/s64da-benchmark-toolkit | b1af60c6a1c7d4c62ae9fb5ce04e2c7b59002b0b | [
"MIT"
] | 6 | 2020-10-08T11:32:40.000Z | 2021-11-17T21:20:44.000Z | ALTER TABLE warehouse ADD CONSTRAINT warehouse_pk PRIMARY KEY (w_id);
ALTER TABLE district ADD CONSTRAINT district_pk PRIMARY KEY (d_w_id, d_id);
ALTER TABLE customer ADD CONSTRAINT customer_pk PRIMARY KEY (c_w_id, c_d_id, c_id);
ALTER TABLE history ADD CONSTRAINT history_pk PRIMARY KEY (id);
ALTER TABLE orders ADD CONSTRAINT orders_pk PRIMARY KEY (o_w_id, o_d_id, o_id);
ALTER TABLE new_orders ADD CONSTRAINT new_orders_pk PRIMARY KEY (no_w_id, no_d_id, no_o_id);
ALTER TABLE order_line ADD CONSTRAINT order_line_pk PRIMARY KEY (ol_w_id, ol_d_id, ol_o_id, ol_number);
ALTER TABLE stock ADD CONSTRAINT stock_pk PRIMARY KEY (s_w_id, s_i_id);
ALTER TABLE item ADD CONSTRAINT item_pk PRIMARY KEY (i_id);
ALTER TABLE region ADD CONSTRAINT region_pk PRIMARY KEY (r_regionkey);
ALTER TABLE nation ADD CONSTRAINT nation_pk PRIMARY KEY (n_nationkey);
ALTER TABLE supplier ADD CONSTRAINT supplier_pk PRIMARY KEY (su_suppkey);
| 38.75 | 103 | 0.809677 |
b2dddf20dfadcb66e5efbea5b82b5fce448e57cf | 727 | py | Python | setup.py | dboddie/Beeware-Hello-VOC | a22ffc58121ead7acac850c6edb60576bdb66993 | [
"MIT"
] | 35 | 2017-09-21T03:45:33.000Z | 2021-11-18T01:18:13.000Z | setup.py | dboddie/Beeware-Hello-VOC | a22ffc58121ead7acac850c6edb60576bdb66993 | [
"MIT"
] | 6 | 2017-09-25T12:34:31.000Z | 2021-07-05T03:40:19.000Z | setup.py | dboddie/Beeware-Hello-VOC | a22ffc58121ead7acac850c6edb60576bdb66993 | [
"MIT"
] | 10 | 2018-02-03T12:51:31.000Z | 2022-02-08T18:54:48.000Z | #!/usr/bin/env python
from setuptools import setup, find_packages
setup(
name='{{ cookiecutter.app_name }}',
version='0.0.1',
description='{{ cookiecutter.description }}',
author='{{ cookiecutter.author }}',
author_email='{{ cookiecutter.author_email }}',
license='{{ cookiecutter.license }}',
packages=find_packages(
exclude=['docs', 'tests', 'android']
),
classifiers=[
'Development Status :: 1 - Planning',
'License :: OSI Approved :: {{ cookiecutter.license }}',
],
install_requires=[
],
options={
'app': {
'formal_name': '{{ cookiecutter.formal_name }}',
'bundle': '{{ cookiecutter.bundle }}'
},
}
)
| 25.964286 | 64 | 0.569464 |
18efa39894327826bcd2e56a7a14247334aba68a | 5,170 | css | CSS | css/projects.css | cpabbot/cpabbot.github.io | 9dd911e7c63d694a98b1f7e77d1af5e4a72ef35e | [
"Apache-2.0"
] | 1 | 2019-04-01T14:23:57.000Z | 2019-04-01T14:23:57.000Z | css/projects.css | cpabbot/cpabbot.github.io | 9dd911e7c63d694a98b1f7e77d1af5e4a72ef35e | [
"Apache-2.0"
] | null | null | null | css/projects.css | cpabbot/cpabbot.github.io | 9dd911e7c63d694a98b1f7e77d1af5e4a72ef35e | [
"Apache-2.0"
] | null | null | null | body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
/*** HEADER ***/
.header--old {
position: absolute;
height: 10vh;
width: 100%;
background-color: darkred;
}
.title--projects--old {
color: #fff;
padding-left: 80px;
}
.header--projects {
/* background-color: #8b0000; */
}
.title--projects {
/* color: #fff; */
}
.nav-link--projects {
/* color: #BBB; */
}
.nav-link--projects:hover {
/* color: #FFF; */
}
.nav-link--active--projects {
/* color: #FFF; */
}
/*** PROJECT ***/
.project {
position: relative;
width: 100%;
height: calc(100vh - 100px);
text-align: center;
/* background-color: #8b00000f; */
/* background-image: url(../img/projects-background.jpg);*/
/* background-size: cover; */
overflow: hidden;
}
.project__img {
width: 50vw;
min-width: 500px;
/* box-shadow: 0px 4px 6px 0px rgba(0, 0, 0, 0.5);*/
position: absolute;
left: calc(50% - 25vw);
top: 5%;
/* filter: grayscale(0.5) brightness(0.9) blur(2px);*/
filter: grayscale(0.4) contrast(0.7) brightness(1.1) blur(2px);
transition: all 400ms ease-in, filter 200ms;
}
@media (max-width: 900px) {
.project__img {
left: calc(50% - 250px);
}
}
.project__img.exit {
transform: translate(-20vw) scale(0.9, 0.9);
}
.project__img.enter {
transform: translate(20vw) scale(1.1, 1.1);
}
.project__date {
font-size: 2rem; /*calc(3vw + 2px);*/
display: block;
position: absolute;
left: 45vw;
line-height: 50vh; /* same as parent */
}
.project__description {
position: absolute;
/* width: 27vw;*/
/* height: 40%;*/
left: 15%;
right: 10%;
top: 60%;
/* bottom: 3vh; */
margin: auto;
text-align: left;
transition: all 300ms ease-in;
}
.project__description.exit {
transform: translateY(10vh);
}
.project__description.enter {
transform: translateY(10vh);
}
.exit, .enter {
opacity: 0 !important;
}
/* Should be made not necessary, but used to remove .link underline on hover */
.project__description a:hover {
text-decoration: none;
}
.project__title {
position: relative;
color: #333;
font-size: 4em;
font-weight: 700;
margin-bottom: 100px !important;
display: inline;
z-index: 1;
/* text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.5);*/
transition: all 200ms;
background: rgb(0,100,121);
background: linear-gradient(90deg, rgba(0,100,121,0.8) 0%, rgba(255,255,255,1) 52%, rgba(162,0,0,0.8) 100%);
background-repeat: no-repeat;
background-size: 140% 0.2em;
background-position: 0 88%;
}
@media (max-width: 800px) {
.project__title {
font-size: calc(6vw + 1rem);
}
}
.project__title:hover {
text-decoration: none;
/* color: #555;*/
/* background-size: 100% 100%;*/
/* color: #fff;*/
background-position: 100% 88%;
background-size: 180% 0.25em;
}
.project__title2 {
font-size: 1rem;
font-weight: 700;
}
.project__story {
line-height: 100%;
margin: 0;
line-height: 1.5em;
}
.indent {
text-indent: 50px;
}
@media (max-width: 700px) {
.project__img {
top: 0;
}
.project__description {
/* bottom: 8vh;*/
}
}
@media (max-width: 600px) {
.project__img {
width: 100%;
left: 0;
}
.project__arrow {
}
.project__description {
/* bottom: 8vh;*/
}
}
.project__arrow {
width: 40px;
position: absolute;
bottom: 23vh;
}
.project__arrow--back {
left: 5vw
}
.project__arrow--next {
right: 5vw;
}
.card {
box-shadow: 0px 4px 6px 0px rgba(0, 0, 0, 0.15);
background-color: #FFF;
position: relative;
width: 500px;
height: 300px;
top: 50px;
margin-bottom: 40px;
}
.project__title2 {
position: absolute;
color: #FFF;
font-size: 2em;
display: inline-block;
margin-left: 0.8em;
bottom: 0px;
}
.link--code {
line-height: 2rem;
color: #0000EE;
}
.link--code:hover {
/* color: #0000BB;*/
text-decoration: underline;
}
.overlay {
position: fixed;
background-color: #000;
opacity: 0.8;
height: 100%;
width: 100%;
z-index: 1;
transition: all 200ms;
}
.unfilter {
filter: none;
transition: filter 200ms;
z-index: 2;
}
/* enter from right, reverse to exit */
@keyframes enterRight{from{opacity:0;-webkit-transform:translateX(20vw);-ms-transform:translateX(20vw);transform:translateX(20vw)}to{opacity:1;-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0)}}
/* enter from left, reverse to exit */
@keyframes enterLeft{from{opacity:0;-webkit-transform:translateX(-20vw);-ms-transform:translateX(-20vw);transform:translateX(-20vw)}to{opacity:1;-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0)}}
.enterRight {
animation: enterRight 1s ease;
}
.exitRight {
animation: enterRight 1s ease;
animation-direction: reverse;
}
.enterLeft {
animation: enterRight 1s ease;
}
.exitLeft {
animation: enterRight 1s ease;
animation-direction: reverse;
}
| 18.66426 | 230 | 0.604255 |
772170e8fba627d5d43794f3f7730acc10d545fa | 1,134 | rs | Rust | src/enclave_api.rs | gskapka/secp256k1-enclave-rust | 26119099ce6cb5e74274d90f4312b402646cb4cf | [
"MIT"
] | 26 | 2019-07-02T22:20:56.000Z | 2022-03-02T05:22:14.000Z | src/enclave_api.rs | gskapka/secp256k1-enclave-rust | 26119099ce6cb5e74274d90f4312b402646cb4cf | [
"MIT"
] | 1 | 2021-04-05T16:10:29.000Z | 2021-04-05T16:10:29.000Z | src/enclave_api.rs | gskapka/secp256k1-enclave-rust | 26119099ce6cb5e74274d90f4312b402646cb4cf | [
"MIT"
] | 9 | 2019-08-15T18:13:07.000Z | 2022-01-16T07:43:28.000Z | #![allow(improper_ctypes)]
use secp256k1::key::PublicKey;
use sgx_types::{sgx_enclave_id_t, sgx_status_t};
extern {
pub fn generate_keypair(
eid: sgx_enclave_id_t,
retval: *mut sgx_status_t,
sealed_log: *mut u8,
sealed_log_size: *const u32
) -> sgx_status_t;
pub fn sign_message(
eid: sgx_enclave_id_t,
retval: *mut sgx_status_t,
sealed_log: *mut u8,
sealed_log_size: *const u32,
hashed_message: *mut u8,
signature: *mut u8
) -> sgx_status_t;
pub fn get_public_key(
eid: sgx_enclave_id_t,
retval: *mut sgx_status_t,
pub_key: *mut PublicKey,
sealed_log: *mut u8,
sealed_log_size: *const u32
) -> sgx_status_t;
pub fn show_private_key(
eid: sgx_enclave_id_t,
retval: *mut sgx_status_t,
sealed_log: *mut u8,
sealed_log_size: *const u32
) -> sgx_status_t;
pub fn destroy_key(
eid: sgx_enclave_id_t,
retval: *mut sgx_status_t,
sealed_log: *mut u8,
sealed_log_size: *const u32
) -> sgx_status_t;
}
| 25.772727 | 48 | 0.604938 |
71e68956d75edcf9698c155dfeb03a06cc6ecaee | 1,472 | kt | Kotlin | modules/drawing/src/main/kotlin/silentorb/mythic/drawing/drawText.kt | silentorb/mythic-kotlin | 74462fcba9e7805dddec1bfcb3431665df7d0dee | [
"MIT"
] | 1 | 2020-06-24T02:01:23.000Z | 2020-06-24T02:01:23.000Z | modules/drawing/src/main/kotlin/silentorb/mythic/drawing/drawText.kt | silentorb/mythic-kotlin | 74462fcba9e7805dddec1bfcb3431665df7d0dee | [
"MIT"
] | 5 | 2019-12-24T17:14:43.000Z | 2021-01-26T22:33:47.000Z | modules/drawing/src/main/kotlin/silentorb/mythic/drawing/drawText.kt | silentorb/mythic-kotlin | 74462fcba9e7805dddec1bfcb3431665df7d0dee | [
"MIT"
] | null | null | null | package silentorb.mythic.drawing
import silentorb.mythic.glowing.DrawMethod
import silentorb.mythic.glowing.VertexSchema
import silentorb.mythic.glowing.globalState
import silentorb.mythic.spatial.Matrix
import silentorb.mythic.spatial.Vector2
import silentorb.mythic.typography.TextConfiguration
import silentorb.mythic.typography.TextPackage
import silentorb.mythic.typography.prepareText
import silentorb.mythic.spatial.Vector2i
import org.lwjgl.opengl.GL11.*
fun getUnitScaling(dimensions: Vector2i) =
if (dimensions.x < dimensions.y)
Vector2(1f, dimensions.x.toFloat() / dimensions.y)
else
Vector2(dimensions.y.toFloat() / dimensions.x, 1f)
fun prepareTextMatrix(pixelsToScalar: Matrix, position: Vector2) =
Matrix.identity
.mul(pixelsToScalar)
.translate(position.x, position.y, 0f)
fun renderText(config: TextConfiguration, effect: ColoredImageShader, textPackage: TextPackage, transform: Matrix) {
effect.activate(transform, config.style.color, config.style.font.texture)
globalState.blendEnabled = true
globalState.blendFunction = Pair(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
textPackage.mesh.draw(DrawMethod.triangleFan)
}
fun drawTextRaw(config: TextConfiguration, effect: ColoredImageShader, vertexSchema: VertexSchema, transform: Matrix) {
val textPackage = prepareText(config, vertexSchema)
if (textPackage != null) {
renderText(config, effect, textPackage, transform)
textPackage.mesh.dispose()
}
}
| 36.8 | 119 | 0.796196 |
10edb16c986845e63bcdc9ab418356a6c1b18f4f | 1,072 | kt | Kotlin | ktlint-test/src/main/kotlin/com/pinterest/ktlint/test/RuleSetProviderTest.kt | LiteKite/ktlint | 1b0e5353437a85362ec01168c82632b6646895e7 | [
"MIT"
] | 2,031 | 2016-07-27T10:07:55.000Z | 2019-03-14T05:57:01.000Z | ktlint-test/src/main/kotlin/com/pinterest/ktlint/test/RuleSetProviderTest.kt | LiteKite/ktlint | 1b0e5353437a85362ec01168c82632b6646895e7 | [
"MIT"
] | 351 | 2016-07-28T12:23:55.000Z | 2019-03-14T23:54:31.000Z | ktlint-test/src/main/kotlin/com/pinterest/ktlint/test/RuleSetProviderTest.kt | LiteKite/ktlint | 1b0e5353437a85362ec01168c82632b6646895e7 | [
"MIT"
] | 174 | 2016-08-01T15:54:57.000Z | 2019-03-13T20:13:21.000Z | package com.pinterest.ktlint.test
import com.pinterest.ktlint.core.RuleSetProvider
import java.io.File
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
open class RuleSetProviderTest(
private val rulesetClass: Class<out RuleSetProvider>,
private val packageName: String
) {
@Test
fun checkAllRulesProvided() {
val srcLocation = rulesetClass.protectionDomain.codeSource.location.path
val rulesDir = File(srcLocation + packageName.replace(".", "/"))
val packageRules = rulesDir.listFiles()
?.map { it.name.removeSuffix(".class") }
?.filter { it.endsWith("Rule") }
?: arrayListOf()
val provider = rulesetClass
val providerRules = provider.newInstance().get().rules.map { it::class.java.simpleName }
val diff = packageRules - providerRules
assertThat(diff)
.withFailMessage("%s is missing to provide the following rules: \n%s", provider.simpleName, diff.joinToString(separator = "\n"))
.hasSize(0)
}
}
| 36.965517 | 140 | 0.676306 |
b7ab2d0f1afd688077aa1d8d438945d60e201ce5 | 418 | asm | Assembly | oeis/332/A332426.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 11 | 2021-08-22T19:44:55.000Z | 2022-03-20T16:47:57.000Z | oeis/332/A332426.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 9 | 2021-08-29T13:15:54.000Z | 2022-03-09T19:52:31.000Z | oeis/332/A332426.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 3 | 2021-08-22T20:56:47.000Z | 2021-09-29T06:26:12.000Z | ; A332426: Number of unordered pairs of non-selfintersecting paths with nodes that cover all vertices of a convex n-gon.
; Submitted by Christian Krause
; 0,3,30,210,1260,6944,36288,182880,897600,4316928,20427264,95373824,440294400,2013020160,9126248448,41069371392,183607050240,816037560320,3607758766080,15874168848384,69544044134400,303465064562688
mov $1,2
pow $1,$0
add $0,3
bin $0,2
bin $1,2
mul $0,$1
div $0,2
| 34.833333 | 198 | 0.796651 |
d283e9ea3da2e2ddebece85748928dae3bcaf0cc | 229 | sql | SQL | src/Security/AW2014_user.sql | NowinskiK/ssdt-training | d66dc0bb2ca9ad7a20b655bbde2a2e2801241139 | [
"MIT"
] | 5 | 2020-09-16T18:13:49.000Z | 2021-12-10T04:59:55.000Z | src/Security/AW2014_user.sql | NowinskiK/ssdt-training | d66dc0bb2ca9ad7a20b655bbde2a2e2801241139 | [
"MIT"
] | null | null | null | src/Security/AW2014_user.sql | NowinskiK/ssdt-training | d66dc0bb2ca9ad7a20b655bbde2a2e2801241139 | [
"MIT"
] | 3 | 2021-10-08T12:35:43.000Z | 2021-12-27T19:53:28.000Z | USE AdventureWorks2014
GO
CREATE USER extROUser
WITH PASSWORD = 'ReeA1frejgiWeZjg'
GO
-- Add user to the database owner role
--EXEC sp_addrolemember N'db_owner', N'extROUser'
EXEC sp_addrolemember 'db_datareader', 'extROUser'
| 20.818182 | 50 | 0.79476 |
9b9f8bfe6b1623e4a1933da74d7fdb1b0e2bd6f3 | 633 | js | JavaScript | src/App.spec.js | ArGJolan/memory-game-back | 894c9dd8234db495cabf4f3cca5ede08e49181ac | [
"MIT"
] | null | null | null | src/App.spec.js | ArGJolan/memory-game-back | 894c9dd8234db495cabf4f3cca5ede08e49181ac | [
"MIT"
] | null | null | null | src/App.spec.js | ArGJolan/memory-game-back | 894c9dd8234db495cabf4f3cca5ede08e49181ac | [
"MIT"
] | null | null | null | /* global expect */
/* eslint-disable no-unused-expressions */
const proxyquire = require('proxyquire');
const { EmptyFixture, ServerFixture, UtilsFixture } = require('../test/fixture');
const App = proxyquire('./App', {
'./Random/Random.Service': EmptyFixture,
'./Random/Random.Controller': EmptyFixture,
'./Server': ServerFixture,
'../utils': UtilsFixture,
});
describe('App', () => {
let app;
beforeEach(() => {
app = new App({
random: {},
server: {},
});
});
it('should call server start', async () => {
await app.start();
expect(app.server.start).to.have.been.called;
});
});
| 21.1 | 81 | 0.605055 |
1fee9f4b5773ce1ca551ca12e6bb2553790a8bbf | 15,066 | css | CSS | src/pages/index.css | jonathanedward/internal-site | c0a29c5677bbd592df661c2b9e1859fee3d199e6 | [
"MIT"
] | null | null | null | src/pages/index.css | jonathanedward/internal-site | c0a29c5677bbd592df661c2b9e1859fee3d199e6 | [
"MIT"
] | 7 | 2021-05-08T23:16:26.000Z | 2022-02-26T11:10:23.000Z | src/pages/index.css | jonathanedward/internal-site | c0a29c5677bbd592df661c2b9e1859fee3d199e6 | [
"MIT"
] | null | null | null | @import url("https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500&display=swap");
.StartHero h1 {
font-size: 100px;
line-height: 1;
}
@media (max-width: 640px) {
.StartHero h1 {
font-size: 60px;
}
}
.MindsetTitle h2, .HowsTitle h2, .Fusion .FusionGroup .FusionTitle h2, .ToolsTitle h2, .BlogTitle h2, .Details h2 {
font-size: 60px;
line-height: 1;
margin: 10px auto;
}
@media (max-width: 640px) {
.MindsetTitle h2, .HowsTitle h2, .Fusion .FusionGroup .FusionTitle h2, .ToolsTitle h2, .BlogTitle h2, .Details h2 {
font-size: 50px;
}
}
.StartHero h4 {
font-size: 25px;
line-height: 1;
}
@media (max-width: 640px) {
.StartHero h4 {
font-size: 16px;
}
}
.Division h5, .Details h5 {
font-size: 20px;
margin: 10px auto;
line-height: 1;
}
.IntroGroup h6, .Card h6, .Tool h6, .JobSection h6 {
margin: 0px auto;
font-size: 20px;
line-height: 1;
}
.IntroGroup p, .IntroGroup ul, .Card p, .HowsTitle p, .Fusion .FusionGroup .FusionTitle p, .Tool h6 p {
font-size: 14px;
line-height: 1.5;
margin: 10px auto;
}
.ToolsTitle p {
font-size: 16px;
line-height: 1.8;
margin: 10px auto;
}
.Division p, .BlogTiles p {
font-size: 12px;
line-height: 1.5;
margin: 10px auto;
}
.StartHeroGroup, .IntroGroup, .MindsetTitle, .HowWeWorkGroup, .Fusion .FusionGroup, .OurToolsContainer, .BlogContainer, .CareersSection, .FooterContainer {
max-width: 900px;
margin: 0 auto;
}
.Intro, .OurMindset, .WhiteBG, .MindsetTitle, .Blog, .DividerGroup, .Careers {
background-color: white;
color: black;
}
.HowWeWork, .Fusion, .OurTools {
background-color: black;
color: white;
}
html {
scroll-behavior: smooth;
}
body {
background-color: black;
font-family: "Source Code Pro", monospace;
border: none;
margin: 0;
overflow-x: hidden;
}
body p {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}
.StartHero {
margin: 0;
padding: 0;
position: relative;
background: url(../images/bg2.jpg);
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.StartHeroGroup {
padding: 150px 20px;
}
@media (max-width: 640px) {
.StartHeroGroup {
padding: 80px 20px 50px 20px;
}
}
.StartHero h1 {
color: white;
}
.StartHero h4 {
color: white;
line-height: 1.5;
font-weight: 500;
}
.Intro {
margin: 0;
padding-top: 100px;
padding-bottom: 100px;
}
@media (max-width: 640px) {
.Intro {
padding-top: 50px;
padding-bottom: 20px;
}
}
.IntroGroup {
display: -ms-grid;
display: grid;
-ms-grid-columns: 1fr;
grid-template-columns: 1fr 1fr;
padding: 0 20px;
}
@media (max-width: 640px) {
.IntroGroup {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
padding: 0 20px;
}
}
.IntroGroup h2 {
font-size: 60px;
line-height: 1;
}
.IntroGroup h6 {
font-size: 16px;
padding-top: 20px;
}
.IntroGroup ul {
padding-left: 30px;
}
.IntroGroup img {
width: 100%;
-o-object-fit: contain;
object-fit: contain;
}
.OurMindset {
margin: 0;
}
.MindsetTitle {
padding: 0 20px;
}
.MindsetGroup {
width: 100%;
height: 600px;
overflow: hidden;
}
.Mindset {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
height: 100%;
width: 100%;
padding-left: 200px;
padding-top: 17px;
}
@media (max-width: 640px) {
.Mindset {
padding-left: 0px;
}
}
@media (max-width: 640px) {
.Mindset div:nth-last-child(1) {
display: none;
}
}
.Card {
-webkit-box-flex: 0;
-ms-flex: 0 0 auto;
flex: 0 0 auto;
margin-right: 3px;
width: 300px;
height: 400px;
padding-left: 60px;
padding-top: 30px;
}
@media (max-width: 640px) {
.Card {
padding-left: 20px;
}
}
.Card img {
-o-object-fit: cover;
object-fit: cover;
width: 250px;
}
.Card h6 {
margin: 30px auto;
}
.HowWeWork {
position: relative;
padding-top: 100px;
padding-bottom: 50px;
}
@media (max-width: 640px) {
.HowWeWork {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
padding-top: 50px;
padding-bottom: 10px;
}
}
.HowWeWorkGroup {
display: -ms-grid;
display: grid;
-ms-grid-rows: 1fr 1fr;
grid-template-rows: 1fr 1fr;
padding: 0 20px;
}
@media (max-width: 640px) {
.HowWeWorkGroup {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
padding: 0;
}
}
.HowsTitle {
max-width: 900px;
display: -ms-grid;
display: grid;
-ms-grid-columns: 400px auto;
grid-template-columns: 400px auto;
}
@media (max-width: 640px) {
.HowsTitle {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
padding: 0 20px;
}
}
.Divisions {
display: -ms-grid;
display: grid;
-ms-grid-columns: 1fr 1fr 1fr;
grid-template-columns: 1fr 1fr 1fr;
grid-column-gap: 20px;
padding-top: 50px;
}
@media (max-width: 640px) {
.Divisions {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
padding: 30px 20px;
}
}
@media (max-width: 640px) {
.Division {
padding-bottom: 10px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
}
.Division img {
width: 50px;
}
@media (max-width: 640px) {
.Division div {
padding-left: 20px;
padding-top: 10px;
}
}
hr {
max-width: 900px;
display: block;
margin-top: 50px;
margin-bottom: 0.5em;
border-style: inset;
border-width: 1px;
border-color: black;
}
@media (max-width: 640px) {
hr {
display: none;
}
}
.Fusion {
padding-top: 150px;
}
.Fusion .FusionGroup {
display: -ms-grid;
display: grid;
-ms-grid-columns: 1fr 1fr;
grid-template-columns: 1fr 1fr;
grid-column-gap: 20px;
}
.Fusion .FusionGroup .FusionButtons a {
color: white;
text-decoration: none;
line-height: 2;
}
.Fusion .FusionGroup .FusionButtons a:hover {
text-decoration: underline;
}
.Fusion .FusionImg {
-ms-grid-column-align: center;
justify-self: center;
}
.Fusion .FusionImg img {
width: 180px;
}
.OurToolsContainer {
display: -ms-grid;
display: grid;
-ms-grid-rows: 100px auto;
grid-template-rows: 100px auto;
padding: 0 20px;
}
.ToolsTitle p a {
color: white;
text-decoration: none;
}
.ToolsTitle p a:hover {
text-decoration: underline;
}
.ToolsGroup {
width: 100%;
height: 600px;
overflow: hidden;
padding-top: 30px;
}
@media (max-width: 640px) {
.ToolsGroup {
height: 500px;
}
}
.Tools {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
height: 100%;
width: 100%;
padding-top: 17px;
}
@media (max-width: 640px) {
.Tools {
height: 100%;
}
}
.Links {
text-decoration: none !important;
color: white;
}
.Tool {
-webkit-box-flex: 0;
-ms-flex: 0 0 auto;
flex: 0 0 auto;
width: 400px;
height: 600px;
padding-left: 30px;
padding-top: 30px;
background-color: yellow;
position: relative;
-webkit-transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
overflow: hidden;
}
.Tool h6 {
max-width: 390px;
font-size: 43px;
font-weight: 400;
position: absolute;
z-index: 2;
}
.Tool h6:hover {
text-decoration: underline;
}
.Tool h6 p {
max-width: 390px;
opacity: 0;
}
.Tool img {
position: absolute;
right: 50px;
bottom: 100px;
width: 200px;
}
.Tool .ToolsBackground {
position: absolute;
top: 0;
left: 0;
-o-object-fit: contain;
object-fit: contain;
opacity: 0;
width: 200%;
-webkit-transition: 1s cubic-bezier(0.2, 0.8, 0.2, 1);
transition: 1s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (max-width: 640px) {
.Tool {
height: 500px;
}
}
.Tool:hover .ToolsBackground {
opacity: 1;
width: 220%;
-webkit-filter: brightness(65%);
filter: brightness(65%);
}
.Tool:hover img {
opacity: 0;
}
.STN {
background-color: #faba00;
}
.IFR {
background-color: #18a79b;
}
.PPMS {
background-color: #303d4e;
}
.Mailwave {
background-color: #00bcd4;
}
.Sirius {
background-color: #43a0d6;
}
.Lucid {
background-color: #6cc6b3;
}
.Bridge {
background-color: #6bc5d6;
}
.Polaris {
background-color: #8283ce;
}
.Solaris {
background-color: #5867f1;
}
.Toby {
background-color: #c14040;
}
.Blog {
padding-top: 100px;
padding-bottom: 100px;
}
@media (max-width: 640px) {
.Blog {
padding-top: 50px;
padding-bottom: 50px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
}
}
.BlogContainer {
display: -ms-grid;
display: grid;
-ms-grid-rows: 1fr 1fr;
grid-template-rows: 1fr 1fr;
padding: 0 20px;
}
@media (max-width: 640px) {
.BlogContainer {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
}
}
.BlogTitle p {
margin: 20px auto;
}
.Blogs {
display: -ms-grid;
display: grid;
max-width: 900px;
-ms-grid-columns: 1fr 1fr 1fr;
grid-template-columns: 1fr 1fr 1fr;
grid-column-gap: 20px;
}
.Blogs a {
color: black;
text-decoration: none;
}
@media (max-width: 640px) {
.Blogs {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
}
}
@media (max-width: 640px) {
.BlogTiles b {
font-size: 20px;
line-height: 1;
}
}
@media (max-width: 640px) {
.BlogTiles {
padding-bottom: 20px;
}
}
.BlogTiles img {
width: 100%;
height: 150px;
-o-object-fit: cover;
object-fit: cover;
-webkit-transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.BlogTiles:hover img {
-webkit-filter: brightness(80%);
/* Safari */
filter: brightness(80%);
}
.DividerGroup {
overflow: hidden;
}
.DividerGroup div {
height: 300px;
width: 5883px;
background: url(../images/divider.jpg) repeat-x;
background-size: contain;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
-webkit-animation: moveSlideshow 30s linear infinite;
animation: moveSlideshow 30s linear infinite;
}
@-webkit-keyframes moveSlideshow {
100% {
-webkit-transform: translateX(-1961px);
transform: translateX(-1961px);
}
}
@keyframes moveSlideshow {
100% {
-webkit-transform: translateX(-1961px);
transform: translateX(-1961px);
}
}
.Careers {
padding-top: 80px;
padding-bottom: 100px;
}
@media (max-width: 640px) {
.Careers {
padding-top: 50px;
padding-bottom: 50px;
}
}
.CareersSection {
display: -ms-grid;
display: grid;
-ms-grid-columns: 1fr 1fr;
grid-template-columns: 1fr 1fr;
grid-column-gap: 20px;
margin: 0px auto;
padding: 0 20px;
}
@media (max-width: 640px) {
.CareersSection {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
}
}
.Details h5 {
margin: 30px auto;
}
.Details p {
font-size: 12px;
line-height: 1.5;
width: 90%;
}
.Details p a {
color: black;
font-weight: bold;
text-decoration: none;
}
.Details p a:hover {
text-decoration: underline;
}
.Jobs {
display: -ms-grid;
display: grid;
-ms-grid-rows: repeat;
grid-template-rows: repeat;
}
.Jobs p {
font-size: 14px;
}
.JobSection h6 {
margin: 20px 0;
}
.JobLinks {
width: 100%;
text-decoration: none;
}
.Button {
margin-bottom: 10px;
border: 1px solid black;
height: 50px;
border-radius: 5px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
width: 100%;
-webkit-transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.Button p {
padding-left: 20px;
font-size: 14px;
text-decoration: none;
color: black;
}
.Button img {
padding-right: 20px;
-webkit-transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.Button:hover {
background-color: #eeeeee;
}
.Button:hover img {
padding-right: 15px;
}
.Footer {
background-color: black;
height: 60px;
position: absolute;
width: 100%;
}
.FooterContainer {
height: 100%;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
padding: 0 20px;
}
.FooterContainer .FooterLeft {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.FooterContainer .FooterLeft img {
height: 1.5rem;
}
.FooterContainer .FooterLeft a {
padding: 0 10px;
text-decoration: none;
color: white;
font-size: 12px;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}
.FooterContainer .FooterLeft a:hover {
color: #cccccc;
}
.FooterContainer .FooterRight {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: end;
-ms-flex-align: end;
align-items: flex-end;
}
.FooterContainer .FooterRight img {
height: 1.2rem;
padding-left: 10px;
-webkit-transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (max-width: 640px) {
.FooterContainer .hide {
display: none;
}
}
.Typist .Cursor {
display: inline-block;
}
.Typist .Cursor--blinking {
opacity: 1;
-webkit-animation: blink 1s linear infinite;
animation: blink 1s linear infinite;
}
@-webkit-keyframes blink {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes blink {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@media (max-width: 640px) {
.Typist {
max-width: 90%;
}
}
/*# sourceMappingURL=index.css.map */ | 16.647514 | 155 | 0.639387 |
6e65d7cda9f8bf29e9228edb7907d3f7461d482f | 493 | asm | Assembly | programs/oeis/035/A035336.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 22 | 2018-02-06T19:19:31.000Z | 2022-01-17T21:53:31.000Z | programs/oeis/035/A035336.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 41 | 2021-02-22T19:00:34.000Z | 2021-08-28T10:47:47.000Z | programs/oeis/035/A035336.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 5 | 2021-02-24T21:14:16.000Z | 2021-08-09T19:48:05.000Z | ; A035336: a(n) = 2*floor(n*phi) + n - 1, where phi = (1+sqrt(5))/2.
; 2,7,10,15,20,23,28,31,36,41,44,49,54,57,62,65,70,75,78,83,86,91,96,99,104,109,112,117,120,125,130,133,138,143,146,151,154,159,164,167,172,175,180,185,188,193,198,201,206,209,214,219,222,227,230,235,240,243,248,253,256,261,264,269,274,277,282,287,290,295,298,303,308,311,316,319,324,329,332,337,342,345,350,353,358,363,366,371,376,379,384,387,392,397,400,405,408,413,418,421
mov $1,$0
seq $1,283233 ; 2*A000201.
add $0,$1
| 70.428571 | 375 | 0.685598 |
297f3d704dd4a5bc595d28894068dc9909f05a51 | 5,391 | sql | SQL | database/src/migrations/release.0.5/populate_caribou_population_unit.sql | bcgov/restoration-tracker | 42e4fbc8e3915813df06a42aa83ff7d295f94bdb | [
"Apache-2.0"
] | null | null | null | database/src/migrations/release.0.5/populate_caribou_population_unit.sql | bcgov/restoration-tracker | 42e4fbc8e3915813df06a42aa83ff7d295f94bdb | [
"Apache-2.0"
] | 66 | 2022-01-06T18:24:37.000Z | 2022-03-31T23:44:58.000Z | database/src/migrations/release.0.5/populate_caribou_population_unit.sql | bcgov/restoration-tracker | 42e4fbc8e3915813df06a42aa83ff7d295f94bdb | [
"Apache-2.0"
] | null | null | null | -- populate_caribou_population_unit.sql
delete from caribou_population_unit;
insert into caribou_population_unit (name, record_effective_date) values ('Atlin', now());
insert into caribou_population_unit (name, record_effective_date) values ('Calendar', now());
insert into caribou_population_unit (name, record_effective_date) values ('Carcross', now());
insert into caribou_population_unit (name, record_effective_date) values ('Chase', now());
insert into caribou_population_unit (name, record_effective_date) values ('Itcha-Ilgachuz', now());
insert into caribou_population_unit (name, record_effective_date) values ('Kennedy Siding', now());
insert into caribou_population_unit (name, record_effective_date) values ('Moberly', now());
insert into caribou_population_unit (name, record_effective_date) values ('Monashee', now());
insert into caribou_population_unit (name, record_effective_date) values ('Chinchaga', now());
insert into caribou_population_unit (name, record_effective_date) values ('Edziza', now());
insert into caribou_population_unit (name, record_effective_date) values ('Finlay', now());
insert into caribou_population_unit (name, record_effective_date) values ('Frog', now());
insert into caribou_population_unit (name, record_effective_date) values ('Gataga', now());
insert into caribou_population_unit (name, record_effective_date) values ('George Mountain', now());
insert into caribou_population_unit (name, record_effective_date) values ('Horseranch', now());
insert into caribou_population_unit (name, record_effective_date) values ('Level-Kawdy', now());
insert into caribou_population_unit (name, record_effective_date) values ('Liard Plateau', now());
insert into caribou_population_unit (name, record_effective_date) values ('Tweedsmuir', now());
insert into caribou_population_unit (name, record_effective_date) values ('Pink Mountain', now());
insert into caribou_population_unit (name, record_effective_date) values ('Barkerville', now());
insert into caribou_population_unit (name, record_effective_date) values ('Burnt Pine', now());
insert into caribou_population_unit (name, record_effective_date) values ('Central Rockies', now());
insert into caribou_population_unit (name, record_effective_date) values ('Central Selkirks', now());
insert into caribou_population_unit (name, record_effective_date) values ('Charlotte Alplands', now());
insert into caribou_population_unit (name, record_effective_date) values ('Columbia North', now());
insert into caribou_population_unit (name, record_effective_date) values ('Columbia South', now());
insert into caribou_population_unit (name, record_effective_date) values ('Frisby Boulder', now());
insert into caribou_population_unit (name, record_effective_date) values ('Graham', now());
insert into caribou_population_unit (name, record_effective_date) values ('Groundhog', now());
insert into caribou_population_unit (name, record_effective_date) values ('Little Rancheria', now());
insert into caribou_population_unit (name, record_effective_date) values ('Maxhamish', now());
insert into caribou_population_unit (name, record_effective_date) values ('Rabbit', now());
insert into caribou_population_unit (name, record_effective_date) values ('Snake-Sahtaneh', now());
insert into caribou_population_unit (name, record_effective_date) values ('Spatsizi', now());
insert into caribou_population_unit (name, record_effective_date) values ('Swan Lake', now());
insert into caribou_population_unit (name, record_effective_date) values ('Takla', now());
insert into caribou_population_unit (name, record_effective_date) values ('Thutade', now());
insert into caribou_population_unit (name, record_effective_date) values ('Tsenaglode', now());
insert into caribou_population_unit (name, record_effective_date) values ('Wolverine', now());
insert into caribou_population_unit (name, record_effective_date) values ('Westside Fort Nelson', now());
insert into caribou_population_unit (name, record_effective_date) values ('Muskwa', now());
insert into caribou_population_unit (name, record_effective_date) values ('Hart Ranges', now());
insert into caribou_population_unit (name, record_effective_date) values ('Narraway', now());
insert into caribou_population_unit (name, record_effective_date) values ('Narrow Lake', now());
insert into caribou_population_unit (name, record_effective_date) values ('North Cariboo', now());
insert into caribou_population_unit (name, record_effective_date) values ('Purcell Central', now());
insert into caribou_population_unit (name, record_effective_date) values ('Purcells South', now());
insert into caribou_population_unit (name, record_effective_date) values ('Quintette', now());
insert into caribou_population_unit (name, record_effective_date) values ('Rainbows', now());
insert into caribou_population_unit (name, record_effective_date) values ('Redrock-Prairie Creek', now());
insert into caribou_population_unit (name, record_effective_date) values ('South Selkirks', now());
insert into caribou_population_unit (name, record_effective_date) values ('Telkwa', now());
insert into caribou_population_unit (name, record_effective_date) values ('Wells Gray North', now());
insert into caribou_population_unit (name, record_effective_date) values ('Wells Gray South', now());
insert into caribou_population_unit (name, record_effective_date) values ('Scott', now()); | 94.578947 | 106 | 0.79911 |
b34dffe7233322163229fd19ac636d12224a6d23 | 1,132 | rb | Ruby | spec/features/idv/max_attempts_spec.rb | s2t2/identity-idp | e2d1361093327b1e5c769939a7a4e05523fd1404 | [
"CC0-1.0"
] | null | null | null | spec/features/idv/max_attempts_spec.rb | s2t2/identity-idp | e2d1361093327b1e5c769939a7a4e05523fd1404 | [
"CC0-1.0"
] | null | null | null | spec/features/idv/max_attempts_spec.rb | s2t2/identity-idp | e2d1361093327b1e5c769939a7a4e05523fd1404 | [
"CC0-1.0"
] | null | null | null | require 'rails_helper'
feature 'IdV max attempts' do
include IdvHelper
scenario 'profile shows failure modal after max attempts', :email, :idv_job, :js do
sign_in_and_2fa_user
visit verify_session_path
max_attempts_less_one.times do
fill_out_idv_form_fail
click_continue
click_button t('idv.modal.button.warning')
expect(current_path).to eq verify_session_result_path
end
fill_out_idv_form_fail
click_continue
expect(page).to have_css('.modal-fail', text: t('idv.modal.sessions.heading'))
end
scenario 'phone shows failure modal after max attempts', :email, :idv_job, :js do
sign_in_and_2fa_user
visit verify_session_path
fill_out_idv_form_ok
click_idv_continue
click_idv_address_choose_phone
max_attempts_less_one.times do
fill_out_phone_form_fail
click_idv_continue
click_button t('idv.modal.button.warning')
expect(current_path).to eq verify_phone_result_path
end
fill_out_phone_form_fail
click_idv_continue
expect(page).to have_css('.modal-fail', text: t('idv.modal.phone.heading'))
end
end
| 25.155556 | 85 | 0.742049 |
f075ae0016f05b776907ec9b3806c42232f69f5d | 68 | kt | Kotlin | src/main/kotlin/com/common/Status.kt | lgoyescondor/SSD_MODULE | d7ecd74fc9796885d6c03261896f9f5f4a86c22c | [
"MIT"
] | null | null | null | src/main/kotlin/com/common/Status.kt | lgoyescondor/SSD_MODULE | d7ecd74fc9796885d6c03261896f9f5f4a86c22c | [
"MIT"
] | null | null | null | src/main/kotlin/com/common/Status.kt | lgoyescondor/SSD_MODULE | d7ecd74fc9796885d6c03261896f9f5f4a86c22c | [
"MIT"
] | 1 | 2018-12-12T20:54:51.000Z | 2018-12-12T20:54:51.000Z | package com.common
data class Status(val id: Int, val name: String) | 22.666667 | 48 | 0.764706 |
0ba12b62e7fa10c396c6633bb470e317da8a4782 | 1,346 | js | JavaScript | node_modules/@react-icons/all-files/io5/IoLogoDiscord.esm.js | syazwanirahimin/dotcom | 162acf4500655ec965d27bd1e45ef0415963d346 | [
"MIT"
] | null | null | null | node_modules/@react-icons/all-files/io5/IoLogoDiscord.esm.js | syazwanirahimin/dotcom | 162acf4500655ec965d27bd1e45ef0415963d346 | [
"MIT"
] | null | null | null | node_modules/@react-icons/all-files/io5/IoLogoDiscord.esm.js | syazwanirahimin/dotcom | 162acf4500655ec965d27bd1e45ef0415963d346 | [
"MIT"
] | null | null | null | // THIS FILE IS AUTO GENERATED
import { GenIcon } from '../lib';
export function IoLogoDiscord (props) {
return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 512 512"},"child":[{"tag":"path","attr":{"d":"M464 66.52A50 50 0 00414.12 17L97.64 16A49.65 49.65 0 0048 65.52V392c0 27.3 22.28 48 49.64 48H368l-13-44 109 100zM324.65 329.81s-8.72-10.39-16-19.32C340.39 301.55 352.5 282 352.5 282a139 139 0 01-27.85 14.25 173.31 173.31 0 01-35.11 10.39 170.05 170.05 0 01-62.72-.24 184.45 184.45 0 01-35.59-10.4 141.46 141.46 0 01-17.68-8.21c-.73-.48-1.45-.72-2.18-1.21-.49-.24-.73-.48-1-.48-4.36-2.42-6.78-4.11-6.78-4.11s11.62 19.09 42.38 28.26c-7.27 9.18-16.23 19.81-16.23 19.81-53.51-1.69-73.85-36.47-73.85-36.47 0-77.06 34.87-139.62 34.87-139.62 34.87-25.85 67.8-25.12 67.8-25.12l2.42 2.9c-43.59 12.32-63.44 31.4-63.44 31.4s5.32-2.9 14.28-6.77c25.91-11.35 46.5-14.25 55-15.21a24 24 0 014.12-.49 205.62 205.62 0 0148.91-.48 201.62 201.62 0 0172.89 22.95s-19.13-18.15-60.3-30.45l3.39-3.86s33.17-.73 67.81 25.16c0 0 34.87 62.56 34.87 139.62 0-.28-20.35 34.5-73.86 36.19z"}},{"tag":"path","attr":{"d":"M212.05 218c-13.8 0-24.7 11.84-24.7 26.57s11.14 26.57 24.7 26.57c13.8 0 24.7-11.83 24.7-26.57.25-14.76-10.9-26.57-24.7-26.57zm88.38 0c-13.8 0-24.7 11.84-24.7 26.57s11.14 26.57 24.7 26.57c13.81 0 24.7-11.83 24.7-26.57S314 218 300.43 218z"}}]})(props);
};
| 224.333333 | 1,237 | 0.659733 |
8e7bfc1f3b078daae4a80a5d0b4bb3007ac99c75 | 50 | rb | Ruby | app/models/user_blacklisted_tag.rb | bluelovers/Danbooru | 655ffd1174947a0c415de9aa0e30147235bf4a3e | [
"BSD-2-Clause-FreeBSD"
] | 3 | 2018-11-04T08:16:23.000Z | 2019-12-06T10:17:29.000Z | app/models/user_blacklisted_tag.rb | neplus/moebooru | bfd91cf63c8e9421354dce46378dd62fe90ab0b2 | [
"0BSD"
] | null | null | null | app/models/user_blacklisted_tag.rb | neplus/moebooru | bfd91cf63c8e9421354dce46378dd62fe90ab0b2 | [
"0BSD"
] | 1 | 2019-12-06T10:17:31.000Z | 2019-12-06T10:17:31.000Z | class UserBlacklistedTag < ActiveRecord::Base
end
| 16.666667 | 45 | 0.84 |
23706d933c27ae03835c4217b2f1c101093bcba1 | 760 | kt | Kotlin | src/main/kotlin/net/jibini/check/engine/timing/GlobalDeltaSync.kt | zgoethel/CheckEngine | 6a71ff5903d3bc0d1c0438235104637359244a63 | [
"MIT"
] | 2 | 2021-07-01T16:34:20.000Z | 2022-01-11T01:37:47.000Z | src/main/kotlin/net/jibini/check/engine/timing/GlobalDeltaSync.kt | zgoethel/CheckEngine | 6a71ff5903d3bc0d1c0438235104637359244a63 | [
"MIT"
] | null | null | null | src/main/kotlin/net/jibini/check/engine/timing/GlobalDeltaSync.kt | zgoethel/CheckEngine | 6a71ff5903d3bc0d1c0438235104637359244a63 | [
"MIT"
] | null | null | null | package net.jibini.check.engine.timing
import net.jibini.check.engine.RegisterObject
/**
* Ensures that all auto-resetting [timers][DeltaTimer] reset in sync
* with each other. The sync is [performed][globalAutoUpdate] once per
* frame.
*
* @author Zach Goethel
*/
@RegisterObject
class GlobalDeltaSync
{
/**
* The global timer on which to base all child timers.
*/
private val deltaTimer = DeltaTimer(false)
/**
* Delta time result of all synced auto-resetting timers.
*/
var delta: Double = 0.0
/**
* Updates the internal timer, thus updating all auto-resetting
* timers on a global scope.
*/
fun globalAutoUpdate()
{
delta = deltaTimer.delta
deltaTimer.reset()
}
} | 22.352941 | 70 | 0.656579 |
b3e4296ac49b9251e61133e5d8e1077679c218ab | 105 | rb | Ruby | test_site/config/initializers/orms.rb | 27crags/scaffolding_extensions | 05cf0c7ccbca6aa3ab63301e0d5200c7a0d14ad4 | [
"MIT"
] | 4 | 2015-11-05T12:09:17.000Z | 2020-04-03T10:51:20.000Z | test_site/config/initializers/orms.rb | 27crags/scaffolding_extensions | 05cf0c7ccbca6aa3ab63301e0d5200c7a0d14ad4 | [
"MIT"
] | null | null | null | test_site/config/initializers/orms.rb | 27crags/scaffolding_extensions | 05cf0c7ccbca6aa3ab63301e0d5200c7a0d14ad4 | [
"MIT"
] | 2 | 2018-02-09T22:21:49.000Z | 2021-07-13T07:14:19.000Z | SE_TEST_FRAMEWORK='rails'
$: << '.'
require 'datamapper_setup'
require 'sequel_setup'
require 'se_setup'
| 17.5 | 26 | 0.752381 |
95bbe17f5755b4fac3eba263913f2209e8cdfa13 | 5,671 | css | CSS | submissions/ses3332002/memory-game/style.css | Roophee/frontend-2021-homeworks | 10f049fa24e7e53a4f6c8fc438b2d649c8a0085a | [
"RSA-MD"
] | null | null | null | submissions/ses3332002/memory-game/style.css | Roophee/frontend-2021-homeworks | 10f049fa24e7e53a4f6c8fc438b2d649c8a0085a | [
"RSA-MD"
] | null | null | null | submissions/ses3332002/memory-game/style.css | Roophee/frontend-2021-homeworks | 10f049fa24e7e53a4f6c8fc438b2d649c8a0085a | [
"RSA-MD"
] | null | null | null | @font-face {
font-family: theme1_font;
src: url('fonts/helveticaneuecyr-light-webfont.woff2') format('woff2');
font-weight: bold;
font-style: normal;
}
@font-face {
font-family: theme2_font;
src: url('fonts/Bellota-Regular.woff2') format('woff2');
font-weight: normal;
font-style: normal;
}
body {
margin: 0;
padding: 0;
box-sizing: border-box;
color: var(--color);
background-color: var(--background_color);
font-size: var(--base_font_size);
font-family: var(--font_family);
min-height: 100vh;
display: grid;
grid-template-rows: auto 1fr auto;
}
.theme1 {
--color: #f6da73;
--background_color: #3e5336;
--decor_color: #e55b7e;
--base_font_size: 16px;
--font_family: theme1_font;
}
.theme2 {
--color: #f4f6ec;
--background_color: #2d0c03;
--decor_color: #f8b786;
--base_font_size: 16px;
--font_family: theme2_font;
}
header {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
padding: 10px;
}
button {
height: 32px;
}
.selector {
display: flex;
flex-wrap: nowrap;
justify-content: center;
align-items: center;
margin: 10px;
}
.caption {
text-align: left;
font-size: var(--base_font_size);
margin-right: 10px;
}
.theme_selector__button, .start_button {
width: 80px;
margin: 3px;
padding: 5px 0;
color: var(--color);
background-color: var(--background_color);
font-size: calc(var(--base_font_size) - 1);
font-family: var(--font_family);
border: 2px solid var(--decor_color);
border-radius: 3px;
cursor: pointer;
flex-shrink: 0;
}
input[type=radio] {
position: absolute;
-webkit-appearance: none;
appearance: none;
}
label img {
width: 60px;
height: 60px;
margin: 3px;
padding: 0;
border-radius: 3px;
border: 2px solid transparent;
flex-shrink: 0;
cursor: pointer;
}
input[type=radio]:checked + label img {
border: 2px solid var(--decor_color);
}
select {
-webkit-appearance: none;
appearance: none;
padding: 3px 28px 3px 10px;
border: 2px solid var(--decor_color);
border-radius: 3px;
font-family: inherit;
font-size: inherit;
background: var(--background_color);
color: var(--color);
}
.select_wrapper {
position: relative;
}
.select_wrapper::after {
content: '<>';
position: absolute;
top: 6px;
right: 5px;
transform: rotate(90deg);
font-size: 15px;
color: var(--decor_color);
pointer-events: none;
}
.select_wrapper::before {
content: '';
position: absolute;
top: 6px;
right: 24px;
height: 20px;
border-left: solid 1px var(--decor_color);
pointer-events: none;
}
option {
background-color: var(--color);
color: var(--background_color);
}
.start_button {
margin: 10px;
color: var(--color);
background-color: var(--background_color);
font-size: var(--base_font_size);
font-family: var(--font_family);
font-weight: bold;
}
.start_button:focus, .start_button:hover, .popup_hail__button:focus, .popup_hail__button:hover {
color: var(--background_color);
border: 2px solid var(--color);
background-color: var(--decor_color);
}
.invisible {
height: 1px;
width: 1px;
position: absolute;
overflow: hidden;
clip: rect(0 0 0 0);
}
.form_item-desabled {
filter: grayscale();
pointer-events: none;
}
.game_field {
text-align: center;
margin: 20px 0;
}
.game_area {
display: inline-grid;
width: min(90vw, 770px);
grid-gap: 10px;
}
.game_area-3columns {
grid-template-columns: repeat(3, 1fr);
}
.game_area-4columns {
grid-template-columns: repeat(4, 1fr);
}
.game_area-5columns {
grid-template-columns: repeat(5, 1fr);
}
.game_area-6columns {
grid-template-columns: repeat(6, 1fr);
}
.card {
position: relative;
width: min(100%, 120px);
height: 120px;
transform-style: preserve-3d;
perspective: 300px;
transition: 0.5s;
margin: 0;
padding: 0;
border: none;
outline: none;
background-color: transparent;
box-sizing: border-box;
cursor: pointer;
}
.card:focus {
outline: var(--color) solid thin;
outline-offset: 3px;
}
.card__front, .card__back {
position: absolute;
top: 0;
left: 0;
box-sizing: border-box;
width: min(100%, 120px);
height: 120px;
border-radius: 3px;
border: 3px solid var(--decor_color);
backface-visibility: hidden;
transform: rotateX(0deg);
transition: 0.5s;
background-position: center;
background-repeat: no-repeat;
pointer-events: none;
}
.card__back {
transform: rotateX(180deg);
}
.card-flip .card__front {
transform: rotateX(-180deg) !important;
}
.card-flip .card__back {
transform: rotateX(0deg) !important;
}
.card-vanish {
opacity: 0;
pointer-events: none;
transition: 0.7s;
}
footer {
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
}
.icon {
height: 28px;
width: 28px;
object-fit: cover;
margin: 6px;
}
a {
font-size: 0;
text-decoration: none;
}
.popup_hail__window {
position: absolute;
width: 200px;
height: 140px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 5;
background-color: var(--background_color);
color: var(--color);
border-radius: 3px;
border: 2px solid var(--decor_color);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-shadow: 0px 0px 13px 1px var(--color);
}
.popup_hail__button {
margin-top: 10px;
padding: 0 10px;
background-color: inherit;
color: inherit;
border-radius: 3px;
border: 2px solid var(--decor_color);
}
.popup_hail {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: #00000090;
}
.popup_hail-hide {
display: none;
}
.card-locked {
pointer-events: none;
}
| 17.666667 | 96 | 0.669547 |
475989581c28e5e7dc249a4f4e2532749a548428 | 717 | html | HTML | layouts/partials/icons/cloud-moon.html | bugoio/bugo-font-awesome | b13de4a9447710e87feb9aaeb455c1b51fb93c39 | [
"MIT"
] | null | null | null | layouts/partials/icons/cloud-moon.html | bugoio/bugo-font-awesome | b13de4a9447710e87feb9aaeb455c1b51fb93c39 | [
"MIT"
] | null | null | null | layouts/partials/icons/cloud-moon.html | bugoio/bugo-font-awesome | b13de4a9447710e87feb9aaeb455c1b51fb93c39 | [
"MIT"
] | null | null | null | <svg tabindex="-1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"tabindex="-1"><path d="M342.8 352.7c5.7-9.6 9.2-20.7 9.2-32.7 0-35.3-28.7-64-64-64-17.2 0-32.8 6.9-44.3 17.9-16.3-29.6-47.5-49.9-83.7-49.9-53 0-96 43-96 96 0 2 .5 3.8.6 5.7C27.1 338.8 0 374.1 0 416c0 53 43 96 96 96h240c44.2 0 80-35.8 80-80 0-41.9-32.3-75.8-73.2-79.3zm222.5-54.3c-93.1 17.7-178.5-53.7-178.5-147.7 0-54.2 29-104 76.1-130.8 7.3-4.1 5.4-15.1-2.8-16.7C448.4 1.1 436.7 0 425 0 319.1 0 233.1 85.9 233.1 192c0 8.5.7 16.8 1.8 25 5.9 4.3 11.6 8.9 16.7 14.2 11.4-4.7 23.7-7.2 36.4-7.2 52.9 0 96 43.1 96 96 0 3.6-.2 7.2-.6 10.7 23.6 10.8 42.4 29.5 53.5 52.6 54.4-3.4 103.7-29.3 137.1-70.4 5.3-6.5-.5-16.1-8.7-14.5z" tabindex="-1"/></svg> | 717 | 717 | 0.615063 |
47f61ad13ad8ccff87df2913729c0dda1abd97e3 | 495 | css | CSS | assets/css/style.css | carloscjm/streamer | b02c77af3217f22291a0cfc381a016030ae47d12 | [
"MIT"
] | null | null | null | assets/css/style.css | carloscjm/streamer | b02c77af3217f22291a0cfc381a016030ae47d12 | [
"MIT"
] | null | null | null | assets/css/style.css | carloscjm/streamer | b02c77af3217f22291a0cfc381a016030ae47d12 | [
"MIT"
] | null | null | null | .modal-dialog{
max-width: 100%;
transform: none !important;
}
.usersHome {
background-color: red;
padding-bottom: 20px;
padding-top: 20px;
margin-right: 20px;
cursor: pointer;
text-align: center;
}
.usersHome:hover {
background-color: #9b1e1e;
}
@media screen and (max-width: 600px) {
.modal-dialog{
transform: translate(0, 0) !important;
}
#video
{
position: initial !important;
width: 100% !important;
}
} | 18.333333 | 46 | 0.591919 |
ef6569ee88eafec6561c7a0b987d36cf3d207c67 | 672 | asm | Assembly | oeis/097/A097743.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 11 | 2021-08-22T19:44:55.000Z | 2022-03-20T16:47:57.000Z | oeis/097/A097743.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 9 | 2021-08-29T13:15:54.000Z | 2022-03-09T19:52:31.000Z | oeis/097/A097743.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 3 | 2021-08-22T20:56:47.000Z | 2021-09-29T06:26:12.000Z | ; A097743: Numbers of the form 3*2^(p - 1) - 1 where p is prime.
; 5,11,47,191,3071,12287,196607,786431,12582911,805306367,3221225471,206158430207,3298534883327,13194139533311,211106232532991,13510798882111487,864691128455135231,3458764513820540927,221360928884514619391,3541774862152233910271,14167099448608935641087,906694364710971881029631,14507109835375550096474111,928455029464035206174343167,237684487542793012780631851007,3802951800684688204490109616127,15211807202738752817960438464511,243388915243820045087367015432191,973555660975280180349468061728767
seq $0,6005 ; The odd prime numbers together with 1.
trn $0,2
mov $2,2
pow $2,$0
mov $0,$2
mul $0,6
sub $0,1
| 61.090909 | 496 | 0.857143 |
388abc89ceaa198090818bccc86846adb6f0ec62 | 3,675 | c | C | examples/old_io/full_func_io.c | swils/verifast | b0bdb6b5bb49cb6a6ae5457e703ee3eea9f3463e | [
"MIT"
] | 272 | 2016-01-28T16:01:28.000Z | 2022-03-10T11:53:19.000Z | examples/old_io/full_func_io.c | swils/verifast | b0bdb6b5bb49cb6a6ae5457e703ee3eea9f3463e | [
"MIT"
] | 207 | 2016-01-28T16:03:17.000Z | 2022-03-11T14:38:58.000Z | examples/old_io/full_func_io.c | DriesVuylsteke/verifast | 79e814ad7236a7aa99424a03799d27b73b71c4ce | [
"MIT"
] | 59 | 2016-04-03T17:52:17.000Z | 2022-01-28T11:35:57.000Z | /*@
inductive io_action =
getchar_action
| getchar_return_action(int)
| putchar_action(char)
| putchar_return_action;
predicate world<s>(s state, fixpoint(s, io_action, bool) allowed, fixpoint(s, io_action, s) next);
@*/
int getchar/*@ <s> @*/();
//@ requires world<s>(?s, ?allowed, ?next) &*& allowed(s, getchar_action) == true;
/*@
ensures
allowed(next(s, getchar_action), getchar_return_action(result)) == true &*&
world<s>(next(next(s, getchar_action), getchar_return_action(result)), allowed, next);
@*/
void putchar/*@ <s> @*/(char c);
//@ requires world<s>(?s, ?allowed, ?next) &*& allowed(s, putchar_action(c)) == true;
/*@
ensures
allowed(next(s, putchar_action(c)), putchar_return_action) == true &*&
world<s>(next(next(s, putchar_action(c)), putchar_return_action), allowed, next);
@*/
// helloworld
// The LTS state is the list of characters that have yet to be written.
/*@
fixpoint bool helloworld_allowed(list<char> s, io_action a) {
switch (a) {
case getchar_action: return false;
case getchar_return_action(result): return true;
case putchar_action(c): return s != nil && head(s) == c;
case putchar_return_action: return true;
}
}
fixpoint list<char> helloworld_next(list<char> s, io_action a) {
switch (a) {
case getchar_action: return s;
case getchar_return_action(result): return s;
case putchar_action(c): return tail(s);
case putchar_return_action: return s;
}
}
@*/
void helloworld()
//@ requires world<list<char> >(cons('H', cons('e', /*...*/ cons('\n', nil))), helloworld_allowed, helloworld_next);
//@ ensures world(nil, helloworld_allowed, helloworld_next);
{
putchar('H');
putchar('e');
// ...
putchar('\n');
}
// cat
/*@
fixpoint bool is_suffix_of<t>(list<t> xs, list<t> ys) {
switch (ys) {
case nil: return xs == ys;
case cons(y, ys0): return xs == ys || is_suffix_of(xs, ys0);
}
}
inductive cat_state = cat_state(bool eof, list<char> read, list<char> written);
fixpoint bool cat_allowed(cat_state s, io_action a) {
switch (s) {
case cat_state(eof, read, written): return
switch (a) {
case getchar_action: return !eof;
case getchar_return_action(result): return true;
case putchar_action(c): return is_suffix_of(cons(c, written), read);
case putchar_return_action: return true;
};
}
}
fixpoint cat_state cat_next(cat_state s, io_action a) {
switch (s) {
case cat_state(eof, read, written): return
switch (a) {
case getchar_action: return s;
case getchar_return_action(result): return 0 <= result ? cat_state(eof, cons((char)result, read), written) : cat_state(true, read, written);
case putchar_action(c): return cat_state(eof, read, cons(c, written));
case putchar_return_action: return s;
};
}
}
@*/
void cat()
//@ requires world(cat_state(false, nil, nil), cat_allowed, cat_next);
//@ ensures world<cat_state>(?s, cat_allowed, cat_next) &*& switch (s) { case cat_state(eof, read, written): return eof == true &*& written == read; };
{
for (;;)
//@ invariant world<cat_state>(?s, cat_allowed, cat_next) &*& switch (s) { case cat_state(eof, read, written): return !eof &*& written == read; };
{
int c = getchar();
if (c < 0) return;
putchar((char)c);
}
}
| 31.681034 | 157 | 0.588844 |
74b3475ca867b8286d27ee5360eaf8d1a737711b | 345 | js | JavaScript | LemonadeStand.Web/Scripts/LemonadeStand/focusSelect.js | lars-erik/lemonade-stand | 83f37747e3ef5aa6d527ce744b0131dc7c2957d2 | [
"MIT"
] | 6 | 2017-12-16T21:12:05.000Z | 2021-06-14T15:47:57.000Z | LemonadeStand.Web/Scripts/LemonadeStand/focusSelect.js | kevinmel2000/lemonade-stand-1 | 83f37747e3ef5aa6d527ce744b0131dc7c2957d2 | [
"MIT"
] | null | null | null | LemonadeStand.Web/Scripts/LemonadeStand/focusSelect.js | kevinmel2000/lemonade-stand-1 | 83f37747e3ef5aa6d527ce744b0131dc7c2957d2 | [
"MIT"
] | 2 | 2015-11-09T20:11:33.000Z | 2019-09-26T06:52:53.000Z | (function() {
angular.module("lemonade")
.directive("ngFocusSelect", function() {
return {
link: function(scope, element, attrs) {
$(element).on("focus", function() {
$(this).select();
});
}
}
});
}()); | 24.642857 | 55 | 0.365217 |
4ac87f094d3b581c3ab92e6cafc2e99bae670058 | 45 | sql | SQL | src/main/resources/db/changesets/books/20201025/add_tst_column.sql | Khromushkin/study-kotlin-liquibase | 3c1f43208dd0f943621eb3707c13d759bd761aaf | [
"MIT"
] | null | null | null | src/main/resources/db/changesets/books/20201025/add_tst_column.sql | Khromushkin/study-kotlin-liquibase | 3c1f43208dd0f943621eb3707c13d759bd761aaf | [
"MIT"
] | null | null | null | src/main/resources/db/changesets/books/20201025/add_tst_column.sql | Khromushkin/study-kotlin-liquibase | 3c1f43208dd0f943621eb3707c13d759bd761aaf | [
"MIT"
] | null | null | null | alter table books
add column tst varchar; | 22.5 | 27 | 0.755556 |
ead8cbdda754fbed9e92c676aa18c078b6507033 | 788 | sql | SQL | db/sql/6063__drop_and_create_f_amk_keksintoilmoitukset.sql | CSC-IT-Center-for-Science/antero | 2835d7fd07cd7399a348033a6230d1b16634fb3b | [
"MIT"
] | 2 | 2016-12-27T09:44:16.000Z | 2017-02-16T09:23:13.000Z | db/sql/6063__drop_and_create_f_amk_keksintoilmoitukset.sql | CSC-IT-Center-for-Science/antero | 2835d7fd07cd7399a348033a6230d1b16634fb3b | [
"MIT"
] | null | null | null | db/sql/6063__drop_and_create_f_amk_keksintoilmoitukset.sql | CSC-IT-Center-for-Science/antero | 2835d7fd07cd7399a348033a6230d1b16634fb3b | [
"MIT"
] | null | null | null | USE [ANTERO]
GO
/****** Object: Table [dw].[f_amk_keksintoilmoitukset] Script Date: 30.3.2022 16:19:47 ******/
DROP TABLE [dw].[f_amk_keksintoilmoitukset]
GO
/****** Object: Table [dw].[f_amk_keksintoilmoitukset] Script Date: 30.3.2022 16:19:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dw].[f_amk_keksintoilmoitukset](
[d_amk_id] [int] NULL,
[d_organisaatioluokitus_id] [int] NULL,
[d_koulutusala_id] [int] NULL,
[d_ohjauksenala_id] [int] NULL,
[d_julkaisun_kansainvalisyys_id] [int] NULL,
[d_tieteenala_id] [int] NULL,
[vuosi] [int] NULL,
[h21] [int] NULL,
[h22] [int] NULL,
[h23] [int] NULL,
[h24] [int] NULL,
[loadtime] [datetime] NULL,
[source] [varchar](55) NULL,
[username] [varchar](55) NULL
) ON [PRIMARY]
GO
USE [ANTERO] | 22.514286 | 98 | 0.678934 |
f03f530e1dc98bcc4544ec79667fa0181fc768d4 | 373 | py | Python | tests/data_elements/test_other_double.py | GalBenZvi/dicom_parser | fc3e892ebf99c4e5d62cb5e7de7df341baf445fe | [
"MIT"
] | 11 | 2020-08-08T21:41:54.000Z | 2021-07-27T12:48:31.000Z | tests/data_elements/test_other_double.py | GalBenZvi/dicom_parser | fc3e892ebf99c4e5d62cb5e7de7df341baf445fe | [
"MIT"
] | 45 | 2020-03-03T14:32:16.000Z | 2021-07-30T16:42:17.000Z | tests/data_elements/test_other_double.py | GalBenZvi/dicom_parser | fc3e892ebf99c4e5d62cb5e7de7df341baf445fe | [
"MIT"
] | 6 | 2021-10-19T09:19:22.000Z | 2022-03-13T19:26:10.000Z | """
Definition of the :class:`OtherDoubleTestCase` class.
"""
from dicom_parser.data_elements.other_double import OtherDouble
from tests.test_data_element import DataElementTestCase
class OtherDoubleTestCase(DataElementTestCase):
"""
Tests for the
:class:`~dicom_parser.data_elements.other_double.OtherDouble`
class.
"""
TEST_CLASS = OtherDouble
| 23.3125 | 65 | 0.766756 |
c0216daebdb17d72f14345eb720a74fe6e5d9876 | 121 | sql | SQL | src/test/resources/sql/update/c753c092.sql | Shuttl-Tech/antlr_psql | fcf83192300abe723f3fd3709aff5b0c8118ad12 | [
"MIT"
] | 66 | 2018-06-15T11:34:03.000Z | 2022-03-16T09:24:49.000Z | src/test/resources/sql/update/c753c092.sql | Shuttl-Tech/antlr_psql | fcf83192300abe723f3fd3709aff5b0c8118ad12 | [
"MIT"
] | 13 | 2019-03-19T11:56:28.000Z | 2020-08-05T04:20:50.000Z | src/test/resources/sql/update/c753c092.sql | Shuttl-Tech/antlr_psql | fcf83192300abe723f3fd3709aff5b0c8118ad12 | [
"MIT"
] | 28 | 2019-01-05T19:59:02.000Z | 2022-03-24T11:55:50.000Z | -- file:rules.sql ln:233 expect:true
update rtest_v1 set a = rtest_t3.a + 20 from rtest_t3 where rtest_v1.b = rtest_t3.b
| 40.333333 | 83 | 0.752066 |
38ac832a39616dfb928a4b22a1155b02007454cf | 9,388 | h | C | src/main/jstd/string/string_libc.h | shines77/jstd | a9fe267ac692162af53e16515a3552b45b6fd55a | [
"MIT"
] | null | null | null | src/main/jstd/string/string_libc.h | shines77/jstd | a9fe267ac692162af53e16515a3552b45b6fd55a | [
"MIT"
] | null | null | null | src/main/jstd/string/string_libc.h | shines77/jstd | a9fe267ac692162af53e16515a3552b45b6fd55a | [
"MIT"
] | 1 | 2021-06-21T12:33:06.000Z | 2021-06-21T12:33:06.000Z |
#ifndef JSTD_STRING_LIBC_H
#define JSTD_STRING_LIBC_H
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include "jstd/basic/stddef.h"
#include "jstd/basic/stdint.h"
#include "jstd/basic/stdsize.h"
#include <string.h>
#include <wchar.h>
#include <assert.h>
#include <cstdint>
#include <cstddef> // For std::size_t
#include <cstring>
#include <cwchar>
#include <string>
#include "jstd/string/string_def.h"
#if defined(_WIN32) || defined(WIN32) || defined(OS_WINDOWS) || defined(__WINDOWS__)
// TODO:
#endif // _WIN32
namespace jstd {
namespace libc {
///////////////////////////////////////////////////////////////////////////////
// libc::StrLen<CharTy>()
///////////////////////////////////////////////////////////////////////////////
template <typename CharTy>
inline std::size_t StrLen(const CharTy * str) {
assert(str != nullptr);
const CharTy * start = str;
while (CharTy(*str) != CharTy(0)) {
str++;
}
assert(str >= start);
return std::size_t(str - start);
}
template <>
inline std::size_t StrLen(const char * str) {
assert(str != nullptr);
return std::strlen(str);
}
template <>
inline std::size_t StrLen(const wchar_t * str) {
assert(str != nullptr);
return std::wcslen(str);
}
template <typename CharTy>
inline std::size_t StrLenSafe(const CharTy * str) {
if (likely(str != nullptr))
return StrLen(str);
else
return 0;
}
///////////////////////////////////////////////////////////////////////////////
// libc::StrEqual<CharTy>()
///////////////////////////////////////////////////////////////////////////////
template <typename CharTy>
inline
bool StrEqual(const CharTy * str1, const CharTy * str2) {
assert(str1 != nullptr);
assert(str2 != nullptr);
while (*str1 == *str2) {
if (unlikely(((*str1) & (*str2)) == 0)) {
return true;
}
str1++;
str2++;
}
return false;
}
template <>
inline
bool StrEqual(const char * str1, const char * str2) {
assert(str1 != nullptr);
assert(str2 != nullptr);
return (std::strcmp(str1, str2) == 0);
}
template <>
inline
bool StrEqual(const wchar_t * str1, const wchar_t * str2) {
assert(str1 != nullptr);
assert(str2 != nullptr);
return (std::wcscmp(str1, str2) == 0);
}
template <typename CharTy>
inline
bool StrEqual(const CharTy * str1, const CharTy * str2, std::size_t count) {
assert(str1 != nullptr);
assert(str2 != nullptr);
while (*str1 == *str2) {
count--;
if (unlikely(count == 0)) {
return true;
}
if (unlikely(((*str1) & (*str2)) == 0)) {
return true;
}
str1++;
str2++;
}
return false;
}
template <>
inline
bool StrEqual(const char * str1, const char * str2, std::size_t count) {
assert(str1 != nullptr);
assert(str2 != nullptr);
return (std::strncmp(str1, str2, count) == 0);
}
template <>
inline
bool StrEqual(const wchar_t * str1, const wchar_t * str2, std::size_t count) {
assert(str1 != nullptr);
assert(str2 != nullptr);
return (std::wcsncmp(str1, str2, count) == 0);
}
template <typename CharTy>
inline
bool StrEqual(const CharTy * str1, std::size_t len1, const CharTy * str2, std::size_t len2) {
assert(str1 != nullptr);
assert(str2 != nullptr);
if (likely(len1 != len2)) {
// The length of between str1 and str2 is not equal.
return false;
}
else {
if (likely(str1 != str2)) {
return StrEqual(str1, str2, len1);
}
else {
// The str1 and str2 is a same string.
return true;
}
}
}
template <typename StringTy>
inline
bool StrEqualUnsafe(const StringTy & str1, const StringTy & str2) {
return StrEqual(str1.data(), str1.size(), str2.data(), str2.size());
}
////////////////////////// libc::StrEqual<CharTy> - Safe //////////////////////////////
template <typename CharTy>
inline
bool StrEqualSafe(const CharTy * str1, const CharTy * str2, std::size_t count) {
if (likely(count != 0)) {
if (likely(str1 != nullptr)) {
if (likely(str2 != nullptr)) {
assert(str1 != nullptr && str2 != nullptr);
return StrEqual(str1, str2, count);
}
else {
assert(str1 != nullptr && str2 == nullptr);
return false;
}
}
else {
assert(str1 == nullptr);
return (str2 == nullptr);
}
}
else {
// All strings of length is 0, see it as a empty string.
return true;
}
}
template <typename CharTy>
inline
bool StrEqualSafe(const CharTy * str1, std::size_t len1, const CharTy * str2, std::size_t len2) {
if (likely(len1 != len2)) {
// The length of str1 and str2 is different, the string must be not equal.
return false;
}
else {
if (likely(str1 != str2)) {
return StrEqualSafe(str1, str2, len1);
}
else {
// The str1 and str2 is a same string.
return true;
}
}
}
template <typename StringTy>
inline
bool StrEqualSafe(const StringTy & str1, const StringTy & str2) {
return StrEqualSafe(str1.c_str(), str1.size(), str2.c_str(), str2.size());
}
///////////////////////////////////////////////////////////////////////////////
// libc::StrCmp<CharTy>()
///////////////////////////////////////////////////////////////////////////////
template <typename CharTy>
inline
int StrCmp(const CharTy * str1, const CharTy * str2) {
while (*str1 == *str2) {
if (unlikely(((*str1) & (*str2)) == 0)) {
return CompareResult::IsEqual;
}
str1++;
str2++;
}
if (*str1 > *str2)
return CompareResult::IsBigger;
else
return CompareResult::IsSmaller;
}
template <>
inline
int StrCmp(const char * str1, const char * str2) {
return std::strcmp(str1, str2);
}
template <>
inline
int StrCmp(const wchar_t * str1, const wchar_t * str2) {
return std::wcscmp(str1, str2);
}
template <typename CharTy>
inline
int StrCmp(const CharTy * str1, const CharTy * str2, std::size_t count) {
while (*str1 == *str2) {
count--;
if (unlikely(count == 0)) {
return CompareResult::IsEqual;
}
if (unlikely(((*str1) & (*str2)) == 0)) {
return CompareResult::IsEqual;
}
str1++;
str2++;
}
if (*str1 > *str2)
return CompareResult::IsBigger;
else
return CompareResult::IsSmaller;
}
template <>
inline
int StrCmp(const char * str1, const char * str2, std::size_t count) {
return std::strncmp(str1, str2, count);
}
template <>
inline
int StrCmp(const wchar_t * str1, const wchar_t * str2, std::size_t count) {
return std::wcsncmp(str1, str2, count);
}
template <typename CharTy>
inline
int StrCmp(const CharTy * str1, std::size_t len1, const CharTy * str2, std::size_t len2) {
assert(str1 != nullptr);
assert(str2 != nullptr);
std::size_t count = (len1 <= len2) ? len1 : len2;
int compare = StrCmp(str1, str2, count);
if (likely(compare != 0)) {
return compare;
}
else {
if (len1 > len2)
return CompareResult::IsBigger;
else if (len1 < len2)
return CompareResult::IsSmaller;
else
return CompareResult::IsEqual;
}
}
template <typename StringTy>
inline
int StrCmpUnsafe(const StringTy & str1, const StringTy & str2) {
return StrCmp(str1.data(), str1.size(), str2.data(), str2.size());
}
////////////////////////// libc::StrCmp<CharTy> - Safe /////////////////////////////
template <typename CharTy>
inline
int StrCmpSafe(const CharTy * str1, const CharTy * str2, std::size_t count) {
if (likely(count != 0)) {
if (likely(str1 != nullptr)) {
if (likely(str2 != nullptr)) {
assert(str1 != nullptr && str2 != nullptr);
return StrCmp(str1, str2, count);
}
else {
assert(str1 != nullptr && str2 == nullptr);
return CompareResult::IsBigger;
}
}
else {
assert(str1 == nullptr);
return ((str2 != nullptr) ? CompareResult::IsSmaller : CompareResult::IsEqual);
}
}
else {
// All strings of length is 0, see it as a empty string.
return CompareResult::IsEqual;
}
}
template <typename CharTy>
inline
int StrCmpSafe(const CharTy * str1, std::size_t len1, const CharTy * str2, std::size_t len2) {
if (likely(str1 != nullptr)) {
if (likely(str2 != nullptr)) {
assert(str1 != nullptr && str2 != nullptr);
return StrCmp(str1, len1, str2, len2);
}
else {
assert(str1 != nullptr && str2 == nullptr);
return ((len1 != 0) ? CompareResult::IsBigger : CompareResult::IsEqual);
}
}
else {
assert(str1 == nullptr);
return ((str2 == nullptr || len2 == 0) ? CompareResult::IsEqual : CompareResult::IsSmaller);
}
}
template <typename StringTy>
inline
int StrCmpSafe(const StringTy & str1, const StringTy & str2) {
return StrCmpSafe(str1.c_str(), str1.size(), str2.c_str(), str2.size());
}
} // namespace libc
} // namespace jstd
#endif // JSTD_STRING_LIBC_H
| 25.720548 | 100 | 0.54559 |
3461fdb69200be886b46a7e834d17b27042e497b | 426 | asm | Assembly | programs/oeis/101/A101926.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | programs/oeis/101/A101926.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | programs/oeis/101/A101926.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | ; A101926: a(n) = 2^A101925(n).
; 2,4,16,32,256,512,2048,4096,65536,131072,524288,1048576,8388608,16777216,67108864,134217728,4294967296,8589934592,34359738368,68719476736,549755813888,1099511627776,4398046511104,8796093022208
mov $2,7
mov $3,$0
add $0,8
mov $1,1
lpb $0,1
sub $0,1
div $3,2
add $2,$3
add $2,1
mov $4,$1
lpe
mul $1,2
pow $1,$2
div $1,2
add $4,2
add $1,$4
sub $1,16387
div $1,16384
mul $1,2
add $1,2
| 17.75 | 194 | 0.687793 |
13c49630ba632d9d5811bd8276a0365a573c0741 | 4,044 | asm | Assembly | zadanie2/producer_consumer.asm | BAndysc/SO | ed70e3dd45ec1afb009060e1cd7381eaefdbbd47 | [
"Unlicense"
] | null | null | null | zadanie2/producer_consumer.asm | BAndysc/SO | ed70e3dd45ec1afb009060e1cd7381eaefdbbd47 | [
"Unlicense"
] | null | null | null | zadanie2/producer_consumer.asm | BAndysc/SO | ed70e3dd45ec1afb009060e1cd7381eaefdbbd47 | [
"Unlicense"
] | 1 | 2020-03-26T16:51:37.000Z | 2020-03-26T16:51:37.000Z | global init
global producer;
global consumer
extern malloc
extern produce ; int produce(int64_t *);
extern consume ; int consume(int64_t);
extern verhogen ; void verhogen(int32_t*);
extern proberen ; void proberen(int32_t*);
section .bss
buffer_start: resq 1
buffer_size: resq 1
sem_free: resd 1
sem_full: resd 1
portion_producer: resq 1
buffer_producer_index: resq 1
portion_consumer: resq 1
buffer_consumer_index: resq 1
section .text
INIT_MAX_SIZE equ 0x7FFFFFFF
INIT_ERROR_OVERFLOW equ -1
INIT_ERROR_ZERO equ -2
INIT_ERROR_MALLOC equ -3
init: ; (size_t rdi)
push rdi
; zero all global variables, so that even if we run init twice
; everything will be ok
mov qword [buffer_start], 0
mov qword [buffer_size], 0
mov dword [sem_free], 0
mov dword [sem_full], 0
mov qword [portion_producer], 0
mov qword [buffer_producer_index], 0
mov qword [portion_consumer], 0
mov qword [buffer_consumer_index], 0
cmp rdi, INIT_MAX_SIZE ; if (rdi <= 2^31-1)
jbe init_check_zero ; goto init_check_zero
mov rax, INIT_ERROR_OVERFLOW ; return INIT_ERROR_OVERFLOW
pop rdi
ret
init_check_zero:
cmp rdi,0 ; if (rdi == 0)
jne init_alloc ; goto init_alloc
mov rax, INIT_ERROR_ZERO ; return INIT_ERROR_ZERO
pop rdi
ret
init_alloc:
imul rdi, 8 ; rdi = n * sizeof(int64)
call malloc ; rax = malloc(rdi)
cmp rax, 0 ; if (rax == 0)
jnz init_ok
mov rax, INIT_ERROR_MALLOC ; return INIT_ERROR_MALLOC
pop rdi
ret
init_ok: ; else
pop rdi
mov [buffer_start], rax ; buffer_start = rax
mov [buffer_size], rdi ; buffer_size = rdi
mov [sem_free], edi ; sem_free = edi
mov rax, 0 ; return 0
ret
producer:
sub rsp, 8
producer_loop:
mov rdi, portion_producer
call produce ; rax = produce(&portion_producer)
test rax, rax ; if rax == 0
je producer_end ; goto producer_end // return
mov rdi, sem_free
call proberen ; proberen(&sem_free)
mov r8, [portion_producer]
mov r9, [buffer_producer_index]
mov r10, [buffer_start]
mov [r10+r9*8], r8 ; *(buffer_start + buffer_producer_index*8) = portion_producer
mov rdi, sem_full
call verhogen ; verhogen(&sem_full)
inc qword [buffer_producer_index] ; buffer_producer_index++
mov qword rax, [buffer_producer_index]
cmp qword rax, [buffer_size]
jl producer_loop ; if buffer_producer_index >= buffer_size
mov qword [buffer_producer_index], 0 ; buffer_producer_index = 0
jmp producer_loop ; repeat
producer_end:
add rsp, 8
ret
consumer:
sub rsp, 8
consumer_loop:
mov rdi, sem_full
call proberen ; proberen(&sem_full)
mov r8, [buffer_consumer_index]
mov r9, [buffer_start]
mov r10, [r9 + r8 * 8] ; portion_consumer = *(buffer_start + buffer_consumer_index*8)
mov [portion_consumer], r10
mov rdi,sem_free
call verhogen ; verhogen(&sem_free)
inc qword [buffer_consumer_index] ; buffer_consumer_index++
mov qword rax, [buffer_consumer_index]
cmp qword rax, [buffer_size]
jl consumer_continue ; if buffer_consumer_index >= buffer_size
mov qword [buffer_consumer_index], 0 ; buffer_consumer_index = 0
consumer_continue:
mov rdi,[portion_consumer]
call consume ; rax = consume(&portion_consumer)
cmp rax, 0
jne consumer_loop ; if rax == 0, repeat
add rsp, 8
ret
| 29.093525 | 106 | 0.584075 |
9c563035d59380ff55aee283bb957898ef7874d5 | 3,442 | asm | Assembly | cc4x86/tests/regressive/asm_listings/mul_div_.asm | artyompal/C-compiler | 0c13e96b926d4c3282be8e9629cbc7ba439ea2d4 | [
"MIT"
] | 4 | 2017-03-19T20:10:55.000Z | 2022-01-20T08:34:25.000Z | cc4x86/tests/regressive/asm_listings/mul_div_.asm | artyompal/C-compiler | 0c13e96b926d4c3282be8e9629cbc7ba439ea2d4 | [
"MIT"
] | null | null | null | cc4x86/tests/regressive/asm_listings/mul_div_.asm | artyompal/C-compiler | 0c13e96b926d4c3282be8e9629cbc7ba439ea2d4 | [
"MIT"
] | null | null | null |
.686
.model flat
.xmm
.code
_test proc
push ebp
mov ebp,esp
sub esp,44
mov dword ptr [ebp-4],2
mov dword ptr [ebp-8],3
mov dword ptr [ebp-12],4
mov dword ptr [ebp-16],5
mov eax,[ebp-8]
xor edx,edx
div dword ptr [ebp-4]
mov [ebp-24],eax
mov eax,[ebp-8]
xor edx,edx
div dword ptr [ebp-4]
mov [ebp-28],eax
mov eax,[ebp-24]
mul dword ptr [ebp-28]
mov [ebp-24],eax
mov eax,[ebp-16]
xor edx,edx
div dword ptr [ebp-12]
mov [ebp-32],eax
mov eax,[ebp-16]
xor edx,edx
div dword ptr [ebp-12]
mov [ebp-36],eax
mov eax,[ebp-32]
mul dword ptr [ebp-36]
mov [ebp-32],eax
mov eax,[ebp-24]
add eax,[ebp-32]
mov [ebp-20],eax
cmp dword ptr [ebp-20],2
je label0000
mov edx,1
mov eax,edx
add esp,44
pop ebp
ret
label0000:
mov eax,[ebp-12]
xor edx,edx
div dword ptr [ebp-4]
mov [ebp-12],eax
cmp dword ptr [ebp-12],2
je label0001
mov edx,2
mov eax,edx
add esp,44
pop ebp
ret
label0001:
mov eax,[ebp-16]
xor edx,edx
div dword ptr [ebp-8]
mov [ebp-16],edx
cmp dword ptr [ebp-16],2
je label0002
mov eax,3
add esp,44
pop ebp
ret
label0002:
mov eax,[ebp-4]
mul dword ptr [ebp-8]
mov [ebp-12],eax
cmp dword ptr [ebp-12],6
je label0003
mov eax,4
add esp,44
pop ebp
ret
label0003:
mov eax,[ebp-4]
mov [ebp-16],eax
mov eax,[ebp-16]
mul dword ptr [ebp-8]
mov [ebp-16],eax
cmp dword ptr [ebp-16],6
je label0004
mov eax,5
add esp,44
pop ebp
ret
label0004:
mov dword ptr [ebp-4],65536
mov dword ptr [ebp-8],65536
mov eax,[ebp-4]
mul dword ptr [ebp-8]
cmp eax,0
je label0005
mov eax,6
add esp,44
pop ebp
ret
label0005:
mov dword ptr [ebp-4],2
mov dword ptr [ebp-8],3
mov dword ptr [ebp-12],4
mov dword ptr [ebp-16],5
mov eax,[ebp-8]
xor edx,edx
div dword ptr [ebp-4]
mov [ebp-40],eax
mov eax,[ebp-12]
xor edx,edx
div dword ptr [ebp-4]
mov [ebp-44],eax
mov eax,[ebp-40]
mul dword ptr [ebp-44]
mov [ebp-20],eax
cmp dword ptr [ebp-20],2
je label0006
mov edx,7
mov eax,edx
add esp,44
pop ebp
ret
label0006:
mov edx,0
mov eax,edx
add esp,44
pop ebp
ret
_test endp
end
| 25.308824 | 40 | 0.391052 |
df59211d2f65b8d84d3a827285e224c0a59e5d0b | 33 | rb | Ruby | vendor/cache/gems/thor-0.19.1/spec/sandbox/doc/block_helper.rb | defc0n1/shoppe_promo | f5318ba9dac899a28b7f0c42f85f49e6547e026c | [
"MIT"
] | 2,511 | 2015-01-02T17:19:00.000Z | 2021-06-03T11:30:14.000Z | vendor/cache/gems/thor-0.19.1/spec/sandbox/doc/block_helper.rb | defc0n1/shoppe_promo | f5318ba9dac899a28b7f0c42f85f49e6547e026c | [
"MIT"
] | 371 | 2020-03-04T21:51:56.000Z | 2022-03-31T20:59:11.000Z | vendor/cache/gems/thor-0.19.1/spec/sandbox/doc/block_helper.rb | defc0n1/shoppe_promo | f5318ba9dac899a28b7f0c42f85f49e6547e026c | [
"MIT"
] | 330 | 2015-01-04T11:37:41.000Z | 2021-06-01T13:36:27.000Z | <% world do -%>
Hello
<% end -%>
| 8.25 | 15 | 0.454545 |
aa8a2bb87788f82c51a8e4eecdfe4631386c4210 | 186 | kt | Kotlin | app/src/main/java/com/huotu/android/mifang/bean/PushMessageActivityBean.kt | hottech-jxd/mifang-shopman-android | d409993f3900a1ebef52bfd8ea2bbbd7799bce79 | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/huotu/android/mifang/bean/PushMessageActivityBean.kt | hottech-jxd/mifang-shopman-android | d409993f3900a1ebef52bfd8ea2bbbd7799bce79 | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/huotu/android/mifang/bean/PushMessageActivityBean.kt | hottech-jxd/mifang-shopman-android | d409993f3900a1ebef52bfd8ea2bbbd7799bce79 | [
"Apache-2.0"
] | null | null | null | package com.huotu.android.mifang.bean
/**
* Created by jinxiangdong on 2017/12/25.
*/
data class PushMessageActivityBean (
var imageUrl:String?=null,
var link:String?=null
)
| 16.909091 | 41 | 0.715054 |
e72246ac10343250a993a80d690c94a209993ffc | 273 | js | JavaScript | random_trip/src/Components/ResultsData.js | Pieter-Jacobs/Random_Trip | 3d79ae9c12563fb0606e2512abe856b5a0e88082 | [
"MIT"
] | null | null | null | random_trip/src/Components/ResultsData.js | Pieter-Jacobs/Random_Trip | 3d79ae9c12563fb0606e2512abe856b5a0e88082 | [
"MIT"
] | null | null | null | random_trip/src/Components/ResultsData.js | Pieter-Jacobs/Random_Trip | 3d79ae9c12563fb0606e2512abe856b5a0e88082 | [
"MIT"
] | null | null | null | import React from 'react';
import PropTypes from 'prop-types';
import '../Styles/ResultsData.module.css'
export default function ResultsData(props) {
return (
<div>
{props.data.map((item) => <div>{item}</div>)}
</div>
);
}
ResultsData.propTypes = {
};
| 17.0625 | 51 | 0.641026 |
3bc6938b3c15879bc7d2e8cd560e3e4fd081d2f5 | 122 | kt | Kotlin | app/src/main/java/com/arcadan/dodgetheenemies/enums/Reward.kt | ArcaDone/DodgeTheEnemies | 24133757b19f2b2fea64542347b339f8621284f6 | [
"MIT"
] | 1 | 2021-03-25T15:58:25.000Z | 2021-03-25T15:58:25.000Z | app/src/main/java/com/arcadan/dodgetheenemies/enums/Reward.kt | ArcaDone/DodgeTheEnemies | 24133757b19f2b2fea64542347b339f8621284f6 | [
"MIT"
] | null | null | null | app/src/main/java/com/arcadan/dodgetheenemies/enums/Reward.kt | ArcaDone/DodgeTheEnemies | 24133757b19f2b2fea64542347b339f8621284f6 | [
"MIT"
] | null | null | null | package com.arcadan.dodgetheenemies.enums
enum class Reward {
POWER_UP,
HEARTS,
COINS,
GEMS,
NONE,
}
| 12.2 | 41 | 0.647541 |
f6743e007e18ef6144696c5a28916071fb960531 | 1,915 | kt | Kotlin | src/main/kotlin/ui/util/swing/Tables.kt | marshallbrain/pulsar-java | fed43a0164421b27056045446f07982e0313452d | [
"MIT"
] | null | null | null | src/main/kotlin/ui/util/swing/Tables.kt | marshallbrain/pulsar-java | fed43a0164421b27056045446f07982e0313452d | [
"MIT"
] | null | null | null | src/main/kotlin/ui/util/swing/Tables.kt | marshallbrain/pulsar-java | fed43a0164421b27056045446f07982e0313452d | [
"MIT"
] | null | null | null | package ui.util.swing
import java.awt.Dimension
import javax.swing.BorderFactory
import javax.swing.JScrollPane
import javax.swing.JTable
import javax.swing.ListSelectionModel
import javax.swing.border.Border
import javax.swing.table.DefaultTableModel
fun createScrollTable(
table: JTable,
maxVisibleRows: Int = table.rowCount,
border: Border = BorderFactory.createEmptyBorder()
) : JScrollPane {
val scrollPane = object : ContinuesScrollPane(table) {
override fun getPreferredSize(): Dimension {
val insets = border.getBorderInsets(this)
return Dimension(0, (table.rowHeight)*maxVisibleRows) +
columnHeader.preferredSize +
Dimension(insets.left + insets.right, insets.top + insets.bottom)
}
override fun getMinimumSize(): Dimension = preferredSize
override fun getMaximumSize(): Dimension = preferredSize
init {
addMouseWheelListener(ContinuesMouseWheelListener())
}
}
scrollPane.border = border
return scrollPane
}
fun createTable(
vararg columnNames: String,
data: MutableList<*> = emptyList<String>().toMutableList()
) : JTable {
val formattedData = getFormattedData(data, *columnNames)
val table = object : JTable(DefaultTableModel(formattedData, columnNames)) {
override fun isCellEditable(row: Int, column: Int): Boolean = false
}
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
table.cellSelectionEnabled = false
table.rowSelectionAllowed = true
table.fillsViewportHeight = true
return table
}
private fun getFormattedData(
data: MutableList<*>,
vararg columnNames: String
) : Array<Array<*>> {
val colNum = columnNames.size
val rowNum = data.size / colNum
return List(rowNum) { row ->
List(colNum) { col ->
data[row * colNum + col]
}.toTypedArray()
}.toTypedArray()
}
private operator fun Dimension.plus(i : Dimension) : Dimension {
return Dimension(width + i.width, height + i.height)
}
| 23.641975 | 77 | 0.746214 |
c43201f94895ebca0819715fd216476e43a64fd5 | 718 | h | C | s_xml_doc.h | Ludorg/s_fractal_cpp | 308dc45d5e587005b9dc273ffe8bf623c5c85c85 | [
"MIT"
] | 1 | 2020-05-13T17:18:43.000Z | 2020-05-13T17:18:43.000Z | s_xml_doc.h | Ludorg/s_fractal_cpp | 308dc45d5e587005b9dc273ffe8bf623c5c85c85 | [
"MIT"
] | 1 | 2021-08-30T22:50:37.000Z | 2021-08-30T22:50:37.000Z | s_xml_doc.h | Ludorg/s_fractal_cpp | 308dc45d5e587005b9dc273ffe8bf623c5c85c85 | [
"MIT"
] | null | null | null | #if !defined(S_XML_DOC_H)
#define S_XML_DOC_H 1
// Sofia (Sofia_aleph)
//
// Sofia, my way for developing knowledge
//
// (c) 2004 Ludovic LIEVRE aka Ludorg
// XML manipulation based on libxml2
#include "sofia.h"
#include <libxml/xmlmemory.h>
#include <libxml/xmlerror.h>
#include <libxml/parser.h>
SOFIA_NS_BEGIN
class XMLDoc
{
public:
XMLDoc();
XMLDoc(const char *fileName);
virtual ~XMLDoc();
bool parse(const char *fileName);
inline xmlNodePtr getRootNode() { return rootNode_; }
private:
xmlDocPtr doc_;
xmlNodePtr rootNode_;
xmlParserCtxtPtr ctxt_;
XMLDoc &operator=(const XMLDoc &);
XMLDoc(const XMLDoc &);
};
SOFIA_NS_END
#endif // S_XML_DOC_H
| 16.318182 | 55 | 0.683844 |
124f49977e548fd065352dda1813f453f87675ba | 5,700 | h | C | src/backgroundprocess/app.h | Skycoder42/QBackgroundProcess | 9681aa736729ce1b7985e8664e0f05729235e0c4 | [
"BSD-3-Clause"
] | 10 | 2017-08-17T16:34:03.000Z | 2021-02-16T17:42:30.000Z | src/backgroundprocess/app.h | Skycoder42/QBackgroundProcess | 9681aa736729ce1b7985e8664e0f05729235e0c4 | [
"BSD-3-Clause"
] | null | null | null | src/backgroundprocess/app.h | Skycoder42/QBackgroundProcess | 9681aa736729ce1b7985e8664e0f05729235e0c4 | [
"BSD-3-Clause"
] | 4 | 2018-08-27T06:15:11.000Z | 2021-03-08T10:10:34.000Z | #ifndef QTBACKGROUNDPROCESS_APP_H
#define QTBACKGROUNDPROCESS_APP_H
#include "QtBackgroundProcess/qtbackgroundprocess_global.h"
#include <QtCore/qcommandlineparser.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qexception.h>
#include <functional>
//! The Namespace containing all classes of the QtBackgroundProcess module
namespace QtBackgroundProcess {
class Terminal;
//! Will be thrown, if you perform an operation, that is not allowed in running state
class Q_BACKGROUNDPROCESS_EXPORT NotAllowedInRunningStateException : public QException
{
public:
NotAllowedInRunningStateException();
//! @inherit{std::exception::what}
const char *what() const noexcept override;
//! @inherit{QException::raise}
void raise() const override;
//! @inherit{QException::clone}
QException *clone() const override;
};
class AppPrivate;
//! The background process application. The main class of QtBackgroundProcess
class Q_BACKGROUNDPROCESS_EXPORT App : public QCoreApplication
{
Q_OBJECT
friend class AppPrivate;
//! The current id of the singleton instance of the master process
Q_PROPERTY(QString instanceID READ instanceID WRITE setInstanceID RESET createDefaultInstanceID)
//! Specify whether the app should be a systemwide or userwide single instance
Q_PROPERTY(bool globalInstance READ globalInstance WRITE setGlobalInstance)
//! Specifies, whether the master should forward debug output to all terminals
Q_PROPERTY(bool forwardMasterLog READ forwardMasterLog WRITE setForwardMasterLog)
//! If true, the master process will always be started, not only with "start"
Q_PROPERTY(bool autoStartMaster READ autoStartMaster WRITE setAutoStartMaster)
//! If true, "start" commands will be ignored, if the master is already running
Q_PROPERTY(bool ignoreMultiStarts READ ignoreMultiStarts WRITE setIgnoreMultiStarts)
//! If true, the master process will automatically delete terminals that have been disconnected
Q_PROPERTY(bool autoDeleteTerminals READ autoDeleteTerminals WRITE setAutoDeleteTerminals)
//! If true, the master process will automatically close terminals after it received the parameters
Q_PROPERTY(bool autoKillTerminals READ autoKillTerminals WRITE setAutoKillTerminals)
//! Holds a list of all currently connected terminals
Q_PROPERTY(QList<Terminal*> connectedTerminals READ connectedTerminals NOTIFY connectedTerminalsChanged)
public:
//! Creates a new app with it's arguments
App(int &argc, char **argv, int flags = ApplicationFlags);
//! Destructor
~App();
//! @readAcFn{App::instanceID}
QString instanceID() const;
//! @readAcFn{App::globalInstance}
bool globalInstance() const;
//! @readAcFn{App::forwardMasterLog}
bool forwardMasterLog() const;
//! @readAcFn{App::autoStartMaster}
bool autoStartMaster() const;
//! @readAcFn{App::ignoreMultiStarts}
bool ignoreMultiStarts() const;
//! @readAcFn{App::autoDeleteTerminals}
bool autoDeleteTerminals() const;
//! @readAcFn{App::autoKillTerminals}
bool autoKillTerminals() const;
//! Sets the function to be called for the creation of the parser (Instead of overriding)
void setParserSetupFunction(const std::function<void(QCommandLineParser &)> &function);
//! Sets the function to be called to startup the application (Instead of overriding)
void setStartupFunction(const std::function<int (const QCommandLineParser &)> &function);
//! Sets the function to be called to handle shutdown requests (Instead of overriding)
void setShutdownRequestFunction(const std::function<bool(const QCommandLineParser &, int&)> &function);
//! Sets the function to be called to handle shutdown requests (Instead of overriding)
void setShutdownRequestFunction(const std::function<bool(Terminal*, int&)> &function);
//! Executes the application event loop
int exec();
//! @readAcFn{App::connectedTerminals}
QList<Terminal*> connectedTerminals() const;
public Q_SLOTS:
//! @resetAcFn{App::instanceID}
void createDefaultInstanceID(bool overwrite = true);
//! @writeAcFn{App::instanceID}
void setInstanceID(QString instanceID, bool useAsSeed = true);
//! @writeAcFn{App::globalInstance}
void setGlobalInstance(bool globalInstance);
//! @writeAcFn{App::forwardMasterLog}
void setForwardMasterLog(bool forwardMasterLog);
//! @writeAcFn{App::autoStartMaster}
void setAutoStartMaster(bool autoStartMaster);
//! @writeAcFn{App::ignoreMultiStarts}
void setIgnoreMultiStarts(bool ignoreMultiStarts);
//! @writeAcFn{App::autoDeleteTerminals}
void setAutoDeleteTerminals(bool autoDeleteTerminals, bool changeCurrent = false);
//! @writeAcFn{App::autoKillTerminals}
void setAutoKillTerminals(bool autoKillTerminals, bool killCurrent = false);
Q_SIGNALS:
//! Will be emitted when a new terminal has connected to the master
void newTerminalConnected(QtBackgroundProcess::Terminal *terminal, QPrivateSignal);
//! Will be emitted when a new terminal sent arguments to the master
void commandReceived(QSharedPointer<QCommandLineParser> parser, bool isStarter, QPrivateSignal);
//! @notifyAcFn{App::connectedTerminals}
void connectedTerminalsChanged(QList<Terminal*> connectedTerminals, QPrivateSignal);
protected:
//! Sets up the parser to parse commands and arguments
virtual void setupParser(QCommandLineParser &parser, bool useShortOptions = true);
//! Is called as initialization function of the master process
virtual int startupApp(const QCommandLineParser &parser);
//! Gets called when a terminal requests a shutdown of the master
virtual bool requestAppShutdown(Terminal *terminal, int &exitCode);
private:
AppPrivate* d;
};
}
#undef qApp
#define qApp static_cast<QtBackgroundProcess::App*>(QCoreApplication::instance())
#endif // QTBACKGROUNDPROCESS_APP_H
| 41.605839 | 105 | 0.792982 |
0b9068ae3299f03b04a8be28a4b732a299e46459 | 1,132 | py | Python | config.py | xXAligatorXx/repostAlert | 74f450b577fa0971632a57c7d1f599eea4808427 | [
"MIT"
] | 25 | 2018-10-18T15:16:39.000Z | 2019-06-06T04:33:20.000Z | config.py | xXAligatorXx/repostAlert | 74f450b577fa0971632a57c7d1f599eea4808427 | [
"MIT"
] | 6 | 2018-10-17T01:34:13.000Z | 2019-06-08T18:31:41.000Z | config.py | xXAligatorXx/repostAlert | 74f450b577fa0971632a57c7d1f599eea4808427 | [
"MIT"
] | 2 | 2018-10-25T19:42:45.000Z | 2018-12-05T23:09:06.000Z | import os
client_id = os.environ['BOT_CLIENT_ID']
client_secret = os.environ['BOT_CLIENT_SECRET']
user_agent = os.environ['BOT_USER_AGENT']
username = os.environ['BOT_USERNAME']
password = os.environ['BOT_PASSWORD']
num_subs = int(os.environ['BOT_SUB_COUNT'])
sub_settings = [[
os.environ['BOT_SUBREDDIT' + i],
int(os.environ['BOT_TOP_DAYS' + i]) if 'BOT_TOP_DAYS' + i in os.environ else None,
int(os.environ['BOT_HOT_DAYS' + i]) if 'BOT_HOT_DAYS' + i in os.environ else None,
int(os.environ['BOT_NEW_DAYS' + i]) if 'BOT_NEW_DAYS' + i in os.environ else None,
int(os.environ['BOT_TOP_NUM_POSTS' + i]) if 'BOT_TOP_NUM_POSTS' + i in os.environ else 1000,
int(os.environ['BOT_HOT_NUM_POSTS' + i]) if 'BOT_HOT_NUM_POSTS' + i in os.environ else 1000,
int(os.environ['BOT_NEW_NUM_POSTS' + i]) if 'BOT_NEW_NUM_POSTS' + i in os.environ else 1000,
int(os.environ['BOT_THRESH' +i]) if 'BOT_THRESH' + i in os.environ else 5,
bool(os.environ['BOT_TEXT_IN_IMAGE' + i]) if 'BOT_TEXT_IN_IMAGE' + i in os.environ else False,
] for i in [str(x) for x in range(num_subs)]]
| 56.6 | 102 | 0.682862 |
926c02e3268bca8b5a33943b8481c9a047d00a98 | 11,811 | lua | Lua | lua/wuma/datahandler.lua | Kill-Zone/wuma | 6755a3e3b332719c61bda12a386287a3ecac3cfa | [
"Apache-2.0"
] | null | null | null | lua/wuma/datahandler.lua | Kill-Zone/wuma | 6755a3e3b332719c61bda12a386287a3ecac3cfa | [
"Apache-2.0"
] | null | null | null | lua/wuma/datahandler.lua | Kill-Zone/wuma | 6755a3e3b332719c61bda12a386287a3ecac3cfa | [
"Apache-2.0"
] | null | null | null |
WUMA = WUMA or {}
local WUMADebug = WUMADebug
local WUMALog = WUMALog
WUMA.DATA = {}
WUMA.DataUpdateCooldown = WUMA.CreateConVar("wuma_data_save_delay", "10", FCVAR_ARCHIVE, "Delay before changes are saved.")
function WUMA.GetSavedTable(enum,user)
if (enum == Restriction) then
return WUMA.GetSavedRestrictions(user)
elseif (enum == Limit) then
return WUMA.GetSavedLimits(user)
elseif (enum == Loadout) then
return WUMA.GetSavedLoadouts(user)
end
end
function WUMA.isTableEmpty(tbl)
if not istable(tbl) then return true end
if (table.Count(tbl) < 1) then return true else return false end
end
--Pooling
WUMA.FunctionPool = {}
WUMA.FunctionTimers = {}
function WUMA.PopFunctionPool(id)
if (WUMA.FunctionPool[id]) then
local data = {}
for k, tbl in pairs(WUMA.FunctionPool[id].data) do
table.Merge(data, tbl)
end
local args = WUMA.FunctionPool[id].args
args[WUMA.FunctionPool[id].datai] = data
WUMA.FunctionPool[id].func(unpack(args))
WUMA.FunctionPool[id] = nil
WUMA.FunctionTimers[id] = nil
end
end
function WUMA.PoolFunction(id, func, data, args, datai)
if not WUMA.FunctionTimers[id] then
timer.Simple(1, function() WUMA.PopFunctionPool(id) end)
WUMA.FunctionTimers[id] = true
end
if WUMA.FunctionPool[id] then
table.insert(WUMA.FunctionPool[id].data, data)
else
WUMA.FunctionPool[id] = {func=func, data={data}, args=args, datai=datai}
end
end
--Update Clients
WUMA.DATA.Subscriptions = {}
WUMA.DATA.Subscriptions.users = {}
function WUMA.AddDataSubscription(user,target,extra)
if WUMA.IsSteamID(target) then
WUMA.DATA.Subscriptions.users[target] = WUMA.DATA.Subscriptions.users[target] or {}
WUMA.DATA.Subscriptions.users[target][extra] = WUMA.DATA.Subscriptions.users[target][extra] or {}
WUMA.DATA.Subscriptions.users[target][extra][user:SteamID()] = user
else
if not (WUMA.DATA.Subscriptions[target]) then WUMA.DATA.Subscriptions[target] = {} end
WUMA.DATA.Subscriptions[target][user:SteamID()] = user
end
end
function WUMA.RemoveDataSubscription(user,target,extra)
user = user:SteamID()
if WUMA.IsSteamID(target) and WUMA.DATA.Subscriptions.users[target] then
for k, v in pairs(WUMA.DATA.Subscriptions.users[target]) do
if not extra then
if v[user] then v[user] = nil end
if (table.Count(v) < 1) then WUMA.DATA.Subscriptions.users[target][k] = nil end
else
if (extra == k) then
if v[user] then v[user] = nil end
if (table.Count(v) < 1) then WUMA.DATA.Subscriptions.users[target][k] = nil end
end
end
end
if (table.Count(WUMA.DATA.Subscriptions.users[target]) < 1) then WUMA.DATA.Subscriptions.users[target] = nil end
elseif (WUMA.DATA.Subscriptions[target] ~= nil and WUMA.DATA.Subscriptions[target][user]) then
WUMA.DATA.Subscriptions[target][user] = nil
if (table.Count(WUMA.DATA.Subscriptions[target]) < 1) then WUMA.DATA.Subscriptions[target] = nil end
end
end
function WUMA.GetDataSubsribers(target,enum)
if WUMA.IsSteamID(target) then
if not WUMA.DATA.Subscriptions.users[target] then return {} end
if not WUMA.DATA.Subscriptions.users[target][enum] then return {} end --Stops here
return WUMA.DATA.Subscriptions.users[target][enum]
else
if not (WUMA.DATA.Subscriptions[target]) then return {} end
return WUMA.DATA.Subscriptions[target]
end
end
function WUMA.RemoveClientUpdateUser(user)
WUMA.RemoveDataSubscription(user,Restriction:GetID())
WUMA.RemoveDataSubscription(user,Limit:GetID())
WUMA.RemoveDataSubscription(user,Loadout:GetID())
user = user:SteamID()
for k, ply in pairs(WUMA.DATA.Subscriptions.users) do
for type, subscribers in pairs(ply) do
for steamid, _ in pairs(subscribers) do
if (steamid == user) then subscribers[steamid] = nil end
end
if (table.Count(subscribers) < 1) then ply[type] = nil end
end
if (table.Count(ply) < 1) then WUMA.DATA.Subscriptions.users[k] = nil end
end
end
hook.Add("PlayerDisconnected","WUMADataHandlerPlayerDisconnected", WUMA.RemoveClientUpdateUser, 0)
function WUMA.SendData(user)
if WUMA.Files.Exists(WUMA.DataDirectory.."restrictions.txt") then
WUMA.SendCompressedData(user,WUMA.GetSavedRestrictions(),Restriction:GetID())
end
if WUMA.Files.Exists(WUMA.DataDirectory.."limits.txt") then
WUMA.SendCompressedData(user,WUMA.GetSavedLimits(),Limit:GetID())
end
if WUMA.Files.Exists(WUMA.DataDirectory.."loadouts.txt") then
WUMA.SendCompressedData(user,WUMA.GetSavedLoadouts(),Loadout:GetID())
end
end
--Client updates
WUMA.DATA.ClientUpdates = {}
WUMA.DATA.ClientUpdates.users = {}
local tick_clients = false
function WUMA.AddClientUpdate(enum, func, user)
if (table.Count(player.GetAll()) == 0) then return end --Why bother?
if isentity(user) then user = user:SteamID() end
enum = enum:GetID()
if (user) then
local tbl = WUMA.DATA.ClientUpdates.users
if not (tbl[user]) then tbl[user] = {} end
if not (tbl[user][enum]) then tbl[user][enum] = {} end
tbl[user][enum] = func(tbl[user][enum])
else
local tbl = WUMA.DATA.ClientUpdates
if not (tbl[enum]) then tbl[enum] = {} end
tbl[enum] = func(tbl[enum])
end
if not tick_clients then
hook.Add("Think","WUMAClientUpdateCooldown",WUMA.Clients_Tick)
tick_clients = 0
end
end
function WUMA.Clients_Tick()
tick_clients = tick_clients + 1
if (tick_clients > 10) then
hook.Remove("Think", "WUMAClientUpdateCooldown")
tick_clients = false
for enum, tbl in pairs (WUMA.DATA.ClientUpdates) do
if not (enum == "users") then
WUMA.SendCompressedData(WUMA.GetDataSubsribers(enum),tbl,enum)
end
end
for user, tbl in pairs (WUMA.DATA.ClientUpdates.users) do
for enum, data in pairs(tbl) do
for _, subscriber in pairs(WUMA.GetDataSubsribers(user,enum)) do
WUMA.SendCompressedData(subscriber,data,enum..":::"..user)
end
end
end
WUMA.DATA.ClientUpdates = {}
WUMA.DATA.ClientUpdates.users = {}
end
end
/////////////////////////////////////////////////////////
///// Global files update /////
/////////////////////////////////////////////////////////
WUMA.DATA.DataRegistry = {}
WUMA.DATA.DataSchedule = {}
local tick_global = WUMA.DataUpdateCooldown:GetInt() + 1
function WUMA.ScheduleDataUpdate(id, func)
if WUMA.DATA.DataRegistry[id] then
table.insert(WUMA.DATA.DataSchedule, {id=id, func=func})
tick_global = 0
WUMA.InvalidateCache(id)
else
WUMADebug("Tried to schedule unregistered data update (%s)!",id)
end
end
function WUMA.RegisterDataID(id, path, init)
WUMA.DATA.DataRegistry[id] = {path=path, init=init}
end
function WUMA.SaveData(data)
local dataregistry = WUMA.DATA.DataRegistry
for id, tbl in pairs(data) do
if (tbl and tbl ~= WUMA.DELETE) then
local str = util.TableToJSON(tbl)
WUMA.Cache(id, util.Compress(str)) --Cache the compressed data
WUMA.Files.Write(WUMA.DataDirectory..dataregistry[id].path, str)
elseif (tbl == WUMA.DELETE) then
WUMA.Files.Delete(WUMA.DataDirectory..dataregistry[id].path)
end
end
end
function WUMA.UpdateGlobal()
if (tick_global >= 0) then
tick_global = tick_global + 1
end
if (tick_global >= WUMA.DataUpdateCooldown:GetInt()) then
local tbl = {}
local dataregistry = WUMA.DATA.DataRegistry
for _, update in pairs(WUMA.DATA.DataSchedule) do
tbl[update.id] = update.func(tbl[update.id] or dataregistry[update.id].init())
end
for _, update in pairs(WUMA.DATA.DataSchedule) do
tbl[update.id].m = nil
end
for id, update in pairs(dataregistry) do
if (WUMA.isTableEmpty(tbl[id]) and tbl[id] ~= nil) then
tbl[id] = WUMA.DELETE
end
end
WUMA.DATA.DataSchedule = {}
WUMA.SaveData(tbl)
tick_global = -1
end
end
timer.Create("WUMAUpdateData", 1, 0, WUMA.UpdateGlobal)
/////////////////////////////////////////////////////////
///// User files update /////
/////////////////////////////////////////////////////////
WUMA.DATA.UserDataRegistry = {}
WUMA.DATA.UserDataSchedule = {}
local tick_user = WUMA.DataUpdateCooldown:GetInt() + 1
function WUMA.ScheduleUserDataUpdate(user, id, func)
if WUMA.DATA.UserDataRegistry[id] then
if isentity(user) then user = user:SteamID() end
table.insert(WUMA.DATA.UserDataSchedule, {id=id, func=func, user=user})
tick_user = 0
else
WUMADebug("Tried to schedule unregistered userdata update (%s)!",id)
end
end
function WUMA.RegisterUserDataID(id, path, init, delete)
WUMA.DATA.UserDataRegistry[id] = {path=path, init=init, delete=delete}
end
function WUMA.SaveUserData(data)
local dataregistry = WUMA.DATA.UserDataRegistry
for user, tbls in pairs(data) do
for id, tbl in pairs(tbls) do
if (tbl and tbl ~= WUMA.DELETE) then
local str = util.TableToJSON(tbl)
WUMA.Files.CreateDir(WUMA.DataDirectory..WUMA.UserDataDirectory..WUMA.GetUserFolder(user))
WUMA.Files.Write(WUMA.DataDirectory..WUMA.UserDataDirectory..WUMA.GetUserFolder(user)..dataregistry[id].path, str)
elseif (tbl == WUMA.DELETE) then
WUMA.DeleteUserFile(user, id)
end
end
end
end
function WUMA.UpdateUser()
if (tick_user >= 0) then
tick_user = tick_user + 1
end
if (tick_user >= WUMA.DataUpdateCooldown:GetInt()) then
local tbl = {}
local dataregistry = WUMA.DATA.UserDataRegistry
for _, update in pairs(WUMA.DATA.UserDataSchedule) do
tbl[update.user] = tbl[update.user] or {}
tbl[update.user][update.id] = update.func(tbl[update.user][update.id] or dataregistry[update.id].init(update.user))
end
for _, update in pairs(WUMA.DATA.UserDataSchedule) do
if tbl[update.user] then
tbl[update.user][update.id].m = nil
end
end
for id, data in pairs(dataregistry) do
for user, updates in pairs(tbl) do
if (data.delete(updates[id] or data.init(user)) and updates[id] ~= nil) then
updates[id] = WUMA.DELETE
end
end
end
WUMA.DATA.UserDataSchedule = {}
WUMA.SaveUserData(tbl)
tick_user = -1
end
end
timer.Create("WUMAUpdateUserData", 1, 0, WUMA.UpdateUser)
function WUMA.GetUserFolder(user)
if (isstring(user)) then
return string.gsub(user,":","_").."/"
else
return string.gsub(user:SteamID(),":","_").."/"
end
end
function WUMA.GetUserFile(user,enum)
local folder = WUMA.GetUserFolder(user)
if (enum == Restriction or enum == Restriction:GetID()) then
return WUMA.DataDirectory..WUMA.UserDataDirectory..folder.."restrictions.txt"
elseif (enum == Limit or enum == Limit:GetID()) then
return WUMA.DataDirectory..WUMA.UserDataDirectory..folder.."limits.txt"
elseif (enum == Loadout or enum == Loadout:GetID()) then
return WUMA.DataDirectory..WUMA.UserDataDirectory..folder.."loadouts.txt"
end
end
function WUMA.CheckUserFileExists(user,enum)
return WUMA.Files.Exists(WUMA.GetUserFile(user,enum))
end
function WUMA.DeleteUserFile(user, enum)
WUMA.Files.Delete(WUMA.GetUserFile(user,enum))
timer.Simple(2, function()
if not WUMA.CheckUserFileExists(user,Restriction) and not WUMA.CheckUserFileExists(user,Limit) and not WUMA.CheckUserFileExists(user,Loadout) then
WUMA.DeleteUserFolder(user)
end
end)
end
function WUMA.DeleteUserFolder(user)
local path = WUMA.DataDirectory..WUMA.UserDataDirectory..WUMA.GetUserFolder(user)
WUMA.Files.Delete(string.Left(path,string.len(path)-1))
end
local function onShutdown()
tick_user = WUMA.DataUpdateCooldown:GetInt() - 1
tick_global = WUMA.DataUpdateCooldown:GetInt() -1
WUMA.UpdateUser()
WUMA.UpdateGlobal()
end
hook.Add("ShutDown", "WUMADatahandlerShutdown", onShutdown) | 30.284615 | 149 | 0.687749 |
91b4defa3b87ba15cb1c025a55b623347b08ca47 | 695 | lua | Lua | wrk.lua | implementing-microservices/event-store | 0fe56446a39b1983545279f3affc9084d4bb2564 | [
"MIT"
] | 1 | 2020-12-11T23:39:46.000Z | 2020-12-11T23:39:46.000Z | wrk.lua | implementing-microservices/event-store | 0fe56446a39b1983545279f3affc9084d4bb2564 | [
"MIT"
] | null | null | null | wrk.lua | implementing-microservices/event-store | 0fe56446a39b1983545279f3affc9084d4bb2564 | [
"MIT"
] | 2 | 2020-12-11T23:39:55.000Z | 2021-12-12T23:19:35.000Z | wrk.method = "POST"
wrk.body = '[ { "eventId": "6a05e510-12ee-47b1-a7a7-2e4259d24809", "data": { "userId": "0a41c6e5-5ad9-4412-ac5c-fc4cc13e2d6c", "cartId": "a40ea1f4-b2f0-4904-9a3c-85c27efeca92", "productId": "5ca94d88036709a43a429a2b", "numItems": 9, "pricePerItem": 99.23, "productOptions": {"color": "blue"} } }, { "eventId": "12106650-4e49-47bd-b93a-0b59a7217497", "data": { "userId": "5c564d55-5393-48d4-94f5-0ed3402f2a08", "cartId": "ed3ffd05-11cd-41c8-ab58-69292f9a0a9f", "productId": "5ca94e34f7e55570ecb918af", "numItems": 2, "pricePerItem": 93.82, "productOptions": {"color": "red"} } } ]'
wrk.headers["Content-Type"] = "application/json"
wrk.headers["Accept"] = "application/json" | 139 | 582 | 0.699281 |
c35122f51206b031197087950e4424aeed6cb344 | 2,584 | go | Go | cmd/root.go | didenko/recent | e486c8bc044d654f12aa8552d164c03c670faeb2 | [
"Apache-2.0"
] | null | null | null | cmd/root.go | didenko/recent | e486c8bc044d654f12aa8552d164c03c670faeb2 | [
"Apache-2.0"
] | null | null | null | cmd/root.go | didenko/recent | e486c8bc044d654f12aa8552d164c03c670faeb2 | [
"Apache-2.0"
] | null | null | null | // Copyright © 2017 Vlad Didenko <[email protected]>
//
// 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 cmd
import (
"fmt"
"log"
"os"
"path"
"path/filepath"
"github.com/didenko/recent/internal/pt"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
var (
limit int
withdate bool
withmill bool
withtime bool
root = "."
store pt.PTslice
tsFormat string
)
var rootCmd = &cobra.Command{
Use: "recent <path>",
Short: "List a number of recently modified files ",
Long: `The recent utility collects a number of most recently modified
files from the specified directory tree. Current directory is used by default.`,
Args: cobra.MaximumNArgs(1),
PreRun: setup,
Run: collect,
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func init() {
rootCmd.PersistentFlags().IntVarP(&limit, "limit", "n", 10, "a number of recent files to list")
rootCmd.PersistentFlags().BoolVarP(&withdate, "date", "d", false, "include time in file timestamps output")
rootCmd.PersistentFlags().BoolVarP(&withtime, "time", "t", false, "include time in file timestamps output")
rootCmd.PersistentFlags().BoolVarP(&withmill, "mill", "m", false, "include milliseconts in file timestamps output - only if time included as well")
}
func setup(cmd *cobra.Command, args []string) {
if len(args) > 0 {
root = path.Clean(args[0])
}
tsFormat = pt.PickFormat(withdate, withtime, withmill)
store = make(pt.PTslice, 0, limit+1)
}
func collect(cmd *cobra.Command, args []string) {
err := filepath.Walk(root, consider)
if err != nil {
log.Fatal(errors.Wrap(err, "Scanning incomplete"))
}
for _, pt := range store {
fmt.Println(pt.ToString(tsFormat))
}
}
func min(a, b int) int {
if a < b {
return a
}
return b
}
func consider(path string, info os.FileInfo, err error) error {
if err != nil {
return errors.Wrapf(err, "Error while scanning %q", path)
}
if !info.IsDir() {
store = pt.Insert(store, pt.New(path, info.ModTime()))
store = store[:min(limit, len(store))]
}
return nil
}
| 25.333333 | 148 | 0.694272 |
672a28ca2aa3015e3894dbb1fd759cd00e12575d | 808 | lua | Lua | lua/plugins.lua | zantinger/nvim | fc13d19b6a73c08e23fa4614cb07a2813ed3ef9b | [
"MIT"
] | 2 | 2021-04-29T23:32:16.000Z | 2021-05-02T19:24:36.000Z | lua/plugins.lua | zantinger/nvim | fc13d19b6a73c08e23fa4614cb07a2813ed3ef9b | [
"MIT"
] | null | null | null | lua/plugins.lua | zantinger/nvim | fc13d19b6a73c08e23fa4614cb07a2813ed3ef9b | [
"MIT"
] | null | null | null | return require('packer').startup(function()
-- Packer can manage itself
use 'wbthomason/packer.nvim'
use 'morhetz/gruvbox'
use 'tpope/vim-fugitive'
use {
'nvim-telescope/telescope.nvim',
requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}}
}
use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }
use 'vim-airline/vim-airline'
use 'jiangmiao/auto-pairs'
use 'neovim/nvim-lspconfig'
use 'nvim-lua/completion-nvim'
use 'ervandew/supertab'
use 'maxmellon/vim-jsx-pretty'
use 'tpope/vim-commentary'
use {
'prettier/vim-prettier',
run = 'npm install'
}
use 'tpope/vim-unimpaired'
use 'mattn/emmet-vim'
use 'nelsyeung/twig.vim'
--use 'captbaritone/better-indent-support-for-php-with-html'
use 'danilamihailov/beacon.nvim'
end)
| 28.857143 | 67 | 0.684406 |
f080d8951298ed4993c4d12173d611eb730c94f6 | 706 | js | JavaScript | src/components/AnnotationTab/DynamicPreannotationsControl.js | mukeshgoud35/custom-lsf | 3746b4045db5dd930221833e12889a5dfeb4d8fa | [
"Apache-2.0"
] | 207 | 2020-01-13T02:55:50.000Z | 2022-03-25T09:12:38.000Z | src/components/AnnotationTab/DynamicPreannotationsControl.js | mukeshgoud35/custom-lsf | 3746b4045db5dd930221833e12889a5dfeb4d8fa | [
"Apache-2.0"
] | 196 | 2020-02-11T10:03:26.000Z | 2022-03-31T12:56:01.000Z | src/components/AnnotationTab/DynamicPreannotationsControl.js | Edern76/label-studio-frontend | b4f74feb7479cd00a856e866c4f3429c62bbb0cf | [
"Apache-2.0"
] | 150 | 2020-01-13T02:59:04.000Z | 2022-03-24T06:45:18.000Z | import { inject, observer } from "mobx-react";
import Input from "../../common/Input/Input";
import { Block } from "../../utils/bem";
import "./DynamicPreannotationsControl.styl";
export const DynamicPreannotationsControl = inject("store")(observer(({ store }) => {
return store.autoAnnotation ? (
<Block name="dynamic-preannotations-control">
<Input
type="checkbox"
checked={store.autoAcceptSuggestions}
label="Auto accept annotation suggestions"
onChange={(e) => store.setAutoAcceptSuggestions(e.target.checked)}
waiting={store.awaitingSuggestions}
labelProps={{
placement: 'right',
}}
/>
</Block>
) : null;
}));
| 32.090909 | 85 | 0.640227 |
98e0d712ec45428b582dd7fca6c51429c36f63e9 | 37,904 | html | HTML | org.elasticsearch.common.collect/.classes/CopyOnWriteHashMap.html | hnspn/LOG8371 | de2bac7e6a9cde766096ac6c82340b245365575d | [
"Apache-2.0"
] | null | null | null | org.elasticsearch.common.collect/.classes/CopyOnWriteHashMap.html | hnspn/LOG8371 | de2bac7e6a9cde766096ac6c82340b245365575d | [
"Apache-2.0"
] | null | null | null | org.elasticsearch.common.collect/.classes/CopyOnWriteHashMap.html | hnspn/LOG8371 | de2bac7e6a9cde766096ac6c82340b245365575d | [
"Apache-2.0"
] | null | null | null |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html id="htmlId">
<head>
<title>Coverage Report :: CopyOnWriteHashMap</title>
<style type="text/css">
@import "../../.css/coverage.css";
</style>
</head>
<body>
<div class="header"></div>
<div class="content">
<div class="breadCrumbs">
[ <a href="../../index.html">all classes</a> ]
[ <a href="../index.html">org.elasticsearch.common.collect</a> ]
</div>
<h1>Coverage Summary for Class: CopyOnWriteHashMap (org.elasticsearch.common.collect)</h1>
<table class="coverageStats">
<tr>
<th class="name">Class</th>
<th class="coverageStat
">
Method, %
</th>
<th class="coverageStat
">
Line, %
</th>
</tr>
<tr>
<td class="name">CopyOnWriteHashMap</td>
<td class="coverageStat">
<span class="percent">
72.2%
</span>
<span class="absValue">
(13/ 18)
</span>
</td>
<td class="coverageStat">
<span class="percent">
58.1%
</span>
<span class="absValue">
(36/ 62)
</span>
</td>
</tr>
<tr>
<td class="name">CopyOnWriteHashMap$1</td>
<td class="coverageStat">
<span class="percent">
50%
</span>
<span class="absValue">
(2/ 4)
</span>
</td>
<td class="coverageStat">
<span class="percent">
28.6%
</span>
<span class="absValue">
(2/ 7)
</span>
</td>
</tr>
<tr>
<td class="name">CopyOnWriteHashMap$EntryIterator</td>
<td class="coverageStat">
<span class="percent">
75%
</span>
<span class="absValue">
(3/ 4)
</span>
</td>
<td class="coverageStat">
<span class="percent">
85.7%
</span>
<span class="absValue">
(12/ 14)
</span>
</td>
</tr>
<tr>
<td class="name">CopyOnWriteHashMap$InnerNode</td>
<td class="coverageStat">
<span class="percent">
86.7%
</span>
<span class="absValue">
(13/ 15)
</span>
</td>
<td class="coverageStat">
<span class="percent">
75.3%
</span>
<span class="absValue">
(73/ 97)
</span>
</td>
</tr>
<tr>
<td class="name">CopyOnWriteHashMap$Leaf</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/ 9)
</span>
</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/ 41)
</span>
</td>
</tr>
<tr>
<td class="name">CopyOnWriteHashMap$Node</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(1/ 1)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(1/ 1)
</span>
</td>
</tr>
<tr>
<td class="name"><strong>total</strong></td>
<td class="coverageStat">
<span class="percent">
62.7%
</span>
<span class="absValue">
(32/ 51)
</span>
</td>
<td class="coverageStat">
<span class="percent">
55.9%
</span>
<span class="absValue">
(124/ 222)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<div class="sourceCode"><i>1</i> /*
<i>2</i> * Licensed to Elasticsearch under one or more contributor
<i>3</i> * license agreements. See the NOTICE file distributed with
<i>4</i> * this work for additional information regarding copyright
<i>5</i> * ownership. Elasticsearch licenses this file to you under
<i>6</i> * the Apache License, Version 2.0 (the "License"); you may
<i>7</i> * not use this file except in compliance with the License.
<i>8</i> * You may obtain a copy of the License at
<i>9</i> *
<i>10</i> * http://www.apache.org/licenses/LICENSE-2.0
<i>11</i> *
<i>12</i> * Unless required by applicable law or agreed to in writing,
<i>13</i> * software distributed under the License is distributed on an
<i>14</i> * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
<i>15</i> * KIND, either express or implied. See the License for the
<i>16</i> * specific language governing permissions and limitations
<i>17</i> * under the License.
<i>18</i> */
<i>19</i>
<i>20</i> package org.elasticsearch.common.collect;
<i>21</i>
<i>22</i> import org.apache.lucene.util.mutable.MutableValueInt;
<i>23</i>
<i>24</i> import java.lang.reflect.Array;
<i>25</i> import java.util.AbstractMap;
<i>26</i> import java.util.AbstractSet;
<i>27</i> import java.util.ArrayDeque;
<i>28</i> import java.util.Arrays;
<i>29</i> import java.util.Collection;
<i>30</i> import java.util.Deque;
<i>31</i> import java.util.Iterator;
<i>32</i> import java.util.Map;
<i>33</i> import java.util.NoSuchElementException;
<i>34</i> import java.util.Set;
<i>35</i> import java.util.stream.Stream;
<i>36</i>
<i>37</i> /**
<i>38</i> * An immutable map whose writes result in a new copy of the map to be created.
<i>39</i> *
<i>40</i> * This is essentially a hash array mapped trie: inner nodes use a bitmap in
<i>41</i> * order to map hashes to slots by counting ones. In case of a collision (two
<i>42</i> * values having the same 32-bits hash), a leaf node is created which stores
<i>43</i> * and searches for values sequentially.
<i>44</i> *
<i>45</i> * Reads and writes both perform in logarithmic time. Null keys and values are
<i>46</i> * not supported.
<i>47</i> *
<i>48</i> * This structure might need to perform several object creations per write so
<i>49</i> * it is better suited for work-loads that are not too write-intensive.
<i>50</i> *
<i>51</i> * @see <a href="http://en.wikipedia.org/wiki/Hash_array_mapped_trie">the wikipedia page</a>
<i>52</i> */
<b class="fc"><i>53</i> public final class CopyOnWriteHashMap<K, V> extends AbstractMap<K, V> {</b>
<i>54</i>
<i>55</i> private static final int TOTAL_HASH_BITS = 32;
<b class="fc"><i>56</i> private static final Object[] EMPTY_ARRAY = new Object[0];</b>
<i>57</i>
<i>58</i> private static final int HASH_BITS = 6;
<i>59</i> private static final int HASH_MASK = 0x3F;
<i>60</i>
<i>61</i> /**
<i>62</i> * Return a copy of the provided map.
<i>63</i> */
<i>64</i> public static <K, V> CopyOnWriteHashMap<K, V> copyOf(Map<? extends K, ? extends V> map) {
<b class="fc"><i>65</i> if (map instanceof CopyOnWriteHashMap) {</b>
<i>66</i> // no need to copy in that case
<i>67</i> @SuppressWarnings("unchecked")
<b class="nc"><i>68</i> final CopyOnWriteHashMap<K, V> cowMap = (CopyOnWriteHashMap<K, V>) map;</b>
<b class="nc"><i>69</i> return cowMap;</b>
<i>70</i> } else {
<b class="fc"><i>71</i> return new CopyOnWriteHashMap<K, V>().copyAndPutAll(map);</b>
<i>72</i> }
<i>73</i> }
<i>74</i>
<i>75</i> /**
<i>76</i> * Abstraction of a node, implemented by both inner and leaf nodes.
<i>77</i> */
<b class="fc"><i>78</i> private abstract static class Node<K, V> {</b>
<i>79</i>
<i>80</i> /**
<i>81</i> * Recursively get the key with the given hash.
<i>82</i> */
<i>83</i> abstract V get(Object key, int hash);
<i>84</i>
<i>85</i> /**
<i>86</i> * Recursively add a new entry to this node. <code>hashBits</code> is
<i>87</i> * the number of bits that are still set in the hash. When this value
<i>88</i> * reaches a number that is less than or equal to {@code 0}, a leaf
<i>89</i> * node needs to be created since it means that a collision occurred
<i>90</i> * on the 32 bits of the hash.
<i>91</i> */
<i>92</i> abstract Node<K, V> put(K key, int hash, int hashBits, V value, MutableValueInt newValue);
<i>93</i>
<i>94</i> /**
<i>95</i> * Recursively remove an entry from this node.
<i>96</i> */
<i>97</i> abstract Node<K, V> remove(Object key, int hash);
<i>98</i>
<i>99</i> /**
<i>100</i> * For the current node only, append entries that are stored on this
<i>101</i> * node to <code>entries</code> and sub nodes to <code>nodes</code>.
<i>102</i> */
<i>103</i> abstract void visit(Deque<Map.Entry<K, V>> entries, Deque<Node<K, V>> nodes);
<i>104</i>
<i>105</i> /**
<i>106</i> * Whether this node stores nothing under it.
<i>107</i> */
<i>108</i> abstract boolean isEmpty();
<i>109</i>
<i>110</i> }
<i>111</i>
<i>112</i> /**
<i>113</i> * A leaf of the tree where all hashes are equal. Values are added and retrieved in linear time.
<i>114</i> */
<b class="nc"><i>115</i> private static class Leaf<K, V> extends Node<K, V> {</b>
<i>116</i>
<i>117</i> private final K[] keys;
<i>118</i> private final V[] values;
<i>119</i>
<b class="nc"><i>120</i> Leaf(K[] keys, V[] values) {</b>
<b class="nc"><i>121</i> this.keys = keys;</b>
<b class="nc"><i>122</i> this.values = values;</b>
<b class="nc"><i>123</i> }</b>
<i>124</i>
<i>125</i> @SuppressWarnings("unchecked")
<i>126</i> Leaf() {
<b class="nc"><i>127</i> this((K[]) EMPTY_ARRAY, (V[]) EMPTY_ARRAY);</b>
<b class="nc"><i>128</i> }</b>
<i>129</i>
<i>130</i> @Override
<i>131</i> boolean isEmpty() {
<b class="nc"><i>132</i> return keys.length == 0;</b>
<i>133</i> }
<i>134</i>
<i>135</i> @Override
<i>136</i> void visit(Deque<Map.Entry<K, V>> entries, Deque<Node<K, V>> nodes) {
<b class="nc"><i>137</i> for (int i = 0; i < keys.length; ++i) {</b>
<b class="nc"><i>138</i> entries.add(new AbstractMap.SimpleImmutableEntry<>(keys[i], values[i]));</b>
<i>139</i> }
<b class="nc"><i>140</i> }</b>
<i>141</i>
<i>142</i> @Override
<i>143</i> V get(Object key, int hash) {
<b class="nc"><i>144</i> for (int i = 0; i < keys.length; i++) {</b>
<b class="nc"><i>145</i> if (key.equals(keys[i])) {</b>
<b class="nc"><i>146</i> return values[i];</b>
<i>147</i> }
<i>148</i> }
<b class="nc"><i>149</i> return null;</b>
<i>150</i>
<i>151</i> }
<i>152</i>
<i>153</i> private static <T> T[] replace(T[] array, int index, T value) {
<b class="nc"><i>154</i> final T[] copy = Arrays.copyOf(array, array.length);</b>
<b class="nc"><i>155</i> copy[index] = value;</b>
<b class="nc"><i>156</i> return copy;</b>
<i>157</i> }
<i>158</i>
<i>159</i> @Override
<i>160</i> Leaf<K, V> put(K key, int hash, int hashBits, V value, MutableValueInt newValue) {
<b class="nc"><i>161</i> assert hashBits <= 0 : hashBits;</b>
<b class="nc"><i>162</i> int slot = -1;</b>
<b class="nc"><i>163</i> for (int i = 0; i < keys.length; i++) {</b>
<b class="nc"><i>164</i> if (key.equals(keys[i])) {</b>
<b class="nc"><i>165</i> slot = i;</b>
<b class="nc"><i>166</i> break;</b>
<i>167</i> }
<i>168</i> }
<i>169</i>
<i>170</i> final K[] keys2;
<i>171</i> final V[] values2;
<i>172</i>
<b class="nc"><i>173</i> if (slot < 0) {</b>
<b class="nc"><i>174</i> keys2 = appendElement(keys, key);</b>
<b class="nc"><i>175</i> values2 = appendElement(values, value);</b>
<b class="nc"><i>176</i> newValue.value = 1;</b>
<i>177</i> } else {
<b class="nc"><i>178</i> keys2 = replace(keys, slot, key);</b>
<b class="nc"><i>179</i> values2 = replace(values, slot, value);</b>
<i>180</i> }
<i>181</i>
<b class="nc"><i>182</i> return new Leaf<>(keys2, values2);</b>
<i>183</i> }
<i>184</i>
<i>185</i> @Override
<i>186</i> Leaf<K, V> remove(Object key, int hash) {
<b class="nc"><i>187</i> int slot = -1;</b>
<b class="nc"><i>188</i> for (int i = 0; i < keys.length; i++) {</b>
<b class="nc"><i>189</i> if (key.equals(keys[i])) {</b>
<b class="nc"><i>190</i> slot = i;</b>
<b class="nc"><i>191</i> break;</b>
<i>192</i> }
<i>193</i> }
<b class="nc"><i>194</i> if (slot < 0) {</b>
<b class="nc"><i>195</i> return this;</b>
<i>196</i> }
<b class="nc"><i>197</i> final K[] keys2 = removeArrayElement(keys, slot);</b>
<b class="nc"><i>198</i> final V[] values2 = removeArrayElement(values, slot);</b>
<b class="nc"><i>199</i> return new Leaf<>(keys2, values2);</b>
<i>200</i> }
<i>201</i> }
<i>202</i>
<i>203</i> private static <T> T[] removeArrayElement(T[] array, int index) {
<b class="nc"><i>204</i> final Object result = Array.newInstance(array.getClass().getComponentType(), array.length - 1);</b>
<b class="nc"><i>205</i> System.arraycopy(array, 0, result, 0, index);</b>
<b class="nc"><i>206</i> if (index < array.length - 1) {</b>
<b class="nc"><i>207</i> System.arraycopy(array, index + 1, result, index, array.length - index - 1);</b>
<i>208</i> }
<i>209</i>
<b class="nc"><i>210</i> return (T[]) result;</b>
<i>211</i> }
<i>212</i>
<i>213</i> public static <T> T[] appendElement(final T[] array, final T element) {
<b class="nc"><i>214</i> final T[] newArray = Arrays.copyOf(array, array.length + 1);</b>
<b class="nc"><i>215</i> newArray[newArray.length - 1] = element;</b>
<b class="nc"><i>216</i> return newArray;</b>
<i>217</i> }
<i>218</i>
<i>219</i> public static <T> T[] insertElement(final T[] array, final T element, final int index) {
<b class="fc"><i>220</i> final T[] result = Arrays.copyOf(array, array.length + 1);</b>
<b class="fc"><i>221</i> System.arraycopy(array, 0, result, 0, index);</b>
<b class="fc"><i>222</i> result[index] = element;</b>
<b class="fc"><i>223</i> if (index < array.length) {</b>
<b class="fc"><i>224</i> System.arraycopy(array, index, result, index + 1, array.length - index);</b>
<i>225</i> }
<b class="fc"><i>226</i> return result;</b>
<i>227</i> }
<i>228</i>
<i>229</i>
<i>230</i> /**
<i>231</i> * An inner node in this trie. Inner nodes store up to 64 key-value pairs
<i>232</i> * and use a bitmap in order to associate hashes to them. For example, if
<i>233</i> * an inner node contains 5 values, then 5 bits will be set in the bitmap
<i>234</i> * and the ordinal of the bit set in this bit map will be the slot number.
<i>235</i> *
<i>236</i> * As a consequence, the number of slots in an inner node is equal to the
<i>237</i> * number of one bits in the bitmap.
<i>238</i> */
<b class="fc"><i>239</i> private static class InnerNode<K, V> extends Node<K, V> {</b>
<i>240</i>
<i>241</i> private final long mask; // the bitmap
<i>242</i> private final K[] keys;
<i>243</i> final Object[] subNodes; // subNodes[slot] is either a value or a sub node in case of a hash collision
<i>244</i>
<b class="fc"><i>245</i> InnerNode(long mask, K[] keys, Object[] subNodes) {</b>
<b class="fc"><i>246</i> this.mask = mask;</b>
<b class="fc"><i>247</i> this.keys = keys;</b>
<b class="fc"><i>248</i> this.subNodes = subNodes;</b>
<b class="fc"><i>249</i> assert consistent();</b>
<b class="fc"><i>250</i> }</b>
<i>251</i>
<i>252</i> // only used in assert
<i>253</i> private boolean consistent() {
<b class="fc"><i>254</i> assert Long.bitCount(mask) == keys.length;</b>
<b class="fc"><i>255</i> assert Long.bitCount(mask) == subNodes.length;</b>
<b class="fc"><i>256</i> for (int i = 0; i < keys.length; ++i) {</b>
<b class="fc"><i>257</i> if (subNodes[i] instanceof Node) {</b>
<b class="fc"><i>258</i> assert keys[i] == null;</b>
<i>259</i> } else {
<b class="fc"><i>260</i> assert keys[i] != null;</b>
<i>261</i> }
<i>262</i> }
<b class="fc"><i>263</i> return true;</b>
<i>264</i> }
<i>265</i>
<i>266</i> @Override
<i>267</i> boolean isEmpty() {
<b class="fc"><i>268</i> return mask == 0;</b>
<i>269</i> }
<i>270</i>
<i>271</i> @SuppressWarnings("unchecked")
<i>272</i> InnerNode() {
<b class="fc"><i>273</i> this(0, (K[]) EMPTY_ARRAY, EMPTY_ARRAY);</b>
<b class="fc"><i>274</i> }</b>
<i>275</i>
<i>276</i> @Override
<i>277</i> void visit(Deque<Map.Entry<K, V>> entries, Deque<Node<K, V>> nodes) {
<b class="fc"><i>278</i> for (int i = 0; i < keys.length; ++i) {</b>
<b class="fc"><i>279</i> final Object sub = subNodes[i];</b>
<b class="fc"><i>280</i> if (sub instanceof Node) {</b>
<i>281</i> @SuppressWarnings("unchecked")
<b class="fc"><i>282</i> final Node<K, V> subNode = (Node<K, V>) sub;</b>
<b class="fc"><i>283</i> assert keys[i] == null;</b>
<b class="fc"><i>284</i> nodes.add(subNode);</b>
<b class="fc"><i>285</i> } else {</b>
<i>286</i> @SuppressWarnings("unchecked")
<b class="fc"><i>287</i> final V value = (V) sub;</b>
<b class="fc"><i>288</i> entries.add(new AbstractMap.SimpleImmutableEntry<>(keys[i], value));</b>
<i>289</i> }
<i>290</i> }
<b class="fc"><i>291</i> }</b>
<i>292</i>
<i>293</i> /**
<i>294</i> * For a given hash on 6 bits, its value is set if the bitmap has a one
<i>295</i> * at the corresponding index.
<i>296</i> */
<i>297</i> private boolean exists(int hash6) {
<b class="fc"><i>298</i> return (mask & (1L << hash6)) != 0;</b>
<i>299</i> }
<i>300</i>
<i>301</i> /**
<i>302</i> * For a given hash on 6 bits, the slot number is the number of one
<i>303</i> * bits on the right of the <code>hash6</code>-th bit.
<i>304</i> */
<i>305</i> private int slot(int hash6) {
<b class="fc"><i>306</i> return Long.bitCount(mask & ((1L << hash6) - 1));</b>
<i>307</i> }
<i>308</i>
<i>309</i> @Override
<i>310</i> V get(Object key, int hash) {
<b class="fc"><i>311</i> final int hash6 = hash & HASH_MASK;</b>
<b class="fc"><i>312</i> if (!exists(hash6)) {</b>
<b class="fc"><i>313</i> return null;</b>
<i>314</i> }
<b class="fc"><i>315</i> final int slot = slot(hash6);</b>
<b class="fc"><i>316</i> final Object sub = subNodes[slot];</b>
<b class="fc"><i>317</i> assert sub != null;</b>
<b class="fc"><i>318</i> if (sub instanceof Node) {</b>
<b class="fc"><i>319</i> assert keys[slot] == null; // keys don't make sense on inner nodes</b>
<i>320</i> @SuppressWarnings("unchecked")
<b class="fc"><i>321</i> final Node<K, V> subNode = (Node<K, V>) sub;</b>
<b class="fc"><i>322</i> return subNode.get(key, hash >>> HASH_BITS);</b>
<i>323</i> } else {
<b class="fc"><i>324</i> if (keys[slot].equals(key)) {</b>
<i>325</i> @SuppressWarnings("unchecked")
<b class="fc"><i>326</i> final V v = (V) sub;</b>
<b class="fc"><i>327</i> return v;</b>
<i>328</i> } else {
<i>329</i> // we have an entry for this hash, but the value is different
<b class="fc"><i>330</i> return null;</b>
<i>331</i> }
<i>332</i> }
<i>333</i> }
<i>334</i>
<i>335</i> private Node<K, V> newSubNode(int hashBits) {
<b class="fc"><i>336</i> if (hashBits <= 0) {</b>
<b class="nc"><i>337</i> return new Leaf<K, V>();</b>
<i>338</i> } else {
<b class="fc"><i>339</i> return new InnerNode<K, V>();</b>
<i>340</i> }
<i>341</i> }
<i>342</i>
<i>343</i> private InnerNode<K, V> putExisting(K key, int hash, int hashBits, int slot, V value, MutableValueInt newValue) {
<b class="fc"><i>344</i> final K[] keys2 = Arrays.copyOf(keys, keys.length);</b>
<b class="fc"><i>345</i> final Object[] subNodes2 = Arrays.copyOf(subNodes, subNodes.length);</b>
<i>346</i>
<b class="fc"><i>347</i> final Object previousValue = subNodes2[slot];</b>
<b class="fc"><i>348</i> if (previousValue instanceof Node) {</b>
<i>349</i> // insert recursively
<b class="fc"><i>350</i> assert keys[slot] == null;</b>
<b class="fc"><i>351</i> subNodes2[slot] = ((Node<K, V>) previousValue).put(key, hash, hashBits, value, newValue);</b>
<b class="fc"><i>352</i> } else if (keys[slot].equals(key)) {</b>
<i>353</i> // replace the existing entry
<b class="fc"><i>354</i> subNodes2[slot] = value;</b>
<i>355</i> } else {
<i>356</i> // hash collision
<b class="fc"><i>357</i> final K previousKey = keys[slot];</b>
<b class="fc"><i>358</i> final int previousHash = previousKey.hashCode() >>> (TOTAL_HASH_BITS - hashBits);</b>
<b class="fc"><i>359</i> Node<K, V> subNode = newSubNode(hashBits);</b>
<b class="fc"><i>360</i> subNode = subNode.put(previousKey, previousHash, hashBits, (V) previousValue, newValue);</b>
<b class="fc"><i>361</i> subNode = subNode.put(key, hash, hashBits, value, newValue);</b>
<b class="fc"><i>362</i> keys2[slot] = null;</b>
<b class="fc"><i>363</i> subNodes2[slot] = subNode;</b>
<i>364</i> }
<b class="fc"><i>365</i> return new InnerNode<>(mask, keys2, subNodes2);</b>
<i>366</i> }
<i>367</i>
<i>368</i> private InnerNode<K, V> putNew(K key, int hash6, int slot, V value) {
<b class="fc"><i>369</i> final long mask2 = mask | (1L << hash6);</b>
<b class="fc"><i>370</i> final K[] keys2 = insertElement(keys, key, slot);</b>
<b class="fc"><i>371</i> final Object[] subNodes2 = insertElement(subNodes, value, slot);</b>
<b class="fc"><i>372</i> return new InnerNode<>(mask2, keys2, subNodes2);</b>
<i>373</i> }
<i>374</i>
<i>375</i> @Override
<i>376</i> InnerNode<K, V> put(K key, int hash, int hashBits, V value, MutableValueInt newValue) {
<b class="fc"><i>377</i> final int hash6 = hash & HASH_MASK;</b>
<b class="fc"><i>378</i> final int slot = slot(hash6);</b>
<i>379</i>
<b class="fc"><i>380</i> if (exists(hash6)) {</b>
<b class="fc"><i>381</i> hash >>>= HASH_BITS;</b>
<b class="fc"><i>382</i> hashBits -= HASH_BITS;</b>
<b class="fc"><i>383</i> return putExisting(key, hash, hashBits, slot, value, newValue);</b>
<i>384</i> } else {
<b class="fc"><i>385</i> newValue.value = 1;</b>
<b class="fc"><i>386</i> return putNew(key, hash6, slot, value);</b>
<i>387</i> }
<i>388</i> }
<i>389</i>
<i>390</i> private InnerNode<K, V> removeSlot(int hash6, int slot) {
<b class="nc"><i>391</i> final long mask2 = mask & ~(1L << hash6);</b>
<b class="nc"><i>392</i> final K[] keys2 = removeArrayElement(keys, slot);</b>
<b class="nc"><i>393</i> final Object[] subNodes2 = removeArrayElement(subNodes, slot);</b>
<b class="nc"><i>394</i> return new InnerNode<>(mask2, keys2, subNodes2);</b>
<i>395</i> }
<i>396</i>
<i>397</i> @Override
<i>398</i> InnerNode<K, V> remove(Object key, int hash) {
<b class="nc"><i>399</i> final int hash6 = hash & HASH_MASK;</b>
<b class="nc"><i>400</i> if (!exists(hash6)) {</b>
<b class="nc"><i>401</i> return this;</b>
<i>402</i> }
<b class="nc"><i>403</i> final int slot = slot(hash6);</b>
<b class="nc"><i>404</i> final Object previousValue = subNodes[slot];</b>
<b class="nc"><i>405</i> if (previousValue instanceof Node) {</b>
<i>406</i> @SuppressWarnings("unchecked")
<b class="nc"><i>407</i> final Node<K, V> subNode = (Node<K, V>) previousValue;</b>
<b class="nc"><i>408</i> final Node<K, V> removed = subNode.remove(key, hash >>> HASH_BITS);</b>
<b class="nc"><i>409</i> if (removed == subNode) {</b>
<i>410</i> // not in sub-nodes
<b class="nc"><i>411</i> return this;</b>
<i>412</i> }
<b class="nc"><i>413</i> if (removed.isEmpty()) {</b>
<b class="nc"><i>414</i> return removeSlot(hash6, slot);</b>
<i>415</i> }
<b class="nc"><i>416</i> final K[] keys2 = Arrays.copyOf(keys, keys.length);</b>
<b class="nc"><i>417</i> final Object[] subNodes2 = Arrays.copyOf(subNodes, subNodes.length);</b>
<b class="nc"><i>418</i> subNodes2[slot] = removed;</b>
<b class="nc"><i>419</i> return new InnerNode<>(mask, keys2, subNodes2);</b>
<b class="nc"><i>420</i> } else if (keys[slot].equals(key)) {</b>
<i>421</i> // remove entry
<b class="nc"><i>422</i> return removeSlot(hash6, slot);</b>
<i>423</i> } else {
<i>424</i> // hash collision, nothing to remove
<b class="nc"><i>425</i> return this;</b>
<i>426</i> }
<i>427</i> }
<i>428</i>
<i>429</i> }
<i>430</i>
<i>431</i> private static class EntryIterator<K, V> implements Iterator<Map.Entry<K, V>> {
<i>432</i>
<i>433</i> private final Deque<Map.Entry<K, V>> entries;
<i>434</i> private final Deque<Node<K, V>> nodes;
<i>435</i>
<b class="fc"><i>436</i> EntryIterator(Node<K, V> node) {</b>
<b class="fc"><i>437</i> entries = new ArrayDeque<>();</b>
<b class="fc"><i>438</i> nodes = new ArrayDeque<>();</b>
<b class="fc"><i>439</i> node.visit(entries, nodes);</b>
<b class="fc"><i>440</i> }</b>
<i>441</i>
<i>442</i> @Override
<i>443</i> public boolean hasNext() {
<b class="fc"><i>444</i> return !entries.isEmpty() || !nodes.isEmpty();</b>
<i>445</i> }
<i>446</i>
<i>447</i> @Override
<i>448</i> public Map.Entry<K, V> next() {
<b class="fc"><i>449</i> while (entries.isEmpty()) {</b>
<b class="fc"><i>450</i> if (nodes.isEmpty()) {</b>
<b class="nc"><i>451</i> throw new NoSuchElementException();</b>
<i>452</i> }
<b class="fc"><i>453</i> final Node<K, V> nextNode = nodes.pop();</b>
<b class="fc"><i>454</i> nextNode.visit(entries, nodes);</b>
<b class="fc"><i>455</i> }</b>
<b class="fc"><i>456</i> return entries.pop();</b>
<i>457</i> }
<i>458</i>
<i>459</i> @Override
<i>460</i> public final void remove() {
<b class="nc"><i>461</i> throw new UnsupportedOperationException();</b>
<i>462</i> }
<i>463</i>
<i>464</i> }
<i>465</i>
<i>466</i> private final InnerNode<K, V> root;
<i>467</i> private final int size;
<i>468</i>
<i>469</i> /**
<i>470</i> * Create a new empty map.
<i>471</i> */
<i>472</i> public CopyOnWriteHashMap() {
<b class="fc"><i>473</i> this(new InnerNode<K, V>(), 0);</b>
<b class="fc"><i>474</i> }</b>
<i>475</i>
<b class="fc"><i>476</i> private CopyOnWriteHashMap(InnerNode<K, V> root, int size) {</b>
<b class="fc"><i>477</i> this.root = root;</b>
<b class="fc"><i>478</i> this.size = size;</b>
<b class="fc"><i>479</i> }</b>
<i>480</i>
<i>481</i> @Override
<i>482</i> public boolean containsKey(Object key) {
<i>483</i> // works fine since null values are not supported
<b class="fc"><i>484</i> return get(key) != null;</b>
<i>485</i> }
<i>486</i>
<i>487</i> @Override
<i>488</i> public V get(Object key) {
<b class="fc"><i>489</i> if (key == null) {</b>
<b class="nc"><i>490</i> throw new IllegalArgumentException("null keys are not supported");</b>
<i>491</i> }
<b class="fc"><i>492</i> final int hash = key.hashCode();</b>
<b class="fc"><i>493</i> return root.get(key, hash);</b>
<i>494</i> }
<i>495</i>
<i>496</i> @Override
<i>497</i> public int size() {
<b class="fc"><i>498</i> assert size != 0 || root.isEmpty();</b>
<b class="fc"><i>499</i> return size;</b>
<i>500</i> }
<i>501</i>
<i>502</i> /**
<i>503</i> * Associate <code>key</code> with <code>value</code> and return a new copy
<i>504</i> * of the hash table. The current hash table is not modified.
<i>505</i> */
<i>506</i> public CopyOnWriteHashMap<K, V> copyAndPut(K key, V value) {
<b class="fc"><i>507</i> if (key == null) {</b>
<b class="nc"><i>508</i> throw new IllegalArgumentException("null keys are not supported");</b>
<i>509</i> }
<b class="fc"><i>510</i> if (value == null) {</b>
<b class="nc"><i>511</i> throw new IllegalArgumentException("null values are not supported");</b>
<i>512</i> }
<b class="fc"><i>513</i> final int hash = key.hashCode();</b>
<b class="fc"><i>514</i> final MutableValueInt newValue = new MutableValueInt();</b>
<b class="fc"><i>515</i> final InnerNode<K, V> newRoot = root.put(key, hash, TOTAL_HASH_BITS, value, newValue);</b>
<b class="fc"><i>516</i> final int newSize = size + newValue.value;</b>
<b class="fc"><i>517</i> return new CopyOnWriteHashMap<>(newRoot, newSize);</b>
<i>518</i> }
<i>519</i>
<i>520</i> /**
<i>521</i> * Same as {@link #copyAndPut(Object, Object)} but for an arbitrary number of entries.
<i>522</i> */
<i>523</i> public CopyOnWriteHashMap<K, V> copyAndPutAll(Map<? extends K, ? extends V> other) {
<b class="fc"><i>524</i> return copyAndPutAll(other.entrySet());</b>
<i>525</i> }
<i>526</i>
<i>527</i> public <K1 extends K, V1 extends V> CopyOnWriteHashMap<K, V> copyAndPutAll(Iterable<Entry<K1, V1>> entries) {
<b class="fc"><i>528</i> CopyOnWriteHashMap<K, V> result = this;</b>
<b class="fc"><i>529</i> for (Entry<K1, V1> entry : entries) {</b>
<b class="fc"><i>530</i> result = result.copyAndPut(entry.getKey(), entry.getValue());</b>
<b class="fc"><i>531</i> }</b>
<b class="fc"><i>532</i> return result;</b>
<i>533</i> }
<i>534</i>
<i>535</i> public <K1 extends K, V1 extends V> CopyOnWriteHashMap<K, V> copyAndPutAll(Stream<Entry<K1, V1>> entries) {
<b class="nc"><i>536</i> return copyAndPutAll(entries::iterator);</b>
<i>537</i> }
<i>538</i>
<i>539</i> /**
<i>540</i> * Remove the given key from this map. The current hash table is not modified.
<i>541</i> */
<i>542</i> public CopyOnWriteHashMap<K, V> copyAndRemove(Object key) {
<b class="nc"><i>543</i> if (key == null) {</b>
<b class="nc"><i>544</i> throw new IllegalArgumentException("null keys are not supported");</b>
<i>545</i> }
<b class="nc"><i>546</i> final int hash = key.hashCode();</b>
<b class="nc"><i>547</i> final InnerNode<K, V> newRoot = root.remove(key, hash);</b>
<b class="nc"><i>548</i> if (root == newRoot) {</b>
<b class="nc"><i>549</i> return this;</b>
<i>550</i> } else {
<b class="nc"><i>551</i> return new CopyOnWriteHashMap<>(newRoot, size - 1);</b>
<i>552</i> }
<i>553</i> }
<i>554</i>
<i>555</i> /**
<i>556</i> * Same as {@link #copyAndRemove(Object)} but for an arbitrary number of entries.
<i>557</i> */
<i>558</i> public CopyOnWriteHashMap<K, V> copyAndRemoveAll(Collection<?> keys) {
<b class="nc"><i>559</i> CopyOnWriteHashMap<K, V> result = this;</b>
<b class="nc"><i>560</i> for (Object key : keys) {</b>
<b class="nc"><i>561</i> result = result.copyAndRemove(key);</b>
<b class="nc"><i>562</i> }</b>
<b class="nc"><i>563</i> return result;</b>
<i>564</i> }
<i>565</i>
<i>566</i> @Override
<i>567</i> public Set<Map.Entry<K, V>> entrySet() {
<b class="fc"><i>568</i> return new AbstractSet<Map.Entry<K, V>>() {</b>
<i>569</i>
<i>570</i> @Override
<i>571</i> public Iterator<java.util.Map.Entry<K, V>> iterator() {
<b class="fc"><i>572</i> return new EntryIterator<>(root);</b>
<i>573</i> }
<i>574</i>
<i>575</i> @Override
<i>576</i> public boolean contains(Object o) {
<b class="nc"><i>577</i> if (o == null || !(o instanceof Map.Entry)) {</b>
<b class="nc"><i>578</i> return false;</b>
<i>579</i> }
<b class="nc"><i>580</i> Map.Entry<?, ?> entry = (java.util.Map.Entry<?, ?>) o;</b>
<b class="nc"><i>581</i> return entry.getValue().equals(CopyOnWriteHashMap.this.get(entry.getKey()));</b>
<i>582</i> }
<i>583</i>
<i>584</i> @Override
<i>585</i> public int size() {
<b class="nc"><i>586</i> return CopyOnWriteHashMap.this.size();</b>
<i>587</i> }
<i>588</i> };
<i>589</i> }
<i>590</i>
<i>591</i> }
</div>
</div>
<div class="footer">
<div style="float:right;">generated on 2020-02-09 18:46</div>
</div>
</body>
</html>
| 48.782497 | 153 | 0.548939 |
6b887cbbe1691303f3f9d4c5bcf8381d5ade9f8e | 5,421 | sql | SQL | db.sql | jimbaldwin123/laratest | 12f3bb26779b11eecd348023e285ec550405acd9 | [
"MIT"
] | null | null | null | db.sql | jimbaldwin123/laratest | 12f3bb26779b11eecd348023e285ec550405acd9 | [
"MIT"
] | null | null | null | db.sql | jimbaldwin123/laratest | 12f3bb26779b11eecd348023e285ec550405acd9 | [
"MIT"
] | null | null | null | -- MySQL dump 10.13 Distrib 5.7.11, for Linux (x86_64)
--
-- Host: localhost Database: homestead
-- ------------------------------------------------------
-- Server version 5.7.11
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `migrations`
--
DROP TABLE IF EXISTS `migrations`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `migrations` (
`migration` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `migrations`
--
LOCK TABLES `migrations` WRITE;
/*!40000 ALTER TABLE `migrations` DISABLE KEYS */;
INSERT INTO `migrations` VALUES ('2014_10_12_000000_create_users_table',1),('2014_10_12_100000_create_password_resets_table',1),('2016_03_08_155730_create_sessions_table',1);
/*!40000 ALTER TABLE `migrations` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `password_resets`
--
DROP TABLE IF EXISTS `password_resets`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `password_resets` (
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`token` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NOT NULL,
KEY `password_resets_email_index` (`email`),
KEY `password_resets_token_index` (`token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `password_resets`
--
LOCK TABLES `password_resets` WRITE;
/*!40000 ALTER TABLE `password_resets` DISABLE KEYS */;
/*!40000 ALTER TABLE `password_resets` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `sessions`
--
DROP TABLE IF EXISTS `sessions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sessions` (
`id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`user_id` int(11) DEFAULT NULL,
`ip_address` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
`user_agent` text COLLATE utf8_unicode_ci,
`payload` text COLLATE utf8_unicode_ci NOT NULL,
`last_activity` int(11) NOT NULL,
UNIQUE KEY `sessions_id_unique` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `sessions`
--
LOCK TABLES `sessions` WRITE;
/*!40000 ALTER TABLE `sessions` DISABLE KEYS */;
/*!40000 ALTER TABLE `sessions` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`remember_token` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `users_email_unique` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `users`
--
LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
INSERT INTO `users` VALUES (2,'Timmy Johnson','[email protected]','$2y$10$dW79LsRNhJZmJEeVmK8rq.eeD4Y3bCvekMa4QDl5jglHaaYs5pDFS','7fH6U0ikSbEIEQjL6XzD2rgujvqeMEUcolN0NDAMgwz6IoEa9g71ZWOyDdKK','2016-03-08 19:28:45','2016-03-08 20:33:54'),(3,'Git McClain','[email protected]','$2y$10$4ttrxZbzztOiHHOo1SPUGO5G3sgIP43FHHUmXe2r0sLJZQj2HMwT2','xJygaxn9we20b6gmKY36D9PvzoIloQMCijcoC9YKW350zeyGtT3vItqjUjXa',NULL,'2016-03-08 19:51:59'),(4,'Jim Baldwin','[email protected]','$2y$10$rOFnyi1or8IvsRbuq5n8o.utcuYHZgX6OF0vhusNJZByFG5yk7vqa','7clhV9rNqJg0C9rduEl8WoGsfvHmqpD5DYuL0239BcXAqLzqPaxFBj6QYAxU',NULL,'2016-03-08 20:03:06'),(5,'Your Emailaddress','[email protected]','$2y$10$4/s..EXMhLHVeHTETuE2D.5jORTHJaMC6kYszXdev36JwiRvo0HRy',NULL,NULL,NULL);
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2016-03-08 22:20:29
| 40.759398 | 750 | 0.745434 |
c4d6f4c640c6a198b16107affd57019eb06232b7 | 246 | sql | SQL | Ex10.sql | cs-fullstack-2019-spring/sql-join-cw-MelaatiJ | b2ead15ff703692e9d24730abc17ad999bae5676 | [
"Apache-2.0"
] | null | null | null | Ex10.sql | cs-fullstack-2019-spring/sql-join-cw-MelaatiJ | b2ead15ff703692e9d24730abc17ad999bae5676 | [
"Apache-2.0"
] | null | null | null | Ex10.sql | cs-fullstack-2019-spring/sql-join-cw-MelaatiJ | b2ead15ff703692e9d24730abc17ad999bae5676 | [
"Apache-2.0"
] | null | null | null | -- SQL
-- 10. Show the average each person pays for rent each year.
select people.name, avg(address.rent * 12)
from address
inner join people
on people.id=address.id
group by people.name;
-- results:
-- B 13200
-- C 13200
-- D 25500
-- A 9600
| 15.375 | 60 | 0.699187 |
f037e3032ce0ce519e6e32edcbecb11a4130e35e | 1,595 | js | JavaScript | www/js/search_worker.js | xqqy/myfuzhong | 25e7f6e79b65a4e2c550f4b8d43a35f5030fcf1b | [
"Apache-2.0"
] | 1 | 2018-01-27T15:48:01.000Z | 2018-01-27T15:48:01.000Z | www/js/search_worker.js | xqqy/myfuzhong | 25e7f6e79b65a4e2c550f4b8d43a35f5030fcf1b | [
"Apache-2.0"
] | null | null | null | www/js/search_worker.js | xqqy/myfuzhong | 25e7f6e79b65a4e2c550f4b8d43a35f5030fcf1b | [
"Apache-2.0"
] | null | null | null | var list,all;
function dialogAlert(message, title, buttonname, callback) { //通知服务
title = title || "错误";
buttonname = buttonname || "确定";
callback = callback || function () {
return;
}
if(navigator.notification){
navigator.notification.alert(message, callback, title, buttonname);
}else{
alert(message);
}
}
function get(e) {//获取列表
var data=new FormData;
data.append("UID",e.data[2]);
data.append("TOKEN",e.data[3]);
var xhr = new XMLHttpRequest;
xhr.open("post", e.data[1], true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
if (xhr.responseText.split("/meow/")[0] == "done") {
list = xhr.responseText.split("/meow/");
all = list.length
onmsg(e)
} else {
dialogAlert(xhr.responseText);
close();
}
} else {
dialogAlert("网络不能连接") + xhr.status;
close();
}
}
}
xhr.send(data);
}
onmessage = onmsg;
function onmsg(e) {
if(!list){
get(e);
return;
}
var now = 1,
ret = "";
while (now < all) {
if (list[now+2].toUpperCase().indexOf(document.getElementById("search").value.toUpperCase()) > -1) {
ret+='<a href="#" class="collection-item" onclick="ati('+"'"+list[now+1]+"'"+','+"'"+list[now]+"'"+')">'+list[now+2]+'</a>';
}
now += 3;
}
postMessage(ret);
}; | 29 | 136 | 0.485893 |
70a6e0f0a13f501ae201c9ac8000211bff2a4632 | 2,374 | go | Go | rule/lefv.go | vlifesystems/rhkit | 44847ab03a28c7b03fa35220bc807d0cf20d7f8a | [
"MIT"
] | 1 | 2017-12-02T16:09:15.000Z | 2017-12-02T16:09:15.000Z | rule/lefv.go | vlifesystems/rhkit | 44847ab03a28c7b03fa35220bc807d0cf20d7f8a | [
"MIT"
] | null | null | null | rule/lefv.go | vlifesystems/rhkit | 44847ab03a28c7b03fa35220bc807d0cf20d7f8a | [
"MIT"
] | null | null | null | // Copyright (C) 2016-2018 vLife Systems Ltd <http://vlifesystems.com>
// Licensed under an MIT licence. Please see LICENSE.md for details.
package rule
import (
"fmt"
"github.com/lawrencewoodman/ddataset"
"github.com/lawrencewoodman/dlit"
"github.com/vlifesystems/rhkit/description"
"github.com/vlifesystems/rhkit/internal"
)
// LEFV represents a rule determining if field <= value
type LEFV struct {
field string
value *dlit.Literal
}
func init() {
registerGenerator("LEFV", generateLEFV)
}
func NewLEFV(field string, value *dlit.Literal) *LEFV {
return &LEFV{field: field, value: value}
}
func (r *LEFV) String() string {
return fmt.Sprintf("%s <= %s", r.field, r.value)
}
func (r *LEFV) Value() *dlit.Literal {
return r.value
}
func (r *LEFV) IsTrue(record ddataset.Record) (bool, error) {
lh, ok := record[r.field]
if !ok {
return false, InvalidRuleError{Rule: r}
}
if lhInt, lhIsInt := lh.Int(); lhIsInt {
if v, ok := r.value.Int(); ok {
return lhInt <= v, nil
}
}
if lhFloat, lhIsFloat := lh.Float(); lhIsFloat {
if v, ok := r.value.Float(); ok {
return lhFloat <= v, nil
}
}
return false, IncompatibleTypesRuleError{Rule: r}
}
func (r *LEFV) Tweak(
inputDescription *description.Description,
stage int,
) []Rule {
points := generateTweakPoints(
r.value,
inputDescription.Fields[r.field].Min,
inputDescription.Fields[r.field].Max,
inputDescription.Fields[r.field].MaxDP,
stage,
)
rules := make([]Rule, len(points))
for i, p := range points {
rules[i] = NewLEFV(r.field, p)
}
return rules
}
func (r *LEFV) Fields() []string {
return []string{r.field}
}
func (r *LEFV) Overlaps(o Rule) bool {
switch x := o.(type) {
case *LEFV:
oField := x.Fields()[0]
return r.field == oField
}
return false
}
func (r *LEFV) DPReduce() []Rule {
return roundRules(r.value, func(p *dlit.Literal) Rule {
return NewLEFV(r.field, p)
})
}
func generateLEFV(
inputDescription *description.Description,
generationDesc GenerationDescriber,
) []Rule {
rules := make([]Rule, 0)
for _, field := range generationDesc.Fields() {
fd := inputDescription.Fields[field]
if !generationDesc.Deny("LEFV", field) && fd.Kind == description.Number {
points := internal.GeneratePoints(fd.Min, fd.Max, fd.MaxDP)
for _, p := range points {
rules = append(rules, NewLEFV(field, p))
}
}
}
return rules
}
| 21.581818 | 75 | 0.673968 |
017122a7fb8b1706758a18fe85846f5134231fc0 | 254 | lua | Lua | src/shared/Utils/Janitor/Symbol.lua | RBLXUtils/BetterWaitForChild | a277455d2791ba3f1d1ed0cf7a5bec994548e5f5 | [
"MIT"
] | 1 | 2021-10-21T07:01:35.000Z | 2021-10-21T07:01:35.000Z | src/shared/Utils/Janitor/Symbol.lua | RBLXUtils/BetterWaitForChild | a277455d2791ba3f1d1ed0cf7a5bec994548e5f5 | [
"MIT"
] | null | null | null | src/shared/Utils/Janitor/Symbol.lua | RBLXUtils/BetterWaitForChild | a277455d2791ba3f1d1ed0cf7a5bec994548e5f5 | [
"MIT"
] | null | null | null | -- This only exists because the LSP warns Key `__tostring` not found in type `table?`.
return function(Name: string)
local self = newproxy(true)
local Metatable = getmetatable(self)
function Metatable.__tostring()
return Name
end
return self
end | 23.090909 | 86 | 0.755906 |
706005dd7e8a1bcf4d52f75344841b7d79889e2e | 1,503 | go | Go | ezmqx/ezmqxerrorcode.go | chcho79/protocol-ezmq-plus-go | 29ae31bc9c96834efe52c21a45275f6bebad9565 | [
"Apache-2.0"
] | null | null | null | ezmqx/ezmqxerrorcode.go | chcho79/protocol-ezmq-plus-go | 29ae31bc9c96834efe52c21a45275f6bebad9565 | [
"Apache-2.0"
] | null | null | null | ezmqx/ezmqxerrorcode.go | chcho79/protocol-ezmq-plus-go | 29ae31bc9c96834efe52c21a45275f6bebad9565 | [
"Apache-2.0"
] | 2 | 2020-04-01T06:05:42.000Z | 2020-04-01T06:45:43.000Z | /*******************************************************************************
* Copyright 2018 Samsung Electronics 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.
*
*******************************************************************************/
package ezmqx
type EZMQXErrorCode int
// Constants represents EZMQX error codes.
const (
EZMQX_OK = 0
EZMQX_INVALID_PARAM = 1
EZMQX_INITIALIZED = 2
EZMQX_NOT_INITIALIZED = 3
EZMQX_TERMINATED = 4
EZMQX_UNKNOWN_STATE = 5
EZMQX_SERVICE_UNAVAILABLE = 6
EZMQX_INVALID_TOPIC = 7
EZMQX_DUPLICATED_TOPIC = 8
EZMQX_UNKNOWN_TOPIC = 9
EZMQX_INVALID_ENDPOINT = 10
EZMQX_BROKEN_PAYLOAD = 11
EZMQX_REST_ERROR = 12
EZMQX_MAXIMUM_PORT_EXCEED = 13
EZMQX_RELEASE_WRONG_PORT = 14
EZMQX_NO_TOPIC_MATCHED = 15
EZMQX_TNS_NOT_AVAILABLE = 16
EZMQX_UNKNOWN_AML_MODEL = 17
EZMQX_INVALID_AML_MODEL = 18
EZMQX_SESSION_UNAVAILABLE = 19
)
| 33.4 | 81 | 0.648037 |
43d32886e7366c537eaaae41282fdc11187d2636 | 497 | go | Go | example/go/wordLength/main.go | wbuchwalter/lox | 6fdd880279b2c08a121a802ee610d607e8f64327 | [
"Apache-2.0"
] | 24 | 2016-07-12T19:09:37.000Z | 2021-05-27T11:32:57.000Z | example/go/wordLength/main.go | wbuchwalter/lox | 6fdd880279b2c08a121a802ee610d607e8f64327 | [
"Apache-2.0"
] | 2 | 2016-07-10T00:35:14.000Z | 2016-07-10T02:51:37.000Z | example/go/wordLength/main.go | wbuchwalter/lox | 6fdd880279b2c08a121a802ee610d607e8f64327 | [
"Apache-2.0"
] | 1 | 2018-02-08T18:59:27.000Z | 2018-02-08T18:59:27.000Z | package main
import (
"encoding/json"
"github.com/wbuchwalter/azul/azul-go"
"github.com/wbuchwalter/azul/azul-go/logs"
)
type input struct {
Word string `json:"word"`
}
type Output struct {
Length int `json:"length"`
}
func main() {
azul.Handle(func(event json.RawMessage, logger logs.Logger) (interface{}, error) {
var i input
var output Output
err := json.Unmarshal(event, &i)
if err != nil {
return nil, err
}
output.Length = len(i.Word)
return output, nil
})
}
| 15.060606 | 83 | 0.67002 |
e71c2281359e85bc0e6f9a37c39e0e5bae4b55f9 | 4,622 | js | JavaScript | doc/html/c_j_s_o_n_8h.js | eugen-vusak/finding-mutations-using-3th-gen-sequencing | f7515053fbde23abcaa1620d7725390d1ebb3e82 | [
"MIT"
] | null | null | null | doc/html/c_j_s_o_n_8h.js | eugen-vusak/finding-mutations-using-3th-gen-sequencing | f7515053fbde23abcaa1620d7725390d1ebb3e82 | [
"MIT"
] | null | null | null | doc/html/c_j_s_o_n_8h.js | eugen-vusak/finding-mutations-using-3th-gen-sequencing | f7515053fbde23abcaa1620d7725390d1ebb3e82 | [
"MIT"
] | null | null | null | var c_j_s_o_n_8h =
[
[ "cJSON", "structc_j_s_o_n.html", "structc_j_s_o_n" ],
[ "cJSON_Hooks", "structc_j_s_o_n___hooks.html", "structc_j_s_o_n___hooks" ],
[ "cJSON_Array", "c_j_s_o_n_8h.html#a57cffa126740a8efcdcb7bcef80e8897", null ],
[ "cJSON_ArrayForEach", "c_j_s_o_n_8h.html#ac3d6e5782fb4bb3c7a25c7c5b1868f06", null ],
[ "CJSON_CDECL", "c_j_s_o_n_8h.html#a79203c3ba406ffd5736627cc1e082e38", null ],
[ "CJSON_DOUBLE_PRECISION", "c_j_s_o_n_8h.html#a52e1b995c3e4e1fcb748fcdf5e2348d4", null ],
[ "cJSON_False", "c_j_s_o_n_8h.html#a2d240682316354b5748f909ad220184b", null ],
[ "cJSON_Invalid", "c_j_s_o_n_8h.html#a80c36e86d8d65b697bc623fe28027668", null ],
[ "cJSON_IsReference", "c_j_s_o_n_8h.html#ad3d18116aae3bfa46f13bcfd7fd6d4e7", null ],
[ "CJSON_NESTING_LIMIT", "c_j_s_o_n_8h.html#a9c7ac4e1b31070b787afb3a4b67727f4", null ],
[ "cJSON_NULL", "c_j_s_o_n_8h.html#aeadaba63ddb68aaa518528595d503dcd", null ],
[ "cJSON_Number", "c_j_s_o_n_8h.html#a15e77e2f6457dc9b19c10ddb032af971", null ],
[ "cJSON_Object", "c_j_s_o_n_8h.html#a22c6e13481c090629afbd77b7cebd24c", null ],
[ "CJSON_PUBLIC", "c_j_s_o_n_8h.html#a70709a6f2a7e45debe4f5abe345fcb86", null ],
[ "cJSON_Raw", "c_j_s_o_n_8h.html#ae9ddc931ea84908d12f48c5b7f8731a1", null ],
[ "cJSON_SetIntValue", "c_j_s_o_n_8h.html#ae5b1335bfccc358f566bea6f7e4bfdc6", null ],
[ "cJSON_SetNumberValue", "c_j_s_o_n_8h.html#adab3f1e3586395bdb2da5a40059cb24b", null ],
[ "CJSON_STDCALL", "c_j_s_o_n_8h.html#aee2cdf14a236df79175ef257a5a94964", null ],
[ "cJSON_String", "c_j_s_o_n_8h.html#aa2cb4765308e2bbdf01988b2acdf92d9", null ],
[ "cJSON_StringIsConst", "c_j_s_o_n_8h.html#a491c3484a36f3915cc4710088f55971f", null ],
[ "cJSON_True", "c_j_s_o_n_8h.html#aad4e442b8095939decddfb67d87d9324", null ],
[ "CJSON_VERSION_MAJOR", "c_j_s_o_n_8h.html#a78f100ac5089a51941e2ca573ad8e380", null ],
[ "CJSON_VERSION_MINOR", "c_j_s_o_n_8h.html#a55a808fe6b77cef1e4c2cf02a4316301", null ],
[ "CJSON_VERSION_PATCH", "c_j_s_o_n_8h.html#a6ad7073103d4b9aaf2153add95561c47", null ],
[ "cJSON", "c_j_s_o_n_8h.html#a4c146234dfd7b6adbf13b49505e995bc", null ],
[ "cJSON_bool", "c_j_s_o_n_8h.html#aea0a1491f73d98b7cc4b8b791c408a4a", null ],
[ "cJSON_Hooks", "c_j_s_o_n_8h.html#ab67bc592e52110fee68ab8ab4140530d", null ],
[ "CJSON_PUBLIC", "c_j_s_o_n_8h.html#acc0bf2ad0de27db33e6471754c8f3ace", null ],
[ "CJSON_PUBLIC", "c_j_s_o_n_8h.html#abd55c37a5af547c3c1ada176e38afbc6", null ],
[ "CJSON_PUBLIC", "c_j_s_o_n_8h.html#aa7717765ab33f9dac70ff47e7e078b8b", null ],
[ "CJSON_PUBLIC", "c_j_s_o_n_8h.html#ad111420010c8684e2acde69bb1ead4f8", null ],
[ "CJSON_PUBLIC", "c_j_s_o_n_8h.html#a2d3690b60cffe4af76f406052e3c35e2", null ],
[ "CJSON_PUBLIC", "c_j_s_o_n_8h.html#a8172bffbb05eec3c761bf0b43484f62d", null ],
[ "CJSON_PUBLIC", "c_j_s_o_n_8h.html#a5712efac9864c56f805260c5e2a5c01b", null ],
[ "b", "c_j_s_o_n_8h.html#a1a175e87536301df98c805ac0636ad7c", null ],
[ "boolean", "c_j_s_o_n_8h.html#a08f076c86f430b6f0e301fcf94223b38", null ],
[ "buffer", "c_j_s_o_n_8h.html#aff2566f4c366b48d73479bef43ee4d2e", null ],
[ "case_sensitive", "c_j_s_o_n_8h.html#a05334336676ca1cd88db19ede4a065de", null ],
[ "count", "c_j_s_o_n_8h.html#ad43c3812e6d13e0518d9f8b8f463ffcf", null ],
[ "fmt", "c_j_s_o_n_8h.html#aa813b2b7bde1a5a1f528cd9d9aa9ee7d", null ],
[ "format", "c_j_s_o_n_8h.html#adb411a44855a4c49231d72a0fc9a3b3b", null ],
[ "index", "c_j_s_o_n_8h.html#a750b5d744c39a06bfb13e6eb010e35d0", null ],
[ "item", "c_j_s_o_n_8h.html#ac76cea59d438ba893d2f82aabb367d14", null ],
[ "length", "c_j_s_o_n_8h.html#a03c83e0884e2e3a1783db79f2d67101f", null ],
[ "name", "c_j_s_o_n_8h.html#a25d22ecc7e656d2c59332072684e8766", null ],
[ "newitem", "c_j_s_o_n_8h.html#abd13e53985a93dee588f840f06aac973", null ],
[ "number", "c_j_s_o_n_8h.html#a01b4671c6b7cc8f831c951c000a37735", null ],
[ "prebuffer", "c_j_s_o_n_8h.html#a039dc262c2ae63f95cfe193245f8ee7e", null ],
[ "raw", "c_j_s_o_n_8h.html#a788db922597cf2fb6389e278f822e59f", null ],
[ "recurse", "c_j_s_o_n_8h.html#afc8d1c385c6dc37e1c5b640869ce4ab6", null ],
[ "replacement", "c_j_s_o_n_8h.html#a10573fccca598ec39809e8beb3f7f791", null ],
[ "require_null_terminated", "c_j_s_o_n_8h.html#a3e9f50821aac02e0611c5e5a808776b9", null ],
[ "return_parse_end", "c_j_s_o_n_8h.html#a3393bb8fdfb601b078bd0c44d8e34348", null ],
[ "string", "c_j_s_o_n_8h.html#addf925fe055723aa55a381a1ba45bda2", null ],
[ "which", "c_j_s_o_n_8h.html#aa2a4dae2a14de4093826005f9bdfd3bb", null ]
]; | 79.689655 | 95 | 0.760061 |
097098c78602af6e8563f455585a29b76369d68f | 2,340 | asm | Assembly | programs/oeis/227/A227327.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | 1 | 2021-03-15T11:38:20.000Z | 2021-03-15T11:38:20.000Z | programs/oeis/227/A227327.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | null | null | null | programs/oeis/227/A227327.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | null | null | null | ; A227327: Number of non-equivalent ways to choose two points in an equilateral triangle grid of side n.
; 0,1,4,10,22,41,72,116,180,265,380,526,714,945,1232,1576,1992,2481,3060,3730,4510,5401,6424,7580,8892,10361,12012,13846,15890,18145,20640,23376,26384,29665,33252,37146,41382,45961,50920,56260,62020,68201,74844,81950,89562,97681,106352,115576,125400,135825,146900,158626,171054,184185,198072,212716,228172,244441,261580,279590,298530,318401,339264,361120,384032,408001,433092,459306,486710,515305,545160,576276,608724,642505,677692,714286,752362,791921,833040,875720,920040,966001,1013684,1063090,1114302,1167321,1222232,1279036,1337820,1398585,1461420,1526326,1593394,1662625,1734112,1807856,1883952,1962401,2043300,2126650,2212550,2301001,2392104,2485860,2582372,2681641,2783772,2888766,2996730,3107665,3221680,3338776,3459064,3582545,3709332,3839426,3972942,4109881,4250360,4394380,4542060,4693401,4848524,5007430,5170242,5336961,5507712,5682496,5861440,6044545,6231940,6423626,6619734,6820265,7025352,7234996,7449332,7668361,7892220,8120910,8354570,8593201,8836944,9085800,9339912,9599281,9864052,10134226,10409950,10691225,10978200,11270876,11569404,11873785,12184172,12500566,12823122,13151841,13486880,13828240,14176080,14530401,14891364,15258970,15633382,16014601,16402792,16797956,17200260,17609705,18026460,18450526,18882074,19321105,19767792,20222136,20684312,21154321,21632340,22118370,22612590,23115001,23625784,24144940,24672652,25208921,25753932,26307686,26870370,27441985,28022720,28612576,29211744,29820225,30438212,31065706,31702902,32349801,33006600,33673300,34350100,35037001,35734204,36441710,37159722,37888241,38627472,39377416,40138280,40910065,41692980,42487026,43292414,44109145,44937432,45777276,46628892,47492281,48367660,49255030,50154610,51066401,51990624,52927280,53876592,54838561,55813412,56801146,57801990,58815945,59843240,60883876,61938084,63005865,64087452,65182846,66292282,67415761,68553520,69705560,70872120,72053201,73249044,74459650,75685262,76925881,78181752,79452876,80739500,82041625
mov $14,$0
mov $16,$0
lpb $16
clr $0,14
mov $0,$14
sub $16,1
sub $0,$16
mov $11,$0
mov $13,$0
lpb $13
mov $0,$11
sub $13,1
sub $0,$13
mov $4,$0
mov $9,$0
div $9,2
mov $3,$9
pow $3,2
sub $4,$9
add $3,$4
add $12,$3
lpe
add $15,$12
lpe
mov $1,$15
| 80.689655 | 1,927 | 0.809829 |
0bc6ef3ed241becc1afee395cbae4a3b843d3a02 | 1,342 | js | JavaScript | app/components/layout/Header.js | yarikgenza/trello | a95f9418757aedd696ee24ee9c4be4fd4ab01a67 | [
"MIT"
] | 1 | 2017-01-07T23:57:15.000Z | 2017-01-07T23:57:15.000Z | app/components/layout/Header.js | yarikgenza/trello | a95f9418757aedd696ee24ee9c4be4fd4ab01a67 | [
"MIT"
] | null | null | null | app/components/layout/Header.js | yarikgenza/trello | a95f9418757aedd696ee24ee9c4be4fd4ab01a67 | [
"MIT"
] | null | null | null | import React, {Component} from 'react';
import {Button} from 'react-bootstrap';
export default class Header extends Component {
constructor() {
super();
this.state = {
text: ''
}
}
componentDidMount() {
const token = localStorage.getItem('token');
const {text} = this.state;
if (token) {
fetch('/api/user', {
method: 'get',
headers: {
'Content-type': 'application/json',
authorization: token
}
})
.then(res => res.json())
.then((res) => {
this.setState({
text: res.login
})
})
.catch((e) => { console.log(e) })
}
}
logOut() {
localStorage.removeItem('token');
window.location.href = '/'
}
render() {
const token = localStorage.getItem('token');
if (token) {
return (
<div className="header">
<h1 className="header_positioned">Trello</h1>
<div className="logOut">
<div className="userLogin">
<p>{this.state.text}</p>
</div>
<Button onClick={() => this.logOut()} bsStyle="info">Log out</Button>
</div>
</div>
)
} else {
return (
<div className="header">
<h1>Trello</h1>
</div>
)
}
}
}
| 20.333333 | 81 | 0.481371 |
1846dd0c1ce4dcec56c86165729bb7a2e5f1503d | 1,280 | css | CSS | public/css/print_style.css | softactor/registro.asia | 0a7bfa67bba7e153a8a361da955a7caa75a4678a | [
"MIT"
] | null | null | null | public/css/print_style.css | softactor/registro.asia | 0a7bfa67bba7e153a8a361da955a7caa75a4678a | [
"MIT"
] | null | null | null | public/css/print_style.css | softactor/registro.asia | 0a7bfa67bba7e153a8a361da955a7caa75a4678a | [
"MIT"
] | null | null | null | /*
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
*/
/*
Created on : Dec 29, 2018, 9:24:40 AM
Author : Tanveer Qureshee
*/
@media screen {
#pdf_content_section{
width: 21cm;
height: auto;
font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
font-size: 1em;
color: #333333;
}
#pdf_content_section table.pdf_table{
border-collapse: collapse;
width: 17cm;
margin-top:.5cm;
margin-right: 2cm;
margin-bottom: 1.5cm;
margin-left: 2cm;
}
#pdf_content_section table.pdf_table td {
border: 1px solid #ddd;
text-align: left;
/*padding: 2px;*/
vertical-align: top;
}
#pdf_content_section table.pdf_table th {
border: 1px solid #ddd;
text-align: left;
/*padding: 2px;*/
vertical-align: top;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
#pdf_content_section h3{
text-align: center;
text-transform: uppercase;
}
#pdf_content_section img.print_header_image {
max-width: 100% !important;
}
} | 26.122449 | 76 | 0.592188 |
75550fca0d5a5e85566d239a0507878a9a4b5726 | 881 | h | C | c/meterpreter/source/extensions/extapi/clipboard_image.h | fergonaut/metasploit-payloads | 840f8c9cb47020940db921f6d900925cff1d5a22 | [
"PSF-2.0"
] | 1,331 | 2015-04-13T22:19:39.000Z | 2022-03-31T06:59:35.000Z | c/meterpreter/source/extensions/extapi/clipboard_image.h | fergonaut/metasploit-payloads | 840f8c9cb47020940db921f6d900925cff1d5a22 | [
"PSF-2.0"
] | 489 | 2015-07-01T02:19:19.000Z | 2022-03-31T23:43:26.000Z | c/meterpreter/source/extensions/extapi/clipboard_image.h | fergonaut/metasploit-payloads | 840f8c9cb47020940db921f6d900925cff1d5a22 | [
"PSF-2.0"
] | 645 | 2015-04-21T21:53:02.000Z | 2022-03-29T05:36:14.000Z | /*!
* @file clipboard_image.h
* @brief Declarations for clipboard image handling functionality
*/
#ifndef _METERPRETER_SOURCE_EXTENSION_EXTAPI_CLIPBOARD_IMAGE_H
#define _METERPRETER_SOURCE_EXTENSION_EXTAPI_CLIPBOARD_IMAGE_H
typedef struct _ConvertedImage
{
/*!
* @brief Pointer to a pointer which will receive the JPEG image data buffer.
* This value is allocated using \c malloc prior to returning. If after
* calling this function the value is non-NULL the caller must call
* \c free to release this memory.
*/
PBYTE pImageBuffer;
/*!
* @brief The size of the \c pImageBuffer buffer.
*/
DWORD dwImageBufferSize;
} ConvertedImage;
DWORD get_bitmapinfo_size(const LPBITMAPINFO lpBI, BOOL bRGB);
DWORD convert_to_jpg(const LPBITMAPINFO lpBI, const LPVOID lpDIB, ULONG ulQuality, ConvertedImage* pImage);
#endif
| 32.62963 | 107 | 0.740068 |
6b8aa5cf9e0542343faa807661a41187705157e4 | 1,750 | h | C | suricata-4.1.4/src/detect-engine-loader.h | runtest007/dpdk_surcata_4.1.1 | 5abf91f483b418b5d9c2dd410b5c850d6ed95c5f | [
"MIT"
] | 77 | 2019-06-17T07:05:07.000Z | 2022-03-07T03:26:27.000Z | suricata-4.1.4/src/detect-engine-loader.h | clockdad/DPDK_SURICATA-4_1_1 | 974cc9eb54b0b1ab90eff12a95617e3e293b77d3 | [
"MIT"
] | 22 | 2019-07-18T02:32:10.000Z | 2022-03-24T03:39:11.000Z | suricata-4.1.4/src/detect-engine-loader.h | clockdad/DPDK_SURICATA-4_1_1 | 974cc9eb54b0b1ab90eff12a95617e3e293b77d3 | [
"MIT"
] | 49 | 2019-06-18T03:31:56.000Z | 2022-03-13T05:23:10.000Z | /* Copyright (C) 2015 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* \file
*
* \author Victor Julien <[email protected]>
*
* Detect loader API, for using multiple 'loader' threads
* that can load multiple detection engines in parallel.
*/
#ifndef __DETECT_ENGINE_LOADER_H__
#define __DETECT_ENGINE_LOADER_H__
/**
* \param ctx function specific data
* \param loader_id id of the loader that executed the task
*/
typedef int (*LoaderFunc)(void *ctx, int loader_id);
typedef struct DetectLoaderTask_ {
LoaderFunc Func;
void *ctx;
TAILQ_ENTRY(DetectLoaderTask_) next;
} DetectLoaderTask;
typedef struct DetectLoaderControl_ {
int id;
int result; /* 0 for ok, error otherwise */
SCMutex m;
TAILQ_HEAD(, DetectLoaderTask_) task_list;
} DetectLoaderControl;
int DetectLoaderQueueTask(int loader_id, LoaderFunc Func, void *func_ctx);
int DetectLoadersSync(void);
void DetectLoadersInit(void);
void TmThreadContinueDetectLoaderThreads(void);
void DetectLoaderThreadSpawn(void);
void TmModuleDetectLoaderRegister (void);
#endif /* __DETECT_ENGINE_LOADER_H__ */
| 30.172414 | 74 | 0.754286 |
11c17cffca45808b3ff136341eb793f249307f98 | 2,384 | rs | Rust | src/pointer.rs | sim82/game1 | e4cd03c91421dea3234eaf7b4f9fabbae30312be | [
"MIT"
] | null | null | null | src/pointer.rs | sim82/game1 | e4cd03c91421dea3234eaf7b4f9fabbae30312be | [
"MIT"
] | null | null | null | src/pointer.rs | sim82/game1 | e4cd03c91421dea3234eaf7b4f9fabbae30312be | [
"MIT"
] | null | null | null | use bevy::{
input::mouse::{MouseButtonInput, MouseMotion},
prelude::*,
};
pub struct MouseGrabState {
pub shall_grab: bool,
known_state: bool,
}
fn mouse_grab_system(
mut grab_state: ResMut<MouseGrabState>,
mut windows: ResMut<Windows>,
keyboard_input: Res<Input<KeyCode>>,
) {
let update = if keyboard_input.just_pressed(KeyCode::Grave) {
grab_state.shall_grab = !grab_state.shall_grab;
true
} else {
false
};
if update || !grab_state.known_state {
grab_state.known_state = true;
let window = windows.get_primary_mut().unwrap();
if window.cursor_locked() != grab_state.shall_grab {
window.set_cursor_lock_mode(grab_state.shall_grab);
window.set_cursor_visibility(!grab_state.shall_grab);
}
}
}
#[derive(Default)]
pub struct PrimaryPointerPos {
pub pos: Vec3,
}
#[derive(Debug)]
pub struct ClickEvent {
pub pos: Vec3,
}
#[derive(Component)]
pub struct MousePointerFlag;
pub fn mouse_input_system(
mut query: Query<&mut Transform, With<MousePointerFlag>>,
mut mouse_button_input_events: EventReader<MouseButtonInput>,
mut mouse_motion_events: EventReader<MouseMotion>,
mut primary_pointer: ResMut<PrimaryPointerPos>,
grab_state: Res<MouseGrabState>,
mut click_events: EventWriter<ClickEvent>,
) {
if !grab_state.shall_grab {
return;
}
for mut transform in query.iter_mut() {
for event in mouse_motion_events.iter() {
let d = Vec3::new(event.delta.x, -event.delta.y, 0.0);
transform.translation += d * 0.5;
}
primary_pointer.pos = transform.translation;
}
for event in mouse_button_input_events.iter() {
if event.button == MouseButton::Left && event.state.is_pressed() {
// info!("pressed");
click_events.send(ClickEvent {
pos: primary_pointer.pos,
})
}
}
}
pub struct PointerPlugin;
impl Plugin for PointerPlugin {
fn build(&self, app: &mut App) {
app.add_system(mouse_input_system)
.add_system(mouse_grab_system)
.init_resource::<PrimaryPointerPos>()
.insert_resource(MouseGrabState {
shall_grab: true,
known_state: false,
})
.add_event::<ClickEvent>();
}
}
| 26.786517 | 74 | 0.630453 |
10352dde39f297c81e3a71dba9fe70341fc7ee9f | 1,651 | kt | Kotlin | chapter02/src/main/kotlin/com/example/mss/chapter2/Chapter2Application.kt | aucd29/kotlin-msa | 7c0dc87a9c04edc32d75affeefff4bcdb56dd36b | [
"Apache-2.0"
] | null | null | null | chapter02/src/main/kotlin/com/example/mss/chapter2/Chapter2Application.kt | aucd29/kotlin-msa | 7c0dc87a9c04edc32d75affeefff4bcdb56dd36b | [
"Apache-2.0"
] | null | null | null | chapter02/src/main/kotlin/com/example/mss/chapter2/Chapter2Application.kt | aucd29/kotlin-msa | 7c0dc87a9c04edc32d75affeefff4bcdb56dd36b | [
"Apache-2.0"
] | null | null | null | package com.example.mss.chapter2
import com.example.mss.chapter2.service.AdvanceService
import com.example.mss.chapter2.service.ExampleService
import com.example.mss.chapter2.service.IService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
import org.springframework.boot.runApplication
import org.springframework.context.annotation.Bean
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.ResponseBody
@SpringBootApplication
class Chapter2Application {
@Bean
@ConditionalOnExpression("#{'\${service.message.type}'=='simple'}")
fun exampleService() = ExampleService()
@Bean
@ConditionalOnExpression("#{'\${service.message.type}'=='advance'}")
fun advanceService() = AdvanceService()
}
@Controller
class FirstController {
@Autowired
lateinit var service: IService
@RequestMapping(value = "/user", method = arrayOf(RequestMethod.GET))
@ResponseBody
fun hello() = "hello world"
@RequestMapping(value = "/users/{name}", method = arrayOf(RequestMethod.GET))
@ResponseBody
fun hello(@PathVariable name: String) = service.hello(name)
@RequestMapping(value = "/message", method = arrayOf(RequestMethod.GET))
@ResponseBody
fun messageText() = service.messageText()
}
fun main(args: Array<String>) {
runApplication<Chapter2Application>(*args)
}
| 33.02 | 79 | 0.806784 |
c0c040cf9759480979702cabc15cb46d14cd4a74 | 154 | sql | SQL | qal/sql/tests/resources/_test_DELETE_PostgreSQL_in.sql | OptimalBPM/qal | 4d7a31c0d68042b4110e1fa3e733711e0fdd473e | [
"Unlicense"
] | 3 | 2016-05-02T14:35:55.000Z | 2021-08-31T14:19:15.000Z | qal/sql/tests/resources/_test_DELETE_PostgreSQL_in.sql | OptimalBPM/qal | 4d7a31c0d68042b4110e1fa3e733711e0fdd473e | [
"Unlicense"
] | null | null | null | qal/sql/tests/resources/_test_DELETE_PostgreSQL_in.sql | OptimalBPM/qal | 4d7a31c0d68042b4110e1fa3e733711e0fdd473e | [
"Unlicense"
] | 1 | 2018-03-18T13:19:52.000Z | 2018-03-18T13:19:52.000Z | DELETE FROM "Test" T1
USING (SELECT 'CSV11' AS "Column1",'CSV12' AS "Column2"
UNION
SELECT 'CSV21','CSV22') AS T2 WHERE ((T2."Column1" = T1."Column1"))
| 30.8 | 68 | 0.668831 |
c80300876f15184a480ccf55f8fc137886dcc2bd | 6,618 | h | C | services/service_manager/public/cpp/service_receiver.h | mghgroup/Glide-Browser | 6a4c1eaa6632ec55014fee87781c6bbbb92a2af5 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 575 | 2015-06-18T23:58:20.000Z | 2022-03-23T09:32:39.000Z | services/service_manager/public/cpp/service_receiver.h | mghgroup/Glide-Browser | 6a4c1eaa6632ec55014fee87781c6bbbb92a2af5 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 113 | 2015-05-04T09:58:14.000Z | 2022-01-31T19:35:03.000Z | services/service_manager/public/cpp/service_receiver.h | DamieFC/chromium | 54ce2d3c77723697efd22cfdb02aea38f9dfa25c | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 52 | 2015-07-14T10:40:50.000Z | 2022-03-15T01:11:49.000Z | // Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_RECEIVER_H_
#define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_RECEIVER_H_
#include <memory>
#include "base/bind.h"
#include "base/callback.h"
#include "base/component_export.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/mojom/connector.mojom.h"
#include "services/service_manager/public/mojom/service.mojom.h"
#include "services/service_manager/public/mojom/service_control.mojom.h"
namespace service_manager {
class Service;
// Encapsulates service-side bindings to Service Manager interfaces. Namely,
// this helps receive and dispatch Service interface events to a service
// implementation, while also exposing a working Connector interface the service
// can use to make outgoing interface requests.
//
// A ServiceReceiver is considered to be "bound" after |Bind()| is invoked with
// a valid Service receiver (or the equivalent constructor is used -- see
// below). Upon connection error or an explicit call to |Close()|, the
// ServiceReceiver will be considered "unbound" until another call to |Bind()|
// is made.
//
// NOTE: A well-behaved service should aim to always close its ServiceReceiver
// gracefully by calling |RequestClose()|. Closing a ServiceReceiver abruptly
// (by either destroying it or explicitly calling |Close()|) introduces inherent
// flakiness into the system unless the Service's |OnDisconnected()| has already
// been invoked, because otherwise the Service Manager may have in-flight
// interface requests directed at your service instance and these will be
// dropped to the dismay of the service instance which issued them. Exceptions
// can reasonably be made for system-wide shutdown situations where even the
// Service Manager itself will be imminently torn down.
class COMPONENT_EXPORT(SERVICE_MANAGER_CPP) ServiceReceiver
: public mojom::Service {
public:
// Creates a new ServiceReceiver bound to |service|. The service will not
// receive any Service interface calls until |Bind()| is called, but its
// |connector()| is usable immediately upon construction.
//
// |service| is not owned and must outlive this ServiceReceiver.
explicit ServiceReceiver(service_manager::Service* service);
// Same as above, but behaves as if |Bind(receiver)| is also called
// immediately after construction. See below.
ServiceReceiver(service_manager::Service* service,
mojo::PendingReceiver<mojom::Service> receiver);
~ServiceReceiver() override;
bool is_bound() const { return receiver_.is_bound(); }
const Identity& identity() const { return identity_; }
// Returns a usable Connector which can make outgoing interface requests
// identifying as the service to which this ServiceReceiver is bound.
Connector* GetConnector();
// Binds this ServiceReceiver to a new Service receiver. Once a
// ServiceReceiver is bound, its target Service will begin receiving Service
// events. The order of events received is:
//
// - OnStart() exactly once
// - OnIdentityKnown() exactly once
// - OnBindInterface() zero or more times
//
// The target Service will be able to receive these events until this
// ServiceReceiver is either unbound or destroyed.
//
// If |receiver| is invalid, this call does nothing.
//
// Must only be called on an unbound ServiceReceiver.
void Bind(mojo::PendingReceiver<mojom::Service> receiver);
// Asks the Service Manager nicely if it's OK for this service instance to
// disappear now. If the Service Manager thinks it's OK, it will sever the
// binding's connection, ultimately triggering an |OnDisconnected()| call on
// the bound Service object.
//
// Must only be called on a bound ServiceReceiver.
void RequestClose();
// Immediately severs the connection to the Service Manager. No further
// incoming interface requests will be received until this ServiceReceiver is
// bound again. Always prefer |RequestClose()| under normal circumstances,
// unless |OnDisconnected()| has already been invoked on the Service. See the
// note in the class documentation above regarding graceful binding closure.
//
// Must only be called on a bound ServiceReceiver.
void Close();
private:
void OnConnectionError();
// mojom::Service:
void OnStart(const Identity& identity, OnStartCallback callback) override;
void OnBindInterface(const BindSourceInfo& source_info,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle interface_pipe,
OnBindInterfaceCallback callback) override;
void CreatePackagedServiceInstance(
const Identity& identity,
mojo::PendingReceiver<mojom::Service> receiver,
mojo::PendingRemote<mojom::ProcessMetadata> metadata) override;
// The Service instance to which all incoming events from the Service Manager
// should be directed. Typically this is the object which owns this
// ServiceReceiver.
service_manager::Service* const service_;
// A pending Connector request which will eventually be passed to the Service
// Manager. Created preemptively by every unbound ServiceReceiver so that
// |connector()| may begin pipelining outgoing requests even before the
// ServiceReceiver is bound to a Service receiver.
mojo::PendingReceiver<mojom::Connector> pending_connector_receiver_;
mojo::Receiver<mojom::Service> receiver_{this};
Identity identity_;
std::unique_ptr<Connector> connector_;
// This instance's control interface to the service manager. Note that this
// is unbound and therefore invalid until OnStart() is called.
mojo::AssociatedRemote<mojom::ServiceControl> service_control_;
// Tracks whether |RequestClose()| has been called at least once prior to
// receiving |OnStart()| on a bound ServiceReceiver. This ensures that the
// closure request is actually issued once |OnStart()| is invoked.
bool request_closure_on_start_ = false;
DISALLOW_COPY_AND_ASSIGN(ServiceReceiver);
};
} // namespace service_manager
#endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_RECEIVER_H_
| 44.12 | 80 | 0.757782 |
633be6440b7accc3234ecfde40462bd6b7482800 | 445 | kt | Kotlin | app/src/main/java/com/byd/firstcode/kotlin/ten/MainViewModelFactory.kt | liufangqq/TestBYD | fcb8f6450a07e4598bf034dbfaaaa47037586107 | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/byd/firstcode/kotlin/ten/MainViewModelFactory.kt | liufangqq/TestBYD | fcb8f6450a07e4598bf034dbfaaaa47037586107 | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/byd/firstcode/kotlin/ten/MainViewModelFactory.kt | liufangqq/TestBYD | fcb8f6450a07e4598bf034dbfaaaa47037586107 | [
"Apache-2.0"
] | null | null | null | package com.byd.firstcode.kotlin.ten
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
/**
* <pre>
* author : liu.fang49
* e-mail : xxx@xx
* time : 2021/12/09
* desc :
* version: 1.0
* </pre>
*/
class MainViewModelFactory(private val countReserved:Int):ViewModelProvider.Factory {
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
return MainViewModel(countReserved) as T
}
} | 23.421053 | 85 | 0.703371 |
1617a406eb6e9e26290ac096f0b83d299dea8a2c | 23,707 | h | C | src/common/eavlOperation.h | jsmeredith/EAVL | 114924a92aed4f1adfcf4f751151d9355c593944 | [
"Apache-2.0",
"BSD-2-Clause"
] | 6 | 2016-12-11T21:40:00.000Z | 2018-04-04T10:33:40.000Z | src/common/eavlOperation.h | jsmeredith/EAVL | 114924a92aed4f1adfcf4f751151d9355c593944 | [
"Apache-2.0",
"BSD-2-Clause"
] | 3 | 2015-02-11T20:55:01.000Z | 2017-05-31T01:56:21.000Z | src/common/eavlOperation.h | jsmeredith/EAVL | 114924a92aed4f1adfcf4f751151d9355c593944 | [
"Apache-2.0",
"BSD-2-Clause"
] | 6 | 2015-05-24T06:27:45.000Z | 2020-05-08T12:17:07.000Z | // Copyright 2010-2014 UT-Battelle, LLC. See LICENSE.txt for more information.
#ifndef EAVL_OPERATION_H
#define EAVL_OPERATION_H
#include <climits>
#include <cfloat>
#include "eavlException.h"
#include "eavlConfig.h"
#include "eavlArray.h"
#include "eavlRegularStructure.h"
#include "eavlExplicitConnectivity.h"
#include "eavlCUDA.h"
#include "eavlIndexable.h"
#include "eavlTuple.h"
#include "eavlRefTuple.h"
#include "eavlTupleTraits.h"
#include "eavlCollect.h"
// Create a tuple of indexable arrays. This style is called if your inputs are all eavlIndexable<> types already.
inline nulltype eavlOpArgs() { return cnull(); }
template <class A>
inline tuple<A> eavlOpArgs(const A &a) { return tuple<A>(a); }
template <class A, class B>
inline tuple<A,B> eavlOpArgs(const A &a, const B &b) { return tuple<A,B>(a,b); }
template <class A, class B, class C>
inline tuple<A,B,C> eavlOpArgs(const A &a, const B &b, const C &c) { return tuple<A,B,C>(a,b,c); }
template <class A, class B, class C, class D>
inline tuple<A,B,C,D> eavlOpArgs(const A &a, const B &b, const C &c, const D &d) { return tuple<A,B,C,D>(a,b,c,d); }
template <class A, class B, class C, class D, class E>
inline tuple<A,B,C,D,E> eavlOpArgs(const A &a, const B &b, const C &c, const D &d, const E &e) { return tuple<A,B,C,D,E>(a,b,c,d,e); }
template <class A, class B, class C, class D, class E, class F>
inline tuple<A,B,C,D,E,F> eavlOpArgs(const A &a, const B &b, const C &c, const D &d, const E &e, const F &f) { return tuple<A,B,C,D,E,F>(a,b,c,d,e,f); }
template <class A, class B, class C, class D, class E, class F, class G>
inline tuple<A,B,C,D,E,F,G> eavlOpArgs(const A &a, const B &b, const C &c, const D &d, const E &e, const F &f, const G &g) { return tuple<A,B,C,D,E,F,G>(a,b,c,d,e,f,g); }
template <class A, class B, class C, class D, class E, class F, class G, class H>
inline tuple<A,B,C,D,E,F,G,H> eavlOpArgs(const A &a, const B &b, const C &c, const D &d, const E &e, const F &f, const G &g, const H &h) { return tuple<A,B,C,D,E,F,G,H>(a,b,c,d,e,f,g,h); }
template <class A, class B, class C, class D, class E, class F, class G, class H, class I>
inline tuple<A,B,C,D,E,F,G,H,I> eavlOpArgs(const A &a, const B &b, const C &c, const D &d, const E &e, const F &f, const G &g, const H &h, const I &i) { return tuple<A,B,C,D,E,F,G,H,I>(a,b,c,d,e,f,g,h,i); }
template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J>
inline tuple<A,B,C,D,E,F,G,H,I,J> eavlOpArgs(const A &a, const B &b, const C &c, const D &d, const E &e, const F &f, const G &g, const H &h, const I &i, const J &j) { return tuple<A,B,C,D,E,F,G,H,I,J>(a,b,c,d,e,f,g,h,i,j); }
template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J, class K>
inline tuple<A,B,C,D,E,F,G,H,I,J,K> eavlOpArgs(const A &a, const B &b, const C &c, const D &d, const E &e, const F &f, const G &g, const H &h, const I &i, const J &j, const K &k) { return tuple<A,B,C,D,E,F,G,H,I,J,K>(a,b,c,d,e,f,g,h,i,j,k); }
template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J, class K, class L>
inline tuple<A,B,C,D,E,F,G,H,I,J,K,L> eavlOpArgs(const A &a, const B &b, const C &c, const D &d, const E &e, const F &f, const G &g, const H &h, const I &i, const J &j, const K &k, const L &l) { return tuple<A,B,C,D,E,F,G,H,I,J,K,L>(a,b,c,d,e,f,g,h,i,j,k,l); }
template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J, class K, class L, class M>
inline tuple<A,B,C,D,E,F,G,H,I,J,K,L,M> eavlOpArgs(const A &a, const B &b, const C &c, const D &d, const E &e, const F &f, const G &g, const H &h, const I &i, const J &j, const K &k, const L &l, const M &m) { return tuple<A,B,C,D,E,F,G,H,I,J,K,L,M>(a,b,c,d,e,f,g,h,i,j,k,l,m); }
template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J, class K, class L, class M, class N>
inline tuple<A,B,C,D,E,F,G,H,I,J,K,L,M,N> eavlOpArgs(const A &a, const B &b, const C &c, const D &d, const E &e, const F &f, const G &g, const H &h, const I &i, const J &j, const K &k, const L &l, const M &m, const N &n) { return tuple<A,B,C,D,E,F,G,H,I,J,K,L,M,N>(a,b,c,d,e,f,g,h,i,j,k,l,m,n); }
template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J, class K, class L, class M, class N, class O>
inline tuple<A,B,C,D,E,F,G,H,I,J,K,L,M,N,O> eavlOpArgs(const A &a, const B &b, const C &c, const D &d, const E &e, const F &f, const G &g, const H &h, const I &i, const J &j, const K &k, const L &l, const M &m, const N &n, const O &o) { return tuple<A,B,C,D,E,F,G,H,I,J,K,L,M,N,O>(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o); }
template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J, class K, class L, class M, class N, class O, class P>
inline tuple<A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P> eavlOpArgs(const A &a, const B &b, const C &c, const D &d, const E &e, const F &f, const G &g, const H &h, const I &i, const J &j, const K &k, const L &l, const M &m, const N &n, const O &o, const P &p) { return tuple<A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P>(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p); }
// Create a tuple of indexable arrays. This style is called if your inputs are all standard arrays; it will create linear indexes for them.
template <class A>
inline tuple< eavlIndexable<A> > eavlOpArgs(A *a) { return make_tuple(eavlIndexable<A>(a)); }
template <class A, class B>
inline tuple< eavlIndexable<A> , eavlIndexable<B> > eavlOpArgs(A *a, B *b) { return make_tuple(eavlIndexable<A>(a), eavlIndexable<B>(b)); }
template <class A, class B, class C>
inline tuple< eavlIndexable<A> , eavlIndexable<B> , eavlIndexable<C> > eavlOpArgs(A *a, B *b, C *c) { return make_tuple(eavlIndexable<A>(a), eavlIndexable<B>(b), eavlIndexable<C>(c)); }
template <class A, class B, class C, class D>
inline tuple< eavlIndexable<A> , eavlIndexable<B> , eavlIndexable<C> , eavlIndexable<D> > eavlOpArgs(A *a, B *b, C *c, D *d) { return make_tuple(eavlIndexable<A>(a), eavlIndexable<B>(b), eavlIndexable<C>(c), eavlIndexable<D>(d)); }
template <class A, class B, class C, class D, class E>
inline tuple< eavlIndexable<A> , eavlIndexable<B> , eavlIndexable<C> , eavlIndexable<D> , eavlIndexable<E> > eavlOpArgs(A *a, B *b, C *c, D *d, E *e) { return make_tuple(eavlIndexable<A>(a), eavlIndexable<B>(b), eavlIndexable<C>(c), eavlIndexable<D>(d), eavlIndexable<E>(e)); }
template <class A, class B, class C, class D, class E, class F>
inline tuple< eavlIndexable<A> , eavlIndexable<B> , eavlIndexable<C> , eavlIndexable<D> , eavlIndexable<E> , eavlIndexable<F> > eavlOpArgs(A *a, B *b, C *c, D *d, E *e, F *f) { return make_tuple(eavlIndexable<A>(a), eavlIndexable<B>(b), eavlIndexable<C>(c), eavlIndexable<D>(d), eavlIndexable<E>(e), eavlIndexable<F>(f)); }
template <class A, class B, class C, class D, class E, class F, class G>
inline tuple< eavlIndexable<A> , eavlIndexable<B> , eavlIndexable<C> , eavlIndexable<D> , eavlIndexable<E> , eavlIndexable<F> , eavlIndexable<G> > eavlOpArgs(A *a, B *b, C *c, D *d, E *e, F *f, G *g) { return make_tuple(eavlIndexable<A>(a), eavlIndexable<B>(b), eavlIndexable<C>(c), eavlIndexable<D>(d), eavlIndexable<E>(e), eavlIndexable<F>(f), eavlIndexable<G>(g)); }
template <class A, class B, class C, class D, class E, class F, class G, class H>
inline tuple< eavlIndexable<A> , eavlIndexable<B> , eavlIndexable<C> , eavlIndexable<D> , eavlIndexable<E> , eavlIndexable<F> , eavlIndexable<G> , eavlIndexable<H> > eavlOpArgs(A *a, B *b, C *c, D *d, E *e, F *f, G *g, H *h) { return make_tuple(eavlIndexable<A>(a), eavlIndexable<B>(b), eavlIndexable<C>(c), eavlIndexable<D>(d), eavlIndexable<E>(e), eavlIndexable<F>(f), eavlIndexable<G>(g), eavlIndexable<H>(h)); }
template <class A, class B, class C, class D, class E, class F, class G, class H, class I>
inline tuple< eavlIndexable<A> , eavlIndexable<B> , eavlIndexable<C> , eavlIndexable<D> , eavlIndexable<E> , eavlIndexable<F> , eavlIndexable<G> , eavlIndexable<H>, eavlIndexable<I> > eavlOpArgs(A *a, B *b, C *c, D *d, E *e, F *f, G *g, H *h, I *i) { return make_tuple(eavlIndexable<A>(a), eavlIndexable<B>(b), eavlIndexable<C>(c), eavlIndexable<D>(d), eavlIndexable<E>(e), eavlIndexable<F>(f), eavlIndexable<G>(g), eavlIndexable<H>(h), eavlIndexable<I>(i)); }
template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J>
inline tuple< eavlIndexable<A> , eavlIndexable<B> , eavlIndexable<C> , eavlIndexable<D> , eavlIndexable<E> , eavlIndexable<F> , eavlIndexable<G> , eavlIndexable<H>, eavlIndexable<I>, eavlIndexable<J> > eavlOpArgs(A *a, B *b, C *c, D *d, E *e, F *f, G *g, H *h, I *i, J *j) { return make_tuple(eavlIndexable<A>(a), eavlIndexable<B>(b), eavlIndexable<C>(c), eavlIndexable<D>(d), eavlIndexable<E>(e), eavlIndexable<F>(f), eavlIndexable<G>(g), eavlIndexable<H>(h), eavlIndexable<I>(i), eavlIndexable<J>(j)); }
template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J, class K>
inline tuple< eavlIndexable<A> , eavlIndexable<B> , eavlIndexable<C> , eavlIndexable<D> , eavlIndexable<E> , eavlIndexable<F> , eavlIndexable<G> , eavlIndexable<H>, eavlIndexable<I>, eavlIndexable<J>, eavlIndexable<K> > eavlOpArgs(A *a, B *b, C *c, D *d, E *e, F *f, G *g, H *h, I *i, J *j, K *k) { return make_tuple(eavlIndexable<A>(a), eavlIndexable<B>(b), eavlIndexable<C>(c), eavlIndexable<D>(d), eavlIndexable<E>(e), eavlIndexable<F>(f), eavlIndexable<G>(g), eavlIndexable<H>(h), eavlIndexable<I>(i), eavlIndexable<J>(j), eavlIndexable<K>(k)); }
template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J, class K, class L>
inline tuple< eavlIndexable<A> , eavlIndexable<B> , eavlIndexable<C> , eavlIndexable<D> , eavlIndexable<E> , eavlIndexable<F> , eavlIndexable<G> , eavlIndexable<H>, eavlIndexable<I>, eavlIndexable<J>, eavlIndexable<K>, eavlIndexable<L> > eavlOpArgs(A *a, B *b, C *c, D *d, E *e, F *f, G *g, H *h, I *i, J *j, K *k, L *l) { return make_tuple(eavlIndexable<A>(a), eavlIndexable<B>(b), eavlIndexable<C>(c), eavlIndexable<D>(d), eavlIndexable<E>(e), eavlIndexable<F>(f), eavlIndexable<G>(g), eavlIndexable<H>(h), eavlIndexable<I>(i), eavlIndexable<J>(j), eavlIndexable<K>(k), eavlIndexable<L>(l)); }
template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J, class K, class L, class M>
inline tuple< eavlIndexable<A> , eavlIndexable<B> , eavlIndexable<C> , eavlIndexable<D> , eavlIndexable<E> , eavlIndexable<F> , eavlIndexable<G> , eavlIndexable<H>, eavlIndexable<I>, eavlIndexable<J>, eavlIndexable<K>, eavlIndexable<L>, eavlIndexable<M> > eavlOpArgs(A *a, B *b, C *c, D *d, E *e, F *f, G *g, H *h, I *i, J *j, K *k, L *l, M *m) { return make_tuple(eavlIndexable<A>(a), eavlIndexable<B>(b), eavlIndexable<C>(c), eavlIndexable<D>(d), eavlIndexable<E>(e), eavlIndexable<F>(f), eavlIndexable<G>(g), eavlIndexable<H>(h), eavlIndexable<I>(i), eavlIndexable<J>(j), eavlIndexable<K>(k), eavlIndexable<L>(l), eavlIndexable<M>(m)); }
template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J, class K, class L, class M, class N>
inline tuple< eavlIndexable<A> , eavlIndexable<B> , eavlIndexable<C> , eavlIndexable<D> , eavlIndexable<E> , eavlIndexable<F> , eavlIndexable<G> , eavlIndexable<H>, eavlIndexable<I>, eavlIndexable<J>, eavlIndexable<K>, eavlIndexable<L>, eavlIndexable<M>, eavlIndexable<N> > eavlOpArgs(A *a, B *b, C *c, D *d, E *e, F *f, G *g, H *h, I *i, J *j, K *k, L *l, M *m, N *n) { return make_tuple(eavlIndexable<A>(a), eavlIndexable<B>(b), eavlIndexable<C>(c), eavlIndexable<D>(d), eavlIndexable<E>(e), eavlIndexable<F>(f), eavlIndexable<G>(g), eavlIndexable<H>(h), eavlIndexable<I>(i), eavlIndexable<J>(j), eavlIndexable<K>(k), eavlIndexable<L>(l), eavlIndexable<M>(m), eavlIndexable<N>(n)); }
template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J, class K, class L, class M, class N, class O>
inline tuple< eavlIndexable<A> , eavlIndexable<B> , eavlIndexable<C> , eavlIndexable<D> , eavlIndexable<E> , eavlIndexable<F> , eavlIndexable<G> , eavlIndexable<H>, eavlIndexable<I>, eavlIndexable<J>, eavlIndexable<K>, eavlIndexable<L>, eavlIndexable<M>, eavlIndexable<N>, eavlIndexable<O> > eavlOpArgs(A *a, B *b, C *c, D *d, E *e, F *f, G *g, H *h, I *i, J *j, K *k, L *l, M *m, N *n, O *o) { return make_tuple(eavlIndexable<A>(a), eavlIndexable<B>(b), eavlIndexable<C>(c), eavlIndexable<D>(d), eavlIndexable<E>(e), eavlIndexable<F>(f), eavlIndexable<G>(g), eavlIndexable<H>(h), eavlIndexable<I>(i), eavlIndexable<J>(j), eavlIndexable<K>(k), eavlIndexable<L>(l), eavlIndexable<M>(m), eavlIndexable<N>(n), eavlIndexable<O>(o)); }
template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J, class K, class L, class M, class N, class O, class P>
inline tuple< eavlIndexable<A> , eavlIndexable<B> , eavlIndexable<C> , eavlIndexable<D> , eavlIndexable<E> , eavlIndexable<F> , eavlIndexable<G> , eavlIndexable<H>, eavlIndexable<I>, eavlIndexable<J>, eavlIndexable<K>, eavlIndexable<L>, eavlIndexable<M>, eavlIndexable<N>, eavlIndexable<O>, eavlIndexable<P> > eavlOpArgs(A *a, B *b, C *c, D *d, E *e, F *f, G *g, H *h, I *i, J *j, K *k, L *l, M *m, N *n, O *o, P *p) { return make_tuple(eavlIndexable<A>(a), eavlIndexable<B>(b), eavlIndexable<C>(c), eavlIndexable<D>(d), eavlIndexable<E>(e), eavlIndexable<F>(f), eavlIndexable<G>(g), eavlIndexable<H>(h), eavlIndexable<I>(i), eavlIndexable<J>(j), eavlIndexable<K>(k), eavlIndexable<L>(l), eavlIndexable<M>(m), eavlIndexable<N>(n), eavlIndexable<O>(o), eavlIndexable<P>(p)); }
///\todo: switch to the new eavlIndexable and remove this
struct eavlArrayWithLinearIndex
{
eavlArray *array;
int div;
int mod;
int mul;
int add;
eavlArrayWithLinearIndex() : array(NULL)
{
}
eavlArrayWithLinearIndex(const eavlArrayWithLinearIndex &awli)
: array(awli.array),
div(awli.div),
mod(awli.mod),
mul(awli.mul),
add(awli.add)
{
}
void operator=(const eavlArrayWithLinearIndex &awli)
{
array = awli.array;
div = awli.div;
mod = awli.mod;
mul = awli.mul;
add = awli.add;
}
eavlArrayWithLinearIndex(eavlArray *arr)
: array(arr),
div(1),
mod(INT_MAX),
mul(1),
add(0)
{
if (array->GetNumberOfComponents() != 1)
THROW(eavlException,"Must specify a component for a multi-component array");
}
eavlArrayWithLinearIndex(eavlArray *arr, int component)
: array(arr),
div(1),
mod(INT_MAX),
mul(arr->GetNumberOfComponents()),
add(component)
{
}
///\todo: we're assuming a logical dimension must be a NODE array, and
/// we're probably not just making that assumption right here, either!
eavlArrayWithLinearIndex(eavlArray *arr,
eavlRegularStructure reg, int logicaldim)
: array(arr),
div(reg.CalculateNodeIndexDivForDimension(logicaldim)),
mod(reg.CalculateNodeIndexModForDimension(logicaldim)),
mul(1),
add(0)
{
if (array->GetNumberOfComponents() != 1)
THROW(eavlException,"Must specify a component for a multi-component array");
}
///\todo: we're assuming a logical dimension must be a NODE array, and
/// we're probably not just making that assumption right here, either!
eavlArrayWithLinearIndex(eavlArray *arr, int component,
eavlRegularStructure reg, int logicaldim)
: array(arr),
div(reg.CalculateNodeIndexDivForDimension(logicaldim)),
mod(reg.CalculateNodeIndexModForDimension(logicaldim)),
mul(arr->GetNumberOfComponents()),
add(component)
{
}
void Print(ostream &out)
{
cout << "array="<<array<<" div="<<div<<" mod="<<mod<<" mul="<<mul<<" add="<<add<<endl;
}
};
// ****************************************************************************
// Class: eavlOperation
//
// Purpose:
///
//
// Programmer: Jeremy Meredith, Dave Pugmire, Sean Ahern, Rob Sisneros
// Creation: September 2, 2011
//
// ****************************************************************************
// Note:
// These functors are more complex than they need to be for most usage.
// However, as these are provided for arbitrary use, they need to be
// flexible. For instance, they need to support use with either a
// pair of arguments or a tuple. And in the case of a tuple, we want
// to support a tuple of references to the original arrays (refcons)
// or a standard tuple of some known type. The associative/commutative
// ones -- like addition or min and max -- are worse, because you might
// potentially want to collapse any number of items with these functors,
// and so those must use template-recursion to walk through all items.
// When you are writing your own functor, you know how it will be used,
// and so you can often get away with a single operator() taking
// either a tuple or primitive arguments. So while the functors below
// can provide an example of how to write one which will perform well
// and accurately in any situation, you can generally write a much
// simpler functor without having to follow these patterns.
template<class T>
struct eavlAddFunctor
{
// this works on two inputs (each of arbitrary length) by calling the single-arg versions below
template<class A, class B>
EAVL_FUNCTOR T operator()(const A &args0, const B &args1) { return operator()(args0) + operator()(args1); }
// this works on one primitive type
template<class A>
EAVL_FUNCTOR T operator()(const A &arg) { return arg; }
// this works on one input (of arbitrary length) via template recursion; cons/tuple version
template<class HT, class TT>
EAVL_FUNCTOR T operator()(const cons<HT,TT> &args) { return T(args.first) + operator()(args.rest); }
template<class HT>
EAVL_FUNCTOR T operator()(const cons<HT,nulltype> &args) { return T(args.first); }
// this works on one input (of arbitrary length) via template recursion; refcons version
template<class HT, class TT>
EAVL_FUNCTOR T operator()(const refcons<HT,TT> &args) { return T(args.first) + operator()(args.rest); }
template<class HT>
EAVL_FUNCTOR T operator()(const refcons<HT,nulltype> &args) { return T(args.first); }
T identity() { return 0; }
};
template<class T>
struct eavlSubFunctor
{
EAVL_FUNCTOR T operator()(T a, T b) { return a - b; }
template <class T1, class T2>
EAVL_FUNCTOR T operator()(const cons<T1, const cons<T2, nulltype> > &args) { return T(args.first) - T(args.rest.first); }
template <class T1, class T2>
EAVL_FUNCTOR T operator()(const refcons<T1, const refcons<T2, nulltype> > &args) { return T(args.first) - T(args.rest.first); }
T identity() { return 0; }
};
template<class T>
struct eavlMulFunctor
{
// this works on two inputs (each of arbitrary length) by calling the single-arg versions below
template<class A, class B>
EAVL_FUNCTOR T operator()(const A &args0, const B &args1) { return operator()(args0) * operator()(args1); }
// this works on one primitive type
template<class A>
EAVL_FUNCTOR T operator()(const A &arg) { return arg; }
// this works on one input (of arbitrary length) via template recursion; cons/tuple version
template<class HT, class TT>
EAVL_FUNCTOR T operator()(const cons<HT,TT> &args) { return T(args.first) * operator()(args.rest); }
template<class HT>
EAVL_FUNCTOR T operator()(const cons<HT,nulltype> &args) { return T(args.first); }
// this works on one input (of arbitrary length) via template recursion; refcons version
template<class HT, class TT>
EAVL_FUNCTOR T operator()(const refcons<HT,TT> &args) { return T(args.first) * operator()(args.rest); }
template<class HT>
EAVL_FUNCTOR T operator()(const refcons<HT,nulltype> &args) { return T(args.first); }
T identity() { return 0; }
};
template<class T>
struct eavlDivFunctor
{
EAVL_FUNCTOR T operator()(T a, T b) { return a / b; }
template <class T1, class T2>
EAVL_FUNCTOR T operator()(const cons<T1, const cons<T2, nulltype> > &args) { return T(args.first) / T(args.rest.first); }
template <class T1, class T2>
EAVL_FUNCTOR T operator()(const refcons<T1, const refcons<T2, nulltype> > &args) { return T(args.first) / T(args.rest.first); }
T identity() { return 0; }
};
template<class T>
struct eavlMaxFunctor
{
// this works on two inputs (each of arbitrary length) by calling the single-arg versions below
template<class A, class B>
EAVL_FUNCTOR T operator()(const A &args0, const B &args1) { T a0 = operator()(args0); T a1 = operator()(args1); return a0>a1 ? a0:a1; }
// this works on one primitive type
template<class A>
EAVL_FUNCTOR T operator()(const A &arg) { return arg; }
// this works on one input (of arbitrary length) via template recursion; cons/tuple version
template<class HT, class TT>
EAVL_FUNCTOR T operator()(const cons<HT,TT> &args) { T a0 = args.first; T a1 = operator()(args.rest); return a0>a1 ? a0:a1; }
template<class HT>
EAVL_FUNCTOR T operator()(const cons<HT,nulltype> &args) { return T(args.first); }
// this works on one input (of arbitrary length) via template recursion; refcons version
template<class HT, class TT>
EAVL_FUNCTOR T operator()(const refcons<HT,TT> &args) { T a0 = args.first; T a1 = operator()(args.rest); return a0>a1 ? a0:a1; }
template<class HT>
EAVL_FUNCTOR T operator()(const refcons<HT,nulltype> &args) { return T(args.first); }
T identity();
};
template<class T>
struct eavlMinFunctor
{
// this works on two inputs (each of arbitrary length) by calling the single-arg versions below
template<class A, class B>
EAVL_FUNCTOR T operator()(const A &args0, const B &args1) { T a0 = operator()(args0); T a1 = operator()(args1); return a0<a1 ? a0:a1; }
// this works on one primitive type
template<class A>
EAVL_FUNCTOR T operator()(const A &arg) { return arg; }
// this works on one input (of arbitrary length) via template recursion; cons/tuple version
template<class HT, class TT>
EAVL_FUNCTOR T operator()(const cons<HT,TT> &args) { T a0 = args.first; T a1 = operator()(args.rest); return a0<a1 ? a0:a1; }
template<class HT>
EAVL_FUNCTOR T operator()(const cons<HT,nulltype> &args) { return T(args.first); }
// this works on one input (of arbitrary length) via template recursion; refcons version
template<class HT, class TT>
EAVL_FUNCTOR T operator()(const refcons<HT,TT> &args) { T a0 = args.first; T a1 = operator()(args.rest); return a0<a1 ? a0:a1; }
template<class HT>
EAVL_FUNCTOR T operator()(const refcons<HT,nulltype> &args) { return T(args.first); }
T identity();
};
template<class T>
struct eavlLessThanConstFunctor
{
private:
T target;
public:
eavlLessThanConstFunctor(const T &t) : target(t) { }
EAVL_FUNCTOR bool operator()(float x) { return x < target; }
};
template<class T>
struct eavlNotEqualFunctor
{
EAVL_FUNCTOR bool operator()(T a, T b) { return a != b; }
};
struct DummyFunctor
{
void operator()(void) { }
};
class eavlOperation
{
friend class eavlExecutor;
public:
virtual ~eavlOperation() { }
protected:
virtual void GoCPU() = 0;
virtual void GoGPU() = 0;
};
#endif
| 61.576623 | 775 | 0.659257 |
12e0722bdbd8338376771f4df13c07a152e6ede2 | 2,155 | kt | Kotlin | retrofit_wrapper/src/main/java/com/sch/retrofit/wrapper/convert/util/GsonHelper.kt | shichaohui/RetrofitWrapper | 12dc7fa2dc723568ad118ad42feda62c938294eb | [
"Apache-2.0"
] | null | null | null | retrofit_wrapper/src/main/java/com/sch/retrofit/wrapper/convert/util/GsonHelper.kt | shichaohui/RetrofitWrapper | 12dc7fa2dc723568ad118ad42feda62c938294eb | [
"Apache-2.0"
] | null | null | null | retrofit_wrapper/src/main/java/com/sch/retrofit/wrapper/convert/util/GsonHelper.kt | shichaohui/RetrofitWrapper | 12dc7fa2dc723568ad118ad42feda62c938294eb | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) 2015-2018 Shi ChaoHui
*
* 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 com.sch.retrofit.wrapper.convert.util
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.sch.retrofit.wrapper.convert.serializer.*
/**
* Created by StoneHui on 2017/7/24.
* <p>
* Gson 扩展。
*/
object GsonHelper {
/**
* 创建 Gson 对象。
*/
fun create(): Gson {
val booleanSerializer = BooleanSerializer()
val stringSerializer = StringSerializer()
val integerSerializer = IntegerSerializer()
val longSerializer = LongSerializer()
val floatSerializer = FloatSerializer()
val doubleSerializer = DoubleSerializer()
return GsonBuilder()
.registerTypeAdapter(Boolean::class.java, booleanSerializer)
.registerTypeAdapter(Boolean::class.javaPrimitiveType, booleanSerializer)
.registerTypeAdapter(String::class.java, stringSerializer)
.registerTypeAdapter(Int::class.java, integerSerializer)
.registerTypeAdapter(Int::class.javaPrimitiveType, integerSerializer)
.registerTypeAdapter(Long::class.java, longSerializer)
.registerTypeAdapter(Long::class.javaPrimitiveType, longSerializer)
.registerTypeAdapter(Float::class.java, floatSerializer)
.registerTypeAdapter(Float::class.javaPrimitiveType, floatSerializer)
.registerTypeAdapter(Double::class.java, doubleSerializer)
.registerTypeAdapter(Double::class.javaPrimitiveType, doubleSerializer)
.create()
}
} | 37.807018 | 89 | 0.688631 |
6e433f062d28a70797a87c34945ac47d3b7d85ec | 989 | sql | SQL | sql/table/announcement.sql | tiaodan/bugcount_flask | 7cb8aaf486e7d845acb3d5f42e73919ee939d979 | [
"MulanPSL-1.0"
] | null | null | null | sql/table/announcement.sql | tiaodan/bugcount_flask | 7cb8aaf486e7d845acb3d5f42e73919ee939d979 | [
"MulanPSL-1.0"
] | null | null | null | sql/table/announcement.sql | tiaodan/bugcount_flask | 7cb8aaf486e7d845acb3d5f42e73919ee939d979 | [
"MulanPSL-1.0"
] | null | null | null | /*
Navicat MySQL Data Transfer
Source Server : localhost
Source Server Version : 50717
Source Host : localhost:3306
Source Database : hahahh
Target Server Type : MYSQL
Target Server Version : 50717
File Encoding : 65001
Date: 2020-09-24 11:40:10
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `announcement`
-- ----------------------------
DROP TABLE IF EXISTS `announcement`;
CREATE TABLE `announcement` (
`announcementid` int(10) NOT NULL AUTO_INCREMENT,
`announcement` varchar(2048) DEFAULT NULL,
PRIMARY KEY (`announcementid`),
KEY `announcementid` (`announcementid`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of announcement
-- ----------------------------
INSERT INTO `announcement` VALUES ('1', '公告内容1:2020-09-10 恭喜项目1圆满完成,大家放假一天');
INSERT INTO `announcement` VALUES ('2', '公告内容2222');
INSERT INTO `announcement` VALUES ('3', '公告内容33333');
| 28.257143 | 77 | 0.628918 |