hexsha stringlengths 40 40 | size int64 5 1.05M | ext stringclasses 98
values | lang stringclasses 21
values | max_stars_repo_path stringlengths 3 945 | max_stars_repo_name stringlengths 4 118 | max_stars_repo_head_hexsha stringlengths 40 78 | max_stars_repo_licenses listlengths 1 10 | max_stars_count int64 1 368k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 3 945 | max_issues_repo_name stringlengths 4 118 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses listlengths 1 10 | max_issues_count int64 1 134k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 945 | max_forks_repo_name stringlengths 4 135 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses listlengths 1 10 | max_forks_count int64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 5 1.05M | avg_line_length float64 1 1.03M | max_line_length int64 2 1.03M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ed204092bb43237ade0e7a5a26404f48ccbb08c7 | 2,913 | kt | Kotlin | lib/src/main/java/com/drew/metadata/mp4/media/Mp4VideoDescriptor.kt | baelec/metadata-extractor | 2df8efc24efa24aca040bc4f392d9b9285d23369 | [
"Apache-2.0"
] | null | null | null | lib/src/main/java/com/drew/metadata/mp4/media/Mp4VideoDescriptor.kt | baelec/metadata-extractor | 2df8efc24efa24aca040bc4f392d9b9285d23369 | [
"Apache-2.0"
] | null | null | null | lib/src/main/java/com/drew/metadata/mp4/media/Mp4VideoDescriptor.kt | baelec/metadata-extractor | 2df8efc24efa24aca040bc4f392d9b9285d23369 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2002-2019 Drew Noakes and contributors
*
* 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.
*
* More information about this project is available at:
*
* https://drewnoakes.com/code/exif/
* https://github.com/drewnoakes/metadata-extractor
*/
package com.drew.metadata.mp4.media
import com.drew.metadata.TagDescriptor
class Mp4VideoDescriptor(directory: Mp4VideoDirectory) : TagDescriptor<Mp4VideoDirectory>(directory) {
override fun getDescription(tagType: Int): String? {
return when (tagType) {
Mp4VideoDirectory.TAG_HEIGHT, Mp4VideoDirectory.TAG_WIDTH -> getPixelDescription(tagType)
Mp4VideoDirectory.TAG_DEPTH -> depthDescription
Mp4VideoDirectory.TAG_COLOR_TABLE -> colorTableDescription
Mp4VideoDirectory.TAG_GRAPHICS_MODE -> graphicsModeDescription
else -> super.getDescription(tagType)
}
}
private fun getPixelDescription(tagType: Int): String? {
val value = _directory.getString(tagType)
return if (value == null) null else "$value pixels"
}
private val depthDescription: String?
get() {
val value = _directory.getInteger(Mp4VideoDirectory.TAG_DEPTH) ?: return null
return when (value) {
1, 2, 4, 8, 16, 24, 32 -> "$value-bit color"
40, 36, 34 -> (value - 32).toString() + "-bit grayscale"
else -> "Unknown ($value)"
}
}
private val colorTableDescription: String?
get() {
val value = _directory.getInteger(Mp4VideoDirectory.TAG_COLOR_TABLE) ?: return null
return when (value) {
-1 -> {
val depth = _directory.getInteger(Mp4VideoDirectory.TAG_DEPTH) ?: return "None"
if (depth < 16) {
"Default"
} else {
"None"
}
}
0 -> "Color table within file"
else -> "Unknown ($value)"
}
}
private val graphicsModeDescription: String?
get() {
val value = _directory.getInteger(Mp4VideoDirectory.TAG_GRAPHICS_MODE) ?: return null
return when (value) {
0x00 -> "Copy"
0x40 -> "Dither copy"
0x20 -> "Blend"
0x24 -> "Transparent"
0x100 -> "Straight alpha"
0x101 -> "Premul white alpha"
0x102 -> "Premul black alpha"
0x104 -> "Straight alpha blend"
0x103 -> "Composition (dither copy)"
else -> "Unknown ($value)"
}
}
}
| 34.270588 | 102 | 0.649502 |
72aefa16bffedeb24ff0e8761d5f4b906062a03a | 22,880 | rs | Rust | examples/ui.rs | remilauzier/rg3d | 4bc996dc124df4f175b5c7394321a892821d70bb | [
"MIT"
] | null | null | null | examples/ui.rs | remilauzier/rg3d | 4bc996dc124df4f175b5c7394321a892821d70bb | [
"MIT"
] | null | null | null | examples/ui.rs | remilauzier/rg3d | 4bc996dc124df4f175b5c7394321a892821d70bb | [
"MIT"
] | null | null | null | //! Example 04. User Interface
//!
//! Difficulty: Easy
//!
//! This example shows how to use user interface system of engine. It is
//! based on framework example because UI will be used to operate on
//! model.
extern crate rg3d;
pub mod shared;
use crate::shared::create_camera;
use rg3d::engine::resource_manager::MaterialSearchOptions;
use rg3d::{
animation::Animation,
core::{
algebra::{UnitQuaternion, Vector2, Vector3},
color::Color,
pool::Handle,
},
engine::resource_manager::ResourceManager,
event::{ElementState, Event, VirtualKeyCode, WindowEvent},
event_loop::{ControlFlow, EventLoop},
gui::{
border::BorderBuilder,
button::ButtonBuilder,
decorator::DecoratorBuilder,
dropdown_list::DropdownListBuilder,
grid::{Column, GridBuilder, Row},
message::{
ButtonMessage, DropdownListMessage, MessageDirection, ScrollBarMessage, TextMessage,
UiMessageData,
},
node::StubNode,
scroll_bar::ScrollBarBuilder,
stack_panel::StackPanelBuilder,
text::TextBuilder,
widget::WidgetBuilder,
window::{WindowBuilder, WindowTitle},
HorizontalAlignment, Orientation, Thickness, VerticalAlignment,
},
monitor::VideoMode,
scene::{node::Node, Scene},
utils::translate_event,
window::Fullscreen,
};
use rg3d_ui::formatted_text::WrapMode;
use std::time::Instant;
const DEFAULT_MODEL_ROTATION: f32 = 180.0;
const DEFAULT_MODEL_SCALE: f32 = 0.05;
// Create our own engine type aliases. These specializations are needed
// because engine provides a way to extend UI with custom nodes and messages.
type GameEngine = rg3d::engine::Engine<(), StubNode>;
type UiNode = rg3d::gui::node::UINode<(), StubNode>;
struct Interface {
debug_text: Handle<UiNode>,
yaw: Handle<UiNode>,
scale: Handle<UiNode>,
reset: Handle<UiNode>,
video_modes: Vec<VideoMode>,
resolutions: Handle<UiNode>,
}
// User interface in the engine build up on graph data structure, on tree to be
// more precise. Each UI element can has single parent and multiple children.
// UI uses complex layout system which automatically organizes your widgets.
// In this example we'll use Grid and StackPanel layout controls. Grid can be
// divided in rows and columns, its child element can set their desired column
// and row and grid will automatically put them in correct position. StackPanel
// will "stack" UI elements either on top of each other or in one line. Such
// complex layout system was borrowed from WPF framework. You can read more here:
// https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/layout
fn create_ui(engine: &mut GameEngine) -> Interface {
let window_width = engine.renderer.get_frame_size().0 as f32;
// Gather all suitable video modes, we'll use them to fill combo box of
// available resolutions.
let video_modes = engine
.get_window()
.primary_monitor()
.unwrap()
.video_modes()
.filter(|vm| {
// Leave only modern video modes, we are not in 1998.
vm.size().width > 800 && vm.size().height > 600 && vm.bit_depth() == 32
})
.collect::<Vec<_>>();
let ctx = &mut engine.user_interface.build_ctx();
// First of all create debug text that will show title of example and current FPS.
let debug_text = TextBuilder::new(WidgetBuilder::new()).build(ctx);
// Then create model options window.
let yaw;
let scale;
let reset;
WindowBuilder::new(
WidgetBuilder::new()
// We want the window to be anchored at right top corner at the beginning
.with_desired_position(Vector2::new(window_width - 300.0, 0.0))
.with_width(300.0),
)
// Window can have any content you want, in this example it is Grid with other
// controls. The layout looks like this:
// ______________________________
// | Yaw | Scroll bar |
// |_____________|_______________|
// | Scale | Scroll bar |
// |_____________|_______________|
// | | Reset button |
// |_____________|_______________|
//
.with_content(
GridBuilder::new(
WidgetBuilder::new()
.with_child(
TextBuilder::new(
WidgetBuilder::new()
.on_row(0)
.on_column(0)
.with_vertical_alignment(VerticalAlignment::Center),
)
.with_text("Yaw")
.build(ctx),
)
.with_child({
yaw = ScrollBarBuilder::new(
WidgetBuilder::new()
.on_row(0)
.on_column(1)
// Make sure scroll bar will stay in center of available space.
.with_vertical_alignment(VerticalAlignment::Center)
// Add some margin so ui element won't be too close to each other.
.with_margin(Thickness::uniform(2.0)),
)
.with_min(0.0)
// Our max rotation is 360 degrees.
.with_max(360.0)
// Set some initial value
.with_value(DEFAULT_MODEL_ROTATION)
// Set step by which value will change when user will click on arrows.
.with_step(5.0)
// Make sure scroll bar will show its current value on slider.
.show_value(true)
// Turn off all decimal places.
.with_value_precision(0)
.build(ctx);
yaw
})
.with_child(
TextBuilder::new(
WidgetBuilder::new()
.on_row(1)
.on_column(0)
.with_vertical_alignment(VerticalAlignment::Center),
)
.with_wrap(WrapMode::Word)
.with_text("Scale")
.build(ctx),
)
.with_child({
scale = ScrollBarBuilder::new(
WidgetBuilder::new()
.on_row(1)
.on_column(1)
.with_vertical_alignment(VerticalAlignment::Center)
.with_margin(Thickness::uniform(2.0)),
)
.with_min(0.01)
.with_max(0.1)
.with_step(0.01)
.with_value(DEFAULT_MODEL_SCALE)
.show_value(true)
.build(ctx);
scale
})
.with_child(
StackPanelBuilder::new(
WidgetBuilder::new()
.on_row(2)
.on_column(1)
.with_horizontal_alignment(HorizontalAlignment::Right)
.with_child({
reset = ButtonBuilder::new(WidgetBuilder::new())
.with_text("Reset")
.build(ctx);
reset
}),
)
.with_orientation(Orientation::Horizontal)
.build(ctx),
),
)
.add_column(Column::strict(100.0))
.add_column(Column::stretch())
.add_row(Row::strict(30.0))
.add_row(Row::stretch())
.add_row(Row::strict(30.0))
.build(ctx),
)
.with_title(WindowTitle::text("Model Options"))
.can_close(false)
.build(ctx);
// Create another window which will show some graphics options.
let resolutions;
WindowBuilder::new(
WidgetBuilder::new()
.with_desired_position(Vector2::new(window_width - 670.0, 0.0))
.with_width(350.0),
)
.with_content(
GridBuilder::new(
WidgetBuilder::new()
.with_child(
TextBuilder::new(WidgetBuilder::new().on_column(0).on_row(0))
.with_text("Resolution")
.build(ctx),
)
.with_child({
resolutions =
DropdownListBuilder::new(WidgetBuilder::new().on_row(0).on_column(1))
// Set combo box items - each item will represent video mode value.
// When user will select something, we'll receive SelectionChanged
// message and will use received index to switch to desired video
// mode.
.with_items({
let mut items = Vec::new();
for video_mode in video_modes.iter() {
let size = video_mode.size();
let rate = video_mode.refresh_rate();
let item = DecoratorBuilder::new(BorderBuilder::new(
WidgetBuilder::new().with_height(28.0).with_child(
TextBuilder::new(
WidgetBuilder::new().with_horizontal_alignment(
HorizontalAlignment::Center,
),
)
.with_text(format!(
"{}x{}@{}Hz",
size.width, size.height, rate
))
.build(ctx),
),
))
.build(ctx);
items.push(item);
}
items
})
.build(ctx);
resolutions
}),
)
.add_column(Column::strict(120.0))
.add_column(Column::stretch())
.add_row(Row::strict(30.0))
.build(ctx),
)
.with_title(WindowTitle::text("Graphics Options"))
.can_close(false)
.build(ctx);
Interface {
debug_text,
yaw,
scale,
reset,
resolutions,
video_modes,
}
}
struct GameScene {
scene: Scene,
model_handle: Handle<Node>,
walk_animation: Handle<Animation>,
}
async fn create_scene(resource_manager: ResourceManager) -> GameScene {
let mut scene = Scene::new();
// Set ambient light.
scene.ambient_lighting_color = Color::opaque(200, 200, 200);
// Camera is our eyes in the world - you won't see anything without it.
create_camera(
resource_manager.clone(),
Vector3::new(0.0, 6.0, -12.0),
&mut scene.graph,
)
.await;
// Load model resource. Is does *not* adds anything to our scene - it just loads a
// resource then can be used later on to instantiate models from it on scene. Why
// loading of resource is separated from instantiation? Because there it is too
// inefficient to load a resource every time you trying to create instance of it -
// much more efficient is to load it one and then make copies of it. In case of
// models it is very efficient because single vertex and index buffer can be used
// for all models instances, so memory footprint on GPU will be lower.
let model_resource = resource_manager
.request_model(
"examples/data/mutant/mutant.FBX",
MaterialSearchOptions::RecursiveUp,
)
.await
.unwrap();
// Instantiate model on scene - but only geometry, without any animations.
// Instantiation is a process of embedding model resource data in desired scene.
let model_handle = model_resource.instantiate_geometry(&mut scene);
// Add simple animation for our model. Animations are loaded from model resources -
// this is because animation is a set of skeleton bones with their own transforms.
let walk_animation_resource = resource_manager
.request_model(
"examples/data/mutant/walk.fbx",
MaterialSearchOptions::RecursiveUp,
)
.await
.unwrap();
// Once animation resource is loaded it must be re-targeted to our model instance.
// Why? Because animation in *resource* uses information about *resource* bones,
// not model instance bones, retarget_animations maps animations of each bone on
// model instance so animation will know about nodes it should operate on.
let walk_animation = *walk_animation_resource
.retarget_animations(model_handle, &mut scene)
.get(0)
.unwrap();
GameScene {
scene,
model_handle,
walk_animation,
}
}
fn main() {
let event_loop = EventLoop::new();
let window_builder = rg3d::window::WindowBuilder::new()
.with_title("Example - User Interface")
.with_resizable(true);
let mut engine = GameEngine::new(window_builder, &event_loop, true).unwrap();
// Create simple user interface that will show some useful info.
let interface = create_ui(&mut engine);
// Create test scene.
let GameScene {
scene,
model_handle,
walk_animation,
} = rg3d::core::futures::executor::block_on(create_scene(engine.resource_manager.clone()));
// Add scene to engine - engine will take ownership over scene and will return
// you a handle to scene which can be used later on to borrow it and do some
// actions you need.
let scene_handle = engine.scenes.add(scene);
let clock = Instant::now();
let fixed_timestep = 1.0 / 60.0;
let mut elapsed_time = 0.0;
// We will rotate model using keyboard input.
let mut model_angle = DEFAULT_MODEL_ROTATION;
let mut model_scale = DEFAULT_MODEL_SCALE;
// Finally run our event loop which will respond to OS and window events and update
// engine state accordingly. Engine lets you to decide which event should be handled,
// this is minimal working example if how it should be.
event_loop.run(move |event, _, control_flow| {
match event {
Event::MainEventsCleared => {
// This main game loop - it has fixed time step which means that game
// code will run at fixed speed even if renderer can't give you desired
// 60 fps.
let mut dt = clock.elapsed().as_secs_f32() - elapsed_time;
while dt >= fixed_timestep {
dt -= fixed_timestep;
elapsed_time += fixed_timestep;
// ************************
// Put your game logic here.
// ************************
// Use stored scene handle to borrow a mutable reference of scene in
// engine.
let scene = &mut engine.scenes[scene_handle];
// Our animation must be applied to scene explicitly, otherwise
// it will have no effect.
scene
.animations
.get_mut(walk_animation)
.get_pose()
.apply(&mut scene.graph);
scene.graph[model_handle]
.local_transform_mut()
.set_scale(Vector3::new(model_scale, model_scale, model_scale))
.set_rotation(UnitQuaternion::from_axis_angle(
&Vector3::y_axis(),
model_angle.to_radians(),
));
let fps = engine.renderer.get_statistics().frames_per_second;
engine.user_interface.send_message(TextMessage::text(
interface.debug_text,
MessageDirection::ToWidget,
format!("Example 04 - User Interface\nFPS: {}", fps),
));
engine.update(fixed_timestep);
}
// It is very important to "pump" messages from UI. This our main point where we communicate
// with user interface. As you saw earlier, there is no callbacks on UI elements, instead we
// use messages to get information from UI elements. This provides perfect decoupling of logic
// from UI elements and works well with borrow checker.
while let Some(ui_message) = engine.user_interface.poll_message() {
match ui_message.data() {
UiMessageData::ScrollBar(msg)
if ui_message.direction() == MessageDirection::FromWidget =>
{
// Some of our scroll bars has changed its value. Check which one.
if let ScrollBarMessage::Value(value) = msg {
// Each message has source - a handle of UI element that created this message.
// It is used to understand from which UI element message has come.
if ui_message.destination() == interface.scale {
model_scale = *value;
} else if ui_message.destination() == interface.yaw {
model_angle = *value;
}
}
}
UiMessageData::Button(msg) => {
if let ButtonMessage::Click = msg {
// Once we received Click event from Reset button, we have to reset angle and scale
// of model. To do that we borrow each UI element in engine and set its value directly.
// This is not ideal because there is tight coupling between UI code and model values,
// but still good enough for example.
if ui_message.destination() == interface.reset {
engine.user_interface.send_message(ScrollBarMessage::value(
interface.scale,
MessageDirection::ToWidget,
DEFAULT_MODEL_SCALE,
));
engine.user_interface.send_message(ScrollBarMessage::value(
interface.yaw,
MessageDirection::ToWidget,
DEFAULT_MODEL_ROTATION,
));
}
}
}
UiMessageData::DropdownList(msg) => {
if let DropdownListMessage::SelectionChanged(idx) = msg {
// Video mode has changed and we must change video mode to what user wants.
if let Some(idx) = idx {
if ui_message.destination() == interface.resolutions {
let video_mode = interface.video_modes.get(*idx).unwrap();
engine.get_window().set_fullscreen(Some(
Fullscreen::Exclusive(video_mode.clone()),
));
// Due to some weird bug in winit it does not send Resized event.
engine.renderer.set_frame_size((
video_mode.size().width,
video_mode.size().height,
));
}
}
}
}
_ => (),
}
}
// Rendering must be explicitly requested and handled after RedrawRequested event is received.
engine.get_window().request_redraw();
}
Event::RedrawRequested(_) => {
// Run renderer at max speed - it is not tied to game code.
engine.render().unwrap();
}
Event::WindowEvent { event, .. } => {
match event {
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
WindowEvent::Resized(size) => {
// It is very important to handle Resized event from window, because
// renderer knows nothing about window size - it must be notified
// directly when window size has changed.
engine.renderer.set_frame_size(size.into());
}
WindowEvent::KeyboardInput { input, .. } => {
if let Some(key_code) = input.virtual_keycode {
if input.state == ElementState::Pressed
&& key_code == VirtualKeyCode::Escape
{
*control_flow = ControlFlow::Exit;
}
}
}
_ => (),
}
// It is very important to "feed" user interface (UI) with events coming
// from main window, otherwise UI won't respond to mouse, keyboard, or any
// other event.
if let Some(os_event) = translate_event(&event) {
engine.user_interface.process_os_event(&os_event);
}
}
Event::DeviceEvent { .. } => {
// Handle key input events via `WindowEvent`, not via `DeviceEvent` (#32)
}
_ => *control_flow = ControlFlow::Poll,
}
});
}
| 43.251418 | 119 | 0.500612 |
0d0e615aee183cb0c893d8631bc28845a2793aa6 | 578 | ps1 | PowerShell | Functions/Convert-CredentialToUserProfileCredential.ps1 | exactmike/OneShell | 8d766e30648632c895f2c62e7904f61b1a30d9e2 | [
"MIT"
] | 11 | 2018-04-05T15:26:43.000Z | 2021-10-03T12:23:13.000Z | Functions/Convert-CredentialToUserProfileCredential.ps1 | exactmike/OneShell | 8d766e30648632c895f2c62e7904f61b1a30d9e2 | [
"MIT"
] | 6 | 2016-12-14T19:40:51.000Z | 2018-12-13T22:45:07.000Z | Functions/Convert-CredentialToUserProfileCredential.ps1 | exactmike/OneShell | 8d766e30648632c895f2c62e7904f61b1a30d9e2 | [
"MIT"
] | 4 | 2017-10-03T19:55:24.000Z | 2018-10-11T15:39:38.000Z | Function Convert-CredentialToUserProfileCredential
{
[cmdletbinding()]
param
(
[pscredential]$credential
,
[string]$Identity
)
if ($null -eq $Identity -or [string]::IsNullOrWhiteSpace($Identity))
{$Identity = $(New-OneShellGuid).guid}
$credential | Add-Member -MemberType NoteProperty -Name 'Identity' -Value $Identity
$credential | Select-Object -Property @{n = 'Identity'; e = {$_.Identity}}, @{n = 'UserName'; e = {$_.UserName}}, @{n = 'Password'; e = {$_.Password | ConvertFrom-SecureString}}
}
| 32.111111 | 181 | 0.614187 |
f4fd3f2a882a3a80eef70623bff025639048cfc5 | 616 | go | Go | hashes/modules/1400_sha256.go | 6un9-h0-Dan/hashvalidate | b5c74a1728c5ad5d88caf59842f9ec4fc71132a9 | [
"MIT"
] | 3 | 2020-11-08T00:18:14.000Z | 2020-12-23T19:27:19.000Z | hashes/modules/1400_sha256.go | 6un9-h0-Dan/hashvalidate | b5c74a1728c5ad5d88caf59842f9ec4fc71132a9 | [
"MIT"
] | 1 | 2020-11-08T00:12:33.000Z | 2020-11-08T00:12:33.000Z | hashes/modules/1400_sha256.go | 6un9-h0-Dan/hashvalidate | b5c74a1728c5ad5d88caf59842f9ec4fc71132a9 | [
"MIT"
] | 1 | 2020-12-23T19:27:22.000Z | 2020-12-23T19:27:22.000Z | package modules
import (
"github.com/tankbusta/hashvalidate/hashes"
"github.com/tankbusta/hashvalidate/tokenizer"
)
type sha256_1400 struct{}
func init() {
hashes.Register(1400, sha256_1400{})
}
func (s sha256_1400) Name() string { return "SHA-256" }
func (s sha256_1400) Example() string {
return "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935"
}
func (s sha256_1400) Type() int { return 1400 }
func (s sha256_1400) Tokens() []tokenizer.Token {
return []tokenizer.Token{
{
LengthMin: 64,
LengthMax: 64,
Attributes: tokenizer.VerifyLength | tokenizer.VerifyHex,
},
}
}
| 19.870968 | 74 | 0.730519 |
0a3117b1951aae82374a3b799765a43bb12a129d | 966 | tsx | TypeScript | app/renderer/containers/Home/DataFetcherHoc.tsx | yeahDDD/cnode-electron | 3c22c0c6fa74848bceeb7025a2df2e153704fcab | [
"MIT"
] | null | null | null | app/renderer/containers/Home/DataFetcherHoc.tsx | yeahDDD/cnode-electron | 3c22c0c6fa74848bceeb7025a2df2e153704fcab | [
"MIT"
] | null | null | null | app/renderer/containers/Home/DataFetcherHoc.tsx | yeahDDD/cnode-electron | 3c22c0c6fa74848bceeb7025a2df2e153704fcab | [
"MIT"
] | null | null | null | import * as React from "react";
import { getTopics } from '@renderer/services'
import { TopicModel } from '@renderer/models'
import {fixImgUrl} from '@renderer/util/index'
interface HomeState {
topics: TopicModel[]
}
const dataFetcherHoc = (tab = '') => {
return (WrapComponent) => class dataFetcherHoc extends React.Component<any, HomeState> {
constructor(props) {
super(props)
this.state = {
topics: []
}
}
async componentDidMount() {
const topics = tab ? await getTopics({tab}) : await getTopics()
const data = topics.data.map(item => ({...item, author: {
...item.author,
avatar_url: fixImgUrl(item.author.avatar_url)
}}))
this.setState({topics: data})
}
render() {
return (<WrapComponent topics={this.state.topics}/>)
}
}
}
export default dataFetcherHoc | 29.272727 | 92 | 0.561077 |
a0f4f2e7c6617cf3fb076ec338ffeb00b550db84 | 76 | lua | Lua | lua/jesse/lsp/languages/yaml.lua | malinoskj2/j2-nvim | 603aa0396754068814329b38d99bf914df9e50fe | [
"BSD-2-Clause"
] | null | null | null | lua/jesse/lsp/languages/yaml.lua | malinoskj2/j2-nvim | 603aa0396754068814329b38d99bf914df9e50fe | [
"BSD-2-Clause"
] | null | null | null | lua/jesse/lsp/languages/yaml.lua | malinoskj2/j2-nvim | 603aa0396754068814329b38d99bf914df9e50fe | [
"BSD-2-Clause"
] | null | null | null | return {
name = "YAML",
language_server = {
name = "yamlls",
},
}
| 10.857143 | 21 | 0.513158 |
818cfe0d1b3bf149f0ad7bd1bdd662dd714b0eac | 1,630 | lua | Lua | src/Player.lua | michidevv/tile-rpg | 880a242e6e021c9b2d2058ee225e2a6024e8113b | [
"MIT"
] | null | null | null | src/Player.lua | michidevv/tile-rpg | 880a242e6e021c9b2d2058ee225e2a6024e8113b | [
"MIT"
] | null | null | null | src/Player.lua | michidevv/tile-rpg | 880a242e6e021c9b2d2058ee225e2a6024e8113b | [
"MIT"
] | null | null | null | local MOVE_MAP = {
[1] = function(self) return { y = self.y + DRAW_TILESIZE } end,
[2] = function(self) return { x = self.x - DRAW_TILESIZE } end,
[3] = function(self) return { y = self.y - DRAW_TILESIZE } end,
[4] = function(self) return { x = self.x + DRAW_TILESIZE } end,
}
local Player = function(def)
local player = {
x = def.x,
y = def.y,
scale = def.scale,
moving = false,
animation = Animation {
frames = {1, 2, 3},
delay = 0.2,
},
facing = 1,
tween = Tween(),
}
local function move(self)
self.moving = true
self.tween:start({
timer = 0.3, -- Calculate using speed.
subject = self,
target = MOVE_MAP[self.facing](self),
}):after(function() self.moving = false end)
end
function player:update(dt)
self.animation:update(dt)
self.tween:update(dt)
for k, v in pairs(FACING_ENUM) do
if love.keyboard.isDown(v) then
if not self.moving then
self.facing = k
move(self)
end
end
end
end
function player:draw()
love.graphics.draw(
TILESHEET,
CHAR_TILES[FACING_ENUM[self.facing]][self.animation:getFrame()],
self.x,
self.y,
self.facing == 2 and math.pi or 0,
self.scale,
self.facing == 2 and -self.scale or self.scale,
self.facing == 2 and 9 or 0
)
end
return player
end
return Player
| 25.46875 | 76 | 0.504294 |
cf3307205e0ced88cd9f12ad78ca718637ea8027 | 772 | sql | SQL | tests/queries/0_stateless/01414_push_predicate_when_contains_with_clause.sql | pdv-ru/ClickHouse | 0ff975bcf3008fa6c6373cbdfed16328e3863ec5 | [
"Apache-2.0"
] | 15,577 | 2019-09-23T11:57:53.000Z | 2022-03-31T18:21:48.000Z | tests/queries/0_stateless/01414_push_predicate_when_contains_with_clause.sql | pdv-ru/ClickHouse | 0ff975bcf3008fa6c6373cbdfed16328e3863ec5 | [
"Apache-2.0"
] | 16,476 | 2019-09-23T11:47:00.000Z | 2022-03-31T23:06:01.000Z | tests/queries/0_stateless/01414_push_predicate_when_contains_with_clause.sql | pdv-ru/ClickHouse | 0ff975bcf3008fa6c6373cbdfed16328e3863ec5 | [
"Apache-2.0"
] | 3,633 | 2019-09-23T12:18:28.000Z | 2022-03-31T15:55:48.000Z | DROP TABLE IF EXISTS numbers_indexed;
DROP TABLE IF EXISTS squares;
CREATE TABLE numbers_indexed Engine=MergeTree ORDER BY number PARTITION BY bitShiftRight(number,8) SETTINGS index_granularity=8 AS SELECT * FROM numbers(16384);
CREATE VIEW squares AS WITH number*2 AS square_number SELECT number, square_number FROM numbers_indexed;
SET max_rows_to_read=8, read_overflow_mode='throw';
WITH number * 2 AS square_number SELECT number, square_number FROM numbers_indexed WHERE number = 999;
SELECT * FROM squares WHERE number = 999;
EXPLAIN SYNTAX SELECT number, square_number FROM ( WITH number * 2 AS square_number SELECT number, square_number FROM numbers_indexed) AS squares WHERE number = 999;
DROP TABLE IF EXISTS squares;
DROP TABLE IF EXISTS numbers_indexed;
| 42.888889 | 165 | 0.814767 |
4a63394691580afddfa7185469ac537fd51762fb | 2,096 | html | HTML | about.html | HCC-NEH/HCC-NEH.github.io | 0c2dfbbd0e11a8723aa890fd17352a4ca7912c6b | [
"MIT"
] | 1 | 2021-02-11T01:56:51.000Z | 2021-02-11T01:56:51.000Z | about.html | HCC-NEH/HCC-NEH.github.io | 0c2dfbbd0e11a8723aa890fd17352a4ca7912c6b | [
"MIT"
] | 5 | 2021-02-21T02:03:49.000Z | 2021-03-04T01:32:03.000Z | about.html | HCC-NEH/HCC-NEH.github.io | 0c2dfbbd0e11a8723aa890fd17352a4ca7912c6b | [
"MIT"
] | null | null | null | <html>
<head>
<title>About</title>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel ="stylesheet" href="reflectionstyle.css">
</head>
<body>
<h1>About us</h1>
<a href="/index.html">back</a>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Nec nam aliquam sem et tortor consequat id porta nibh. Dui ut ornare lectus sit amet est placerat in. Morbi tristique senectus et netus et. Nibh mauris cursus mattis molestie a iaculis. Odio eu feugiat pretium nibh ipsum consequat nisl vel. Eget duis at tellus at. Amet dictum sit amet justo. Eget lorem dolor sed viverra ipsum nunc aliquet. Fringilla urna porttitor rhoncus dolor. Rhoncus mattis rhoncus urna neque viverra. Ipsum dolor sit amet consectetur adipiscing elit pellentesque habitant morbi. Nec ullamcorper sit amet risus nullam eget felis. Suscipit tellus mauris a diam maecenas. Eu sem integer vitae justo.
</p>
<h3>About James Karmel</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem sed risus ultricies tristique nulla. Aliquam faucibus purus in massa. Blandit massa enim nec dui nunc mattis enim ut. Ut ornare lectus sit amet est placerat in egestas erat. Quis vel eros donec ac odio tempor orci dapibus. Nulla at volutpat diam ut venenatis. Imperdiet massa tincidunt nunc pulvinar. Gravida neque convallis a cras semper auctor neque vitae tempus. Feugiat sed lectus vestibulum mattis ullamcorper velit.
</p>
<h3>The NEH Team</h3>
<p>
Aidan Bennett<br>
Alex Wienecke<br>
Jill Russell<br>
Joud Omar<br>
Jason Dipnarine<br>
Logan Milford<br>
Mark Dencler<br>
Mason Piatt<br>
Michael Lunenfeld<br>
Nick Schoeb
</p>
</body>
</html> | 52.4 | 756 | 0.674141 |
22eaf5119ccfaff9da9d33f07343e22b5585ca47 | 20,547 | cpp | C++ | src/taint.cpp | nesclab/ProtocolTaint | 4c51e77fb9e0d0253f488d9a8278b87ecc7ff082 | [
"MIT"
] | 11 | 2020-06-05T11:58:13.000Z | 2021-10-12T03:18:01.000Z | src/taint.cpp | Felix-Kit/ProtocolTaint | b34d0a74967b98dbc7971d504c614f1ac9913365 | [
"MIT"
] | null | null | null | src/taint.cpp | Felix-Kit/ProtocolTaint | b34d0a74967b98dbc7971d504c614f1ac9913365 | [
"MIT"
] | 5 | 2020-05-20T03:22:22.000Z | 2020-11-26T07:52:36.000Z | #include <asm/unistd.h>
#include <vector>
#include <set>
#include "config.hpp"
#include "logic.hpp"
#include "pin.H"
#include "pinobject.hpp"
#include "util.hpp"
#include "loop.cpp"
void Test(Ins ins) {
UINT32 opcount = ins.OpCount();
OPCODE opcode = ins.OpCode();
INT32 ext = ins.Extention();
if (ins.isCall() || ins.isRet() || ins.isBranch() || ins.isNop() ||
opcount <= 1)
return;
if (ext >= 40) return; // sse TODO
if (opcount == 2 || (opcode >= 83 && opcode <= 98)) {
if (ins.isLea()) return;
if (ins.isOpImplicit(0) || ins.isOpImplicit(1)) return;
if (ins.isOpReg(0) && ins.isOpReg(1)) return;
if (ins.isOpReg(0) && ins.isOpImm(1)) return;
if (ins.isOpReg(0) && ins.isOpMem(1)) return;
if (ins.isOpMem(0) && ins.isOpReg(1)) return;
logger::verbose("0 %s", ins.prettify()); return;
// if (ins.isOpMem(0) && ins.isOpImm(1)) return;
// if ((ins.isMemoryWrite() || ins.isMemoryRead())) return;
} else if (opcount == 3) {
logger::verbose("1 %s", ins.prettify()); return;
// if (opcode != XED_ICLASS_XOR) return;
// add sub adc(carry) sbb(borrow)
// sar shr shl ror(rotate) or and
// test cmp bt
} else if (opcount == 4) {
logger::verbose("2 %s", ins.prettify()); return;
// push pop
// mul div imul idiv
} else {
logger::verbose("3 %s", ins.prettify()); return;
}
// INS_OperandImmediate
// INS_OperandRead
// INS_OperandReadAndWritten
// INS_OperandReg
// INS_OperandWritten
// INS_OperandReadOnly
// INS_OperandWrittenOnly
}
bool filter_ins(Ins ins) {
// filter rules
// if (opcount == 2 && (ins.isOpImplicit(0) || ins.isOpImplicit(1))) return;
// TODO neg inc, dec cgo setx
UINT32 opcount = ins.OpCount();
bool ret = ins.isCall() || ins.isRet() || ins.isBranch() || ins.isNop() || opcount <= 1 || opcount >= 5
|| ins.Extention() >= 40 // TODO sse instructions
// || (ins.isOpReg(0) && (ins.OpReg(0) == REG_RBP || ins.OpReg(0) == REG_RSP || ins.OpReg(0) == REG_RIP))
// || (ins.isOpReg(0) && (ins.OpReg(0) == REG_EBP || ins.OpReg(0) == REG_ESP || ins.OpReg(0) == REG_EIP))
;
static std::vector<OPCODE> cache;
if (ret) {
OPCODE opcode = ins.OpCode();
if (std::find(cache.begin(), cache.end(), opcode) == cache.end()) {
cache.push_back(opcode);
logger::debug("assembly not taint included : %s\n",
ins.Name().c_str());
}
}
return ret;
}
void LogInst(Ins ins) {
if (!config::debugMode) return;
if ( filter_ins(ins) ) {
INS_InsertPredicatedCall(
ins, IPOINT_BEFORE, (AFUNPTR)print_instructions0,
IARG_PTR, new std::string(ins.Name()), IARG_INST_PTR,
IARG_END);
return;
}
if (ins.isOpMem(0)) {
if (ins.isOpMem(1)) {
INS_InsertPredicatedCall(
ins, IPOINT_BEFORE, (AFUNPTR)print_instructions1,
IARG_PTR, new std::string(ins.Name()), IARG_INST_PTR,
IARG_CONST_CONTEXT,
IARG_ADDRINT, ins.OpReg(0),
IARG_ADDRINT, ins.OpReg(1),
IARG_MEMORYOP_EA, 0,
IARG_MEMORYOP_EA, 1,
IARG_END);
} else {
INS_InsertPredicatedCall(
ins, IPOINT_BEFORE, (AFUNPTR)print_instructions1,
IARG_PTR, new std::string(ins.Name()), IARG_INST_PTR,
IARG_CONST_CONTEXT,
IARG_ADDRINT, ins.OpReg(0),
IARG_ADDRINT, ins.OpReg(1),
IARG_MEMORYOP_EA, 0,
IARG_ADDRINT, 0,
IARG_END);
}
} else {
INS_InsertPredicatedCall(
ins, IPOINT_BEFORE, (AFUNPTR)print_instructions1,
IARG_PTR, new std::string(ins.Name()), IARG_INST_PTR,
IARG_CONST_CONTEXT,
IARG_ADDRINT, ins.OpReg(0),
IARG_ADDRINT, ins.OpReg(1),
IARG_ADDRINT, 0,
IARG_ADDRINT, 0,
IARG_END);
}
}
void Instruction(Ins ins) {
UINT32 opcount = ins.OpCount();
if ( filter_ins(ins) ) {
return;
}
bool miss = false;
OPCODE opcode = ins.OpCode();
REG reg_w = ins.OpReg(0);
REG reg_r = ins.OpReg(1);
if (opcount == 2) { // condition mov
if (ins.isLea()) { // reg calculation
InsertCall(ins, reg_w); // deleteReg #TODO
} else if (ins.isOpReg(0) && ins.isOpMem(1)) {
InsertCall(ins, reg_w, 0); // ReadMem
} else if (ins.isOpMem(0) && ins.isOpReg(1)) {
InsertCall(ins, 0, reg_r); // WriteMem
} else if (ins.isOpMem(0) && ins.isOpImm(1)) {
InsertCall(ins, 0); // deleteMem
} else if (ins.isOpReg(0) && ins.isOpReg(1)) {
InsertCall(ins, reg_w, reg_r); // spreadReg
} else if (ins.isOpReg(0) && ins.isOpImm(1)) {
InsertCall(ins, reg_w); // deleteReg
} else {
miss = true;
}
} else if (opcount == 3) {
if (ins.isOpReg(0) && ins.isOpReg(1)) {
InsertCallExtra(ins, reg_w, reg_r);
} else if (ins.isOpReg(0) && ins.isOpMem(1)) {
InsertCallExtra(ins, reg_w, 0);
} else if (ins.isOpReg(0) && ins.isOpImm(1)) {
InsertCallExtra(ins, reg_w);
} else if (ins.isOpMem(0) && ins.isOpImm(1)) {
InsertCallExtra(ins, 0);
} else if (ins.isOpMem(0) && ins.isOpReg(1)) {
InsertCallExtra(ins, 0, reg_r);
} else {
miss = true;
}
// add sub adc(carry) sbb(borrow)
// sar shr shl ror(rotate) or and
// test cmp bt
} else if (opcount == 4) {
if (opcode == XED_ICLASS_PUSH) { // push
if (ins.isOpReg(0)) {
InsertCall(ins, 0, reg_w); // WriteMem // note reg_w is the
// first reg op in push
} else if (ins.isOpMem(0)) {
InsertCall(ins, 0, 1); // spreadMem
} else if (ins.isOpImm(0)) {
InsertCall(ins, 0); // deleteMem
} else {
miss = true;
}
} else if (opcode == XED_ICLASS_POP) { // pop
if (ins.isOpReg(0)) {
InsertCall(ins, reg_w, 0); // ReadMem
} else {
miss = true;
}
} else {
miss = true;
}
// mul div imul idiv
}
if (config::missFlag && miss) {
static std::vector<OPCODE> cache;
if (std::find(cache.begin(), cache.end(), opcode) == cache.end()) {
cache.push_back(opcode);
logger::debug("assembly not taint included : %s %d %d\n",
ins.Name().c_str(), reg_w, reg_r);
}
}
}
void Image(IMG img, VOID *v) {
std::string imgName = IMG_Name(img);
logger::verbose("image: %s\n", imgName.c_str());
const bool isMain = IMG_IsMainExecutable(img);
const bool isWrapper = (imgName.find("libx.so") != std::string::npos);
const bool isLib = filter::libs(imgName);
if (!(isMain || isWrapper || isLib)) return;
for (SEC sec = IMG_SecHead(img); SEC_Valid(sec); sec = SEC_Next(sec)) {
logger::verbose("sec: %s\n", SEC_Name(sec).c_str());
for (Rtn rtn = SEC_RtnHead(sec); rtn.Valid(); rtn = rtn.Next()) {
if (rtn.isArtificial()) continue;
std::string *rtnName = new std::string(rtn.Name());
if (filter::blackfunc(*rtnName)) continue;
logger::verbose("function %s\t%s\n", rtnName->c_str(), util::demangle(rtnName->c_str()));
rtn.Open();
if (config::debugMode) {
RTN_InsertCall(
rtn, IPOINT_BEFORE, (AFUNPTR)print_functions,
IARG_PTR, rtnName,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0,
IARG_FUNCARG_ENTRYPOINT_VALUE, 1,
IARG_FUNCARG_ENTRYPOINT_VALUE, 2,
IARG_FUNCARG_ENTRYPOINT_VALUE, 3,
IARG_END);
}
if (isMain || isLib) {
RTN_InsertCall(rtn, IPOINT_BEFORE, (AFUNPTR)function_entry,
IARG_THREAD_ID, IARG_PTR, rtnName,
IARG_ADDRINT, rtn.InsHead().Address(),
IARG_ADDRINT, rtn.InsTail().Address(),
IARG_RETURN_IP,
IARG_END);
RTN_InsertCall(rtn, IPOINT_AFTER, (AFUNPTR)function_exit,
IARG_THREAD_ID, IARG_PTR, rtnName,
IARG_END);
for (Ins ins = rtn.InsHead(); ins.Valid();
ins = ins.Next()) {
LogInst(ins);
Instruction(ins);
}
} else if (isWrapper) {
if (*rtnName == "read") {
RTN_InsertCall(
rtn, IPOINT_BEFORE, (AFUNPTR)read_point,
IARG_ADDRINT, filter::entry,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, // fd
IARG_FUNCARG_ENTRYPOINT_VALUE, 1, // buf
IARG_FUNCARG_ENTRYPOINT_VALUE, 2, // len
IARG_REG_VALUE, REG_RAX, // ret
IARG_END);
RTN_InsertCall(
rtn, IPOINT_AFTER, (AFUNPTR)read_point,
IARG_ADDRINT, filter::exit,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, // fd
IARG_FUNCARG_ENTRYPOINT_VALUE, 1, // buf
IARG_FUNCARG_ENTRYPOINT_VALUE, 2, // len
IARG_REG_VALUE, REG_RAX, // ret
IARG_END);
} else if (*rtnName == "recv") {
RTN_InsertCall(
rtn, IPOINT_BEFORE, (AFUNPTR)recv_point,
IARG_ADDRINT, filter::entry,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, // socket
IARG_FUNCARG_ENTRYPOINT_VALUE, 1, // buf
IARG_FUNCARG_ENTRYPOINT_VALUE, 2, // len
IARG_FUNCARG_ENTRYPOINT_VALUE, 3, // flags
IARG_REG_VALUE, REG_RAX, // ret
IARG_END);
RTN_InsertCall(
rtn, IPOINT_AFTER, (AFUNPTR)recv_point,
IARG_ADDRINT, filter::exit,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, // socket
IARG_FUNCARG_ENTRYPOINT_VALUE, 1, // buf
IARG_FUNCARG_ENTRYPOINT_VALUE, 2, // len
IARG_FUNCARG_ENTRYPOINT_VALUE, 3, // flags
IARG_REG_VALUE, REG_RAX, // ret
IARG_END);
} else if (*rtnName == "recvfrom") {
RTN_InsertCall(
rtn, IPOINT_BEFORE, (AFUNPTR)recvfrom_point,
IARG_ADDRINT, filter::entry,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, // socket
IARG_FUNCARG_ENTRYPOINT_VALUE, 1, // buf
IARG_FUNCARG_ENTRYPOINT_VALUE, 2, // len
IARG_FUNCARG_ENTRYPOINT_VALUE, 3, // flags
IARG_FUNCARG_ENTRYPOINT_VALUE, 4, // address
IARG_FUNCARG_ENTRYPOINT_VALUE, 5, // address_len
IARG_REG_VALUE, REG_RAX, // ret
IARG_END);
RTN_InsertCall(
rtn, IPOINT_AFTER, (AFUNPTR)recvfrom_point,
IARG_ADDRINT, filter::exit,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, // socket
IARG_FUNCARG_ENTRYPOINT_VALUE, 1, // buf
IARG_FUNCARG_ENTRYPOINT_VALUE, 2, // len
IARG_FUNCARG_ENTRYPOINT_VALUE, 3, // flags
IARG_FUNCARG_ENTRYPOINT_VALUE, 4, // address
IARG_FUNCARG_ENTRYPOINT_VALUE, 5, // address_len
IARG_REG_VALUE, REG_RAX, // ret
IARG_END);
} else if (*rtnName == "recvmsg") {
RTN_InsertCall(
rtn, IPOINT_BEFORE, (AFUNPTR)recvmsg_point,
IARG_ADDRINT, filter::entry,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, // socket
IARG_FUNCARG_ENTRYPOINT_VALUE, 1, // msghdr
IARG_FUNCARG_ENTRYPOINT_VALUE, 2, // flags
IARG_REG_VALUE, REG_RAX, // ret
IARG_END);
RTN_InsertCall(
rtn, IPOINT_AFTER, (AFUNPTR)recvmsg_point,
IARG_ADDRINT, filter::exit,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, // socket
IARG_FUNCARG_ENTRYPOINT_VALUE, 1, // msghdr
IARG_FUNCARG_ENTRYPOINT_VALUE, 2, // flags
IARG_REG_VALUE, REG_RAX, // ret
IARG_END);
} else if (*rtnName == "write") {
RTN_InsertCall(
rtn, IPOINT_BEFORE, (AFUNPTR)write_point,
IARG_ADDRINT, filter::entry,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, // fd
IARG_FUNCARG_ENTRYPOINT_VALUE, 1, // buf
IARG_FUNCARG_ENTRYPOINT_VALUE, 2, // len
IARG_REG_VALUE, REG_RAX, // ret
IARG_END);
RTN_InsertCall(
rtn, IPOINT_AFTER, (AFUNPTR)read_point,
IARG_ADDRINT, filter::exit,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, // fd
IARG_FUNCARG_ENTRYPOINT_VALUE, 1, // buf
IARG_FUNCARG_ENTRYPOINT_VALUE, 2, // len
IARG_REG_VALUE, REG_RAX, // ret
IARG_END);
} else if (*rtnName == "send") {
RTN_InsertCall(
rtn, IPOINT_BEFORE, (AFUNPTR)send_point,
IARG_ADDRINT, filter::entry,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, // socket
IARG_FUNCARG_ENTRYPOINT_VALUE, 1, // buf
IARG_FUNCARG_ENTRYPOINT_VALUE, 2, // len
IARG_FUNCARG_ENTRYPOINT_VALUE, 3, // flags
IARG_REG_VALUE, REG_RAX, // ret
IARG_END);
RTN_InsertCall(
rtn, IPOINT_AFTER, (AFUNPTR)send_point,
IARG_ADDRINT, filter::exit,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, // socket
IARG_FUNCARG_ENTRYPOINT_VALUE, 1, // buf
IARG_FUNCARG_ENTRYPOINT_VALUE, 2, // len
IARG_FUNCARG_ENTRYPOINT_VALUE, 3, // flags
IARG_REG_VALUE, REG_RAX, // ret
IARG_END);
} else if (*rtnName == "sendto") {
RTN_InsertCall(
rtn, IPOINT_BEFORE, (AFUNPTR)sendto_point,
IARG_ADDRINT, filter::entry,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, // socket
IARG_FUNCARG_ENTRYPOINT_VALUE, 1, // buf
IARG_FUNCARG_ENTRYPOINT_VALUE, 2, // len
IARG_FUNCARG_ENTRYPOINT_VALUE, 3, // flags
IARG_FUNCARG_ENTRYPOINT_VALUE, 4, // address
IARG_FUNCARG_ENTRYPOINT_VALUE, 5, // address_len
IARG_REG_VALUE, REG_RAX, // ret
IARG_END);
RTN_InsertCall(
rtn, IPOINT_AFTER, (AFUNPTR)sendto_point,
IARG_ADDRINT, filter::exit,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, // socket
IARG_FUNCARG_ENTRYPOINT_VALUE, 1, // buf
IARG_FUNCARG_ENTRYPOINT_VALUE, 2, // len
IARG_FUNCARG_ENTRYPOINT_VALUE, 3, // flags
IARG_FUNCARG_ENTRYPOINT_VALUE, 4, // address
IARG_FUNCARG_ENTRYPOINT_VALUE, 5, // address_len
IARG_REG_VALUE, REG_RAX, // ret
IARG_END);
} else if (*rtnName == "sendmsg") {
RTN_InsertCall(
rtn, IPOINT_BEFORE, (AFUNPTR)sendmsg_point,
IARG_ADDRINT, filter::entry,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, // socket
IARG_FUNCARG_ENTRYPOINT_VALUE, 1, // msghdr
IARG_FUNCARG_ENTRYPOINT_VALUE, 2, // flags
IARG_REG_VALUE, REG_RAX, // ret
IARG_END);
RTN_InsertCall(
rtn, IPOINT_AFTER, (AFUNPTR)sendmsg_point,
IARG_ADDRINT, filter::exit,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, // socket
IARG_FUNCARG_ENTRYPOINT_VALUE, 1, // msghdr
IARG_FUNCARG_ENTRYPOINT_VALUE, 2, // flags
IARG_REG_VALUE, REG_RAX, // ret
IARG_END);
} else if (*rtnName == "memcpy") { // memcpy use xmm registers to copy
RTN_InsertCall(
rtn, IPOINT_BEFORE, (AFUNPTR)memcpy_point,
IARG_ADDRINT, filter::entry,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, // dest
IARG_FUNCARG_ENTRYPOINT_VALUE, 1, // src
IARG_FUNCARG_ENTRYPOINT_VALUE, 2, // len
IARG_END);
} else if (*rtnName == "memmove") {
RTN_InsertCall(
rtn, IPOINT_BEFORE, (AFUNPTR)memmove_point,
IARG_ADDRINT, filter::entry,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, // dest
IARG_FUNCARG_ENTRYPOINT_VALUE, 1, // src
IARG_FUNCARG_ENTRYPOINT_VALUE, 2, // len
IARG_END);
}
}
rtn.Close();
}
}
}
FILE *files[3];
void Init() {
// PIN_InitLock(&util::lock);
files[0] = fopen(config::filenames[0], "w");
files[1] = fopen(config::filenames[1], "w");
files[2] = fopen(config::filenames[2], "w");
logger::setDebug(config::flags[0], files[0]);
logger::setInfo(config::flags[1], files[1]);
logger::setVerbose(config::flags[2], files[2]);
}
void Fini(INT32 code, VOID *v) {
printf("program end\n");
fprintf(files[0], "#eof\n");
fclose(files[0]);
fprintf(files[1], "#eof\n");
fclose(files[1]);
fprintf(files[2], "#eof\n");
fclose(files[2]);
}
INT32 Usage() {
printf("error\n");
return -1;
}
/* ===================================================================== */
/* Main */
/* ===================================================================== */
int main(int argc, char *argv[]) {
if (PIN_Init(argc, argv)) return Usage();
Init();
// Initialize symbol table code, needed for rtn instrumentation
PIN_InitSymbols();
PIN_InitLock(&util::lock);
// PIN_SetSyntaxIntel();
IMG_AddInstrumentFunction(Image, 0);
TRACE_AddInstrumentFunction(Trace, 0);
// if (config::syscall) {
// if (config::use_entry) PIN_AddSyscallEntryFunction(Syscall_point,
// (void*)filter::entry); if (config::use_exit)
// PIN_AddSyscallExitFunction(Syscall_point , (void*)filter::exit);
// }
PIN_StartProgram();
// PIN_StartProgramProbed();
PIN_AddFiniFunction(Fini, 0);
return 0;
}
| 42.190965 | 113 | 0.482406 |
9c129f156af8c71b7f5bea27057f9448d21e4b84 | 2,841 | js | JavaScript | test/webf.js | WebReflection/webf | cefea1aa6af4a946c419fa706c2ecb242be9e3a8 | [
"MIT"
] | 1 | 2019-01-10T05:49:36.000Z | 2019-01-10T05:49:36.000Z | test/webf.js | WebReflection/webf | cefea1aa6af4a946c419fa706c2ecb242be9e3a8 | [
"MIT"
] | null | null | null | test/webf.js | WebReflection/webf | cefea1aa6af4a946c419fa706c2ecb242be9e3a8 | [
"MIT"
] | null | null | null | if (!module.parent) {
var
wru = require("wru"),
fs = require("fs"),
path = require("path"),
spawn = require('child_process').spawn,
webfDBPath = path.join(process.env.HOME, ".webf"),
webfPath = path.join(__dirname, "../build", "webf"),
bin = process.argv[2] || "polpetta",
binFolder = bin == "polpetta" ? "build" : "bin",
program = path.join(__dirname, "../node_modules/" + bin + "/" + binFolder + "/" + bin),
originalContent,
testObject, testContent
;
try {
originalContent = fs.readFileSync(webfDBPath, "utf-8");
} catch(o_O) {
fs.writeFileSync(webfDBPath, originalContent = "{}", "utf-8");
}
update();
function update() {
testObject = JSON.parse(
testContent = fs.readFileSync(webfDBPath, "utf-8")
);
}
function exec() {
var args = [].slice.call(arguments);
return spawn(
"node", [webfPath].concat(args), {
stdio: [process.stdin, process.stdout, process.stderr]
});
}
function getFolder() {
return path.join(__dirname, ".." + path.sep).slice(0, -path.sep.length);
}
fs.writeFileSync(webfDBPath, testContent, "utf-8");
wru.test([{
name: "webf starts " + bin,
test: function () {
exec("start", program).on("close", wru.async(function () {
update();
wru.assert(bin + " as default namespace", bin in testObject);
wru.assert("folder is there", testObject[bin] && getFolder() in testObject[bin]);
var sub = testObject[bin][getFolder()];
wru.assert(Object.keys(sub).length === 1);
wru.assert(typeof sub[Object.keys(sub)[0]] == "number");
}));
}
}, {
name: "webf stops " + bin,
test: function () {
exec("stop", program).on("close", wru.async(function () {
update();
wru.assert("no more processes", testContent === '{"' + bin + '":{}}');
}));
}
}, {
name: "webf starts with specified port",
test: function () {
exec("start", program, "2902").on("close", wru.async(function () {
update();
wru.assert(bin + " as default namespace", bin in testObject);
wru.assert("folder is there", testObject[bin] && getFolder() in testObject[bin]);
var sub = testObject[bin][getFolder()];
wru.assert(Object.keys(sub).length === 1);
wru.assert(typeof sub[Object.keys(sub)[0]] == "number");
}));
}
}, {
name: "webf stops with " + bin + " argument too",
test: function () {
exec("stop", program).on("close", wru.async(function () {
update();
wru.assert("no more processes", testContent === '{"' + bin + '":{}}');
}));
}
}, function putOriginalContentBack() {
fs.writeFileSync(webfDBPath, originalContent, "utf-8");
update();
wru.assert("same content", testContent === originalContent);
}]);
} | 31.921348 | 91 | 0.570574 |
aa534c12541b5ae8072f695c0bed40fe8f635942 | 182 | sql | SQL | src/test/resources/sql/select/89a8629c.sql | Shuttl-Tech/antlr_psql | fcf83192300abe723f3fd3709aff5b0c8118ad12 | [
"MIT"
] | 66 | 2018-06-15T11:34:03.000Z | 2022-03-16T09:24:49.000Z | src/test/resources/sql/select/89a8629c.sql | Shuttl-Tech/antlr_psql | fcf83192300abe723f3fd3709aff5b0c8118ad12 | [
"MIT"
] | 13 | 2019-03-19T11:56:28.000Z | 2020-08-05T04:20:50.000Z | src/test/resources/sql/select/89a8629c.sql | Shuttl-Tech/antlr_psql | fcf83192300abe723f3fd3709aff5b0c8118ad12 | [
"MIT"
] | 28 | 2019-01-05T19:59:02.000Z | 2022-03-24T11:55:50.000Z | -- file:interval.sql ln:227 expect:true
SELECT f1, f1::INTERVAL DAY TO MINUTE AS "minutes",
(f1 + INTERVAL '1 month')::INTERVAL MONTH::INTERVAL YEAR AS "years"
FROM interval_tbl
| 36.4 | 69 | 0.725275 |
22c8913e60e1c73b5bd4c4b13086386581c13acb | 45,010 | cc | C++ | zircon/system/fidl/fuchsia-hardware-backlight/gen/llcpp/fidl.cc | opensource-assist/fuschia | 66646c55b3d0b36aae90a4b6706b87f1a6261935 | [
"BSD-3-Clause"
] | null | null | null | zircon/system/fidl/fuchsia-hardware-backlight/gen/llcpp/fidl.cc | opensource-assist/fuschia | 66646c55b3d0b36aae90a4b6706b87f1a6261935 | [
"BSD-3-Clause"
] | null | null | null | zircon/system/fidl/fuchsia-hardware-backlight/gen/llcpp/fidl.cc | opensource-assist/fuschia | 66646c55b3d0b36aae90a4b6706b87f1a6261935 | [
"BSD-3-Clause"
] | null | null | null | // WARNING: This file is machine generated by fidlgen.
#include <fuchsia/hardware/backlight/llcpp/fidl.h>
#include <memory>
namespace llcpp {
namespace fuchsia {
namespace hardware {
namespace backlight {
void ::llcpp::fuchsia::hardware::backlight::Device_GetStateNormalized_Result::SizeAndOffsetAssertionHelper() {
static_assert(sizeof(Device_GetStateNormalized_Result) == sizeof(fidl_xunion_t));
static_assert(offsetof(Device_GetStateNormalized_Result, ordinal_) == offsetof(fidl_xunion_t, tag));
static_assert(offsetof(Device_GetStateNormalized_Result, envelope_) == offsetof(fidl_xunion_t, envelope));
}
void ::llcpp::fuchsia::hardware::backlight::Device_GetStateAbsolute_Result::SizeAndOffsetAssertionHelper() {
static_assert(sizeof(Device_GetStateAbsolute_Result) == sizeof(fidl_xunion_t));
static_assert(offsetof(Device_GetStateAbsolute_Result, ordinal_) == offsetof(fidl_xunion_t, tag));
static_assert(offsetof(Device_GetStateAbsolute_Result, envelope_) == offsetof(fidl_xunion_t, envelope));
}
void ::llcpp::fuchsia::hardware::backlight::Device_SetStateNormalized_Result::SizeAndOffsetAssertionHelper() {
static_assert(sizeof(Device_SetStateNormalized_Result) == sizeof(fidl_xunion_t));
static_assert(offsetof(Device_SetStateNormalized_Result, ordinal_) == offsetof(fidl_xunion_t, tag));
static_assert(offsetof(Device_SetStateNormalized_Result, envelope_) == offsetof(fidl_xunion_t, envelope));
}
void ::llcpp::fuchsia::hardware::backlight::Device_SetStateAbsolute_Result::SizeAndOffsetAssertionHelper() {
static_assert(sizeof(Device_SetStateAbsolute_Result) == sizeof(fidl_xunion_t));
static_assert(offsetof(Device_SetStateAbsolute_Result, ordinal_) == offsetof(fidl_xunion_t, tag));
static_assert(offsetof(Device_SetStateAbsolute_Result, envelope_) == offsetof(fidl_xunion_t, envelope));
}
void ::llcpp::fuchsia::hardware::backlight::Device_GetMaxAbsoluteBrightness_Result::SizeAndOffsetAssertionHelper() {
static_assert(sizeof(Device_GetMaxAbsoluteBrightness_Result) == sizeof(fidl_xunion_t));
static_assert(offsetof(Device_GetMaxAbsoluteBrightness_Result, ordinal_) == offsetof(fidl_xunion_t, tag));
static_assert(offsetof(Device_GetMaxAbsoluteBrightness_Result, envelope_) == offsetof(fidl_xunion_t, envelope));
}
namespace {
[[maybe_unused]]
constexpr uint64_t kDevice_GetStateNormalized_Ordinal = 0x44ba72a000000000lu;
[[maybe_unused]]
constexpr uint64_t kDevice_GetStateNormalized_GenOrdinal = 0x2506201b5999b9b7lu;
extern "C" const fidl_type_t fuchsia_hardware_backlight_DeviceGetStateNormalizedRequestTable;
extern "C" const fidl_type_t fuchsia_hardware_backlight_DeviceGetStateNormalizedResponseTable;
extern "C" const fidl_type_t v1_fuchsia_hardware_backlight_DeviceGetStateNormalizedResponseTable;
[[maybe_unused]]
constexpr uint64_t kDevice_SetStateNormalized_Ordinal = 0xc19adb00000000lu;
[[maybe_unused]]
constexpr uint64_t kDevice_SetStateNormalized_GenOrdinal = 0x554ac5cb4f9f5b62lu;
extern "C" const fidl_type_t fuchsia_hardware_backlight_DeviceSetStateNormalizedRequestTable;
extern "C" const fidl_type_t fuchsia_hardware_backlight_DeviceSetStateNormalizedResponseTable;
extern "C" const fidl_type_t v1_fuchsia_hardware_backlight_DeviceSetStateNormalizedResponseTable;
[[maybe_unused]]
constexpr uint64_t kDevice_GetStateAbsolute_Ordinal = 0x971592f00000000lu;
[[maybe_unused]]
constexpr uint64_t kDevice_GetStateAbsolute_GenOrdinal = 0x1f8ccf01cf526a2blu;
extern "C" const fidl_type_t fuchsia_hardware_backlight_DeviceGetStateAbsoluteRequestTable;
extern "C" const fidl_type_t fuchsia_hardware_backlight_DeviceGetStateAbsoluteResponseTable;
extern "C" const fidl_type_t v1_fuchsia_hardware_backlight_DeviceGetStateAbsoluteResponseTable;
[[maybe_unused]]
constexpr uint64_t kDevice_SetStateAbsolute_Ordinal = 0x697f353e00000000lu;
[[maybe_unused]]
constexpr uint64_t kDevice_SetStateAbsolute_GenOrdinal = 0x19c100c43faaa178lu;
extern "C" const fidl_type_t fuchsia_hardware_backlight_DeviceSetStateAbsoluteRequestTable;
extern "C" const fidl_type_t fuchsia_hardware_backlight_DeviceSetStateAbsoluteResponseTable;
extern "C" const fidl_type_t v1_fuchsia_hardware_backlight_DeviceSetStateAbsoluteResponseTable;
[[maybe_unused]]
constexpr uint64_t kDevice_GetMaxAbsoluteBrightness_Ordinal = 0x65fe16500000000lu;
[[maybe_unused]]
constexpr uint64_t kDevice_GetMaxAbsoluteBrightness_GenOrdinal = 0x2aa0699313d4160dlu;
extern "C" const fidl_type_t fuchsia_hardware_backlight_DeviceGetMaxAbsoluteBrightnessRequestTable;
extern "C" const fidl_type_t fuchsia_hardware_backlight_DeviceGetMaxAbsoluteBrightnessResponseTable;
extern "C" const fidl_type_t v1_fuchsia_hardware_backlight_DeviceGetMaxAbsoluteBrightnessResponseTable;
} // namespace
template <>
Device::ResultOf::GetStateNormalized_Impl<Device::GetStateNormalizedResponse>::GetStateNormalized_Impl(::zx::unowned_channel _client_end) {
constexpr uint32_t _kWriteAllocSize = ::fidl::internal::ClampedMessageSize<GetStateNormalizedRequest, ::fidl::MessageDirection::kSending>();
::fidl::internal::AlignedBuffer<_kWriteAllocSize> _write_bytes_inlined;
auto& _write_bytes_array = _write_bytes_inlined;
uint8_t* _write_bytes = _write_bytes_array.view().data();
memset(_write_bytes, 0, GetStateNormalizedRequest::PrimarySize);
::fidl::BytePart _request_bytes(_write_bytes, _kWriteAllocSize, sizeof(GetStateNormalizedRequest));
::fidl::DecodedMessage<GetStateNormalizedRequest> _decoded_request(std::move(_request_bytes));
Super::SetResult(
Device::InPlace::GetStateNormalized(std::move(_client_end), Super::response_buffer()));
}
Device::ResultOf::GetStateNormalized Device::SyncClient::GetStateNormalized() {
return ResultOf::GetStateNormalized(::zx::unowned_channel(this->channel_));
}
Device::ResultOf::GetStateNormalized Device::Call::GetStateNormalized(::zx::unowned_channel _client_end) {
return ResultOf::GetStateNormalized(std::move(_client_end));
}
template <>
Device::UnownedResultOf::GetStateNormalized_Impl<Device::GetStateNormalizedResponse>::GetStateNormalized_Impl(::zx::unowned_channel _client_end, ::fidl::BytePart _response_buffer) {
FIDL_ALIGNDECL uint8_t _write_bytes[sizeof(GetStateNormalizedRequest)] = {};
::fidl::BytePart _request_buffer(_write_bytes, sizeof(_write_bytes));
memset(_request_buffer.data(), 0, GetStateNormalizedRequest::PrimarySize);
_request_buffer.set_actual(sizeof(GetStateNormalizedRequest));
::fidl::DecodedMessage<GetStateNormalizedRequest> _decoded_request(std::move(_request_buffer));
Super::SetResult(
Device::InPlace::GetStateNormalized(std::move(_client_end), std::move(_response_buffer)));
}
Device::UnownedResultOf::GetStateNormalized Device::SyncClient::GetStateNormalized(::fidl::BytePart _response_buffer) {
return UnownedResultOf::GetStateNormalized(::zx::unowned_channel(this->channel_), std::move(_response_buffer));
}
Device::UnownedResultOf::GetStateNormalized Device::Call::GetStateNormalized(::zx::unowned_channel _client_end, ::fidl::BytePart _response_buffer) {
return UnownedResultOf::GetStateNormalized(std::move(_client_end), std::move(_response_buffer));
}
::fidl::DecodeResult<Device::GetStateNormalizedResponse> Device::InPlace::GetStateNormalized(::zx::unowned_channel _client_end, ::fidl::BytePart response_buffer) {
constexpr uint32_t _write_num_bytes = sizeof(GetStateNormalizedRequest);
::fidl::internal::AlignedBuffer<_write_num_bytes> _write_bytes;
::fidl::BytePart _request_buffer = _write_bytes.view();
_request_buffer.set_actual(_write_num_bytes);
::fidl::DecodedMessage<GetStateNormalizedRequest> params(std::move(_request_buffer));
Device::SetTransactionHeaderFor::GetStateNormalizedRequest(params);
auto _encode_request_result = ::fidl::Encode(std::move(params));
if (_encode_request_result.status != ZX_OK) {
return ::fidl::DecodeResult<Device::GetStateNormalizedResponse>::FromFailure(
std::move(_encode_request_result));
}
auto _call_result = ::fidl::Call<GetStateNormalizedRequest, GetStateNormalizedResponse>(
std::move(_client_end), std::move(_encode_request_result.message), std::move(response_buffer));
if (_call_result.status != ZX_OK) {
return ::fidl::DecodeResult<Device::GetStateNormalizedResponse>::FromFailure(
std::move(_call_result));
}
return ::fidl::Decode(std::move(_call_result.message));
}
template <>
Device::ResultOf::SetStateNormalized_Impl<Device::SetStateNormalizedResponse>::SetStateNormalized_Impl(::zx::unowned_channel _client_end, ::llcpp::fuchsia::hardware::backlight::State state) {
constexpr uint32_t _kWriteAllocSize = ::fidl::internal::ClampedMessageSize<SetStateNormalizedRequest, ::fidl::MessageDirection::kSending>();
::fidl::internal::AlignedBuffer<_kWriteAllocSize> _write_bytes_inlined;
auto& _write_bytes_array = _write_bytes_inlined;
uint8_t* _write_bytes = _write_bytes_array.view().data();
memset(_write_bytes, 0, SetStateNormalizedRequest::PrimarySize);
auto& _request = *reinterpret_cast<SetStateNormalizedRequest*>(_write_bytes);
_request.state = std::move(state);
::fidl::BytePart _request_bytes(_write_bytes, _kWriteAllocSize, sizeof(SetStateNormalizedRequest));
::fidl::DecodedMessage<SetStateNormalizedRequest> _decoded_request(std::move(_request_bytes));
Super::SetResult(
Device::InPlace::SetStateNormalized(std::move(_client_end), std::move(_decoded_request), Super::response_buffer()));
}
Device::ResultOf::SetStateNormalized Device::SyncClient::SetStateNormalized(::llcpp::fuchsia::hardware::backlight::State state) {
return ResultOf::SetStateNormalized(::zx::unowned_channel(this->channel_), std::move(state));
}
Device::ResultOf::SetStateNormalized Device::Call::SetStateNormalized(::zx::unowned_channel _client_end, ::llcpp::fuchsia::hardware::backlight::State state) {
return ResultOf::SetStateNormalized(std::move(_client_end), std::move(state));
}
template <>
Device::UnownedResultOf::SetStateNormalized_Impl<Device::SetStateNormalizedResponse>::SetStateNormalized_Impl(::zx::unowned_channel _client_end, ::fidl::BytePart _request_buffer, ::llcpp::fuchsia::hardware::backlight::State state, ::fidl::BytePart _response_buffer) {
if (_request_buffer.capacity() < SetStateNormalizedRequest::PrimarySize) {
Super::SetFailure(::fidl::DecodeResult<SetStateNormalizedResponse>(ZX_ERR_BUFFER_TOO_SMALL, ::fidl::internal::kErrorRequestBufferTooSmall));
return;
}
memset(_request_buffer.data(), 0, SetStateNormalizedRequest::PrimarySize);
auto& _request = *reinterpret_cast<SetStateNormalizedRequest*>(_request_buffer.data());
_request.state = std::move(state);
_request_buffer.set_actual(sizeof(SetStateNormalizedRequest));
::fidl::DecodedMessage<SetStateNormalizedRequest> _decoded_request(std::move(_request_buffer));
Super::SetResult(
Device::InPlace::SetStateNormalized(std::move(_client_end), std::move(_decoded_request), std::move(_response_buffer)));
}
Device::UnownedResultOf::SetStateNormalized Device::SyncClient::SetStateNormalized(::fidl::BytePart _request_buffer, ::llcpp::fuchsia::hardware::backlight::State state, ::fidl::BytePart _response_buffer) {
return UnownedResultOf::SetStateNormalized(::zx::unowned_channel(this->channel_), std::move(_request_buffer), std::move(state), std::move(_response_buffer));
}
Device::UnownedResultOf::SetStateNormalized Device::Call::SetStateNormalized(::zx::unowned_channel _client_end, ::fidl::BytePart _request_buffer, ::llcpp::fuchsia::hardware::backlight::State state, ::fidl::BytePart _response_buffer) {
return UnownedResultOf::SetStateNormalized(std::move(_client_end), std::move(_request_buffer), std::move(state), std::move(_response_buffer));
}
::fidl::DecodeResult<Device::SetStateNormalizedResponse> Device::InPlace::SetStateNormalized(::zx::unowned_channel _client_end, ::fidl::DecodedMessage<SetStateNormalizedRequest> params, ::fidl::BytePart response_buffer) {
Device::SetTransactionHeaderFor::SetStateNormalizedRequest(params);
auto _encode_request_result = ::fidl::Encode(std::move(params));
if (_encode_request_result.status != ZX_OK) {
return ::fidl::DecodeResult<Device::SetStateNormalizedResponse>::FromFailure(
std::move(_encode_request_result));
}
auto _call_result = ::fidl::Call<SetStateNormalizedRequest, SetStateNormalizedResponse>(
std::move(_client_end), std::move(_encode_request_result.message), std::move(response_buffer));
if (_call_result.status != ZX_OK) {
return ::fidl::DecodeResult<Device::SetStateNormalizedResponse>::FromFailure(
std::move(_call_result));
}
return ::fidl::Decode(std::move(_call_result.message));
}
template <>
Device::ResultOf::GetStateAbsolute_Impl<Device::GetStateAbsoluteResponse>::GetStateAbsolute_Impl(::zx::unowned_channel _client_end) {
constexpr uint32_t _kWriteAllocSize = ::fidl::internal::ClampedMessageSize<GetStateAbsoluteRequest, ::fidl::MessageDirection::kSending>();
::fidl::internal::AlignedBuffer<_kWriteAllocSize> _write_bytes_inlined;
auto& _write_bytes_array = _write_bytes_inlined;
uint8_t* _write_bytes = _write_bytes_array.view().data();
memset(_write_bytes, 0, GetStateAbsoluteRequest::PrimarySize);
::fidl::BytePart _request_bytes(_write_bytes, _kWriteAllocSize, sizeof(GetStateAbsoluteRequest));
::fidl::DecodedMessage<GetStateAbsoluteRequest> _decoded_request(std::move(_request_bytes));
Super::SetResult(
Device::InPlace::GetStateAbsolute(std::move(_client_end), Super::response_buffer()));
}
Device::ResultOf::GetStateAbsolute Device::SyncClient::GetStateAbsolute() {
return ResultOf::GetStateAbsolute(::zx::unowned_channel(this->channel_));
}
Device::ResultOf::GetStateAbsolute Device::Call::GetStateAbsolute(::zx::unowned_channel _client_end) {
return ResultOf::GetStateAbsolute(std::move(_client_end));
}
template <>
Device::UnownedResultOf::GetStateAbsolute_Impl<Device::GetStateAbsoluteResponse>::GetStateAbsolute_Impl(::zx::unowned_channel _client_end, ::fidl::BytePart _response_buffer) {
FIDL_ALIGNDECL uint8_t _write_bytes[sizeof(GetStateAbsoluteRequest)] = {};
::fidl::BytePart _request_buffer(_write_bytes, sizeof(_write_bytes));
memset(_request_buffer.data(), 0, GetStateAbsoluteRequest::PrimarySize);
_request_buffer.set_actual(sizeof(GetStateAbsoluteRequest));
::fidl::DecodedMessage<GetStateAbsoluteRequest> _decoded_request(std::move(_request_buffer));
Super::SetResult(
Device::InPlace::GetStateAbsolute(std::move(_client_end), std::move(_response_buffer)));
}
Device::UnownedResultOf::GetStateAbsolute Device::SyncClient::GetStateAbsolute(::fidl::BytePart _response_buffer) {
return UnownedResultOf::GetStateAbsolute(::zx::unowned_channel(this->channel_), std::move(_response_buffer));
}
Device::UnownedResultOf::GetStateAbsolute Device::Call::GetStateAbsolute(::zx::unowned_channel _client_end, ::fidl::BytePart _response_buffer) {
return UnownedResultOf::GetStateAbsolute(std::move(_client_end), std::move(_response_buffer));
}
::fidl::DecodeResult<Device::GetStateAbsoluteResponse> Device::InPlace::GetStateAbsolute(::zx::unowned_channel _client_end, ::fidl::BytePart response_buffer) {
constexpr uint32_t _write_num_bytes = sizeof(GetStateAbsoluteRequest);
::fidl::internal::AlignedBuffer<_write_num_bytes> _write_bytes;
::fidl::BytePart _request_buffer = _write_bytes.view();
_request_buffer.set_actual(_write_num_bytes);
::fidl::DecodedMessage<GetStateAbsoluteRequest> params(std::move(_request_buffer));
Device::SetTransactionHeaderFor::GetStateAbsoluteRequest(params);
auto _encode_request_result = ::fidl::Encode(std::move(params));
if (_encode_request_result.status != ZX_OK) {
return ::fidl::DecodeResult<Device::GetStateAbsoluteResponse>::FromFailure(
std::move(_encode_request_result));
}
auto _call_result = ::fidl::Call<GetStateAbsoluteRequest, GetStateAbsoluteResponse>(
std::move(_client_end), std::move(_encode_request_result.message), std::move(response_buffer));
if (_call_result.status != ZX_OK) {
return ::fidl::DecodeResult<Device::GetStateAbsoluteResponse>::FromFailure(
std::move(_call_result));
}
return ::fidl::Decode(std::move(_call_result.message));
}
template <>
Device::ResultOf::SetStateAbsolute_Impl<Device::SetStateAbsoluteResponse>::SetStateAbsolute_Impl(::zx::unowned_channel _client_end, ::llcpp::fuchsia::hardware::backlight::State state) {
constexpr uint32_t _kWriteAllocSize = ::fidl::internal::ClampedMessageSize<SetStateAbsoluteRequest, ::fidl::MessageDirection::kSending>();
::fidl::internal::AlignedBuffer<_kWriteAllocSize> _write_bytes_inlined;
auto& _write_bytes_array = _write_bytes_inlined;
uint8_t* _write_bytes = _write_bytes_array.view().data();
memset(_write_bytes, 0, SetStateAbsoluteRequest::PrimarySize);
auto& _request = *reinterpret_cast<SetStateAbsoluteRequest*>(_write_bytes);
_request.state = std::move(state);
::fidl::BytePart _request_bytes(_write_bytes, _kWriteAllocSize, sizeof(SetStateAbsoluteRequest));
::fidl::DecodedMessage<SetStateAbsoluteRequest> _decoded_request(std::move(_request_bytes));
Super::SetResult(
Device::InPlace::SetStateAbsolute(std::move(_client_end), std::move(_decoded_request), Super::response_buffer()));
}
Device::ResultOf::SetStateAbsolute Device::SyncClient::SetStateAbsolute(::llcpp::fuchsia::hardware::backlight::State state) {
return ResultOf::SetStateAbsolute(::zx::unowned_channel(this->channel_), std::move(state));
}
Device::ResultOf::SetStateAbsolute Device::Call::SetStateAbsolute(::zx::unowned_channel _client_end, ::llcpp::fuchsia::hardware::backlight::State state) {
return ResultOf::SetStateAbsolute(std::move(_client_end), std::move(state));
}
template <>
Device::UnownedResultOf::SetStateAbsolute_Impl<Device::SetStateAbsoluteResponse>::SetStateAbsolute_Impl(::zx::unowned_channel _client_end, ::fidl::BytePart _request_buffer, ::llcpp::fuchsia::hardware::backlight::State state, ::fidl::BytePart _response_buffer) {
if (_request_buffer.capacity() < SetStateAbsoluteRequest::PrimarySize) {
Super::SetFailure(::fidl::DecodeResult<SetStateAbsoluteResponse>(ZX_ERR_BUFFER_TOO_SMALL, ::fidl::internal::kErrorRequestBufferTooSmall));
return;
}
memset(_request_buffer.data(), 0, SetStateAbsoluteRequest::PrimarySize);
auto& _request = *reinterpret_cast<SetStateAbsoluteRequest*>(_request_buffer.data());
_request.state = std::move(state);
_request_buffer.set_actual(sizeof(SetStateAbsoluteRequest));
::fidl::DecodedMessage<SetStateAbsoluteRequest> _decoded_request(std::move(_request_buffer));
Super::SetResult(
Device::InPlace::SetStateAbsolute(std::move(_client_end), std::move(_decoded_request), std::move(_response_buffer)));
}
Device::UnownedResultOf::SetStateAbsolute Device::SyncClient::SetStateAbsolute(::fidl::BytePart _request_buffer, ::llcpp::fuchsia::hardware::backlight::State state, ::fidl::BytePart _response_buffer) {
return UnownedResultOf::SetStateAbsolute(::zx::unowned_channel(this->channel_), std::move(_request_buffer), std::move(state), std::move(_response_buffer));
}
Device::UnownedResultOf::SetStateAbsolute Device::Call::SetStateAbsolute(::zx::unowned_channel _client_end, ::fidl::BytePart _request_buffer, ::llcpp::fuchsia::hardware::backlight::State state, ::fidl::BytePart _response_buffer) {
return UnownedResultOf::SetStateAbsolute(std::move(_client_end), std::move(_request_buffer), std::move(state), std::move(_response_buffer));
}
::fidl::DecodeResult<Device::SetStateAbsoluteResponse> Device::InPlace::SetStateAbsolute(::zx::unowned_channel _client_end, ::fidl::DecodedMessage<SetStateAbsoluteRequest> params, ::fidl::BytePart response_buffer) {
Device::SetTransactionHeaderFor::SetStateAbsoluteRequest(params);
auto _encode_request_result = ::fidl::Encode(std::move(params));
if (_encode_request_result.status != ZX_OK) {
return ::fidl::DecodeResult<Device::SetStateAbsoluteResponse>::FromFailure(
std::move(_encode_request_result));
}
auto _call_result = ::fidl::Call<SetStateAbsoluteRequest, SetStateAbsoluteResponse>(
std::move(_client_end), std::move(_encode_request_result.message), std::move(response_buffer));
if (_call_result.status != ZX_OK) {
return ::fidl::DecodeResult<Device::SetStateAbsoluteResponse>::FromFailure(
std::move(_call_result));
}
return ::fidl::Decode(std::move(_call_result.message));
}
template <>
Device::ResultOf::GetMaxAbsoluteBrightness_Impl<Device::GetMaxAbsoluteBrightnessResponse>::GetMaxAbsoluteBrightness_Impl(::zx::unowned_channel _client_end) {
constexpr uint32_t _kWriteAllocSize = ::fidl::internal::ClampedMessageSize<GetMaxAbsoluteBrightnessRequest, ::fidl::MessageDirection::kSending>();
::fidl::internal::AlignedBuffer<_kWriteAllocSize> _write_bytes_inlined;
auto& _write_bytes_array = _write_bytes_inlined;
uint8_t* _write_bytes = _write_bytes_array.view().data();
memset(_write_bytes, 0, GetMaxAbsoluteBrightnessRequest::PrimarySize);
::fidl::BytePart _request_bytes(_write_bytes, _kWriteAllocSize, sizeof(GetMaxAbsoluteBrightnessRequest));
::fidl::DecodedMessage<GetMaxAbsoluteBrightnessRequest> _decoded_request(std::move(_request_bytes));
Super::SetResult(
Device::InPlace::GetMaxAbsoluteBrightness(std::move(_client_end), Super::response_buffer()));
}
Device::ResultOf::GetMaxAbsoluteBrightness Device::SyncClient::GetMaxAbsoluteBrightness() {
return ResultOf::GetMaxAbsoluteBrightness(::zx::unowned_channel(this->channel_));
}
Device::ResultOf::GetMaxAbsoluteBrightness Device::Call::GetMaxAbsoluteBrightness(::zx::unowned_channel _client_end) {
return ResultOf::GetMaxAbsoluteBrightness(std::move(_client_end));
}
template <>
Device::UnownedResultOf::GetMaxAbsoluteBrightness_Impl<Device::GetMaxAbsoluteBrightnessResponse>::GetMaxAbsoluteBrightness_Impl(::zx::unowned_channel _client_end, ::fidl::BytePart _response_buffer) {
FIDL_ALIGNDECL uint8_t _write_bytes[sizeof(GetMaxAbsoluteBrightnessRequest)] = {};
::fidl::BytePart _request_buffer(_write_bytes, sizeof(_write_bytes));
memset(_request_buffer.data(), 0, GetMaxAbsoluteBrightnessRequest::PrimarySize);
_request_buffer.set_actual(sizeof(GetMaxAbsoluteBrightnessRequest));
::fidl::DecodedMessage<GetMaxAbsoluteBrightnessRequest> _decoded_request(std::move(_request_buffer));
Super::SetResult(
Device::InPlace::GetMaxAbsoluteBrightness(std::move(_client_end), std::move(_response_buffer)));
}
Device::UnownedResultOf::GetMaxAbsoluteBrightness Device::SyncClient::GetMaxAbsoluteBrightness(::fidl::BytePart _response_buffer) {
return UnownedResultOf::GetMaxAbsoluteBrightness(::zx::unowned_channel(this->channel_), std::move(_response_buffer));
}
Device::UnownedResultOf::GetMaxAbsoluteBrightness Device::Call::GetMaxAbsoluteBrightness(::zx::unowned_channel _client_end, ::fidl::BytePart _response_buffer) {
return UnownedResultOf::GetMaxAbsoluteBrightness(std::move(_client_end), std::move(_response_buffer));
}
::fidl::DecodeResult<Device::GetMaxAbsoluteBrightnessResponse> Device::InPlace::GetMaxAbsoluteBrightness(::zx::unowned_channel _client_end, ::fidl::BytePart response_buffer) {
constexpr uint32_t _write_num_bytes = sizeof(GetMaxAbsoluteBrightnessRequest);
::fidl::internal::AlignedBuffer<_write_num_bytes> _write_bytes;
::fidl::BytePart _request_buffer = _write_bytes.view();
_request_buffer.set_actual(_write_num_bytes);
::fidl::DecodedMessage<GetMaxAbsoluteBrightnessRequest> params(std::move(_request_buffer));
Device::SetTransactionHeaderFor::GetMaxAbsoluteBrightnessRequest(params);
auto _encode_request_result = ::fidl::Encode(std::move(params));
if (_encode_request_result.status != ZX_OK) {
return ::fidl::DecodeResult<Device::GetMaxAbsoluteBrightnessResponse>::FromFailure(
std::move(_encode_request_result));
}
auto _call_result = ::fidl::Call<GetMaxAbsoluteBrightnessRequest, GetMaxAbsoluteBrightnessResponse>(
std::move(_client_end), std::move(_encode_request_result.message), std::move(response_buffer));
if (_call_result.status != ZX_OK) {
return ::fidl::DecodeResult<Device::GetMaxAbsoluteBrightnessResponse>::FromFailure(
std::move(_call_result));
}
return ::fidl::Decode(std::move(_call_result.message));
}
bool Device::TryDispatch(Interface* impl, fidl_msg_t* msg, ::fidl::Transaction* txn) {
if (msg->num_bytes < sizeof(fidl_message_header_t)) {
zx_handle_close_many(msg->handles, msg->num_handles);
txn->Close(ZX_ERR_INVALID_ARGS);
return true;
}
fidl_message_header_t* hdr = reinterpret_cast<fidl_message_header_t*>(msg->bytes);
zx_status_t status = fidl_validate_txn_header(hdr);
if (status != ZX_OK) {
txn->Close(status);
return true;
}
switch (hdr->ordinal) {
case kDevice_GetStateNormalized_Ordinal:
case kDevice_GetStateNormalized_GenOrdinal:
{
auto result = ::fidl::DecodeAs<GetStateNormalizedRequest>(msg);
if (result.status != ZX_OK) {
txn->Close(ZX_ERR_INVALID_ARGS);
return true;
}
impl->GetStateNormalized(
Interface::GetStateNormalizedCompleter::Sync(txn));
return true;
}
case kDevice_SetStateNormalized_Ordinal:
case kDevice_SetStateNormalized_GenOrdinal:
{
auto result = ::fidl::DecodeAs<SetStateNormalizedRequest>(msg);
if (result.status != ZX_OK) {
txn->Close(ZX_ERR_INVALID_ARGS);
return true;
}
auto message = result.message.message();
impl->SetStateNormalized(std::move(message->state),
Interface::SetStateNormalizedCompleter::Sync(txn));
return true;
}
case kDevice_GetStateAbsolute_Ordinal:
case kDevice_GetStateAbsolute_GenOrdinal:
{
auto result = ::fidl::DecodeAs<GetStateAbsoluteRequest>(msg);
if (result.status != ZX_OK) {
txn->Close(ZX_ERR_INVALID_ARGS);
return true;
}
impl->GetStateAbsolute(
Interface::GetStateAbsoluteCompleter::Sync(txn));
return true;
}
case kDevice_SetStateAbsolute_Ordinal:
case kDevice_SetStateAbsolute_GenOrdinal:
{
auto result = ::fidl::DecodeAs<SetStateAbsoluteRequest>(msg);
if (result.status != ZX_OK) {
txn->Close(ZX_ERR_INVALID_ARGS);
return true;
}
auto message = result.message.message();
impl->SetStateAbsolute(std::move(message->state),
Interface::SetStateAbsoluteCompleter::Sync(txn));
return true;
}
case kDevice_GetMaxAbsoluteBrightness_Ordinal:
case kDevice_GetMaxAbsoluteBrightness_GenOrdinal:
{
auto result = ::fidl::DecodeAs<GetMaxAbsoluteBrightnessRequest>(msg);
if (result.status != ZX_OK) {
txn->Close(ZX_ERR_INVALID_ARGS);
return true;
}
impl->GetMaxAbsoluteBrightness(
Interface::GetMaxAbsoluteBrightnessCompleter::Sync(txn));
return true;
}
default: {
return false;
}
}
}
bool Device::Dispatch(Interface* impl, fidl_msg_t* msg, ::fidl::Transaction* txn) {
bool found = TryDispatch(impl, msg, txn);
if (!found) {
zx_handle_close_many(msg->handles, msg->num_handles);
txn->Close(ZX_ERR_NOT_SUPPORTED);
}
return found;
}
void Device::Interface::GetStateNormalizedCompleterBase::Reply(::llcpp::fuchsia::hardware::backlight::Device_GetStateNormalized_Result result) {
constexpr uint32_t _kWriteAllocSize = ::fidl::internal::ClampedMessageSize<GetStateNormalizedResponse, ::fidl::MessageDirection::kSending>();
FIDL_ALIGNDECL uint8_t _write_bytes[_kWriteAllocSize];
GetStateNormalizedResponse _response = {};
Device::SetTransactionHeaderFor::GetStateNormalizedResponse(
::fidl::DecodedMessage<GetStateNormalizedResponse>(
::fidl::BytePart(reinterpret_cast<uint8_t*>(&_response),
GetStateNormalizedResponse::PrimarySize,
GetStateNormalizedResponse::PrimarySize)));
_response.result = std::move(result);
auto _linearize_result = ::fidl::Linearize(&_response, ::fidl::BytePart(_write_bytes,
_kWriteAllocSize));
if (_linearize_result.status != ZX_OK) {
CompleterBase::Close(ZX_ERR_INTERNAL);
return;
}
CompleterBase::SendReply(std::move(_linearize_result.message));
}
void Device::Interface::GetStateNormalizedCompleterBase::ReplySuccess(::llcpp::fuchsia::hardware::backlight::State state) {
Device_GetStateNormalized_Response response;
response.state = std::move(state);
Reply(Device_GetStateNormalized_Result::WithResponse(&response));
}
void Device::Interface::GetStateNormalizedCompleterBase::ReplyError(int32_t error) {
Reply(Device_GetStateNormalized_Result::WithErr(&error));
}
void Device::Interface::GetStateNormalizedCompleterBase::Reply(::fidl::BytePart _buffer, ::llcpp::fuchsia::hardware::backlight::Device_GetStateNormalized_Result result) {
if (_buffer.capacity() < GetStateNormalizedResponse::PrimarySize) {
CompleterBase::Close(ZX_ERR_INTERNAL);
return;
}
GetStateNormalizedResponse _response = {};
Device::SetTransactionHeaderFor::GetStateNormalizedResponse(
::fidl::DecodedMessage<GetStateNormalizedResponse>(
::fidl::BytePart(reinterpret_cast<uint8_t*>(&_response),
GetStateNormalizedResponse::PrimarySize,
GetStateNormalizedResponse::PrimarySize)));
_response.result = std::move(result);
auto _linearize_result = ::fidl::Linearize(&_response, std::move(_buffer));
if (_linearize_result.status != ZX_OK) {
CompleterBase::Close(ZX_ERR_INTERNAL);
return;
}
CompleterBase::SendReply(std::move(_linearize_result.message));
}
void Device::Interface::GetStateNormalizedCompleterBase::ReplySuccess(::fidl::BytePart _buffer, ::llcpp::fuchsia::hardware::backlight::State state) {
Device_GetStateNormalized_Response response;
response.state = std::move(state);
Reply(std::move(_buffer), Device_GetStateNormalized_Result::WithResponse(&response));
}
void Device::Interface::GetStateNormalizedCompleterBase::Reply(::fidl::DecodedMessage<GetStateNormalizedResponse> params) {
Device::SetTransactionHeaderFor::GetStateNormalizedResponse(params);
CompleterBase::SendReply(std::move(params));
}
void Device::Interface::SetStateNormalizedCompleterBase::Reply(::llcpp::fuchsia::hardware::backlight::Device_SetStateNormalized_Result result) {
constexpr uint32_t _kWriteAllocSize = ::fidl::internal::ClampedMessageSize<SetStateNormalizedResponse, ::fidl::MessageDirection::kSending>();
FIDL_ALIGNDECL uint8_t _write_bytes[_kWriteAllocSize];
SetStateNormalizedResponse _response = {};
Device::SetTransactionHeaderFor::SetStateNormalizedResponse(
::fidl::DecodedMessage<SetStateNormalizedResponse>(
::fidl::BytePart(reinterpret_cast<uint8_t*>(&_response),
SetStateNormalizedResponse::PrimarySize,
SetStateNormalizedResponse::PrimarySize)));
_response.result = std::move(result);
auto _linearize_result = ::fidl::Linearize(&_response, ::fidl::BytePart(_write_bytes,
_kWriteAllocSize));
if (_linearize_result.status != ZX_OK) {
CompleterBase::Close(ZX_ERR_INTERNAL);
return;
}
CompleterBase::SendReply(std::move(_linearize_result.message));
}
void Device::Interface::SetStateNormalizedCompleterBase::ReplySuccess() {
Device_SetStateNormalized_Response response;
Reply(Device_SetStateNormalized_Result::WithResponse(&response));
}
void Device::Interface::SetStateNormalizedCompleterBase::ReplyError(int32_t error) {
Reply(Device_SetStateNormalized_Result::WithErr(&error));
}
void Device::Interface::SetStateNormalizedCompleterBase::Reply(::fidl::BytePart _buffer, ::llcpp::fuchsia::hardware::backlight::Device_SetStateNormalized_Result result) {
if (_buffer.capacity() < SetStateNormalizedResponse::PrimarySize) {
CompleterBase::Close(ZX_ERR_INTERNAL);
return;
}
SetStateNormalizedResponse _response = {};
Device::SetTransactionHeaderFor::SetStateNormalizedResponse(
::fidl::DecodedMessage<SetStateNormalizedResponse>(
::fidl::BytePart(reinterpret_cast<uint8_t*>(&_response),
SetStateNormalizedResponse::PrimarySize,
SetStateNormalizedResponse::PrimarySize)));
_response.result = std::move(result);
auto _linearize_result = ::fidl::Linearize(&_response, std::move(_buffer));
if (_linearize_result.status != ZX_OK) {
CompleterBase::Close(ZX_ERR_INTERNAL);
return;
}
CompleterBase::SendReply(std::move(_linearize_result.message));
}
void Device::Interface::SetStateNormalizedCompleterBase::ReplySuccess(::fidl::BytePart _buffer) {
Device_SetStateNormalized_Response response;
Reply(std::move(_buffer), Device_SetStateNormalized_Result::WithResponse(&response));
}
void Device::Interface::SetStateNormalizedCompleterBase::Reply(::fidl::DecodedMessage<SetStateNormalizedResponse> params) {
Device::SetTransactionHeaderFor::SetStateNormalizedResponse(params);
CompleterBase::SendReply(std::move(params));
}
void Device::Interface::GetStateAbsoluteCompleterBase::Reply(::llcpp::fuchsia::hardware::backlight::Device_GetStateAbsolute_Result result) {
constexpr uint32_t _kWriteAllocSize = ::fidl::internal::ClampedMessageSize<GetStateAbsoluteResponse, ::fidl::MessageDirection::kSending>();
FIDL_ALIGNDECL uint8_t _write_bytes[_kWriteAllocSize];
GetStateAbsoluteResponse _response = {};
Device::SetTransactionHeaderFor::GetStateAbsoluteResponse(
::fidl::DecodedMessage<GetStateAbsoluteResponse>(
::fidl::BytePart(reinterpret_cast<uint8_t*>(&_response),
GetStateAbsoluteResponse::PrimarySize,
GetStateAbsoluteResponse::PrimarySize)));
_response.result = std::move(result);
auto _linearize_result = ::fidl::Linearize(&_response, ::fidl::BytePart(_write_bytes,
_kWriteAllocSize));
if (_linearize_result.status != ZX_OK) {
CompleterBase::Close(ZX_ERR_INTERNAL);
return;
}
CompleterBase::SendReply(std::move(_linearize_result.message));
}
void Device::Interface::GetStateAbsoluteCompleterBase::ReplySuccess(::llcpp::fuchsia::hardware::backlight::State state) {
Device_GetStateAbsolute_Response response;
response.state = std::move(state);
Reply(Device_GetStateAbsolute_Result::WithResponse(&response));
}
void Device::Interface::GetStateAbsoluteCompleterBase::ReplyError(int32_t error) {
Reply(Device_GetStateAbsolute_Result::WithErr(&error));
}
void Device::Interface::GetStateAbsoluteCompleterBase::Reply(::fidl::BytePart _buffer, ::llcpp::fuchsia::hardware::backlight::Device_GetStateAbsolute_Result result) {
if (_buffer.capacity() < GetStateAbsoluteResponse::PrimarySize) {
CompleterBase::Close(ZX_ERR_INTERNAL);
return;
}
GetStateAbsoluteResponse _response = {};
Device::SetTransactionHeaderFor::GetStateAbsoluteResponse(
::fidl::DecodedMessage<GetStateAbsoluteResponse>(
::fidl::BytePart(reinterpret_cast<uint8_t*>(&_response),
GetStateAbsoluteResponse::PrimarySize,
GetStateAbsoluteResponse::PrimarySize)));
_response.result = std::move(result);
auto _linearize_result = ::fidl::Linearize(&_response, std::move(_buffer));
if (_linearize_result.status != ZX_OK) {
CompleterBase::Close(ZX_ERR_INTERNAL);
return;
}
CompleterBase::SendReply(std::move(_linearize_result.message));
}
void Device::Interface::GetStateAbsoluteCompleterBase::ReplySuccess(::fidl::BytePart _buffer, ::llcpp::fuchsia::hardware::backlight::State state) {
Device_GetStateAbsolute_Response response;
response.state = std::move(state);
Reply(std::move(_buffer), Device_GetStateAbsolute_Result::WithResponse(&response));
}
void Device::Interface::GetStateAbsoluteCompleterBase::Reply(::fidl::DecodedMessage<GetStateAbsoluteResponse> params) {
Device::SetTransactionHeaderFor::GetStateAbsoluteResponse(params);
CompleterBase::SendReply(std::move(params));
}
void Device::Interface::SetStateAbsoluteCompleterBase::Reply(::llcpp::fuchsia::hardware::backlight::Device_SetStateAbsolute_Result result) {
constexpr uint32_t _kWriteAllocSize = ::fidl::internal::ClampedMessageSize<SetStateAbsoluteResponse, ::fidl::MessageDirection::kSending>();
FIDL_ALIGNDECL uint8_t _write_bytes[_kWriteAllocSize];
SetStateAbsoluteResponse _response = {};
Device::SetTransactionHeaderFor::SetStateAbsoluteResponse(
::fidl::DecodedMessage<SetStateAbsoluteResponse>(
::fidl::BytePart(reinterpret_cast<uint8_t*>(&_response),
SetStateAbsoluteResponse::PrimarySize,
SetStateAbsoluteResponse::PrimarySize)));
_response.result = std::move(result);
auto _linearize_result = ::fidl::Linearize(&_response, ::fidl::BytePart(_write_bytes,
_kWriteAllocSize));
if (_linearize_result.status != ZX_OK) {
CompleterBase::Close(ZX_ERR_INTERNAL);
return;
}
CompleterBase::SendReply(std::move(_linearize_result.message));
}
void Device::Interface::SetStateAbsoluteCompleterBase::ReplySuccess() {
Device_SetStateAbsolute_Response response;
Reply(Device_SetStateAbsolute_Result::WithResponse(&response));
}
void Device::Interface::SetStateAbsoluteCompleterBase::ReplyError(int32_t error) {
Reply(Device_SetStateAbsolute_Result::WithErr(&error));
}
void Device::Interface::SetStateAbsoluteCompleterBase::Reply(::fidl::BytePart _buffer, ::llcpp::fuchsia::hardware::backlight::Device_SetStateAbsolute_Result result) {
if (_buffer.capacity() < SetStateAbsoluteResponse::PrimarySize) {
CompleterBase::Close(ZX_ERR_INTERNAL);
return;
}
SetStateAbsoluteResponse _response = {};
Device::SetTransactionHeaderFor::SetStateAbsoluteResponse(
::fidl::DecodedMessage<SetStateAbsoluteResponse>(
::fidl::BytePart(reinterpret_cast<uint8_t*>(&_response),
SetStateAbsoluteResponse::PrimarySize,
SetStateAbsoluteResponse::PrimarySize)));
_response.result = std::move(result);
auto _linearize_result = ::fidl::Linearize(&_response, std::move(_buffer));
if (_linearize_result.status != ZX_OK) {
CompleterBase::Close(ZX_ERR_INTERNAL);
return;
}
CompleterBase::SendReply(std::move(_linearize_result.message));
}
void Device::Interface::SetStateAbsoluteCompleterBase::ReplySuccess(::fidl::BytePart _buffer) {
Device_SetStateAbsolute_Response response;
Reply(std::move(_buffer), Device_SetStateAbsolute_Result::WithResponse(&response));
}
void Device::Interface::SetStateAbsoluteCompleterBase::Reply(::fidl::DecodedMessage<SetStateAbsoluteResponse> params) {
Device::SetTransactionHeaderFor::SetStateAbsoluteResponse(params);
CompleterBase::SendReply(std::move(params));
}
void Device::Interface::GetMaxAbsoluteBrightnessCompleterBase::Reply(::llcpp::fuchsia::hardware::backlight::Device_GetMaxAbsoluteBrightness_Result result) {
constexpr uint32_t _kWriteAllocSize = ::fidl::internal::ClampedMessageSize<GetMaxAbsoluteBrightnessResponse, ::fidl::MessageDirection::kSending>();
FIDL_ALIGNDECL uint8_t _write_bytes[_kWriteAllocSize];
GetMaxAbsoluteBrightnessResponse _response = {};
Device::SetTransactionHeaderFor::GetMaxAbsoluteBrightnessResponse(
::fidl::DecodedMessage<GetMaxAbsoluteBrightnessResponse>(
::fidl::BytePart(reinterpret_cast<uint8_t*>(&_response),
GetMaxAbsoluteBrightnessResponse::PrimarySize,
GetMaxAbsoluteBrightnessResponse::PrimarySize)));
_response.result = std::move(result);
auto _linearize_result = ::fidl::Linearize(&_response, ::fidl::BytePart(_write_bytes,
_kWriteAllocSize));
if (_linearize_result.status != ZX_OK) {
CompleterBase::Close(ZX_ERR_INTERNAL);
return;
}
CompleterBase::SendReply(std::move(_linearize_result.message));
}
void Device::Interface::GetMaxAbsoluteBrightnessCompleterBase::ReplySuccess(double max_brightness) {
Device_GetMaxAbsoluteBrightness_Response response;
response.max_brightness = std::move(max_brightness);
Reply(Device_GetMaxAbsoluteBrightness_Result::WithResponse(&response));
}
void Device::Interface::GetMaxAbsoluteBrightnessCompleterBase::ReplyError(int32_t error) {
Reply(Device_GetMaxAbsoluteBrightness_Result::WithErr(&error));
}
void Device::Interface::GetMaxAbsoluteBrightnessCompleterBase::Reply(::fidl::BytePart _buffer, ::llcpp::fuchsia::hardware::backlight::Device_GetMaxAbsoluteBrightness_Result result) {
if (_buffer.capacity() < GetMaxAbsoluteBrightnessResponse::PrimarySize) {
CompleterBase::Close(ZX_ERR_INTERNAL);
return;
}
GetMaxAbsoluteBrightnessResponse _response = {};
Device::SetTransactionHeaderFor::GetMaxAbsoluteBrightnessResponse(
::fidl::DecodedMessage<GetMaxAbsoluteBrightnessResponse>(
::fidl::BytePart(reinterpret_cast<uint8_t*>(&_response),
GetMaxAbsoluteBrightnessResponse::PrimarySize,
GetMaxAbsoluteBrightnessResponse::PrimarySize)));
_response.result = std::move(result);
auto _linearize_result = ::fidl::Linearize(&_response, std::move(_buffer));
if (_linearize_result.status != ZX_OK) {
CompleterBase::Close(ZX_ERR_INTERNAL);
return;
}
CompleterBase::SendReply(std::move(_linearize_result.message));
}
void Device::Interface::GetMaxAbsoluteBrightnessCompleterBase::ReplySuccess(::fidl::BytePart _buffer, double max_brightness) {
Device_GetMaxAbsoluteBrightness_Response response;
response.max_brightness = std::move(max_brightness);
Reply(std::move(_buffer), Device_GetMaxAbsoluteBrightness_Result::WithResponse(&response));
}
void Device::Interface::GetMaxAbsoluteBrightnessCompleterBase::Reply(::fidl::DecodedMessage<GetMaxAbsoluteBrightnessResponse> params) {
Device::SetTransactionHeaderFor::GetMaxAbsoluteBrightnessResponse(params);
CompleterBase::SendReply(std::move(params));
}
void Device::SetTransactionHeaderFor::GetStateNormalizedRequest(const ::fidl::DecodedMessage<Device::GetStateNormalizedRequest>& _msg) {
fidl_init_txn_header(&_msg.message()->_hdr, 0, kDevice_GetStateNormalized_GenOrdinal);
_msg.message()->_hdr.flags[0] |= FIDL_TXN_HEADER_UNION_FROM_XUNION_FLAG;
}
void Device::SetTransactionHeaderFor::GetStateNormalizedResponse(const ::fidl::DecodedMessage<Device::GetStateNormalizedResponse>& _msg) {
fidl_init_txn_header(&_msg.message()->_hdr, 0, kDevice_GetStateNormalized_GenOrdinal);
_msg.message()->_hdr.flags[0] |= FIDL_TXN_HEADER_UNION_FROM_XUNION_FLAG;
}
void Device::SetTransactionHeaderFor::SetStateNormalizedRequest(const ::fidl::DecodedMessage<Device::SetStateNormalizedRequest>& _msg) {
fidl_init_txn_header(&_msg.message()->_hdr, 0, kDevice_SetStateNormalized_GenOrdinal);
_msg.message()->_hdr.flags[0] |= FIDL_TXN_HEADER_UNION_FROM_XUNION_FLAG;
}
void Device::SetTransactionHeaderFor::SetStateNormalizedResponse(const ::fidl::DecodedMessage<Device::SetStateNormalizedResponse>& _msg) {
fidl_init_txn_header(&_msg.message()->_hdr, 0, kDevice_SetStateNormalized_GenOrdinal);
_msg.message()->_hdr.flags[0] |= FIDL_TXN_HEADER_UNION_FROM_XUNION_FLAG;
}
void Device::SetTransactionHeaderFor::GetStateAbsoluteRequest(const ::fidl::DecodedMessage<Device::GetStateAbsoluteRequest>& _msg) {
fidl_init_txn_header(&_msg.message()->_hdr, 0, kDevice_GetStateAbsolute_GenOrdinal);
_msg.message()->_hdr.flags[0] |= FIDL_TXN_HEADER_UNION_FROM_XUNION_FLAG;
}
void Device::SetTransactionHeaderFor::GetStateAbsoluteResponse(const ::fidl::DecodedMessage<Device::GetStateAbsoluteResponse>& _msg) {
fidl_init_txn_header(&_msg.message()->_hdr, 0, kDevice_GetStateAbsolute_GenOrdinal);
_msg.message()->_hdr.flags[0] |= FIDL_TXN_HEADER_UNION_FROM_XUNION_FLAG;
}
void Device::SetTransactionHeaderFor::SetStateAbsoluteRequest(const ::fidl::DecodedMessage<Device::SetStateAbsoluteRequest>& _msg) {
fidl_init_txn_header(&_msg.message()->_hdr, 0, kDevice_SetStateAbsolute_GenOrdinal);
_msg.message()->_hdr.flags[0] |= FIDL_TXN_HEADER_UNION_FROM_XUNION_FLAG;
}
void Device::SetTransactionHeaderFor::SetStateAbsoluteResponse(const ::fidl::DecodedMessage<Device::SetStateAbsoluteResponse>& _msg) {
fidl_init_txn_header(&_msg.message()->_hdr, 0, kDevice_SetStateAbsolute_GenOrdinal);
_msg.message()->_hdr.flags[0] |= FIDL_TXN_HEADER_UNION_FROM_XUNION_FLAG;
}
void Device::SetTransactionHeaderFor::GetMaxAbsoluteBrightnessRequest(const ::fidl::DecodedMessage<Device::GetMaxAbsoluteBrightnessRequest>& _msg) {
fidl_init_txn_header(&_msg.message()->_hdr, 0, kDevice_GetMaxAbsoluteBrightness_GenOrdinal);
_msg.message()->_hdr.flags[0] |= FIDL_TXN_HEADER_UNION_FROM_XUNION_FLAG;
}
void Device::SetTransactionHeaderFor::GetMaxAbsoluteBrightnessResponse(const ::fidl::DecodedMessage<Device::GetMaxAbsoluteBrightnessResponse>& _msg) {
fidl_init_txn_header(&_msg.message()->_hdr, 0, kDevice_GetMaxAbsoluteBrightness_GenOrdinal);
_msg.message()->_hdr.flags[0] |= FIDL_TXN_HEADER_UNION_FROM_XUNION_FLAG;
}
} // namespace backlight
} // namespace hardware
} // namespace fuchsia
} // namespace llcpp
| 54.491525 | 267 | 0.780116 |
1e02e6018e13cc82275f27d9e9049f246620bd24 | 87,980 | lua | Lua | wowItemDB/final_DB/wands_db.lua | Leom3/checkmymogHubProject | 71e573cd48f20fe0eb2121b5bd5116da08d8f97b | [
"MIT"
] | null | null | null | wowItemDB/final_DB/wands_db.lua | Leom3/checkmymogHubProject | 71e573cd48f20fe0eb2121b5bd5116da08d8f97b | [
"MIT"
] | null | null | null | wowItemDB/final_DB/wands_db.lua | Leom3/checkmymogHubProject | 71e573cd48f20fe0eb2121b5bd5116da08d8f97b | [
"MIT"
] | null | null | null | wands_db = {
id0 = {
source = "Taloc",
drop_rate = "0.0",
name = "Titanspark Animator",
category_territory = "Raid",
territory = "Horde",
id = "0",
expansion = "Battle For Azeroth",
location = "Uldir"
},
id1 = {
source = "Savage Cursespitter",
drop_rate = "0.0",
name = "Carmodius Crystalline Stylus",
category_territory = "Outdoor Zone",
territory = "Horde",
id = "1",
expansion = "Battle For Azeroth",
location = "Zuldazar"
},
id2 = {
source = "Laminaria",
drop_rate = "Unknown",
name = "Siren's Song",
category_territory = "Raid",
territory = "Horde",
id = "2",
expansion = "Battle For Azeroth",
location = "Battle of Dazar'alor"
},
id3 = {
source = "Priestess Alunza",
drop_rate = "Unknown",
name = "Wand of Zealous Purification",
category_territory = "Dungeon",
territory = "Horde",
id = "3",
expansion = "Battle For Azeroth",
location = "Atal'Dazar"
},
id4 = {
source = "Sister Martha",
drop_rate = "0.0",
name = "Sister Martha's Soulstealer",
category_territory = "",
territory = "Horde",
id = "4",
expansion = "Battle For Azeroth",
location = "Drustvar"
},
id5 = {
source = "Squirgle of the Depths",
drop_rate = "0.0",
name = "Squirgle's Deepstone Wand",
category_territory = "",
territory = "Horde",
id = "5",
expansion = "Battle For Azeroth",
location = "Tiragarde Sound"
},
id6 = {
source = "Maw of Shul-Nagruth",
drop_rate = "0.0",
name = "Accursed Tuskwand",
category_territory = "Outdoor Zone",
territory = "Horde",
id = "6",
expansion = "Battle For Azeroth",
location = "Nazmir"
},
id7 = {
source = "Venomarus",
drop_rate = "0.0",
name = "Honorbound Wand",
category_territory = "",
territory = "Horde",
id = "7",
expansion = "",
location = "Arathi Highlands"
},
id8 = {
source = "Venomarus",
drop_rate = "0.0",
name = "7th Legionnaire's Wand",
category_territory = "",
territory = "Horde",
id = "8",
expansion = "",
location = "Arathi Highlands"
},
id9 = {
source = "Tidesage Archivist",
drop_rate = "0.0",
name = "Gol Osigr Wand",
category_territory = "",
territory = "Horde",
id = "9",
expansion = "Battle For Azeroth",
location = "Boralus"
},
id10 = {
source = "Volzith the Whisperer",
drop_rate = "0.0",
name = "Coldscale Rod",
category_territory = "Dungeon",
territory = "Horde",
id = "10",
expansion = "Battle For Azeroth",
location = "Shrine of the Storm"
},
id11 = {
source = "Invading Blight Specialist",
drop_rate = "0.0",
name = "Ironcrest Baton",
category_territory = "",
territory = "Horde",
id = "11",
expansion = "Battle For Azeroth",
location = "Tiragarde Sound"
},
id12 = {
source = "Nazmani Supplicant",
drop_rate = "0.0",
name = "Bleached Bone Wand",
category_territory = "Raid",
territory = "Horde",
id = "12",
expansion = "Battle For Azeroth",
location = "Uldir"
},
id13 = {
source = "Bloodhunter Cursecarver",
drop_rate = "0.0",
name = "Rivermarsh Wand",
category_territory = "Outdoor Zone",
territory = "Horde",
id = "13",
expansion = "Battle For Azeroth",
location = "Nazmir"
},
id14 = {
source = "Zandalari Spy",
drop_rate = "0.0",
name = "Warport Hexxer",
category_territory = "Outdoor Zone",
territory = "Horde",
id = "14",
expansion = "Battle For Azeroth",
location = "Zuldazar"
},
id15 = {
source = "Disciple of Nalorakk",
drop_rate = "0.0",
name = "Golden Fleet Wand",
category_territory = "Outdoor Zone",
territory = "Horde",
id = "15",
expansion = "Battle For Azeroth",
location = "Dazar'alor"
},
id16 = {
source = "The Irontide Crew",
drop_rate = "quest",
name = "Seafury Tamer",
category_territory = "",
territory = "Horde",
id = "16",
expansion = "Battle For Azeroth",
location = "Tiragarde Sound"
},
id17 = {
source = "Pork Chop",
drop_rate = "quest",
name = "Elder Crone's Ladle",
category_territory = "",
territory = "Horde",
id = "17",
expansion = "Battle For Azeroth",
location = "Drustvar"
},
id18 = {
source = "From the Depths",
drop_rate = "quest",
name = "Storm's Wake Baton",
category_territory = "",
territory = "Horde",
id = "18",
expansion = "Battle For Azeroth",
location = "Stormsong Valley"
},
id19 = {
source = "Zandalari Treasure Trove",
drop_rate = "quest",
name = "Mugabu's Soulwand",
category_territory = "Outdoor Zone",
territory = "Horde",
id = "19",
expansion = "Battle For Azeroth",
location = "Vol'dun"
},
id20 = {
source = "Off With Her Head",
drop_rate = "quest",
name = "Bloodsinger Wand",
category_territory = "Outdoor Zone",
territory = "Horde",
id = "20",
expansion = "Battle For Azeroth",
location = "Nazmir"
},
id21 = {
source = "Dire Situation",
drop_rate = "quest",
name = "Raal's Spare Hexxer",
category_territory = "Outdoor Zone",
territory = "Horde",
id = "21",
expansion = "Battle For Azeroth",
location = "Zuldazar"
},
id22 = {
source = "Holly McTilla",
drop_rate = "Unknown",
name = "Warmongering Gladiator's Baton of Light",
category_territory = "",
territory = "War Zone",
id = "22",
expansion = "Warlords Of Draenor",
location = "Stormshield"
},
id23 = {
source = "Holly McTilla",
drop_rate = "Unknown",
name = "Warmongering Gladiator's Touch of Defeat",
category_territory = "",
territory = "War Zone",
id = "23",
expansion = "Warlords Of Draenor",
location = "Stormshield"
},
id24 = {
source = "Malukah Lightsong",
drop_rate = "Unknown",
name = "Warmongering Gladiator's Baton of Light",
category_territory = "",
territory = "Alliance",
id = "24",
expansion = "Warlords Of Draenor",
location = "Warspear"
},
id25 = {
source = "Malukah Lightsong",
drop_rate = "Unknown",
name = "Warmongering Gladiator's Touch of Defeat",
category_territory = "",
territory = "Alliance",
id = "25",
expansion = "Warlords Of Draenor",
location = "Warspear"
},
id26 = {
source = "Amelia Clarke",
drop_rate = "Unknown",
name = "Wild Gladiator's Baton of Light",
category_territory = "",
territory = "War Zone",
id = "26",
expansion = "Warlords Of Draenor",
location = "Stormshield"
},
id27 = {
source = "Amelia Clarke",
drop_rate = "Unknown",
name = "Wild Gladiator's Touch of Defeat",
category_territory = "",
territory = "War Zone",
id = "27",
expansion = "Warlords Of Draenor",
location = "Stormshield"
},
id28 = {
source = "Cladd Dawnstrider",
drop_rate = "Unknown",
name = "Wild Gladiator's Baton of Light",
category_territory = "",
territory = "Alliance",
id = "28",
expansion = "Warlords Of Draenor",
location = "Warspear"
},
id29 = {
source = "Cladd Dawnstrider",
drop_rate = "Unknown",
name = "Wild Gladiator's Touch of Defeat",
category_territory = "",
territory = "Alliance",
id = "29",
expansion = "Warlords Of Draenor",
location = "Warspear"
},
id30 = {
source = "Li ",
drop_rate = "Unknown",
name = "Warmongering Combatant's Baton of Light",
category_territory = "",
territory = "War Zone",
id = "30",
expansion = "Warlords Of Draenor",
location = "Stormshield"
},
id31 = {
source = "Li ",
drop_rate = "Unknown",
name = "Warmongering Combatant's Touch of Defeat",
category_territory = "",
territory = "War Zone",
id = "31",
expansion = "Warlords Of Draenor",
location = "Stormshield"
},
id32 = {
source = "Taeloxe Soulshrivel",
drop_rate = "Unknown",
name = "Warmongering Combatant's Baton of Light",
category_territory = "",
territory = "Alliance",
id = "32",
expansion = "Warlords Of Draenor",
location = "Warspear"
},
id33 = {
source = "Taeloxe Soulshrivel",
drop_rate = "Unknown",
name = "Warmongering Combatant's Touch of Defeat",
category_territory = "",
territory = "Alliance",
id = "33",
expansion = "Warlords Of Draenor",
location = "Warspear"
},
id34 = {
source = "Shadow-Lord Iskar",
drop_rate = "0.0",
name = "Deceiver's Felbeak Wand",
category_territory = "Raid",
territory = "Horde",
id = "34",
expansion = "Warlords Of Draenor",
location = "Hellfire Citadel"
},
id35 = {
source = "Blood Guard Axelash",
drop_rate = "Unknown",
name = "Primal Gladiator's Baton of Light",
category_territory = "",
territory = "Alliance",
id = "35",
expansion = "Warlords Of Draenor",
location = "Warspear"
},
id36 = {
source = "Blood Guard Axelash",
drop_rate = "Unknown",
name = "Primal Gladiator's Touch of Defeat",
category_territory = "",
territory = "Alliance",
id = "36",
expansion = "Warlords Of Draenor",
location = "Warspear"
},
id37 = {
source = "Koragh",
drop_rate = "0.0",
name = "Rod of Fel Nullification",
category_territory = "Raid",
territory = "Horde",
id = "37",
expansion = "Warlords Of Draenor",
location = "Highmaul"
},
id38 = {
source = "Ingrid Blackingot",
drop_rate = "Unknown",
name = "Primal Gladiator's Baton of Light",
category_territory = "",
territory = "War Zone",
id = "38",
expansion = "Warlords Of Draenor",
location = "Stormshield"
},
id39 = {
source = "Ingrid Blackingot",
drop_rate = "Unknown",
name = "Primal Gladiator's Touch of Defeat",
category_territory = "",
territory = "War Zone",
id = "39",
expansion = "Warlords Of Draenor",
location = "Stormshield"
},
id40 = {
source = "Enforcer Sorka",
drop_rate = "Unknown",
name = "Battle Medic's Wand",
category_territory = "Raid",
territory = "Horde",
id = "40",
expansion = "Warlords Of Draenor",
location = "Blackrock Foundry"
},
id41 = {
source = "Shadow-Lord Iskar",
drop_rate = "0",
name = "Demonspine Wand",
category_territory = "Raid",
territory = "Horde",
id = "41",
expansion = "Warlords Of Draenor",
location = "Hellfire Citadel"
},
id42 = {
source = "Slugg Spinbolt",
drop_rate = "Unknown",
name = "Wild Combatant's Baton of Light",
category_territory = "",
territory = "War Zone",
id = "42",
expansion = "Warlords Of Draenor",
location = "Stormshield"
},
id43 = {
source = "Slugg Spinbolt",
drop_rate = "Unknown",
name = "Wild Combatant's Touch of Defeat",
category_territory = "",
territory = "War Zone",
id = "43",
expansion = "Warlords Of Draenor",
location = "Stormshield"
},
id44 = {
source = "Fobbly Kickfix",
drop_rate = "Unknown",
name = "Wild Combatant's Baton of Light",
category_territory = "",
territory = "Alliance",
id = "44",
expansion = "Warlords Of Draenor",
location = "Warspear"
},
id45 = {
source = "Fobbly Kickfix",
drop_rate = "Unknown",
name = "Wild Combatant's Touch of Defeat",
category_territory = "",
territory = "Alliance",
id = "45",
expansion = "Warlords Of Draenor",
location = "Warspear"
},
id46 = {
source = "Skulloc",
drop_rate = "0.0",
name = "Painbringer's Crystal",
category_territory = "Dungeon",
territory = "Horde",
id = "46",
expansion = "Warlords Of Draenor",
location = "Iron Docks"
},
id47 = {
source = "Stone Guard Brokefist",
drop_rate = "Unknown",
name = "Primal Combatant's Baton of Light",
category_territory = "",
territory = "Alliance",
id = "47",
expansion = "Warlords Of Draenor",
location = "Warspear"
},
id48 = {
source = "Stone Guard Brokefist",
drop_rate = "Unknown",
name = "Primal Combatant's Touch of Defeat",
category_territory = "",
territory = "Alliance",
id = "48",
expansion = "Warlords Of Draenor",
location = "Warspear"
},
id49 = {
source = "Gluttonous Giant",
drop_rate = "0.0",
name = "Glowing Morel",
category_territory = "",
territory = "Horde",
id = "49",
expansion = "Warlords Of Draenor",
location = "Spires of Arak"
},
id50 = {
source = "Bregg Coppercast",
drop_rate = "Unknown",
name = "Primal Combatant's Baton of Light",
category_territory = "",
territory = "War Zone",
id = "50",
expansion = "Warlords Of Draenor",
location = "Stormshield"
},
id51 = {
source = "Bregg Coppercast",
drop_rate = "Unknown",
name = "Primal Combatant's Touch of Defeat",
category_territory = "",
territory = "War Zone",
id = "51",
expansion = "Warlords Of Draenor",
location = "Stormshield"
},
id52 = {
source = "Sargerei Magus",
drop_rate = "0.0",
name = "Oshu'gun Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "52",
expansion = "Warlords Of Draenor",
location = "Auchindoun"
},
id53 = {
source = "Bloodmane Gutripper",
drop_rate = "0.0",
name = "Felcore Iron Wand",
category_territory = "",
territory = "Horde",
id = "53",
expansion = "Warlords Of Draenor",
location = "Spires of Arak"
},
id54 = {
source = "Everbloom Wasp",
drop_rate = "0.0",
name = "Ancestral Wand",
category_territory = "",
territory = "Horde",
id = "54",
expansion = "Warlords Of Draenor",
location = "Gorgrond"
},
id55 = {
source = "Gorian Beast-Lasher",
drop_rate = "0.0",
name = "Shadowsage Wand",
category_territory = "",
territory = "Horde",
id = "55",
expansion = "Warlords Of Draenor",
location = "Nagrand"
},
id56 = {
source = "Skyreach Sun Talon",
drop_rate = "0.0",
name = "Ruhkmari Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "56",
expansion = "Warlords Of Draenor",
location = "Skyreach"
},
id57 = {
source = "Starlight Sinclair",
drop_rate = "Unknown",
name = "Prideful Gladiator's Touch of Defeat",
category_territory = "",
territory = "Horde",
id = "57",
expansion = "Mists Of Pandaria",
location = "Valley of the Four Winds"
},
id58 = {
source = "Starlight Sinclair",
drop_rate = "Unknown",
name = "Prideful Gladiator's Baton of Light",
category_territory = "",
territory = "Horde",
id = "58",
expansion = "Mists Of Pandaria",
location = "Valley of the Four Winds"
},
id59 = {
source = "Shonn Su",
drop_rate = "Unknown",
name = "Prideful Gladiator's Touch of Defeat",
category_territory = "",
territory = "Horde",
id = "59",
expansion = "Mists Of Pandaria",
location = "Kun-Lai Summit"
},
id60 = {
source = "Shonn Su",
drop_rate = "Unknown",
name = "Prideful Gladiator's Baton of Light",
category_territory = "",
territory = "Horde",
id = "60",
expansion = "Mists Of Pandaria",
location = "Kun-Lai Summit"
},
id61 = {
source = "Engineering Her Demise",
drop_rate = "quest",
name = "Iron Shredder Doohickey",
category_territory = "",
territory = "Horde",
id = "61",
expansion = "Warlords Of Draenor",
location = "Talador"
},
id62 = {
source = "Shattered Hand Brawler",
drop_rate = "0.0",
name = "Sunsworn Wand",
category_territory = "",
territory = "Horde",
id = "62",
expansion = "Warlords Of Draenor",
location = "Spires of Arak"
},
id63 = {
source = "Horridon",
drop_rate = "0.0",
name = "Venomlord's Totemic Wand",
category_territory = "Raid",
territory = "Horde",
id = "63",
expansion = "Mists Of Pandaria",
location = "Throne of Thunder"
},
id64 = {
source = "Horridon",
drop_rate = "0.0",
name = "Venomlord's Totemic Wand",
category_territory = "Raid",
territory = "Horde",
id = "64",
expansion = "Mists Of Pandaria",
location = "Throne of Thunder"
},
id65 = {
source = "Secured Stockpile of Pandaren Spoils",
drop_rate = "Unknown",
name = "Immaculately Preserved Wand",
category_territory = "Raid",
territory = "Horde",
id = "65",
expansion = "Mists Of Pandaria",
location = "Siege of Orgrimmar"
},
id66 = {
source = "Desert Wastetalon",
drop_rate = "0.0",
name = "Kuug'lar's Stylus of Sorcery",
category_territory = "",
territory = "Horde",
id = "66",
expansion = "Warlords Of Draenor",
location = "Gorgrond"
},
id67 = {
source = "Sargerei Ritualist",
drop_rate = "0.0",
name = "Soulkeeper Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "67",
expansion = "Warlords Of Draenor",
location = "Auchindoun"
},
id68 = {
source = "Horridon",
drop_rate = "0.0",
name = "Venomlord's Totemic Wand",
category_territory = "Raid",
territory = "Horde",
id = "68",
expansion = "Mists Of Pandaria",
location = "Throne of Thunder"
},
id69 = {
source = "Gromkar Technician",
drop_rate = "0.0",
name = "Zangarra Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "69",
expansion = "Warlords Of Draenor",
location = "Iron Docks"
},
id70 = {
source = "Horridon",
drop_rate = "0.0",
name = "Venomlord's Totemic Wand",
category_territory = "Raid",
territory = "Horde",
id = "70",
expansion = "Mists Of Pandaria",
location = "Throne of Thunder"
},
id71 = {
source = "Acon Deathwielder",
drop_rate = "Unknown",
name = "Grievous Gladiator's Touch of Defeat",
category_territory = "",
territory = "Horde",
id = "71",
expansion = "Mists Of Pandaria",
location = "Kun-Lai Summit"
},
id72 = {
source = "Acon Deathwielder",
drop_rate = "Unknown",
name = "Grievous Gladiator's Baton of Light",
category_territory = "",
territory = "Horde",
id = "72",
expansion = "Mists Of Pandaria",
location = "Kun-Lai Summit"
},
id73 = {
source = "Ethan Natice",
drop_rate = "Unknown",
name = "Grievous Gladiator's Touch of Defeat",
category_territory = "",
territory = "Horde",
id = "73",
expansion = "Mists Of Pandaria",
location = "Valley of the Four Winds"
},
id74 = {
source = "Ethan Natice",
drop_rate = "Unknown",
name = "Grievous Gladiator's Baton of Light",
category_territory = "",
territory = "Horde",
id = "74",
expansion = "Mists Of Pandaria",
location = "Valley of the Four Winds"
},
id75 = {
source = "Darkness Falls",
drop_rate = "quest",
name = "Karabor Arcanist Wand",
category_territory = "",
territory = "Horde",
id = "75",
expansion = "Warlords Of Draenor",
location = "Shadowmoon Valley"
},
id76 = {
source = "Goren Gouger",
drop_rate = "0.0",
name = "Evermorn Wand",
category_territory = "",
territory = "Horde",
id = "76",
expansion = "Warlords Of Draenor",
location = "Gorgrond"
},
id77 = {
source = "Horridon",
drop_rate = "0.0",
name = "Venomlord's Totemic Wand",
category_territory = "Raid",
territory = "Horde",
id = "77",
expansion = "Mists Of Pandaria",
location = "Throne of Thunder"
},
id78 = {
source = "Bloodmaul Slaver",
drop_rate = "0.0",
name = "Growthshaper Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "78",
expansion = "Warlords Of Draenor",
location = "Bloodmaul Slag Mines"
},
id79 = {
source = "Rattlegore",
drop_rate = "0.0",
name = "Necromantic Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "79",
expansion = "Mists Of Pandaria",
location = "Scholomance"
},
id80 = {
source = "Ethereal Sha",
drop_rate = "0.0",
name = "Wand of Stultifying Smoke",
category_territory = "Dungeon",
territory = "Horde",
id = "80",
expansion = "Mists Of Pandaria",
location = "Shado-Pan Monastery"
},
id81 = {
source = "Rattlegore",
drop_rate = "0.0",
name = "Necromantic Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "81",
expansion = "Mists Of Pandaria",
location = "Scholomance"
},
id82 = {
source = "Pale Skinslicer",
drop_rate = "0.0",
name = "Coldsinger Wand",
category_territory = "",
territory = "Horde",
id = "82",
expansion = "Warlords Of Draenor",
location = "Frostfire Ridge"
},
id83 = {
source = "Darktide Husk",
drop_rate = "0.0",
name = "Moonwhisper Wand",
category_territory = "",
territory = "Horde",
id = "83",
expansion = "Warlords Of Draenor",
location = "Shadowmoon Valley"
},
id84 = {
source = "Vanity",
drop_rate = "0.0",
name = "Immaculate Wand",
category_territory = "Raid",
territory = "Horde",
id = "84",
expansion = "Mists Of Pandaria",
location = "Siege of Orgrimmar"
},
id85 = {
source = "Zandalari Prophet",
drop_rate = "0.0",
name = "Rustic Voodoo Wand",
category_territory = "Raid",
territory = "Horde",
id = "85",
expansion = "Mists Of Pandaria",
location = "Throne of Thunder"
},
id86 = {
source = "Bamboo Python",
drop_rate = "0.0",
name = "Wand of the Exiled Path",
category_territory = "",
territory = "Horde",
id = "86",
expansion = "Mists Of Pandaria",
location = "The Jade Forest"
},
id87 = {
source = "The Ordo Warbringer",
drop_rate = "quest",
name = "Blazecaster's Wand",
category_territory = "",
territory = "Horde",
id = "87",
expansion = "Mists Of Pandaria",
location = "Kun-Lai Summit"
},
id88 = {
source = "Warlord Zonozz",
drop_rate = "0.0",
name = "Finger of Zon'ozz",
category_territory = "Raid",
territory = "Horde",
id = "88",
expansion = "Cataclysm",
location = "Dragon Soul"
},
id89 = {
source = "Enraged Tideweaver",
drop_rate = "0.0",
name = "Grummle Wand",
category_territory = "",
territory = "Horde",
id = "89",
expansion = "Mists Of Pandaria",
location = "Kun-Lai Summit"
},
id90 = {
source = "Vess-Guard Vikaz",
drop_rate = "0.0",
name = "Bejeweled Wand",
category_territory = "",
territory = "Horde",
id = "90",
expansion = "Mists Of Pandaria",
location = "Dread Wastes"
},
id91 = {
source = "Balance",
drop_rate = "quest",
name = "Waterkeeper's Wand",
category_territory = "",
territory = "Horde",
id = "91",
expansion = "Mists Of Pandaria",
location = "Krasarang Wilds"
},
id92 = {
source = "Gardener Fran and the Watering Can",
drop_rate = "quest",
name = "Gardener's Wand",
category_territory = "",
territory = "Horde",
id = "92",
expansion = "Mists Of Pandaria",
location = "Valley of the Four Winds"
},
id93 = {
source = "Majordomo Staghelm",
drop_rate = "0.0",
name = "Stinger of the Flaming Scorpion",
category_territory = "Raid",
territory = "Horde",
id = "93",
expansion = "Cataclysm",
location = "Firelands"
},
id94 = {
source = "Lurah Wrathvine",
drop_rate = "Unknown",
name = "Trail of Embers",
category_territory = "",
territory = "Horde",
id = "94",
expansion = "Cataclysm",
location = "Mount Hyjal"
},
id95 = {
source = "Lurah Wrathvine",
drop_rate = "Unknown",
name = "Scorchvine Wand",
category_territory = "",
territory = "Horde",
id = "95",
expansion = "Cataclysm",
location = "Mount Hyjal"
},
id96 = {
source = "JamusVaz",
drop_rate = "Unknown",
name = "Scintillating Rods",
category_territory = "",
territory = "Alliance",
id = "96",
expansion = "",
location = "Orgrimmar"
},
id97 = {
source = "JamusVaz",
drop_rate = "Unknown",
name = "Hungermouth Wand",
category_territory = "",
territory = "Alliance",
id = "97",
expansion = "",
location = "Orgrimmar"
},
id98 = {
source = "Warlord Zonozz",
drop_rate = "0.0",
name = "Finger of Zon'ozz",
category_territory = "Raid",
territory = "Horde",
id = "98",
expansion = "Cataclysm",
location = "Dragon Soul"
},
id99 = {
source = "Twitchheel Sleepyhead",
drop_rate = "0.0",
name = "Shamanic Wand",
category_territory = "",
territory = "Horde",
id = "99",
expansion = "Mists Of Pandaria",
location = "Valley of the Four Winds"
},
id100 = {
source = "Sergeant Thunderhorn",
drop_rate = "Unknown",
name = "Cataclysmic Gladiator's Baton of Light",
category_territory = "",
territory = "Alliance",
id = "100",
expansion = "",
location = "Orgrimmar"
},
id101 = {
source = "Sergeant Thunderhorn",
drop_rate = "Unknown",
name = "Cataclysmic Gladiator's Touch of Defeat",
category_territory = "",
territory = "Alliance",
id = "101",
expansion = "",
location = "Orgrimmar"
},
id102 = {
source = "Warlord Zonozz",
drop_rate = "0.0",
name = "Finger of Zon'ozz",
category_territory = "Raid",
territory = "Horde",
id = "102",
expansion = "Cataclysm",
location = "Dragon Soul"
},
id103 = {
source = "Chimaeron",
drop_rate = "0.0",
name = "Finkle's Mixer Upper",
category_territory = "Raid",
territory = "Horde",
id = "103",
expansion = "Cataclysm",
location = "Blackwing Descent"
},
id104 = {
source = "Golem Sentry",
drop_rate = "0.0",
name = "Theresa's Booklight",
category_territory = "Raid",
territory = "Horde",
id = "104",
expansion = "Cataclysm",
location = "Blackwing Descent"
},
id105 = {
source = "Blazzek the Biter",
drop_rate = "Unknown",
name = "Vicious Gladiator's Touch of Defeat",
category_territory = "",
territory = "Horde",
id = "105",
expansion = "",
location = "Tanaris"
},
id106 = {
source = "Blazzek the Biter",
drop_rate = "Unknown",
name = "Vicious Gladiator's Baton of Light",
category_territory = "",
territory = "Horde",
id = "106",
expansion = "",
location = "Tanaris"
},
id107 = {
source = "Chimaeron",
drop_rate = "0.0",
name = "Finkle's Mixer Upper",
category_territory = "Raid",
territory = "Horde",
id = "107",
expansion = "Cataclysm",
location = "Blackwing Descent"
},
id108 = {
source = "Bloodlord Mandokir",
drop_rate = "0.0",
name = "Touch of Discord",
category_territory = "Dungeon",
territory = "Horde",
id = "108",
expansion = "Cataclysm",
location = "Zul'Gurub"
},
id109 = {
source = "Wushoolay",
drop_rate = "0.0",
name = "Zulian Voodoo Stick",
category_territory = "Dungeon",
territory = "Horde",
id = "109",
expansion = "Cataclysm",
location = "Zul'Gurub"
},
id110 = {
source = "Blood Guard Zarshi",
drop_rate = "Unknown",
name = "Ruthless Gladiator's Touch of Defeat",
category_territory = "",
territory = "Alliance",
id = "110",
expansion = "",
location = "Orgrimmar"
},
id111 = {
source = "Blood Guard Zarshi",
drop_rate = "Unknown",
name = "Ruthless Gladiator's Baton of Light",
category_territory = "",
territory = "Alliance",
id = "111",
expansion = "",
location = "Orgrimmar"
},
id112 = {
source = "Gunra",
drop_rate = "Unknown",
name = "Scorchvine Wand",
category_territory = "",
territory = "Alliance",
id = "112",
expansion = "",
location = "Orgrimmar"
},
id113 = {
source = "Gunra",
drop_rate = "Unknown",
name = "Trail of Embers",
category_territory = "",
territory = "Alliance",
id = "113",
expansion = "",
location = "Orgrimmar"
},
id114 = {
source = "Majordomo Staghelm",
drop_rate = "0.0",
name = "Stinger of the Flaming Scorpion",
category_territory = "Raid",
territory = "Horde",
id = "114",
expansion = "Cataclysm",
location = "Firelands"
},
id115 = {
source = "Archival Purposes",
drop_rate = "quest",
name = "Crescent Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "115",
expansion = "Cataclysm",
location = "End Time"
},
id116 = {
source = "The Twilight Prophet",
drop_rate = "quest",
name = "Writhing Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "116",
expansion = "Cataclysm",
location = "Hour of Twilight"
},
id117 = {
source = "Forgemaster Throngus",
drop_rate = "0.0",
name = "Wand of Untainted Power",
category_territory = "Dungeon",
territory = "Horde",
id = "117",
expansion = "Cataclysm",
location = "Grim Batol"
},
id118 = {
source = "Corla, Herald of Twilight",
drop_rate = "0.0",
name = "Corla's Baton",
category_territory = "Dungeon",
territory = "Horde",
id = "118",
expansion = "Cataclysm",
location = "Blackrock Caverns"
},
id119 = {
source = "Forgemaster Throngus",
drop_rate = "0.0",
name = "Wand of Untainted Power",
category_territory = "Dungeon",
territory = "Horde",
id = "119",
expansion = "Cataclysm",
location = "Grim Batol"
},
id120 = {
source = "boss",
drop_rate = "Unknown",
name = "Cookie's Stirring Rod",
category_territory = "Dungeon",
territory = "War Zone",
id = "120",
expansion = "",
location = "The Deadmines"
},
id121 = {
source = "Slabhide",
drop_rate = "0.0",
name = "Wand of Dark Worship",
category_territory = "Dungeon",
territory = "Horde",
id = "121",
expansion = "Cataclysm",
location = "The Stonecore"
},
id122 = {
source = "Forgemaster Throngus",
drop_rate = "0.0",
name = "Wand of Untainted Power",
category_territory = "Dungeon",
territory = "Horde",
id = "122",
expansion = "Cataclysm",
location = "Grim Batol"
},
id123 = {
source = "Echo of Jaina",
drop_rate = "0.0",
name = "Crescent Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "123",
expansion = "Cataclysm",
location = "End Time"
},
id124 = {
source = "Garroshar Grunt",
drop_rate = "0.0",
name = "Intricate Wand",
category_territory = "",
territory = "Horde",
id = "124",
expansion = "Mists Of Pandaria",
location = "The Jade Forest"
},
id125 = {
source = "Monstrous Plainshawk",
drop_rate = "0.0",
name = "Gemmed Wand",
category_territory = "",
territory = "Horde",
id = "125",
expansion = "Mists Of Pandaria",
location = "Valley of the Four Winds"
},
id126 = {
source = "Portal Overload",
drop_rate = "quest",
name = "Darklight Torch",
category_territory = "",
territory = "Horde",
id = "126",
expansion = "Cataclysm",
location = "Twilight Highlands"
},
id127 = {
source = "Insurrection",
drop_rate = "quest",
name = "Shackle-Shatter Wand",
category_territory = "",
territory = "Horde",
id = "127",
expansion = "Cataclysm",
location = "Twilight Highlands"
},
id128 = {
source = "Landgrab",
drop_rate = "quest",
name = "Beach-Sweeper Wand",
category_territory = "",
territory = "Horde",
id = "128",
expansion = "Cataclysm",
location = "Twilight Highlands"
},
id129 = {
source = "Stonecore Warbringer",
drop_rate = "0.0",
name = "Wand of Dark Worship",
category_territory = "Dungeon",
territory = "Horde",
id = "129",
expansion = "Cataclysm",
location = "The Stonecore"
},
id130 = {
source = "Temple Adept",
drop_rate = "0.0",
name = "Cyu's Ornate Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "130",
expansion = "Cataclysm",
location = "The Vortex Pinnacle"
},
id131 = {
source = "Amani Elder Lynx",
drop_rate = "0.0",
name = "Blackwolf Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "131",
expansion = "Cataclysm",
location = "Zul'Aman"
},
id132 = {
source = "Fortune and Glory",
drop_rate = "quest",
name = "Harrison's Climbing Hook",
category_territory = "",
territory = "Horde",
id = "132",
expansion = "Cataclysm",
location = "Uldum"
},
id133 = {
source = "Corla, Herald of Twilight",
drop_rate = "0.0",
name = "Corla's Baton",
category_territory = "Dungeon",
territory = "Horde",
id = "133",
expansion = "Cataclysm",
location = "Blackrock Caverns"
},
id134 = {
source = "Lycanthoth Vandal",
drop_rate = "0.0",
name = "Torchlight Wand",
category_territory = "",
territory = "Horde",
id = "134",
expansion = "Cataclysm",
location = "Mount Hyjal"
},
id135 = {
source = "Neferset Venom Keeper",
drop_rate = "0.0",
name = "Nethander Wand",
category_territory = "",
territory = "Horde",
id = "135",
expansion = "Cataclysm",
location = "Uldum"
},
id136 = {
source = "Fetid Ghoul",
drop_rate = "0.0",
name = "Mereldar Wand",
category_territory = "Dungeon",
territory = "Alliance",
id = "136",
expansion = "",
location = "Shadowfang Keep"
},
id137 = {
source = "Tolvir Merchant",
drop_rate = "0.0",
name = "Thondroril Wand",
category_territory = "",
territory = "Horde",
id = "137",
expansion = "Cataclysm",
location = "Uldum"
},
id138 = {
source = "Rock Bottom",
drop_rate = "quest",
name = "Basilisk Eye Wand",
category_territory = "",
territory = "Horde",
id = "138",
expansion = "Cataclysm",
location = "Deepholm"
},
id139 = {
source = "Stonecore Warbringer",
drop_rate = "0.0",
name = "Mirkfallon Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "139",
expansion = "Cataclysm",
location = "The Stonecore"
},
id140 = {
source = "Rotface",
drop_rate = "0.0",
name = "Corpse-Impaling Spike",
category_territory = "Raid",
territory = "Horde",
id = "140",
expansion = "Wrath Of The Lich King",
location = "Icecrown Citadel"
},
id141 = {
source = "Twilight Zealot",
drop_rate = "0.0",
name = "Swamplight Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "141",
expansion = "Cataclysm",
location = "Blackrock Caverns"
},
id142 = {
source = "Maziel",
drop_rate = "0.0",
name = "Sishir Wand",
category_territory = "",
territory = "Horde",
id = "142",
expansion = "Cataclysm",
location = "Deepholm"
},
id143 = {
source = "Twilight Zealot",
drop_rate = "0.0",
name = "Moonbrook Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "143",
expansion = "Cataclysm",
location = "Blackrock Caverns"
},
id144 = {
source = "Disrupting the Rituals",
drop_rate = "quest",
name = "Lordbane Scepter",
category_territory = "",
territory = "Horde",
id = "144",
expansion = "Cataclysm",
location = "Mount Hyjal"
},
id145 = {
source = "Sweeping the Shelf",
drop_rate = "quest",
name = "Goldrinn's Purifier",
category_territory = "",
territory = "Horde",
id = "145",
expansion = "Cataclysm",
location = "Mount Hyjal"
},
id146 = {
source = "Sweeping the Shelf",
drop_rate = "quest",
name = "Rage of Lo'Gosh",
category_territory = "",
territory = "Horde",
id = "146",
expansion = "Cataclysm",
location = "Mount Hyjal"
},
id147 = {
source = "Piece of the Past",
drop_rate = "quest",
name = "Scribe's Quill",
category_territory = "",
territory = "Horde",
id = "147",
expansion = "Cataclysm",
location = "Shimmering Expanse"
},
id148 = {
source = "Piece of the Past",
drop_rate = "quest",
name = "Scribe's Quill",
category_territory = "",
territory = "Horde",
id = "148",
expansion = "Cataclysm",
location = "Shimmering Expanse"
},
id149 = {
source = "Anubarak",
drop_rate = "0.0",
name = "Rod of the Fallen Monarch",
category_territory = "Dungeon",
territory = "Horde",
id = "149",
expansion = "Wrath Of The Lich King",
location = "Azjol-Nerub"
},
id150 = {
source = "Herald Volazj",
drop_rate = "0.0",
name = "Wand of Ahn'kahet",
category_territory = "Dungeon",
territory = "Horde",
id = "150",
expansion = "Wrath Of The Lich King",
location = "Ahn'kahet: The Old Kingdom"
},
id151 = {
source = "KelThuzad",
drop_rate = "0.0",
name = "Wand of the Archlich",
category_territory = "Raid",
territory = "Horde",
id = "151",
expansion = "Wrath Of The Lich King",
location = "Naxxramas"
},
id152 = {
source = "Frenzied Bat",
drop_rate = "0.0",
name = "Contortion",
category_territory = "Raid",
territory = "Horde",
id = "152",
expansion = "Wrath Of The Lich King",
location = "Naxxramas"
},
id153 = {
source = "Gluth",
drop_rate = "0.0",
name = "Gemmed Wand of the Nerubians",
category_territory = "Raid",
territory = "Horde",
id = "153",
expansion = "Wrath Of The Lich King",
location = "Naxxramas"
},
id154 = {
source = "Gluth",
drop_rate = "0.0",
name = "Fading Glow",
category_territory = "Raid",
territory = "Horde",
id = "154",
expansion = "Wrath Of The Lich King",
location = "Naxxramas"
},
id155 = {
source = "Gluth",
drop_rate = "0.0",
name = "Plague Igniter",
category_territory = "Raid",
territory = "Horde",
id = "155",
expansion = "Wrath Of The Lich King",
location = "Naxxramas"
},
id156 = {
source = "Gluth",
drop_rate = "0.0",
name = "Touch of Horror",
category_territory = "Raid",
territory = "Horde",
id = "156",
expansion = "Wrath Of The Lich King",
location = "Naxxramas"
},
id157 = {
source = "Herwin Steampop",
drop_rate = "Unknown",
name = "Deadly Gladiator's Touch of Defeat",
category_territory = "",
territory = "",
id = "157",
expansion = "Wrath Of The Lich King",
location = "Dalaran"
},
id158 = {
source = "Kylo Kelwin",
drop_rate = "Unknown",
name = "Furious Gladiator's Touch of Defeat",
category_territory = "",
territory = "",
id = "158",
expansion = "Wrath Of The Lich King",
location = "Dalaran"
},
id159 = {
source = "Zom Bocom",
drop_rate = "Unknown",
name = "Relentless Gladiator's Touch of Defeat",
category_territory = "",
territory = "",
id = "159",
expansion = "Wrath Of The Lich King",
location = "Dalaran"
},
id160 = {
source = "Herwin Steampop",
drop_rate = "Unknown",
name = "Deadly Gladiator's Baton of Light",
category_territory = "",
territory = "",
id = "160",
expansion = "Wrath Of The Lich King",
location = "Dalaran"
},
id161 = {
source = "Kylo Kelwin",
drop_rate = "Unknown",
name = "Furious Gladiator's Baton of Light",
category_territory = "",
territory = "",
id = "161",
expansion = "Wrath Of The Lich King",
location = "Dalaran"
},
id162 = {
source = "Zom Bocom",
drop_rate = "Unknown",
name = "Relentless Gladiator's Baton of Light",
category_territory = "",
territory = "",
id = "162",
expansion = "Wrath Of The Lich King",
location = "Dalaran"
},
id163 = {
source = "Herwin Steampop",
drop_rate = "Unknown",
name = "Deadly Gladiator's Piercing Touch",
category_territory = "",
territory = "",
id = "163",
expansion = "Wrath Of The Lich King",
location = "Dalaran"
},
id164 = {
source = "Kylo Kelwin",
drop_rate = "Unknown",
name = "Furious Gladiator's Piercing Touch",
category_territory = "",
territory = "",
id = "164",
expansion = "Wrath Of The Lich King",
location = "Dalaran"
},
id165 = {
source = "Zom Bocom",
drop_rate = "Unknown",
name = "Relentless Gladiator's Piercing Touch",
category_territory = "",
territory = "",
id = "165",
expansion = "Wrath Of The Lich King",
location = "Dalaran"
},
id166 = {
source = "Ignis the Furnace Master",
drop_rate = "0.0",
name = "Scepter of Creation",
category_territory = "Raid",
territory = "Horde",
id = "166",
expansion = "Wrath Of The Lich King",
location = "Ulduar"
},
id167 = {
source = "XT-002 Deconstructor",
drop_rate = "0.0",
name = "Quartz Crystal Wand",
category_territory = "Raid",
territory = "Horde",
id = "167",
expansion = "Wrath Of The Lich King",
location = "Ulduar"
},
id168 = {
source = "General Vezax",
drop_rate = "0.0",
name = "Scepter of Lost Souls",
category_territory = "Raid",
territory = "Horde",
id = "168",
expansion = "Wrath Of The Lich King",
location = "Ulduar"
},
id169 = {
source = "Auriaya",
drop_rate = "0.0",
name = "Nurturing Touch",
category_territory = "Raid",
territory = "Horde",
id = "169",
expansion = "Wrath Of The Lich King",
location = "Ulduar"
},
id170 = {
source = "Gormok the Impaler",
drop_rate = "Unknown",
name = "Rod of Imprisoned Souls",
category_territory = "Raid",
territory = "Horde",
id = "170",
expansion = "Wrath Of The Lich King",
location = "Crusaders' Coliseum: Trial of the Crusader"
},
id171 = {
source = "Wanda Chanter",
drop_rate = "Unknown",
name = "Brimstone Igniter",
category_territory = "",
territory = "",
id = "171",
expansion = "Legion",
location = "Dalaran"
},
id172 = {
source = "Gormok the Impaler",
drop_rate = "Unknown",
name = "Scepter of Imprisoned Souls",
category_territory = "Raid",
territory = "Horde",
id = "172",
expansion = "Wrath Of The Lich King",
location = "Crusaders' Coliseum: Trial of the Crusader"
},
id173 = {
source = "Gormok the Impaler",
drop_rate = "Unknown",
name = "Rod of Imprisoned Souls",
category_territory = "Raid",
territory = "Horde",
id = "173",
expansion = "Wrath Of The Lich King",
location = "Crusaders' Coliseum: Trial of the Crusader"
},
id174 = {
source = "Gormok the Impaler",
drop_rate = "Unknown",
name = "Scepter of Imprisoned Souls",
category_territory = "Raid",
territory = "Horde",
id = "174",
expansion = "Wrath Of The Lich King",
location = "Crusaders' Coliseum: Trial of the Crusader"
},
id175 = {
source = "Soulguard Watchman",
drop_rate = "0.0",
name = "Coffin Nail",
category_territory = "Dungeon",
territory = "Horde",
id = "175",
expansion = "Wrath Of The Lich King",
location = "The Forge of Souls"
},
id176 = {
source = "Rotface",
drop_rate = "0.0",
name = "Corpse-Impaling Spike",
category_territory = "Raid",
territory = "Horde",
id = "176",
expansion = "Wrath Of The Lich King",
location = "Icecrown Citadel"
},
id177 = {
source = "Falric",
drop_rate = "0.0",
name = "Soulsplinter",
category_territory = "Dungeon",
territory = "Horde",
id = "177",
expansion = "Wrath Of The Lich King",
location = "Halls of Reflection"
},
id178 = {
source = "Prince Keleseth",
drop_rate = "Unknown",
name = "Wand of Ruby Claret",
category_territory = "Raid",
territory = "Horde",
id = "178",
expansion = "Wrath Of The Lich King",
location = "Icecrown Citadel"
},
id179 = {
source = "Xazi Smolderpipe",
drop_rate = "Unknown",
name = "Wrathful Gladiator's Touch of Defeat",
category_territory = "",
territory = "",
id = "179",
expansion = "Wrath Of The Lich King",
location = "Dalaran"
},
id180 = {
source = "Xazi Smolderpipe",
drop_rate = "Unknown",
name = "Wrathful Gladiator's Wand of Alacrity",
category_territory = "",
territory = "",
id = "180",
expansion = "Wrath Of The Lich King",
location = "Dalaran"
},
id181 = {
source = "Xazi Smolderpipe",
drop_rate = "Unknown",
name = "Wrathful Gladiator's Piercing Touch",
category_territory = "",
territory = "",
id = "181",
expansion = "Wrath Of The Lich King",
location = "Dalaran"
},
id182 = {
source = "Xazi Smolderpipe",
drop_rate = "Unknown",
name = "Wrathful Gladiator's Baton of Light",
category_territory = "",
territory = "",
id = "182",
expansion = "Wrath Of The Lich King",
location = "Dalaran"
},
id183 = {
source = "Blood-Queen Lanathel",
drop_rate = "0.0",
name = "Lana'thel's Bloody Nail",
category_territory = "Raid",
territory = "Horde",
id = "183",
expansion = "Wrath Of The Lich King",
location = "Icecrown Citadel"
},
id184 = {
source = "Blood-Queen Lanathel",
drop_rate = "0.0",
name = "Lana'thel's Bloody Nail",
category_territory = "Raid",
territory = "Horde",
id = "184",
expansion = "Wrath Of The Lich King",
location = "Icecrown Citadel"
},
id185 = {
source = "Prince Keleseth",
drop_rate = "Unknown",
name = "Wand of Ruby Claret",
category_territory = "Raid",
territory = "Horde",
id = "185",
expansion = "Wrath Of The Lich King",
location = "Icecrown Citadel"
},
id186 = {
source = "Ignis the Furnace Master",
drop_rate = "Unknown",
name = "Scepter of Creation",
category_territory = "Raid",
territory = "Horde",
id = "186",
expansion = "Wrath Of The Lich King",
location = "Ulduar"
},
id187 = {
source = "XT-002 Deconstructor",
drop_rate = "Unknown",
name = "Quartz Crystal Wand",
category_territory = "Raid",
territory = "Horde",
id = "187",
expansion = "Wrath Of The Lich King",
location = "Ulduar"
},
id188 = {
source = "General Vezax",
drop_rate = "Unknown",
name = "Scepter of Lost Souls",
category_territory = "Raid",
territory = "Horde",
id = "188",
expansion = "Wrath Of The Lich King",
location = "Ulduar"
},
id189 = {
source = "Auriaya",
drop_rate = "Unknown",
name = "Nurturing Touch",
category_territory = "Raid",
territory = "Horde",
id = "189",
expansion = "Wrath Of The Lich King",
location = "Ulduar"
},
id190 = {
source = "Azure Raider",
drop_rate = "0.0",
name = "Incessant Torch",
category_territory = "Dungeon",
territory = "Horde",
id = "190",
expansion = "Wrath Of The Lich King",
location = "The Violet Hold"
},
id191 = {
source = "Loken",
drop_rate = "0.0",
name = "Ancient Measuring Rod",
category_territory = "Dungeon",
territory = "Horde",
id = "191",
expansion = "Wrath Of The Lich King",
location = "Halls of Lightning"
},
id192 = {
source = "Svala Sorrowgrave",
drop_rate = "0.0",
name = "Brazier Igniter",
category_territory = "Dungeon",
territory = "Horde",
id = "192",
expansion = "Wrath Of The Lich King",
location = "Utgarde Pinnacle"
},
id193 = {
source = "Prince Keleseth",
drop_rate = "0.0",
name = "Wand of the San'layn",
category_territory = "Dungeon",
territory = "Horde",
id = "193",
expansion = "Wrath Of The Lich King",
location = "Utgarde Keep"
},
id194 = {
source = "Sladran",
drop_rate = "0.0",
name = "Wand of Sseratus",
category_territory = "Dungeon",
territory = "Horde",
id = "194",
expansion = "Wrath Of The Lich King",
location = "Gundrak"
},
id195 = {
source = "Geen",
drop_rate = "Unknown",
name = "Shinygem Rod",
category_territory = "",
territory = "Horde",
id = "195",
expansion = "Wrath Of The Lich King",
location = "Sholazar Basin"
},
id196 = {
source = "Veteran Crusader Aliocha Segard",
drop_rate = "Unknown",
name = "Purifying Torch",
category_territory = "",
territory = "Horde",
id = "196",
expansion = "Wrath Of The Lich King",
location = "Icecrown"
},
id197 = {
source = "Svala Sorrowgrave",
drop_rate = "0.0",
name = "Brazier Igniter",
category_territory = "Dungeon",
territory = "Horde",
id = "197",
expansion = "Wrath Of The Lich King",
location = "Utgarde Pinnacle"
},
id198 = {
source = "Sladran",
drop_rate = "0.0",
name = "Wand of Sseratus",
category_territory = "Dungeon",
territory = "Horde",
id = "198",
expansion = "Wrath Of The Lich King",
location = "Gundrak"
},
id199 = {
source = "Herald Volazj",
drop_rate = "0.0",
name = "Wand of Ahn'kahet",
category_territory = "Dungeon",
territory = "Horde",
id = "199",
expansion = "Wrath Of The Lich King",
location = "Ahn'kahet: The Old Kingdom"
},
id200 = {
source = "Trollgore",
drop_rate = "0.0",
name = "Solid Ice Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "200",
expansion = "Wrath Of The Lich King",
location = "Drak'Tharon Keep"
},
id201 = {
source = "Drakkari Shaman",
drop_rate = "0.0",
name = "Mindless Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "201",
expansion = "Wrath Of The Lich King",
location = "Drak'Tharon Keep"
},
id202 = {
source = "Iris Moondreamer",
drop_rate = "Unknown",
name = "Magesoul Wand",
category_territory = "",
territory = "Horde",
id = "202",
expansion = "Cataclysm",
location = "Mount Hyjal"
},
id203 = {
source = "Iris Moondreamer",
drop_rate = "Unknown",
name = "Dreadsoul Wand",
category_territory = "",
territory = "Horde",
id = "203",
expansion = "Cataclysm",
location = "Mount Hyjal"
},
id204 = {
source = "Iris Moondreamer",
drop_rate = "Unknown",
name = "Seraphic Wand",
category_territory = "",
territory = "Horde",
id = "204",
expansion = "Cataclysm",
location = "Mount Hyjal"
},
id205 = {
source = "Svala Sorrowgrave",
drop_rate = "0.0",
name = "Gwyneth's Runed Dragonwand",
category_territory = "Dungeon",
territory = "Horde",
id = "205",
expansion = "Wrath Of The Lich King",
location = "Utgarde Pinnacle"
},
id206 = {
source = "Sirana Iceshriek",
drop_rate = "quest",
name = "Wand of Chilled Renewal",
category_territory = "",
territory = "Horde",
id = "206",
expansion = "Wrath Of The Lich King",
location = "The Storm Peaks"
},
id207 = {
source = "Sirana Iceshriek",
drop_rate = "quest",
name = "Iceshrieker's Touch",
category_territory = "",
territory = "Horde",
id = "207",
expansion = "Wrath Of The Lich King",
location = "The Storm Peaks"
},
id208 = {
source = "No Rest For The Wicked",
drop_rate = "quest",
name = "Encrusted Zombie Finger",
category_territory = "",
territory = "Horde",
id = "208",
expansion = "Wrath Of The Lich King",
location = "Icecrown"
},
id209 = {
source = "No Rest For The Wicked",
drop_rate = "quest",
name = "Touch of Unlife",
category_territory = "",
territory = "Horde",
id = "209",
expansion = "Wrath Of The Lich King",
location = "Icecrown"
},
id210 = {
source = "Alliance Ranger",
drop_rate = "0.0",
name = "Polar Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "210",
expansion = "Wrath Of The Lich King",
location = "The Nexus"
},
id211 = {
source = "Defending The Vanguard",
drop_rate = "quest",
name = "Touch of Light",
category_territory = "",
territory = "Horde",
id = "211",
expansion = "Wrath Of The Lich King",
location = "Icecrown"
},
id212 = {
source = "The Rider of the Unholy",
drop_rate = "quest",
name = "Frail Bone Wand",
category_territory = "",
territory = "Horde",
id = "212",
expansion = "Wrath Of The Lich King",
location = "Icecrown"
},
id213 = {
source = "By Fire Be Purged",
drop_rate = "quest",
name = "Fair Touch of the Crusader",
category_territory = "",
territory = "Horde",
id = "213",
expansion = "Wrath Of The Lich King",
location = "Icecrown"
},
id214 = {
source = "By Fire Be Purged",
drop_rate = "quest",
name = "Olakin's Enchanted Torch",
category_territory = "",
territory = "Horde",
id = "214",
expansion = "Wrath Of The Lich King",
location = "Icecrown"
},
id215 = {
source = "Dalronn the Controller",
drop_rate = "Unknown",
name = "Constructor's Worklight",
category_territory = "Dungeon",
territory = "Horde",
id = "215",
expansion = "Wrath Of The Lich King",
location = "Utgarde Keep"
},
id216 = {
source = "Varos Cloudstrider",
drop_rate = "0.0",
name = "Wasteland Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "216",
expansion = "Wrath Of The Lich King",
location = "The Oculus"
},
id217 = {
source = "Sebastian Crane",
drop_rate = "Unknown",
name = "Charged Wand of the Cleft",
category_territory = "",
territory = "Horde",
id = "217",
expansion = "Wrath Of The Lich King",
location = "Howling Fjord"
},
id218 = {
source = "Logistics Officer Brighton",
drop_rate = "Unknown",
name = "Gnomish Magician's Quill",
category_territory = "",
territory = "Horde",
id = "218",
expansion = "Wrath Of The Lich King",
location = "Howling Fjord"
},
id219 = {
source = "Lavanthor",
drop_rate = "0.0",
name = "Chilled Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "219",
expansion = "Wrath Of The Lich King",
location = "The Violet Hold"
},
id220 = {
source = "Post-partum Aggression",
drop_rate = "quest",
name = "Nesingwary Brush Burner",
category_territory = "",
territory = "Horde",
id = "220",
expansion = "Wrath Of The Lich King",
location = "Sholazar Basin"
},
id221 = {
source = "Unyielding Constrictor",
drop_rate = "0.0",
name = "Ancient Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "221",
expansion = "Wrath Of The Lich King",
location = "Gundrak"
},
id222 = {
source = "Grand Magus Telestra",
drop_rate = "0.0",
name = "Wand of Shimmering Scales",
category_territory = "Dungeon",
territory = "Horde",
id = "222",
expansion = "Wrath Of The Lich King",
location = "The Nexus"
},
id223 = {
source = "Grand Magus Telestra",
drop_rate = "0.0",
name = "Wand of Shimmering Scales",
category_territory = "Dungeon",
territory = "Horde",
id = "223",
expansion = "Wrath Of The Lich King",
location = "The Nexus"
},
id224 = {
source = "Unrelenting Construct",
drop_rate = "0.0",
name = "Voodoo Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "224",
expansion = "Wrath Of The Lich King",
location = "Halls of Stone"
},
id225 = {
source = "Sunblade Dawn Priest",
drop_rate = "0.0",
name = "Wand of the Demonsoul",
category_territory = "Raid",
territory = "Horde",
id = "225",
expansion = "The Burning Crusade",
location = "Sunwell Plateau"
},
id226 = {
source = "Sunblade Dawn Priest",
drop_rate = "0.0",
name = "Wand of Cleansing Light",
category_territory = "Raid",
territory = "Horde",
id = "226",
expansion = "The Burning Crusade",
location = "Sunwell Plateau"
},
id227 = {
source = "Blaze Magmaburn",
drop_rate = "Unknown",
name = "Brutal Gladiator's Baton of Light",
category_territory = "",
territory = "Horde",
id = "227",
expansion = "The Burning Crusade",
location = "Netherstorm"
},
id228 = {
source = "Blaze Magmaburn",
drop_rate = "Unknown",
name = "Brutal Gladiator's Piercing Touch",
category_territory = "",
territory = "Horde",
id = "228",
expansion = "The Burning Crusade",
location = "Netherstorm"
},
id229 = {
source = "Blaze Magmaburn",
drop_rate = "Unknown",
name = "Brutal Gladiator's Touch of Defeat",
category_territory = "",
territory = "Horde",
id = "229",
expansion = "The Burning Crusade",
location = "Netherstorm"
},
id230 = {
source = "Drakkari Guardian",
drop_rate = "0.0",
name = "Enigmatic Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "230",
expansion = "Wrath Of The Lich King",
location = "Drak'Tharon Keep"
},
id231 = {
source = "boss",
drop_rate = "Unknown",
name = "Venture Battle Wand",
category_territory = "",
territory = "Horde",
id = "231",
expansion = "Wrath Of The Lich King",
location = "Grizzly Hills"
},
id232 = {
source = "Skarvald the Constructor",
drop_rate = "0.0",
name = "Melted Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "232",
expansion = "Wrath Of The Lich King",
location = "Utgarde Keep"
},
id233 = {
source = "Kitzie Crankshot",
drop_rate = "Unknown",
name = "Vengeful Gladiator's Touch of Defeat",
category_territory = "",
territory = "Horde",
id = "233",
expansion = "The Burning Crusade",
location = "Netherstorm"
},
id234 = {
source = "Kitzie Crankshot",
drop_rate = "Unknown",
name = "Vengeful Gladiator's Baton of Light",
category_territory = "",
territory = "Horde",
id = "234",
expansion = "The Burning Crusade",
location = "Netherstorm"
},
id235 = {
source = "Kitzie Crankshot",
drop_rate = "Unknown",
name = "Vengeful Gladiator's Piercing Touch",
category_territory = "",
territory = "Horde",
id = "235",
expansion = "The Burning Crusade",
location = "Netherstorm"
},
id236 = {
source = "Mystery of the Infinite",
drop_rate = "quest",
name = "Twig of Happy Reminders",
category_territory = "",
territory = "Horde",
id = "236",
expansion = "Wrath Of The Lich King",
location = "Dragonblight"
},
id237 = {
source = "The Cleansing Of Jinthakalar",
drop_rate = "quest",
name = "Wand of Blinding Light",
category_territory = "",
territory = "Horde",
id = "237",
expansion = "Wrath Of The Lich King",
location = "Dragonblight"
},
id238 = {
source = "The Cleansing Of Jinthakalar",
drop_rate = "quest",
name = "Wand of Purifying Fire",
category_territory = "",
territory = "Horde",
id = "238",
expansion = "Wrath Of The Lich King",
location = "Dragonblight"
},
id239 = {
source = "Gurtogg Bloodboil",
drop_rate = "0.0",
name = "Wand of Prismatic Focus",
category_territory = "Raid",
territory = "Horde",
id = "239",
expansion = "The Burning Crusade",
location = "Black Temple"
},
id240 = {
source = "Essence of Suffering",
drop_rate = "Unknown",
name = "Naaru-Blessed Life Rod",
category_territory = "Raid",
territory = "Horde",
id = "240",
expansion = "The Burning Crusade",
location = "Black Temple"
},
id241 = {
source = "Gurtogg Bloodboil",
drop_rate = "Unknown",
name = "Wand of Prismatic Focus",
category_territory = "Raid",
territory = "Horde",
id = "241",
expansion = "The Burning Crusade",
location = "Black Temple"
},
id242 = {
source = "Essence of Suffering",
drop_rate = "Unknown",
name = "Naaru-Blessed Life Rod",
category_territory = "Raid",
territory = "Horde",
id = "242",
expansion = "The Burning Crusade",
location = "Black Temple"
},
id243 = {
source = "Steward",
drop_rate = "0.0",
name = "Extinguished Spark",
category_territory = "Dungeon",
territory = "Horde",
id = "243",
expansion = "Wrath Of The Lich King",
location = "The Nexus"
},
id244 = {
source = "Trail of Fire",
drop_rate = "quest",
name = "Whelpling-Skull Zapper",
category_territory = "",
territory = "Horde",
id = "244",
expansion = "Wrath Of The Lich King",
location = "Howling Fjord"
},
id245 = {
source = "Trail of Fire",
drop_rate = "quest",
name = "Regal Sceptre",
category_territory = "",
territory = "Horde",
id = "245",
expansion = "Wrath Of The Lich King",
location = "Howling Fjord"
},
id246 = {
source = "Tallhorn Stag",
drop_rate = "0.0",
name = "Vicious Wand",
category_territory = "",
territory = "Horde",
id = "246",
expansion = "Wrath Of The Lich King",
location = "Grizzly Hills"
},
id247 = {
source = "Return My Remains",
drop_rate = "quest",
name = "Branch of Everlasting Flame",
category_territory = "",
territory = "Horde",
id = "247",
expansion = "Wrath Of The Lich King",
location = "Borean Tundra"
},
id248 = {
source = "Springing the Trap",
drop_rate = "quest",
name = "Rod of the Crimson Keeper",
category_territory = "",
territory = "Horde",
id = "248",
expansion = "Wrath Of The Lich King",
location = "Borean Tundra"
},
id249 = {
source = "Seeds of the Blacksouled Keepers",
drop_rate = "quest",
name = "Root of the Everlasting",
category_territory = "",
territory = "Horde",
id = "249",
expansion = "Wrath Of The Lich King",
location = "Howling Fjord"
},
id250 = {
source = "Kezzik the Striker",
drop_rate = "Unknown",
name = "Gladiator's Touch of Defeat",
category_territory = "",
territory = "Horde",
id = "250",
expansion = "The Burning Crusade",
location = "Netherstorm"
},
id251 = {
source = "The Big Bad Wolf",
drop_rate = "Unknown",
name = "Blue Diamond Witchwand",
category_territory = "Raid",
territory = "Horde",
id = "251",
expansion = "The Burning Crusade",
location = "Karazhan"
},
id252 = {
source = "Shade of Aran",
drop_rate = "0",
name = "Tirisfal Wand of Ascendancy",
category_territory = "Raid",
territory = "Horde",
id = "252",
expansion = "The Burning Crusade",
location = "Karazhan"
},
id253 = {
source = "Magtheridon",
drop_rate = "0.0",
name = "Eredar Wand of Obliteration",
category_territory = "Raid",
territory = "Horde",
id = "253",
expansion = "The Burning Crusade",
location = "Magtheridon's Lair"
},
id254 = {
source = "High Astromancer Solarian",
drop_rate = "0.0",
name = "Wand of the Forgotten Star",
category_territory = "Raid",
territory = "Horde",
id = "254",
expansion = "The Burning Crusade",
location = "The Eye"
},
id255 = {
source = "Morogrim Tidewalker",
drop_rate = "0.0",
name = "Luminescent Rod of the Naaru",
category_territory = "Raid",
territory = "Horde",
id = "255",
expansion = "The Burning Crusade",
location = "Serpentshrine Cavern"
},
id256 = {
source = "Izzee the Clutch",
drop_rate = "Unknown",
name = "Merciless Gladiator's Touch of Defeat",
category_territory = "",
territory = "Horde",
id = "256",
expansion = "The Burning Crusade",
location = "Netherstorm"
},
id257 = {
source = "Geras",
drop_rate = "Unknown",
name = "Carved Witch Doctor's Stick",
category_territory = "",
territory = "",
id = "257",
expansion = "The Burning Crusade",
location = "Shattrath City"
},
id258 = {
source = "Warchief Kargath Bladefist",
drop_rate = "0.0",
name = "Nexus Torch",
category_territory = "Dungeon",
territory = "Horde",
id = "258",
expansion = "The Burning Crusade",
location = "The Shattered Halls"
},
id259 = {
source = "Dalliah the Doomsayer",
drop_rate = "0.0",
name = "Nether Core's Control Rod",
category_territory = "Dungeon",
territory = "Horde",
id = "259",
expansion = "The Burning Crusade",
location = "The Arcatraz"
},
id260 = {
source = "Jhonass",
drop_rate = "Unknown",
name = "Cerulean Crystal Rod",
category_territory = "",
territory = "Horde",
id = "260",
expansion = "The Burning Crusade",
location = "Blade's Edge Mountains"
},
id261 = {
source = "Warchief Kargath Bladefist",
drop_rate = "0.0",
name = "Nexus Torch",
category_territory = "Dungeon",
territory = "Horde",
id = "261",
expansion = "The Burning Crusade",
location = "The Shattered Halls"
},
id262 = {
source = "Dalliah the Doomsayer",
drop_rate = "0.0",
name = "Nether Core's Control Rod",
category_territory = "Dungeon",
territory = "Horde",
id = "262",
expansion = "The Burning Crusade",
location = "The Arcatraz"
},
id263 = {
source = "Murmur",
drop_rate = "0.0",
name = "Dragonscale Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "263",
expansion = "The Burning Crusade",
location = "Shadow Labyrinth"
},
id264 = {
source = "Attumen the Huntsman",
drop_rate = "0.0",
name = "Flawless Wand",
category_territory = "Raid",
territory = "Horde",
id = "264",
expansion = "The Burning Crusade",
location = "Karazhan"
},
id265 = {
source = "Dragonflayer Metalworker",
drop_rate = "0.0",
name = "Pearled Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "265",
expansion = "Wrath Of The Lich King",
location = "Utgarde Keep"
},
id266 = {
source = "Scavenge-bot 004-A8",
drop_rate = "0.0",
name = "Darkened Wand",
category_territory = "",
territory = "Horde",
id = "266",
expansion = "Wrath Of The Lich King",
location = "Borean Tundra"
},
id267 = {
source = "Magical Horror",
drop_rate = "0.0",
name = "Draenethyst Wand",
category_territory = "Raid",
territory = "Horde",
id = "267",
expansion = "The Burning Crusade",
location = "Karazhan"
},
id268 = {
source = "Subdue the Subduer",
drop_rate = "quest",
name = "Illidari Rod of Discipline",
category_territory = "",
territory = "Horde",
id = "268",
expansion = "The Burning Crusade",
location = "Shadowmoon Valley"
},
id269 = {
source = "Ambassador Hellmaw",
drop_rate = "0.0",
name = "Soul-Wand of the Aldor",
category_territory = "Dungeon",
territory = "Horde",
id = "269",
expansion = "The Burning Crusade",
location = "Shadow Labyrinth"
},
id270 = {
source = "Blackheart the Inciter",
drop_rate = "0.0",
name = "Wand of the Netherwing",
category_territory = "Dungeon",
territory = "Horde",
id = "270",
expansion = "The Burning Crusade",
location = "Shadow Labyrinth"
},
id271 = {
source = "The Black Stalker",
drop_rate = "0.0",
name = "The Black Stalk",
category_territory = "Dungeon",
territory = "Horde",
id = "271",
expansion = "The Burning Crusade",
location = "The Underbog"
},
id272 = {
source = "Mechano-Lord Capacitus",
drop_rate = "0.0",
name = "Mechano-Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "272",
expansion = "The Burning Crusade",
location = "The Mechanar"
},
id273 = {
source = "When the Cows Come Home",
drop_rate = "quest",
name = "Hotshot Cattle Prod",
category_territory = "",
territory = "Horde",
id = "273",
expansion = "The Burning Crusade",
location = "Netherstorm"
},
id274 = {
source = "Turning the Tide",
drop_rate = "quest",
name = "Nethekurse's Rod of Torment",
category_territory = "Dungeon",
territory = "Horde",
id = "274",
expansion = "The Burning Crusade",
location = "The Shattered Halls"
},
id275 = {
source = "The Will of the Warchief",
drop_rate = "quest",
name = "Rod of Dire Shadows",
category_territory = "Dungeon",
territory = "Horde",
id = "275",
expansion = "The Burning Crusade",
location = "The Shattered Halls"
},
id276 = {
source = "Turning Point",
drop_rate = "quest",
name = "Wand of the Seer",
category_territory = "",
territory = "Horde",
id = "276",
expansion = "The Burning Crusade",
location = "Netherstorm"
},
id277 = {
source = "Terokks Downfall",
drop_rate = "quest",
name = "Jeweled Rod",
category_territory = "",
territory = "Horde",
id = "277",
expansion = "The Burning Crusade",
location = "Terokkar Forest"
},
id278 = {
source = "Ripfang Lynx",
drop_rate = "0.0",
name = "Nobility Torch",
category_territory = "",
territory = "Horde",
id = "278",
expansion = "The Burning Crusade",
location = "Netherstorm"
},
id279 = {
source = "Dealer Jadyan",
drop_rate = "Unknown",
name = "Starheart Baton",
category_territory = "",
territory = "Horde",
id = "279",
expansion = "The Burning Crusade",
location = "Netherstorm"
},
id280 = {
source = "Arkelos the Guardian",
drop_rate = "quest",
name = "Rejuvenating Scepter",
category_territory = "",
territory = "Horde",
id = "280",
expansion = "The Burning Crusade",
location = "Netherstorm"
},
id281 = {
source = "Mark V is Alive!",
drop_rate = "quest",
name = "Unearthed Enkaat Wand",
category_territory = "",
territory = "Horde",
id = "281",
expansion = "The Burning Crusade",
location = "Netherstorm"
},
id282 = {
source = "Durnholde Sentry",
drop_rate = "0.0",
name = "Solitaire Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "282",
expansion = "The Burning Crusade",
location = "Old Hillsbrad Foothills"
},
id283 = {
source = "The Thunderspike",
drop_rate = "quest",
name = "Wand of the Ancestors",
category_territory = "",
territory = "Horde",
id = "283",
expansion = "The Burning Crusade",
location = "Blade's Edge Mountains"
},
id284 = {
source = "The Ultimate Bloodsport",
drop_rate = "quest",
name = "Nesingwary Safari Stick",
category_territory = "",
territory = "Horde",
id = "284",
expansion = "The Burning Crusade",
location = "Nagrand"
},
id285 = {
source = "Ethereal Darkcaster",
drop_rate = "0.0",
name = "Majestic Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "285",
expansion = "The Burning Crusade",
location = "Mana-Tombs"
},
id286 = {
source = "The Den Mother",
drop_rate = "quest",
name = "Arcane Wand of Sylvanaar",
category_territory = "",
territory = "Horde",
id = "286",
expansion = "The Burning Crusade",
location = "Blade's Edge Mountains"
},
id287 = {
source = "Ethereal Sorcerer",
drop_rate = "0.0",
name = "Conjurer's Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "287",
expansion = "The Burning Crusade",
location = "Mana-Tombs"
},
id288 = {
source = "A Personal Favor",
drop_rate = "quest",
name = "Arakkoa Divining Rod",
category_territory = "",
territory = "Horde",
id = "288",
expansion = "The Burning Crusade",
location = "Terokkar Forest"
},
id289 = {
source = "Pandemonius",
drop_rate = "0.0",
name = "Voidfire Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "289",
expansion = "The Burning Crusade",
location = "Mana-Tombs"
},
id290 = {
source = "Pandemonius",
drop_rate = "0.0",
name = "Voidfire Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "290",
expansion = "The Burning Crusade",
location = "Mana-Tombs"
},
id291 = {
source = "Ethereal Priest",
drop_rate = "0.0",
name = "Magician's Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "291",
expansion = "The Burning Crusade",
location = "Mana-Tombs"
},
id292 = {
source = "Veil Rhaze: Unliving Evil",
drop_rate = "quest",
name = "Talonbranch Wand",
category_territory = "",
territory = "Horde",
id = "292",
expansion = "The Burning Crusade",
location = "Terokkar Forest"
},
id293 = {
source = "Ethereal Crypt Raider",
drop_rate = "0.0",
name = "Yew Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "293",
expansion = "The Burning Crusade",
location = "Mana-Tombs"
},
id294 = {
source = "Colossal Menace",
drop_rate = "quest",
name = "Survivalist's Wand",
category_territory = "",
territory = "Horde",
id = "294",
expansion = "The Burning Crusade",
location = "Hellfire Peninsula"
},
id295 = {
source = "Rokmar the Crackler",
drop_rate = "0.0",
name = "Calming Spore Reed",
category_territory = "Dungeon",
territory = "Horde",
id = "295",
expansion = "The Burning Crusade",
location = "The Slave Pens"
},
id296 = {
source = "Horde Field Scout",
drop_rate = "Unknown",
name = "Incendic Rod",
category_territory = "",
territory = "Horde",
id = "296",
expansion = "The Burning Crusade",
location = "Zangarmarsh"
},
id297 = {
source = "Alliance Field Scout",
drop_rate = "Unknown",
name = "Incendic Rod",
category_territory = "",
territory = "Horde",
id = "297",
expansion = "The Burning Crusade",
location = "Zangarmarsh"
},
id298 = {
source = "Mycah",
drop_rate = "Unknown",
name = "Sporeling's Firestick",
category_territory = "",
territory = "Horde",
id = "298",
expansion = "The Burning Crusade",
location = "Zangarmarsh"
},
id299 = {
source = "Rokmar the Crackler",
drop_rate = "0.0",
name = "Calming Spore Reed",
category_territory = "Dungeon",
territory = "Horde",
id = "299",
expansion = "The Burning Crusade",
location = "The Slave Pens"
},
id300 = {
source = "Kaliri Swooper",
drop_rate = "0.0",
name = "Purpleheart Wand",
category_territory = "",
territory = "Horde",
id = "300",
expansion = "The Burning Crusade",
location = "Hellfire Peninsula"
},
id301 = {
source = "Bonechewer Hungerer",
drop_rate = "0.0",
name = "Crystallized Ebony Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "301",
expansion = "The Burning Crusade",
location = "Hellfire Ramparts"
},
id302 = {
source = "Shattered Hand Warhound",
drop_rate = "0.0",
name = "Mahogany Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "302",
expansion = "The Burning Crusade",
location = "Hellfire Ramparts"
},
id303 = {
source = "Bonechewer Blood",
drop_rate = "quest",
name = "Desolation Rod",
category_territory = "",
territory = "Horde",
id = "303",
expansion = "The Burning Crusade",
location = "Hellfire Peninsula"
},
id304 = {
source = "Shazzrah",
drop_rate = "0.0",
name = "Crimson Shocker",
category_territory = "Raid",
territory = "Horde",
id = "304",
expansion = "",
location = "Molten Core"
},
id305 = {
source = "Flamegor",
drop_rate = "0.0",
name = "Dragon's Touch",
category_territory = "Raid",
territory = "Horde",
id = "305",
expansion = "",
location = "Blackwing Lair"
},
id306 = {
source = "Blackwing Warlock",
drop_rate = "0.0",
name = "Essence Gatherer",
category_territory = "Raid",
territory = "Horde",
id = "306",
expansion = "",
location = "Blackwing Lair"
},
id307 = {
source = "Princess Yauj",
drop_rate = "Unknown",
name = "Wand of Qiraji Nobility",
category_territory = "Raid",
territory = "Horde",
id = "307",
expansion = "",
location = "Temple of Ahn'Qiraj"
},
id308 = {
source = "Azuregos",
drop_rate = "0.0",
name = "Cold Snap",
category_territory = "",
territory = "Alliance",
id = "308",
expansion = "",
location = "Azshara"
},
id309 = {
source = "HiveZara Wasp",
drop_rate = "0.0",
name = "Antenna of Invigoration",
category_territory = "Raid",
territory = "Horde",
id = "309",
expansion = "",
location = "Ruins of Ahn'Qiraj"
},
id310 = {
source = "Blackwing Technician",
drop_rate = "0.0",
name = "Dragon Finger",
category_territory = "Raid",
territory = "Horde",
id = "310",
expansion = "",
location = "Blackwing Lair"
},
id311 = {
source = "Nefarian",
drop_rate = "0.0",
name = "Lunar Wand",
category_territory = "Raid",
territory = "Horde",
id = "311",
expansion = "",
location = "Blackwing Lair"
},
id312 = {
source = "Thinning the Ranks",
drop_rate = "quest",
name = "Dark Augur's Wand",
category_territory = "",
territory = "Horde",
id = "312",
expansion = "The Burning Crusade",
location = "Terokkar Forest"
},
id313 = {
source = "Skarr the Broken",
drop_rate = "0.0",
name = "Torch of Austen",
category_territory = "",
territory = "Horde",
id = "313",
expansion = "",
location = "Feralas"
},
id314 = {
source = "Spire Spiderling",
drop_rate = "0.0",
name = "Glowstar Rod",
category_territory = "Dungeon",
territory = "Horde",
id = "314",
expansion = "",
location = "Blackrock Spire"
},
id315 = {
source = "Shade of Eranikus",
drop_rate = "0.0",
name = "Rod of Corrosion",
category_territory = "Dungeon",
territory = "Horde",
id = "315",
expansion = "",
location = "Sunken Temple"
},
id316 = {
source = "Skul",
drop_rate = "0.0",
name = "Skul's Ghastly Touch",
category_territory = "Dungeon",
territory = "Horde",
id = "316",
expansion = "",
location = "Stratholme"
},
id317 = {
source = "Baroness Anastari",
drop_rate = "0.0",
name = "Banshee Finger",
category_territory = "Dungeon",
territory = "Horde",
id = "317",
expansion = "",
location = "Stratholme"
},
id318 = {
source = "Lord Aurius Rivendare",
drop_rate = "0.0",
name = "Ritssyn's Wand of Bad Mojo",
category_territory = "Dungeon",
territory = "Horde",
id = "318",
expansion = "",
location = "Stratholme"
},
id319 = {
source = "Dark Keeper Vorfalk",
drop_rate = "0.0",
name = "Wizard's Hand",
category_territory = "Dungeon",
territory = "Horde",
id = "319",
expansion = "",
location = "Blackrock Depths"
},
id320 = {
source = "Marshals Refuse",
drop_rate = "quest",
name = "Doreen's Wand",
category_territory = "",
territory = "Horde",
id = "320",
expansion = "",
location = "Un'Goro Crater"
},
id321 = {
source = "Pyromancer Loregrain",
drop_rate = "0.0",
name = "Pyric Caduceus",
category_territory = "Dungeon",
territory = "Horde",
id = "321",
expansion = "",
location = "Blackrock Depths"
},
id322 = {
source = "Eviscerator",
drop_rate = "0.0",
name = "Ivory Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "322",
expansion = "",
location = "Blackrock Depths"
},
id323 = {
source = "Ice Thistle Yeti",
drop_rate = "0.0",
name = "Wand of Allistarj",
category_territory = "",
territory = "Horde",
id = "323",
expansion = "",
location = "Winterspring"
},
id324 = {
source = "High Chief Winterfall",
drop_rate = "quest",
name = "Wand of Sudden Changes",
category_territory = "",
territory = "Horde",
id = "324",
expansion = "",
location = "Winterspring"
},
id325 = {
source = "Sandarr Dunereaver",
drop_rate = "0.0",
name = "Flaming Incinerator",
category_territory = "Dungeon",
territory = "Horde",
id = "325",
expansion = "",
location = "Zul'Farrak"
},
id326 = {
source = "ChoRush the Observer",
drop_rate = "0.0",
name = "Mana Channeling Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "326",
expansion = "",
location = "Dire Maul"
},
id327 = {
source = "Rise, Obsidion",
drop_rate = "quest",
name = "Sootsmoke Wand",
category_territory = "",
territory = "Horde",
id = "327",
expansion = "",
location = "Searing Gorge"
},
id328 = {
source = "See the Invisible",
drop_rate = "quest",
name = "Impsy's Wand",
category_territory = "",
territory = "Horde",
id = "328",
expansion = "",
location = "Felwood"
},
id329 = {
source = "Gelatanized Plague Gunk",
drop_rate = "0.0",
name = "Freezing Shard",
category_territory = "Dungeon",
territory = "Horde",
id = "329",
expansion = "",
location = "Razorfen Downs"
},
id330 = {
source = "Death Speaker Blackthorn",
drop_rate = "0.0",
name = "Plaguerot Sprig",
category_territory = "Dungeon",
territory = "Horde",
id = "330",
expansion = "",
location = "Razorfen Downs"
},
id331 = {
source = "Mana Remnant",
drop_rate = "0.0",
name = "Wand of Arcane Potency",
category_territory = "Dungeon",
territory = "Horde",
id = "331",
expansion = "",
location = "Dire Maul"
},
id332 = {
source = "The Unforgiven",
drop_rate = "0.0",
name = "Umbral Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "332",
expansion = "",
location = "Stratholme"
},
id333 = {
source = "Rattlegore",
drop_rate = "0.0",
name = "Necromantic Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "333",
expansion = "Mists Of Pandaria",
location = "Scholomance"
},
id334 = {
source = "Southsea Pirate",
drop_rate = "0.0",
name = "Jaina's Firestarter",
category_territory = "",
territory = "Horde",
id = "334",
expansion = "",
location = "Tanaris"
},
id335 = {
source = "Lethtendris",
drop_rate = "0.0",
name = "Lethtendris' Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "335",
expansion = "",
location = "Dire Maul"
},
id336 = {
source = "Ancient Stone Keeper",
drop_rate = "0.0",
name = "Ember Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "336",
expansion = "",
location = "Uldaman"
},
id337 = {
source = "Stonevault Cave Lurker",
drop_rate = "0.0",
name = "Earthen Rod",
category_territory = "Dungeon",
territory = "Horde",
id = "337",
expansion = "",
location = "Uldaman"
},
id338 = {
source = "Noxxion",
drop_rate = "0.0",
name = "Noxious Shooter",
category_territory = "Dungeon",
territory = "Horde",
id = "338",
expansion = "",
location = "Maraudon"
},
id339 = {
source = "Questioning Reethe",
drop_rate = "quest",
name = "Eyepoker",
category_territory = "",
territory = "Horde",
id = "339",
expansion = "",
location = "Dustwallow Marsh"
},
id340 = {
source = "Baelog",
drop_rate = "0.0",
name = "Scorching Wand",
category_territory = "Dungeon",
territory = "Horde",
id = "340",
expansion = "",
location = "Uldaman"
},
id341 = {
source = "Enchanter Nalthanis",
drop_rate = "Unknown",
name = "Greater Mystic Wand",
category_territory = "",
territory = "",
id = "341",
expansion = "Legion",
location = "Dalaran"
},
id342 = {
source = "Enormous Bullfrog",
drop_rate = "0.0",
name = "Starfaller",
category_territory = "Dungeon",
territory = "Alliance",
id = "342",
expansion = "",
location = "Razorfen Kraul"
},
id343 = {
source = "Drive-By Piracy",
drop_rate = "quest",
name = "Venture Blaster",
category_territory = "",
territory = "Horde",
id = "343",
expansion = "",
location = "The Cape of Stranglethorn"
},
id344 = {
source = "Scarlet Fanatic",
drop_rate = "0.0",
name = "Wand of Eventide",
category_territory = "Dungeon",
territory = "Horde",
id = "344",
expansion = "Mists Of Pandaria",
location = "Scarlet Monastery"
},
id345 = {
source = "Siegebreaker",
drop_rate = "quest",
name = "Groady Goblin Wand",
category_territory = "",
territory = "Horde",
id = "345",
expansion = "",
location = "Southern Barrens"
},
id346 = {
source = "Marching On Our Stomachs",
drop_rate = "quest",
name = "Pot Stirrer",
category_territory = "",
territory = "Horde",
id = "346",
expansion = "",
location = "Southern Barrens"
},
id347 = {
source = "Prime Slime",
drop_rate = "quest",
name = "Wand of Oomph",
category_territory = "",
territory = "Horde",
id = "347",
expansion = "",
location = "The Hinterlands"
},
id348 = {
source = "Prime Slime",
drop_rate = "quest",
name = "Research Assistant's Wand",
category_territory = "",
territory = "Horde",
id = "348",
expansion = "",
location = "The Hinterlands"
},
id349 = {
source = "Mechanized Guardian",
drop_rate = "0.0",
name = "Gyromatic Icemaker",
category_territory = "Dungeon",
territory = "War Zone",
id = "349",
expansion = "",
location = "Gnomeregan"
},
id350 = {
source = "Enchanter Nalthanis",
drop_rate = "Unknown",
name = "Lesser Mystic Wand",
category_territory = "",
territory = "",
id = "350",
expansion = "Legion",
location = "Dalaran"
},
id351 = {
source = "To Battlescar!",
drop_rate = "quest",
name = "Wand of Destructive Talent",
category_territory = "",
territory = "Horde",
id = "351",
expansion = "",
location = "Stonetalon Mountains"
},
id352 = {
source = "Dark Iron Ambassador",
drop_rate = "0.0",
name = "Firestarter",
category_territory = "Dungeon",
territory = "War Zone",
id = "352",
expansion = "",
location = "Gnomeregan"
},
id353 = {
source = "Saving Yenniku",
drop_rate = "quest",
name = "Stone Etcher",
category_territory = "",
territory = "Horde",
id = "353",
expansion = "",
location = "Northern Stranglethorn"
},
id354 = {
source = "The Minds Eye",
drop_rate = "quest",
name = "Wand of Imagination",
category_territory = "",
territory = "Horde",
id = "354",
expansion = "",
location = "Northern Stranglethorn"
},
id355 = {
source = "Leprous Assistant",
drop_rate = "0.0",
name = "Thunderwood",
category_territory = "Dungeon",
territory = "War Zone",
id = "355",
expansion = "",
location = "Gnomeregan"
},
id356 = {
source = "Stormpike Engineer",
drop_rate = "0.0",
name = "Dire Wand",
category_territory = "",
territory = "Alliance",
id = "356",
expansion = "",
location = "Hillsbrad Foothills"
},
id357 = {
source = "Commandeer That Balloon!",
drop_rate = "quest",
name = "Wand of Bought Time",
category_territory = "",
territory = "Horde",
id = "357",
expansion = "",
location = "Stonetalon Mountains"
},
id358 = {
source = "The Stolen Letters",
drop_rate = "quest",
name = "Archivist's Lighter",
category_territory = "",
territory = "War Zone",
id = "358",
expansion = "",
location = "Duskwood"
},
id359 = {
source = "Rolands Doom",
drop_rate = "quest",
name = "Exorcist's Wand",
category_territory = "",
territory = "War Zone",
id = "359",
expansion = "",
location = "Duskwood"
},
id360 = {
source = "Rain of Destruction",
drop_rate = "quest",
name = "Durak's Wand",
category_territory = "",
territory = "Horde",
id = "360",
expansion = "",
location = "Ashenvale"
},
id361 = {
source = "Deviate Faerie Dragon",
drop_rate = "0.0",
name = "Firebelcher",
category_territory = "Dungeon",
territory = "Alliance",
id = "361",
expansion = "",
location = "Wailing Caverns"
},
id362 = {
source = "Rumbling Earth",
drop_rate = "0.0",
name = "Skycaller",
category_territory = "Dungeon",
territory = "War Zone",
id = "362",
expansion = "",
location = "The Stockade"
},
id363 = {
source = "Assault on Menethil Keep",
drop_rate = "quest",
name = "Wand of Infectious Dementia",
category_territory = "",
territory = "War Zone",
id = "363",
expansion = "",
location = "Wetlands"
},
id364 = {
source = "boss",
drop_rate = "Unknown",
name = "Cookie's Stirring Rod",
category_territory = "Dungeon",
territory = "War Zone",
id = "364",
expansion = "",
location = "The Deadmines"
},
id365 = {
source = "The Conquest of Azshara",
drop_rate = "quest",
name = "Wind Rider Wand",
category_territory = "",
territory = "Alliance",
id = "365",
expansion = "",
location = "Azshara"
},
id366 = {
source = "Counterattack!",
drop_rate = "quest",
name = "Suppressor's Wand",
category_territory = "",
territory = "Alliance",
id = "366",
expansion = "",
location = "Northern Barrens"
},
id367 = {
source = "Skum",
drop_rate = "0.0",
name = "Opaque Wand",
category_territory = "Dungeon",
territory = "Alliance",
id = "367",
expansion = "",
location = "Wailing Caverns"
},
id368 = {
source = "DarKhans Lieutenants",
drop_rate = "quest",
name = "Ley-Keeper's Wand",
category_territory = "",
territory = "Alliance",
id = "368",
expansion = "",
location = "Ghostlands"
},
id369 = {
source = "Lawn of the Dead",
drop_rate = "quest",
name = "Brazie's Plant Light",
category_territory = "",
territory = "Alliance",
id = "369",
expansion = "",
location = "Hillsbrad Foothills"
},
id370 = {
source = "The Defiler",
drop_rate = "quest",
name = "Blackwood Ritual Stick",
category_territory = "",
territory = "War Zone",
id = "370",
expansion = "",
location = "Darkshore"
},
id371 = {
source = "Guron Twaintail",
drop_rate = "Unknown",
name = "Greater Magic Wand",
category_territory = "",
territory = "Horde",
id = "371",
expansion = "Legion",
location = "Thunder Totem"
},
id372 = {
source = "The Defias Kingpin",
drop_rate = "quest",
name = "Cookie's Stirring Stick",
category_territory = "Dungeon",
territory = "War Zone",
id = "372",
expansion = "",
location = "The Deadmines"
},
id373 = {
source = "The Defias Kingpin",
drop_rate = "quest",
name = "Cookie's Stirring Stick",
category_territory = "Dungeon",
territory = "War Zone",
id = "373",
expansion = "",
location = "The Deadmines"
},
id374 = {
source = "Hill Grizzly",
drop_rate = "0.0",
name = "Blazing Wand",
category_territory = "",
territory = "War Zone",
id = "374",
expansion = "",
location = "Loch Modan"
},
id375 = {
source = "Containing the Threat",
drop_rate = "quest",
name = "Lightspark",
category_territory = "",
territory = "War Zone",
id = "375",
expansion = "",
location = "Bloodmyst Isle"
},
id376 = {
source = "Adarogg",
drop_rate = "0.0",
name = "Shadow Wand",
category_territory = "Dungeon",
territory = "Alliance",
id = "376",
expansion = "",
location = "Ragefire Chasm"
},
id377 = {
source = "Windrunner Village",
drop_rate = "quest",
name = "Arcanist's Wand",
category_territory = "",
territory = "Alliance",
id = "377",
expansion = "",
location = "Ghostlands"
},
id378 = {
source = "Strategic Strikes",
drop_rate = "quest",
name = "Dryad's Wand",
category_territory = "",
territory = "War Zone",
id = "378",
expansion = "",
location = "Darkshore"
},
id379 = {
source = "Jango Spothide",
drop_rate = "quest",
name = "Mystic Riverpaw Wand",
category_territory = "",
territory = "War Zone",
id = "379",
expansion = "",
location = "Westfall"
},
id380 = {
source = "Slagmaw",
drop_rate = "0.0",
name = "Fire Wand",
category_territory = "Dungeon",
territory = "Alliance",
id = "380",
expansion = "",
location = "Ragefire Chasm"
},
id381 = {
source = "Heartfelt Appreciation",
drop_rate = "quest",
name = "Star Shooter",
category_territory = "",
territory = "War Zone",
id = "381",
expansion = "",
location = "Loch Modan"
},
id382 = {
source = "The Tortusk Takedown",
drop_rate = "quest",
name = "Wand of Separation",
category_territory = "",
territory = "Alliance",
id = "382",
expansion = "",
location = "Northern Barrens"
},
id383 = {
source = "Guron Twaintail",
drop_rate = "Unknown",
name = "Lesser Magic Wand",
category_territory = "",
territory = "Horde",
id = "383",
expansion = "Legion",
location = "Thunder Totem"
},
id384 = {
source = "The Eyes of Ashenvale",
drop_rate = "quest",
name = "Hill's Eye Wand",
category_territory = "",
territory = "Alliance",
id = "384",
expansion = "",
location = "Azshara"
}
} | 22.840083 | 57 | 0.615276 |
9c4b837cec877dfeb1b839345c89a9ee891270f8 | 294 | js | JavaScript | icons/hololens.js | darosh/material-icons-bundle | 3dd1cc534b011fc4fe78e9d71ef919a62096033f | [
"MIT"
] | 11 | 2017-11-02T18:14:44.000Z | 2022-02-08T07:22:44.000Z | icons/hololens.js | darosh/material-icons-bundle | 3dd1cc534b011fc4fe78e9d71ef919a62096033f | [
"MIT"
] | 1 | 2021-03-02T15:17:09.000Z | 2021-03-02T15:17:09.000Z | icons/hololens.js | darosh/material-icons-bundle | 3dd1cc534b011fc4fe78e9d71ef919a62096033f | [
"MIT"
] | 1 | 2020-03-12T10:40:22.000Z | 2020-03-12T10:40:22.000Z | export default "M12,8C12,8 22,8 22,11C22,11 22.09,14.36 21.75,14.25C21,11 12,11 12,11C12,11 3,11 2.25,14.25C1.91,14.36 2,11 2,11C2,8 12,8 12,8M12,12C20,12 20.75,14.25 20.75,14.25C19.75,17.25 19,18 15,18C12,18 13,16.5 12,16.5C11,16.5 12,18 9,18C5,18 4.25,17.25 3.25,14.25C3.25,14.25 4,12 12,12Z" | 294 | 294 | 0.697279 |
e8a84a73c5e894e083294de43e0dc56668006aec | 1,034 | kts | Kotlin | exposition/build.gradle.kts | jeanbisutti/TripAgency | 2d8d6ff95a847d56d5d05fd5d4757de8f7164629 | [
"MIT"
] | null | null | null | exposition/build.gradle.kts | jeanbisutti/TripAgency | 2d8d6ff95a847d56d5d05fd5d4757de8f7164629 | [
"MIT"
] | null | null | null | exposition/build.gradle.kts | jeanbisutti/TripAgency | 2d8d6ff95a847d56d5d05fd5d4757de8f7164629 | [
"MIT"
] | null | null | null | dependencies {
implementation(project(":domain"))
implementation(project(":repository"))
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.liquibase:liquibase-core")
implementation("javax.xml.bind:jaxb-api")
implementation("io.springfox:springfox-boot-starter")
runtimeOnly("org.springframework.boot:spring-boot-devtools")
runtimeOnly("org.postgresql:postgresql")
testImplementation("org.assertj:assertj-core")
testImplementation("com.h2database:h2")
testImplementation("io.rest-assured:rest-assured")
testImplementation("org.assertj:assertj-core")
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.boot:spring-boot-test")
testImplementation("org.springframework:spring-test")
testImplementation("org.mockito:mockito-junit-jupiter")
} | 44.956522 | 75 | 0.767892 |
fb0c4cca919eb5e0a5d037d8fc6471927a7f6539 | 1,390 | dart | Dart | Section 4/4.3/4.3 - Stateless Widgets Part 1/lib/main.dart | PacktPublishing/Dart-2-in-7-Days | 917111f84cdc8059459812a968945b1917697343 | [
"MIT"
] | 5 | 2019-03-20T18:54:38.000Z | 2021-10-02T03:19:58.000Z | Section 4/4.3/4.3 - Stateless Widgets Part 1/lib/main.dart | 2733284198/Dart-2-in-7-Days | 83115c68a1241afcfc91cabd786859f81a6f1bd5 | [
"MIT"
] | null | null | null | Section 4/4.3/4.3 - Stateless Widgets Part 1/lib/main.dart | 2733284198/Dart-2-in-7-Days | 83115c68a1241afcfc91cabd786859f81a6f1bd5 | [
"MIT"
] | 4 | 2018-10-04T01:59:44.000Z | 2020-10-07T10:23:18.000Z | import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main(){
runApp(
new MaterialApp(
home: new HomeScreen(),
debugShowCheckedModeBanner: false,
)
);
}
class HomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light.copyWith(
statusBarIconBrightness: Brightness.light
));
return Scaffold(
body: Stack(
children: <Widget>[
new Image.asset(
'images/background.jpg',
fit: BoxFit.cover,
height: double.infinity,
width: double.infinity,
alignment: Alignment.center,
),
Container(
alignment: Alignment.topCenter,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(padding: EdgeInsets.all(15.0),),
Text(
"Teacher's \n Corner",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 36.0, fontWeight: FontWeight.w500,
fontFamily: 'Chalkduster',
color: Colors.green)),
],
),
)
],
),
);
}
}
| 18.051948 | 77 | 0.523022 |
ce162b1b7ed434c3ede867aaa093462c88538685 | 3,791 | lua | Lua | 2020/02_PasswordPhilosophy/passwords.lua | deanearlwright/AdventOfCode | ca4cf6315c0efa38bd7748fb6f4bc99e7934871d | [
"MIT"
] | 1 | 2021-01-03T23:09:28.000Z | 2021-01-03T23:09:28.000Z | 2020/02_PasswordPhilosophy/passwords.lua | deanearlwright/AdventOfCode | ca4cf6315c0efa38bd7748fb6f4bc99e7934871d | [
"MIT"
] | 6 | 2020-12-26T21:02:42.000Z | 2020-12-26T21:02:52.000Z | 2020/02_PasswordPhilosophy/passwords.lua | deanearlwright/AdventOfCode | ca4cf6315c0efa38bd7748fb6f4bc99e7934871d | [
"MIT"
] | null | null | null | -- ======================================================================
-- Password Philosophy
-- Advent of Code 2020 Day 02 -- Eric Wastl -- https://adventofcode.com
--
-- lua implementation by Dr. Dean Earl Wright III
-- ======================================================================
-- ======================================================================
-- p a s s w o r d s . l u a
-- ======================================================================
-- "A solver for the Advent of Code 2020 Day 02 puzzle"
-- ----------------------------------------------------------------------
-- require
-- ----------------------------------------------------------------------
policy = require('policy')
-- ----------------------------------------------------------------------
-- local
-- ----------------------------------------------------------------------
local Passwords = { part2 = false, text = {} }
-- ----------------------------------------------------------------------
-- constants
-- ----------------------------------------------------------------------
-- ======================================================================
-- Passwords
-- ======================================================================
-- "Object for Password Philosophy"
function Passwords:Passwords (o)
-- 1. Set the initial values
o = o or {}
o.part2 = o.part2 or false
o.text = o.text or {}
-- 2. Create the object metatable
self.__index = self
setmetatable(o, self)
-- 3. Process text (if any)
o.policies = {}
if o.text ~= nil and #o.text > 0 then
o:_process_text(o.text)
end
return o
end
function Passwords:_process_text(text)
-- "Assign values from text
-- 0. Precondition axioms
assert(text ~= nil and #text > 0)
-- 1. Loop for each line of the text
for _, line in ipairs(text) do
-- 2. Create a policy from that line and add it
table.insert(self.policies, policy:Policy({part2=self.part2, text=line}))
end
end
function Passwords:count_valid()
-- 1. Start with nothing
result = 0
-- 2. Loop for all of the password policies
for _, pol in ipairs(self.policies) do
-- 3. Does this policy have a valid password?
valid = pol:check_password()
-- 4. If so, increment the cound
if valid then
result = result + 1
end
end
-- 5. Return the cound of valid passwords
return result
end
function Passwords:part_one(args)
-- "Returns the solution for part one"
-- 0. Precondition axioms
local verbose = args.verbose or false
local limit = args.limit or 0
assert(verbose == true or verbose == false)
assert(limit >= 0)
-- 1. Return the solution for part one
return self:count_valid()
end
function Passwords:part_two(args)
-- "Returns the solution for part two"
-- 0. Precondition axioms
local verbose = args.verbose or false
local limit = args.limit or 0
assert(verbose == true or verbose == false)
assert(limit >= 0)
-- 1. Return the solution for part one
return self:count_valid()
end
-- ----------------------------------------------------------------------
-- module initialization
-- ----------------------------------------------------------------------
return Passwords
-- ======================================================================
-- end p a s s w o r d s . l u a end
-- ======================================================================
| 30.572581 | 77 | 0.391717 |
93ca24223b46562140176422ab92ba236153de1b | 2,470 | dart | Dart | clean_code_base/lib/features/number_trivia/repositories/number_trivia_repository_Impl.dart | dev4vin/numbers_dictionary | 82c1d7c1cec5ca0288a5ec2067a1c90e415038c0 | [
"Apache-2.0"
] | 1 | 2020-09-02T04:44:34.000Z | 2020-09-02T04:44:34.000Z | clean_code_base/lib/features/number_trivia/repositories/number_trivia_repository_Impl.dart | dev4vin/numbers_dictionary | 82c1d7c1cec5ca0288a5ec2067a1c90e415038c0 | [
"Apache-2.0"
] | null | null | null | clean_code_base/lib/features/number_trivia/repositories/number_trivia_repository_Impl.dart | dev4vin/numbers_dictionary | 82c1d7c1cec5ca0288a5ec2067a1c90e415038c0 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2020 Peter Vincent
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import 'package:clean_code_base/core/errors/exceptions.dart';
import 'package:clean_code_base/core/network/network_info.dart';
import 'package:clean_code_base/features/number_trivia/datasources/number_trivia_local_data_source.dart';
import 'package:clean_code_base/features/number_trivia/datasources/number_trivia_remote_data_source.dart';
import 'package:clean_code_models/core/errors/failure.dart';
import 'package:clean_code_models/number_trivia.dart';
import 'package:clean_code_models/repositories/number_trivia_repository.dart';
import 'package:dartz/dartz.dart';
import 'package:meta/meta.dart';
class NumberTriviaRepositoryImpl implements NumberTriviaRepository {
final NumberTriviaLocalDataSource localDataSource;
final NumberTriviaRemoteDataSource remoteDataSource;
final NetworkInfo networkInfo;
NumberTriviaRepositoryImpl(
{@required this.localDataSource,
@required this.remoteDataSource,
@required this.networkInfo});
@override
Future<Either<Failure, NumberTrivia>> getConcreteNumberTrivia(
int number,
) async =>
_getTrivia(() => remoteDataSource.getConcreteNumberTrivia(number));
@override
Future<Either<Failure, NumberTrivia>> getRandomNumberTrivia() async =>
_getTrivia(() => remoteDataSource.getRandomNumberTrivia());
Future<Either<Failure, NumberTrivia>> _getTrivia(
Future<NumberTrivia> getConcreteOrRandom()) async {
if (await networkInfo.isConnected) {
try {
final result = await getConcreteOrRandom();
localDataSource.cacheNumberTrivia(result);
return Right(result);
} on ServerException {
return Left(ServerFailure());
}
} else {
try {
final trivia = await localDataSource.getLastNumberTrivia();
return Right(trivia);
} on CacheException {
return Left(CacheFailure());
}
}
}
}
| 36.865672 | 106 | 0.748583 |
0c7f6731f5646673b86f750e904ab2bac091382a | 45,064 | html | HTML | docs/.vuepress/dist/articles/frontend/css.html | sanyaojiuchan/vuepress-blog | 7603531639c0fa17892097e13641ae96f475fed0 | [
"MIT"
] | null | null | null | docs/.vuepress/dist/articles/frontend/css.html | sanyaojiuchan/vuepress-blog | 7603531639c0fa17892097e13641ae96f475fed0 | [
"MIT"
] | 4 | 2021-03-01T21:22:09.000Z | 2022-02-19T05:14:36.000Z | docs/.vuepress/dist/articles/frontend/css.html | sanyaojiuchan/vuepress-blog | 7603531639c0fa17892097e13641ae96f475fed0 | [
"MIT"
] | null | null | null | <!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>CSS3查漏补缺 | 王负剑的博客</title>
<meta name="generator" content="VuePress 1.5.2">
<link rel="icon" href="/4.jpg">
<meta name="description" content="不要在该奋斗的年纪选择安逸,在这记录了我成长的脚步">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
<link rel="preload" href="/assets/css/0.styles.8908b199.css" as="style"><link rel="preload" href="/assets/js/app.800ef70b.js" as="script"><link rel="preload" href="/assets/js/4.7602e631.js" as="script"><link rel="preload" href="/assets/js/1.7dbd71d8.js" as="script"><link rel="preload" href="/assets/js/22.ae97a39f.js" as="script"><link rel="prefetch" href="/assets/js/10.fd81d254.js"><link rel="prefetch" href="/assets/js/11.c94debb9.js"><link rel="prefetch" href="/assets/js/12.43f7f7d0.js"><link rel="prefetch" href="/assets/js/13.ce7becb4.js"><link rel="prefetch" href="/assets/js/14.d17f14f8.js"><link rel="prefetch" href="/assets/js/15.b41090d3.js"><link rel="prefetch" href="/assets/js/16.5c793ede.js"><link rel="prefetch" href="/assets/js/17.aa5a6bc5.js"><link rel="prefetch" href="/assets/js/18.fb67359c.js"><link rel="prefetch" href="/assets/js/19.909a082c.js"><link rel="prefetch" href="/assets/js/20.a84cf911.js"><link rel="prefetch" href="/assets/js/21.9a044c59.js"><link rel="prefetch" href="/assets/js/23.144ab08c.js"><link rel="prefetch" href="/assets/js/24.6a707500.js"><link rel="prefetch" href="/assets/js/25.33b5f899.js"><link rel="prefetch" href="/assets/js/26.b398b6d5.js"><link rel="prefetch" href="/assets/js/5.360a52d3.js"><link rel="prefetch" href="/assets/js/6.ec28c6b0.js"><link rel="prefetch" href="/assets/js/7.e3c0eb5a.js"><link rel="prefetch" href="/assets/js/8.69f39480.js"><link rel="prefetch" href="/assets/js/9.9d7751ae.js"><link rel="prefetch" href="/assets/js/vendors~flowchart.0b4af48c.js">
<link rel="stylesheet" href="/assets/css/0.styles.8908b199.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container no-sidebar" data-v-dad8a512><div data-v-dad8a512><div id="loader-wrapper" class="loading-wrapper" data-v-d48f4d20 data-v-dad8a512 data-v-dad8a512><div class="loader-main" data-v-d48f4d20><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div></div> <!----> <!----></div> <div class="password-shadow password-wrapper-out" style="display:none;" data-v-64685f0e data-v-dad8a512 data-v-dad8a512><h3 class="title" style="display:none;" data-v-64685f0e data-v-64685f0e>王负剑的博客</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-64685f0e data-v-64685f0e><input type="password" value="" data-v-64685f0e> <span data-v-64685f0e>Konck! Knock!</span> <button data-v-64685f0e>OK</button></label> <div class="footer" style="display:none;" data-v-64685f0e data-v-64685f0e><span data-v-64685f0e><i class="iconfont reco-theme" data-v-64685f0e></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-64685f0e>vuePress-theme-reco</a></span> <span data-v-64685f0e><i class="iconfont reco-copyright" data-v-64685f0e></i> <a data-v-64685f0e><span data-v-64685f0e>王负剑的博客</span>
<span data-v-64685f0e>2017 - </span>
2020
</a></span></div></div> <div class="hide" data-v-dad8a512><header class="navbar" data-v-dad8a512><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/4.jpg" alt="王负剑的博客" class="logo"> <span class="site-name">王负剑的博客</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><i class="iconfont reco-search"></i> <input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link"><i class="iconfont reco-home"></i>
首页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
Category
</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/前端/" class="nav-link"><i class="iconfont undefined"></i>
前端
</a></li><li class="dropdown-item"><!----> <a href="/categories/面试/" class="nav-link"><i class="iconfont undefined"></i>
面试
</a></li><li class="dropdown-item"><!----> <a href="/categories/前端学习/" class="nav-link"><i class="iconfont undefined"></i>
前端学习
</a></li></ul></div></div><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
Tag
</a></div><div class="nav-item"><a href="/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
时间线
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-coding"></i>
文章列表
</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>前端</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/articles/frontend/html.html" class="nav-link"><i class="iconfont undefined"></i>
HTML
</a></li><li class="dropdown-subitem"><a href="/articles/frontend/css.html" aria-current="page" class="nav-link router-link-exact-active router-link-active"><i class="iconfont undefined"></i>
CSS
</a></li><li class="dropdown-subitem"><a href="/articles/frontend/javascript.html" class="nav-link"><i class="iconfont undefined"></i>
JavaScript
</a></li></ul></li><li class="dropdown-item"><h4>后端</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/articles/backend/nodejs.html" class="nav-link"><i class="iconfont undefined"></i>
nodeJS
</a></li><li class="dropdown-subitem"><a href="/articles/backend/css.html" class="nav-link"><i class="iconfont undefined"></i>
CSS
</a></li><li class="dropdown-subitem"><a href="/articles/backend/javascript.html" class="nav-link"><i class="iconfont undefined"></i>
JavaScript
</a></li></ul></li><li class="dropdown-item"><h4>WEB</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/articles/webwork/html.html" class="nav-link"><i class="iconfont undefined"></i>
HTML
</a></li><li class="dropdown-subitem"><a href="/articles/webwork/css.html" class="nav-link"><i class="iconfont undefined"></i>
CSS
</a></li><li class="dropdown-subitem"><a href="/articles/webwork/javascript.html" class="nav-link"><i class="iconfont undefined"></i>
JavaScript
</a></li></ul></li><li class="dropdown-item"><h4>框架</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/articles/framework/vue.html" class="nav-link"><i class="iconfont undefined"></i>
Vue
</a></li><li class="dropdown-subitem"><a href="/articles/framework/react.html" class="nav-link"><i class="iconfont undefined"></i>
React
</a></li><li class="dropdown-subitem"><a href="/articles/framework/element.html" class="nav-link"><i class="iconfont undefined"></i>
Element
</a></li></ul></li><li class="dropdown-item"><!----> <a href="/articles/study/" class="nav-link"><i class="iconfont undefined"></i>
学习
</a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-dad8a512></div> <aside class="sidebar" data-v-dad8a512><div class="personal-info-wrapper" data-v-ca798c94 data-v-dad8a512><img src="/4.jpg" alt="author-avatar" class="personal-img" data-v-ca798c94> <h3 class="name" data-v-ca798c94>
王负剑的博客
</h3> <div class="num" data-v-ca798c94><div data-v-ca798c94><h3 data-v-ca798c94>5</h3> <h6 data-v-ca798c94>Article</h6></div> <div data-v-ca798c94><h3 data-v-ca798c94>5</h3> <h6 data-v-ca798c94>Tag</h6></div></div> <hr data-v-ca798c94></div> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link"><i class="iconfont reco-home"></i>
首页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
Category
</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/前端/" class="nav-link"><i class="iconfont undefined"></i>
前端
</a></li><li class="dropdown-item"><!----> <a href="/categories/面试/" class="nav-link"><i class="iconfont undefined"></i>
面试
</a></li><li class="dropdown-item"><!----> <a href="/categories/前端学习/" class="nav-link"><i class="iconfont undefined"></i>
前端学习
</a></li></ul></div></div><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
Tag
</a></div><div class="nav-item"><a href="/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
时间线
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-coding"></i>
文章列表
</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>前端</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/articles/frontend/html.html" class="nav-link"><i class="iconfont undefined"></i>
HTML
</a></li><li class="dropdown-subitem"><a href="/articles/frontend/css.html" aria-current="page" class="nav-link router-link-exact-active router-link-active"><i class="iconfont undefined"></i>
CSS
</a></li><li class="dropdown-subitem"><a href="/articles/frontend/javascript.html" class="nav-link"><i class="iconfont undefined"></i>
JavaScript
</a></li></ul></li><li class="dropdown-item"><h4>后端</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/articles/backend/nodejs.html" class="nav-link"><i class="iconfont undefined"></i>
nodeJS
</a></li><li class="dropdown-subitem"><a href="/articles/backend/css.html" class="nav-link"><i class="iconfont undefined"></i>
CSS
</a></li><li class="dropdown-subitem"><a href="/articles/backend/javascript.html" class="nav-link"><i class="iconfont undefined"></i>
JavaScript
</a></li></ul></li><li class="dropdown-item"><h4>WEB</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/articles/webwork/html.html" class="nav-link"><i class="iconfont undefined"></i>
HTML
</a></li><li class="dropdown-subitem"><a href="/articles/webwork/css.html" class="nav-link"><i class="iconfont undefined"></i>
CSS
</a></li><li class="dropdown-subitem"><a href="/articles/webwork/javascript.html" class="nav-link"><i class="iconfont undefined"></i>
JavaScript
</a></li></ul></li><li class="dropdown-item"><h4>框架</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/articles/framework/vue.html" class="nav-link"><i class="iconfont undefined"></i>
Vue
</a></li><li class="dropdown-subitem"><a href="/articles/framework/react.html" class="nav-link"><i class="iconfont undefined"></i>
React
</a></li><li class="dropdown-subitem"><a href="/articles/framework/element.html" class="nav-link"><i class="iconfont undefined"></i>
Element
</a></li></ul></li><li class="dropdown-item"><!----> <a href="/articles/study/" class="nav-link"><i class="iconfont undefined"></i>
学习
</a></li></ul></div></div> <!----></nav> <!----> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-64685f0e data-v-dad8a512><h3 class="title" style="display:none;" data-v-64685f0e data-v-64685f0e>CSS3查漏补缺</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-64685f0e data-v-64685f0e><input type="password" value="" data-v-64685f0e> <span data-v-64685f0e>Konck! Knock!</span> <button data-v-64685f0e>OK</button></label> <div class="footer" style="display:none;" data-v-64685f0e data-v-64685f0e><span data-v-64685f0e><i class="iconfont reco-theme" data-v-64685f0e></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-64685f0e>vuePress-theme-reco</a></span> <span data-v-64685f0e><i class="iconfont reco-copyright" data-v-64685f0e></i> <a data-v-64685f0e><span data-v-64685f0e>王负剑的博客</span>
<span data-v-64685f0e>2017 - </span>
2020
</a></span></div></div> <div data-v-dad8a512><main class="page"><div class="page-title" style="display:none;"><h1>CSS3查漏补缺</h1> <hr> <div data-v-aa64b9d0><i class="iconfont reco-account" data-v-aa64b9d0><span data-v-aa64b9d0>王负剑</span></i> <i class="iconfont reco-date" data-v-aa64b9d0><span data-v-aa64b9d0>2020-06-10</span></i> <!----> <i class="iconfont reco-tag tags" data-v-aa64b9d0><span class="tag-item" data-v-aa64b9d0>CSS3</span></i></div></div> <div class="theme-reco-content content__default" style="display:none;"><h2 id="文本溢出处理"><a href="#文本溢出处理" class="header-anchor">#</a> 文本溢出处理</h2> <div class="language- line-numbers-mode"><pre class="language-text"><code>.main{
width: 20px;
border: 1px solid #ddd;
text-overflow: ellipsis;
overflow: hidden;
}
<div class="main"> sssssssssssssssssssss
</div>
//IE
.main{
overflow:hidden;
width:xxx;
white-space:nowrap;
text-overflow:ellipsis;
}
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br></div></div><h2 id="文字排版"><a href="#文字排版" class="header-anchor">#</a> 文字排版</h2> <div class="language- line-numbers-mode"><pre class="language-text"><code><div class="main"> sssssssssssssssssssss
</div>
.main{
width:20px;
writing-mode: vertical-rl;
}
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h2 id="渐变属性"><a href="#渐变属性" class="header-anchor">#</a> 渐变属性</h2> <div class="language- line-numbers-mode"><pre class="language-text"><code><div class="d0"></div>
<div class="d1"></div>
<div class="d2"></div>
<div class="d3"></div>
//
body{
width: 100%;
height: 300px;
display: inline-flex;
flex-direction: row;
}
body div{
margin-left: 15px;
}
//线性渐变
.d0{
width: 300px;
height: 300px;
background: linear-gradient(red 50%,50%,black)
}
//径向渐变
.d1{
width: 300px;
height: 300px;
background: radial-gradient(red,yellow 30% ,
black 50%,black)
}
//重复线性渐变
.d2{
width: 300px;
height: 300px;
background:repeating-linear-gradient(90deg ,red ,25px,yellow 25px,25px,black 50px)
}
//重复径向渐变
.d3{
width: 300px;
height: 300px;
background: repeating-radial-gradient(red,24px,yellow 25px,26px,black 50px)
}
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br></div></div><h2 id="元素默认蓝色边框"><a href="#元素默认蓝色边框" class="header-anchor">#</a> 元素默认蓝色边框</h2> <p> <code>input</code>标签元素,如<code>button、text、areatext</code>的一些事件,在很多浏览器默认情况下会出现蓝色边框。这是由于元素默认的轮廓线产生的。取消方式如下:</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>//方法1
outline:none /default
//方法2
outline-width:0
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><h2 id="背景透明,文字不透明"><a href="#背景透明,文字不透明" class="header-anchor">#</a> 背景透明,文字不透明</h2> <p> 我们通常是使用<code>opacity</code>来做背景的透明化处理。使用<code>opacity</code>会导致所有子元素都透明。如果只想让背景透明,其他不透明,可以使用<code>rgba</code>来处理背景</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>background-color: rgba(red,green,blue,alpha)
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="div内置img元素,底部总有距离"><a href="#div内置img元素,底部总有距离" class="header-anchor">#</a> <code>div</code>内置<code>img</code>元素,底部总有距离</h2> <p> 用一个``div<code>包裹一个</code>img<code>,底边会有一个缝隙。这是由于</code>img`是行内元素,浏览器为下行字符留下的一些空间(与当前字体大小有关)。</p> <p>解决办法:</p> <div class="language- line-numbers-mode"><pre class="language-text"><code><div> <img /></div>
// 1. 给 div的font-size或者ling-height设置为0
div{font-size:0}
// 2. 改变img的垂直对齐方式
img{ vertical-align:top | middle}
//img变成块级元素(inline-block不可以)
img{ display : block}
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h2 id="元素自动填充背景色"><a href="#元素自动填充背景色" class="header-anchor">#</a> 元素自动填充背景色</h2> <p> 当浏览器(chrome)给输入框自动填充内容后,也会自动给输入框带上背景。该问题是由于chrome会默认给自动填充的<code>input</code>、<code>select</code>、<code>textarea</code>等加上<code>:-webkit-autofill</code>私有伪属性造成的</p> <p>解决办法:</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>input:-webkit-autofill{
box-shadow: 0 0 0px 1000px white inset !important;
}
select:-webkit-autofill{
box-shadow: 0 0 0px 1000px white inset !important;
}
textarea:-webkit-autofill{
box-shadow: 0 0 0px 1000px white inset !important;
}
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h2 id="transform奇数数值导致字体模糊"><a href="#transform奇数数值导致字体模糊" class="header-anchor">#</a> transform奇数数值导致字体模糊</h2> <p> 当元素设置有transform,且其值为基数或小数,同事其整体高度也有基数时,其内部文字会变模糊</p> <p>解决方案:</p> <ul><li>不要给transform属性值设置奇数和小数值;</li> <li>调整整体元素高度不要为奇数。</li></ul> <h2 id="last-child-和-last-of-type"><a href="#last-child-和-last-of-type" class="header-anchor">#</a> :last-child 和 :last-of-type</h2> <div class="language- line-numbers-mode"><pre class="language-text"><code><style>
.content{
width: 500px;
height: 500px;
background: #ddd;
display: flex;
}
.content div{
width: 150px;
height: 150px;
background: #000;
margin: 10px;
}
//最后一个 div 的border未生效
/* .content div:last-child{
border: 5px solid #ff0;
} */
//最后一个div的border生效
.content div:last-of-type{
border: 5px solid #ff0;
}
</style>
<div class="content">
<div>aaaa</div>
<div>bbbb</div>
<div>cccc</div>
<span>dddd</span>
</div>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br></div></div><p>结论:</p> <ol><li><code>:last-child</code>选取一群兄弟元素中的最后一个元素,并且最后的这个元素必须是所声明的指定元素(注意2个条件);</li> <li><code>:last-of-type</code>选取一群兄弟元素中的最后一个指定类型的元素。</li></ol> <p>综上:推荐使用<code>:last-of-type</code> 。同理适用于<code>:nth-last-child(n)</code>和<code>:nth-last-of-type(n)</code></p> <h2 id="div-css设计中如何去掉链接的虚线框?"><a href="#div-css设计中如何去掉链接的虚线框?" class="header-anchor">#</a> <code>DIV CSS</code>设计中如何去掉链接的虚线框?</h2> <p><code>IE</code>下:<code><a href="#"onfocus="this.blur();"> FF下:a{outline:none;}</code></p> <h2 id="如何区别display-none与visibility-hidden"><a href="#如何区别display-none与visibility-hidden" class="header-anchor">#</a> 如何区别<code>display:none与visibility:hidden?</code></h2> <p>相同的是display:none与visibility:hidden都可以用来隐藏某个元素;</p> <p>不同的是display:none在隐藏元素的时候,将其占位空间也去掉;而visibility:hidden只是隐藏了内容而已,其占位空间仍然保留。</p> <h2 id="float和margin同时使用时,-ie6的双倍边距bug如何解决?"><a href="#float和margin同时使用时,-ie6的双倍边距bug如何解决?" class="header-anchor">#</a> <code>float</code>和<code>margin</code>同时使用时, IE6的双倍边距BUG如何解决?</h2> <p> 解决办法就是是加上<code>display:inline</code>代码</p> <h2 id="清除浮动的几种方式,各自的优缺点"><a href="#清除浮动的几种方式,各自的优缺点" class="header-anchor">#</a> 清除浮动的几种方式,各自的优缺点</h2> <ul><li>父级<code>div</code>定义<code>height</code></li> <li>结尾处加空<code>div</code>标签<code>clear:both</code></li> <li>父级<code>div</code>定义伪类<code>:after</code>和<code>zoom</code></li> <li>父级<code>div</code>定义<code>overflow:hidden</code></li> <li>父级<code>div</code>也浮动,需要定义宽度</li> <li>结尾处加<code>br</code>标签<code>clear:both</code></li> <li>比较好的是第3种方式,好多网站都这么用</li></ul> <h2 id="display-inline-block-什么时候不会显示间隙?-携程"><a href="#display-inline-block-什么时候不会显示间隙?-携程" class="header-anchor">#</a> display:inline-block 什么时候不会显示间隙?(携程)</h2> <ul><li>移除空格</li> <li>使用<code>margin</code>负值</li> <li>使用<code>font-size:0</code></li> <li><code>letter-spacing</code></li> <li><code>word-spacing</code></li></ul> <h2 id="如果需要手动写动画,你认为最小时间间隔是多久,为什么?(阿里)"><a href="#如果需要手动写动画,你认为最小时间间隔是多久,为什么?(阿里)" class="header-anchor">#</a> 如果需要手动写动画,你认为最小时间间隔是多久,为什么?(阿里)</h2> <ul><li>多数显示器默认频率是<code>60Hz</code>,即<code>1</code>秒刷新<code>60</code>次,所以理论上最小间隔为<code>1/60*1000ms = 16.7ms</code></li></ul> <h2 id="几种常见的css布局"><a href="#几种常见的css布局" class="header-anchor">#</a> 几种常见的CSS布局</h2> <ul><li>流体布局</li></ul> <div class="language-css line-numbers-mode"><pre class="language-css"><code> <span class="token selector">.left</span> <span class="token punctuation">{</span>
<span class="token property">float</span><span class="token punctuation">:</span> left<span class="token punctuation">;</span>
<span class="token property">width</span><span class="token punctuation">:</span> 100px<span class="token punctuation">;</span>
<span class="token property">height</span><span class="token punctuation">:</span> 200px<span class="token punctuation">;</span>
<span class="token property">background</span><span class="token punctuation">:</span> red<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token selector">.right</span> <span class="token punctuation">{</span>
<span class="token property">float</span><span class="token punctuation">:</span> right<span class="token punctuation">;</span>
<span class="token property">width</span><span class="token punctuation">:</span> 200px<span class="token punctuation">;</span>
<span class="token property">height</span><span class="token punctuation">:</span> 200px<span class="token punctuation">;</span>
<span class="token property">background</span><span class="token punctuation">:</span> blue<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token selector">.main</span> <span class="token punctuation">{</span>
<span class="token property">margin-left</span><span class="token punctuation">:</span> 120px<span class="token punctuation">;</span>
<span class="token property">margin-right</span><span class="token punctuation">:</span> 220px<span class="token punctuation">;</span>
<span class="token property">height</span><span class="token punctuation">:</span> 200px<span class="token punctuation">;</span>
<span class="token property">background</span><span class="token punctuation">:</span> green<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<div class=<span class="token string">"container"</span>>
<div class=<span class="token string">"left"</span>></div>
<div class=<span class="token string">"right"</span>></div>
<div class=<span class="token string">"main"</span>></div>
</div>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br></div></div><ul><li>圣杯布局</li></ul> <div class="language-css line-numbers-mode"><pre class="language-css"><code><span class="token selector">.container</span> <span class="token punctuation">{</span>
<span class="token property">margin-left</span><span class="token punctuation">:</span> 120px<span class="token punctuation">;</span>
<span class="token property">margin-right</span><span class="token punctuation">:</span> 220px<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token selector">.main</span> <span class="token punctuation">{</span>
<span class="token property">float</span><span class="token punctuation">:</span> left<span class="token punctuation">;</span>
<span class="token property">width</span><span class="token punctuation">:</span> 100%<span class="token punctuation">;</span>
<span class="token property">height</span><span class="token punctuation">:</span>300px<span class="token punctuation">;</span>
<span class="token property">background</span><span class="token punctuation">:</span> green<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token selector">.left</span> <span class="token punctuation">{</span>
<span class="token property">position</span><span class="token punctuation">:</span> relative<span class="token punctuation">;</span>
<span class="token property">left</span><span class="token punctuation">:</span> -120px<span class="token punctuation">;</span>
<span class="token property">float</span><span class="token punctuation">:</span> left<span class="token punctuation">;</span>
<span class="token property">height</span><span class="token punctuation">:</span> 300px<span class="token punctuation">;</span>
<span class="token property">width</span><span class="token punctuation">:</span> 100px<span class="token punctuation">;</span>
<span class="token property">margin-left</span><span class="token punctuation">:</span> -100%<span class="token punctuation">;</span>
<span class="token property">background</span><span class="token punctuation">:</span> red<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token selector">.right</span> <span class="token punctuation">{</span>
<span class="token property">position</span><span class="token punctuation">:</span> relative<span class="token punctuation">;</span>
<span class="token property">right</span><span class="token punctuation">:</span> -220px<span class="token punctuation">;</span>
<span class="token property">float</span><span class="token punctuation">:</span> right<span class="token punctuation">;</span>
<span class="token property">height</span><span class="token punctuation">:</span> 300px<span class="token punctuation">;</span>
<span class="token property">width</span><span class="token punctuation">:</span> 200px<span class="token punctuation">;</span>
<span class="token property">margin-left</span><span class="token punctuation">:</span> -200px<span class="token punctuation">;</span>
<span class="token property">background</span><span class="token punctuation">:</span> blue<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<div class=<span class="token string">"container"</span>>
<div class=<span class="token string">"main"</span>></div>
<div class=<span class="token string">"left"</span>></div>
<div class=<span class="token string">"right"</span>></div>
</div>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br></div></div><ul><li>双飞翼布局</li></ul> <div class="language-css line-numbers-mode"><pre class="language-css"><code><span class="token selector">.content</span> <span class="token punctuation">{</span>
<span class="token property">float</span><span class="token punctuation">:</span> left<span class="token punctuation">;</span>
<span class="token property">width</span><span class="token punctuation">:</span> 100%<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token selector">.main</span> <span class="token punctuation">{</span>
<span class="token property">height</span><span class="token punctuation">:</span> 200px<span class="token punctuation">;</span>
<span class="token property">margin-left</span><span class="token punctuation">:</span> 110px<span class="token punctuation">;</span>
<span class="token property">margin-right</span><span class="token punctuation">:</span> 220px<span class="token punctuation">;</span>
<span class="token property">background</span><span class="token punctuation">:</span> green<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token selector">.main::after</span> <span class="token punctuation">{</span>
<span class="token property">content</span><span class="token punctuation">:</span> <span class="token string">''</span><span class="token punctuation">;</span>
<span class="token property">display</span><span class="token punctuation">:</span> block<span class="token punctuation">;</span>
<span class="token property">font-size</span><span class="token punctuation">:</span>0<span class="token punctuation">;</span>
<span class="token property">height</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
<span class="token property">zoom</span><span class="token punctuation">:</span> 1<span class="token punctuation">;</span>
<span class="token property">clear</span><span class="token punctuation">:</span> both<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token selector">.left</span> <span class="token punctuation">{</span>
<span class="token property">float</span><span class="token punctuation">:</span>left<span class="token punctuation">;</span>
<span class="token property">height</span><span class="token punctuation">:</span> 200px<span class="token punctuation">;</span>
<span class="token property">width</span><span class="token punctuation">:</span> 100px<span class="token punctuation">;</span>
<span class="token property">margin-left</span><span class="token punctuation">:</span> -100%<span class="token punctuation">;</span>
<span class="token property">background</span><span class="token punctuation">:</span> red<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token selector">.right</span> <span class="token punctuation">{</span>
<span class="token property">float</span><span class="token punctuation">:</span> right<span class="token punctuation">;</span>
<span class="token property">height</span><span class="token punctuation">:</span> 200px<span class="token punctuation">;</span>
<span class="token property">width</span><span class="token punctuation">:</span> 200px<span class="token punctuation">;</span>
<span class="token property">margin-left</span><span class="token punctuation">:</span> -200px<span class="token punctuation">;</span>
<span class="token property">background</span><span class="token punctuation">:</span> blue<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<div class=<span class="token string">"content"</span>>
<div class=<span class="token string">"main"</span>></div>
</div>
<div class=<span class="token string">"left"</span>></div>
<div class=<span class="token string">"right"</span>></div>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br></div></div><h2 id="css中可以让文字在垂直和水平方向上重叠的两个属性是什么?"><a href="#css中可以让文字在垂直和水平方向上重叠的两个属性是什么?" class="header-anchor">#</a> css中可以让文字在垂直和水平方向上重叠的两个属性是什么?</h2> <ul><li>垂直方向:<code>line-height</code></li> <li>水平方向:<code>letter-spacing</code></li></ul> <h2 id="如何使用css实现硬件加速?"><a href="#如何使用css实现硬件加速?" class="header-anchor">#</a> 如何使用CSS实现硬件加速?</h2> <blockquote><p>硬件加速是指通过创建独立的复合图层,让GPU来渲染这个图层,从而提高性能,</p></blockquote> <ul><li>一般触发硬件加速的<code>CSS</code>属性有<code>transform</code>、<code>opacity</code>、<code>filter</code>,为了避免2D动画在 开始和结束的时候的<code>repaint</code>操作,一般使用<code>tranform:translateZ(0)</code></li></ul></div> <footer class="page-edit" style="display:none;"><!----> <!----></footer> <!----> <!----> <ul class="side-bar sub-sidebar-wrapper" style="width:12rem;" data-v-40a3448a><li class="level-2" data-v-40a3448a><a href="/articles/frontend/css.html#文本溢出处理" class="sidebar-link" data-v-40a3448a>文本溢出处理</a></li><li class="level-2" data-v-40a3448a><a href="/articles/frontend/css.html#文字排版" class="sidebar-link" data-v-40a3448a>文字排版</a></li><li class="level-2" data-v-40a3448a><a href="/articles/frontend/css.html#渐变属性" class="sidebar-link" data-v-40a3448a>渐变属性</a></li><li class="level-2" data-v-40a3448a><a href="/articles/frontend/css.html#元素默认蓝色边框" class="sidebar-link" data-v-40a3448a>元素默认蓝色边框</a></li><li class="level-2" data-v-40a3448a><a href="/articles/frontend/css.html#背景透明,文字不透明" class="sidebar-link" data-v-40a3448a>背景透明,文字不透明</a></li><li class="level-2" data-v-40a3448a><a href="/articles/frontend/css.html#div内置img元素,底部总有距离" class="sidebar-link" data-v-40a3448a>div内置img元素,底部总有距离</a></li><li class="level-2" data-v-40a3448a><a href="/articles/frontend/css.html#元素自动填充背景色" class="sidebar-link" data-v-40a3448a>元素自动填充背景色</a></li><li class="level-2" data-v-40a3448a><a href="/articles/frontend/css.html#transform奇数数值导致字体模糊" class="sidebar-link" data-v-40a3448a>transform奇数数值导致字体模糊</a></li><li class="level-2" data-v-40a3448a><a href="/articles/frontend/css.html#last-child-和-last-of-type" class="sidebar-link" data-v-40a3448a>:last-child 和 :last-of-type</a></li><li class="level-2" data-v-40a3448a><a href="/articles/frontend/css.html#div-css设计中如何去掉链接的虚线框?" class="sidebar-link" data-v-40a3448a>DIV CSS设计中如何去掉链接的虚线框?</a></li><li class="level-2" data-v-40a3448a><a href="/articles/frontend/css.html#如何区别display-none与visibility-hidden" class="sidebar-link" data-v-40a3448a>如何区别display:none与visibility:hidden?</a></li><li class="level-2" data-v-40a3448a><a href="/articles/frontend/css.html#float和margin同时使用时,-ie6的双倍边距bug如何解决?" class="sidebar-link" data-v-40a3448a>float和margin同时使用时, IE6的双倍边距BUG如何解决?</a></li><li class="level-2" data-v-40a3448a><a href="/articles/frontend/css.html#清除浮动的几种方式,各自的优缺点" class="sidebar-link" data-v-40a3448a>清除浮动的几种方式,各自的优缺点</a></li><li class="level-2" data-v-40a3448a><a href="/articles/frontend/css.html#display-inline-block-什么时候不会显示间隙?-携程" class="sidebar-link" data-v-40a3448a>display:inline-block 什么时候不会显示间隙?(携程)</a></li><li class="level-2" data-v-40a3448a><a href="/articles/frontend/css.html#如果需要手动写动画,你认为最小时间间隔是多久,为什么?(阿里)" class="sidebar-link" data-v-40a3448a>如果需要手动写动画,你认为最小时间间隔是多久,为什么?(阿里)</a></li><li class="level-2" data-v-40a3448a><a href="/articles/frontend/css.html#几种常见的css布局" class="sidebar-link" data-v-40a3448a>几种常见的CSS布局</a></li><li class="level-2" data-v-40a3448a><a href="/articles/frontend/css.html#css中可以让文字在垂直和水平方向上重叠的两个属性是什么?" class="sidebar-link" data-v-40a3448a>css中可以让文字在垂直和水平方向上重叠的两个属性是什么?</a></li><li class="level-2" data-v-40a3448a><a href="/articles/frontend/css.html#如何使用css实现硬件加速?" class="sidebar-link" data-v-40a3448a>如何使用CSS实现硬件加速?</a></li></ul></main> <!----></div></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-44bd5a18 data-v-44bd5a18><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-44bd5a18><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-44bd5a18></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-44bd5a18></path></svg></div></div></div>
<script src="/assets/js/app.800ef70b.js" defer></script><script src="/assets/js/4.7602e631.js" defer></script><script src="/assets/js/1.7dbd71d8.js" defer></script><script src="/assets/js/22.ae97a39f.js" defer></script>
</body>
</html>
| 140.825 | 7,242 | 0.699427 |
f06f2cf97d8da48c7ae640dd4974c12d832537f5 | 3,398 | py | Python | njdate/hebdfind.py | schorrm/njdate | 5a31d944973904b75f1dbac811fc7393aaa4ed7c | [
"MIT"
] | 4 | 2019-07-16T19:58:42.000Z | 2021-11-17T14:50:17.000Z | njdate/hebdfind.py | schorrm/njdate | 5a31d944973904b75f1dbac811fc7393aaa4ed7c | [
"MIT"
] | null | null | null | njdate/hebdfind.py | schorrm/njdate | 5a31d944973904b75f1dbac811fc7393aaa4ed7c | [
"MIT"
] | null | null | null | # Takes two years, and runs an aggressive search for dates in between those two years (inclusive).
import njdate.gematria as gematria
import njdate.ej_generic as ej_generic
import string
specpunc = string.punctuation.replace('"','').replace("'","")
tr_table = str.maketrans("","",specpunc)
def date_aggressor (search_text, begin_year, end_year):
tokens = search_text.translate(tr_table).split()
for search_year in range (begin_year, end_year+1):
if gematria.YearNoToGematria(search_year) in tokens:
query = ' '.join(search_text.partition(gematria.YearNoToGematria(search_year))[:2])
return ej_generic.ExtractDate(query)
if gematria.YearNoToGematria(search_year, False) in tokens:
query = ' '.join(search_text.partition(gematria.YearNoToGematria(search_year, False))[:2])
return ej_generic.ExtractDate(query)
if gematria.YearNoToGematria(search_year, prepend_heh=True) in tokens:
query = ' '.join(search_text.partition(gematria.YearNoToGematria(search_year, False))[:2])
return ej_generic.ExtractDate(query)
return None
def date_aggressor_lamedify (search_text, begin_year, end_year):
tokens = search_text.translate(tr_table).split()
for search_year in range (begin_year, end_year+1):
if gematria.YearNoToGematria(search_year) in tokens:
query = ' '.join(search_text.partition(gematria.YearNoToGematria(search_year))[:2])
return ej_generic.ExtractDate(query)
if gematria.YearNoToGematria(search_year, False) in tokens:
query = ' '.join(search_text.partition(gematria.YearNoToGematria(search_year, False))[:2])
return ej_generic.ExtractDate(query)
if gematria.YearNoToGematria(search_year, False, False) + '"ל' in tokens:
query = ' '.join(search_text.partition(gematria.YearNoToGematria(search_year, False, False))[:2])
return ej_generic.ExtractDate(query)
return None
# For dropped Tafs etc, so we need to add 400 years after what we've found, etc
def yshift_date_aggressor (search_text, begin_year, end_year, shift=400):
# change: move search year and begin year to before shifting 400 years, so the call is the same.
begin_year -= shift
end_year -= shift
tokens = search_text.translate(tr_table).split()
for search_year in range (begin_year, end_year+1):
if gematria.YearNoToGematria(search_year) in tokens:
query = ' '.join(search_text.partition(gematria.YearNoToGematria(search_year))[:2])
return ej_generic.ForceYear(query, search_year+shift)
if gematria.YearNoToGematria(search_year, False) in tokens:
query = ' '.join(search_text.partition(gematria.YearNoToGematria(search_year, False))[:2])
return ej_generic.ForceYear(query, search_year+shift)
return None
def yshift_date_aggressor_lamedify (search_text, begin_year, end_year, shift=400):
tokens = search_text.translate(tr_table).split()
for search_year in range (begin_year, end_year+1):
if gematria.YearNoToGematria(search_year, False, False) + '"ל' in tokens:
query = ' '.join(search_text.partition(gematria.YearNoToGematria(search_year, False, False))[:2])
return ej_generic.ForceYear(query, search_year+shift)
return None
| 57.59322 | 110 | 0.700706 |
1cd23789ebb80e68a61fbfb7d581cab46abad597 | 2,215 | css | CSS | css/style.css | ahmetkilinc/holymoly | 73ea185f02f3241240081bce81922e7e154bbdea | [
"MIT"
] | null | null | null | css/style.css | ahmetkilinc/holymoly | 73ea185f02f3241240081bce81922e7e154bbdea | [
"MIT"
] | 10 | 2017-09-13T11:42:33.000Z | 2018-02-16T14:06:31.000Z | css/style.css | ahmetkilinc/holymoly | 73ea185f02f3241240081bce81922e7e154bbdea | [
"MIT"
] | null | null | null | *{
margin: 0;
padding: 0;
}
/*popup css*/
.modal{
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding-top: 100px; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgba(0,0,0, 0.5); /* Fallback color */
}
/* Modal Content */
.modal-content{
background-color: rgba(255,255,255, 0.8);
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}
/* The Close Button */
.close-arakat{
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close-arakat:hover,
.close-arakat:focus{
color: #000;
text-decoration: none;
cursor: pointer;
}
/*popup over.*/
html{
overflow: hidden;
}
#info{
position: fixed;
top: 80%;
width: 75%;
text-align: center;
z-index: 50;
display: grid;
margin-top: 4%;
}
p{
color: #000000;
text-align: center;
width: 10%;
height: 10%;
}
#container{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
zIndex: -10;
background: radial-gradient(#FFFFFF,#FFFFFF);
}
#gui2{
position: absolute;
text-align: left;
}
.dg.main .close-button{
opacity: 0.5;
border-radius: 0 0 10px 10px;
}
#title{
position:absolute;
width:100%;
left: 20px;
top: 20px;
font-family:'Open Sans', sans-serif;
color:#ffffff;
line-height : 1.5;
font-size: 2em;
}
.subtitle{
color:#ffffff;
text-transform: uppercase;
font-size: 0.4em;
}
.full_width{
width: 100% !important;
}
.reset_button{
width: 100% !important;
color: deepskyblue !important;
font-size: 105% !important;
font-weight: bold;
text-align: center;
}
.elilegir{
width: 100% !important;
color: crimson !important;
font-size: 105% !important;
font-weight: bold;
text-align: center;
}
.kontrol_buttons{
width: 100% !important;
color: cyan !important;
font-size: 105% !important;
font-weight: bold;
text-align: center;
}
.teklif_button{
width: 100% !important;
text-align: center !important;
} | 13.84375 | 60 | 0.602257 |
1fc16b06c80223ae49a9ff60403bf40a53f49704 | 4,792 | lua | Lua | engine/math/chain.lua | Kishimi/UNDERLOD | e4fe556cab246937a98ec044e5b893ccb31b06fa | [
"MIT"
] | 982 | 2021-05-17T10:53:34.000Z | 2022-03-26T06:06:03.000Z | engine/math/chain.lua | Kishimi/UNDERLOD | e4fe556cab246937a98ec044e5b893ccb31b06fa | [
"MIT"
] | 12 | 2021-05-17T10:57:21.000Z | 2021-10-06T06:09:45.000Z | engine/math/chain.lua | Kishimi/UNDERLOD | e4fe556cab246937a98ec044e5b893ccb31b06fa | [
"MIT"
] | 185 | 2021-05-17T10:53:35.000Z | 2022-03-25T01:48:10.000Z | -- A chain class. If loop is true then this is the same as a polygon, otherwise its a collection of connected lines (an open polygon).
-- Implements every function that Polygon does.
Chain = Object:extend()
Chain:implement(Polygon)
function Chain:init(loop, vertices)
self.loop = loop
self.vertices = vertices
self:get_size()
self:get_bounds()
self:get_centroid()
end
-- Draws the chain of lines with the given color and width.
function Chain:draw(color, line_width)
if self.loop and not line_width then
graphics.polygon(self.vertices, color, line_width)
else
for i = 1, #self.vertices-2, 2 do
graphics.line(self.vertices[i], self.vertices[i+1], self.vertices[i+2], self.vertices[i+3], color, line_width)
if self.loop and i == #self.vertices-2 then
graphics.line(self.vertices[i], self.vertices[i+1], self.vertices[1], self.vertices[2], color, line_width)
end
end
end
end
-- If loop is true, returns true if the point is inside the polygon.
-- If loop is false, returns true if the point lies on any of the chain's lines.
-- colliding = chain:is_colliding_with_point(x, y)
function Chain:is_colliding_with_point(x, y)
if self.loop then
return mlib.polygon.checkPoint(x, y, self.vertices)
else
for i = 1, #self.vertices-2, 2 do
if mlib.segment.checkPoint(x, y, self.vertices[i], self.vertices[i+1], self.vertices[i+2], self.vertices[i+3]) then
return true
end
end
end
end
-- If loop is true, returns true if the line is colliding with the polygon.
-- If loop is false, returns true if the line is colliding with any of the chain's lines.
-- colliding = chain:is_colliding_with_line(line)
function Chain:is_colliding_with_line(line)
if self.loop then
return mlib.polygon.isSegmentInside(line.x1, line.y1, line.x2, line.y2, self.vertices)
else
for i = 1, #self.vertices-2, 2 do
if mlib.segment.getIntersection(self.vertices[i], self.vertices[i+1], self.vertices[i+2], self.vertices[i+3], line.x1, line.y1, line.x2, line.y2) then
return true
end
end
end
end
-- If loop is true for both chains, returns true if the polygon is colliding with the polygon.
-- If loop is false for both chains, returns true if any of the lines of one chain are colliding with any of the lines of the other chain.
-- If one is true and the other is false, returns true if the one that's a polygon is colliding with any of the lines of the one that is a chain.
-- colliding = chain:is_colliding_with_chain(other_chain)
function Chain:is_colliding_with_chain(chain)
if self.loop and chain.loop then
return mlib.polygon.isPolygonInside(self.vertices, chain.vertices) or mlib.polygon.isPolygonInside(chain.vertices, self.vertices)
elseif self.loop and not chain.loop then
return chain:is_colliding_with_polygon(self)
elseif not self.loop and chain.loop then
return self:is_colliding_with_polygon(chain)
else
for i = 1, #self.vertices-2, 2 do
for j = 1, #chain.vertices-2, 2 do
if mlib.segment.getIntersection(self.vertices[i], self.vertices[i+1], self.vertices[i+2], self.vertices[i+3], chain.vertices[j], chain.vertices[j+1], chain.vertices[j+2], chain.vertices[j+3]) then
return true
end
end
end
end
end
-- If loop is true, returns true if the circle is colliding with the polygon.
-- If loop is false, returns true if the circle is colliding with any of the chain's lines.
-- colliding = chain:is_colliding_with_circle(circle)
function Chain:is_colliding_with_circle(circle)
if self.loop then
return mlib.polygon.isCircleCompletelyInside(circle.x, circle.y, circle.rs, self.vertices) or
mlib.circle.isPolygonCompletelyInside(circle.x, circle.y, circle.rs, self.vertices) or
mlib.polygon.getCircleIntersection(circle.x, circle.y, circle.rs, self.vertices)
else
for i = 1, #self.vertices-2, 2 do
if mlib.circle.getSegmentIntersection(circle.x, circle.y, circle.rs, self.vertices[i], self.vertices[i+1], self.vertices[i+2], self.vertices[i+3]) then
return true
end
end
end
end
-- If loop is true, returns true if the polygon is colliding with the polygon.
-- If loop is false, returns true if the polygon is colliding with any of the chain's lines.
-- colliding = chain:is_colliding_with_polygon(polygon)
function Chain:is_colliding_with_polygon(polygon)
if self.loop then
return mlib.polygon.isPolygonInside(self.vertices, polygon.vertices) or mlib.polygon.isPolygonInside(polygon.vertices, self.vertices)
else
for i = 1, #self.vertices-2, 2 do
if mlib.polygon.getSegmentIntersection(self.vertices[i], self.vertices[i+1], self.vertices[i+2], self.vertices[i+3], polygon.vertices) then
return true
end
end
end
end
| 41.310345 | 204 | 0.723289 |
721b31196d7a0b0dd47893693621d23bb2406a5e | 1,346 | dart | Dart | lib/src/interface/output.dart | mzdm/beautiful_soup | c063dbf9cf24d1d53eef62adeef56e43798733fc | [
"MIT"
] | 13 | 2021-06-30T18:57:48.000Z | 2022-03-30T14:13:06.000Z | lib/src/interface/output.dart | mzdm/beautiful_soup | c063dbf9cf24d1d53eef62adeef56e43798733fc | [
"MIT"
] | null | null | null | lib/src/interface/output.dart | mzdm/beautiful_soup | c063dbf9cf24d1d53eef62adeef56e43798733fc | [
"MIT"
] | 1 | 2022-01-28T15:28:25.000Z | 2022-01-28T15:28:25.000Z | import '../bs_soup.dart';
/// Contains methods from [Output](https://www.crummy.com/software/BeautifulSoup/bs4/doc/#output).
// TODO: improve prettify
abstract class IOutput {
/// The method will turn a [BeautifulSoup] parse tree into a nicely
/// formatted [String], with a separate line for each tag and
/// each string.
///
/// You can call [prettify] on the top-level BeautifulSoup object, or on
/// any of its element objects.
///
/// Since it adds whitespace (in the form of newlines), [prettify] changes
/// the meaning of an HTML document and should not be used to reformat one.
///
/// The **goal** of [prettify] is to **help you visually understand the structure**
/// of the documents you work with.
String prettify();
/// {@template output_getText}
/// Returns the text of an element.
///
/// Same like `bs4element.string`.
/// {@endtemplate}
///
/// \- [separator] - Strings will be concatenated using this separator.
///
/// \- [strip] If `true`, strings will be stripped before being concatenated
/// (strips whitespace from the beginning and end of each bit of text).
/// `false` by default.
String getText({String separator, bool strip});
/// {@macro output_getText}
String get text;
/// Returns the whole element's representation as a [String].
String toString();
}
| 34.512821 | 98 | 0.673848 |
5bd76ef8107787108a2338422a6a09e99d63b198 | 13,817 | c | C | caswcx.c | imulilla/casMSXwcx | 1b4f50e4b2bb8cf98573dd0901799a28eeacdda8 | [
"MIT"
] | 5 | 2019-03-03T08:53:52.000Z | 2021-09-22T00:03:55.000Z | caswcx.c | imulilla/casMSXwcx | 1b4f50e4b2bb8cf98573dd0901799a28eeacdda8 | [
"MIT"
] | null | null | null | caswcx.c | imulilla/casMSXwcx | 1b4f50e4b2bb8cf98573dd0901799a28eeacdda8 | [
"MIT"
] | 1 | 2021-04-02T13:46:42.000Z | 2021-04-02T13:46:42.000Z | /*
===========================================================
$Name: caswcx.c
$Desc: Open MSX CAS files
$Author: NataliaPC <natalia.pujol@gmail.com>
$Revision: 1.3
$Comments: https://github.com/nataliapc/casMSXwcx
===========================================================
*/
#include "wcxapi.h"
#include "win2nix_binds.h"
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <ctype.h>
#ifdef __MINGW32__
#include <unistd.h>
#endif
#include "types.h"
#include "defs.h"
#include "resource.h"
/*===========================================================
Constants
*/
#define CAS_PACKED 0x0001
#define FIXED_DATE ((1984 - 1980) << 25 | 1 << 21 | 1 << 16 | 0 << 11 | 0 << 5 | 0/2)
#define CAS_HDR_LEN 8
const char CAS_HEADER[] = "\x1F\xA6\xDE\xBA\xCC\x13\x7D\x74";
#define HDR_LEN 10
const char HEAD_BIN[] = "\xD0\xD0\xD0\xD0\xD0\xD0\xD0\xD0\xD0\xD0";
const char HEAD_BAS[] = "\xD3\xD3\xD3\xD3\xD3\xD3\xD3\xD3\xD3\xD3";
const char HEAD_ASC[] = "\xEA\xEA\xEA\xEA\xEA\xEA\xEA\xEA\xEA\xEA";
const char NAME_HBIN[] = "HEADER_BIN";
const char NAME_HASC[] = "HEADER_ASC";
const char NAME_HBAS[] = "HEADER_BAS";
const char NAME_DATA[] = "DATA";
const char CMT_HEAD_BIN[] = "Standard Binary Header";
const char CMT_HEAD_BAS[] = "Standard Tokenized Basic Header";
const char CMT_HEAD_ASC[] = "Standard ASCII Basic Header";
const char CMT_DATA[] = "Standard Data Block";
const char szCfgKey[] = "casMSXwcx";
/*===========================================================
Structs
*/
typedef struct FileList_s {
char szFileName[MAX_PATH-9]; // File name translated
dword dwSize; // File size in bytes
byte *cData; // File data
dword crc32; // Data CRC32
char *szComment; // Text Comment
struct FileList_s *lpNext; // Next entry
} FileList_t;
typedef struct CAShandle_s {
WCHAR szCASname[MAX_PATH * 16]; // CAS file name
dword dwCASflags; // Flags
byte *cRawCAS;
long lSize;
FileList_t *lpFileListHead;
FileList_t *lpFileListCur;
FileList_t *lpFileListThis;
} CAShandle_t;
/*===========================================================
Global variables
*/
char szCfgFile[MAX_PATH]; //Path to .INI config file
char mInvalidReplacer; //Char replacement if invalid one in "Found:" name
BOOL mbEnableWarnings; //Enable warnings
BOOL mTrimBinaryData; //Remove final zeros from DATA end.
/*===========================================================
Internal functions
*/
void GetCfgPath(void)
{
#ifdef WINDOWS
char path[MAX_PATH];
if (GetModuleFileName(GetModuleHandle( NULL ), path, sizeof(path))) {
char *p = strrchr(path, '\\');
if (p)
*++p = '\0';
else
path[0] = '\0';
} else
path[0] = '\0';
strcpy(szCfgFile, path);
strcat(szCfgFile, "plugins\\wcx\\casMSX\\casMSX.ini");
#endif
}
dword crc32b(unsigned char *data, unsigned int len) {
int i, j;
unsigned int byte, crc, mask;
i = 0;
crc = 0xFFFFFFFF;
while (len--) {
byte = data[i]; // Get next byte.
crc = crc ^ byte;
for (j = 7; j >= 0; j--) { // Do eight times.
mask = -(crc & 1);
crc = (crc >> 1) ^ (0xEDB88320 & mask);
}
i = i + 1;
}
return ~crc;
}
static void GetFoundString(FileList_t *pfl, char pInvalidReplacer, byte *pnameOut)
{
int pos=10, lastValidPos=10;
pnameOut[0] = '\0';
for (pos=10; pos<16; pos++) {
if (isalnum(pfl->cData[pos])) {
pnameOut[pos-10] = pfl->cData[pos];
lastValidPos = pos;
} else {
pnameOut[pos-10] = pInvalidReplacer;
}
}
pnameOut[lastValidPos-9] = '\0';
}
static void FreeCAShandler(CAShandle_t *lpH)
{
FileList_t *lpNext;
free(lpH->cRawCAS);
while (lpH->lpFileListHead) {
lpNext = lpH->lpFileListHead->lpNext;
free(lpH->lpFileListHead);
lpH->lpFileListHead = lpNext;
}
free(lpH);
}
static int MakeCASlist(CAShandle_t *lpH)
{
FILE *pFile;
int rc = 0, idx = 1;
long pos = 0, pos2, pos3;
byte foundName[7];
FileList_t *fl;
char *pName, *pCmt;
// Read CAS file
pFile = _wfopen (lpH->szCASname, L"rb");
if (pFile==NULL) return E_EOPEN;
// Get file size
fseek (pFile , 0 , SEEK_END);
lpH->lSize = ftell (pFile);
rewind (pFile);
// Read CAS file
lpH->cRawCAS = (byte*)malloc(lpH->lSize);
lpH->cRawCAS[0] = 0;
if (lpH->cRawCAS==NULL) return E_NO_MEMORY;
if (fread (lpH->cRawCAS, 1, lpH->lSize, pFile) != lpH->lSize) rc = E_EREAD;
if (fclose(pFile)) rc = E_ECLOSE;
if (memcmp(CAS_HEADER, (char*)lpH->cRawCAS, CAS_HDR_LEN) && lpH->lSize) rc = E_UNKNOWN_FORMAT;
if (!rc) {
// Search for CAS blocks
while (!rc && pos < lpH->lSize) {
pos += CAS_HDR_LEN;
if (pos >= lpH->lSize) { rc = E_BAD_DATA; break; }
// Create new block
fl = (FileList_t*)malloc(sizeof(FileList_t));
if (fl==NULL) { rc = E_NO_MEMORY; break; }
memset(fl, 0, sizeof(FileList_t));
// Search block end
pos2 = pos;
while (pos2 < lpH->lSize && memcmp(CAS_HEADER, &lpH->cRawCAS[pos2], CAS_HDR_LEN)) {
pos2++;
}
// Trim last zeros
pos3 = pos2;
if (mTrimBinaryData) {
while (pos3 > pos && lpH->cRawCAS[pos3-1]=='\0') pos3--;
}
// Found & Fill struct
fl->dwSize = pos3-pos;
fl->cData = lpH->cRawCAS + pos;
fl->crc32 = crc32b(fl->cData, fl->dwSize);
pName = pCmt = NULL;
if (fl->dwSize==16) {
GetFoundString(fl, mInvalidReplacer, foundName);
if (!memcmp(HEAD_BIN, fl->cData, HDR_LEN)) {
pName = (char*)NAME_HBIN;
pCmt = (char*)CMT_HEAD_BIN;
}
if (!memcmp(HEAD_ASC, fl->cData, HDR_LEN)) {
pName = (char*)NAME_HASC;
pCmt = (char*)CMT_HEAD_ASC;
}
if (!memcmp(HEAD_BAS, fl->cData, HDR_LEN)) {
pName = (char*)NAME_HBAS;
pCmt = (char*)CMT_HEAD_BAS;
}
sprintf(fl->szFileName, "%02u_%s[%s].%08lx", idx, pName, foundName, fl->crc32);
fl->szComment = pCmt;
}
if (pName==NULL) {
sprintf(fl->szFileName, "%02u_%s.%08lx", idx, NAME_DATA, fl->crc32);
fl->szComment = (char*)CMT_DATA;
}
// Set pointers
if (lpH->lpFileListHead==NULL) lpH->lpFileListHead = fl;
if (lpH->lpFileListCur) lpH->lpFileListCur->lpNext = fl;
lpH->lpFileListCur = fl;
fl->lpNext = NULL;
// Pos to next block
idx++;
pos = pos2;
}
}
if (rc) FreeCAShandler(lpH);
return rc;
}
/*
=====================================================================
Function name : STDCALL OpenArchive
Description : Main entry point to Windows Commander
Return type : WCX_API HANDLE
Argument : tOpenArchiveDataW *ArchiveData
*/
HANDLE CAS_OpenArchive(tOpenArchiveDataW *ArchiveData)
{
CAShandle_t *lpH = (CAShandle_t *)malloc(sizeof(CAShandle_t));
char szBuf[256] __attribute__((unused));
// Check for out of memory
if(lpH==NULL) {
ArchiveData->OpenResult = E_NO_MEMORY;
return 0;
}
memset(lpH, 0, sizeof(CAShandle_t));
#ifdef WINDOWS
GetCfgPath();
GetPrivateProfileString(szCfgKey, "EnableWarning", "1", szBuf, sizeof(szBuf), szCfgFile);
mbEnableWarnings = atoi(szBuf);
GetPrivateProfileString(szCfgKey, "InvalidCharReplacer", "_", szBuf, sizeof(szBuf), szCfgFile);
mInvalidReplacer = szBuf[0];
GetPrivateProfileString(szCfgKey, "TrimBinaryData", "0", szBuf, sizeof(szBuf), szCfgFile);
mTrimBinaryData = atoi(szBuf);
#else
mbEnableWarnings = 1;
mInvalidReplacer = '_';
#endif
// Copy archive name to handler
wcslcpy(lpH->szCASname, ArchiveData->ArcName, sizeof(lpH->szCASname));
// Default responding
ArchiveData->OpenResult = E_BAD_ARCHIVE;
// Read and create CAS list
if ((ArchiveData->OpenResult = MakeCASlist(lpH))) {
free(lpH);
return 0;
}
// Reset entry list
lpH->lpFileListCur = lpH->lpFileListHead;
return (HANDLE)lpH;
}
/*
=====================================================================
Function name : STDCALL ReadHeader
Description : Totalcmd find out what files are in the archive.
Return type : int (error code or 0)
Argument : WCX_API HANDLE hArcData
Argument : tHeaderDataExW *HeaderData
*/
int CAS_ReadHeader(HANDLE hArcData, tHeaderDataExW *HeaderData)
{
CAShandle_t *lpH = (CAShandle_t *)hArcData;
FileList_t *fl;
if (lpH->lpFileListCur) {
fl = lpH->lpFileListCur;
awfilenamecopy(HeaderData->FileName, fl->szFileName);
HeaderData->FileTime = FIXED_DATE;
HeaderData->FileAttr = 0x20;
HeaderData->FileCRC = fl->crc32;
HeaderData->PackSize = fl->dwSize + strlen(CAS_HEADER);
HeaderData->UnpSize = fl->dwSize;
HeaderData->CmtBuf = fl->szComment;
HeaderData->CmtSize = strlen(fl->szComment);
HeaderData->CmtBufSize = 80;
lpH->lpFileListThis = lpH->lpFileListCur;
lpH->lpFileListCur = lpH->lpFileListCur->lpNext;
return 0;
}
return E_END_ARCHIVE;
}
/*
=====================================================================
Function name : STDCALL ProcessFile
Description : Should unpack the specified file or test the
integrity of the archive.
Return type : int (error code or 0)
Argument : WCX_API HANDLE hArcData
Argument : int Operation
Argument : char *DestPath
Argument : char *DestName
*/
int CAS_ProcessFile(HANDLE hArcData, int Operation, WCHAR *DestPath, WCHAR *DestName)
{
FileList_t *fl = ((CAShandle_t *)hArcData)->lpFileListThis;
FILE *pFile;
switch (Operation) {
case PK_SKIP:
case PK_TEST:
return 0;
case PK_EXTRACT:
if (DestName != NULL) {
// Write Raw Block file
if ((pFile=_wfopen (DestName, L"wb"))==NULL) return E_EOPEN;
if (fwrite(fl->cData, 1, fl->dwSize, pFile) != fl->dwSize) return E_EWRITE;
if (fclose(pFile)) return E_ECLOSE;
} else {
return E_EOPEN;
}
return 0;
}
return E_NOT_SUPPORTED;
}
/*
=====================================================================
Function name : STDCALL CloseArchive
Description : Perform all necessary operations when archive
is about to be closed.
Return type : int (error code or 0)
Argument : WCX_API HANDLE hArcData
*/
int CAS_CloseArchive(HANDLE hArcData)
{
CAShandle_t *lpH = (CAShandle_t *)hArcData;
//Free all inner Handler data
FreeCAShandler(lpH);
return 0;
}
/*
=====================================================================
Function name : PackFiles
Description : Specifies what should happen when a user creates,
or adds files to the archive.
Return type : int (error code or 0)
Argument : WCHAR *PackedFile
Argument : WCHAR *SubPath
Argument : WCHAR *SrcPath
Argument : WCHAR *AddList
Argument : int Flags
*/
int CAS_PackFiles (WCHAR *PackedFile, WCHAR *SubPath, WCHAR *SrcPath, WCHAR *AddList, int Flags)
{
word rc = 0;
char *packedfile = (char*)malloc(MAX_PATH*16);
WCHAR *fullpath = (WCHAR*)malloc(MAX_PATH*16);
byte *buff = (byte*)malloc(2048);
long bsize;
FILE *fin=NULL, *fout=NULL;
if (packedfile==NULL || fullpath==NULL || buff==NULL) {
rc = E_NO_MEMORY;
} else {
// Open output file
if ((fout = _wfopen(PackedFile, L"a+b"))==NULL) rc = E_EOPEN;
while (*AddList && !rc) {
// Open input file
wcslcpy(fullpath, SrcPath, MAX_PATH*16);
wcslcat(fullpath, AddList, MAX_PATH*16);
if ((fin = _wfopen(fullpath, L"rb"))==NULL) {
rc = E_EOPEN;
break;
}
// Write CAS Block Header
if (fwrite(CAS_HEADER, 1, CAS_HDR_LEN, fout)!=CAS_HDR_LEN) {
rc = E_EWRITE;
break;
}
// Dump input file to output file
while ((bsize = fread(buff, 1, 2048, fin))) {
if (fwrite(buff, 1, bsize, fout)!=bsize) {
rc = E_EWRITE;
break;
}
}
fclose(fin);
// Delete origin file if it's a move order
if (!rc && (Flags & PK_PACK_MOVE_FILES)) {
DeleteFileT(fullpath);
}
// Go to next file to be added
while(*AddList) AddList++;
AddList++;
}
if (fout) fclose(fout);
}
free(packedfile);
free(fullpath);
free(buff);
return rc;
}
/*
=====================================================================
Function name : DeleteFiles
Description : Delete file(s) from CAS file
Return type : int (error code or 0)
Argument : WCHAR *PackedFile
Argument : WCHAR *DeleteList
*/
int CAS_DeleteFiles (WCHAR *PackedFile, WCHAR *DeleteList)
{
CAShandle_t *lpH = (CAShandle_t *)malloc(sizeof(CAShandle_t));
FileList_t *fl;
char buff[MAX_PATH];
word rc = 0;
BOOL anyFileDeleted = FALSE;
FILE *fout;
if (!lpH) return E_NO_MEMORY;
memset(lpH, 0, sizeof(CAShandle_t));
wcslcpy(lpH->szCASname, PackedFile, sizeof(lpH->szCASname));
if ((rc = MakeCASlist(lpH))) {
free(lpH);
}
if (!rc) {
while (*DeleteList) {
wafilenamecopy(buff, DeleteList);
// Search file to delete
fl = lpH->lpFileListHead;
do {
if (!strcmp(buff, fl->szFileName)) {
// Reset found node
lpH->lSize -= fl->dwSize;
fl->szFileName[0] = '\0';
fl->cData = NULL;
fl->dwSize = 0;
anyFileDeleted = TRUE;
}
fl = fl->lpNext;
} while (fl!=NULL);
// Go to next file to be delete
while(*DeleteList) DeleteList++;
DeleteList++;
}
if (anyFileDeleted) {
// Save file without deleted blocks
fout = _wfopen(PackedFile, L"wb");
fl = lpH->lpFileListHead;
do {
if (fl->cData != NULL) {
fwrite(CAS_HEADER, 1, CAS_HDR_LEN, fout);
fwrite(fl->cData, 1, fl->dwSize, fout);
}
fl = fl->lpNext;
} while (fl!=NULL);
fclose(fout);
}
FreeCAShandler(lpH);
}
return rc;
}
/*
=====================================================================
Function name : GetPackerCaps
Description : Tells Totalcmd what features packer plugin supports.
Return type : int
*/
int CAS_GetPackerCaps(void)
{
// Return capabilities
return PK_CAPS_NEW|
PK_CAPS_MODIFY|
PK_CAPS_MULTIPLE| // Archive can contain multiple files
PK_CAPS_DELETE; // Can delete files
}
| 25.729981 | 96 | 0.606933 |
c7bbb3ffa064a6aa66991605b37a749f0fcbce5d | 1,515 | py | Python | core/lib/constant.py | duruyi/OnlineSchemaChange | 5434cfd17a7fc7be85625f87745c8cb9be674167 | [
"BSD-3-Clause"
] | 949 | 2017-05-05T17:15:25.000Z | 2022-03-30T19:12:19.000Z | core/lib/constant.py | duruyi/OnlineSchemaChange | 5434cfd17a7fc7be85625f87745c8cb9be674167 | [
"BSD-3-Clause"
] | 31 | 2017-05-05T23:04:19.000Z | 2022-03-04T05:17:19.000Z | core/lib/constant.py | duruyi/OnlineSchemaChange | 5434cfd17a7fc7be85625f87745c8cb9be674167 | [
"BSD-3-Clause"
] | 159 | 2017-05-05T20:22:15.000Z | 2022-03-26T05:47:31.000Z | #!/usr/bin/env python3
"""
Copyright (c) 2017-present, Facebook, Inc.
All rights reserved.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree.
"""
PREFIX = "__osc_"
OUTFILE_TABLE = "__osc_tbl_"
OUTFILE_EXCLUDE_ID = "__osc_ex_"
OUTFILE_INCLUDE_ID = "__osc_in_"
NEW_TABLE_PREFIX = "__osc_new_"
DELTA_TABLE_PREFIX = "__osc_chg_"
RENAMED_TABLE_PREFIX = "__osc_old_"
INSERT_TRIGGER_PREFIX = "__osc_ins_"
UPDATE_TRIGGER_PREFIX = "__osc_upd_"
DELETE_TRIGGER_PREFIX = "__osc_del_"
# tables with 64 character length names need a generic place-holder name
GENERIC_TABLE_NAME = "online_schema_change_temp_tbl"
# Special prefixes for tables that have longer table names
SHORT_NEW_TABLE_PREFIX = "n!"
SHORT_DELTA_TABLE_PREFIX = "c!"
SHORT_RENAMED_TABLE_PREFIX = "o!"
SHORT_INSERT_TRIGGER_PREFIX = "i!"
SHORT_UPDATE_TRIGGER_PREFIX = "u!"
SHORT_DELETE_TRIGGER_PREFIX = "d!"
OSC_LOCK_NAME = "OnlineSchemaChange"
CHUNK_BYTES = 2 * 1024 * 1024
REPLAY_DEFAULT_TIMEOUT = 5 # replay until we can finish in 5 seconds
DEFAULT_BATCH_SIZE = 500
DEFAULT_REPLAY_ATTEMPT = 10
DEFAULT_RESERVED_SPACE_PERCENT = 1
LONG_TRX_TIME = 30
MAX_RUNNING_BEFORE_DDL = 200
DDL_GUARD_ATTEMPTS = 600
LOCK_MAX_ATTEMPTS = 3
LOCK_MAX_WAIT_BEFORE_KILL_SECONDS = 0.5
SESSION_TIMEOUT = 600
DEFAULT_REPLAY_GROUP_SIZE = 200
PK_COVERAGE_SIZE_THRESHOLD = 500 * 1024 * 1024
MAX_WAIT_FOR_SLOW_QUERY = 100
MAX_TABLE_LENGTH = 64
MAX_REPLAY_BATCH_SIZE = 500000
MAX_REPLAY_CHANGES = 2146483647
| 29.705882 | 72 | 0.807921 |
b190a5c1752f9f4a2b60582323ce243c3b560848 | 1,678 | h | C | src/services/ddsi2/code/q_gc.h | agenihorganization/opensplice | 314d3a4538474f2b8e22acffe3c206f4ac38b66b | [
"Apache-2.0"
] | null | null | null | src/services/ddsi2/code/q_gc.h | agenihorganization/opensplice | 314d3a4538474f2b8e22acffe3c206f4ac38b66b | [
"Apache-2.0"
] | null | null | null | src/services/ddsi2/code/q_gc.h | agenihorganization/opensplice | 314d3a4538474f2b8e22acffe3c206f4ac38b66b | [
"Apache-2.0"
] | null | null | null | /*
* OpenSplice DDS
*
* This software and documentation are Copyright 2006 to TO_YEAR PrismTech
* Limited, its affiliated companies and licensors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef Q_GC_H
#define Q_GC_H
#include "q_thread.h"
#if defined (__cplusplus)
extern "C" {
#endif
struct gcreq;
struct gcreq_queue;
struct writer;
struct reader;
struct proxy_writer;
struct proxy_reader;
typedef void (*gcreq_cb_t) (struct gcreq *gcreq);
struct idx_vtime {
unsigned idx;
vtime_t vtime;
};
struct gcreq {
struct gcreq *next;
struct gcreq_queue *queue;
gcreq_cb_t cb;
void *arg;
unsigned nvtimes;
struct idx_vtime vtimes[1 /* really a flex ary */];
};
struct gcreq_queue *gcreq_queue_new (void);
void gcreq_queue_free (struct gcreq_queue *q);
struct gcreq *gcreq_new (struct gcreq_queue *gcreq_queue, gcreq_cb_t cb);
void gcreq_free (struct gcreq *gcreq);
void gcreq_enqueue (struct gcreq *gcreq);
int gcreq_requeue (struct gcreq *gcreq, gcreq_cb_t cb);
#if defined (__cplusplus)
}
#endif
#endif /* Q_GC_H */
/* SHA1 not available (unoffical build.) */
| 24.676471 | 77 | 0.720501 |
6917277406e20170b2cc97e87e7720012e17fb78 | 975 | swift | Swift | BillionWallet/Data+Hex.swift | Billionapp/billion-wallet-ios | f9c96e78e10b4b191497f433bdb171021db226dc | [
"MIT"
] | 18 | 2017-11-03T23:46:09.000Z | 2021-11-11T07:59:17.000Z | BillionWallet/Data+Hex.swift | Billionapp/billion-wallet-ios | f9c96e78e10b4b191497f433bdb171021db226dc | [
"MIT"
] | null | null | null | BillionWallet/Data+Hex.swift | Billionapp/billion-wallet-ios | f9c96e78e10b4b191497f433bdb171021db226dc | [
"MIT"
] | 5 | 2018-02-15T13:45:20.000Z | 2022-02-21T06:52:26.000Z | //
// Data+Hex.swift
// BillionWallet
//
// Created by Evolution Group Ltd on 13/04/2018.
// Copyright © 2018 Evolution Group Ltd. All rights reserved.
//
import UIKit
// MARK: VIP
extension Data {
init(hex string: String) {
self.init()
let string = string.replacingOccurrences(of: " ", with: "").replacingOccurrences(of: "\n", with: "").replacingOccurrences(of: "\t", with: "")
if string.count % 2 != 0 {
return
}
let re = try! NSRegularExpression(pattern: "[0-9a-f]{2}", options: .caseInsensitive)
re.enumerateMatches(in: string, range: NSMakeRange(0, string.utf16.count)) { match, flags, stop in
let byteString = (string as NSString).substring(with: match!.range)
guard let byte = UInt8(byteString, radix: 16) else { return }
self.append(byte)
}
}
var hex: String {
return self.map { String(format: "%02hhx", $0) }.joined()
}
}
| 30.46875 | 149 | 0.591795 |
eaaf37b66fcc762112e9688d80d195c1854ee793 | 684 | kt | Kotlin | src/main/kotlin/com/claygillman/kbehaviortree/nodes/SucceederNode.kt | clay07g/kBehaviorTree | bb87dec4a4433183d625d4b59a5be30bd6e449af | [
"MIT"
] | null | null | null | src/main/kotlin/com/claygillman/kbehaviortree/nodes/SucceederNode.kt | clay07g/kBehaviorTree | bb87dec4a4433183d625d4b59a5be30bd6e449af | [
"MIT"
] | null | null | null | src/main/kotlin/com/claygillman/kbehaviortree/nodes/SucceederNode.kt | clay07g/kBehaviorTree | bb87dec4a4433183d625d4b59a5be30bd6e449af | [
"MIT"
] | null | null | null | package com.claygillman.kbehaviortree.nodes
import com.claygillman.kbehaviortree.BehaviorTreeStatus
import com.claygillman.kbehaviortree.Decorator
/**
* Decorator Node
* A succeeder node's tick always reports success regardless of the actual result of its child
*/
class SucceederNode(private var _name: String = "") : Decorator() {
override var name: String
get() = "[Succeeder] $_name"
set(n) {
this._name = n
}
override fun tick(): BehaviorTreeStatus {
if (child == null)
throw RuntimeException("Succeeder node ($name) has no children")
child!!.tick()
return BehaviorTreeStatus.SUCCESS
}
} | 27.36 | 94 | 0.666667 |
9c3689a62d37666f4010fbfa2aad039f7a5ad31b | 54,911 | asm | Assembly | wc.asm | Alpr1010/cpsc405 | d071f61d11f02cd43eb09deeb793e84bde7b8a2d | [
"MIT-0"
] | null | null | null | wc.asm | Alpr1010/cpsc405 | d071f61d11f02cd43eb09deeb793e84bde7b8a2d | [
"MIT-0"
] | null | null | null | wc.asm | Alpr1010/cpsc405 | d071f61d11f02cd43eb09deeb793e84bde7b8a2d | [
"MIT-0"
] | null | null | null |
_wc: file format elf32-i386
Disassembly of section .text:
00001000 <main>:
printf(1, "%d %d %d %s\n", l, w, c, name);
}
int
main(int argc, char *argv[])
{
1000: 8d 4c 24 04 lea 0x4(%esp),%ecx
1004: 83 e4 f0 and $0xfffffff0,%esp
1007: ff 71 fc pushl -0x4(%ecx)
100a: 55 push %ebp
100b: 89 e5 mov %esp,%ebp
100d: 57 push %edi
100e: 56 push %esi
100f: 53 push %ebx
1010: 51 push %ecx
1011: be 01 00 00 00 mov $0x1,%esi
1016: 83 ec 18 sub $0x18,%esp
1019: 8b 01 mov (%ecx),%eax
101b: 8b 59 04 mov 0x4(%ecx),%ebx
101e: 83 c3 04 add $0x4,%ebx
int fd, i;
if(argc <= 1){
1021: 83 f8 01 cmp $0x1,%eax
printf(1, "%d %d %d %s\n", l, w, c, name);
}
int
main(int argc, char *argv[])
{
1024: 89 45 e4 mov %eax,-0x1c(%ebp)
int fd, i;
if(argc <= 1){
1027: 7e 56 jle 107f <main+0x7f>
1029: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
wc(0, "");
exit();
}
for(i = 1; i < argc; i++){
if((fd = open(argv[i], 0)) < 0){
1030: 83 ec 08 sub $0x8,%esp
1033: 6a 00 push $0x0
1035: ff 33 pushl (%ebx)
1037: e8 c6 03 00 00 call 1402 <open>
103c: 83 c4 10 add $0x10,%esp
103f: 85 c0 test %eax,%eax
1041: 89 c7 mov %eax,%edi
1043: 78 26 js 106b <main+0x6b>
printf(1, "wc: cannot open %s\n", argv[i]);
exit();
}
wc(fd, argv[i]);
1045: 83 ec 08 sub $0x8,%esp
1048: ff 33 pushl (%ebx)
if(argc <= 1){
wc(0, "");
exit();
}
for(i = 1; i < argc; i++){
104a: 83 c6 01 add $0x1,%esi
if((fd = open(argv[i], 0)) < 0){
printf(1, "wc: cannot open %s\n", argv[i]);
exit();
}
wc(fd, argv[i]);
104d: 50 push %eax
104e: 83 c3 04 add $0x4,%ebx
1051: e8 4a 00 00 00 call 10a0 <wc>
close(fd);
1056: 89 3c 24 mov %edi,(%esp)
1059: e8 8c 03 00 00 call 13ea <close>
if(argc <= 1){
wc(0, "");
exit();
}
for(i = 1; i < argc; i++){
105e: 83 c4 10 add $0x10,%esp
1061: 39 75 e4 cmp %esi,-0x1c(%ebp)
1064: 75 ca jne 1030 <main+0x30>
exit();
}
wc(fd, argv[i]);
close(fd);
}
exit();
1066: e8 57 03 00 00 call 13c2 <exit>
exit();
}
for(i = 1; i < argc; i++){
if((fd = open(argv[i], 0)) < 0){
printf(1, "wc: cannot open %s\n", argv[i]);
106b: 50 push %eax
106c: ff 33 pushl (%ebx)
106e: 68 63 18 00 00 push $0x1863
1073: 6a 01 push $0x1
1075: e8 a6 04 00 00 call 1520 <printf>
exit();
107a: e8 43 03 00 00 call 13c2 <exit>
main(int argc, char *argv[])
{
int fd, i;
if(argc <= 1){
wc(0, "");
107f: 52 push %edx
1080: 52 push %edx
1081: 68 55 18 00 00 push $0x1855
1086: 6a 00 push $0x0
1088: e8 13 00 00 00 call 10a0 <wc>
exit();
108d: e8 30 03 00 00 call 13c2 <exit>
1092: 66 90 xchg %ax,%ax
1094: 66 90 xchg %ax,%ax
1096: 66 90 xchg %ax,%ax
1098: 66 90 xchg %ax,%ax
109a: 66 90 xchg %ax,%ax
109c: 66 90 xchg %ax,%ax
109e: 66 90 xchg %ax,%ax
000010a0 <wc>:
char buf[512];
void
wc(int fd, char *name)
{
10a0: 55 push %ebp
10a1: 89 e5 mov %esp,%ebp
10a3: 57 push %edi
10a4: 56 push %esi
10a5: 53 push %ebx
int i, n;
int l, w, c, inword;
l = w = c = 0;
inword = 0;
10a6: 31 f6 xor %esi,%esi
wc(int fd, char *name)
{
int i, n;
int l, w, c, inword;
l = w = c = 0;
10a8: 31 db xor %ebx,%ebx
char buf[512];
void
wc(int fd, char *name)
{
10aa: 83 ec 1c sub $0x1c,%esp
int i, n;
int l, w, c, inword;
l = w = c = 0;
10ad: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp)
10b4: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp)
10bb: 90 nop
10bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
inword = 0;
while((n = read(fd, buf, sizeof(buf))) > 0){
10c0: 83 ec 04 sub $0x4,%esp
10c3: 68 00 02 00 00 push $0x200
10c8: 68 80 1b 00 00 push $0x1b80
10cd: ff 75 08 pushl 0x8(%ebp)
10d0: e8 05 03 00 00 call 13da <read>
10d5: 83 c4 10 add $0x10,%esp
10d8: 83 f8 00 cmp $0x0,%eax
10db: 89 45 e4 mov %eax,-0x1c(%ebp)
10de: 7e 5f jle 113f <wc+0x9f>
10e0: 31 ff xor %edi,%edi
10e2: eb 0e jmp 10f2 <wc+0x52>
10e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(i=0; i<n; i++){
c++;
if(buf[i] == '\n')
l++;
if(strchr(" \r\t\n\v", buf[i]))
inword = 0;
10e8: 31 f6 xor %esi,%esi
int l, w, c, inword;
l = w = c = 0;
inword = 0;
while((n = read(fd, buf, sizeof(buf))) > 0){
for(i=0; i<n; i++){
10ea: 83 c7 01 add $0x1,%edi
10ed: 39 7d e4 cmp %edi,-0x1c(%ebp)
10f0: 74 3a je 112c <wc+0x8c>
c++;
if(buf[i] == '\n')
10f2: 0f be 87 80 1b 00 00 movsbl 0x1b80(%edi),%eax
l++;
10f9: 31 c9 xor %ecx,%ecx
10fb: 3c 0a cmp $0xa,%al
10fd: 0f 94 c1 sete %cl
if(strchr(" \r\t\n\v", buf[i]))
1100: 83 ec 08 sub $0x8,%esp
1103: 50 push %eax
1104: 68 40 18 00 00 push $0x1840
inword = 0;
while((n = read(fd, buf, sizeof(buf))) > 0){
for(i=0; i<n; i++){
c++;
if(buf[i] == '\n')
l++;
1109: 01 cb add %ecx,%ebx
if(strchr(" \r\t\n\v", buf[i]))
110b: e8 40 01 00 00 call 1250 <strchr>
1110: 83 c4 10 add $0x10,%esp
1113: 85 c0 test %eax,%eax
1115: 75 d1 jne 10e8 <wc+0x48>
inword = 0;
else if(!inword){
1117: 85 f6 test %esi,%esi
1119: 75 1d jne 1138 <wc+0x98>
w++;
111b: 83 45 e0 01 addl $0x1,-0x20(%ebp)
int l, w, c, inword;
l = w = c = 0;
inword = 0;
while((n = read(fd, buf, sizeof(buf))) > 0){
for(i=0; i<n; i++){
111f: 83 c7 01 add $0x1,%edi
1122: 39 7d e4 cmp %edi,-0x1c(%ebp)
l++;
if(strchr(" \r\t\n\v", buf[i]))
inword = 0;
else if(!inword){
w++;
inword = 1;
1125: be 01 00 00 00 mov $0x1,%esi
int l, w, c, inword;
l = w = c = 0;
inword = 0;
while((n = read(fd, buf, sizeof(buf))) > 0){
for(i=0; i<n; i++){
112a: 75 c6 jne 10f2 <wc+0x52>
112c: 8b 55 e4 mov -0x1c(%ebp),%edx
112f: 01 55 dc add %edx,-0x24(%ebp)
1132: eb 8c jmp 10c0 <wc+0x20>
1134: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1138: be 01 00 00 00 mov $0x1,%esi
113d: eb ab jmp 10ea <wc+0x4a>
w++;
inword = 1;
}
}
}
if(n < 0){
113f: 75 24 jne 1165 <wc+0xc5>
printf(1, "wc: read error\n");
exit();
}
printf(1, "%d %d %d %s\n", l, w, c, name);
1141: 83 ec 08 sub $0x8,%esp
1144: ff 75 0c pushl 0xc(%ebp)
1147: ff 75 dc pushl -0x24(%ebp)
114a: ff 75 e0 pushl -0x20(%ebp)
114d: 53 push %ebx
114e: 68 56 18 00 00 push $0x1856
1153: 6a 01 push $0x1
1155: e8 c6 03 00 00 call 1520 <printf>
}
115a: 83 c4 20 add $0x20,%esp
115d: 8d 65 f4 lea -0xc(%ebp),%esp
1160: 5b pop %ebx
1161: 5e pop %esi
1162: 5f pop %edi
1163: 5d pop %ebp
1164: c3 ret
inword = 1;
}
}
}
if(n < 0){
printf(1, "wc: read error\n");
1165: 83 ec 08 sub $0x8,%esp
1168: 68 46 18 00 00 push $0x1846
116d: 6a 01 push $0x1
116f: e8 ac 03 00 00 call 1520 <printf>
exit();
1174: e8 49 02 00 00 call 13c2 <exit>
1179: 66 90 xchg %ax,%ax
117b: 66 90 xchg %ax,%ax
117d: 66 90 xchg %ax,%ax
117f: 90 nop
00001180 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
1180: 55 push %ebp
1181: 89 e5 mov %esp,%ebp
1183: 53 push %ebx
1184: 8b 45 08 mov 0x8(%ebp),%eax
1187: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
118a: 89 c2 mov %eax,%edx
118c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1190: 83 c1 01 add $0x1,%ecx
1193: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
1197: 83 c2 01 add $0x1,%edx
119a: 84 db test %bl,%bl
119c: 88 5a ff mov %bl,-0x1(%edx)
119f: 75 ef jne 1190 <strcpy+0x10>
;
return os;
}
11a1: 5b pop %ebx
11a2: 5d pop %ebp
11a3: c3 ret
11a4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
11aa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
000011b0 <strcmp>:
int
strcmp(const char *p, const char *q)
{
11b0: 55 push %ebp
11b1: 89 e5 mov %esp,%ebp
11b3: 56 push %esi
11b4: 53 push %ebx
11b5: 8b 55 08 mov 0x8(%ebp),%edx
11b8: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
11bb: 0f b6 02 movzbl (%edx),%eax
11be: 0f b6 19 movzbl (%ecx),%ebx
11c1: 84 c0 test %al,%al
11c3: 75 1e jne 11e3 <strcmp+0x33>
11c5: eb 29 jmp 11f0 <strcmp+0x40>
11c7: 89 f6 mov %esi,%esi
11c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
11d0: 83 c2 01 add $0x1,%edx
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
11d3: 0f b6 02 movzbl (%edx),%eax
p++, q++;
11d6: 8d 71 01 lea 0x1(%ecx),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
11d9: 0f b6 59 01 movzbl 0x1(%ecx),%ebx
11dd: 84 c0 test %al,%al
11df: 74 0f je 11f0 <strcmp+0x40>
11e1: 89 f1 mov %esi,%ecx
11e3: 38 d8 cmp %bl,%al
11e5: 74 e9 je 11d0 <strcmp+0x20>
p++, q++;
return (uchar)*p - (uchar)*q;
11e7: 29 d8 sub %ebx,%eax
}
11e9: 5b pop %ebx
11ea: 5e pop %esi
11eb: 5d pop %ebp
11ec: c3 ret
11ed: 8d 76 00 lea 0x0(%esi),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
11f0: 31 c0 xor %eax,%eax
p++, q++;
return (uchar)*p - (uchar)*q;
11f2: 29 d8 sub %ebx,%eax
}
11f4: 5b pop %ebx
11f5: 5e pop %esi
11f6: 5d pop %ebp
11f7: c3 ret
11f8: 90 nop
11f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00001200 <strlen>:
uint
strlen(char *s)
{
1200: 55 push %ebp
1201: 89 e5 mov %esp,%ebp
1203: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
1206: 80 39 00 cmpb $0x0,(%ecx)
1209: 74 12 je 121d <strlen+0x1d>
120b: 31 d2 xor %edx,%edx
120d: 8d 76 00 lea 0x0(%esi),%esi
1210: 83 c2 01 add $0x1,%edx
1213: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
1217: 89 d0 mov %edx,%eax
1219: 75 f5 jne 1210 <strlen+0x10>
;
return n;
}
121b: 5d pop %ebp
121c: c3 ret
uint
strlen(char *s)
{
int n;
for(n = 0; s[n]; n++)
121d: 31 c0 xor %eax,%eax
;
return n;
}
121f: 5d pop %ebp
1220: c3 ret
1221: eb 0d jmp 1230 <memset>
1223: 90 nop
1224: 90 nop
1225: 90 nop
1226: 90 nop
1227: 90 nop
1228: 90 nop
1229: 90 nop
122a: 90 nop
122b: 90 nop
122c: 90 nop
122d: 90 nop
122e: 90 nop
122f: 90 nop
00001230 <memset>:
void*
memset(void *dst, int c, uint n)
{
1230: 55 push %ebp
1231: 89 e5 mov %esp,%ebp
1233: 57 push %edi
1234: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
1237: 8b 4d 10 mov 0x10(%ebp),%ecx
123a: 8b 45 0c mov 0xc(%ebp),%eax
123d: 89 d7 mov %edx,%edi
123f: fc cld
1240: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
1242: 89 d0 mov %edx,%eax
1244: 5f pop %edi
1245: 5d pop %ebp
1246: c3 ret
1247: 89 f6 mov %esi,%esi
1249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00001250 <strchr>:
char*
strchr(const char *s, char c)
{
1250: 55 push %ebp
1251: 89 e5 mov %esp,%ebp
1253: 53 push %ebx
1254: 8b 45 08 mov 0x8(%ebp),%eax
1257: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
125a: 0f b6 10 movzbl (%eax),%edx
125d: 84 d2 test %dl,%dl
125f: 74 1d je 127e <strchr+0x2e>
if(*s == c)
1261: 38 d3 cmp %dl,%bl
1263: 89 d9 mov %ebx,%ecx
1265: 75 0d jne 1274 <strchr+0x24>
1267: eb 17 jmp 1280 <strchr+0x30>
1269: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1270: 38 ca cmp %cl,%dl
1272: 74 0c je 1280 <strchr+0x30>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
1274: 83 c0 01 add $0x1,%eax
1277: 0f b6 10 movzbl (%eax),%edx
127a: 84 d2 test %dl,%dl
127c: 75 f2 jne 1270 <strchr+0x20>
if(*s == c)
return (char*)s;
return 0;
127e: 31 c0 xor %eax,%eax
}
1280: 5b pop %ebx
1281: 5d pop %ebp
1282: c3 ret
1283: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1289: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00001290 <gets>:
char*
gets(char *buf, int max)
{
1290: 55 push %ebp
1291: 89 e5 mov %esp,%ebp
1293: 57 push %edi
1294: 56 push %esi
1295: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
1296: 31 f6 xor %esi,%esi
cc = read(0, &c, 1);
1298: 8d 7d e7 lea -0x19(%ebp),%edi
return 0;
}
char*
gets(char *buf, int max)
{
129b: 83 ec 1c sub $0x1c,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
129e: eb 29 jmp 12c9 <gets+0x39>
cc = read(0, &c, 1);
12a0: 83 ec 04 sub $0x4,%esp
12a3: 6a 01 push $0x1
12a5: 57 push %edi
12a6: 6a 00 push $0x0
12a8: e8 2d 01 00 00 call 13da <read>
if(cc < 1)
12ad: 83 c4 10 add $0x10,%esp
12b0: 85 c0 test %eax,%eax
12b2: 7e 1d jle 12d1 <gets+0x41>
break;
buf[i++] = c;
12b4: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
12b8: 8b 55 08 mov 0x8(%ebp),%edx
12bb: 89 de mov %ebx,%esi
if(c == '\n' || c == '\r')
12bd: 3c 0a cmp $0xa,%al
for(i=0; i+1 < max; ){
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
12bf: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1)
if(c == '\n' || c == '\r')
12c3: 74 1b je 12e0 <gets+0x50>
12c5: 3c 0d cmp $0xd,%al
12c7: 74 17 je 12e0 <gets+0x50>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
12c9: 8d 5e 01 lea 0x1(%esi),%ebx
12cc: 3b 5d 0c cmp 0xc(%ebp),%ebx
12cf: 7c cf jl 12a0 <gets+0x10>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
12d1: 8b 45 08 mov 0x8(%ebp),%eax
12d4: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
12d8: 8d 65 f4 lea -0xc(%ebp),%esp
12db: 5b pop %ebx
12dc: 5e pop %esi
12dd: 5f pop %edi
12de: 5d pop %ebp
12df: c3 ret
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
12e0: 8b 45 08 mov 0x8(%ebp),%eax
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
12e3: 89 de mov %ebx,%esi
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
12e5: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
12e9: 8d 65 f4 lea -0xc(%ebp),%esp
12ec: 5b pop %ebx
12ed: 5e pop %esi
12ee: 5f pop %edi
12ef: 5d pop %ebp
12f0: c3 ret
12f1: eb 0d jmp 1300 <stat>
12f3: 90 nop
12f4: 90 nop
12f5: 90 nop
12f6: 90 nop
12f7: 90 nop
12f8: 90 nop
12f9: 90 nop
12fa: 90 nop
12fb: 90 nop
12fc: 90 nop
12fd: 90 nop
12fe: 90 nop
12ff: 90 nop
00001300 <stat>:
int
stat(char *n, struct stat *st)
{
1300: 55 push %ebp
1301: 89 e5 mov %esp,%ebp
1303: 56 push %esi
1304: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
1305: 83 ec 08 sub $0x8,%esp
1308: 6a 00 push $0x0
130a: ff 75 08 pushl 0x8(%ebp)
130d: e8 f0 00 00 00 call 1402 <open>
if(fd < 0)
1312: 83 c4 10 add $0x10,%esp
1315: 85 c0 test %eax,%eax
1317: 78 27 js 1340 <stat+0x40>
return -1;
r = fstat(fd, st);
1319: 83 ec 08 sub $0x8,%esp
131c: ff 75 0c pushl 0xc(%ebp)
131f: 89 c3 mov %eax,%ebx
1321: 50 push %eax
1322: e8 f3 00 00 00 call 141a <fstat>
1327: 89 c6 mov %eax,%esi
close(fd);
1329: 89 1c 24 mov %ebx,(%esp)
132c: e8 b9 00 00 00 call 13ea <close>
return r;
1331: 83 c4 10 add $0x10,%esp
1334: 89 f0 mov %esi,%eax
}
1336: 8d 65 f8 lea -0x8(%ebp),%esp
1339: 5b pop %ebx
133a: 5e pop %esi
133b: 5d pop %ebp
133c: c3 ret
133d: 8d 76 00 lea 0x0(%esi),%esi
int fd;
int r;
fd = open(n, O_RDONLY);
if(fd < 0)
return -1;
1340: b8 ff ff ff ff mov $0xffffffff,%eax
1345: eb ef jmp 1336 <stat+0x36>
1347: 89 f6 mov %esi,%esi
1349: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00001350 <atoi>:
return r;
}
int
atoi(const char *s)
{
1350: 55 push %ebp
1351: 89 e5 mov %esp,%ebp
1353: 53 push %ebx
1354: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
1357: 0f be 11 movsbl (%ecx),%edx
135a: 8d 42 d0 lea -0x30(%edx),%eax
135d: 3c 09 cmp $0x9,%al
135f: b8 00 00 00 00 mov $0x0,%eax
1364: 77 1f ja 1385 <atoi+0x35>
1366: 8d 76 00 lea 0x0(%esi),%esi
1369: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
1370: 8d 04 80 lea (%eax,%eax,4),%eax
1373: 83 c1 01 add $0x1,%ecx
1376: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
137a: 0f be 11 movsbl (%ecx),%edx
137d: 8d 5a d0 lea -0x30(%edx),%ebx
1380: 80 fb 09 cmp $0x9,%bl
1383: 76 eb jbe 1370 <atoi+0x20>
n = n*10 + *s++ - '0';
return n;
}
1385: 5b pop %ebx
1386: 5d pop %ebp
1387: c3 ret
1388: 90 nop
1389: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00001390 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
1390: 55 push %ebp
1391: 89 e5 mov %esp,%ebp
1393: 56 push %esi
1394: 53 push %ebx
1395: 8b 5d 10 mov 0x10(%ebp),%ebx
1398: 8b 45 08 mov 0x8(%ebp),%eax
139b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
139e: 85 db test %ebx,%ebx
13a0: 7e 14 jle 13b6 <memmove+0x26>
13a2: 31 d2 xor %edx,%edx
13a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
13a8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
13ac: 88 0c 10 mov %cl,(%eax,%edx,1)
13af: 83 c2 01 add $0x1,%edx
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
13b2: 39 da cmp %ebx,%edx
13b4: 75 f2 jne 13a8 <memmove+0x18>
*dst++ = *src++;
return vdst;
}
13b6: 5b pop %ebx
13b7: 5e pop %esi
13b8: 5d pop %ebp
13b9: c3 ret
000013ba <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
13ba: b8 01 00 00 00 mov $0x1,%eax
13bf: cd 40 int $0x40
13c1: c3 ret
000013c2 <exit>:
SYSCALL(exit)
13c2: b8 02 00 00 00 mov $0x2,%eax
13c7: cd 40 int $0x40
13c9: c3 ret
000013ca <wait>:
SYSCALL(wait)
13ca: b8 03 00 00 00 mov $0x3,%eax
13cf: cd 40 int $0x40
13d1: c3 ret
000013d2 <pipe>:
SYSCALL(pipe)
13d2: b8 04 00 00 00 mov $0x4,%eax
13d7: cd 40 int $0x40
13d9: c3 ret
000013da <read>:
SYSCALL(read)
13da: b8 05 00 00 00 mov $0x5,%eax
13df: cd 40 int $0x40
13e1: c3 ret
000013e2 <write>:
SYSCALL(write)
13e2: b8 10 00 00 00 mov $0x10,%eax
13e7: cd 40 int $0x40
13e9: c3 ret
000013ea <close>:
SYSCALL(close)
13ea: b8 15 00 00 00 mov $0x15,%eax
13ef: cd 40 int $0x40
13f1: c3 ret
000013f2 <kill>:
SYSCALL(kill)
13f2: b8 06 00 00 00 mov $0x6,%eax
13f7: cd 40 int $0x40
13f9: c3 ret
000013fa <exec>:
SYSCALL(exec)
13fa: b8 07 00 00 00 mov $0x7,%eax
13ff: cd 40 int $0x40
1401: c3 ret
00001402 <open>:
SYSCALL(open)
1402: b8 0f 00 00 00 mov $0xf,%eax
1407: cd 40 int $0x40
1409: c3 ret
0000140a <mknod>:
SYSCALL(mknod)
140a: b8 11 00 00 00 mov $0x11,%eax
140f: cd 40 int $0x40
1411: c3 ret
00001412 <unlink>:
SYSCALL(unlink)
1412: b8 12 00 00 00 mov $0x12,%eax
1417: cd 40 int $0x40
1419: c3 ret
0000141a <fstat>:
SYSCALL(fstat)
141a: b8 08 00 00 00 mov $0x8,%eax
141f: cd 40 int $0x40
1421: c3 ret
00001422 <link>:
SYSCALL(link)
1422: b8 13 00 00 00 mov $0x13,%eax
1427: cd 40 int $0x40
1429: c3 ret
0000142a <mkdir>:
SYSCALL(mkdir)
142a: b8 14 00 00 00 mov $0x14,%eax
142f: cd 40 int $0x40
1431: c3 ret
00001432 <chdir>:
SYSCALL(chdir)
1432: b8 09 00 00 00 mov $0x9,%eax
1437: cd 40 int $0x40
1439: c3 ret
0000143a <dup>:
SYSCALL(dup)
143a: b8 0a 00 00 00 mov $0xa,%eax
143f: cd 40 int $0x40
1441: c3 ret
00001442 <getpid>:
SYSCALL(getpid)
1442: b8 0b 00 00 00 mov $0xb,%eax
1447: cd 40 int $0x40
1449: c3 ret
0000144a <sbrk>:
SYSCALL(sbrk)
144a: b8 0c 00 00 00 mov $0xc,%eax
144f: cd 40 int $0x40
1451: c3 ret
00001452 <sleep>:
SYSCALL(sleep)
1452: b8 0d 00 00 00 mov $0xd,%eax
1457: cd 40 int $0x40
1459: c3 ret
0000145a <uptime>:
SYSCALL(uptime)
145a: b8 0e 00 00 00 mov $0xe,%eax
145f: cd 40 int $0x40
1461: c3 ret
00001462 <getcount>:
SYSCALL(getcount) //added getcount here
1462: b8 16 00 00 00 mov $0x16,%eax
1467: cd 40 int $0x40
1469: c3 ret
0000146a <getprocessinfo>:
SYSCALL(getprocessinfo) //printing all process info
146a: b8 17 00 00 00 mov $0x17,%eax
146f: cd 40 int $0x40
1471: c3 ret
00001472 <increasepriority>:
SYSCALL(increasepriority)
1472: b8 18 00 00 00 mov $0x18,%eax
1477: cd 40 int $0x40
1479: c3 ret
147a: 66 90 xchg %ax,%ax
147c: 66 90 xchg %ax,%ax
147e: 66 90 xchg %ax,%ax
00001480 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
1480: 55 push %ebp
1481: 89 e5 mov %esp,%ebp
1483: 57 push %edi
1484: 56 push %esi
1485: 53 push %ebx
1486: 89 c6 mov %eax,%esi
1488: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
148b: 8b 5d 08 mov 0x8(%ebp),%ebx
148e: 85 db test %ebx,%ebx
1490: 74 7e je 1510 <printint+0x90>
1492: 89 d0 mov %edx,%eax
1494: c1 e8 1f shr $0x1f,%eax
1497: 84 c0 test %al,%al
1499: 74 75 je 1510 <printint+0x90>
neg = 1;
x = -xx;
149b: 89 d0 mov %edx,%eax
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
neg = 1;
149d: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
x = -xx;
14a4: f7 d8 neg %eax
14a6: 89 75 c0 mov %esi,-0x40(%ebp)
} else {
x = xx;
}
i = 0;
14a9: 31 ff xor %edi,%edi
14ab: 8d 5d d7 lea -0x29(%ebp),%ebx
14ae: 89 ce mov %ecx,%esi
14b0: eb 08 jmp 14ba <printint+0x3a>
14b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
do{
buf[i++] = digits[x % base];
14b8: 89 cf mov %ecx,%edi
14ba: 31 d2 xor %edx,%edx
14bc: 8d 4f 01 lea 0x1(%edi),%ecx
14bf: f7 f6 div %esi
14c1: 0f b6 92 80 18 00 00 movzbl 0x1880(%edx),%edx
}while((x /= base) != 0);
14c8: 85 c0 test %eax,%eax
x = xx;
}
i = 0;
do{
buf[i++] = digits[x % base];
14ca: 88 14 0b mov %dl,(%ebx,%ecx,1)
}while((x /= base) != 0);
14cd: 75 e9 jne 14b8 <printint+0x38>
if(neg)
14cf: 8b 45 c4 mov -0x3c(%ebp),%eax
14d2: 8b 75 c0 mov -0x40(%ebp),%esi
14d5: 85 c0 test %eax,%eax
14d7: 74 08 je 14e1 <printint+0x61>
buf[i++] = '-';
14d9: c6 44 0d d8 2d movb $0x2d,-0x28(%ebp,%ecx,1)
14de: 8d 4f 02 lea 0x2(%edi),%ecx
14e1: 8d 7c 0d d7 lea -0x29(%ebp,%ecx,1),%edi
14e5: 8d 76 00 lea 0x0(%esi),%esi
14e8: 0f b6 07 movzbl (%edi),%eax
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
14eb: 83 ec 04 sub $0x4,%esp
14ee: 83 ef 01 sub $0x1,%edi
14f1: 6a 01 push $0x1
14f3: 53 push %ebx
14f4: 56 push %esi
14f5: 88 45 d7 mov %al,-0x29(%ebp)
14f8: e8 e5 fe ff ff call 13e2 <write>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
14fd: 83 c4 10 add $0x10,%esp
1500: 39 df cmp %ebx,%edi
1502: 75 e4 jne 14e8 <printint+0x68>
putc(fd, buf[i]);
}
1504: 8d 65 f4 lea -0xc(%ebp),%esp
1507: 5b pop %ebx
1508: 5e pop %esi
1509: 5f pop %edi
150a: 5d pop %ebp
150b: c3 ret
150c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
if(sgn && xx < 0){
neg = 1;
x = -xx;
} else {
x = xx;
1510: 89 d0 mov %edx,%eax
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
1512: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
1519: eb 8b jmp 14a6 <printint+0x26>
151b: 90 nop
151c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00001520 <printf>:
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
1520: 55 push %ebp
1521: 89 e5 mov %esp,%ebp
1523: 57 push %edi
1524: 56 push %esi
1525: 53 push %ebx
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
1526: 8d 45 10 lea 0x10(%ebp),%eax
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
1529: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
152c: 8b 75 0c mov 0xc(%ebp),%esi
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
152f: 8b 7d 08 mov 0x8(%ebp),%edi
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
1532: 89 45 d0 mov %eax,-0x30(%ebp)
1535: 0f b6 1e movzbl (%esi),%ebx
1538: 83 c6 01 add $0x1,%esi
153b: 84 db test %bl,%bl
153d: 0f 84 b0 00 00 00 je 15f3 <printf+0xd3>
1543: 31 d2 xor %edx,%edx
1545: eb 39 jmp 1580 <printf+0x60>
1547: 89 f6 mov %esi,%esi
1549: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
1550: 83 f8 25 cmp $0x25,%eax
1553: 89 55 d4 mov %edx,-0x2c(%ebp)
state = '%';
1556: ba 25 00 00 00 mov $0x25,%edx
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
155b: 74 18 je 1575 <printf+0x55>
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
155d: 8d 45 e2 lea -0x1e(%ebp),%eax
1560: 83 ec 04 sub $0x4,%esp
1563: 88 5d e2 mov %bl,-0x1e(%ebp)
1566: 6a 01 push $0x1
1568: 50 push %eax
1569: 57 push %edi
156a: e8 73 fe ff ff call 13e2 <write>
156f: 8b 55 d4 mov -0x2c(%ebp),%edx
1572: 83 c4 10 add $0x10,%esp
1575: 83 c6 01 add $0x1,%esi
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
1578: 0f b6 5e ff movzbl -0x1(%esi),%ebx
157c: 84 db test %bl,%bl
157e: 74 73 je 15f3 <printf+0xd3>
c = fmt[i] & 0xff;
if(state == 0){
1580: 85 d2 test %edx,%edx
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
1582: 0f be cb movsbl %bl,%ecx
1585: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
1588: 74 c6 je 1550 <printf+0x30>
if(c == '%'){
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
158a: 83 fa 25 cmp $0x25,%edx
158d: 75 e6 jne 1575 <printf+0x55>
if(c == 'd'){
158f: 83 f8 64 cmp $0x64,%eax
1592: 0f 84 f8 00 00 00 je 1690 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
1598: 81 e1 f7 00 00 00 and $0xf7,%ecx
159e: 83 f9 70 cmp $0x70,%ecx
15a1: 74 5d je 1600 <printf+0xe0>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
15a3: 83 f8 73 cmp $0x73,%eax
15a6: 0f 84 84 00 00 00 je 1630 <printf+0x110>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
15ac: 83 f8 63 cmp $0x63,%eax
15af: 0f 84 ea 00 00 00 je 169f <printf+0x17f>
putc(fd, *ap);
ap++;
} else if(c == '%'){
15b5: 83 f8 25 cmp $0x25,%eax
15b8: 0f 84 c2 00 00 00 je 1680 <printf+0x160>
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
15be: 8d 45 e7 lea -0x19(%ebp),%eax
15c1: 83 ec 04 sub $0x4,%esp
15c4: c6 45 e7 25 movb $0x25,-0x19(%ebp)
15c8: 6a 01 push $0x1
15ca: 50 push %eax
15cb: 57 push %edi
15cc: e8 11 fe ff ff call 13e2 <write>
15d1: 83 c4 0c add $0xc,%esp
15d4: 8d 45 e6 lea -0x1a(%ebp),%eax
15d7: 88 5d e6 mov %bl,-0x1a(%ebp)
15da: 6a 01 push $0x1
15dc: 50 push %eax
15dd: 57 push %edi
15de: 83 c6 01 add $0x1,%esi
15e1: e8 fc fd ff ff call 13e2 <write>
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
15e6: 0f b6 5e ff movzbl -0x1(%esi),%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
15ea: 83 c4 10 add $0x10,%esp
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
15ed: 31 d2 xor %edx,%edx
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
15ef: 84 db test %bl,%bl
15f1: 75 8d jne 1580 <printf+0x60>
putc(fd, c);
}
state = 0;
}
}
}
15f3: 8d 65 f4 lea -0xc(%ebp),%esp
15f6: 5b pop %ebx
15f7: 5e pop %esi
15f8: 5f pop %edi
15f9: 5d pop %ebp
15fa: c3 ret
15fb: 90 nop
15fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
1600: 83 ec 0c sub $0xc,%esp
1603: b9 10 00 00 00 mov $0x10,%ecx
1608: 6a 00 push $0x0
160a: 8b 5d d0 mov -0x30(%ebp),%ebx
160d: 89 f8 mov %edi,%eax
160f: 8b 13 mov (%ebx),%edx
1611: e8 6a fe ff ff call 1480 <printint>
ap++;
1616: 89 d8 mov %ebx,%eax
1618: 83 c4 10 add $0x10,%esp
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
161b: 31 d2 xor %edx,%edx
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
ap++;
161d: 83 c0 04 add $0x4,%eax
1620: 89 45 d0 mov %eax,-0x30(%ebp)
1623: e9 4d ff ff ff jmp 1575 <printf+0x55>
1628: 90 nop
1629: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
} else if(c == 's'){
s = (char*)*ap;
1630: 8b 45 d0 mov -0x30(%ebp),%eax
1633: 8b 18 mov (%eax),%ebx
ap++;
1635: 83 c0 04 add $0x4,%eax
1638: 89 45 d0 mov %eax,-0x30(%ebp)
if(s == 0)
s = "(null)";
163b: b8 77 18 00 00 mov $0x1877,%eax
1640: 85 db test %ebx,%ebx
1642: 0f 44 d8 cmove %eax,%ebx
while(*s != 0){
1645: 0f b6 03 movzbl (%ebx),%eax
1648: 84 c0 test %al,%al
164a: 74 23 je 166f <printf+0x14f>
164c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1650: 88 45 e3 mov %al,-0x1d(%ebp)
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
1653: 8d 45 e3 lea -0x1d(%ebp),%eax
1656: 83 ec 04 sub $0x4,%esp
1659: 6a 01 push $0x1
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
165b: 83 c3 01 add $0x1,%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
165e: 50 push %eax
165f: 57 push %edi
1660: e8 7d fd ff ff call 13e2 <write>
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
1665: 0f b6 03 movzbl (%ebx),%eax
1668: 83 c4 10 add $0x10,%esp
166b: 84 c0 test %al,%al
166d: 75 e1 jne 1650 <printf+0x130>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
166f: 31 d2 xor %edx,%edx
1671: e9 ff fe ff ff jmp 1575 <printf+0x55>
1676: 8d 76 00 lea 0x0(%esi),%esi
1679: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
1680: 83 ec 04 sub $0x4,%esp
1683: 88 5d e5 mov %bl,-0x1b(%ebp)
1686: 8d 45 e5 lea -0x1b(%ebp),%eax
1689: 6a 01 push $0x1
168b: e9 4c ff ff ff jmp 15dc <printf+0xbc>
} else {
putc(fd, c);
}
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
1690: 83 ec 0c sub $0xc,%esp
1693: b9 0a 00 00 00 mov $0xa,%ecx
1698: 6a 01 push $0x1
169a: e9 6b ff ff ff jmp 160a <printf+0xea>
169f: 8b 5d d0 mov -0x30(%ebp),%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
16a2: 83 ec 04 sub $0x4,%esp
16a5: 8b 03 mov (%ebx),%eax
16a7: 6a 01 push $0x1
16a9: 88 45 e4 mov %al,-0x1c(%ebp)
16ac: 8d 45 e4 lea -0x1c(%ebp),%eax
16af: 50 push %eax
16b0: 57 push %edi
16b1: e8 2c fd ff ff call 13e2 <write>
16b6: e9 5b ff ff ff jmp 1616 <printf+0xf6>
16bb: 66 90 xchg %ax,%ax
16bd: 66 90 xchg %ax,%ax
16bf: 90 nop
000016c0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
16c0: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
16c1: a1 60 1b 00 00 mov 0x1b60,%eax
static Header base;
static Header *freep;
void
free(void *ap)
{
16c6: 89 e5 mov %esp,%ebp
16c8: 57 push %edi
16c9: 56 push %esi
16ca: 53 push %ebx
16cb: 8b 5d 08 mov 0x8(%ebp),%ebx
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
16ce: 8b 10 mov (%eax),%edx
void
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
16d0: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
16d3: 39 c8 cmp %ecx,%eax
16d5: 73 19 jae 16f0 <free+0x30>
16d7: 89 f6 mov %esi,%esi
16d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
16e0: 39 d1 cmp %edx,%ecx
16e2: 72 1c jb 1700 <free+0x40>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
16e4: 39 d0 cmp %edx,%eax
16e6: 73 18 jae 1700 <free+0x40>
static Header base;
static Header *freep;
void
free(void *ap)
{
16e8: 89 d0 mov %edx,%eax
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
16ea: 39 c8 cmp %ecx,%eax
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
16ec: 8b 10 mov (%eax),%edx
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
16ee: 72 f0 jb 16e0 <free+0x20>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
16f0: 39 d0 cmp %edx,%eax
16f2: 72 f4 jb 16e8 <free+0x28>
16f4: 39 d1 cmp %edx,%ecx
16f6: 73 f0 jae 16e8 <free+0x28>
16f8: 90 nop
16f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
break;
if(bp + bp->s.size == p->s.ptr){
1700: 8b 73 fc mov -0x4(%ebx),%esi
1703: 8d 3c f1 lea (%ecx,%esi,8),%edi
1706: 39 d7 cmp %edx,%edi
1708: 74 19 je 1723 <free+0x63>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
170a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
170d: 8b 50 04 mov 0x4(%eax),%edx
1710: 8d 34 d0 lea (%eax,%edx,8),%esi
1713: 39 f1 cmp %esi,%ecx
1715: 74 23 je 173a <free+0x7a>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
1717: 89 08 mov %ecx,(%eax)
freep = p;
1719: a3 60 1b 00 00 mov %eax,0x1b60
}
171e: 5b pop %ebx
171f: 5e pop %esi
1720: 5f pop %edi
1721: 5d pop %ebp
1722: c3 ret
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
bp->s.size += p->s.ptr->s.size;
1723: 03 72 04 add 0x4(%edx),%esi
1726: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
1729: 8b 10 mov (%eax),%edx
172b: 8b 12 mov (%edx),%edx
172d: 89 53 f8 mov %edx,-0x8(%ebx)
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
1730: 8b 50 04 mov 0x4(%eax),%edx
1733: 8d 34 d0 lea (%eax,%edx,8),%esi
1736: 39 f1 cmp %esi,%ecx
1738: 75 dd jne 1717 <free+0x57>
p->s.size += bp->s.size;
173a: 03 53 fc add -0x4(%ebx),%edx
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
freep = p;
173d: a3 60 1b 00 00 mov %eax,0x1b60
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
p->s.size += bp->s.size;
1742: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
1745: 8b 53 f8 mov -0x8(%ebx),%edx
1748: 89 10 mov %edx,(%eax)
} else
p->s.ptr = bp;
freep = p;
}
174a: 5b pop %ebx
174b: 5e pop %esi
174c: 5f pop %edi
174d: 5d pop %ebp
174e: c3 ret
174f: 90 nop
00001750 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
1750: 55 push %ebp
1751: 89 e5 mov %esp,%ebp
1753: 57 push %edi
1754: 56 push %esi
1755: 53 push %ebx
1756: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1759: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
175c: 8b 15 60 1b 00 00 mov 0x1b60,%edx
malloc(uint nbytes)
{
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1762: 8d 78 07 lea 0x7(%eax),%edi
1765: c1 ef 03 shr $0x3,%edi
1768: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
176b: 85 d2 test %edx,%edx
176d: 0f 84 a3 00 00 00 je 1816 <malloc+0xc6>
1773: 8b 02 mov (%edx),%eax
1775: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
1778: 39 cf cmp %ecx,%edi
177a: 76 74 jbe 17f0 <malloc+0xa0>
177c: 81 ff 00 10 00 00 cmp $0x1000,%edi
1782: be 00 10 00 00 mov $0x1000,%esi
1787: 8d 1c fd 00 00 00 00 lea 0x0(,%edi,8),%ebx
178e: 0f 43 f7 cmovae %edi,%esi
1791: ba 00 80 00 00 mov $0x8000,%edx
1796: 81 ff ff 0f 00 00 cmp $0xfff,%edi
179c: 0f 46 da cmovbe %edx,%ebx
179f: eb 10 jmp 17b1 <malloc+0x61>
17a1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
17a8: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
17aa: 8b 48 04 mov 0x4(%eax),%ecx
17ad: 39 cf cmp %ecx,%edi
17af: 76 3f jbe 17f0 <malloc+0xa0>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
17b1: 39 05 60 1b 00 00 cmp %eax,0x1b60
17b7: 89 c2 mov %eax,%edx
17b9: 75 ed jne 17a8 <malloc+0x58>
char *p;
Header *hp;
if(nu < 4096)
nu = 4096;
p = sbrk(nu * sizeof(Header));
17bb: 83 ec 0c sub $0xc,%esp
17be: 53 push %ebx
17bf: e8 86 fc ff ff call 144a <sbrk>
if(p == (char*)-1)
17c4: 83 c4 10 add $0x10,%esp
17c7: 83 f8 ff cmp $0xffffffff,%eax
17ca: 74 1c je 17e8 <malloc+0x98>
return 0;
hp = (Header*)p;
hp->s.size = nu;
17cc: 89 70 04 mov %esi,0x4(%eax)
free((void*)(hp + 1));
17cf: 83 ec 0c sub $0xc,%esp
17d2: 83 c0 08 add $0x8,%eax
17d5: 50 push %eax
17d6: e8 e5 fe ff ff call 16c0 <free>
return freep;
17db: 8b 15 60 1b 00 00 mov 0x1b60,%edx
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
17e1: 83 c4 10 add $0x10,%esp
17e4: 85 d2 test %edx,%edx
17e6: 75 c0 jne 17a8 <malloc+0x58>
return 0;
17e8: 31 c0 xor %eax,%eax
17ea: eb 1c jmp 1808 <malloc+0xb8>
17ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
if(p->s.size == nunits)
17f0: 39 cf cmp %ecx,%edi
17f2: 74 1c je 1810 <malloc+0xc0>
prevp->s.ptr = p->s.ptr;
else {
p->s.size -= nunits;
17f4: 29 f9 sub %edi,%ecx
17f6: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
17f9: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
17fc: 89 78 04 mov %edi,0x4(%eax)
}
freep = prevp;
17ff: 89 15 60 1b 00 00 mov %edx,0x1b60
return (void*)(p + 1);
1805: 83 c0 08 add $0x8,%eax
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
}
1808: 8d 65 f4 lea -0xc(%ebp),%esp
180b: 5b pop %ebx
180c: 5e pop %esi
180d: 5f pop %edi
180e: 5d pop %ebp
180f: c3 ret
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
if(p->s.size == nunits)
prevp->s.ptr = p->s.ptr;
1810: 8b 08 mov (%eax),%ecx
1812: 89 0a mov %ecx,(%edx)
1814: eb e9 jmp 17ff <malloc+0xaf>
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
1816: c7 05 60 1b 00 00 64 movl $0x1b64,0x1b60
181d: 1b 00 00
1820: c7 05 64 1b 00 00 64 movl $0x1b64,0x1b64
1827: 1b 00 00
base.s.size = 0;
182a: b8 64 1b 00 00 mov $0x1b64,%eax
182f: c7 05 68 1b 00 00 00 movl $0x0,0x1b68
1836: 00 00 00
1839: e9 3e ff ff ff jmp 177c <malloc+0x2c>
| 31.667243 | 63 | 0.404454 |
0d1378a52a855937a57c61ec94a54989db8e8f93 | 158 | kt | Kotlin | appintro/src/main/java/com/github/appintro/indicator/PageIndicatorAnimationType.kt | twentynine78/KeepOn | a801b25ca382dabcba88a9f30e6ef1273459941f | [
"Apache-2.0"
] | 25 | 2019-07-12T08:07:42.000Z | 2022-03-14T23:54:29.000Z | appintro/src/main/java/com/github/appintro/indicator/PageIndicatorAnimationType.kt | twentynine78/KeepOn | a801b25ca382dabcba88a9f30e6ef1273459941f | [
"Apache-2.0"
] | 5 | 2021-01-14T02:18:35.000Z | 2021-12-10T05:51:16.000Z | appintro/src/main/java/com/github/appintro/indicator/PageIndicatorAnimationType.kt | twentynine78/KeepOn | a801b25ca382dabcba88a9f30e6ef1273459941f | [
"Apache-2.0"
] | 2 | 2021-02-18T21:59:38.000Z | 2021-05-15T15:58:49.000Z | package com.github.appintro.indicator
enum class PageIndicatorAnimationType {
NONE, COLOR, SCALE, WORM, SLIDE, FILL, THIN_WORM, DROP, SWAP, SCALE_DOWN
}
| 26.333333 | 76 | 0.772152 |
e9ddf56b8e1306227d244f148c6ee3a03dad08ab | 5,368 | go | Go | webexAPI/methods.go | bluff-kerfuffler/bluff | 6179fee17fb63e16a9e2baf856e5ddefaa390d1e | [
"MIT"
] | null | null | null | webexAPI/methods.go | bluff-kerfuffler/bluff | 6179fee17fb63e16a9e2baf856e5ddefaa390d1e | [
"MIT"
] | null | null | null | webexAPI/methods.go | bluff-kerfuffler/bluff | 6179fee17fb63e16a9e2baf856e5ddefaa390d1e | [
"MIT"
] | null | null | null | package webexAPI
import (
"bytes"
"encoding/json"
"fmt"
"log"
"net/http"
"net/url"
"strconv"
"github.com/gorilla/mux"
"github.com/pkg/errors"
)
type User struct {
Id string
Emails []string
DisplayName string
NickName string
FirstName string
LastName string
Avatar string
OrgId string
Roles []string
Licenses []string
Created string
Timezone string
LastActivity string
// Status
// InvitePending
// LoginEnabled
}
func (b Bot) GetMe() (*User, error) {
res, err := b.Get("people/me", url.Values{})
if err != nil {
return nil, err
}
var u User
d := json.NewDecoder(bytes.NewBuffer(res))
return &u, d.Decode(&u)
}
func (b Bot) GetUser(userId string) (*User, error) {
v := url.Values{}
v.Set("personId", userId)
res, err := b.Get("people/"+userId, v)
if err != nil {
return nil, err
}
var u User
d := json.NewDecoder(bytes.NewBuffer(res))
return &u, d.Decode(&u)
}
type RoomResponse struct {
Items []Room
}
type Room struct {
Id string
Title string
//Type enum
IsLocked bool
TeamId string
LastActivity string
CreatorId string
Created string
}
func (b Bot) GetRooms() (*RoomResponse, error) {
v := url.Values{}
res, err := b.Get("rooms", v)
if err != nil {
return nil, err
}
var rr RoomResponse
d := json.NewDecoder(bytes.NewBuffer(res))
return &rr, d.Decode(&rr)
}
type MessageResponse struct {
Items []Message
}
type Message struct {
Id string
RoomId string
//RoomType enum // group/direct
ToPersonId string // only in direct
ToPersonEmail string // only in direct
Text string
Markdown string
Files []string
PersonId string
MentionedPeople []string
MentionedGroups []string
Created string
}
func (b Bot) GetMessages(roomId string, nMessages int) (*MessageResponse, error) {
v := url.Values{}
v.Set("roomId", roomId)
v.Set("max", strconv.Itoa(nMessages))
res, err := b.Get("messages", v)
if err != nil {
return nil, err
}
var mr MessageResponse
d := json.NewDecoder(bytes.NewBuffer(res))
return &mr, d.Decode(&mr)
}
func (b Bot) SendMessage(roomId string, text string) (*Message, error) {
v := map[string]interface{}{
"roomId": roomId,
"text": text,
}
res, err := b.Post("messages", v)
if err != nil {
return nil, err
}
var m Message
d := json.NewDecoder(bytes.NewBuffer(res))
return &m, d.Decode(&m)
}
func (b Bot) SendMessageMarkdown(roomId string, markdown string) (*Message, error) {
v := map[string]interface{}{
"roomId": roomId,
"markdown": markdown,
}
res, err := b.Post("messages", v)
if err != nil {
return nil, err
}
var m Message
d := json.NewDecoder(bytes.NewBuffer(res))
return &m, d.Decode(&m)
}
func (b Bot) SendPrivateMessage(userId string, text string) (*Message, error) {
v := map[string]interface{}{
"toPersonId": userId,
"text": text,
}
res, err := b.Post("messages", v)
if err != nil {
return nil, err
}
var m Message
d := json.NewDecoder(bytes.NewBuffer(res))
return &m, d.Decode(&m)
}
func (b Bot) SendPrivateMessageMarkdown(userId string, markdown string) (*Message, error) {
v := map[string]interface{}{
"toPersonId": userId,
"markdown": markdown,
}
res, err := b.Post("messages", v)
if err != nil {
return nil, err
}
var m Message
d := json.NewDecoder(bytes.NewBuffer(res))
return &m, d.Decode(&m)
}
type Webhook struct {
Serve string // base url to where you listen
ServePath string // path you listen to
URL string // where you set the webhook to send to
}
type WebHookResponse struct {
Id string
Name string
TargetUrl string
Resource string
Event string
Filter string
Secret string
Status string
Created string
}
func (b Bot) SetFirehoseWebhook(name string, webhook Webhook) (*WebHookResponse, error) {
v := map[string]interface{}{
"name": name,
"targetUrl": webhook.URL + "/" + webhook.ServePath,
"event": "all",
}
res, err := b.Post("webhooks", v)
if err != nil {
return nil, err
}
var w WebHookResponse
d := json.NewDecoder(bytes.NewBuffer(res))
return &w, d.Decode(&w)
}
func (b Bot) AddWebhook(webhook Webhook, mux *mux.Router) {
mux.HandleFunc("/"+webhook.ServePath, func(w http.ResponseWriter, r *http.Request) {
d := json.NewDecoder(r.Body)
var web IncomingWebhookData
err := d.Decode(&web)
if err != nil {
fmt.Println("error decoding incoming webhook data", err)
return
}
b.handleRawUpdate(&web)
})
}
func (b Bot) StartWebhook(webhook Webhook) {
b.AddWebhook(webhook, mux.NewRouter())
go func() {
// todo: TLS when using certs
err := http.ListenAndServe(":443", nil)
if err != nil {
log.Fatal(errors.WithStack(err))
}
}()
}
type Membership struct {
Id string
RoomId string
PersonId string
PersonEmail string
PersonDisplayName string
PersonOrgId string
IsModerator bool
IsMonitor bool
Created string
}
func (b Bot) AddUserToGroup(userId string, roomId string) (*Membership, error) {
v := map[string]interface{}{
"roomId": roomId,
"personId": userId,
}
res, err := b.Post("memberships", v)
if err != nil {
return nil, err
}
var m Membership
d := json.NewDecoder(bytes.NewBuffer(res))
return &m, d.Decode(&m)
}
| 20.333333 | 91 | 0.643256 |
47bf8df4087949c9cf54370d6dcd35a4e61f482c | 474 | hxx | C++ | generated/include/example/CameraSensorClient.hxx | automyinc/vnx-examples | 492423bb8c8447f641e5691f45575056cab396df | [
"MIT"
] | null | null | null | generated/include/example/CameraSensorClient.hxx | automyinc/vnx-examples | 492423bb8c8447f641e5691f45575056cab396df | [
"MIT"
] | null | null | null | generated/include/example/CameraSensorClient.hxx | automyinc/vnx-examples | 492423bb8c8447f641e5691f45575056cab396df | [
"MIT"
] | null | null | null |
// AUTO GENERATED by vnxcppcodegen
#ifndef INCLUDE_example_CameraSensor_CLIENT_HXX_
#define INCLUDE_example_CameraSensor_CLIENT_HXX_
#include <vnx/Client.h>
#include <vnx/Module.h>
#include <vnx/TopicPtr.h>
namespace example {
class CameraSensorClient : public vnx::Client {
public:
CameraSensorClient(const std::string& service_name);
CameraSensorClient(vnx::Hash64 service_addr);
};
} // namespace example
#endif // INCLUDE_example_CameraSensor_CLIENT_HXX_
| 18.230769 | 53 | 0.795359 |
bbbb5fade49e230f7d967c16070831f57126f212 | 320 | kt | Kotlin | app/src/mock/java/br/ufs/hiring/nubankchallenge/factories/WebServiceFactory.kt | ubiratansoares/nubank-challenge | d0b863a338b04ef40068f005c72b9d8e8335bc26 | [
"MIT"
] | 17 | 2018-12-21T08:37:28.000Z | 2021-12-27T20:56:22.000Z | app/src/mock/java/br/ufs/hiring/nubankchallenge/factories/WebServiceFactory.kt | kaioshenrique/nubank-challenge | d0b863a338b04ef40068f005c72b9d8e8335bc26 | [
"MIT"
] | null | null | null | app/src/mock/java/br/ufs/hiring/nubankchallenge/factories/WebServiceFactory.kt | kaioshenrique/nubank-challenge | d0b863a338b04ef40068f005c72b9d8e8335bc26 | [
"MIT"
] | 7 | 2019-01-29T21:40:22.000Z | 2022-02-03T01:45:17.000Z | package br.ufs.hiring.nubankchallenge.factories
import br.ufs.nubankchallenge.core.infrastructure.rest.NubankWebService
import com.nhaarman.mockito_kotlin.mock
/**
*
* Created by @ubiratanfsoares
*
*/
object WebServiceFactory {
val webservice by lazy(LazyThreadSafetyMode.NONE) { mock<NubankWebService>() }
} | 21.333333 | 82 | 0.784375 |
dfce0b6f1224132e78292aa69461ff788c53de9a | 246 | ts | TypeScript | try_2/app11_m/src/single-spa/asset-url-pipe.ts | arnabdas/single-spa-angular-shared-dependency | 7d2da979811850b84b2bd46e4b0265aafd7936bb | [
"Apache-2.0"
] | null | null | null | try_2/app11_m/src/single-spa/asset-url-pipe.ts | arnabdas/single-spa-angular-shared-dependency | 7d2da979811850b84b2bd46e4b0265aafd7936bb | [
"Apache-2.0"
] | null | null | null | try_2/app11_m/src/single-spa/asset-url-pipe.ts | arnabdas/single-spa-angular-shared-dependency | 7d2da979811850b84b2bd46e4b0265aafd7936bb | [
"Apache-2.0"
] | null | null | null | import { Pipe, PipeTransform } from '@angular/core';
import { assetUrl } from './asset-url';
@Pipe({ name: 'assetUrl' })
export class AssetUrlPipe implements PipeTransform {
transform(value: string): string {
return assetUrl(value);
}
}
| 24.6 | 52 | 0.695122 |
8027382377cd642acef94f855bc9f0dfcb6a5cbb | 2,519 | java | Java | TheRent/src/therent/view/reservation/AddRentControl.java | thefoo547/TheRentDesktop | e6c005a30be264a6534b7ddec85c0956eea6d5b6 | [
"BSD-3-Clause"
] | null | null | null | TheRent/src/therent/view/reservation/AddRentControl.java | thefoo547/TheRentDesktop | e6c005a30be264a6534b7ddec85c0956eea6d5b6 | [
"BSD-3-Clause"
] | null | null | null | TheRent/src/therent/view/reservation/AddRentControl.java | thefoo547/TheRentDesktop | e6c005a30be264a6534b7ddec85c0956eea6d5b6 | [
"BSD-3-Clause"
] | 1 | 2019-09-05T03:45:39.000Z | 2019-09-05T03:45:39.000Z | package therent.view.reservation;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXTextField;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.stage.Stage;
import therent.Main;
import therent.control.client.CCliente;
import therent.control.reservation.CRenta;
import therent.model.beans.ClientBean;
public class AddRentControl {
@FXML
private TableView<ClientBean> clientTab;
@FXML
private TableColumn<ClientBean, String> nomCol;
@FXML
private TableColumn<ClientBean, String> cedCol;
@FXML
private JFXButton submitBtn;
@FXML
private JFXButton backBtn;
@FXML
private JFXTextField searchField;
private ObservableList<ClientBean> cl;
private Stage dlgStage;
private Main main;
public void setDlgStage(Stage dlgStage) {
this.dlgStage = dlgStage;
}
public void setMain(Main main) {
this.main = main;
}
public void initialize(){
refreshtable();
nomCol.setCellValueFactory(cd->cd.getValue().nombreProperty());
cedCol.setCellValueFactory(cd->cd.getValue().dniProperty());
searchField.textProperty().addListener(((observable, oldValue, newValue) -> refreshtable()));
}
public void refreshtable(){
try {
this.cl= FXCollections.observableArrayList(CCliente.ovClient(searchField.getText()));
clientTab.setItems(this.cl);
} catch (Exception e) {
msgerr(e.getMessage());
}
}
public void searchTextChanged(){
refreshtable();
}
@FXML
public void handleSubmit(){
if(clientTab.getSelectionModel().getSelectedItem()==null){
msgerr("Por favor seleccione un cliente de la tabla");
return;
}
try {
CRenta.addRenta(clientTab.getSelectionModel().getSelectedItem().getId(), main.getActive_session().getId());
} catch (Exception e) {
msgerr(e.getMessage());
}
dlgStage.close();
}
@FXML
public void handleBack(){
dlgStage.close();
}
private static void msgerr(String msg) {
Alert al=new Alert(Alert.AlertType.ERROR);
al.setTitle("TheRent Link System");
al.setHeaderText("ERROR");
al.setContentText(msg);
al.showAndWait();
}
}
| 25.704082 | 119 | 0.660183 |
5e7e59b411059eacdf7bca5907717d29b0d5bd39 | 446 | dart | Dart | stay_fit/lib/screens/profile_screen.dart | AM1CODES/StayFit | 9f2952bf01cd92b553773abe0813ffa4ec87a93a | [
"MIT"
] | 1 | 2021-07-14T06:57:47.000Z | 2021-07-14T06:57:47.000Z | stay_fit/lib/screens/profile_screen.dart | AM1CODES/StayFit | 9f2952bf01cd92b553773abe0813ffa4ec87a93a | [
"MIT"
] | null | null | null | stay_fit/lib/screens/profile_screen.dart | AM1CODES/StayFit | 9f2952bf01cd92b553773abe0813ffa4ec87a93a | [
"MIT"
] | 3 | 2021-07-11T12:28:23.000Z | 2021-08-10T15:11:23.000Z | import 'package:flutter/material.dart';
import '../widgets/custom_bottom_navbar.dart';
class ProfileScreen extends StatelessWidget {
const ProfileScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Profile'),
),
backgroundColor: Color(0xffffffff),
bottomNavigationBar: CustomBottonNavBar(),
);
}
}
| 23.473684 | 53 | 0.652466 |
b630946aa32fd1e186250b41f368ebf4d77c14cd | 506 | asm | Assembly | programs/oeis/326/A326247.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 22 | 2018-02-06T19:19:31.000Z | 2022-01-17T21:53:31.000Z | programs/oeis/326/A326247.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 41 | 2021-02-22T19:00:34.000Z | 2021-08-28T10:47:47.000Z | programs/oeis/326/A326247.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 5 | 2021-02-24T21:14:16.000Z | 2021-08-09T19:48:05.000Z | ; A326247: Number of labeled n-vertex 2-edge multigraphs that are neither crossing nor nesting.
; 0,0,1,9,32,80,165,301,504,792,1185,1705,2376,3224,4277,5565,7120,8976,11169,13737,16720,20160,24101,28589,33672,39400,45825,53001,60984,69832,79605,90365,102176,115104,129217,144585,161280,179376,198949,220077,242840
mov $2,1
lpb $0
mov $1,$0
mov $0,$2
trn $1,2
seq $1,207064 ; Number of n X 4 0..1 arrays avoiding 0 0 1 and 0 1 0 horizontally and 0 0 1 and 1 0 1 vertically.
lpe
div $1,9
mov $0,$1
| 38.923077 | 218 | 0.731225 |
572459a9096e16b797cc216c29f44164c6047b1a | 171 | c | C | amity5.c | Ankitpal002/Cprogramming | 2dcc2f0c913586e176879e1940e1acb819da5089 | [
"MIT"
] | null | null | null | amity5.c | Ankitpal002/Cprogramming | 2dcc2f0c913586e176879e1940e1acb819da5089 | [
"MIT"
] | null | null | null | amity5.c | Ankitpal002/Cprogramming | 2dcc2f0c913586e176879e1940e1acb819da5089 | [
"MIT"
] | 1 | 2020-10-01T15:37:47.000Z | 2020-10-01T15:37:47.000Z | #include<stdio.h>
void main()
{
float p,r,t,si;
printf("Enter the values respectively:");
scanf("%f%f%f",&p,&r,&t);
si=p*r*t/100;
printf("SI= %f",si);
}
| 17.1 | 42 | 0.54386 |
049257a8b2f245aa69ea13635475e17d9fd4d228 | 2,294 | java | Java | examples/src/main/java/com/example/CryptoPriceSample.java | ethauvin/cryptoprice | 39251ca9671c845334061050ade9f5c9fd2e3db9 | [
"BSD-3-Clause"
] | 1 | 2022-03-05T00:23:51.000Z | 2022-03-05T00:23:51.000Z | examples/src/main/java/com/example/CryptoPriceSample.java | ethauvin/cryptoprice | 39251ca9671c845334061050ade9f5c9fd2e3db9 | [
"BSD-3-Clause"
] | null | null | null | examples/src/main/java/com/example/CryptoPriceSample.java | ethauvin/cryptoprice | 39251ca9671c845334061050ade9f5c9fd2e3db9 | [
"BSD-3-Clause"
] | null | null | null | package com.example;
import net.thauvin.erik.crypto.CryptoException;
import net.thauvin.erik.crypto.CryptoPrice;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
public class CryptoPriceSample {
public static void main(String[] args) {
try {
if (args.length > 0) {
final CryptoPrice price;
if (args.length == 2) {
price = CryptoPrice.spotPrice(args[0], args[1]);
} else {
price = CryptoPrice.spotPrice(args[0]);
}
System.out.println("The current " + price.getBase() + " price is " + price.getAmount() + " in "
+ price.getCurrency());
} else {
// Get current Bitcoin spot price.
final CryptoPrice price = CryptoPrice.spotPrice("BTC");
System.out.println("The current Bitcoin price is " + price.toCurrency());
System.out.println();
// Get current Ethereum spot price in Pound sterling.
final CryptoPrice gbpPrice = CryptoPrice.spotPrice("ETH", "GBP");
System.out.println("The current Ethereum price is " + gbpPrice.toCurrency());
// Get current Litecoin spot price in Euros.
final CryptoPrice euroPrice = CryptoPrice.spotPrice("LTC", "EUR");
System.out.println("The current Litecoin price is " + euroPrice.toCurrency());
System.out.println();
// Get current Bitcoin buy price using API.
// See: https://developers.coinbase.com/api/v2#get-buy-price
final CryptoPrice buyPrice = CryptoPrice
.toPrice(CryptoPrice.apiCall(List.of("prices", "BTC-USD", "buy"), Collections.emptyMap()));
System.out.println("The current " + buyPrice.getBase() + " buy price is " + buyPrice.getAmount()
+ " in " + buyPrice.getCurrency());
}
} catch (CryptoException e) {
System.err.println("HTTP Status Code: " + e.getStatusCode());
System.err.println(e.getMessage());
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
}
| 42.481481 | 115 | 0.555798 |
ac895c00fcf3c2ea397a48601ca883dc261b9d10 | 5,076 | lua | Lua | src/game/weapons/weapons.lua | maksym-pasichnyk/Pipyaki | 98041022f62744254664434eada1f5cdb490ccf1 | [
"Apache-2.0"
] | 1 | 2019-12-09T19:40:05.000Z | 2019-12-09T19:40:05.000Z | src/game/weapons/weapons.lua | max-pasichnyk/Pipyaki | 98041022f62744254664434eada1f5cdb490ccf1 | [
"Apache-2.0"
] | null | null | null | src/game/weapons/weapons.lua | max-pasichnyk/Pipyaki | 98041022f62744254664434eada1f5cdb490ccf1 | [
"Apache-2.0"
] | null | null | null | import 'game/tile/tile'
import 'game/tile/tile-sprite'
import 'general/math/rect'
import 'general/graphics/sprite'
import 'game/inventory'
import 'general/math/vec2'
local random = love.math.random
local function Clip(item, data)
return item.clip or random(0, data.count - 1)
end
TileWeapon = class(TileSprite)
function TileWeapon:new(item, x, y)
local data = item.sprite_data
TileSprite.new(self, data.texture, Clip(item, data), data.w, data.h, x, y, 0, 0, 1)
self.item = item
end
function TileWeapon:onCreate(level)
self:destroy()
end
function TileWeapon:destroy()
local explosion = self.item.explosion
if explosion then
local function start()
self:explosionEvent(explosion.sprite_data)
local parts = explosion.parts
if parts then
end
local decal = explosion.decal
if decal then
local data = decal.sprite_data
local tile = TileSprite(data.texture, Clip(decal, data), data.w, data.h, self.x, self.y, 0, 0, 0)
self.level:addTile('bottom', tile)
-- self.timer:after(decal.time, function()
-- self.level:removeTile(tile)
-- end)
end
end
self.timer:after(self.item.delay or 0, start)
else
self.timer:after(self.item.delay or 0, function()
self.level:removeTile(self)
end)
end
end
function TileWeapon:explosionEvent(data)
local clips = data.count
local frames = clips - 1
local sprite = Sprite.create(data.texture)
for i = 0, frames do
sprite:add(rect(data.w * i, 0, data.w, data.h))
end
self.sprite = sprite
local time = 0
local duration = clips / 30
self.timer:during(duration, function(dt)
local i = math.ceil(frames * math.min(time / duration, 1)) + 1
self.clip = sprite.clips[i]
time = time + dt
end, function()
self.level:removeTile(self)
end)
end
Throwable = class(TileWeapon)
local throw_axis = {
left = vec2(-1, 0),
right = vec2( 1, 0),
up = vec2( 0, -1),
down = vec2( 0, 1)
}
local ThrowableState = enum {
'Move',
'Static'
}
function Throwable:new(item, x, y, direction)
TileWeapon.new(self, item, x, y)
self.axis = throw_axis[direction]
self.power = 300
self.collision = item.collision or 'default'
end
function Throwable:onCreate(level)
self.state = ThrowableState.Move
local collision = self.collision
local start = vec2(self.x, self.y)
local target = start + self.axis * 300
local tween = self.timer:tween(0.6, start, target)
if collision == 'inside' then
local inside = false
local target_x = 0
local target_y = 0
tween.step = function(dt)
local tile_x = start.x / 30
if self.axis.x < 0 then
tile_x = math.floor(tile_x)
elseif self.axis.x > 0 then
tile_x = math.ceil(tile_x)
end
local tile_y = start.y / 30
if self.axis.y < 0 then
tile_y = math.floor(tile_y)
elseif self.axis.y > 0 then
tile_y = math.ceil(tile_y)
end
if inside then
if tile_x == target_x and tile_y == target_y then
self.tile_x = tile_x
self.tile_y = tile_y
self.x = tile_x * 30
self.y = tile_y * 30
self.timer:cancel(tween)
self:destroy()
end
else
inside = not self.level:canWalk(tile_x, tile_y)
if inside then
target_x = tile_x
target_y = tile_y
end
self.tile_x = tile_x
self.tile_y = tile_y
self.x = start.x
self.y = start.y
end
end
else
tween.step = function(dt)
local tile_x = start.x / 30
if self.axis.x < 0 then
tile_x = math.floor(tile_x)
elseif self.axis.x > 0 then
tile_x = math.ceil(tile_x)
end
local tile_y = start.y / 30
if self.axis.y < 0 then
tile_y = math.floor(tile_y)
elseif self.axis.y > 0 then
tile_y = math.ceil(tile_y)
end
if self.level:canWalk(tile_x, tile_y) then
self.tile_x = tile_x
self.tile_y = tile_y
self.x = start.x
self.y = start.y
else
self.x = self.tile_x * 30
self.y = self.tile_y * 30
self.timer:cancel(tween)
self:destroy()
end
end
end
tween.after = function()
self:destroy()
end
-- level.updates:add(self)
end
function Throwable:onRemove(level)
-- level.updates:remove(self)
end | 26.4375 | 113 | 0.535658 |
709be2bf9e7260569d486dc8c2040eb7edc76ac9 | 2,080 | cs | C# | BCManager/src/Commands/LiveData/BCPlayers.cs | kangkang198778/BCM | b2b9d7ad0767e791cb4c34ad68faa9e16e761524 | [
"MIT"
] | null | null | null | BCManager/src/Commands/LiveData/BCPlayers.cs | kangkang198778/BCM | b2b9d7ad0767e791cb4c34ad68faa9e16e761524 | [
"MIT"
] | null | null | null | BCManager/src/Commands/LiveData/BCPlayers.cs | kangkang198778/BCM | b2b9d7ad0767e791cb4c34ad68faa9e16e761524 | [
"MIT"
] | null | null | null | using System.Collections.Generic;
using BCM.Models;
using System.Linq;
namespace BCM.Commands
{
public class BCPlayers : BCCommandAbstract
{
private static void Filters() => SendJson(typeof(BCMPlayer.StrFilters).GetFields()
.ToDictionary(field => field.Name, field => $"{field.GetValue(typeof(BCMPlayer.StrFilters))}"));
private static void Indexed() => SendJson(BCMPlayer.FilterMap
.GroupBy(kvp => kvp.Value)
.Select(group => group.First()).ToDictionary(kvp => kvp.Value, kvp => kvp.Key));
public override void Process()
{
if (GameManager.Instance.World == null)
{
SendOutput("The world isn't loaded");
return;
}
if (Options.ContainsKey("filters"))
{
Filters();
return;
}
if (Options.ContainsKey("index"))
{
Indexed();
return;
}
if (Params.Count > 1)
{
SendOutput("Wrong number of arguments");
SendOutput(Config.GetHelp(GetType().Name));
return;
}
if (Params.Count == 1)
{
//SPECIFIC PLAYER
if (!PlayerStore.GetId(Params[0], out var steamId, "CON")) return;
var player = new BCMPlayer(PlayerData.PlayerInfo(steamId), Options, GetFilters(BCMGameObject.GOTypes.Players));
if (Options.ContainsKey("min"))
{
SendJson(new List<List<object>>
{
player.Data().Select(d => d.Value).ToList()
});
}
else
{
SendJson(player.Data());
}
}
else
{
//ALL PLAYERS
var data = new List<object>();
foreach (var player in PlayerStore.GetAll(Options).Select(s => new BCMPlayer(PlayerData.PlayerInfo(s), Options, GetFilters(BCMGameObject.GOTypes.Players))))
{
if (Options.ContainsKey("min"))
{
data.Add(player.Data().Select(d => d.Value).ToList());
}
else
{
data.Add(player.Data());
}
}
SendJson(data);
}
}
}
}
| 24.186047 | 164 | 0.549038 |
fb90b22a1f00de01cb2b2224bb86589837711f74 | 664 | java | Java | app/src/main/java/com/zhaoxuan/myandroidtraining/activity/RippleEffectActivity.java | zhaoxuan365/my-android-training | 468fed7b199dad86f6f935305862a2f10cbbba04 | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/zhaoxuan/myandroidtraining/activity/RippleEffectActivity.java | zhaoxuan365/my-android-training | 468fed7b199dad86f6f935305862a2f10cbbba04 | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/zhaoxuan/myandroidtraining/activity/RippleEffectActivity.java | zhaoxuan365/my-android-training | 468fed7b199dad86f6f935305862a2f10cbbba04 | [
"Apache-2.0"
] | null | null | null | package com.zhaoxuan.myandroidtraining.activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.zhaoxuan.myandroidtraining.R;
/**
* author : zhaoxuan
* date : 2021/1/13
* desc :
*/
public class RippleEffectActivity extends AppCompatActivity implements View.OnClickListener {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ripple_effect);
}
@Override
public void onClick(View v) {
}
}
| 21.419355 | 93 | 0.751506 |
155fe698294cebf1a23f964df11a3fb17bd49770 | 1,651 | swift | Swift | twitterdemo/Tweet.swift | ntkhoi/TwitterClient | bda7aaf4cff4dd63551bbdc3a0019bc0d4986758 | [
"Apache-2.0"
] | null | null | null | twitterdemo/Tweet.swift | ntkhoi/TwitterClient | bda7aaf4cff4dd63551bbdc3a0019bc0d4986758 | [
"Apache-2.0"
] | 1 | 2017-03-07T13:46:51.000Z | 2017-03-07T13:46:51.000Z | twitterdemo/Tweet.swift | ntkhoi/TwitterClient | bda7aaf4cff4dd63551bbdc3a0019bc0d4986758 | [
"Apache-2.0"
] | null | null | null | //
// Tweet.swift
// twitterdemo
//
// Created by Nguyen Trong Khoi on 2/27/17.
// Copyright © 2017 Nguyen Trong Khoi. All rights reserved.
//
import UIKit
class Tweet {
var id: String?
var text: String?
var timestamp: Date?
var retweetCount: Int?
var favorite: Int?
var user: User?
var favorited : Bool?
var retweeted : Bool?
init(dictionary: NSDictionary) {
self.id = dictionary["id_str"] as? String
self.favorited = dictionary["favorited"] as? Bool ?? false
self.retweeted = dictionary["retweeted"] as? Bool ?? false
self.text = dictionary["text"] as? String
retweetCount = dictionary["retweet_count"] as? Int ?? 0
favorite = dictionary["favorite_count"] as! Int
let timestampString = dictionary["created_at"] as? String
if let timestampString = timestampString{
let fommater = DateFormatter()
fommater.dateFormat = "EEE MMM d HH:mm:ss Z y"
self.timestamp = fommater.date(from: timestampString)
}
let userDictionary = dictionary["user"] as? NSDictionary
if let userDictionary = userDictionary{
self.user = User(dictionary: userDictionary)
print("User of tweet : \(self.user?.name)")
}
}
class func tweetsWithArray(dictionarys: [NSDictionary]) -> [Tweet] {
var tweets = [Tweet]()
for dictionary in dictionarys{
let tweet = Tweet(dictionary: dictionary)
tweets.append(tweet)
}
return tweets
}
}
| 27.516667 | 73 | 0.582071 |
808227f7b6a0ec4eb405414adde32e28cee603aa | 564 | lua | Lua | commands/pos.lua | blockexchange/blockexchange | d50c1c1236afa549b4b1c80e6eb8993ade851d9a | [
"MIT"
] | 7 | 2020-04-07T17:34:05.000Z | 2022-03-23T23:11:44.000Z | commands/pos.lua | blockexchange/blockexchange | d50c1c1236afa549b4b1c80e6eb8993ade851d9a | [
"MIT"
] | 47 | 2020-03-31T09:45:25.000Z | 2022-03-08T10:52:01.000Z | commands/pos.lua | blockexchange/blockexchange | d50c1c1236afa549b4b1c80e6eb8993ade851d9a | [
"MIT"
] | null | null | null |
minetest.register_chatcommand("bx_pos1", {
description = "Set position 1",
func = function(name)
local player = minetest.get_player_by_name(name)
if player then
local pos = vector.round(player:get_pos())
blockexchange.set_pos(1, name, pos)
end
end
})
minetest.register_chatcommand("bx_pos2", {
description = "Set position 2",
func = function(name)
local player = minetest.get_player_by_name(name)
if player then
local pos = vector.round(player:get_pos())
blockexchange.set_pos(2, name, pos)
end
end
})
| 24.521739 | 52 | 0.684397 |
4a9c77c6df1ac8dfc84b254df8d55858f8cdb7a4 | 7,357 | cshtml | C# | Rights/App/Views/SysLog/Create.cshtml | dujingwei/rights | 576c6f41edb6d5d1eef4a44e0f8ac15e65aa2a41 | [
"Apache-2.0"
] | null | null | null | Rights/App/Views/SysLog/Create.cshtml | dujingwei/rights | 576c6f41edb6d5d1eef4a44e0f8ac15e65aa2a41 | [
"Apache-2.0"
] | null | null | null | Rights/App/Views/SysLog/Create.cshtml | dujingwei/rights | 576c6f41edb6d5d1eef4a44e0f8ac15e65aa2a41 | [
"Apache-2.0"
] | null | null | null | @{
Layout = "~/Views/Shared/Create.cshtml";
}
@model Langben.DAL.SysLog
@using Common
@using Models
<div class="portlet-title">
<div class="caption">
<i class="icon-equalizer font-red-sunglo"></i>
<span class="caption-subject font-red-sunglo bold uppercase">日志</span>
<span class="caption-helper">一定要加油哦,我是来说明的。</span>
</div>
</div>
<div class="portlet-body form">
<!-- BEGIN FORM-->
<script type="text/javascript">
var windowObjectReference = null; // global variable
function openFFPromotionPopup() {
if(windowObjectReference == null || windowObjectReference.closed)
/* if the pointer to the window object in memory does not exist
or if such pointer exists but the window was closed */
{
windowObjectReference = window.open("http://www.spreadfirefox.com/",
"PromoteFirefoxWindowName", "resizable,scrollbars,status");
/* then create it. The new window will be created and
will be brought on top of any other window. */
}
else
{
windowObjectReference.focus();
/* else the window reference must exist and the window
is not closed; therefore, we can bring it back on top of any other
window with the focus() method. There would be no need to re-create
the window or to reload the referenced resource. */
};
}
</script>
(...)
<p>
<a href="http://www.spreadfirefox.com/"
target="PromoteFirefoxWindowName"
onclick="openFFPromotionPopup(); return false;"
title="This link will create a new window or will re-use an already opened one">Promote Firefox adoption</a>
</p>
<form action="/SysLog/Create" class="form-horizontal">
<div class="form-body">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<a onclick="showModalOnly('SysDepartmentId','../../SysDepartment');">
@Html.LabelFor(model => model.Result, new { @class = "control-label col-md-4" })
</a>
<div class="col-md-8">
<span class="help-block">
</span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
@Html.LabelFor(model => model.Result, new { @class = "control-label col-md-4" })
<div class="col-md-8">
@Html.TextBoxFor(model => model.Result, new { @class = "form-control", placeholder = Html.DisplayNameFor(model => model.Result) })
@Html.ValidationMessageFor(model => model.Result)
<span class="help-block">
</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
@Html.LabelFor(model => model.MenuId, new { @class = "control-label col-md-4" })
<div class="col-md-8">
@Html.TextBoxFor(model => model.MenuId, new { @class = "form-control", placeholder = Html.DisplayNameFor(model => model.MenuId) })
@Html.ValidationMessageFor(model => model.MenuId)
<span class="help-block">
</span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
@Html.LabelFor(model => model.Ip, new { @class = "control-label col-md-4" })
<div class="col-md-8">
@Html.TextBoxFor(model => model.Ip, new { @class = "form-control", placeholder = Html.DisplayNameFor(model => model.Ip) })
@Html.ValidationMessageFor(model => model.Ip)
<span class="help-block">
</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
@Html.LabelFor(model => model.State, new { @class = "control-label col-md-4" })
<div class="col-md-8">
@Html.DropDownListFor(model => model.State, Models.SysFieldModels.GetSysField("SysLog", "State"), "请选择", new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.State)
<span class="help-block">
</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
@Html.LabelFor(model => model.Message, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.Message, new { @class = "form-control", placeholder = Html.DisplayNameFor(model => model.Message) })
@Html.ValidationMessageFor(model => model.Message)
<span class="help-block">
</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
@Html.LabelFor(model => model.Remark, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.Remark, new { @class = "form-control", placeholder = Html.DisplayNameFor(model => model.Remark) })
@Html.ValidationMessageFor(model => model.Remark)
<span class="help-block">
</span>
</div>
</div>
</div>
</div>
</div>
<div class="form-actions">
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-offset-3 col-md-9">
<button type="submit" class="btn btn-primary">创建</button>
<button type="button" class="btn default" onclick="BackList('/SysLog')">返回</button>
</div>
</div>
</div>
<div class="col-md-6">
</div>
</div>
</div>
</form>
<!-- END FORM-->
</div>
<script type="text/javascript">
$(function () {
});
</script>
| 36.969849 | 166 | 0.44162 |
363968e8ff116c1621d6b1f208f876c6ddc44485 | 1,297 | swift | Swift | Sources/App/Routes/Routes.swift | PetarMitevski/SwiftWebTest1 | 2773271940313aff8790f3dae1aeca1407bb4b9a | [
"MIT"
] | null | null | null | Sources/App/Routes/Routes.swift | PetarMitevski/SwiftWebTest1 | 2773271940313aff8790f3dae1aeca1407bb4b9a | [
"MIT"
] | null | null | null | Sources/App/Routes/Routes.swift | PetarMitevski/SwiftWebTest1 | 2773271940313aff8790f3dae1aeca1407bb4b9a | [
"MIT"
] | null | null | null | import Vapor
import Foundation
extension Droplet {
func setupRoutes() throws {
get("hello") { req in
var json = JSON()
try json.set("hello", "world")
return json
}
get("plaintext") { req in
return "Hello, world!"
}
get("test") { req in
return "Yea tested!"
}
// response to requests to /info domain
// with a description of the request
get("info") { req in
return req.description
}
get("description") { req in return req.description }
try resource("posts", PostController.self)
try resource("post1", PostController1.self)
// post("post1") { request in
// guard let bs64 = request.json?["bs64"]?.string else{
// throw Abort(.badRequest)}
// let decodedData = Data(base64Encoded: bs64)!
// let json = try JSONSerialization.jsonObject(with: decodedData, options: [])
// if let object = json as? [String: Any] {
// print(object)
// }
//
//
// let test:String! = request.headers["hiiii"];
// return "Hello, \(test ?? "")!"
// }
}
}
| 24.942308 | 89 | 0.484965 |
21e634d65c4220fd7c2c8edfbedd452b92b16749 | 452 | dart | Dart | packages/changelog-lib/lib/src/model/changelog_item.dart | vincenzopalazzo/changelog.dart | a82cd24108145ffaa4ec6357d0286a544e4dedc2 | [
"BSD-3-Clause"
] | null | null | null | packages/changelog-lib/lib/src/model/changelog_item.dart | vincenzopalazzo/changelog.dart | a82cd24108145ffaa4ec6357d0286a544e4dedc2 | [
"BSD-3-Clause"
] | null | null | null | packages/changelog-lib/lib/src/model/changelog_item.dart | vincenzopalazzo/changelog.dart | a82cd24108145ffaa4ec6357d0286a544e4dedc2 | [
"BSD-3-Clause"
] | null | null | null | import 'package:changelog_lib/changelog_lib.dart';
/// changelog item contains the information of the single change
/// in each section of the changelog.
///
/// This item is used to generate the final changelog file.
///
/// author: https://github.com/vincenzopalazzo
class ChangelogItem {
final CommitAuthor authorInfo;
final String? ref;
final String content;
ChangelogItem({required this.authorInfo, required this.content, this.ref});
}
| 26.588235 | 77 | 0.752212 |
7464f1b69ffb0a15da5b341f53801a723564c0b1 | 1,598 | h | C | ClockKit.framework/CLKGaugeProvider.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | 4 | 2021-10-06T12:15:26.000Z | 2022-02-21T02:26:00.000Z | ClockKit.framework/CLKGaugeProvider.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | null | null | null | ClockKit.framework/CLKGaugeProvider.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | 1 | 2021-10-08T07:40:53.000Z | 2021-10-08T07:40:53.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/PrivateFrameworks/ClockKit.framework/ClockKit
*/
@interface CLKGaugeProvider : NSObject <NSCopying, NSSecureCoding> {
NSString * _accessibilityLabel;
bool _finalized;
NSArray * _gaugeColorLocations;
NSArray * _gaugeColors;
bool _paused;
long long _style;
}
@property (nonatomic, retain) NSString *accessibilityLabel;
@property (nonatomic) bool finalized;
@property (nonatomic, retain) NSArray *gaugeColorLocations;
@property (nonatomic, retain) NSArray *gaugeColors;
@property (nonatomic) bool paused;
@property (nonatomic) long long style;
+ (id)gaugeProviderWithJSONObjectRepresentation:(id)arg1 bundle:(id)arg2;
+ (bool)supportsSecureCoding;
- (void).cxx_destruct;
- (id)JSONObjectRepresentation;
- (id)accessibilityLabel;
- (id)copyWithZone:(struct _NSZone { }*)arg1;
- (void)encodeWithCoder:(id)arg1;
- (void)finalize;
- (bool)finalized;
- (id)gaugeColorLocations;
- (id)gaugeColors;
- (unsigned long long)hash;
- (id)initWithCoder:(id)arg1;
- (id)initWithJSONObjectRepresentation:(id)arg1;
- (bool)isEqual:(id)arg1;
- (bool)needsTimerUpdates;
- (bool)paused;
- (double)progressFractionForNow:(id)arg1;
- (void)setAccessibilityLabel:(id)arg1;
- (void)setFinalized:(bool)arg1;
- (void)setGaugeColorLocations:(id)arg1;
- (void)setGaugeColors:(id)arg1;
- (void)setPaused:(bool)arg1;
- (void)setStyle:(long long)arg1;
- (struct NSNumber { Class x1; }*)startUpdatesWithHandler:(id /* block */)arg1;
- (void)stopUpdatesForToken:(struct NSNumber { Class x1; }*)arg1;
- (long long)style;
- (void)validate;
@end
| 30.730769 | 79 | 0.745307 |
c571d74bcd8d6045796c868f030d1505db4d794b | 23,817 | cpp | C++ | mainwindow.cpp | vladimir-vakhter/ble-basestation-app | 43279abc15f2448b9c0c06e50d7ce4dfac3167ed | [
"MIT"
] | null | null | null | mainwindow.cpp | vladimir-vakhter/ble-basestation-app | 43279abc15f2448b9c0c06e50d7ce4dfac3167ed | [
"MIT"
] | null | null | null | mainwindow.cpp | vladimir-vakhter/ble-basestation-app | 43279abc15f2448b9c0c06e50d7ce4dfac3167ed | [
"MIT"
] | null | null | null | /*
* This file contains the logics that controls the view of mainwindow.ui
* mainvindow.ui contains the user interface's widgets
*/
#include "ui_mainwindow.h"
#include "mainwindow.h"
typedef enum {
CH_HEX = 0, CH_BIN, CH_UNICODE
} output_format_type;
typedef enum {
DEVICE_ADDRESS = 0,
DEVICE_NAME,
// DEVICE_CORE_CONF,
DEVICE_RSSI
} device_table_column_index;
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setWindowTitle("BLE Client App");
mDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent();
// connect signals and slots
connect(mDiscoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)), this, SLOT(addDevice(QBluetoothDeviceInfo)));
connect(mDiscoveryAgent, SIGNAL(deviceUpdated(QBluetoothDeviceInfo, QBluetoothDeviceInfo::Fields)),
this, SLOT(deviceUpdated(QBluetoothDeviceInfo, QBluetoothDeviceInfo::Fields)));
connect(mDiscoveryAgent, SIGNAL(finished()), this, SLOT(deviceDiscoveryFinished()));
connect(mDiscoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)),
this, SLOT(deviceDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error)));
connect(mDiscoveryAgent, SIGNAL(canceled()), this, SLOT(deviceDiscoveryCanceled()));
// a table displaying the infromation about Bluetooth devices
ui->devicesTableWidget->setColumnCount(3);
QStringList headerLabels;
headerLabels << "Address" << "Name" << "RSSI, dB";
ui->devicesTableWidget->setHorizontalHeaderLabels(headerLabels);
ui->devicesTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->devicesTableWidget->resizeColumnsToContents();
// start Bluetooth device discovery
mDiscoveryAgent->start();
// the comment below is left to show how to stylize groupboxes and may be deleted
//ui->deviceControlGroupBox->setStyleSheet(QStringLiteral("QGroupBox{border:2px solid gray;border-radius:5px;margin-top: 3ex;background-color: red;}"));
// update the status of the BLE discovery process
ui->scanningIndicatorLabel->setStyleSheet("QLabel { background-color : white; color : red; }");
ui->scanningIndicatorLabel->setText("Scanning...");
// enable the horizontal scroll bar for
ui->bleServicesTreeWidget->setColumnCount(1);
ui->bleServicesTreeWidget->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
ui->bleServicesTreeWidget->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
ui->bleServicesTreeWidget->header()->setStretchLastSection(false);
}
MainWindow::~MainWindow()
{
delete mDiscoveryAgent;
delete mServiceDiscoveryAgent;
delete mSocket;
delete mBLEControl;
delete mBLEService;
delete ui;
}
void MainWindow::addDevice(QBluetoothDeviceInfo info)
{
// retrive the information about a Bluetooth device
QString bluetooth_device_name = info.name();
QString bluetooth_device_addr = info.address().toString();
if (bluetooth_device_name.length() == 0) {
bluetooth_device_name = "unknown";
}
// QString bluetooth_device_configuration = "";
bool isBle = false;
QBluetoothDeviceInfo::CoreConfigurations cconf = info.coreConfigurations();
if (cconf.testFlag(QBluetoothDeviceInfo::LowEnergyCoreConfiguration)) { isBle = true; /*bluetooth_device_configuration.append("BLE");*/ }
if (cconf.testFlag(QBluetoothDeviceInfo::UnknownCoreConfiguration)) { isBle = false; /*bluetooth_device_configuration.append("Unknown");*/ }
if (cconf.testFlag(QBluetoothDeviceInfo::BaseRateCoreConfiguration)) { isBle = false; /*bluetooth_device_configuration.append("Standard");*/ }
if (cconf.testFlag(QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration)) { isBle = true; /*bluetooth_device_configuration.append("BLE & Standard");*/ }
QString rssi = QString::number(info.rssi(), 10);
// add the information about Bluetooth device to a table
QTableWidgetItem *device_addr_item = new QTableWidgetItem();
device_addr_item->setData(Qt::UserRole,QVariant::fromValue(info));
device_addr_item->setText(bluetooth_device_addr);
QTableWidgetItem *device_name_item = new QTableWidgetItem();
device_name_item->setText(bluetooth_device_name);
// QTableWidgetItem *device_configuration_item = new QTableWidgetItem();
// device_configuration_item->setText(bluetooth_device_configuration);
QTableWidgetItem *device_rssi_item = new QTableWidgetItem();
device_rssi_item->setText(rssi);
int device_record_row = 0;
bool device_record_found = false;
// update an existing row
for (; device_record_row < (ui->devicesTableWidget->rowCount()); device_record_row++) {
if (ui->devicesTableWidget->item(device_record_row, 0)->text() == bluetooth_device_addr) {
device_record_found = true;
break;
}
}
// add a new row
if (!device_record_found && isBle) {
int row = ui->devicesTableWidget->rowCount();
ui->devicesTableWidget->setRowCount(row + 1);
}
ui->devicesTableWidget->setItem(device_record_row, DEVICE_ADDRESS, device_addr_item);
ui->devicesTableWidget->setColumnHidden(DEVICE_ADDRESS, true);
ui->devicesTableWidget->setItem(device_record_row, DEVICE_NAME, device_name_item);
// ui->devicesTableWidget->setItem(device_record_row, DEVICE_CORE_CONF, device_configuration_item);
// ui->devicesTableWidget->setColumnHidden(DEVICE_CORE_CONF, true);
ui->devicesTableWidget->setItem(device_record_row, DEVICE_RSSI, device_rssi_item);
}
void MainWindow::deviceUpdated(const QBluetoothDeviceInfo info, QBluetoothDeviceInfo::Fields fields)
{
QString bluetooth_device_addr = info.address().toString();
int device_record_row = 0;
bool device_record_found = false;
for (; device_record_row < ui->devicesTableWidget->rowCount(); device_record_row ++) {
if (ui->devicesTableWidget->item(device_record_row, 0)->text() == bluetooth_device_addr) {
device_record_found = true;
break;
}
}
int mask = 0x0001;
if (device_record_found && (fields & mask)) {
QTableWidgetItem *it = new QTableWidgetItem();
it->setText(QString::number(info.rssi(), 10));
ui->devicesTableWidget->setItem(device_record_row, DEVICE_RSSI, it);
}
}
void MainWindow::deviceDiscoveryFinished()
{
ui->scanningIndicatorLabel->setStyleSheet("QLabel { background-color : white; color : green; }");
ui->scanningIndicatorLabel->setText("Done!");
int msecTimeout = 5000;
// call a slot after a given timeout
if (ui->scanPeriodicallyCheckBox->isChecked()) {
QTimer::singleShot(msecTimeout, this,
[this]()
{
ui->scanningIndicatorLabel->setStyleSheet("QLabel { background-color : white; color : red; }");
ui->scanningIndicatorLabel->setText("Scanning...");
mDiscoveryAgent->start();
}
);
}
}
void MainWindow::socketRead()
{
char buffer[1024];
qint64 len;
while (mSocket->bytesAvailable()) {
len = mSocket->read(buffer, 1024);
qDebug() << len << " : " << QString(buffer);
}
}
void MainWindow::bleServiceDiscovered(const QBluetoothUuid &gatt)
{
QTreeWidgetItem *it = new QTreeWidgetItem();
// it->setExpanded(false);
QLowEnergyService *bleService = mBLEControl->createServiceObject(gatt);
if (bleService) {
connect(bleService, &QLowEnergyService::stateChanged, this,
[bleService, it] (QLowEnergyService::ServiceState state)
{
#ifdef DEBUG
qDebug() << "BLE Service state changed:" << state;
#endif
switch(state) {
case QLowEnergyService::InvalidService:
{
QTreeWidgetItem *child = new QTreeWidgetItem();
child->setText(0, "Invalid Service");
it->addChild(child);
break;
}
case QLowEnergyService::RemoteService:
break;
case QLowEnergyService::RemoteServiceDiscovering:
break;
case QLowEnergyService::RemoteServiceDiscovered:
{
for (const auto &c : bleService->characteristics()) {
int column = 0;
// the human-readable name of the characteristic
QTreeWidgetItem *charChild = new QTreeWidgetItem();
QString charName= "Name: {" + (c.name().isEmpty() ? "Unknown}; " : c.name() + "}; ");
QString charUuid = "UUID: " + c.uuid().toString() + "; ";
QString charProps = "Props: ";
switch (c.properties().toInt()) {
case 0x00:
charProps += "Unknown";
break;
case 0x01:
charProps += "Broadcasting";
break;
case 0x02:
charProps += "Read";
break;
case 0x04:
charProps += "WriteNoResponse";
break;
case 0x08:
charProps += "Write";
break;
case 0x10:
charProps += "Notify";
break;
case 0x20:
charProps += "Indicate";
break;
case 0x40:
charProps += "WriteSigned";
break;
case 0x80:
charProps += "ExtendedProperty";
break;
case 0x06:
charProps += "Read, WriteNoResponse";
break;
default:
charProps += "Define combination!";
break;
}
QString charDescription = charName + charUuid + charProps;
charChild->setData(column, Qt::UserRole, QVariant::fromValue(c));
charChild->setText(column, charDescription);
it->addChild(charChild);
}
break;
}
case QLowEnergyService::LocalService:
{
QTreeWidgetItem *child = new QTreeWidgetItem();
child->setText(0,"Local Service");
it->addChild(child);
break;
}
}
}
);
connect(bleService, &QLowEnergyService::characteristicChanged, this, &MainWindow::bleServiceCharacteristicNotify);
connect(bleService, &QLowEnergyService::characteristicRead, this, &MainWindow::bleServiceCharacteristicRead);
bleService->discoverDetails();
} else {
qDebug() << "Error connecting to BLE Service";
}
it->setData(0, Qt::UserRole, QVariant::fromValue(gatt));
it->setData(1, Qt::UserRole, QVariant::fromValue(bleService));
it->setText(0, gatt.toString());
ui->bleServicesTreeWidget->addTopLevelItem(it);
}
void MainWindow::format_output(const int& format_selector_index, const QByteArray& rawBytesValue, QString& formattedOutput, QString& format)
{
if (format_selector_index == CH_UNICODE) {
format = "Unicode";
formattedOutput = QString(rawBytesValue);
} else {
int base = 0;
int numDigits = 0;
QChar paddingSymbol = '0';
if (format_selector_index == CH_BIN) {
format = "bin";
base = 2;
numDigits = 8;
} else if (format_selector_index == CH_HEX) {
format = "hex";
base = 16;
}
for (int i = 0; i < rawBytesValue.size(); i++) {
formattedOutput += QString::number(rawBytesValue.at(i), base).rightJustified(numDigits, paddingSymbol);
}
}
}
void MainWindow::bleServiceCharacteristicReadNotify(const QString& header, const QByteArray &value)
{
// if other threads try to call lock() on this mutex, they will block until this thread calls unlock()
mutex.lock();
// format value
int output_format_selector_index = ui->bleCharacteristicReadTypeComboBox->currentIndex();
QString output;
QString format;
format_output(output_format_selector_index, value, output, format);
// save if checkbox is checked
if((header == "Notify" && ui->notifyCheckBox->isChecked()) ||
(header == "Read" && ui->readCheckBox->isChecked()))
{
append_to_csv(header, output);
}
// display
output = header + ": " + output;
ui->outputPlainTextEdit->appendPlainText(output);
mutex.unlock();
}
void MainWindow::bleServiceCharacteristicNotify(const QLowEnergyCharacteristic &info, const QByteArray &value)
{
QString header = "Notify";
bleServiceCharacteristicReadNotify(header, value);
}
void MainWindow::bleServiceCharacteristicRead(const QLowEnergyCharacteristic& info, const QByteArray& value)
{
QString header = "Read";
bleServiceCharacteristicReadNotify(header, value);
}
void MainWindow::on_bleConnectPushButton_clicked()
{
#ifdef DEBUG
qDebug() << "on_bleConnectPushButton_clicked() has been called";
#endif
//QBluetoothDeviceInfo dev = ui->devicesListWidget->currentItem()->data(Qt::UserRole).value<QBluetoothDeviceInfo>();
int row = ui->devicesTableWidget->currentRow();
QTableWidgetItem *it = ui->devicesTableWidget->item(row, 0);
if (!it) {
qDebug() << "No device selected!";
return;
}
QBluetoothDeviceInfo dev = it->data(Qt::UserRole).value<QBluetoothDeviceInfo>();
mBLEControl = QLowEnergyController::createCentral(dev, this);
connect(mBLEControl, &QLowEnergyController::serviceDiscovered,
this, &MainWindow::bleServiceDiscovered);
connect(mBLEControl, &QLowEnergyController::discoveryFinished,
this, &MainWindow::bleServiceDiscoveryFinished);
connect(mBLEControl, &QLowEnergyController::connected, this, [this]() {
(void)this; qDebug() << "connected to BLE device!";
mBLEControl->discoverServices();
});
connect(mBLEControl, &QLowEnergyController::disconnected, this, [this]() {
(void) this; qDebug() << "Disconnected from BLE device!";
});
mBLEControl->connectToDevice();
}
void MainWindow::on_bleDisconnectPushButton_clicked()
{
mBLEControl->disconnectFromDevice();
ui->bleServicesTreeWidget->clear();
}
void MainWindow::on_bleCharacteristicReadPushButton_clicked()
{
// if no items selected, give a hint to the user and return
QTreeWidgetItem *it = ui->bleServicesTreeWidget->currentItem();
if (!it) {
ui->statusbar->clearMessage();
ui->statusbar->showMessage("First, connect to a BLE device and select a READ characteristic!");
return;
}
// if a characteristic selected
if (it->data(0, Qt::UserRole).canConvert<QLowEnergyCharacteristic>()) {
QLowEnergyCharacteristic ch = it->data(0,Qt::UserRole).value<QLowEnergyCharacteristic>();
// the top-level parent holds the service
QTreeWidgetItem *p = it->parent();
while (p->parent() != nullptr) { p = p->parent(); }
if (p->data(1, Qt::UserRole).canConvert<QLowEnergyService*>()) {
QLowEnergyService *s = p->data(1, Qt::UserRole).value<QLowEnergyService*>();
// read the characteristic
s->readCharacteristic(ch);
// TODO: If the operation is successful, the characteristicRead() signal is emitted.
// TODO: Otherwise the CharacteristicReadError is set.
// A characteristic can only be read if the service is in the ServiceDiscovered state and belongs to the service.
// If one of these conditions is not true the QLowEnergyService::OperationError is set.
}
} else {
ui->statusbar->clearMessage();
ui->statusbar->showMessage("Not a characteristic! Select a characteristic!");
return;
}
}
void MainWindow::on_bleCharacteristicWritePushButton_clicked()
{
// if no items selected, give a hint to the user and return
QTreeWidgetItem *it = ui->bleServicesTreeWidget->currentItem();
if (!it) {
ui->statusbar->clearMessage();
ui->statusbar->showMessage("First, connect to a BLE device and select a WRITE characteristic!");
return;
}
// if a characteristic selected
if (it->data(0, Qt::UserRole).canConvert<QLowEnergyCharacteristic>()) {
QLowEnergyCharacteristic ch = it->data(0, Qt::UserRole).value<QLowEnergyCharacteristic>();
if (!(ch.properties() & QLowEnergyCharacteristic::PropertyType::WriteNoResponse)) {
if(!(ch.properties() & QLowEnergyCharacteristic::PropertyType::Write)){
if(!(ch.properties() & QLowEnergyCharacteristic::PropertyType::WriteSigned)){
ui->statusbar->clearMessage();
ui->statusbar->showMessage("The characteristic's descriptor is invalid!");
return;
}
}
}
// the top-level parent holds the service
QTreeWidgetItem *p = it->parent();
while (p->parent() != nullptr) { p = p->parent(); }
if (p->data(1, Qt::UserRole).canConvert<QLowEnergyService*>()) {
QLowEnergyService *s = p->data(1, Qt::UserRole).value<QLowEnergyService*>();
// read out and parse the input value
QString value = ui->bleCharacteristicWriteLineEdit->text();
bool parseOK;
int parseBase = 16;
value.toUInt(&parseOK, parseBase);
if(parseOK) {
// transmit the UTF-8 representation of input value or show a hint how to fix the error
s->writeCharacteristic(ch, QByteArray::fromHex(value.toUtf8()), QLowEnergyService::WriteWithoutResponse);
ui->statusbar->clearMessage();
ui->statusbar->showMessage("0x" + value + " has been written!");
} else {
ui->statusbar->clearMessage();
ui->statusbar->showMessage("Convertion to HEX failed: only characters '0-9' and 'a-f' are allowed! Fix the value and try to write again!");
}
} else {
ui->statusbar->clearMessage();
ui->statusbar->showMessage("Cannot find the enclosing service!");
return;
}
} else {
ui->statusbar->clearMessage();
ui->statusbar->showMessage("Not a characteristic! Select a characteristic!");
return;
}
}
void MainWindow::on_listenNotifyPushButton_clicked()
{
QTreeWidgetItem *it = ui->bleServicesTreeWidget->currentItem();
if (!it) {
ui->statusbar->clearMessage();
ui->statusbar->showMessage("First, connect to a BLE device and select a NOTIFY characteristic!");
return;
}
if (!(it->data(0, Qt::UserRole).canConvert<QLowEnergyCharacteristic>())) {
ui->statusbar->clearMessage();
ui->statusbar->showMessage("Not a characteristic! Select a characteristic!");
return;
}
QLowEnergyCharacteristic characteristic = it->data(0, Qt::UserRole).value<QLowEnergyCharacteristic>();
if (characteristic.properties().toInt() != QLowEnergyCharacteristic::Notify) {
ui->statusbar->clearMessage();
ui->statusbar->showMessage("The characteristic's descriptor is invalid!");
return;
}
QTreeWidgetItem *p = it;
while (p->parent() != nullptr) { p = p->parent(); }
if (!(p->data(1, Qt::UserRole).canConvert<QLowEnergyService*>())) {
ui->statusbar->clearMessage();
ui->statusbar->showMessage("Cannot find the enclosing service!");
return;
};
QLowEnergyService *s = p->data(1, Qt::UserRole).value<QLowEnergyService*>();
QLowEnergyDescriptor charDescriptor = characteristic.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration);
if (charDescriptor.isValid()) {
// enable notification
ui->statusbar->clearMessage();
ui->statusbar->showMessage("Listen for the selected notifications!");
s->writeDescriptor(charDescriptor, QByteArray::fromHex("0100"));
} else {
ui->statusbar->clearMessage();
ui->statusbar->showMessage("The characteristic's descriptor is invalid!");
}
}
void MainWindow::on_scanPeriodicallyCheckBox_clicked(bool checked)
{
#ifdef DEBUG
qDebug() << "on_scanPeriodicallyCheckBox_clicked() has been called";
#endif
int msecTimeout = 5000;
if (!mDiscoveryAgent->isActive() && checked) {
QTimer::singleShot(msecTimeout, this,
[this]()
{
ui->scanningIndicatorLabel->setStyleSheet("QLabel { background-color : white; color : red; }");
ui->scanningIndicatorLabel->setText("Scanning...");
mDiscoveryAgent->start();
}
);
}
}
void MainWindow::on_bleServicesTreeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
{
#ifdef DEBUG
qDebug() << "on_bleServicesTreeWidget_currentItemChanged() has been called";
#endif
(void) previous;
(void) current;
}
void MainWindow::on_clearOutputPushButton_clicked()
{
ui->outputPlainTextEdit->clear();
}
void MainWindow::on_browsePushButton_clicked()
{
csvFilePath = QFileDialog::getOpenFileName(this, tr("Save Characteristics"),
"", tr("CSV File (*.csv);;All Files (*)"));
if (csvFilePath.isEmpty()) return;
ui->saveLineEdit->setText(csvFilePath);
}
void MainWindow::append_to_csv(const QString& header, const QString& data)
{
// attempt to open csv-file to append it
QFile file(csvFilePath);
if(!file.open(QIODevice::Append)) {
QMessageBox::information(this, tr("Unable to open file to append"),
file.errorString());
return;
}
// append data to file
QTextStream stream(&file);
// stream the data to the file as a pair "header-data"
stream << header << ","; // comma is used to move to the next column
stream << data << "\n"; // '\n' is used to move to the next row
stream.flush();
file.close();
}
| 39.563123 | 166 | 0.597724 |
7f0f3c1e4ac24b3c6b54c01fa49e4d2a74cd480d | 1,123 | go | Go | cmd/index.go | OliverGilan/jd | aeb6f66431f9a74ee88bb9f4c8efb6d0ce428bc5 | [
"Apache-2.0"
] | 1 | 2021-05-04T21:58:30.000Z | 2021-05-04T21:58:30.000Z | cmd/index.go | OliverGilan/jd | aeb6f66431f9a74ee88bb9f4c8efb6d0ce428bc5 | [
"Apache-2.0"
] | 1 | 2021-05-04T21:59:23.000Z | 2021-09-13T07:03:01.000Z | cmd/index.go | OliverGilan/jd | aeb6f66431f9a74ee88bb9f4c8efb6d0ce428bc5 | [
"Apache-2.0"
] | 1 | 2021-05-07T00:15:13.000Z | 2021-05-07T00:15:13.000Z | /*
Copyright © 2021 NAME HERE <EMAIL ADDRESS>
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"
"github.com/spf13/cobra"
)
// indexCmd represents the index command
var indexCmd = &cobra.Command{
Use: "index [<PRO>]",
Short: "Display system index",
Long: `Display the system index. If no project code is provided the default system will be displayed.
To display all system indices use the -a flag.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("index called")
},
}
func init() {
rootCmd.AddCommand(indexCmd)
indexCmd.Flags().BoolP("all", "a", false, "Display all system indices")
}
| 26.738095 | 102 | 0.739092 |
8066693f46f649553fe92012371182a60c5d5d0c | 280 | java | Java | src/org/sunflow/core/filter/BoxFilter.java | joonhyublee/sunflow | 40771ae754b4986e9d4b4f078b84af4507f47f8d | [
"MIT"
] | 2 | 2016-10-14T14:56:25.000Z | 2016-10-14T14:56:41.000Z | src/org/sunflow/core/filter/BoxFilter.java | joonhyublee/sunflow | 40771ae754b4986e9d4b4f078b84af4507f47f8d | [
"MIT"
] | null | null | null | src/org/sunflow/core/filter/BoxFilter.java | joonhyublee/sunflow | 40771ae754b4986e9d4b4f078b84af4507f47f8d | [
"MIT"
] | null | null | null | package org.sunflow.core.filter;
import org.sunflow.core.Filter;
public class BoxFilter implements Filter {
@Override
public float getSize() {
return 1.0f;
}
@Override
public float get(float x, float y) {
return 1.0f;
}
} | 17.5 | 43 | 0.596429 |
af01a8e741bb507872d8cb4da3a822d7629563d1 | 668 | rb | Ruby | app/controllers/rover_fleet_controller.rb | dmachio/mars_rover | fcff91b20140dd2fefbe198e52c2805e5f046604 | [
"MIT"
] | null | null | null | app/controllers/rover_fleet_controller.rb | dmachio/mars_rover | fcff91b20140dd2fefbe198e52c2805e5f046604 | [
"MIT"
] | null | null | null | app/controllers/rover_fleet_controller.rb | dmachio/mars_rover | fcff91b20140dd2fefbe198e52c2805e5f046604 | [
"MIT"
] | null | null | null | class RoverFleetController < ApplicationController
def index
@rover_fleet = RoverFleet.new
end
def result
@rover_fleet = RoverFleet.new(rover_fleet_params)
respond_to do |format|
if @rover_fleet.valid?
@output = @rover_fleet.process_input()
# prepare output to be presented nicely in html format
@output = @output.gsub! "\n", "<br />"
@output = @output.html_safe
format.html { render :result }
else
format.html { render :index }
end
end
end
private
def rover_fleet_params
params.require(:rover_fleet).permit(:input)
end
end
| 20.242424 | 59 | 0.609281 |
fba798b9e81ede70625f9bb64969937073be514b | 761 | java | Java | 00_framework/core/src/main/java/com/ABC/bitrade/service/DataDictionaryService.java | gcodeabc/ABC-CoinExchange | f8b88ae6c404a8e926db727e0d5fced5a2b5aac9 | [
"Apache-2.0"
] | 1 | 2021-06-25T03:58:57.000Z | 2021-06-25T03:58:57.000Z | 00_framework/core/src/main/java/com/ABC/bitrade/service/DataDictionaryService.java | gcodeabc/ABC-CoinExchange | f8b88ae6c404a8e926db727e0d5fced5a2b5aac9 | [
"Apache-2.0"
] | null | null | null | 00_framework/core/src/main/java/com/ABC/bitrade/service/DataDictionaryService.java | gcodeabc/ABC-CoinExchange | f8b88ae6c404a8e926db727e0d5fced5a2b5aac9 | [
"Apache-2.0"
] | 1 | 2021-06-25T03:59:15.000Z | 2021-06-25T03:59:15.000Z | package com.ABC.bitrade.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ABC.bitrade.dao.DataDictionaryDao;
import com.ABC.bitrade.entity.DataDictionary;
import com.ABC.bitrade.service.Base.TopBaseService;
/**
* @author GS
* @Title: ${file_name}
* @Description:
* @date 2018/4/1214:19
*/
@Service
public class DataDictionaryService extends TopBaseService<DataDictionary, DataDictionaryDao> {
@Autowired
DataDictionaryDao dataDictionaryDao;
@Override
@Autowired
public void setDao(DataDictionaryDao dao) {
super.setDao(dao);
}
public DataDictionary findByBond(String bond) {
return dataDictionaryDao.findByBond(bond);
}
}
| 23.78125 | 94 | 0.750329 |
80a597a5b78c562ee945c1d5c7e161ecc84d0aed | 47,790 | java | Java | src/main/java/com/github/webdriverextensions/webdriverasserts/WebDriverAsserts.java | webdriverextensions/webdriverasserts | 9aa074e33b69055f6d515c6fe14b000cfde5a334 | [
"Apache-2.0"
] | null | null | null | src/main/java/com/github/webdriverextensions/webdriverasserts/WebDriverAsserts.java | webdriverextensions/webdriverasserts | 9aa074e33b69055f6d515c6fe14b000cfde5a334 | [
"Apache-2.0"
] | null | null | null | src/main/java/com/github/webdriverextensions/webdriverasserts/WebDriverAsserts.java | webdriverextensions/webdriverasserts | 9aa074e33b69055f6d515c6fe14b000cfde5a334 | [
"Apache-2.0"
] | null | null | null | package com.github.webdriverextensions.webdriverasserts;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import com.github.webdriverextensions.webdriverasserts.internal.BotUtils;
import org.apache.commons.lang3.StringUtils;
import static org.apache.commons.lang3.math.NumberUtils.*;
import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;
import static com.github.webdriverextensions.webdriverasserts.internal.StringUtils.*;
public class WebDriverAsserts {
private static InheritableThreadLocal<WebDriver> threadLocalDriver = new InheritableThreadLocal<>();
public static void removeDriver() {
threadLocalDriver.remove();
}
public static void setDriver(WebDriver driver) {
threadLocalDriver.set(driver);
}
public static WebDriver getDriver() {
if (threadLocalDriver.get() == null) {
throw new WebDriverException("Driver in WebDriverActions is not set. Please set the driver with WebDriverActions.setDriver(...) method before using the WebDriverActions asserts. Note that the driver will be thread safe since ThreadLocal is used so don't worry about thread safety.");
}
return threadLocalDriver.get();
}
/* Is Displayed */
private static boolean isDisplayed(WebElement webElement) {
try {
return webElement.isDisplayed();
} catch (NoSuchElementException e) {
return false;
}
}
private static boolean isNotDisplayed(WebElement webElement) {
return !isDisplayed(webElement);
}
private static boolean isDisplayed(WebElement webElement, long secondsToWait) {
try {
WebElement foundWebElement = new WebDriverWait(getDriver(), secondsToWait).until(ExpectedConditions.visibilityOf(webElement));
return foundWebElement != null;
} catch (RuntimeException e) {
return false;
}
}
private static boolean isNotDisplayed(WebElement webElement, long secondsToWait) {
return !isDisplayed(webElement, secondsToWait);
}
public static void assertIsDisplayed(WebElement webElement) {
if (isNotDisplayed(webElement)) {
throw new WebDriverAssertionError("Element is not displayed", webElement);
}
}
public static void assertIsNotDisplayed(WebElement webElement) {
if (isDisplayed(webElement)) {
throw new WebDriverAssertionError("Element is displayed when it shouldn't", webElement);
}
}
public static void assertIsDisplayed(WebElement webElement, long secondsToWait) {
if (isNotDisplayed(webElement, secondsToWait)) {
throw new WebDriverAssertionError("Element is not displayed within " + secondsToWait + " seconds", webElement);
}
}
public static void assertIsNotDisplayed(WebElement webElement, long secondsToWait) {
if (isDisplayed(webElement, secondsToWait)) {
throw new WebDriverAssertionError("Element is displayed within " + secondsToWait + " seconds when it shouldn't", webElement);
}
}
/* Size */
public static void assertSizeEquals(int number, Collection collection) {
BotUtils.assertEquals("Size", (double) number, (double) collection.size());
}
public static void assertSizeNotEquals(int number, Collection collection) {
BotUtils.assertNotEquals("Size", (double) number, (double) collection.size());
}
public static void assertSizeLessThan(int number, Collection collection) {
BotUtils.assertLessThan("Size", (double) number, (double) collection.size());
}
public static void assertSizeLessThanOrEquals(int number, Collection collection) {
BotUtils.assertLessThanOrEquals("Size", (double) number, (double) collection.size());
}
public static void assertSizeGreaterThan(int number, Collection collection) {
BotUtils.assertGreaterThan("Size", (double) number, (double) collection.size());
}
public static void assertSizeGreaterThanOrEquals(int number, Collection collection) {
BotUtils.assertGreaterThanOrEquals("Size", (double) number, (double) collection.size());
}
/* Current Url */
private static String currentUrl() {
return getDriver().getCurrentUrl();
}
public static void assertCurrentUrlEquals(String url) {
BotUtils.assertEquals("Current url", url, currentUrl());
}
public static void assertCurrentUrlNotEquals(String url) {
BotUtils.assertNotEquals("Current url", url, currentUrl());
}
public static void assertCurrentUrlContains(String searchText) {
BotUtils.assertContains("Current url", searchText, currentUrl());
}
public static void assertCurrentUrlNotContains(String searchText) {
BotUtils.assertNotContains("Current url", searchText, currentUrl());
}
public static void assertCurrentUrlStartsWith(String prefix) {
BotUtils.assertStartsWith("Current url", prefix, currentUrl());
}
public static void assertCurrentUrlNotStartsWith(String prefix) {
BotUtils.assertNotStartsWith("Current url", prefix, currentUrl());
}
public static void assertCurrentUrlEndsWith(String suffix) {
BotUtils.assertEndsWith("Current url", suffix, currentUrl());
}
public static void assertCurrentUrlNotEndsWith(String suffix) {
BotUtils.assertNotEndsWith("Current url", suffix, currentUrl());
}
public static void assertCurrentUrlMatches(String regExp) {
BotUtils.assertMatches("Current url", regExp, currentUrl());
}
public static void assertCurrentUrlNotMatches(String regExp) {
BotUtils.assertNotMatches("Current url", regExp, currentUrl());
}
/* Title */
private static String title() {
return getDriver().getTitle();
}
public static void assertTitleEquals(String title) {
BotUtils.assertEquals("Title", title, title());
}
public static void assertTitleNotEquals(String title) {
BotUtils.assertNotEquals("Title", title, title());
}
public static void assertTitleContains(String searchText) {
BotUtils.assertContains("Title", searchText, title());
}
public static void assertTitleNotContains(String searchText) {
BotUtils.assertNotContains("Title", searchText, title());
}
public static void assertTitleStartsWith(String prefix) {
BotUtils.assertStartsWith("Title", prefix, title());
}
public static void assertTitleNotStartsWith(String prefix) {
BotUtils.assertNotStartsWith("Title", prefix, title());
}
public static void assertTitleEndsWith(String suffix) {
BotUtils.assertEndsWith("Title", suffix, title());
}
public static void assertTitleNotEndsWith(String suffix) {
BotUtils.assertNotEndsWith("Title", suffix, title());
}
public static void assertTitleMatches(String regExp) {
BotUtils.assertMatches("Title", regExp, title());
}
public static void assertTitleNotMatches(String regExp) {
BotUtils.assertNotMatches("Title", regExp, title());
}
/* Tag Name */
private static String tagNameOf(WebElement webElement) {
return webElement.getTagName();
}
public static void assertTagNameEquals(String value, WebElement webElement) {
BotUtils.assertEquals("Tag name", value, tagNameOf(webElement), webElement);
}
public static void assertTagNameNotEquals(String value, WebElement webElement) {
BotUtils.assertNotEquals("Tag name", value, tagNameOf(webElement), webElement);
}
/* Attribute */
private static String attributeIn(String name, WebElement webElement) {
return webElement.getAttribute(name);
}
private static boolean hasAttribute(String name, WebElement webElement) {
return webElement.getAttribute(name) != null;
}
private static boolean hasNotAttribute(String name, WebElement webElement) {
return !hasAttribute(name, webElement);
}
private static boolean attributeEquals(String name, String value, WebElement webElement) {
return BotUtils.isEqual(value, attributeIn(name, webElement));
}
public static void assertHasAttribute(String name, WebElement webElement) {
if (hasNotAttribute(name, webElement)) {
throw new WebDriverAssertionError("Element does not have attribute " + quote(name), webElement);
}
}
public static void assertHasNotAttribute(String name, WebElement webElement) {
if (hasAttribute(name, webElement)) {
throw new WebDriverAssertionError("Element has attribute " + quote(name) + " when it shouldn't", webElement);
}
}
public static void assertAttributeEquals(String name, String value, WebElement webElement) {
BotUtils.assertEquals("Element attribute " + name, value, attributeIn(name, webElement), webElement);
}
public static void assertAttributeNotEquals(String name, String value, WebElement webElement) {
BotUtils.assertNotEquals("Element attribute " + name, value, attributeIn(name, webElement), webElement);
}
public static void assertAttributeContains(String name, String searchText, WebElement webElement) {
BotUtils.assertContains("Element attribute " + name, searchText, attributeIn(name, webElement), webElement);
}
public static void assertAttributeNotContains(String name, String searchText, WebElement webElement) {
BotUtils.assertNotContains("Element attribute " + name, searchText, attributeIn(name, webElement), webElement);
}
public static void assertAttributeStartsWith(String name, String prefix, WebElement webElement) {
BotUtils.assertStartsWith("Element attribute " + name, prefix, attributeIn(name, webElement), webElement);
}
public static void assertAttributeNotStartsWith(String name, String prefix, WebElement webElement) {
BotUtils.assertNotStartsWith("Element attribute " + name, prefix, attributeIn(name, webElement), webElement);
}
public static void assertAttributeEndsWith(String name, String suffix, WebElement webElement) {
BotUtils.assertEndsWith("Element attribute " + name, suffix, attributeIn(name, webElement), webElement);
}
public static void assertAttributeNotEndsWith(String name, String suffix, WebElement webElement) {
BotUtils.assertNotEndsWith("Element attribute " + name, suffix, attributeIn(name, webElement), webElement);
}
public static void assertAttributeMatches(String name, String regExp, WebElement webElement) {
BotUtils.assertMatches("Element attribute " + name, regExp, attributeIn(name, webElement), webElement);
}
public static void assertAttributeNotMatches(String name, String regExp, WebElement webElement) {
BotUtils.assertNotMatches("Element attribute " + name, regExp, attributeIn(name, webElement), webElement);
}
/* Attribute as Number */
private static double attributeInAsNumber(String name, WebElement webElement) {
return createDouble(attributeIn(name, webElement));
}
private static boolean attributeIsNumber(String name, WebElement webElement) {
try {
attributeInAsNumber(name, webElement);
return true;
} catch (NumberFormatException e) {
return false;
}
}
private static boolean attributeIsNotNumber(String name, WebElement webElement) {
return !attributeIsNumber(name, webElement);
}
public static void assertAttributeIsNumber(String name, WebElement webElement) {
if (attributeIsNotNumber(name, webElement)) {
throw new WebDriverAssertionError("Element attribute " + name + " is not a number", webElement);
}
}
public static void assertAttributeIsNotNumber(String name, WebElement webElement) {
if (attributeIsNumber(name, webElement)) {
throw new WebDriverAssertionError("Element attribute " + name + " is a number when it shouldn't", webElement);
}
}
public static void assertAttributeEquals(String name, double number, WebElement webElement) {
BotUtils.assertEquals(name, number, attributeInAsNumber(name, webElement), webElement);
}
public static void assertAttributeNotEquals(String name, double number, WebElement webElement) {
BotUtils.assertNotEquals(name, number, attributeInAsNumber(name, webElement), webElement);
}
public static void assertAttributeLessThan(String name, double number, WebElement webElement) {
BotUtils.assertLessThan(name, number, attributeInAsNumber(name, webElement), webElement);
}
public static void assertAttributeLessThanOrEquals(String name, double number, WebElement webElement) {
BotUtils.assertLessThanOrEquals(name, number, attributeInAsNumber(name, webElement), webElement);
}
public static void assertAttributeGreaterThan(String name, double number, WebElement webElement) {
BotUtils.assertGreaterThan(name, number, attributeInAsNumber(name, webElement), webElement);
}
public static void assertAttributeGreaterThanOrEquals(String name, double number, WebElement webElement) {
BotUtils.assertGreaterThanOrEquals(name, number, attributeInAsNumber(name, webElement), webElement);
}
/* Id */
public static void assertIdEquals(String value, WebElement webElement) {
assertAttributeEquals("id", value, webElement);
}
public static void assertIdNotEquals(String value, WebElement webElement) {
assertAttributeNotEquals("id", value, webElement);
}
public static void assertIdContains(String searchText, WebElement webElement) {
assertAttributeContains("id", searchText, webElement);
}
public static void assertIdNotContains(String searchText, WebElement webElement) {
assertAttributeNotContains("id", searchText, webElement);
}
public static void assertIdStartsWith(String prefix, WebElement webElement) {
assertAttributeStartsWith("id", prefix, webElement);
}
public static void assertIdNotStartsWith(String prefix, WebElement webElement) {
assertAttributeNotStartsWith("id", prefix, webElement);
}
public static void assertIdEndsWith(String suffix, WebElement webElement) {
assertAttributeEndsWith("id", suffix, webElement);
}
public static void assertIdNotEndsWith(String suffix, WebElement webElement) {
assertAttributeNotEndsWith("id", suffix, webElement);
}
public static void assertIdMatches(String regExp, WebElement webElement) {
assertAttributeMatches("id", regExp, webElement);
}
public static void assertIdNotMatches(String regExp, WebElement webElement) {
assertAttributeNotMatches("id", regExp, webElement);
}
/* Name */
public static void assertNameEquals(String value, WebElement webElement) {
assertAttributeEquals("name", value, webElement);
}
public static void assertNameNotEquals(String value, WebElement webElement) {
assertAttributeNotEquals("name", value, webElement);
}
public static void assertNameContains(String searchText, WebElement webElement) {
assertAttributeContains("name", searchText, webElement);
}
public static void assertNameNotContains(String searchText, WebElement webElement) {
assertAttributeNotContains("name", searchText, webElement);
}
public static void assertNameStartsWith(String prefix, WebElement webElement) {
assertAttributeStartsWith("name", prefix, webElement);
}
public static void assertNameNotStartsWith(String prefix, WebElement webElement) {
assertAttributeNotStartsWith("name", prefix, webElement);
}
public static void assertNameEndsWith(String suffix, WebElement webElement) {
assertAttributeEndsWith("name", suffix, webElement);
}
public static void assertNameNotEndsWith(String suffix, WebElement webElement) {
assertAttributeNotEndsWith("name", suffix, webElement);
}
public static void assertNameMatches(String regExp, WebElement webElement) {
assertAttributeMatches("name", regExp, webElement);
}
public static void assertNameNotMatches(String regExp, WebElement webElement) {
assertAttributeNotMatches("name", regExp, webElement);
}
/* Class */
private static String classIn(WebElement webElement) {
return attributeIn("class", webElement);
}
private static List<String> classesIn(WebElement webElement) {
return Arrays.asList(StringUtils.split(classIn(webElement)));
}
private static boolean hasClass(String className, WebElement webElement) {
List<String> classes = classesIn(webElement);
for (String clazz : classes) {
if (BotUtils.isEqual(className, clazz)) {
return true;
}
}
return false;
}
private static boolean hasNotClass(String className, WebElement webElement) {
return !hasClass(className, webElement);
}
private static boolean hasClassContaining(String searchText, WebElement webElement) {
List<String> classes = classesIn(webElement);
for (String clazz : classes) {
if (BotUtils.contains(searchText, clazz)) {
return true;
}
}
return false;
}
private static boolean hasNotClassContaining(String searchText, WebElement webElement) {
return !hasClassContaining(searchText, webElement);
}
private static boolean hasClassStartingWith(String prefix, WebElement webElement) {
List<String> classes = classesIn(webElement);
for (String clazz : classes) {
if (BotUtils.startsWith(prefix, clazz)) {
return true;
}
}
return false;
}
private static boolean hasNotClassStartingWith(String prefix, WebElement webElement) {
return !hasClassStartingWith(prefix, webElement);
}
private static boolean hasClassEndingWith(String suffix, WebElement webElement) {
List<String> classes = classesIn(webElement);
for (String clazz : classes) {
if (BotUtils.endsWith(suffix, clazz)) {
return true;
}
}
return false;
}
private static boolean hasNotClassEndingWith(String suffix, WebElement webElement) {
return !hasClassEndingWith(suffix, webElement);
}
private static boolean hasClassMatching(String regExp, WebElement webElement) {
List<String> classes = classesIn(webElement);
for (String clazz : classes) {
if (BotUtils.matches(regExp, clazz)) {
return true;
}
}
return false;
}
private static boolean hasNotClassMatching(String regExp, WebElement webElement) {
return !hasClassMatching(regExp, webElement);
}
public static void assertHasClass(WebElement webElement) {
assertHasAttribute("class", webElement);
}
public static void assertHasNotClass(WebElement webElement) {
assertHasNotAttribute("class", webElement);
}
public static void assertHasClass(String className, WebElement webElement) {
if (hasNotClass(className, webElement)) {
throw new WebDriverAssertionError("Element does not have class " + quote(className.trim()), webElement);
}
}
public static void assertHasNotClass(String className, WebElement webElement) {
if (hasClass(className, webElement)) {
throw new WebDriverAssertionError("Element has class " + quote(className.trim()) + " when it shouldn't", webElement);
}
}
public static void assertHasClassContaining(String searchText, WebElement webElement) {
if (hasNotClassContaining(searchText, webElement)) {
throw new WebDriverAssertionError("Element does not have class containing text " + quote(searchText.trim()), webElement);
}
}
public static void assertHasNotClassContaining(String searchText, WebElement webElement) {
if (hasClassContaining(searchText, webElement)) {
throw new WebDriverAssertionError("Element has class containing text " + quote(searchText.trim()) + " when it shouldn't", webElement);
}
}
public static void assertHasClassStartingWith(String prefix, WebElement webElement) {
if (hasNotClassStartingWith(prefix, webElement)) {
throw new WebDriverAssertionError("Element does not have class containing prefix " + quote(prefix.trim()), webElement);
}
}
public static void assertHasNotClassStartingWith(String prefix, WebElement webElement) {
if (hasClassStartingWith(prefix, webElement)) {
throw new WebDriverAssertionError("Element has class containing prefix " + quote(prefix.trim()) + " when it shouldn't", webElement);
}
}
public static void assertHasClassEndingWith(String suffix, WebElement webElement) {
if (hasNotClassEndingWith(suffix, webElement)) {
throw new WebDriverAssertionError("Element does not have class containing suffix " + quote(suffix.trim()), webElement);
}
}
public static void assertHasNotClassEndingWith(String suffix, WebElement webElement) {
if (hasClassEndingWith(suffix, webElement)) {
throw new WebDriverAssertionError("Element has class containing suffix " + quote(suffix.trim()) + " when it shouldn't", webElement);
}
}
public static void assertHasClassMatching(String regExp, WebElement webElement) {
if (hasNotClassMatching(regExp, webElement)) {
throw new WebDriverAssertionError("Element does not have class matching regExp " + quote(regExp.trim()), webElement);
}
}
public static void assertHasNotClassMatching(String regExp, WebElement webElement) {
if (hasClassMatching(regExp, webElement)) {
throw new WebDriverAssertionError("Element has class matching regExp " + quote(regExp.trim()) + " when it shouldn't", webElement);
}
}
/* Value */
private static boolean valueEquals(String value, WebElement webElement) {
return attributeEquals("value", value, webElement);
}
public static void assertValueEquals(String value, WebElement webElement) {
assertAttributeEquals("value", value, webElement);
}
public static void assertValueNotEquals(String value, WebElement webElement) {
assertAttributeNotEquals("value", value, webElement);
}
public static void assertValueContains(String searchText, WebElement webElement) {
assertAttributeContains("value", searchText, webElement);
}
public static void assertValueNotContains(String searchText, WebElement webElement) {
assertAttributeNotContains("value", searchText, webElement);
}
public static void assertValueStartsWith(String prefix, WebElement webElement) {
assertAttributeStartsWith("value", prefix, webElement);
}
public static void assertValueNotStartsWith(String prefix, WebElement webElement) {
assertAttributeNotStartsWith("value", prefix, webElement);
}
public static void assertValueEndsWith(String suffix, WebElement webElement) {
assertAttributeEndsWith("value", suffix, webElement);
}
public static void assertValueNotEndsWith(String suffix, WebElement webElement) {
assertAttributeNotEndsWith("value", suffix, webElement);
}
public static void assertValueMatches(String regExp, WebElement webElement) {
assertAttributeMatches("value", regExp, webElement);
}
public static void assertValueNotMatches(String regExp, WebElement webElement) {
assertAttributeNotMatches("value", regExp, webElement);
}
/* Value as Number */
public static void assertValueIsNumber(WebElement webElement) {
assertAttributeIsNumber("value", webElement);
}
public static void assertValueIsNotNumber(WebElement webElement) {
assertAttributeIsNotNumber("value", webElement);
}
public static void assertValueEquals(double number, WebElement webElement) {
assertAttributeEquals("value", number, webElement);
}
public static void assertValueNotEquals(double number, WebElement webElement) {
assertAttributeNotEquals("value", number, webElement);
}
public static void assertValueLessThan(double number, WebElement webElement) {
assertAttributeLessThan("value", number, webElement);
}
public static void assertValueLessThanOrEquals(double number, WebElement webElement) {
assertAttributeLessThanOrEquals("value", number, webElement);
}
public static void assertValueGreaterThan(double number, WebElement webElement) {
assertAttributeGreaterThan("value", number, webElement);
}
public static void assertValueGreaterThanOrEquals(double number, WebElement webElement) {
assertAttributeGreaterThanOrEquals("value", number, webElement);
}
/* Href */
public static void assertHrefEquals(String value, WebElement webElement) {
assertAttributeEquals("href", value, webElement);
}
public static void assertHrefNotEquals(String value, WebElement webElement) {
assertAttributeNotEquals("href", value, webElement);
}
public static void assertHrefContains(String searchText, WebElement webElement) {
assertAttributeContains("href", searchText, webElement);
}
public static void assertHrefNotContains(String searchText, WebElement webElement) {
assertAttributeNotContains("href", searchText, webElement);
}
public static void assertHrefStartsWith(String prefix, WebElement webElement) {
assertAttributeStartsWith("href", prefix, webElement);
}
public static void assertHrefNotStartsWith(String prefix, WebElement webElement) {
assertAttributeNotStartsWith("href", prefix, webElement);
}
public static void assertHrefEndsWith(String suffix, WebElement webElement) {
assertAttributeEndsWith("href", suffix, webElement);
}
public static void assertHrefNotEndsWith(String suffix, WebElement webElement) {
assertAttributeNotEndsWith("href", suffix, webElement);
}
public static void assertHrefMatches(String regExp, WebElement webElement) {
assertAttributeMatches("href", regExp, webElement);
}
public static void assertHrefNotMatches(String regExp, WebElement webElement) {
assertAttributeNotMatches("href", regExp, webElement);
}
/* Text */
private static String textIn(WebElement webElement) {
// Text is trimmed to normalize behavior since Chrome and PhantomJS driver incorrectly returns spaces around the text (Not according the the WebElement tetText docs), see bug report https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/7473 remove this when bug is solved!
return StringUtils.trim(webElement.getText());
}
private static boolean hasText(WebElement webElement) {
return BotUtils.notEquals("", textIn(webElement));
}
private static boolean hasNotText(WebElement webElement) {
return BotUtils.isEqual("", textIn(webElement));
}
private static boolean textEquals(String text, WebElement webElement) {
return BotUtils.isEqual(text, textIn(webElement));
}
public static void assertHasText(WebElement webElement) {
if (hasNotText(webElement)) {
throw new WebDriverAssertionError("Element has no text", webElement);
}
}
public static void assertHasNotText(WebElement webElement) {
if (hasText(webElement)) {
throw new WebDriverAssertionError("Element has text " + quote(textIn(webElement)) + " when it shouldn't", webElement);
}
}
public static void assertTextEquals(String text, WebElement webElement) {
BotUtils.assertEquals("Text", text, textIn(webElement), webElement);
}
public static void assertTextNotEquals(String text, WebElement webElement) {
BotUtils.assertNotEquals("Text", text, textIn(webElement), webElement);
}
public static void assertTextEqualsIgnoreCase(String text, WebElement webElement) {
BotUtils.assertEqualsIgnoreCase("Text", text, textIn(webElement), webElement);
}
public static void assertTextNotEqualsIgnoreCase(String text, WebElement webElement) {
BotUtils.assertNotEqualsIgnoreCase("Text", text, textIn(webElement), webElement);
}
public static void assertTextContains(String searchText, WebElement webElement) {
BotUtils.assertContains("Text", searchText, textIn(webElement), webElement);
}
public static void assertTextNotContains(String searchText, WebElement webElement) {
BotUtils.assertNotContains("Text", searchText, textIn(webElement), webElement);
}
public static void assertTextContainsIgnoreCase(String searchText, WebElement webElement) {
BotUtils.assertContainsIgnoreCase("Text", searchText, textIn(webElement), webElement);
}
public static void assertTextNotContainsIgnoreCase(String searchText, WebElement webElement) {
BotUtils.assertNotContainsIgnoreCase("Text", searchText, textIn(webElement), webElement);
}
public static void assertTextStartsWith(String prefix, WebElement webElement) {
BotUtils.assertStartsWith("Text", prefix, textIn(webElement), webElement);
}
public static void assertTextNotStartsWith(String prefix, WebElement webElement) {
BotUtils.assertNotStartsWith("Text", prefix, textIn(webElement), webElement);
}
public static void assertTextStartsWithIgnoreCase(String prefix, WebElement webElement) {
BotUtils.assertStartsWithIgnoreCase("Text", prefix, textIn(webElement), webElement);
}
public static void assertTextNotStartsWithIgnoreCase(String prefix, WebElement webElement) {
BotUtils.assertNotStartsWithIgnoreCase("Text", prefix, textIn(webElement), webElement);
}
public static void assertTextEndsWith(String suffix, WebElement webElement) {
BotUtils.assertEndsWith("Text", suffix, textIn(webElement), webElement);
}
public static void assertTextNotEndsWith(String suffix, WebElement webElement) {
BotUtils.assertNotEndsWith("Text", suffix, textIn(webElement), webElement);
}
public static void assertTextEndsWithIgnoreCase(String suffix, WebElement webElement) {
BotUtils.assertEndsWithIgnoreCase("Text", suffix, textIn(webElement), webElement);
}
public static void assertTextNotEndsWithIgnoreCase(String suffix, WebElement webElement) {
BotUtils.assertNotEndsWithIgnoreCase("Text", suffix, textIn(webElement), webElement);
}
public static void assertTextMatches(String regExp, WebElement webElement) {
BotUtils.assertMatches("Text", regExp, textIn(webElement), webElement);
}
public static void assertTextNotMatches(String regExp, WebElement webElement) {
BotUtils.assertNotMatches("Text", regExp, textIn(webElement), webElement);
}
/* Text as Number */
private static double textInAsNumber(WebElement webElement) {
return createDouble(textIn(webElement));
}
private static boolean textIsNumber(WebElement webElement) {
try {
textInAsNumber(webElement);
return true;
} catch (NumberFormatException e) {
return false;
}
}
private static boolean textIsNotNumber(WebElement webElement) {
return !textIsNumber(webElement);
}
public static void assertTextIsNumber(WebElement webElement) {
if (textIsNotNumber(webElement)) {
throw new WebDriverAssertionError("Element text is not a number", webElement);
}
}
public static void assertTextIsNotNumber(WebElement webElement) {
if (textIsNumber(webElement)) {
throw new WebDriverAssertionError("Element text is a number when it shouldn't", webElement);
}
}
public static void assertTextEquals(double number, WebElement webElement) {
BotUtils.assertEquals("Text", number, textInAsNumber(webElement), webElement);
}
public static void assertTextNotEquals(double number, WebElement webElement) {
BotUtils.assertNotEquals("Text", number, textInAsNumber(webElement), webElement);
}
public static void assertTextLessThan(double number, WebElement webElement) {
BotUtils.assertLessThan("Text", number, textInAsNumber(webElement), webElement);
}
public static void assertTextLessThanOrEquals(double number, WebElement webElement) {
BotUtils.assertLessThanOrEquals("Text", number, textInAsNumber(webElement), webElement);
}
public static void assertTextGreaterThan(double number, WebElement webElement) {
BotUtils.assertGreaterThan("Text", number, textInAsNumber(webElement), webElement);
}
public static void assertTextGreaterThanOrEquals(double number, WebElement webElement) {
BotUtils.assertGreaterThanOrEquals("Text", number, textInAsNumber(webElement), webElement);
}
/* Selected/Deselected */
private static boolean isSelected(WebElement webElement) {
return webElement.isSelected();
}
private static boolean isDeselected(WebElement webElement) {
return !isSelected(webElement);
}
public static void assertIsSelected(WebElement webElement) {
if (isDeselected(webElement)) {
throw new WebDriverAssertionError("Element is not selected", webElement);
}
}
public static void assertIsDeselected(WebElement webElement) {
if (isSelected(webElement)) {
throw new WebDriverAssertionError("Element is not deselected", webElement);
}
}
/* Checked/Unchecked */
private static boolean isChecked(WebElement webElement) {
return webElement.isSelected();
}
private static boolean isUnchecked(WebElement webElement) {
return !isChecked(webElement);
}
public static void assertIsChecked(WebElement webElement) {
if (isUnchecked(webElement)) {
throw new WebDriverAssertionError("Element is not checked", webElement);
}
}
public static void assertIsUnchecked(WebElement webElement) {
if (isChecked(webElement)) {
throw new WebDriverAssertionError("Element is not unchecked", webElement);
}
}
/* Enabled/Disabled */
private static boolean isEnabled(WebElement webElement) {
return webElement.isEnabled();
}
private static boolean isDisabled(WebElement webElement) {
return !isEnabled(webElement);
}
public static void assertIsEnabled(WebElement webElement) {
if (isDisabled(webElement)) {
throw new WebDriverAssertionError("Element is not enabled", webElement);
}
}
public static void assertIsDisabled(WebElement webElement) {
if (isEnabled(webElement)) {
throw new WebDriverAssertionError("Element is not disabled", webElement);
}
}
/* Option */
private static boolean hasOption(String text, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (textEquals(text, option)) {
return true;
}
}
return false;
}
private static boolean hasNotOption(String text, WebElement webElement) {
return !hasOption(text, webElement);
}
private static boolean optionIsEnabled(String text, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (textEquals(text, option) && isEnabled(option)) {
return true;
}
}
return false;
}
private static boolean optionIsDisabled(String text, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (textEquals(text, option) && isDisabled(option)) {
return true;
}
}
return false;
}
private static boolean optionIsSelected(String text, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (textEquals(text, option) && isSelected(option)) {
return true;
}
}
return false;
}
private static boolean optionIsDeselected(String text, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (textEquals(text, option) && isDeselected(option)) {
return true;
}
}
return false;
}
private static boolean allOptionsAreSelected(WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (isDeselected(option)) {
return false;
}
}
return true;
}
private static boolean noOptionIsSelected(WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (isSelected(option)) {
return false;
}
}
return true;
}
public static void assertHasOption(String text, WebElement webElement) {
if (hasNotOption(text, webElement)) {
throw new WebDriverAssertionError("Element has no option " + quote(text.trim()), webElement);
}
}
public static void assertHasNotOption(String text, WebElement webElement) {
if (hasOption(text, webElement)) {
throw new WebDriverAssertionError("Element has option " + quote(text.trim()) + " when it shouldn't", webElement);
}
}
public static void assertOptionIsEnabled(String text, WebElement webElement) {
assertHasOption(text, webElement);
if (optionIsDisabled(text, webElement)) {
throw new WebDriverAssertionError("Option " + quote(text.trim()) + " is not enabled", webElement);
}
}
public static void assertOptionIsDisabled(String text, WebElement webElement) {
assertHasOption(text, webElement);
if (optionIsEnabled(text, webElement)) {
throw new WebDriverAssertionError("Option " + quote(text.trim()) + " is not disabled", webElement);
}
}
public static void assertOptionIsSelected(String text, WebElement webElement) {
assertHasOption(text, webElement);
if (optionIsDeselected(text, webElement)) {
throw new WebDriverAssertionError("Option " + quote(text.trim()) + " is not selected", webElement);
}
}
public static void assertOptionIsDeselected(String text, WebElement webElement) {
assertHasOption(text, webElement);
if (optionIsSelected(text, webElement)) {
throw new WebDriverAssertionError("Option " + quote(text.trim()) + " is not deselected", webElement);
}
}
public static void assertAllOptionsAreSelected(WebElement webElement) {
if (!allOptionsAreSelected(webElement)) {
throw new WebDriverAssertionError("All options are not selected", webElement);
}
}
public static void assertNoOptionIsSelected(WebElement webElement) {
if (!noOptionIsSelected(webElement)) {
throw new WebDriverAssertionError("All options are not deselected", webElement);
}
}
/* Option Value */
private static boolean hasOptionWithValue(String value, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (valueEquals(value, option)) {
return true;
}
}
return false;
}
private static boolean hasNotOptionWithValue(String value, WebElement webElement) {
return !hasOptionWithValue(value, webElement);
}
private static boolean optionWithValueIsEnabled(String value, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (valueEquals(value, option) && isEnabled(option)) {
return true;
}
}
return false;
}
private static boolean optionWithValueIsDisabled(String value, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (valueEquals(value, option) && isDisabled(option)) {
return true;
}
}
return false;
}
private static boolean optionWithValueIsSelected(String value, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (valueEquals(value, option) && isSelected(option)) {
return true;
}
}
return false;
}
private static boolean optionWithValueIsDeselected(String value, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
for (WebElement option : options) {
if (valueEquals(value, option) && isDeselected(option)) {
return true;
}
}
return false;
}
public static void assertHasOptionWithValue(String value, WebElement webElement) {
if (hasNotOptionWithValue(value, webElement)) {
throw new WebDriverAssertionError("Element has no option with value " + quote(value.trim()), webElement);
}
}
public static void assertHasNotOptionWithValue(String value, WebElement webElement) {
if (hasOptionWithValue(value, webElement)) {
throw new WebDriverAssertionError("Element has option with value " + quote(value.trim()) + " when it shouldn't", webElement);
}
}
public static void assertOptionWithValueIsEnabled(String value, WebElement webElement) {
assertHasOptionWithValue(value, webElement);
if (optionWithValueIsDisabled(value, webElement)) {
throw new WebDriverAssertionError("Option with value " + quote(value.trim()) + " is not enabled", webElement);
}
}
public static void assertOptionWithValueIsDisabled(String value, WebElement webElement) {
assertHasOptionWithValue(value, webElement);
if (optionWithValueIsEnabled(value, webElement)) {
throw new WebDriverAssertionError("Option with value " + quote(value.trim()) + " is not disabled", webElement);
}
}
public static void assertOptionWithValueIsSelected(String value, WebElement webElement) {
assertHasOptionWithValue(value, webElement);
if (optionWithValueIsDeselected(value, webElement)) {
throw new WebDriverAssertionError("Option with value " + quote(value.trim()) + " is not selected", webElement);
}
}
public static void assertOptionWithValueIsDeselected(String value, WebElement webElement) {
assertHasOptionWithValue(value, webElement);
if (optionWithValueIsSelected(value, webElement)) {
throw new WebDriverAssertionError("Option with value " + quote(value.trim()) + " is not deselected", webElement);
}
}
/* Option Index */
private static boolean hasOptionWithIndex(int index, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
try {
return options.get(index) != null;
} catch (IndexOutOfBoundsException e) {
return false;
}
}
private static boolean hasNotOptionWithIndex(int index, WebElement webElement) {
return !hasOptionWithIndex(index, webElement);
}
private static boolean optionWithIndexIsEnabled(int index, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
try {
return isEnabled(options.get(index));
} catch (IndexOutOfBoundsException e) {
return false;
}
}
private static boolean optionWithIndexIsDisabled(int index, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
try {
return isDisabled(options.get(index));
} catch (IndexOutOfBoundsException e) {
return false;
}
}
private static boolean optionWithIndexIsSelected(int index, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
try {
return isSelected(options.get(index));
} catch (IndexOutOfBoundsException e) {
return false;
}
}
private static boolean optionWithIndexIsDeselected(int index, WebElement webElement) {
List<WebElement> options = new Select(webElement).getOptions();
try {
return isDeselected(options.get(index));
} catch (IndexOutOfBoundsException e) {
return false;
}
}
public static void assertHasOptionWithIndex(int index, WebElement webElement) {
if (hasNotOptionWithIndex(index, webElement)) {
throw new WebDriverAssertionError("Element has no option with index " + quote(index), webElement);
}
}
public static void assertHasNotOptionWithIndex(int index, WebElement webElement) {
if (hasOptionWithIndex(index, webElement)) {
throw new WebDriverAssertionError("Element has option with index " + quote(index) + " when it shouldn't", webElement);
}
}
public static void assertOptionWithIndexIsEnabled(int index, WebElement webElement) {
assertHasOptionWithIndex(index, webElement);
if (optionWithIndexIsDisabled(index, webElement)) {
throw new WebDriverAssertionError("Option with index " + quote(index) + " is not enabled", webElement);
}
}
public static void assertOptionWithIndexIsDisabled(int index, WebElement webElement) {
assertHasOptionWithIndex(index, webElement);
if (optionWithIndexIsEnabled(index, webElement)) {
throw new WebDriverAssertionError("Option with index " + quote(index) + " is not disabled", webElement);
}
}
public static void assertOptionWithIndexIsSelected(int index, WebElement webElement) {
assertHasOptionWithIndex(index, webElement);
if (optionWithIndexIsDeselected(index, webElement)) {
throw new WebDriverAssertionError("Option with index " + quote(index) + " is not selected", webElement);
}
}
public static void assertOptionWithIndexIsDeselected(int index, WebElement webElement) {
assertHasOptionWithIndex(index, webElement);
if (optionWithIndexIsSelected(index, webElement)) {
throw new WebDriverAssertionError("Option with index " + quote(index) + " is not deselected", webElement);
}
}
}
| 37.958697 | 298 | 0.689851 |
7080f0fbee9356ec9dca489588e37f3b249cbdf6 | 159 | go | Go | doc.go | larsth/rmsg-messengerd | fbbc3897683e17a37201fd0027ff04931284f272 | [
"MIT"
] | null | null | null | doc.go | larsth/rmsg-messengerd | fbbc3897683e17a37201fd0027ff04931284f272 | [
"MIT"
] | null | null | null | doc.go | larsth/rmsg-messengerd | fbbc3897683e17a37201fd0027ff04931284f272 | [
"MIT"
] | null | null | null | //Package rmsgmessengerd is an application which is used to send distributed Livestream
//telemetry messages and receive tele commands
package rmsgmessengerd
| 39.75 | 88 | 0.842767 |
b049fc726801ef726e3651fe85c6453f483293c0 | 400 | html | HTML | pages/templates/admin/includes/content_form.html | GrAndSE/django-pages | 003f7492e8b9899f7c0d62b614fe635f96b8862e | [
"BSD-3-Clause"
] | null | null | null | pages/templates/admin/includes/content_form.html | GrAndSE/django-pages | 003f7492e8b9899f7c0d62b614fe635f96b8862e | [
"BSD-3-Clause"
] | 1 | 2017-12-14T05:04:28.000Z | 2017-12-14T05:04:28.000Z | pages/templates/admin/includes/content_form.html | GrAndSE/django-pages | 003f7492e8b9899f7c0d62b614fe635f96b8862e | [
"BSD-3-Clause"
] | null | null | null | {% for form in formset %}
<h2>{{ form.place }}</h2>
{% for field in form %}
<div class="form-row field-{{ field.name }}">
<div class="{% if not field.is_readonly and field.errors %} errors{% endif %}">
{{ field.label_tag }}
{{ field }}
{% if field.help_text %}<p class="help">{{ field.help_text }}</p>{% endif %}
</div>
</div>
{% endfor %}
{% endfor %}
| 28.571429 | 83 | 0.5225 |
de424ed59d4e2f204cdbcf04b420fe22225fb2fe | 24,348 | rs | Rust | src/lib.rs | dabreegster/fast_paths | 82e9a2ef417af6de1b2cb41bcee41b6302db1b4a | [
"Apache-2.0",
"MIT"
] | 2 | 2019-12-14T16:20:56.000Z | 2020-07-06T21:30:57.000Z | src/lib.rs | dabreegster/fast_paths | 82e9a2ef417af6de1b2cb41bcee41b6302db1b4a | [
"Apache-2.0",
"MIT"
] | null | null | null | src/lib.rs | dabreegster/fast_paths | 82e9a2ef417af6de1b2cb41bcee41b6302db1b4a | [
"Apache-2.0",
"MIT"
] | null | null | null | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#[macro_use]
extern crate log;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
pub use crate::constants::*;
pub use crate::fast_graph::FastGraph;
pub use crate::fast_graph32::FastGraph32;
pub use crate::fast_graph_builder::FastGraphBuilder;
pub use crate::fast_graph_builder::Params;
pub use crate::input_graph::Edge;
pub use crate::input_graph::InputGraph;
pub use crate::path_calculator::PathCalculator;
pub use crate::shortest_path::ShortestPath;
mod constants;
#[cfg(test)]
mod dijkstra;
mod fast_graph;
mod fast_graph32;
mod fast_graph_builder;
#[cfg(test)]
mod floyd_warshall;
mod heap_item;
mod input_graph;
mod node_contractor;
mod path_calculator;
mod preparation_graph;
mod shortest_path;
mod valid_flags;
mod witness_search;
/// Prepares the given `InputGraph` for fast shortest path calculations.
pub fn prepare(input_graph: &InputGraph) -> FastGraph {
FastGraphBuilder::build(input_graph)
}
/// Like `prepare()`, but allows specifying some parameters used for the graph preparation.
pub fn prepare_with_params(input_graph: &InputGraph, params: &Params) -> FastGraph {
FastGraphBuilder::build_with_params(input_graph, params)
}
/// Prepares the given input graph using a fixed node ordering, which can be any permutation
/// of the node ids. This can be used to speed up the graph preparation if you have done
/// it for a similar graph with an equal number of nodes. For example if you have changed some
/// of the edge weights only.
pub fn prepare_with_order(input_graph: &InputGraph, order: &[NodeId]) -> Result<FastGraph, String> {
FastGraphBuilder::build_with_order(input_graph, order)
}
/// Calculates the shortest path from `source` to `target`.
pub fn calc_path(fast_graph: &FastGraph, source: NodeId, target: NodeId) -> Option<ShortestPath> {
let mut calc = PathCalculator::new(fast_graph.get_num_nodes());
calc.calc_path(fast_graph, source, target)
}
/// Calculates the shortest path from any of the `sources` to any of the `targets`.
///
/// The path returned will be the one with minimum weight among all possible paths between the sources
/// and targets. The sources and targets can also be assigned an initial weight. In this case the
/// path returned will be the one that minimizes start_weight + path-weight + target_weight. The
/// weight of the path also includes start_weight and target_weight.
pub fn calc_path_multiple_sources_and_targets(
fast_graph: &FastGraph,
sources: Vec<(NodeId, Weight)>,
target: Vec<(NodeId, Weight)>,
) -> Option<ShortestPath> {
let mut calc = PathCalculator::new(fast_graph.get_num_nodes());
calc.calc_path_multiple_sources_and_targets(fast_graph, sources, target)
}
/// Creates a `PathCalculator` that can be used to run many shortest path calculations in a row.
/// This is the preferred way to calculate shortest paths in case you are calculating more than
/// one path. Use one `PathCalculator` for each thread.
pub fn create_calculator(fast_graph: &FastGraph) -> PathCalculator {
PathCalculator::new(fast_graph.get_num_nodes())
}
/// Returns the node ordering of a prepared graph. This can be used to run the preparation with
/// `prepare_with_order()`.
pub fn get_node_ordering(fast_graph: &FastGraph) -> Vec<NodeId> {
fast_graph.get_node_ordering()
}
/// When serializing a `FastGraph` in a larger struct, use `#[serde(serialize_with =
/// "fast_paths::serialize_32`)]` to transform the graph to a 32-bit representation. This will use
/// 50% more RAM than serializing without transformation, but the resulting size will be 50% less.
/// It will panic if the graph has more than 2^32 nodes or edges or values for weight.
pub fn serialize_32<S: Serializer>(fg: &FastGraph, s: S) -> Result<S::Ok, S::Error> {
FastGraph32::new(fg).serialize(s)
}
/// When deserializing a `FastGraph` in a larger struct, use `#[serde(deserialize_with =
/// "fast_paths::deserialize_32`)]` to transform the graph from a 32-bit representation to the
/// current platform's supported size. This is necessary when serializing on a 64-bit system and
/// deserializing on a 32-bit system, such as WASM.
pub fn deserialize_32<'de, D: Deserializer<'de>>(d: D) -> Result<FastGraph, D::Error> {
let fg32 = <FastGraph32>::deserialize(d)?;
Ok(fg32.convert_to_usize())
}
#[cfg(test)]
mod tests {
use std::error::Error;
use std::fs::{remove_file, File};
use std::time::SystemTime;
use rand::rngs::StdRng;
use rand::Rng;
use stopwatch::Stopwatch;
use crate::constants::NodeId;
use crate::dijkstra::Dijkstra;
use crate::fast_graph::FastGraph;
use crate::floyd_warshall::FloydWarshall;
use crate::path_calculator::PathCalculator;
use crate::preparation_graph::PreparationGraph;
use super::*;
#[test]
fn routing_on_random_graph() {
const REPEATS: usize = 100;
for _i in 0..REPEATS {
run_test_on_random_graph();
}
}
fn run_test_on_random_graph() {
const NUM_NODES: usize = 50;
const NUM_QUERIES: usize = 1_000;
const MEAN_DEGREE: f32 = 2.0;
let mut rng = create_rng();
let input_graph = InputGraph::random(&mut rng, NUM_NODES, MEAN_DEGREE);
debug!("random graph: \n {:?}", input_graph);
let fast_graph = prepare(&input_graph);
let mut path_calculator = create_calculator(&fast_graph);
let dijkstra_graph = PreparationGraph::from_input_graph(&input_graph);
let mut dijkstra = Dijkstra::new(input_graph.get_num_nodes());
let mut fw = FloydWarshall::new(input_graph.get_num_nodes());
fw.prepare(&input_graph);
let mut num_different_paths = 0;
for _i in 0..NUM_QUERIES {
let source = rng.gen_range(0, input_graph.get_num_nodes());
let target = rng.gen_range(0, input_graph.get_num_nodes());
let path_fast = path_calculator
.calc_path(&fast_graph, source, target)
.unwrap_or(ShortestPath::none(source, target));
let path_dijkstra = dijkstra
.calc_path(&dijkstra_graph, source, target)
.unwrap_or(ShortestPath::none(source, target));
let weight_fast = path_fast.get_weight();
let weight_dijkstra = path_dijkstra.get_weight();
let weight_fw = fw.calc_weight(source, target);
assert_eq!(
weight_fw, weight_fast,
"\nNo agreement for routing query from: {} to: {}\nFloyd-Warshall: {}\nCH: {}\
\n Failing graph:\n{:?}",
source, target, weight_fw, weight_fast, input_graph
);
assert_eq!(
path_dijkstra, path_fast,
"\nNo agreement for routing query from: {} to: {}\nDijkstra: {}\nCH: {}\
\n Failing graph:\n{:?}",
source, target, weight_dijkstra, weight_fast, input_graph
);
if path_dijkstra.get_nodes() != path_fast.get_nodes() {
num_different_paths += 1;
}
}
if num_different_paths as f32 > 0.1 * NUM_QUERIES as f32 {
panic!(
"too many different paths: {}, out of {}, a few different paths can be expected \
because of unambiguous shortest paths, but if there are too many something is \
wrong",
num_different_paths, NUM_QUERIES
);
}
}
#[test]
fn routing_with_multiple_sources_and_targets_on_random_graph() {
const REPEATS: usize = 20;
for _ in 0..REPEATS {
const NUM_NODES: usize = 50;
const NUM_QUERIES: usize = 1_000;
const MEAN_DEGREE: f32 = 2.0;
const NUM_SOURCES: usize = 3;
const NUM_TARGETS: usize = 3;
let mut rng = create_rng();
let input_graph = InputGraph::random(&mut rng, NUM_NODES, MEAN_DEGREE);
debug!("random graph: \n {:?}", input_graph);
let fast_graph = prepare(&input_graph);
let mut path_calculator = create_calculator(&fast_graph);
let dijkstra_graph = PreparationGraph::from_input_graph(&input_graph);
let mut dijkstra = Dijkstra::new(input_graph.get_num_nodes());
let mut num_different_paths = 0;
let mut num_paths_not_found = 0;
for _ in 0..NUM_QUERIES {
// This may pick duplicate source nodes, and even duplicate source nodes with
// different weights; anyway that shouldn't break anything.
let sources =
gen_weighted_nodes(&mut rng, input_graph.get_num_nodes(), NUM_SOURCES);
let targets =
gen_weighted_nodes(&mut rng, input_graph.get_num_nodes(), NUM_TARGETS);
let fast_path = path_calculator.calc_path_multiple_sources_and_targets(
&fast_graph,
sources.clone(),
targets.clone(),
);
let mut dijkstra_paths: Vec<(Option<ShortestPath>, Weight, Weight)> = vec![];
for (source, source_weight) in &sources {
for (target, target_weight) in &targets {
dijkstra_paths.push((
dijkstra.calc_path(&dijkstra_graph, *source, *target),
*source_weight,
*target_weight,
))
}
}
let found_dijkstras: Vec<(ShortestPath, Weight, Weight)> = dijkstra_paths
.into_iter()
.filter(|(p, source_weight, target_weight)| {
p.is_some() && *source_weight < WEIGHT_MAX && *target_weight < WEIGHT_MAX
})
.map(|(p, source_weight, target_weight)| {
(p.unwrap(), source_weight, target_weight)
})
.collect();
// We have to make sure fast_path is as short as the shortest of all dijkstra_paths
let shortest_dijkstra_weight = found_dijkstras
.iter()
.map(|(p, source_weight, target_weight)| {
p.get_weight() + source_weight + target_weight
})
.min();
if shortest_dijkstra_weight.is_none() {
assert!(fast_path.is_none());
num_paths_not_found += 1;
continue;
}
assert!(fast_path.is_some());
let f = fast_path.unwrap();
let w = shortest_dijkstra_weight.unwrap();
assert_eq!(w, f.get_weight(),
"\nfast_path's weight {} does not match the weight of the shortest Dijkstra path {}.\
\nsources: {:?}\
\ntargets: {:?}\
\nFailing graph:\n{:?}",
f.get_weight(), w, sources, targets, input_graph);
// There can be multiple options with the same weight. fast_path has to match
// at least one of them
let matching_dijkstras: Vec<(ShortestPath, Weight, Weight)> = found_dijkstras
.into_iter()
.filter(|(p, source_weight, target_weight)| {
p.get_weight() + source_weight + target_weight == f.get_weight()
&& p.get_source() == f.get_source()
&& p.get_target() == f.get_target()
})
.collect();
assert!(
matching_dijkstras.len() > 0,
"There has to be at least one Dijkstra path with source,target and weight equal to fast_path"
);
// one of the matching Dijkstra's should have the same nodes as fast_path, but in
// some rare cases this might not be true, because there are multiple shortest paths.
if !matching_dijkstras
.into_iter()
.any(|(p, _, _)| p.get_nodes() == f.get_nodes())
{
num_different_paths += 1;
}
}
if num_paths_not_found as f32 > 0.5 * NUM_QUERIES as f32 {
panic!(
"too many paths not found: {}, out of {}",
num_paths_not_found, NUM_QUERIES
)
}
if num_different_paths as f32 > 0.1 * NUM_QUERIES as f32 {
panic!(
"too many different paths: {}, out of {}, a few different paths can be expected \
because of unambiguous shortest paths, but if there are too many something is \
wrong",
num_different_paths, NUM_QUERIES
);
}
}
}
fn gen_weighted_nodes(rng: &mut StdRng, max_node: usize, num: usize) -> Vec<(NodeId, Weight)> {
(0..num)
.map(|_| {
(
rng.gen_range(0, max_node),
// sometimes use max weight
if rng.gen_range(0, 100) < 3 {
WEIGHT_MAX
} else {
rng.gen_range(0, 100)
},
)
})
.collect()
}
#[test]
fn save_to_and_load_from_disk() {
let mut g = InputGraph::new();
g.add_edge(0, 5, 6);
g.add_edge(5, 2, 1);
g.add_edge(2, 3, 4);
g.freeze();
let fast_graph = prepare(&g);
save_to_disk(&fast_graph, "example.fp").expect("writing to disk failed");
let loaded = load_from_disk("example.fp").unwrap();
remove_file("example.fp").expect("deleting file failed");
assert_eq!(fast_graph.get_num_nodes(), loaded.get_num_nodes());
assert_eq!(fast_graph.get_num_in_edges(), loaded.get_num_in_edges());
assert_eq!(fast_graph.get_num_out_edges(), loaded.get_num_out_edges());
}
#[test]
fn save_to_and_load_from_disk_32() {
let mut g = InputGraph::new();
g.add_edge(0, 5, 6);
g.add_edge(5, 2, 1);
g.add_edge(2, 3, 4);
g.freeze();
let fast_graph = prepare(&g);
save_to_disk32(&fast_graph, "example32.fp").expect("writing to disk failed");
let loaded = load_from_disk32("example32.fp").unwrap();
remove_file("example32.fp").expect("deleting file failed");
assert_eq!(fast_graph.get_num_nodes(), loaded.get_num_nodes());
assert_eq!(fast_graph.get_num_in_edges(), loaded.get_num_in_edges());
assert_eq!(fast_graph.get_num_out_edges(), loaded.get_num_out_edges());
}
#[test]
fn deterministic_result() {
const NUM_NODES: usize = 50;
const MEAN_DEGREE: f32 = 2.0;
// Repeat a few times to reduce test flakiness.
for _ in 0..10 {
let mut rng = create_rng();
let input_graph = InputGraph::random(&mut rng, NUM_NODES, MEAN_DEGREE);
let serialized1 = bincode::serialize(&prepare(&input_graph)).unwrap();
let serialized2 = bincode::serialize(&prepare(&input_graph)).unwrap();
if serialized1 != serialized2 {
panic!("Preparing and serializing the same graph twice produced different results");
}
}
}
#[ignore]
#[test]
fn run_performance_test_dist() {
println!("Running performance test for Bremen dist");
// road network extracted from OSM data from Bremen, Germany using the road distance as weight
run_performance_test(
&InputGraph::from_file("meta/test_maps/bremen_dist.gr"),
&Params::default(),
845493338,
30265,
)
}
#[ignore]
#[test]
fn run_performance_test_time() {
println!("Running performance test for Bremen time");
// road network extracted from OSM data from Bremen, Germany using the travel time as weight
run_performance_test(
&InputGraph::from_file("meta/test_maps/bremen_time.gr"),
&Params::default(),
88104267255,
30265,
);
}
#[ignore]
#[test]
fn run_performance_test_ballard() {
println!("Running performance test for ballard");
run_performance_test(
&InputGraph::from_file("meta/test_maps/graph_ballard.gr"),
&Params::new(0.01),
28409159409,
14992,
);
}
#[ignore]
#[test]
fn run_performance_test_23rd() {
println!("Running performance test for 23rd");
run_performance_test(
&InputGraph::from_file("meta/test_maps/graph_23rd.gr"),
&Params::default(),
19438403873,
20421,
);
}
#[ignore]
#[test]
fn run_performance_test_south_seattle_car() {
println!("Running performance test for South Seattle car");
run_performance_test(
&InputGraph::from_file("meta/test_maps/south_seattle_car.gr"),
&Params::default(),
77479396,
30805,
);
}
#[ignore]
#[test]
fn run_performance_test_dist_fixed_ordering() {
println!("Running performance test for Bremen dist (fixed node ordering)");
let input_graph = InputGraph::from_file("meta/test_maps/bremen_dist.gr");
let mut fast_graph = prepare(&input_graph);
let order = get_node_ordering(&fast_graph);
prepare_algo(
&mut |input_graph| fast_graph = prepare_with_order(input_graph, &order).unwrap(),
&input_graph,
);
print_fast_graph_stats(&fast_graph);
let mut path_calculator = PathCalculator::new(fast_graph.get_num_nodes());
do_run_performance_test(
&mut |s, t| path_calculator.calc_path(&fast_graph, s, t),
input_graph.get_num_nodes(),
845493338,
30265,
);
}
fn run_performance_test(
input_graph: &InputGraph,
params: &Params,
expected_checksum: usize,
expected_num_not_found: usize,
) {
let mut fast_graph = FastGraph::new(1);
prepare_algo(
&mut |input_graph| fast_graph = prepare_with_params(input_graph, params),
&input_graph,
);
print_fast_graph_stats(&fast_graph);
let mut path_calculator = PathCalculator::new(fast_graph.get_num_nodes());
do_run_performance_test(
&mut |s, t| path_calculator.calc_path(&fast_graph, s, t),
input_graph.get_num_nodes(),
expected_checksum,
expected_num_not_found,
);
}
fn print_fast_graph_stats(fast_graph: &FastGraph) {
println!(
"number of nodes (fast graph) ...... {}",
fast_graph.get_num_nodes()
);
println!(
"number of out-edges (fast graph) .. {}",
fast_graph.get_num_out_edges()
);
println!(
"number of in-edges (fast graph) .. {}",
fast_graph.get_num_in_edges()
);
}
pub fn prepare_algo<F>(preparation: &mut F, input_graph: &InputGraph)
where
F: FnMut(&InputGraph),
{
let mut time = Stopwatch::new();
time.start();
preparation(&input_graph);
time.stop();
println!(
"number of nodes (input graph) ..... {}",
input_graph.get_num_nodes()
);
println!(
"number of edges (input graph) ..... {}",
input_graph.get_num_edges()
);
println!(
"preparation time .................. {} ms",
time.elapsed_ms()
);
}
fn do_run_performance_test<F>(
calc_path: &mut F,
num_nodes: usize,
expected_checksum: usize,
expected_num_not_found: usize,
) where
F: FnMut(NodeId, NodeId) -> Option<ShortestPath>,
{
let num_queries = 100_000;
let seed = 123;
let mut rng = create_rng_with_seed(seed);
let mut checksum = 0;
let mut num_not_found = 0;
let mut time = Stopwatch::new();
for _i in 0..num_queries {
let source = rng.gen_range(0, num_nodes);
let target = rng.gen_range(0, num_nodes);
time.start();
let path = calc_path(source, target);
time.stop();
match path {
Some(path) => checksum += path.get_weight(),
None => num_not_found += 1,
}
}
println!(
"total query time .................. {} ms",
time.elapsed_ms()
);
println!(
"query time on average ............. {} micros",
time.elapsed().as_micros() / (num_queries as u128)
);
assert_eq!(expected_checksum, checksum, "invalid checksum");
assert_eq!(
expected_num_not_found, num_not_found,
"invalid number of paths not found"
);
}
fn create_rng() -> StdRng {
let seed = create_seed();
create_rng_with_seed(seed)
}
fn create_rng_with_seed(seed: u64) -> StdRng {
debug!("creating random number generator with seed: {}", seed);
rand::SeedableRng::seed_from_u64(seed)
}
fn create_seed() -> u64 {
SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_nanos() as u64
}
/// Saves the given prepared graph to disk
fn save_to_disk(fast_graph: &FastGraph, file_name: &str) -> Result<(), Box<dyn Error>> {
let file = File::create(file_name)?;
Ok(bincode::serialize_into(file, fast_graph)?)
}
/// Restores a prepared graph from disk
fn load_from_disk(file_name: &str) -> Result<FastGraph, Box<dyn Error>> {
let file = File::open(file_name)?;
Ok(bincode::deserialize_from(file)?)
}
/// Saves the given prepared graph to disk thereby enforcing a 32bit representation no matter whether
/// the system in use uses 32 or 64bit. This is useful when creating the graph on a 64bit system and
/// afterwards loading it on a 32bit system.
/// Note: Using this method requires an extra +50% of RAM while storing the graph (even though
/// the graph will use 50% *less* disk space when it has been saved.
fn save_to_disk32(fast_graph: &FastGraph, file_name: &str) -> Result<(), Box<dyn Error>> {
let fast_graph32 = &FastGraph32::new(fast_graph);
let file = File::create(file_name)?;
Ok(bincode::serialize_into(file, fast_graph32)?)
}
/// Loads a graph from disk that was saved in 32bit representation, i.e. using save_to_disk32. The
/// graph will use usize to store integers, so most commonly either 32 or 64bits per integer
/// depending on the system in use.
/// Note: Using this method requires an extra +50% RAM while loading the graph.
fn load_from_disk32(file_name: &str) -> Result<FastGraph, Box<dyn Error>> {
let file = File::open(file_name)?;
let r: Result<FastGraph32, Box<dyn Error>> = Ok(bincode::deserialize_from(file)?);
r.map(|g| g.convert_to_usize())
}
}
| 39.270968 | 113 | 0.591835 |
77ae15536665eafee3a5971d315e2c6b077f4227 | 6,811 | dart | Dart | lib/survey.dart | PrevenTech/client | 1f831638be28bd5db53a65c761b838170812d641 | [
"MIT"
] | null | null | null | lib/survey.dart | PrevenTech/client | 1f831638be28bd5db53a65c761b838170812d641 | [
"MIT"
] | 6 | 2020-06-22T03:51:21.000Z | 2020-06-24T04:49:15.000Z | lib/survey.dart | PrevenTech/client | 1f831638be28bd5db53a65c761b838170812d641 | [
"MIT"
] | null | null | null | import 'package:flutter/material.dart';
import 'misc/nav.dart';
class SurveyScreen extends StatefulWidget {
@override
createState() => SurveyScreenState();
}
enum YesOrNo {yes, no}
class SurveyScreenState extends State<SurveyScreen> {
var radioItem = YesOrNo.no;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Symptoms Survey'),
),
drawer: AppDrawer(),
body: ListView(
padding: EdgeInsets.all(10.0),
children: <Widget>[
Card(
child: Padding(
padding: EdgeInsets.all(10.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text('1. Have you come into close contact (within 6 feet) with someone who has a laboratory confirmed COVID – 19 diagnosis in the past 14 days?', style: TextStyle(fontWeight: FontWeight.w400),),
ListTile(
leading: Radio(
groupValue: radioItem,
value: YesOrNo.yes,
onChanged: (YesOrNo value) {
this.setState(() {
radioItem = value;
});
},
),
title: Text('Yes'),
),
ListTile(
leading: Radio(
groupValue: radioItem,
value: YesOrNo.no,
onChanged: (YesOrNo value) {
this.setState(() {
radioItem = value;
});
},
),
title: Text('No'),
),
],
),
),
),
Card(
child: Padding(
padding: EdgeInsets.all(10.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text('2. Do you have fever or chills?', style: TextStyle(fontWeight: FontWeight.w400),),
ListTile(
leading: Radio(
groupValue: radioItem,
value: YesOrNo.yes,
onChanged: (YesOrNo value) {
this.setState(() {
radioItem = value;
});
},
),
title: Text('Yes'),
),
ListTile(
leading: Radio(
groupValue: radioItem,
value: YesOrNo.no,
onChanged: (YesOrNo value) {
this.setState(() {
radioItem = value;
});
},
),
title: Text('No'),
),
],
),
),
),
Card(
child: Padding(
padding: EdgeInsets.all(10.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text('3. Do you have shortness of breath or difficulty breathing?', style: TextStyle(fontWeight: FontWeight.w400),),
ListTile(
leading: Radio(
groupValue: radioItem,
value: YesOrNo.yes,
onChanged: (YesOrNo value) {
this.setState(() {
radioItem = value;
});
},
),
title: Text('Yes'),
),
ListTile(
leading: Radio(
groupValue: radioItem,
value: YesOrNo.no,
onChanged: (YesOrNo value) {
this.setState(() {
radioItem = value;
});
},
),
title: Text('No'),
),
],
),
),
),
Card(
child: Padding(
padding: EdgeInsets.all(10.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text('4. Do you have headache?', style: TextStyle(fontWeight: FontWeight.w400),),
ListTile(
leading: Radio(
groupValue: radioItem,
value: YesOrNo.yes,
onChanged: (YesOrNo value) {
this.setState(() {
radioItem = value;
});
},
),
title: Text('Yes'),
),
ListTile(
leading: Radio(
groupValue: radioItem,
value: YesOrNo.no,
onChanged: (YesOrNo value) {
this.setState(() {
radioItem = value;
});
},
),
title: Text('No'),
),
],
),
),
),
Card(
child: Padding(
padding: EdgeInsets.all(10.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text('5. Do you have sore throat?', style: TextStyle(fontWeight: FontWeight.w400),),
ListTile(
leading: Radio(
groupValue: radioItem,
value: YesOrNo.yes,
onChanged: (YesOrNo value) {
this.setState(() {
radioItem = value;
});
},
),
title: Text('Yes'),
),
ListTile(
leading: Radio(
groupValue: radioItem,
value: YesOrNo.no,
onChanged: (YesOrNo value) {
this.setState(() {
radioItem = value;
});
},
),
title: Text('No'),
),
],
),
),
),
],
),
);
}
} | 33.717822 | 212 | 0.346205 |
d8f254f4bd1645a21cb1020f515a24ae49a9b8d7 | 3,840 | sql | SQL | openprescribing/measure_definitions/tmp.sql | annapowellsmith/openpresc | cfa9fb07d6fc2ee304159c04fcc132cefcf78745 | [
"MIT"
] | 91 | 2015-10-14T09:10:32.000Z | 2022-03-10T22:09:21.000Z | openprescribing/measure_definitions/tmp.sql | annapowellsmith/openpresc | cfa9fb07d6fc2ee304159c04fcc132cefcf78745 | [
"MIT"
] | 1,828 | 2015-12-04T14:52:27.000Z | 2022-03-31T08:51:14.000Z | openprescribing/measure_definitions/tmp.sql | HDRUK/openprescribing | 510e8c07e841cd42284c109774d1730b6463f376 | [
"MIT"
] | 27 | 2015-12-03T18:26:56.000Z | 2021-01-09T21:58:53.000Z | # icsdose denominator
SELECT "v1" as v, sum(items) AS items
FROM hscic.prescribing_v1
WHERE practice != '-' AND month = '2019-12-01' AND (
bnf_code LIKE "0302000C0%" OR
bnf_code LIKE "0302000K0%" OR
bnf_code LIKE "0302000N0%" OR
bnf_code LIKE "0302000R0%" OR
bnf_code LIKE "0302000U0%" OR
bnf_code LIKE "0302000V0%" OR
bnf_code LIKE "0301011AB%"
) AND NOT (
bnf_code LIKE "0302000N0%AV" OR
bnf_code LIKE "0302000N0%AW"
)
UNION ALL
SELECT "v2" as v, sum(items) AS items
FROM hscic.prescribing_v2
WHERE practice != '-' AND month = '2019-12-01' AND (
bnf_code LIKE "0302000C0%" OR
bnf_code LIKE "0302000K0%" OR
bnf_code LIKE "0302000N0%" OR
bnf_code LIKE "0302000R0%" OR
bnf_code LIKE "0302000U0%" OR
bnf_code LIKE "0302000V0%" OR
bnf_code LIKE "0301011AB%"
) AND NOT (
bnf_code LIKE "0302000N0%AV" OR
bnf_code LIKE "0302000N0%AW"
)
ORDER BY v
-----
# icsdose numerator
SELECT "v1" as v, sum(items) AS items
FROM hscic.prescribing_v1
WHERE practice != '-' AND month = '2019-12-01' AND (
bnf_code LIKE "0302000C0%AC" OR
bnf_code LIKE "0302000C0%AU" OR
bnf_code LIKE "0302000C0%BK" OR
bnf_code LIKE "0302000C0%BW" OR
bnf_code LIKE "0302000C0%BZ" OR
bnf_code LIKE "0302000C0%CA" OR
bnf_code LIKE "0302000K0%AH" OR
bnf_code LIKE "0302000K0%AY" OR
bnf_code LIKE "0302000K0%AU" OR
bnf_code LIKE "0302000N0%AF" OR
bnf_code LIKE "0302000N0%AP" OR
bnf_code LIKE "0302000N0%AU" OR
bnf_code LIKE "0302000N0%AZ" OR
bnf_code LIKE "0302000N0%BC" OR
bnf_code LIKE "0302000N0%BG" OR
bnf_code LIKE "0302000N0%BK" OR
bnf_code LIKE "0302000U0%AB" OR
bnf_code LIKE "0302000U0%AC" OR
bnf_code LIKE "0302000V0%AA"
)
UNION ALL
SELECT "v2" as v, sum(items) AS items
FROM hscic.prescribing_v2
WHERE practice != '-' AND month = '2019-12-01' AND (
bnf_code LIKE "0302000C0%AC" OR
bnf_code LIKE "0302000C0%AU" OR
bnf_code LIKE "0302000C0%BK" OR
bnf_code LIKE "0302000C0%BW" OR
bnf_code LIKE "0302000C0%BZ" OR
bnf_code LIKE "0302000C0%CA" OR
bnf_code LIKE "0302000K0%AH" OR
bnf_code LIKE "0302000K0%AY" OR
bnf_code LIKE "0302000K0%AU" OR
bnf_code LIKE "0302000N0%AF" OR
bnf_code LIKE "0302000N0%AP" OR
bnf_code LIKE "0302000N0%AU" OR
bnf_code LIKE "0302000N0%AZ" OR
bnf_code LIKE "0302000N0%BC" OR
bnf_code LIKE "0302000N0%BD" OR
bnf_code LIKE "0302000N0%BG" OR
bnf_code LIKE "0302000N0%BK" OR
bnf_code LIKE "0302000U0%AB" OR
bnf_code LIKE "0302000V0%AA"
)
ORDER BY v
-----
WITH v1 AS (
SELECT bnf_code AS v1_bnf_code, SUM(items) AS v1_items
FROM hscic.prescribing_v1
WHERE month = '2019-12-01' AND (
bnf_code LIKE '0401%' AND
bnf_code NOT LIKE '0401010AC%' AND
bnf_code NOT LIKE '0401010AD%' AND
bnf_code NOT LIKE '0401020K0%AD' AND
bnf_code NOT LIKE '0401020K0%AE' AND
bnf_code NOT LIKE '0401020K0%BQ'
)
GROUP BY bnf_code
),
v1_full AS (
SELECT v1_bnf_code, presentation AS v1_bnf_name, v1_items
FROM v1 LEFT OUTER JOIN hscic.bnf ON v1_bnf_code = bnf.presentation_code
),
v2 AS (
SELECT bnf_code AS v2_bnf_code, SUM(items) AS v2_items
FROM hscic.prescribing_v2
WHERE month = '2019-12-01' AND (
bnf_code LIKE '0401%' AND
bnf_code NOT LIKE '0401010AC%' AND
bnf_code NOT LIKE '0401010AD%' AND
bnf_code NOT LIKE '0401020K0%AD' AND
bnf_code NOT LIKE '0401020K0%AE' AND
bnf_code NOT LIKE '0401020K0%BQ'
)
GROUP BY bnf_code
),
v2_full AS (
SELECT v2_bnf_code, presentation AS v2_bnf_name, v2_items
FROM v2 LEFT OUTER JOIN hscic.bnf ON v2_bnf_code = bnf.presentation_code
)
SELECT
COALESCE(v1_bnf_code, v2_bnf_code) AS bnf_code,
COALESCE(v1_bnf_name, v2_bnf_name) AS bnf_name,
COALESCE(v1_items, 0) AS v1_items,
COALESCE(v2_items, 0) AS v2_items
FROM v1_full FULL OUTER JOIN v2_full ON v1_bnf_code = v2_bnf_code
WHERE COALESCE(v1_items, 0) != COALESCE(v2_items, 0)
| 27.234043 | 74 | 0.720833 |
6f7c19f89d40a17ebd0b9ded93994d15d834736c | 3,370 | lua | Lua | Scripts/score_handler.lua | Svampson/stepmania-theme | f1d5fac5d0449e01eb1bb00bfb83a14ff319f08c | [
"MIT"
] | 1 | 2018-05-22T04:34:01.000Z | 2018-05-22T04:34:01.000Z | Scripts/score_handler.lua | Svampson/stepmania-theme | f1d5fac5d0449e01eb1bb00bfb83a14ff319f08c | [
"MIT"
] | 19 | 2018-02-24T12:22:33.000Z | 2018-02-25T20:47:32.000Z | Scripts/score_handler.lua | Svampson/stepmania-theme | f1d5fac5d0449e01eb1bb00bfb83a14ff319f08c | [
"MIT"
] | null | null | null | -- Recalculate the score to use DDR A style calculations
-- Special thanks to Aaron C for his good documentation on various DDR scoring systems (http://aaronin.jp/ddrssystem.html#ss10)
function get_score(steps, score, rounded)
local style = stepstype_to_style[steps:GetStepsType()][1]
-- Holds get counted twice since both the inital press and the release counts
--
-- The caveat here is that in DDR A, Judgments only counts once per row, while in stepmania it registers once per column.
-- So a successful jump will register as one step in DDR, while it will register as two in Stepmania.
-- This will cause the step_score to be slightly off, the more jumps in a song, the more it will drift.
local total_notes_and_holds = steps:GetRadarValues("PlayerNumber_P1"):GetValue("RadarCategory_TapsAndHolds") + steps:GetRadarValues("PlayerNumber_P1"):GetValue("RadarCategory_Holds")
-- Since mines are basically the shock arrow equilevent in StepMania, I count them instead.
-- But since a shock arrow in DDR always covers all columns and counts as one,
-- I have to divide the number of mines with the amount of columns to make scoring on DDR songs
-- equivalent to the arcade version. This might make the scoring ~slightly~ off for stepmania songs
local total_mines = steps:GetRadarValues("PlayerNumber_P1"):GetValue("RadarCategory_Mines") / style.columns_per_player
local step_score = 1000000 / (total_notes_and_holds + total_mines)
-- Judgement points
local tap_judgments = {
{ type = "W1", value = step_score },
{ type = "W2", value = step_score - 10 },
{ type = "W3", value = (step_score * 0.6) - 10 },
{ type = "W4", value = (step_score * 0.2) - 10 },
{ type = "AvoidMine", value = step_score / style.columns_per_player },
}
-- Calculate actual score
local actual_score = 0
local scores = {}
for i, v in ipairs(tap_judgments) do
local t = "TapNoteScore_" .. v.type
local tap_score
-- Differentiate between HighScore and PlayerStageStats (the first one has GetTapNoteScore while the other one has GetTapNoteScores)
if score.GetTapNoteScore ~= nil then
tap_score = score:GetTapNoteScore(t)
else
tap_score = score:GetTapNoteScores(t)
end
actual_score = actual_score + (tap_score * v.value)
end
if score.GetTapNoteScore ~= nil then
actual_score = actual_score + (score:GetHoldNoteScore("HoldNoteScore_Held") * step_score)
else
actual_score = actual_score + (score:GetHoldNoteScores("HoldNoteScore_Held") * step_score)
end
return rounded and math.floor(actual_score/10) * 10 or actual_score
end
function grade_from_score(score)
if (score > 989990) then return "AAA"
elseif (score > 949990) then return "AA+"
elseif (score > 899990) then return "AA"
elseif (score > 889990) then return "AA-"
elseif (score > 849990) then return "A+"
elseif (score > 799990) then return "A"
elseif (score > 789990) then return "A-"
elseif (score > 749990) then return "B+"
elseif (score > 699990) then return "B"
elseif (score > 689990) then return "B-"
elseif (score > 649990) then return "C+"
elseif (score > 599990) then return "C"
elseif (score > 589990) then return "C-"
elseif (score > 549990) then return "D+"
else return "D" end
end
| 39.647059 | 186 | 0.699407 |
b2d75b157f57c7832de3185889e5c4f8fbd90377 | 234 | py | Python | faketranslate/metadata.py | HeywoodKing/faketranslate | 683821eccd0004305c9f1bbfa0aae16f5fbcd829 | [
"MIT"
] | null | null | null | faketranslate/metadata.py | HeywoodKing/faketranslate | 683821eccd0004305c9f1bbfa0aae16f5fbcd829 | [
"MIT"
] | null | null | null | faketranslate/metadata.py | HeywoodKing/faketranslate | 683821eccd0004305c9f1bbfa0aae16f5fbcd829 | [
"MIT"
] | null | null | null | # -*- encoding: utf-8 -*-
"""
@File : metadata.py
@Time : 2020/1/1
@Author : flack
@Email : opencoding@hotmail.com
@ide : PyCharm
@project : faketranslate
@description : 描述
""" | 23.4 | 40 | 0.491453 |
2f210a906bdedeec8c1e953559677a66d7360812 | 1,936 | java | Java | server/src/main/java/com/decathlon/ara/configuration/JsonFactoryConfiguration.java | TroyonGuillaume/ara | c606cea442caf09934b29f69ad8ebfdfb3605f24 | [
"Apache-2.0"
] | 86 | 2019-04-04T13:52:41.000Z | 2022-01-11T16:13:01.000Z | server/src/main/java/com/decathlon/ara/configuration/JsonFactoryConfiguration.java | TroyonGuillaume/ara | c606cea442caf09934b29f69ad8ebfdfb3605f24 | [
"Apache-2.0"
] | 430 | 2019-04-09T20:11:40.000Z | 2022-03-19T07:26:45.000Z | server/src/main/java/com/decathlon/ara/configuration/JsonFactoryConfiguration.java | TroyonGuillaume/ara | c606cea442caf09934b29f69ad8ebfdfb3605f24 | [
"Apache-2.0"
] | 22 | 2019-05-15T13:34:47.000Z | 2022-03-18T18:02:53.000Z | /******************************************************************************
* Copyright (C) 2019 by the ARA Contributors *
* *
* 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.decathlon.ara.configuration;
import com.fasterxml.jackson.core.JsonFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class JsonFactoryConfiguration {
/**
* From the JsonFactory documentation:
* factory instances are thread-safe and reusable [...]
* Factory reuse is important if efficiency matters;
* most recycling of expensive construct is done on per-factory basis.
*
* @return a globally shared JsonFactory
*/
@Bean
public JsonFactory jsonFactory() {
return new JsonFactory();
}
}
| 47.219512 | 80 | 0.477789 |
2dcb47984767adf7a9ec7da6762215bbf1bc53a4 | 18,657 | htm | HTML | ShapeFiles/state_boundsfaq.htm | JupyterJones/Covid-19_Research_Notebooks | dda72440b67ecb38002918563dd64e445a7e1114 | [
"CC0-1.0"
] | 1 | 2020-06-18T00:33:24.000Z | 2020-06-18T00:33:24.000Z | ShapeFiles/state_boundsfaq.htm | JupyterJones/COVID-19-Jupyter-Notebooks | 8b65ade0d4b2b69bb50ab377655497909e3d4a05 | [
"MIT"
] | null | null | null | ShapeFiles/state_boundsfaq.htm | JupyterJones/COVID-19-Jupyter-Notebooks | 8b65ade0d4b2b69bb50ab377655497909e3d4a05 | [
"MIT"
] | null | null | null | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>STATE_BOUNDS.SHP: internal US state boundaries</title>
<link rel=schema.dc href="http://purl.org/metadata/dublin_core">
<meta name="dc.title" content="STATE_BOUNDS.SHP: internal US state boundaries ">
<meta name="dc.creator" content="Valerie Paskevich ">
<meta name="dc.subject" content="U.S. Geological Survey USGS Coastal and Marine Geology Program CMGP Woods Hole Science Center Geographic Information System GIS ArcView shapefile polyline state bounds U.S. and Canada boundary U.S. and Mexico boundary internal boundaries WHSC ">
<meta name="dc.description" content="This ArcView shapefile represents the internal boundaries of the United States and the political boundaries between the U.S., Canada and Mexico. ">
<meta name="dc.publisher" content="U.S. Geological Survey">
<meta name="dc.contributor" content="The true origin of this dataset is compiled from ESRI's 50 individual state 'trct' files. Please view the Source Information for more details ">
<meta name="dc.date" content="2005">
<meta name="dc.type" content="data.vector digital data">
<meta name="dc.format" content="Shapefile">
<meta name="dc.identifier" content="http://pubs.usgs.gov/of/2005/1071/data/background/us_bnds/state_bounds.zip">
<meta name="dc.source" content="Downloadable Data">
<meta name="dc.lang" content="en">
<meta name="dc.relation" content="Part of GIS of selected geophysical and core data in the northern Gulf of Mexico continental slope collected by the U.S. Geological Survey">
<meta name="dc.coverage.x.min" scheme="DD" content="-124.211606">
<meta name="dc.coverage.x.max" scheme="DD" content="-67.158958">
<meta name="dc.coverage.y.min" scheme="DD" content="25.837377">
<meta name="dc.coverage.y.max" scheme="DD" content="49.384359">
<meta name="dc.coverage.placeName" content="United States">
<meta name="dc.coverage.placeName" content="US">
<meta name="dc.coverage.placeName" content="contiguous 48 states">
<meta name="dc.coverage.placeName" content="North America">
<meta name="dc.rights" content="Access constraints: None; Use constraints: None">
</head>
<body>
<h3>STATE_BOUNDS.SHP: internal US state boundaries</h3>
Metadata also available as - [<A HREF="state_boundsmeta.htm">Outline</A>] - [<A HREF="state_boundsmeta.txt">Parseable text</A>]<p>
<h4>Frequently-anticipated questions:</h4>
<ul>
<li><A HREF="#what">What does this data set describe?</A>
<ol>
<li><A HREF="#what.1">How should this data set be cited?</A>
<li><A HREF="#what.2">What geographic area does the data set cover?</A>
<li><A HREF="#what.3">What does it look like?</A>
<li><A HREF="#what.4">Does the data set describe conditions during a particular time period?</A>
<li><A HREF="#what.5">What is the general form of this data set?</A>
<li><A HREF="#what.6">How does the data set represent geographic features?</A>
<li><A HREF="#what.7">How does the data set describe geographic features?</A>
</ol>
<li><A HREF="#who">Who produced the data set?</A>
<ol>
<li><A HREF="#who.1">Who are the originators of the data set?</A>
<li><A HREF="#who.2">Who also contributed to the data set?</A>
<li><A HREF="#who.3">To whom should users address questions about the data?</A>
</ol>
<li><A HREF="#why">Why was the data set created?</A>
<li><A HREF="#how">How was the data set created?</A>
<ol>
<li><A HREF="#how.1">From what previous works were the data drawn?</a>
<li><A HREF="#how.2">How were the data generated, processed, and modified?</a>
<li><A HREF="#how.3">What similar or related data should the user be aware of?</a>
</ol>
<li><A HREF="#quality">How reliable are the data; what problems remain in the data set?</A>
<ol>
<li><A HREF="#quality.1">How well have the observations been checked?</A>
<li><A HREF="#quality.2">How accurate are the geographic locations?</A>
<li><A HREF="#quality.3">How accurate are the heights or depths?</A>
<li><A HREF="#quality.4">Where are the gaps in the data? What is missing?</A>
<li><A HREF="#quality.5">How consistent are the relationships among the data, including topology?</A>
</ol>
<li><A HREF="#getacopy">How can someone get a copy of the data set?</A>
<ol>
<li><A HREF="#getacopy.0">Are there legal restrictions on access or use of the data?</A>
<li><A HREF="#getacopy.1">Who distributes the data?</A>
<li><A HREF="#getacopy.2">What's the catalog number I need to order this data set?</A>
<li><A HREF="#getacopy.3">What legal disclaimers am I supposed to read?</A>
<li><A HREF="#getacopy.4">How can I download or order the data?</A>
</ol>
<li><A HREF="#metaref">Who wrote the metadata?</A>
</ul>
<hr>
<h3><A NAME="what">What does this data set describe?</A></h3>
<div style="margin-left: 2em">
<dl>
<dt><em>Title:</em> STATE_BOUNDS.SHP: internal US state boundaries</dt>
<dt><em>Abstract:</em>
<dd>
This ArcView shapefile represents the internal boundaries of the United States and the political boundaries between the U.S., Canada and Mexico.
</dd>
<dt><em>Supplemental_Information:</em>
<dd>
This dataset was created to be used with the NOS80K coastline (allus80k.shp) to provide state bounds without redrawing the coastline. In creating the data layer, some issues of the NOS80K coastline became apparent. One example, is the US/Mexico boundary. The NOS80K coastline closes and draws a straight line well below the Texas border. The same type of problem can be seen around the U.S./Canada boundary of the Great Lakes. The state_bounds.shp will draw the political boundaries while the allus80k.shp file will display the U.S. beyond the political boundaries. If this is unacceptable to the user, they should consider masking the annexed U.S. possession.
</dd>
</dl>
</div>
<ol>
<li><A NAME="what.1"><b>How should this data set be cited?</b></A><p>
<blockquote>
Paskevich, Valerie, 2005, STATE_BOUNDS.SHP: internal US state boundaries: Open-File Report 2005-1071, U.S. Geological Survey, Coastal and Marine Geology Program, Woods Hole Science Center, Woods Hole, MA.<p>
Online Links:
<ul>
<li><A HREF="http://pubs.usgs.gov/of/2005/1071/data/background/us_bnds/state_bounds.zip"><http://pubs.usgs.gov/of/2005/1071/data/background/us_bnds/state_bounds.zip></A>
</ul>
<p>
</blockquote>
This is part of the following larger work.<p>
<blockquote>
Twichell, D.C., Cross, V.A., Paskevich, V.F., Hutchinson, D.R., Winters, W.J., and Hart, P.E., 2005, GIS of selected geophysical and core data in the northern Gulf of Mexico continental slope collected by the U.S. Geological Survey: Open-File Report 2005-1071, U.S. Geological Survey, Coastal and Marine Geology Program, Woods Hole Science Center, Woods Hole, MA.<p>
Online Links:
<ul>
<li><A HREF="http://pubs.usgs.gov/of/2005/1071"><http://pubs.usgs.gov/of/2005/1071></A>
</ul>
<p>
</blockquote>
<dl>
<dt><em>Other_Citation_Details:</em> 1 DVD-ROM</dt>
</dl>
<p>
<li><A NAME="what.2"><b>What geographic area does the data set cover?</b></A><p>
<dl>
<dt><em>West_Bounding_Coordinate:</em> -124.211606</dt>
<dt><em>East_Bounding_Coordinate:</em> -67.158958</dt>
<dt><em>North_Bounding_Coordinate:</em> 49.384359</dt>
<dt><em>South_Bounding_Coordinate:</em> 25.837377</dt>
</dl>
<p>
<li><A NAME="what.3"><b>What does it look like?</b></A><p>
<dl>
<dt><A HREF="http://pubs.usgs.gov/of/2005/1071/data/background/us_bnds/state_bounds.gif"><http://pubs.usgs.gov/of/2005/1071/data/background/us_bnds/state_bounds.gif></A> (GIF)
<dd>
Image showing extent and coverage of the state_bounds shapefile with large U.S. lakes.
<dt><A HREF="http://coastalmap.marine.usgs.gov/GISdata/basemaps/boundaries/state_bounds/state_bounds.gif"><http://coastalmap.marine.usgs.gov/GISdata/basemaps/boundaries/state_bounds/state_bounds.gif></A> (GIF)
<dd>
Image showing extent and coverage of the state_bounds shapefile with large U.S. lakes.
</dl>
<p>
<li><A NAME="what.4"><b>Does the data set describe conditions during a particular time period?</b></A><p>
<dl>
<dt>Calendar_Date: 04-Oct-2002<dt><em>Currentness_Reference:</em> publication date</dt>
</dl>
<p>
<li><A NAME="what.5"><b>What is the general form of this data set?</b></A><p>
<dl>
<dt><em>Geospatial_Data_Presentation_Form:</em> vector digital data</dt>
</dl>
<p>
<li><A NAME="what.6"><b>How does the data set represent geographic features?</b></A><p>
<ol type="a">
<li><A NAME="what.6.a"><b>How are geographic features stored in the data set?</b></A><p>
This is a Vector data set.
It contains the following vector data types (SDTS terminology):
<ul>
<li>String (19)
</ul>
<p>
<li><A NAME="what.6.b"><b>What coordinate system is used to represent geographic features?</b></A><p>
Horizontal positions are specified in geographic coordinates, that is, latitude and longitude.
Latitudes are given to the nearest 0.000001.
Longitudes are given to the nearest 0.000001.
Latitude and longitude values are specified in Decimal degrees.
<p>
The horizontal datum used is North American Datum of 1983.<br>
The ellipsoid used is Geodetic Reference System 80.<br>
The semi-major axis of the ellipsoid used is 6378137.000000.<br>
The flattening of the ellipsoid used is 1/298.257222.<br>
<p>
</ol>
<p>
<li><A NAME="what.7"><b>How does the data set describe geographic features?</b></A><p>
<dl>
<dt><b><tt>state_bounds.dbf</tt></b><dd>Shapefile Attribute Table
(Source: ESRI)
<p>
<dl>
<dt><b><tt>FID</tt></b><dd>Internal feature number.
(Source: ESRI)<p></p>
<p>
<em>Sequential unique whole numbers that are automatically generated.</em>
<p>
<dt><b><tt>Shape</tt></b><dd>Feature geometry.
(Source: ESRI)<p></p>
<p>
<em>Coordinates defining the features.</em>
<p>
<dt><b><tt>ID</tt></b><dd>Assigned feature id and has no applicable relevenace to the data.
(Source: User Defined)<p></p>
<p>
<dt><b><tt>LENGTH</tt></b><dd>Length of line in native units
(Source: User Defined)<p></p>
<p>
</dl>
<p>
</dl>
<p>
</ol>
<p>
<hr>
<h3><A NAME="who">Who produced the data set?</A></h3>
<ol>
<li><A NAME="who.1"><b>Who are the originators of the data set?</b></A> (may include formal authors, digital compilers, and editors)<p>
<ul>
<li>Valerie Paskevich
</ul>
<p>
<li><A NAME="who.2"><b>Who also contributed to the data set?</b></A><p>
<blockquote>
The true origin of this dataset is compiled from ESRI's 50 individual state 'trct' files. Please view the Source Information for more details
</blockquote>
<p>
<li><A NAME="who.3"><b>To whom should users address questions about the data?</b></A><p>
<div style="margin-left: 2em">
Valerie Paskevich<br>
U. S. Geological Survey<br>
Computer Specialist<br>
384 Woods Hole Road<br>
Woods Hole, MA 02543-1598<br>
USA<br>
<p>
(508) 548-8700 x2281 (voice)<br>
(508) 457-2310 (FAX)<br>
vpaskevich@usgs.gov<br>
</div>
</ol>
<p>
<hr>
<h3><A NAME="why">Why was the data set created?</A></h3>
<blockquote>
This data layer includes the internal boundaries for the United States and the political boundaries of the U.S., Canada and Mexico. The state boundaries are drawn to the U.S. coastline and does not include any coastline or islands. This data layer may be used with the high resolution NOS80K coastline (allus80k.shp) which does not include any internal boundaries.
</blockquote>
<p>
<hr>
<h3><A NAME="how">How was the data set created?</A></h3>
<ol>
<li><A NAME="how.1"><b>From what previous works were the data drawn?</b></A><p>
<dl>
<dt><b>usa.shp</b> (source 1 of 1)
<dd>
<blockquote>
Paskevich, Valerie, Unpublished Material, USA: United States basemap data layer.<p>
Online Links:
<ul>
<li><A HREF="http://coastalmap.marine.usgs.gov/GISdata/basemaps/coastlines/nos80K/allus80k.htm"><http://coastalmap.marine.usgs.gov/GISdata/basemaps/coastlines/nos80K/allus80k.htm></A>
</ul>
<p>
</blockquote>
<dl>
<dt><em>Type_of_Source_Media:</em> disc</dt>
<dt><em>Source_Contribution:</em>
<dd>
The compiled usa.shp file was used as the source for this new data layer.
</dd>
</dl>
<p>
</dl>
<li><A NAME="how.2"><b>How were the data generated, processed, and modified?</b></A><p>
<dl>
<dt>Date: 03-Oct-2002 (process 1 of 1)
<dd>
The usa.shp file was copied and edited to remove the coastline and islands. Because the file contained shapes for the individual states, duplicate common boundaries were numerous. The file was edited further to remove these duplicate shapes and remove the original table information. A final clean-up was done to combine (UNION) line segments and reduce the number of individual shapes.
<p>
Person who carried out this activity:<br>
<div style="margin-left: 2em">
Valerie Paskevich<br>
U.S. Geological Survey<br>
Computer Specialist<br>
384 Woods Hole Road<br>
Woods Hole, MA 02543-1598<br>
USA<br>
<p>
(508) 548-8700 x2281 (voice)<br>
(508) 457-2310 (FAX)<br>
vpaskevich@usgs.gov<br>
</div>
Data sources used in this process:
<ul>
<li>usa.shp
</ul>
<p>
Data sources produced in this process:
<ul>
<li>state_bounds.shp
</ul>
<p>
</dl>
<li><A NAME="how.3"><b>What similar or related data should the user be aware of?</b></A><p>
</ol>
<p>
<hr>
<h3><A NAME="quality">How reliable are the data; what problems remain in the data set?</A></h3>
<ol>
<li><A NAME="quality.1"><b>How well have the observations been checked?</b></A><p>
<p>
<li><A NAME="quality.2"><b>How accurate are the geographic locations?</b></A><p>
<p>
<li><A NAME="quality.3"><b>How accurate are the heights or depths?</b></A><p>
<p>
<li><A NAME="quality.4"><b>Where are the gaps in the data? What is missing?</b></A><p>
This data set contains the internal boundaries for the continental US and the US/Canada and US/Mexico political boundaries.
<p>
<li><A NAME="quality.5"><b>How consistent are the relationships among the observations, including topology?</b></A><p>
No additional checks for topological consistency were performed on this data set.
</ol>
<p>
<hr>
<h3><A NAME="getacopy">How can someone get a copy of the data set?</A></h3>
<blockquote>
<A name="getacopy.0"><b>Are there legal restrictions on access or use of the data?</b></A><p>
<blockquote>
<dl>
<dt><em>Access_Constraints:</em> None</dt>
<dt><em>Use_Constraints:</em> None</dt>
</dl>
</blockquote>
</blockquote>
<p>
<ol>
<li><A NAME="getacopy.1"><b>Who distributes the data set?</b></A> (Distributor 1 of 1)<p>
<div style="margin-left: 2em">
U.S. Geological Survey<br>
c/o Valerie Paskevich<br>
Information Specialist / GIS Coordinator<br>
384 Woods Hole Road<br>
Woods Hole, MA 02543-1598<br>
USA<br>
<p>
(508) 548-8700 x2281 (voice)<br>
(508) 457-2310 (FAX)<br>
vpaskevich@usgs.gov<br>
</div>
<li><A name="getacopy.2"><b>What's the catalog number I need to order this data set?</b></A><p>
<tt>Downloadable Data</tt>
<p>
<li><A name="getacopy.3"><b>What legal disclaimers am I supposed to read?</b></A><p>
<blockquote>
Although this data set has been used by the U.S. Geological Survey (USGS), no warranty, expressed or implied, is made by the USGS as to the accuracy of the data and/or related materials. The act of distribution shall not constitute any such warranty, and no responsibility is assumed by the USGS in the use of these data or related materials.
<P>
Any use of trade, product, or firm names is for descriptive purposes only and does not imply endorsement by the U.S. Government.
</blockquote>
<p>
<li><A name="getacopy.4"><b>How can I download or order the data?</b></A><p>
<ul>
<li><b>Availability in digital form:</b><p>
<table border="0" cellpadding="2">
<tr><th align="left" valign="top">Data format:</th>
<td>
The SHP file contains the geospatial data. The SHX file contains the index of the geospatial data. The DBF file contains the attribute data in dBase format. The PRJ file contains the coordinate system information (optional). The AVL file contains the legend information (optional). The SBN and SBX files contain the spatial index of the geospatial data (optional). The XML file contains the metadata describing the data set <data set name>.shp.xml. An ASCII version of the metadata file. A browse graphic showing the data layer coverage and extent (optional).
in format Shapefile
(version 3.2)
ESRI shapefile
Size: 2.623
</td>
</tr>
<tr><th align="left" valign="top">Network links:</th>
<td>
<A HREF="http://pubs.usgs.gov/of/2005/1071/data/background/us_bnds/state_bounds.zip"><http://pubs.usgs.gov/of/2005/1071/data/background/us_bnds/state_bounds.zip></A><br>
<A HREF="http://coastalmap.marine.usgs.gov/GISdata/basemaps/boundaries/state_bounds/state_bounds.zip"><http://coastalmap.marine.usgs.gov/GISdata/basemaps/boundaries/state_bounds/state_bounds.zip></A><br>
</td>
</tr>
<tr><th align="left" valign="top">Media you can order:</th>
<td>
DVD-ROM
(Density 4.75
Gbytes)
(format UDF)
<p>
</td>
</tr>
</table>
<p>
<li><b>Cost to order the data:</b> None<p>
</ul>
<p>
<li><A name="getacopy.6"><b>What hardware or software do I need in order to use the data set?</b></A><p>
<blockquote>
These data are available in Environmental Systems Research Institute (ESRI) shapefile format. The user must have ArcGIS® or ArcView® 3.0 or greater software to read and process the data file. In lieu of ArcView or ArcGIS, the user may utilize another GIS application package capable of the importing data. A free data viewer, arcexplorer, capable of displaying the data is available from ESRI at www.esri.com.
</blockquote>
<p>
</ol>
<p>
<hr>
<h3><A NAME="metaref">Who wrote the metadata?</A></h3>
<dl>
<dt>Dates:
<dd>Last modified: 20-Jan-2006<br>
</dd>
<dt>Metadata author:
<dd>
<div style="margin-left: 2em">
U.S. Geological Survey<br>
c/o Valerie Paskevich<br>
Information Specialist / GIS Coordinator<br>
384 Woods Hole Road<br>
Woods Hole, MA 02543-1598<br>
USA<br>
<p>
(508) 548-8700 x2281 (voice)<br>
(508) 457-2310 (FAX)<br>
vpaskevich@usgs.gov<br>
</div>
</dd>
<dt>Metadata standard: <dd>FGDC Content Standards for Digital Geospatial Metadata (FGDC-STD-001-1998)<dt>Metadata extensions used:
<dd>
<ul>
<li><A HREF="http://www.esri.com/metadata/esriprof80.html"><http://www.esri.com/metadata/esriprof80.html></A></li>
</ul>
</dd>
</dl>
<p></p>
<hr>
Generated by <A HREF="http://geology.usgs.gov/tools/metadata/tools/doc/mp.html"><tt>mp</tt></A> version 2.8.6 on Fri Jan 20 11:59:31 2006<br>
</body>
</html>
| 44.848558 | 667 | 0.705258 |
e40e6c8f0bcec6c3b8754c3ffbd7332b2e2766c5 | 4,871 | lua | Lua | hydro/draw/3d_slice.lua | thenumbernine/hydro-cl-lua | 857ac71ba8f5cf722a1b43789cde1693e9ecf7b7 | [
"MIT"
] | 15 | 2016-10-11T18:50:34.000Z | 2021-12-21T01:32:28.000Z | hydro/draw/3d_slice.lua | thenumbernine/hydro-cl-lua | 857ac71ba8f5cf722a1b43789cde1693e9ecf7b7 | [
"MIT"
] | null | null | null | hydro/draw/3d_slice.lua | thenumbernine/hydro-cl-lua | 857ac71ba8f5cf722a1b43789cde1693e9ecf7b7 | [
"MIT"
] | 2 | 2018-08-03T01:49:36.000Z | 2018-10-16T23:51:13.000Z | local table = require 'ext.table'
local class = require 'ext.class'
local file = require 'ext.file'
local gl = require 'ffi.OpenGL'
local CartesianCoordinateSystem = require 'hydro.coord.cartesian'
local Draw = require 'hydro.draw.draw'
local Draw3DSlice = class(Draw)
-- 2D
local vertexesInQuad = {{0,0},{1,0},{1,1},{0,1}}
--[[
looks great for flat space
TODO for curved space: provide a coordMapInv function (might have to be manual to account for domains of rotations)
and then call this as we march through volumes
and treat out-of-bound values as fully transparent
--]]
Draw3DSlice.usePoints = false
Draw3DSlice.useIsos = true
Draw3DSlice.numIsobars = 20
Draw3DSlice.useLighting = false
Draw3DSlice.alpha = .15
Draw3DSlice.alphaGamma = 1
Draw3DSlice.numSlices = 255
function Draw3DSlice:showDisplayVar(var, varName, ar, xmin, xmax, ymin, ymax, useLog)
local solver = self.solver
local app = solver.app
if require 'hydro.solver.meshsolver':isa(solver) then return end
app.view:setup(ar)
if app.useClipPlanes then
for i,clipInfo in ipairs(app.clipInfos) do
gl.glClipPlane(gl.GL_CLIP_PLANE0+i-1, clipInfo.plane.s)
end
end
local valueMin, valueMax
if var.heatMapFixedRange then
valueMin = var.heatMapValueMin
valueMax = var.heatMapValueMax
else
valueMin, valueMax = solver:calcDisplayVarRange(var)
var.heatMapValueMin = valueMin
var.heatMapValueMax = valueMax
end
solver:calcDisplayVarToTex(var)
local shader = solver.volumeSliceShader
local uniforms = shader.uniforms
shader:use()
local tex = solver:getTex(var)
tex:bind(0)
tex:setParameter(gl.GL_TEXTURE_MAG_FILTER, app.displayBilinearTextures and gl.GL_LINEAR or gl.GL_NEAREST)
app.gradientTex:bind(1)
self:setupDisplayVarShader(shader, var, valueMin, valueMax)
gl.glUniform1f(uniforms.alpha.loc, self.alpha)
gl.glUniform1f(uniforms.alphaGamma.loc, self.alphaGamma)
gl.glUniform1i(uniforms.useIsos.loc, self.useIsos)
gl.glUniform1f(uniforms.numIsobars.loc, self.numIsobars)
gl.glUniform1i(uniforms.useLighting.loc, self.useLighting)
if app.useClipPlanes then
for i,info in ipairs(app.clipInfos) do
gl.glUniform1i(uniforms['clipEnabled'..i].loc, info.enabled and 1 or 0)
end
end
if self.usePoints then
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glPointSize(2)
gl.glBegin(gl.GL_POINTS)
local numGhost = solver.numGhost
for i=numGhost+1,tonumber(solver.gridSize.x-numGhost) do
for j=numGhost+1,tonumber(solver.gridSize.y-numGhost) do
for k=numGhost+1,tonumber(solver.gridSize.z-numGhost) do
gl.glVertex3d(
(i - numGhost - .5)/tonumber(solver.gridSize.x - 2*numGhost),
(j - numGhost - .5)/tonumber(solver.gridSize.y - 2*numGhost),
(k - numGhost - .5)/tonumber(solver.gridSize.z - 2*numGhost))
end
end
end
gl.glEnd()
gl.glDisable(gl.GL_DEPTH_TEST)
else
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glEnable(gl.GL_BLEND)
local n = self.numSlices
local fwd = -app.frustumView.angle:conjugate():zAxis()
local fwddir
local jmin, jmax, jdir
fwddir = select(2, table{fwd:unpack()}:map(math.abs):sup())
if fwd.s[fwddir-1] < 0 then
jmin, jmax, jdir = 0, n, 1
else
jmin, jmax, jdir = n, 0, -1
end
gl.glUniform3f(uniforms.normal.loc,
fwddir == 1 and jdir or 0,
fwddir == 2 and jdir or 0,
fwddir == 3 and jdir or 0)
gl.glBegin(gl.GL_QUADS)
for j=jmin,jmax,jdir do
local f = j/n
for _,vtx in ipairs(vertexesInQuad) do
if fwddir == 1 then
gl.glVertex3f(f, vtx[1], vtx[2])
elseif fwddir == 2 then
gl.glVertex3f(vtx[1], f, vtx[2])
elseif fwddir == 3 then
gl.glVertex3f(vtx[1], vtx[2], f)
end
end
end
gl.glEnd()
gl.glDisable(gl.GL_BLEND)
end
app.gradientTex:unbind(1)
tex:unbind(0)
shader:useNone()
app:drawGradientLegend(solver, var, varName, ar, valueMin, valueMax)
end
function Draw3DSlice:display(varName, ar, xmin, xmax, ymin, ymax, useLog)
local solver = self.solver
local app = solver.app
local var = solver.displayVarForName[varName]
if var and var.enabled then
self:prepareShader()
self:showDisplayVar(var, varName, ar, xmin, xmax, ymin, ymax, useLog)
end
end
function Draw3DSlice:prepareShader()
local solver = self.solver
if solver.volumeSliceShader then return end
local app = solver.app
local volumeSliceCode = assert(file['hydro/draw/3d_slice.shader'])
solver.volumeSliceShader = solver.GLProgram{
name = '3d_slice',
vertexCode = solver.eqn:template(volumeSliceCode, {
draw = self,
vertexShader = true
}),
fragmentCode = solver.eqn:template(volumeSliceCode, {
draw = self,
fragmentShader = true,
-- TODO move this from app, or make it a field of app?
clipInfos = app.useClipPlanes and app.clipInfos or nil,
}),
uniforms = {
volTex = 0,
gradientTex = 1,
valueMin = 0,
valueMax = 0,
},
}
end
return Draw3DSlice
| 26.472826 | 115 | 0.721412 |
b0f4b7549113c9f0da2aa050826298f07c8510cf | 16,532 | kt | Kotlin | espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/SourceDocument.kt | sravanmedarapu/appium-espresso-driver | de3e45822ef37c59199f91580db12a6c59f78fb6 | [
"Apache-2.0"
] | null | null | null | espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/SourceDocument.kt | sravanmedarapu/appium-espresso-driver | de3e45822ef37c59199f91580db12a6c59f78fb6 | [
"Apache-2.0"
] | 20 | 2021-03-08T11:06:13.000Z | 2022-02-15T21:17:23.000Z | espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/SourceDocument.kt | mykola-mokhnach/appium-espresso-driver | 96fd03f7bb3c2b4ad02b8e070c4cf96272aa854d | [
"Apache-2.0"
] | 1 | 2021-08-31T13:37:04.000Z | 2021-08-31T13:37:04.000Z | /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
* 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 io.appium.espressoserver.lib.model
import android.content.Context
import android.os.SystemClock
import android.text.TextUtils
import android.util.SparseArray
import android.util.Xml
import android.view.View
import android.view.ViewGroup
import android.widget.AdapterView
import androidx.test.core.app.ApplicationProvider.getApplicationContext
import androidx.compose.ui.semantics.SemanticsNode
import androidx.compose.ui.test.SelectionResult
import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.onRoot
import io.appium.espressoserver.EspressoServerRunnerTest
import io.appium.espressoserver.EspressoServerRunnerTest.Companion.context
import io.appium.espressoserver.lib.drivers.DriverContext
import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
import io.appium.espressoserver.lib.handlers.exceptions.XPathLookupException
import io.appium.espressoserver.lib.helpers.AndroidLogger
import io.appium.espressoserver.lib.helpers.StringHelpers.abbreviate
import io.appium.espressoserver.lib.helpers.XMLHelpers.toNodeName
import io.appium.espressoserver.lib.helpers.XMLHelpers.toSafeString
import io.appium.espressoserver.lib.helpers.extensions.withPermit
import io.appium.espressoserver.lib.viewaction.ViewGetter
import org.w3c.dom.NodeList
import org.xml.sax.InputSource
import org.xmlpull.v1.XmlSerializer
import java.io.*
import java.lang.AssertionError
import java.util.*
import java.util.concurrent.Semaphore
import javax.xml.xpath.*
import kotlin.reflect.full.declaredMemberFunctions
import kotlin.reflect.jvm.isAccessible
const val NON_XML_CHAR_REPLACEMENT = "?"
const val VIEW_INDEX = "viewIndex"
const val NAMESPACE = ""
val DEFAULT_VIEW_CLASS_NAME = View::javaClass.name
const val MAX_TRAVERSAL_DEPTH = 70
const val MAX_XML_VALUE_LENGTH = 64 * 1024
const val XML_ENCODING = "UTF-8"
val XPATH: XPath = XPathFactory.newInstance().newXPath()
private fun toXmlNodeName(className: String?): String {
if (className == null || className.trim { it <= ' ' }.isEmpty()) {
return DEFAULT_VIEW_CLASS_NAME
}
var fixedName = className
.replace("[$@#&]".toRegex(), ".")
.replace("\\.+".toRegex(), ".")
.replace("(^\\.|\\.$)".toRegex(), "")
fixedName = toNodeName(fixedName)
if (fixedName.trim { it <= ' ' }.isEmpty()) {
fixedName = DEFAULT_VIEW_CLASS_NAME
}
if (fixedName != className) {
AndroidLogger.info("Rewrote class name '$className' to XML node name '$fixedName'")
}
return fixedName
}
class SourceDocument constructor(
private val root: Any? = null,
private val includedAttributes: Set<AttributesEnum>? = null
) {
@Suppress("PrivatePropertyName")
private val RESOURCES_GUARD = Semaphore(1)
private val viewMap: SparseArray<View> = SparseArray()
private var serializer: XmlSerializer? = null
private var tmpXmlName: String? = null
private fun setAttribute(attrName: AttributesEnum, attrValue: Any?) {
// Do not write attributes, whose values equal to null
attrValue?.let {
// Cut off longer strings to avoid OOM errors
val xmlValue = abbreviate(toSafeString(it.toString(), NON_XML_CHAR_REPLACEMENT),
MAX_XML_VALUE_LENGTH)
serializer?.attribute(NAMESPACE, attrName.toString(), xmlValue)
}
}
private fun recordAdapterViewInfo(adapterView: AdapterView<*>) {
val adapter = adapterView.adapter ?: return
val adapterCount = adapter.count
val adapterData = ArrayList<String>()
var isAdapterTypeSet = false
for (i in 0 until adapterCount) {
val adapterItem = adapter.getItem(i) ?: continue
adapterData.add(adapterItem.toString())
// Get the type of the adapter item
if (!isAdapterTypeSet) {
setAttribute(AttributesEnum.ADAPTER_TYPE, adapterItem.javaClass.simpleName)
isAdapterTypeSet = true
}
}
if (adapterData.isNotEmpty()) {
setAttribute(AttributesEnum.ADAPTERS, TextUtils.join(",", adapterData))
}
}
private fun isAttributeIncluded(attr: AttributesEnum): Boolean =
null == includedAttributes || includedAttributes.contains(attr)
/**
* Recursively visit all of the views and map them to XML elements
*
* @param view The root view
* @param depth The current traversal depth
*/
private fun serializeView(view: View?, depth: Int) {
if (view == null) {
return
}
val viewElement = ViewElement(view)
val className = viewElement.className
val tagName = toXmlNodeName(className)
serializer?.startTag(NAMESPACE, tagName)
var isTextOrHintRecorded = false
var isAdapterInfoRecorded = false
linkedMapOf(
AttributesEnum.INDEX to { viewElement.index },
AttributesEnum.PACKAGE to { viewElement.packageName },
AttributesEnum.CLASS to { className },
AttributesEnum.CONTENT_DESC to { viewElement.contentDescription },
AttributesEnum.CHECKABLE to { viewElement.isCheckable },
AttributesEnum.CHECKED to { viewElement.isChecked },
AttributesEnum.CLICKABLE to { viewElement.isClickable },
AttributesEnum.ENABLED to { viewElement.isEnabled },
AttributesEnum.FOCUSABLE to { viewElement.isFocusable },
AttributesEnum.FOCUSED to { viewElement.isFocused },
AttributesEnum.SCROLLABLE to { viewElement.isScrollable },
AttributesEnum.LONG_CLICKABLE to { viewElement.isLongClickable },
AttributesEnum.PASSWORD to { viewElement.isPassword },
AttributesEnum.SELECTED to { viewElement.isSelected },
AttributesEnum.VISIBLE to { viewElement.isVisible },
AttributesEnum.BOUNDS to { viewElement.bounds.toShortString() },
AttributesEnum.TEXT to null,
AttributesEnum.HINT to null,
AttributesEnum.RESOURCE_ID to { viewElement.resourceId },
AttributesEnum.VIEW_TAG to { viewElement.viewTag },
AttributesEnum.ADAPTERS to null,
AttributesEnum.ADAPTER_TYPE to null
).forEach {
when (it.key) {
AttributesEnum.TEXT, AttributesEnum.HINT ->
if (!isTextOrHintRecorded && isAttributeIncluded(it.key)) {
viewElement.text?.let { text ->
setAttribute(AttributesEnum.TEXT, text.rawText)
setAttribute(AttributesEnum.HINT, text.isHint)
isTextOrHintRecorded = true
}
}
AttributesEnum.ADAPTERS, AttributesEnum.ADAPTER_TYPE ->
if (!isAdapterInfoRecorded && view is AdapterView<*> && isAttributeIncluded(it.key)) {
recordAdapterViewInfo(view)
isAdapterInfoRecorded = true
}
else -> if (isAttributeIncluded(it.key)) {
setAttribute(it.key, it.value!!())
}
}
}
serializer?.attribute(NAMESPACE, VIEW_INDEX, viewMap.size().toString())
viewMap.put(viewMap.size(), view)
if (depth < MAX_TRAVERSAL_DEPTH) {
// Visit the children and build them too
if (view is ViewGroup) {
for (index in 0 until view.childCount) {
serializeView(view.getChildAt(index), depth + 1)
}
}
} else {
AndroidLogger.warn(
"Skipping traversal of ${view.javaClass.name}'s children, since " +
"the current depth has reached its maximum allowed value of $depth"
)
}
serializer?.endTag(NAMESPACE, tagName)
}
private fun serializeComposeNode(semanticsNode: SemanticsNode?, depth: Int) {
if (semanticsNode == null) {
return
}
val nodeElement = ComposeNodeElement(semanticsNode)
val className = nodeElement.className
val tagName = toXmlNodeName(className)
serializer?.startTag(NAMESPACE, tagName)
linkedMapOf(
AttributesEnum.CLASS to { className },
AttributesEnum.INDEX to { nodeElement.index },
AttributesEnum.CLICKABLE to { nodeElement.isClickable },
AttributesEnum.ENABLED to { nodeElement.isEnabled },
AttributesEnum.FOCUSED to { nodeElement.isFocused },
AttributesEnum.SCROLLABLE to { nodeElement.isScrollable },
AttributesEnum.SELECTED to { nodeElement.isSelected },
AttributesEnum.CHECKED to { nodeElement.isChecked },
AttributesEnum.VIEW_TAG to { nodeElement.viewTag },
AttributesEnum.CONTENT_DESC to { nodeElement.contentDescription },
AttributesEnum.BOUNDS to { nodeElement.bounds.toShortString() },
AttributesEnum.TEXT to { nodeElement.text },
AttributesEnum.PASSWORD to { nodeElement.isPassword },
AttributesEnum.RESOURCE_ID to { nodeElement.resourceId },
).forEach {
setAttribute(it.key, it.value())
}
if (depth < MAX_TRAVERSAL_DEPTH) {
// Visit the children and build them too
for (index in 0 until semanticsNode.children.count()) {
serializeComposeNode(semanticsNode.children[index], depth + 1)
}
} else {
AndroidLogger.warn(
"Skipping traversal of ${semanticsNode.javaClass.name}'s children, since " +
"the current depth has reached its maximum allowed value of $depth"
)
}
serializer?.endTag(NAMESPACE, tagName)
}
private fun toStream(): InputStream {
var lastError: Throwable? = null
// Try to serialize the xml into the memory first, since it is fast
// Switch to a file system serializer if the first approach causes OutOfMemory
for (streamType in arrayOf<Class<*>>(
ByteArrayOutputStream::class.java,
FileOutputStream::class.java
)) {
serializer = Xml.newSerializer()
viewMap.clear()
try {
val outputStream = if (streamType == FileOutputStream::class.java) {
tmpXmlName = "${UUID.randomUUID()}.xml"
getApplicationContext<Context>().openFileOutput(
tmpXmlName,
Context.MODE_PRIVATE
)
} else ByteArrayOutputStream()
try {
serializer?.let {
it.setOutput(outputStream, XML_ENCODING)
it.startDocument(XML_ENCODING, true)
it.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true)
val startTime = SystemClock.uptimeMillis()
when (context.currentStrategyType) {
DriverContext.StrategyType.COMPOSE -> {
if (root != null) {
serializeComposeNode(root as SemanticsNode, 0)
} else {
val rootNodes = rootSemanticNodes()
if (rootNodes.size == 1) {
serializeComposeNode(rootNodes.first(), 0)
} else {
serializer?.startTag(NAMESPACE, DEFAULT_TAG_NAME)
rootNodes.forEach { semanticsNode -> serializeComposeNode(semanticsNode, 0) }
serializer?.endTag(NAMESPACE, DEFAULT_TAG_NAME)
}
}
}
DriverContext.StrategyType.ESPRESSO -> {
val rootView = root ?: ViewGetter().rootView
serializeView(rootView as View, 0)
}
}
it.endDocument()
AndroidLogger.info(
"The source XML tree has been fetched in " +
"${SystemClock.uptimeMillis() - startTime}ms " +
"using ${streamType.simpleName}"
)
}
} catch (e: OutOfMemoryError) {
lastError = e
continue
} finally {
outputStream.close()
}
return if (outputStream is FileOutputStream)
getApplicationContext<Context>().openFileInput(tmpXmlName)
else
ByteArrayInputStream((outputStream as ByteArrayOutputStream).toByteArray())
} catch (e: IOException) {
lastError = e
}
}
if (lastError is OutOfMemoryError) {
throw lastError
}
throw AppiumException(lastError!!)
}
private fun rootSemanticNodes(): List<SemanticsNode> {
return try {
listOf(EspressoServerRunnerTest.composeTestRule.onRoot(useUnmergedTree = true).fetchSemanticsNode())
} catch (e: AssertionError) {
// Ideally there should be on `root` node but on some cases e.g:overlays screen, there can be more than 1 root.
// Compose API not respecting such cases instead throws AssertionError, as a work around fetching all root nodes by relaying on internal API.
// e.g: "Reason: Expected exactly '1' node but found '2' nodes that satisfy: (isRoot)"
val result: SelectionResult = SemanticsNodeInteraction::class.declaredMemberFunctions.find { it.name == "fetchSemanticsNodes" }?.let {
it.isAccessible = true
it.call(EspressoServerRunnerTest.composeTestRule.onRoot(useUnmergedTree = true), true, null)
} as SelectionResult
result.selectedNodes
}
}
private fun performCleanup() {
tmpXmlName?.let {
getApplicationContext<Context>().deleteFile(it)
tmpXmlName = null
}
}
fun toXMLString(): String {
return RESOURCES_GUARD.withPermit({
toStream().use { xmlStream ->
val sb = StringBuilder()
val reader = BufferedReader(InputStreamReader(xmlStream, XML_ENCODING))
var line: String? = reader.readLine()
while (line != null) {
sb.append(line)
line = reader.readLine()
}
sb.toString()
}
}, { performCleanup() })
}
fun findViewsByXPath(xpathSelector: String): List<View> =
matchingNodeIds(xpathSelector, VIEW_INDEX).map { viewMap.get(it) }
fun matchingNodeIds(xpathSelector: String, attributeName: String): List<Int> {
val expr = try {
XPATH.compile(xpathSelector)
} catch (xe: XPathExpressionException) {
throw XPathLookupException(xpathSelector, xe.message!!)
}
return RESOURCES_GUARD.withPermit({
toStream().use { xmlStream ->
val list = expr.evaluate(InputSource(xmlStream), XPathConstants.NODESET) as NodeList
(0 until list.length).map { index ->
list.item(index).attributes.getNamedItem(attributeName).nodeValue.toInt()
}
}
}, { performCleanup() })
}
}
| 43.164491 | 152 | 0.602589 |
06de16527af1916a101c8ea3d704b9724a1fd99e | 1,774 | cc | C++ | src/bitmask/tasks/to_bitmask.cc | marcinz/legate.pandas | 94c21c436f59c06cfba454c6569e9f5d7109d839 | [
"Apache-2.0"
] | 67 | 2021-04-12T18:06:55.000Z | 2022-03-28T06:51:05.000Z | src/bitmask/tasks/to_bitmask.cc | marcinz/legate.pandas | 94c21c436f59c06cfba454c6569e9f5d7109d839 | [
"Apache-2.0"
] | 2 | 2021-06-22T00:30:36.000Z | 2021-07-01T22:12:43.000Z | src/bitmask/tasks/to_bitmask.cc | marcinz/legate.pandas | 94c21c436f59c06cfba454c6569e9f5d7109d839 | [
"Apache-2.0"
] | 6 | 2021-04-14T21:28:00.000Z | 2022-03-22T09:45:25.000Z | /* Copyright 2021 NVIDIA Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <math.h>
#include "bitmask/tasks/to_bitmask.h"
#include "bitmask/bitmask.h"
#include "bitmask/compact_bitmask.h"
#include "column/column.h"
#include "deserializer.h"
namespace legate {
namespace pandas {
namespace bitmask {
using namespace Legion;
/*static*/ void ToBitmaskTask::cpu_variant(const Task *task,
const std::vector<PhysicalRegion> ®ions,
Context context,
Runtime *runtime)
{
Deserializer ctx{task, regions};
OutputColumn out;
Column<true> in;
deserialize(ctx, out);
deserialize(ctx, in);
auto size = in.num_elements();
out.allocate(size);
if (size == 0) {
out.make_empty();
return;
}
CompactBitmask bitmask(out.raw_column<CompactBitmask::AllocType>(), size);
Bitmask boolmask(in.raw_column_read<Bitmask::AllocType>(), size);
for (auto idx = 0; idx < size; ++idx) bitmask.set(idx, boolmask.get(idx));
}
static void __attribute__((constructor)) register_tasks(void)
{
ToBitmaskTask::register_variants();
}
} // namespace bitmask
} // namespace pandas
} // namespace legate
| 27.71875 | 86 | 0.673055 |
16689fe005db2dc5d9085f9ece4dbab0aeaf64b1 | 2,743 | kt | Kotlin | app/src/main/java/pt/vilhena/listit/atividades/EscolheListaImportada.kt | VilhenaChen/ListIt | a3abf5f05d1a4028bd3332c1066392f3945a24ba | [
"MIT"
] | null | null | null | app/src/main/java/pt/vilhena/listit/atividades/EscolheListaImportada.kt | VilhenaChen/ListIt | a3abf5f05d1a4028bd3332c1066392f3945a24ba | [
"MIT"
] | null | null | null | app/src/main/java/pt/vilhena/listit/atividades/EscolheListaImportada.kt | VilhenaChen/ListIt | a3abf5f05d1a4028bd3332c1066392f3945a24ba | [
"MIT"
] | null | null | null | package pt.vilhena.listit.atividades
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import kotlinx.android.synthetic.main.activity_lista_importada.*
import kotlinx.android.synthetic.main.activity_ver_listas.*
import kotlinx.android.synthetic.main.entrada_lista.view.*
import pt.vilhena.listit.MainActivity
import pt.vilhena.listit.R
import pt.vilhena.listit.logica.Dados
import pt.vilhena.listit.logica.Lista
class EscolheListaImportada : Activity() {
lateinit var arrayListas: ArrayList<Lista>
lateinit var dados: Dados
var adapter: ListaImportadaAdapter? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_lista_importada)
dados = intent.getSerializableExtra("dados") as Dados
arrayListas = dados.getArrayListas()
adapter = ListaImportadaAdapter(this, arrayListas)
grelhaListasImportatadas.adapter = adapter
grelhaListasImportatadas.setOnItemClickListener { parent, view, position, id ->
dados.addLista()
dados.fazCopiaLista(position)
val intent = Intent(this, NovaLista::class.java)
intent.putExtra("dados", dados)
startActivity(intent)
finish()
}
}
class ListaImportadaAdapter : BaseAdapter {
var arrayListas = ArrayList<Lista>()
var context: Context? = null
constructor(context: Context, arrayListas: ArrayList<Lista>) : super() {
this.context = context
this.arrayListas = arrayListas
}
override fun getCount(): Int {
return arrayListas.size
}
override fun getItem(position: Int): Any {
return arrayListas[position]
}
override fun getItemId(position: Int): Long {
return position.toLong()
}
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
val lista = this.arrayListas[position]
var inflator =
context!!.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
var listaView = inflator.inflate(R.layout.entrada_lista, null)
listaView.nomeLista.text = lista.getNome()
return listaView
}
}
override fun onBackPressed() {
super.onBackPressed()
val intent = Intent(this, MenuCriarLista::class.java)
intent.putExtra("dados", dados)
startActivity(intent)
finish()
}
} | 32.654762 | 97 | 0.675538 |
2f33887557cfeccc9781047aff2fa1e271bb08d5 | 2,297 | java | Java | src/test/java/de/tum/in/www1/artemis/programmingexercise/MockDelegate.java | nicolasruscher/Artemis | 20d0b25fd690913dcb4c7a04bcd5f8f6e1d89d75 | [
"MIT"
] | null | null | null | src/test/java/de/tum/in/www1/artemis/programmingexercise/MockDelegate.java | nicolasruscher/Artemis | 20d0b25fd690913dcb4c7a04bcd5f8f6e1d89d75 | [
"MIT"
] | null | null | null | src/test/java/de/tum/in/www1/artemis/programmingexercise/MockDelegate.java | nicolasruscher/Artemis | 20d0b25fd690913dcb4c7a04bcd5f8f6e1d89d75 | [
"MIT"
] | null | null | null | package de.tum.in.www1.artemis.programmingexercise;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
import java.util.Set;
import com.fasterxml.jackson.core.JsonProcessingException;
import de.tum.in.www1.artemis.domain.ProgrammingExercise;
import de.tum.in.www1.artemis.domain.Team;
import de.tum.in.www1.artemis.domain.User;
import de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseStudentParticipation;
import de.tum.in.www1.artemis.service.connectors.bamboo.dto.BambooBuildResultDTO;
import de.tum.in.www1.artemis.util.Verifiable;
public interface MockDelegate {
void mockConnectorRequestsForSetup(ProgrammingExercise exercise) throws Exception;
List<Verifiable> mockConnectorRequestsForImport(ProgrammingExercise sourceExercise, ProgrammingExercise exerciseToBeImported) throws IOException, URISyntaxException;
List<Verifiable> mockConnectorRequestsForStartParticipation(ProgrammingExercise exercise, String username, Set<User> users) throws IOException, URISyntaxException;
void mockUpdatePlanRepositoryForParticipation(ProgrammingExercise exercise, String username) throws IOException, URISyntaxException;
void mockUpdatePlanRepository(ProgrammingExercise exercise, String planName, String bambooRepoName, String bitbucketRepoName, List<String> triggeredBy)
throws IOException, URISyntaxException;
void mockRemoveRepositoryAccess(ProgrammingExercise exercise, Team team, User firstStudent) throws URISyntaxException;
void mockRepositoryWritePermissions(Team team, User newStudent, ProgrammingExercise exercise) throws URISyntaxException;
void mockRetrieveArtifacts(ProgrammingExerciseStudentParticipation participation) throws MalformedURLException, URISyntaxException, JsonProcessingException;
void mockGetBuildLogs(ProgrammingExerciseStudentParticipation participation, List<BambooBuildResultDTO.BambooBuildLogEntryDTO> logs)
throws URISyntaxException, JsonProcessingException;
void mockGetRepositorySlugFromUrl(String repositorySlug, URL url);
void mockGetProjectKeyFromUrl(String projectKey, URL url);
void mockGetProjectKeyFromAnyUrl(String projectKey);
void resetMockProvider();
}
| 46.877551 | 169 | 0.839791 |
af6aaf3ed21a22301f91973c1846ab39304f317b | 154 | rb | Ruby | spec/spec_helper.rb | Le6ow5k1/petstore | a0faaaf459c71753198f8a90a42d8582d6ff524b | [
"MIT"
] | null | null | null | spec/spec_helper.rb | Le6ow5k1/petstore | a0faaaf459c71753198f8a90a42d8582d6ff524b | [
"MIT"
] | 1 | 2015-08-22T18:36:45.000Z | 2015-08-22T18:37:47.000Z | spec/spec_helper.rb | Le6ow5k1/petstore | a0faaaf459c71753198f8a90a42d8582d6ff524b | [
"MIT"
] | null | null | null | $:.unshift File.expand_path('..', __FILE__)
$:.unshift File.expand_path('../../lib', __FILE__)
require 'petstore'
require 'rspec'
require 'webmock/rspec' | 25.666667 | 50 | 0.707792 |
2012aacdd1f6106a79c57eb47078285ef9b8b2d4 | 3,197 | dart | Dart | calculadora_do_amor/lib/views/home.dart | RafaelSantini23/aulas_flutter | 7164cfefdb91f322911cfbb9dfe76e6bbad99c18 | [
"MIT"
] | null | null | null | calculadora_do_amor/lib/views/home.dart | RafaelSantini23/aulas_flutter | 7164cfefdb91f322911cfbb9dfe76e6bbad99c18 | [
"MIT"
] | null | null | null | calculadora_do_amor/lib/views/home.dart | RafaelSantini23/aulas_flutter | 7164cfefdb91f322911cfbb9dfe76e6bbad99c18 | [
"MIT"
] | null | null | null |
import 'package:calculadora_do_amor/model/love_calculator.dart';
import 'package:flutter/material.dart';
class Home extends StatefulWidget {
Home({Key key, this.title}) : super(key: key);
final String title;
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
GlobalKey<FormState> _formKey = GlobalKey<FormState>();
TextEditingController _name1 = new TextEditingController();
TextEditingController _name2 = new TextEditingController();
_rowName() {
return TextFormField(
controller: _name1,
keyboardType: TextInputType.text,
decoration: new InputDecoration(hintText: "Digite o seu nome:"),
maxLength: 100,
validator: (value) {
if(value.isEmpty) {
return "Digite um nome";
}
return null;
},
);
}
_rowNameCrush() {
return TextFormField(
controller: _name2,
keyboardType: TextInputType.text,
decoration: new InputDecoration(hintText: "Digite o nome da crush:"),
maxLength: 100,
validator: (value) {
if(value.isEmpty) {
return "Digite um nome";
}
return null;
},
);
}
_rowButton(BuildContext context) {
return TextButton.icon(
label: Text("Cadastrar"),
icon: Icon(Icons.add),
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor: Colors.blue,
onSurface: Colors.grey,
),
onPressed: (){
_register(context);
_resetFields();
},
);
}
_formUI(BuildContext context) {
return Column(
children: [
_rowName(),
_rowNameCrush(),
_rowButton(context),
],
);
}
_rowForm(BuildContext context) {
return Form(
key: _formKey,
autovalidateMode: AutovalidateMode.onUserInteraction,
child: _formUI(context),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_rowForm(context),
],
),
),
);
}
Future<String>_register(BuildContext context) async {
print('Validou: ${_formKey.currentState.validate()}');
if(_formKey.currentState.validate()) {
final loveCalculator = LoveCalculator(
_name1.text,
_name2.text,
);
Future.delayed(Duration(seconds: 5), () {
print('Resultado:\n ${loveCalculator.generateLovePercent()}');
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Resultado:\n ${loveCalculator.generateLovePercent()}'), duration: Duration(seconds: 12),)
);
});
} else {
print('Digite os campos corretamente');
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Digite os campos corretamente', ),)
);
}
}
_resetFields() => _formKey.currentState.reset();
}
| 22.835714 | 123 | 0.584298 |
ce1f760626d3fc5d622dc16ea527bbba5ce81204 | 1,931 | ps1 | PowerShell | packer/windows/install-vs-2017-community.ps1 | rhoughton-pivot/geode-native | ab6fe7d996e5ec23832f90663d03f1d66b9f5fbd | [
"Apache-2.0"
] | 48 | 2017-02-08T22:24:07.000Z | 2022-02-06T02:47:56.000Z | packer/windows/install-vs-2017-community.ps1 | rhoughton-pivot/geode-native | ab6fe7d996e5ec23832f90663d03f1d66b9f5fbd | [
"Apache-2.0"
] | 388 | 2017-02-13T17:09:45.000Z | 2022-03-29T22:18:39.000Z | packer/windows/install-vs-2017-community.ps1 | rhoughton-pivot/geode-native | ab6fe7d996e5ec23832f90663d03f1d66b9f5fbd | [
"Apache-2.0"
] | 68 | 2017-02-09T18:43:15.000Z | 2022-03-14T22:59:13.000Z | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# TODO AdminDeploy.xml
# vs_community.exe /AdminFile C:\Users\Administrator\AdminDeployment.xml /Log setup.log /Passive
$ErrorActionPreference = "Stop"
write-host "Installing Visual Studio 2017 Community..."
$args = @('--add microsoft.visualstudio.component.debugger.justintime',
'--add microsoft.visualstudio.component.web',
'--add microsoft.visualstudio.component.vc.coreide',
'--add microsoft.visualstudio.component.vc.redist.14.latest',
'--add microsoft.visualstudio.component.vc.tools.x86.x64',
'--add microsoft.visualstudio.component.windows10sdk.17763',
'--add microsoft.visualstudio.component.vc.testadapterforgoogletest',
'--add microsoft.component.vc.runtime.ucrtsdk',
'--add microsoft.visualstudio.component.vc.cli.support',
'--add microsoft.visualstudio.component.windows10sdk.16299.desktop',
'--add microsoft.visualstudio.component.webdeploy'
'--quiet'
)
choco install visualstudio2017community -confirm --package-parameters "$args"
write-host "Installed Visual Studio 2017 Community."
# Avoids reboot error code
Exit 0
| 45.97619 | 96 | 0.740549 |
46b61e0d8ef9eb72ce82f20890543c995b1d8268 | 4,504 | html | HTML | UniShared_python/website/templates/open25-leadboard.html | UniShared/unishared | 0abc36be9e4262a4928945f70ec030e46e05149b | [
"MIT"
] | null | null | null | UniShared_python/website/templates/open25-leadboard.html | UniShared/unishared | 0abc36be9e4262a4928945f70ec030e46e05149b | [
"MIT"
] | null | null | null | UniShared_python/website/templates/open25-leadboard.html | UniShared/unishared | 0abc36be9e4262a4928945f70ec030e46e05149b | [
"MIT"
] | 2 | 2019-03-03T17:34:48.000Z | 2019-04-23T17:34:14.000Z | {% extends "base_new_design.html" %}
{% load staticfiles %}
{% load require %}
{% load thumbnail %}
{% block title %}
#Open25 leaderboard
{% endblock %}
{% block css %}
<link href="{% static "css/open25-leadboard.css" %}" rel="stylesheet" type="text/css">
{% endblock %}
{% block js %}
{% require_module 'main_modules/base' %}
{% endblock %}
{% block metadata %}
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# {{FACEBOOK_OPEN_GRAPH_ROOT_NAME}}: http://ogp.me/ns/fb/{{FACEBOOK_OPEN_GRAPH_ROOT_NAME}}#">
<meta property="og:type" content="website" />
<meta property="og:url" content="{{BASE_URL}}{% url website.views.open25_leadboard %}" />
<meta property="og:title" content="#Open25 leaderboard" />
<meta property="og:image" content="{% static "images/25_best.png" %}">
<meta property="og:description" content="Win a week to your dream university to open the best classes!" />
{% endblock %}
{% block content %}
<div id="social_panel">
<div class="fb-like" data-href="{{ BASE_URL }}{% url website.views.open25_leadboard %}" data-send="false" data-layout="box_count" data-width="60" data-show-faces="true"></div>
<div style="height:10px"></div>
<a href="https://twitter.com/share" data-count="vertical" class="twitter-share-button" data-url="{{ BASE_URL }}{% url website.views.open25_leadboard %}" data-via="UniShared" data-lang="en" data-hashtags="open25"
data-text="Win a week to your dream university to open the best classes just by taking notes:">Tweeter</a>
<div style="height:10px"></div>
<div class="g-plusone" data-size="tall" data-href="{{ BASE_URL }}{% url website.views.open25_leadboard %}"></div>
</div>
<div id="open25-leadboard" class="leadboard">
<div>
<h2 class="introducing_text">#Open25</h2>
<p class="well well-small">
Thanks to the contribution of 124 awesome members of our <a href="https://www.facebook.com/unishared">community</a>,
we crowdfunded the
<a href="http://www.kisskissbankbank.com/open-the-25-best-classes-of-the-world">#open25 operation</a>
to send five learning freaks to their dream university for one week. So it's time to choose the first
lucky one to begin with. He/she will be selected amongst the <strong>top three people</strong> of this leaderboard as of
<strong>March 10th, 2013</strong>, after an interview by the selection committee composed of the top <a
href="http://www.kisskissbankbank.com/open-the-25-best-classes-of-the-world">#open25
contributors</a>. He/she will have his/her <strong>flight paid to go to his dream university</strong> for a week opening
the
best classes of the world through UniShared. Let's get started!
</p>
</div>
<h2 class="introducing_text">Leaderboard</h2>
<div>
<a href="{% url website.views.create_document %}" target="_blank" class="btn btn-success">Enter the game by
starting your notes</a>
</div>
<div id="users">
{% for username,user_points in users_points %}
<div class="user">
<div class="user_profile">
<a href="{% url website.views.profile username %}" target="_blank"><img
class="userphoto info" rel="tooltip" title="{{ user_points.0.first_name }}" src="{{ user_points.0.picture }}"></a>
</div>
<div id="nb_views_container">
<div rel="tooltip" title="Rank">
{% if forloop.counter <= 3 %}
<p class="rank text-participate">#{{ forloop.counter }}</p>
{% else %}
<p class="rank">#{{ forloop.counter }}</p>
{% endif %}
</div>
<div rel="tooltip" title="Number of participants to notes {{ user_points.0.first_name }} has created/co-written">
<img class="nb_view_eye" src="{% static "images/nb_view.png" %}">
<p class="nb_view">{{ user_points.1 }}</p>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endblock %} | 52.372093 | 219 | 0.565275 |
80462248fa6b39557422b236f33a15c353cd6266 | 2,283 | java | Java | common/messages/src/main/java/com/csgroup/s2pdgs/assets/L1abInitAndAuxPerDetContext.java | CSC-PS-S2/s2-workflow | 4efadfb164e14f4a142d9e1d011f7a881d39250f | [
"Apache-2.0"
] | 7 | 2021-07-29T09:24:52.000Z | 2021-12-15T17:23:58.000Z | common/messages/src/main/java/com/csgroup/s2pdgs/assets/L1abInitAndAuxPerDetContext.java | CSC-PS-S2/s2-workflow | 4efadfb164e14f4a142d9e1d011f7a881d39250f | [
"Apache-2.0"
] | 34 | 2021-09-28T07:38:32.000Z | 2022-01-25T13:59:03.000Z | common/messages/src/main/java/com/csgroup/s2pdgs/assets/L1abInitAndAuxPerDetContext.java | CSC-PS-S2/s2-workflow | 4efadfb164e14f4a142d9e1d011f7a881d39250f | [
"Apache-2.0"
] | null | null | null | package com.csgroup.s2pdgs.assets;
import com.csgroup.s2pdgs.checks.NoNullFieldAssertable;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.JsonDeserializer;
import static com.csgroup.s2pdgs.assets.DetectorParallelizationDescription.readDetectorParallelizationDescription;
import static com.csgroup.s2pdgs.assets.ProductContext.readProductContext;
import static com.csgroup.s2pdgs.json.MessagesModule.buildDeserializer;
import static com.csgroup.s2pdgs.json.JsonDeserializerUtils.readString;
import static com.csgroup.s2pdgs.json.PropertyNames.*;
public record L1abInitAndAuxPerDetContext(
@JsonUnwrapped
ProductContext productContext,
@JsonProperty(DETECTOR_PARALLELIZATION)
DetectorParallelizationDescription detectorParallelizationDescription,
@JsonProperty(L0U_PATH)
String l0uPath,
@JsonProperty(L0C_PATH)
String l0cPath,
@JsonProperty(L1A_PATH)
String l1aPath
) implements WithProductContext<L1abInitAndAuxPerDetContext>, NoNullFieldAssertable {
@Override
public ProductContext getProductContext() {
return productContext;
}
@Override
public L1abInitAndAuxPerDetContext withProductContext(ProductContext productContext) {
return new L1abInitAndAuxPerDetContext(
productContext,
detectorParallelizationDescription,
l0uPath,
l0cPath,
l1aPath
);
}
public static JsonDeserializer<L1abInitAndAuxPerDetContext> deserializer() {
return buildDeserializer(node -> {
final var productContext = readProductContext(node);
final var detectorParallelizationDescription = readDetectorParallelizationDescription(node);
final var l0uPath = readString(node, L0U_PATH);
final var l0cPath = readString(node, L0C_PATH);
final var l1aPath = readString(node, L1A_PATH);
return new L1abInitAndAuxPerDetContext(
productContext,
detectorParallelizationDescription,
l0uPath,
l0cPath,
l1aPath
);
}
);
}
}
| 37.42623 | 114 | 0.709155 |
c53a28b1fa096167ad5db25faadf24fc560a6587 | 686 | cpp | C++ | homework/tic_tac_toe/main.cpp | acc-cosc-1337-spring-2019/acc-cosc-1337-spring-2019-k1788723 | faaf61ef76b9b25600bbfac08e1b9664c2f1dd3e | [
"MIT"
] | null | null | null | homework/tic_tac_toe/main.cpp | acc-cosc-1337-spring-2019/acc-cosc-1337-spring-2019-k1788723 | faaf61ef76b9b25600bbfac08e1b9664c2f1dd3e | [
"MIT"
] | null | null | null | homework/tic_tac_toe/main.cpp | acc-cosc-1337-spring-2019/acc-cosc-1337-spring-2019-k1788723 | faaf61ef76b9b25600bbfac08e1b9664c2f1dd3e | [
"MIT"
] | null | null | null | #include "tic_tac_toe_manager.h"
#include <iostream>
#include <string>
int main()
{
std::string first;
char choice;
int position;
TicTacToeManager manager;
do
{
TicTacToe tic_tac_toe;
std::cout << "first player";
std::cin >> first;
tic_tac_toe.start_game(first);
while (tic_tac_toe.game_over() == false)
{
TicTacToe >> position;
//std::cout << "Enter position";
//std::cin >> position;
tic_tac_toe.mark_board(position);
tic_tac_toe.display_board();
}
manager.save_game(tic_tac_toe);
std::cout << "play again";
std::cin >> choice;
} while (choice == 'y');
manager.display_history();
return 0;
} | 18.540541 | 43 | 0.622449 |
54b97b5492426cfeeb06e9b19b9dcdd6e5c639d2 | 6,530 | swift | Swift | Examples/destination_plugins/FacebookAppEventsDestination.swift | thebrowsercompany/analytics-swift | 76316a5009502de6e7c2788c295e9afc68793cd3 | [
"MIT"
] | null | null | null | Examples/destination_plugins/FacebookAppEventsDestination.swift | thebrowsercompany/analytics-swift | 76316a5009502de6e7c2788c295e9afc68793cd3 | [
"MIT"
] | null | null | null | Examples/destination_plugins/FacebookAppEventsDestination.swift | thebrowsercompany/analytics-swift | 76316a5009502de6e7c2788c295e9afc68793cd3 | [
"MIT"
] | null | null | null | //
// FacebookAppEventsDestination.swift
//
//
// Created by Brandon Sneed on 2/9/22.
//
import Foundation
import Segment
import FBSDKCoreKit
/**
An implementation of the Facebook App Events Analytics device mode destination
as a plugin.
*/
// NOTE: You can see this plugin in use in the DestinationsExample application.
//
// This plugin is NOT SUPPORTED by Segment. It is here merely as an example,
// and for your convenience should you find it useful.
//
// Copyright (c) 2022 Segment
//
// 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.
//
class FacebookAppEventsDestination: DestinationPlugin, iOSLifecycle {
typealias FBSettings = FBSDKCoreKit.Settings
let timeline = Timeline()
let type = PluginType.destination
let key = "Facebook App Events"
var analytics: Analytics? = nil
var dpOptions = ["LDU"]
var dpCountry: Int32 = 0
var dpState: Int32 = 0
static let formatter = NumberFormatter()
private var settings: FacebookAppEventsSettings? = nil
init() {
// creating formatters are expensive, so we make it static
// and just set the style later.
Self.formatter.numberStyle = .decimal
}
public func update(settings: Segment.Settings, type: UpdateType) {
// we've already set up this singleton SDK, can't do it again, so skip.
guard type == .initial else { return }
guard let settings: FacebookAppEventsSettings = settings.integrationSettings(forPlugin: self) else { return }
self.settings = settings
FBSettings.shared.appID = settings.appId
if let ldu = settings.limitedDataUse, ldu {
FBSettings.shared.setDataProcessingOptions(dpOptions, country: dpCountry, state: dpState)
} else {
FBSettings.shared.setDataProcessingOptions(nil)
}
}
func track(event: TrackEvent) -> TrackEvent? {
// FB Event Names must be <= 40 characters
let truncatedEventName = AppEvents.Name(String(event.event.prefix(40)))
let revenue = extractRevenue(properties: event.properties, key: "revenue")
let currency = extractCurrency(properties: event.properties, key: "currency")
var params = extractParameters(properties: event.properties)
if let revenue = revenue {
params[AppEvents.ParameterName.currency] = currency
AppEvents.shared.logEvent(truncatedEventName, valueToSum: revenue, parameters: params)
AppEvents.shared.logPurchase(amount: revenue, currency: currency, parameters: params as? [String: Any])
} else {
AppEvents.shared.logEvent(truncatedEventName, parameters: params)
}
return event
}
func screen(event: ScreenEvent) -> ScreenEvent? {
// FB Event Names must be <= 40 characters
// 'Viewed' and 'Screen' with spaces take up 14
let truncatedEventName = String((event.name ?? "").prefix(26))
let newEventName = "Viewed \(truncatedEventName) Screen"
AppEvents.shared.logEvent(AppEvents.Name(newEventName))
return event
}
func applicationDidBecomeActive(application: UIApplication?) {
ApplicationDelegate.shared.initializeSDK()
}
}
// MARK: Helper methods
extension FacebookAppEventsDestination {
func extractParameters(properties: JSON?) -> [AppEvents.ParameterName: Any] {
// Facebook only accepts properties/parameters that have an NSString key, and an NSString or NSNumber as a value.
// ... so we need to strip out everything else. Not doing so results in a refusal to send and an
// error in the console from the FBSDK.
var result = [AppEvents.ParameterName: Any]()
guard let properties = properties?.dictionaryValue else { return result }
for (key, value) in properties {
switch value {
case let v as NSString:
result[AppEvents.ParameterName(key)] = v
case let v as NSNumber:
result[AppEvents.ParameterName(key)] = v
default:
break
}
}
return result
}
func extractRevenue(properties: JSON?, key: String) -> Double? {
guard let dict = properties?.dictionaryValue else { return nil }
var revenue: Any? = nil
for revenueKey in dict.keys {
if key.caseInsensitiveCompare(revenueKey) == .orderedSame {
revenue = dict[revenueKey]
}
}
if revenue is String, let revenue = revenue as? String {
// format the revenue
let result = Self.formatter.number(from: revenue) as? Double
return result
} else if revenue is Double {
return revenue as? Double
}
return nil
}
func extractCurrency(properties: JSON?, key: String) -> String {
var result = "USD"
guard let dict = properties?.dictionaryValue else { return result }
let found = dict.keys.filter { dictKey in
return (key.caseInsensitiveCompare(dictKey) == .orderedSame)
}
if let key = found.first, let value = dict[key] as? String {
result = value
}
return result
}
}
// MARK: Settings
private struct FacebookAppEventsSettings: Codable {
let appId: String
let limitedDataUse: Bool?
}
| 36.077348 | 121 | 0.651608 |
48d7b035e206f3a824e32ab4f77a1149f139f511 | 611 | h | C | YWXSignSDK/Core/YWXSignSDK.framework/Headers/YWXSignSDK.h | yiwangxin/YWXSignSDK | ebfa339ce77b2b0ff418d234ef13a1bf9757d603 | [
"MIT"
] | 5 | 2019-03-28T03:03:36.000Z | 2020-12-21T02:50:12.000Z | Example/Pods/YWXSignSDK/YWXSignSDK/Core/YWXSignSDK.framework/Headers/YWXSignSDK.h | XingXiaoWu/BjcaSignSDK | 1cbb1da2e89cd4c8201de1730401556070160999 | [
"MIT"
] | 3 | 2020-06-29T03:29:43.000Z | 2021-05-21T14:32:57.000Z | YWXSignSDK/Core/YWXSignSDK.framework/Headers/YWXSignSDK.h | yiwangxin/YWXSignSDK | ebfa339ce77b2b0ff418d234ef13a1bf9757d603 | [
"MIT"
] | null | null | null | //
// YWXSignSDK.h
// YWXSignSDK
//
// Created by szyx on 2021/3/22.
// Copyright © 2021 Beijing Digital Yixin Technology Co., Ltd. All rights reserved.
//
#import <Foundation/Foundation.h>
//! Project version number for YWXSignSDK.
FOUNDATION_EXPORT double YWXSignSDKVersionNumber;
//! Project version string for YWXSignSDK.
FOUNDATION_EXPORT const unsigned char YWXSignSDKVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <YWXSignSDK/PublicHeader.h>
#import <YWXSignSDK/YWXSignManager.h>
#import <YWXSignSDK/YWXSignStatus.h>
| 29.095238 | 135 | 0.774141 |
d26ddb5ab22d61c02f6a08c6fd794928edc6373f | 5,675 | php | PHP | app/Http/Controllers/Property/HotelRateController.php | nhannguyen090199/inv | 2e04bc7ca508ab3d2c4e191c18b5bdcbd9f861f3 | [
"MIT"
] | null | null | null | app/Http/Controllers/Property/HotelRateController.php | nhannguyen090199/inv | 2e04bc7ca508ab3d2c4e191c18b5bdcbd9f861f3 | [
"MIT"
] | null | null | null | app/Http/Controllers/Property/HotelRateController.php | nhannguyen090199/inv | 2e04bc7ca508ab3d2c4e191c18b5bdcbd9f861f3 | [
"MIT"
] | null | null | null | <?php
namespace App\Http\Controllers\Property;
use App\Http\Controllers\Controller;
use App\Models\HotelBeds\Hotels;
use App\Models\Promotions\Promotions;
use App\Repositories\Eloquent\RoomRateRepository;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use App\Models\Hotels\RoomRate;
use App\Repositories\Eloquent\HotelRateRepository;
use Carbon\Carbon;
use Carbon\CarbonPeriod;
class HotelRateController extends Controller
{
public $route = 'property.hotel.rate';
public $baseModel;
protected $hotelRoomRepo;
protected $countriesRepo;
protected $roomsByHotelRepo;
protected $roomRateRepo;
/**
* Create a new controller instance.
* @param HotelRateRepository $hotelRateRepository
* @param RoomRateRepository $roomRateRepository
*/
public function __construct(HotelRateRepository $hotelRateRepository, RoomRateRepository $roomRateRepository)
{
$this->baseModel = new RoomRate();
$this->hotelRoomRepo = $hotelRateRepository;
$this->roomRateRepo = $roomRateRepository;
$this->middleware('auth');
}
/**
* Show the list
*
* @param $idHotel
* @param Request $request
* @return Renderable
* @throws AuthorizationException
*/
public function index($idHotel, Request $request)
{
$this->authorize('permission', $this->route . '.view');
$keyword = $request->input('keyword', '');
$today = Carbon::today()->toImmutable();
$from = $request->input('from')
? Carbon::createFromFormat('Y-m-d', $request->input('from'))
: $today->subDays(7);
$to = $request->input('to')
? Carbon::createFromFormat('Y-m-d', $request->input('to'))
: $today;
$period = CarbonPeriod::create($from, $to->subDay()->format('Y-m-d'));
$dates = [];
foreach ($period as $date) {
$dates[] = $date->format('Y-m-d H:i:s');
}
$data = [
'data' => [],
'dates' => $dates,
'from' => $from->format('Y-m-d H:i:s'),
'to' => $to->format('Y-m-d H:i:s')
];
$items = $this->hotelRoomRepo->getRateByHotel($idHotel, $from, $to, $request->except('page'), $keyword);
foreach ($items as $item) {
if ($item) {
foreach ($dates as $date) {
if ($item->date !== $date) continue;
$data['data'][$item->name][$date][] = $item;
}
}
}
return view($this->route . '.index', $data)
->with('route', $this->route)
->with('idHotel', $idHotel);
}
/**
* show
*
* @param $id
* @return Renderable
* @throws AuthorizationException
*/
public function show($id)
{
$this->authorize('permission', $this->route . '.view');
$room = $this->baseModel->find($id);
return view($this->route . '.desc', compact('room'));
}
/**
* Show the edit property room.
*
* @param $id
* @return Renderable
* @throws AuthorizationException
*/
public function edit($id)
{
$this->authorize('permission', $this->route . '.edit');
$room = $this->baseModel->find($id);
return view($this->route . '.form', compact('room'));
}
/**
* Show the create property room.
*
* @param Request $request
* @return Renderable
* @throws AuthorizationException
*/
public function create($idHotel, Request $request)
{
$this->authorize('permission', $this->route . '.create');
return view($this->route . '.form');
}
/**
* store.
*
* @return Renderable
* @throws AuthorizationException
*/
public function store($idHotel, Request $request)
{
$this->authorize('permission', $this->route . '.create');
}
/**
* update.
*
* @return Renderable
* @throws AuthorizationException
*/
public function update($idHotel, $id, Request $request)
{
$this->authorize('permission', $this->route . '.edit');
$room = $this->baseModel->findOrFail($id);
$rules = [
'code' => ['required', 'unique:carriers,code,' . $room->id],
'name' => ['required'],
];
$this->validate($request, $rules);
$data = $request->all();
$room->update($data);
return redirect(route($this->route))
->with('success', 'Updated Success !');
}
/**
* destroy.
*
* @param $idHotel
* @param $id
* @param Request $request
* @return Renderable
* @throws AuthorizationException
*/
public function destroy($idHotel, $id, Request $request)
{
$this->authorize('permission', $this->route . '.delete');
$this->baseModel
->find($id)
->delete();
return $this->ajaxRespond(1, 'Deleted successfully', []);
}
/**
* sort item by time
* @param $array
* @return $array
*/
private function _sortByDate(&$array)
{
foreach ($array as $key => $value) {
foreach ($array as $key2 => $value2) {
if (strtotime($key) == strtotime($key2)) continue;
if (strtotime($key) > strtotime($key2)) {
$tg = $array[$key];
$array[$key] = $array[$key2];
$array[$key2] = $tg;
}
}
}
dd($array);
return $array;
}
}
| 26.895735 | 113 | 0.538678 |
90ede313f44fde573f30fd056cd81c8513f16bca | 11,159 | py | Python | tests/common/snappi/snappi_helpers.py | xwjiang2021/sonic-mgmt | 82c446b9fb016eb070af765aa9d9999e55b27342 | [
"Apache-2.0"
] | 2 | 2021-11-24T09:33:41.000Z | 2021-12-03T09:08:29.000Z | tests/common/snappi/snappi_helpers.py | xwjiang2021/sonic-mgmt | 82c446b9fb016eb070af765aa9d9999e55b27342 | [
"Apache-2.0"
] | 1 | 2021-09-08T00:59:33.000Z | 2021-09-08T00:59:33.000Z | tests/common/snappi/snappi_helpers.py | xwjiang2021/sonic-mgmt | 82c446b9fb016eb070af765aa9d9999e55b27342 | [
"Apache-2.0"
] | 1 | 2021-08-20T03:34:30.000Z | 2021-08-20T03:34:30.000Z | # -*- coding: utf-8 -*-
"""
This module contains a definition of a simple helper class
"SnappiFanoutManager" which can be used to manage cards and ports of Snappi
chassis instead of reading it from fanout_graph_facts fixture.
"""
from tests.common.helpers.assertions import pytest_assert
from tests.common.snappi.common_helpers import ansible_stdout_to_str, get_peer_snappi_chassis
from tests.common.reboot import logger
import time
class SnappiFanoutManager():
"""Class for managing multiple chassis and extracting the information
like chassis IP, card, port etc. from fanout_graph_fact."""
def __init__(self, fanout_data):
""" When multiple chassis are available inside fanout_graph_facts
this method makes a list of chassis connection-details out of it.
So each chassis and details associated with it can be accessed by
a integer index (starting from 0)
Args:
fanout_data (dict): the dictionary returned by fanout_graph_fact.
Example format of the fanout_data is given below
{u'snappi-sonic': {
u'device_conn': {
u'Card9/Port1': {
u'peerdevice': u'sonic-s6100-dut',
u'peerport': u'Ethernet0',
u'speed': u'100000'
},
u'Card9/Port2': {
u'peerdevice': u'sonic-s6100-dut',
u'peerport': u'Ethernet4',
u'speed': u'100000'
},
u'Card9/Port3': {
u'peerdevice': u'sonic-s6100-dut',
u'peerport': u'Ethernet8',
u'speed': u'100000'
}
},
u'device_info': {
u'HwSku': u'SNAPPI-tester',
u'ManagementGw': u'10.36.78.54',
u'ManagementIp': u'10.36.78.53/32',
u'Type': u'DevSnappiChassis',
u'mgmtip': u'10.36.78.53'
},
u'device_port_vlans': {
u'Card9/Port1': {
u'mode': u'Access',
u'vlanids': u'300',
u'vlanlist': [300]
},
u'Card9/Port2': {
u'mode': u'Access',
u'vlanids': u'301',
u'vlanlist': [301]
},
u'Card9/Port3': {
u'mode': u'Access',
u'vlanids': u'302',
u'vlanlist': [302]
}
},
u'device_vlan_list': [301, 302, 300, 302, 300, 301],
u'device_vlan_range': [u'300-302']
}
}
"""
self.last_fanout_assessed = None
self.fanout_list = []
self.last_device_connection_details = None
self.current_snappi_port_list = None
self.ip_address = '0.0.0.0'
for fanout in fanout_data.keys():
self.fanout_list.append(fanout_data[fanout])
def __parse_fanout_connections__(self):
device_conn = self.last_device_connection_details
retval = []
for key in device_conn.keys():
fanout_port = ansible_stdout_to_str(key)
peer_port = ansible_stdout_to_str(device_conn[key]['peerport'])
peer_device = ansible_stdout_to_str(device_conn[key]['peerdevice'])
speed = ansible_stdout_to_str(device_conn[key]['speed'])
string = "{}/{}/{}/{}/{}".\
format(self.ip_address, fanout_port, peer_port, peer_device, speed)
retval.append(string)
return(retval)
def get_fanout_device_details(self, device_number):
"""With the help of this function you can select the chassis you want
to access. For example get_fanout_device_details(0) selects the
first chassis. It just select the chassis but does not return
anything. The rest of the function then used to extract chassis
information like "get_chassis_ip()" will the return the ip address
of chassis 0 - the first chassis in the list.
Note:
Counting or indexing starts from 0. That is 0 = 1st chassis,
1 = 2nd chassis ...
Args:
device_number (int): the chassis index (0 is the first)
Returns:
None
"""
# Pointer to chassis info
self.last_fanout_assessed = device_number
# Chassis connection details
self.last_device_connection_details = \
self.fanout_list[self.last_fanout_assessed]['device_conn']
# Chassis ip details
chassis_ip = self.fanout_list[self.last_fanout_assessed]['device_info']['mgmtip']
self.ip_address = ansible_stdout_to_str(chassis_ip)
# List of chassis cards and ports
self.current_snappi_port_list = \
self.__parse_fanout_connections__()
def get_connection_details(self):
"""This function returns all the details associated with a particular
chassis (selected earlier using get_fanout_device_details() function).
Details of the chassis will be available like chassis IP, card, ports,
peer port etc. in a dictionary format.
Note: If you have not used get_fanout_device_details(), by default 0th
(first) chassis remains selected.
Args:
This function takes no argument.
Returns:
Details of the chassis connection as dictionary format.
"""
return(self.last_device_connection_details)
def get_chassis_ip(self):
"""This function returns IP address of a particular chassis
(selected earlier using get_fanout_device_details() function).
Note: If you have not used get_fanout_device_details(), by default 0th
(first) chassis remains selected.
Args:
This function takes no argument.
Returns:
The IP address
"""
return self.ip_address
def get_ports(self, peer_device=None):
"""This function returns list of ports that are (1) associated with a
chassis (selected earlier using get_fanout_device_details() function)
and (2) connected to a peer device (SONiC DUT) as a list of dictionary.
Note: If you have not used get_fanout_device_details(), by default 0th
(first) chassis remains selected. If you do not specify peer_device,
this function will return all the ports of the chassis.
Args:
peer_device (str): hostname of the peer device
Returns:
Dictionary of chassis card port information.
"""
retval = []
for port in self.current_snappi_port_list:
info_list = port.split('/')
dict_element = {
'ip': info_list[0],
'card_id': info_list[1].replace('Card', ''),
'port_id': info_list[2].replace('Port', ''),
'peer_port': info_list[3],
'peer_device': info_list[4],
'speed': info_list[5]
}
if peer_device is None or info_list[4] == peer_device:
retval.append(dict_element)
return retval
def get_snappi_port_location(intf):
"""
Extracting location from interface, since Snappi Api accepts location
in terms of chassis ip, card, and port in different format.
Note: Interface must have the keys 'ip', 'card_id' and 'port_id'
Args:
intf (dict) : intf must contain the keys 'ip', 'card_id', 'port_id'.
Example format :
{'ip': u'10.36.78.53',
'port_id': u'1',
'card_id': u'9',
'speed': 100000,
'peer_port': u'Ethernet0'}
Returns: location in string format. Example: '10.36.78.5;1;2' where
1 is card_id and 2 is port_id.
"""
keys = set(['ip', 'card_id', 'port_id'])
pytest_assert(keys.issubset(set(intf.keys())), "intf does not have all the keys")
return "{};{};{}".format(intf['ip'], intf['card_id'], intf['port_id'])
def get_dut_port_id(dut_hostname, dut_port, conn_data, fanout_data):
snappi_fanout = get_peer_snappi_chassis(conn_data=conn_data,
dut_hostname=dut_hostname)
if snappi_fanout is None:
return None
snappi_fanout_id = list(fanout_data.keys()).index(snappi_fanout)
snappi_fanout_list = SnappiFanoutManager(fanout_data)
snappi_fanout_list.get_fanout_device_details(device_number=snappi_fanout_id)
snappi_ports = snappi_fanout_list.get_ports(peer_device=dut_hostname)
for i in range(len(snappi_ports)):
if snappi_ports[i]['peer_port'] == dut_port:
return i
return None
def wait_for_arp(snappi_api, max_attempts=10, poll_interval_sec=1):
"""
This function waits for arp to get resolved for ipv4/ipv6 in the snappi config
Args:
snappi_api: snappi api
max_attempts: maximum attempts for timeout
poll_interval_sec: interval poll second
Return:
returns number of attempts if arp is resolved within max attempts else fail
"""
attempts = 0
v4_gateway_macs_resolved = False
v6_gateway_macs_resolved = False
get_config = snappi_api.get_config()
v4_addresses = []
v6_addresses = []
for device in get_config.devices:
for ethernet in device.ethernets:
for v4_address in ethernet.ipv4_addresses:
v4_addresses.append(v4_address.address)
for v6_address in ethernet.ipv6_addresses:
v6_addresses.append(v6_address.address)
while attempts < max_attempts:
request = snappi_api.states_request()
request.choice = request.IPV4_NEIGHBORS
states = snappi_api.get_states(request)
if len(v4_addresses) > 0:
v4_link_layer_address = [
state.link_layer_address
for state in states.ipv4_neighbors
if state.link_layer_address is not None
]
if len(v4_addresses) == len(v4_link_layer_address):
v4_gateway_macs_resolved = True
else:
v4_gateway_macs_resolved = True
request = snappi_api.states_request()
request.choice = request.IPV6_NEIGHBORS
states = snappi_api.get_states(request)
if len(v6_addresses) > 0:
v6_link_layer_address = [
state.link_layer_address
for state in states.ipv6_neighbors
if state.link_layer_address is not None
]
if len(v6_addresses) == len(v6_link_layer_address):
v6_gateway_macs_resolved = True
else:
v6_gateway_macs_resolved = True
if v4_gateway_macs_resolved and v6_gateway_macs_resolved:
break
else:
time.sleep(poll_interval_sec)
attempts += 1
pytest_assert(attempts < max_attempts,
"ARP is not resolved in {} seconds".format(max_attempts * poll_interval_sec))
return attempts
| 35.766026 | 95 | 0.598261 |
20f68160961fa0d59c22035f08223762e9c32df1 | 359 | lua | Lua | codes/init.lua | NodeUSB/lua-examples | 9884cf98a2c25016eb6aeedce42ff09b8c090828 | [
"MIT"
] | 11 | 2015-07-16T00:56:31.000Z | 2021-12-21T19:50:28.000Z | codes/init.lua | NodeUSB/lua-examples | 9884cf98a2c25016eb6aeedce42ff09b8c090828 | [
"MIT"
] | 1 | 2015-10-14T01:08:15.000Z | 2015-10-14T05:08:58.000Z | codes/init.lua | NodeUSB/lua-examples | 9884cf98a2c25016eb6aeedce42ff09b8c090828 | [
"MIT"
] | 6 | 2015-07-22T10:29:19.000Z | 2020-03-14T15:55:44.000Z |
tmr.alarm(1,3000,1,function()
local ip = wifi.sta.getip()
if(ip==nil) then
print("Offline")
else
require("d").r(ip,wifi.sta.getmac())
ip=nil
tmr.stop(1)
tmr.alarm(0,6000,0,function() dofile("i.lc") end)
tmr.alarm(2,2000,0,function() d=nil package.loaded["d"]=nil collectgarbage("collect") end)
end
end)
| 18.894737 | 97 | 0.590529 |
51da3c1554fe7f00fca4e6672023d56a24250c65 | 941 | lua | Lua | example/example.lua | LuaDist-testing/copas-async | baa7e952eb3227fdbd23fbc35cb2df79d3fdb467 | [
"MIT"
] | 5 | 2016-06-02T21:28:28.000Z | 2021-04-02T05:25:52.000Z | example/example.lua | LuaDist-testing/copas-async | baa7e952eb3227fdbd23fbc35cb2df79d3fdb467 | [
"MIT"
] | null | null | null | example/example.lua | LuaDist-testing/copas-async | baa7e952eb3227fdbd23fbc35cb2df79d3fdb467 | [
"MIT"
] | null | null | null |
local copas = require("copas")
local async = require("copas.async")
copas.addthread(function()
for i = 1, 10 do
print("coroutine A says ", i)
copas.sleep(1)
end
print("DONE A")
end)
local msg = "hello"
local future = async.addthread(function()
os.execute("for i in `seq 5`; do echo 'thread says "..msg.." '$i; sleep 1; done")
return 123
end)
copas.addthread(function()
copas.sleep(2)
msg = "world" -- this will not affect the async thread
print("coroutine B will try to get thread value:")
local val = future:try()
if not val then
print("coroutine B didn't get a value because thread is not done!")
end
print("coroutine B will wait for thread value...")
val = future:get()
print("coroutine B got value from thread:", val)
local ret, typ, cod = async.os_execute("sleep 2; exit 12")
print("coroutine B slept a bit: ", ret, typ, cod)
print("DONE B")
end)
copas.loop()
| 24.763158 | 84 | 0.646121 |
4b2c7776925b13aae620ca93a40e31fd67dcaf65 | 3,427 | html | HTML | WWWRoot/index.html | icris-nl/talos | 3217bc091a66e92a37d0f50ee5224ee88aa1e3a3 | [
"MIT"
] | null | null | null | WWWRoot/index.html | icris-nl/talos | 3217bc091a66e92a37d0f50ee5224ee88aa1e3a3 | [
"MIT"
] | 1 | 2019-07-08T12:50:21.000Z | 2019-07-09T06:51:24.000Z | WWWRoot/index.html | icris-nl/talos | 3217bc091a66e92a37d0f50ee5224ee88aa1e3a3 | [
"MIT"
] | null | null | null | <html>
<head>
<link rel="stylesheet" href="style.css">
</link>
<script src="js/vue.min.js"></script>
<script src="components.js"></script>
<script src="app.js"></script>
</head>
<body>
<div id="main" class="box">
<div class="accordion box">
<section id="home">
<h2><a href="#home">Home</a></h2>
<div>
<img src="images/talos.png" style="width:300px;" />
<p>
Welcome to your Talos stack.
</p>
<p>
Current system status:
</p>
<table>
<tr><th>Service</th><th>Status</th></tr>
<tr><td>InfluxDB</td><td>{{status.influxdb}}</td><td><a href="http://localhost:8888/" target="_blank">>> Chronograf</a></td></tr>
<tr><td>mongodb</td><td>{{status.mongodb}}</td></tr>
<tr><td>node-red</td><td>{{status.app}}</td><td><a href="http://localhost:1880/admin" target="_blank">>> Flow editor</a></td></tr>
</table>
<br/>
<button @click="Restart">Restart</button>
<br/>
</div>
</section>
<section id="sysmon">
<h2><a href="#sysmon" @click="RefreshSysmon">System Status</a></h2>
<div>
<br/>
<p>
System monitoring
</p>
<iframe id="sysgraphs" style="width:100%; height:537px; overflow: unset" src="http://localhost:8889/d/KGfK3WSWz/sysmon?orgId=1&refresh=10s&kiosk"></iframe>
<!--<iframe style="width:100%; height:537px;" src="http://localhost:8888/sources/1/dashboards/2?present=true"></iframe>-->
</div>
</section>
<section id="timeseries">
<h2><a href="#timeseries">Timeseries</a></h2>
<div>
<h2>Timeseries</h2>
<grid :height="'200'" :data="timeseries" :columns="timeseriesColumns"
@selected="TimeseriesSelected"></grid>
</div>
</section>
<section id="sources">
<h2><a href="#sources">Sources</a></h2>
<div>
<grid :height="'400'" :data="sources" :columns="sourcesColumns" v-on:selected="SourceSelected">
<!--Subscribe to the emitted event -->
</grid>
<detailstable :item="selectedSource" :keys="sourceKeys" @save="SaveSource" @delete="DeleteSource"
@new="NewSource">
</div>
</section>
<section id="dashboards">
<h2><a href="#dashboards">Dashboards</a></h2>
<div>
dashboards
</div>
</section>
<section id="panels">
<h2><a href="#panels">Panels</a></h2>
<div>
panels
</div>
</section>
</div>
</div>
<div class="loading" id="loader" style="display: none">Loading…</div>
<div id="snackbar">Toast message</div>
<script src="index.js"></script>
</body>
</html> | 38.943182 | 175 | 0.437117 |
40fb9cf20093693e9db370ba4dc58c314304de22 | 2,903 | py | Python | code/chapter03_DL-basics/3.3_linear-regression-scratch.py | Sandy1230/Dive-into-DL-PyTorch-master | eca149f6b706a4e6a7b377707deab22341b014d1 | [
"Apache-2.0"
] | 4 | 2020-11-13T09:44:17.000Z | 2022-03-17T13:53:56.000Z | code/chapter03_DL-basics/3.3_linear-regression-scratch.py | zjc6666/Dive-into-DL-PyTorch-master | eca149f6b706a4e6a7b377707deab22341b014d1 | [
"Apache-2.0"
] | null | null | null | code/chapter03_DL-basics/3.3_linear-regression-scratch.py | zjc6666/Dive-into-DL-PyTorch-master | eca149f6b706a4e6a7b377707deab22341b014d1 | [
"Apache-2.0"
] | 2 | 2020-09-01T11:43:16.000Z | 2021-09-13T13:28:33.000Z | # To add a new cell, type '# %%'
# To add a new markdown cell, type '# %% [markdown]'
# # 3.3 线性回归的简洁实现
import torch
from torch import nn
import numpy as np
torch.manual_seed(1)
print(torch.__version__)
torch.set_default_tensor_type('torch.FloatTensor')
# ## 3.3.1 生成数据集
num_inputs = 2
num_examples = 1000
true_w = [2, -3.4]
true_b = 4.2
features = torch.tensor(np.random.normal(0, 1, (num_examples, num_inputs)), dtype=torch.float)
labels = true_w[0] * features[:, 0] + true_w[1] * features[:, 1] + true_b
labels += torch.tensor(np.random.normal(0, 0.01, size=labels.size()), dtype=torch.float)
# ## 3.3.2 读取数据
import torch.utils.data as Data
batch_size = 10
# 将训练数据的特征和标签组合
dataset = Data.TensorDataset(features, labels)
# 把 dataset 放入 DataLoader
data_iter = Data.DataLoader(
dataset=dataset, # torch TensorDataset format
batch_size=batch_size, # mini batch size
shuffle=True, # 要不要打乱数据 (打乱比较好)
num_workers=2, # 多线程来读数据
)
for X, y in data_iter:
print(X, '\n', y)
break
# ## 3.3.3 定义模型
class LinearNet(nn.Module):
def __init__(self, n_feature):
super(LinearNet, self).__init__()
self.linear = nn.Linear(n_feature, 1)
def forward(self, x):
y = self.linear(x)
return y
net = LinearNet(num_inputs)
print(net) # 使用print可以打印出网络的结构
# 写法一
net = nn.Sequential(
nn.Linear(num_inputs, 1)
# 此处还可以传入其他层
)
# 写法二
net = nn.Sequential()
net.add_module('linear', nn.Linear(num_inputs, 1))
# net.add_module ......
# 写法三
from collections import OrderedDict
net = nn.Sequential(OrderedDict([
('linear', nn.Linear(num_inputs, 1))
# ......
]))
print(net)
print(net[0])
for param in net.parameters():
print(param)
# ## 3.3.4 初始化模型参数
from torch.nn import init
init.normal_(net[0].weight, mean=0.0, std=0.01)
init.constant_(net[0].bias, val=0.0) # 也可以直接修改bias的data: net[0].bias.data.fill_(0)
for param in net.parameters():
print(param)
# ## 3.3.5 定义损失函数
loss = nn.MSELoss()
# ## 3.3.6 定义优化算法
import torch.optim as optim
optimizer = optim.SGD(net.parameters(), lr=0.03)
print(optimizer)
# 为不同子网络设置不同的学习率
# optimizer =optim.SGD([
# # 如果对某个参数不指定学习率,就使用最外层的默认学习率
# {'params': net.subnet1.parameters()}, # lr=0.03
# {'params': net.subnet2.parameters(), 'lr': 0.01}
# ], lr=0.03)
# # 调整学习率
# for param_group in optimizer.param_groups:
# param_group['lr'] *= 0.1 # 学习率为之前的0.1倍
# ## 3.3.7 训练模型
num_epochs = 3
for epoch in range(1, num_epochs + 1):
for X, y in data_iter:
output = net(X)
l = loss(output, y.view(-1, 1))
optimizer.zero_grad() # 梯度清零,等价于net.zero_grad()
l.backward()
optimizer.step()
print('epoch %d, loss: %f' % (epoch, l.item()))
dense = net[0]
print(true_w, dense.weight.data)
print(true_b, dense.bias.data)
| 20.588652 | 94 | 0.627627 |
17b51f1a399886c1c97e56f8b7eb41fd6e4c8314 | 3,144 | cs | C# | platformPerformer/sortingmethods/Mergesort T.cs | Tvede-dk/platform-performance-c- | e1948ab04c1af98c0c6f5a5f527c72e60379913a | [
"MIT"
] | null | null | null | platformPerformer/sortingmethods/Mergesort T.cs | Tvede-dk/platform-performance-c- | e1948ab04c1af98c0c6f5a5f527c72e60379913a | [
"MIT"
] | null | null | null | platformPerformer/sortingmethods/Mergesort T.cs | Tvede-dk/platform-performance-c- | e1948ab04c1af98c0c6f5a5f527c72e60379913a | [
"MIT"
] | 1 | 2020-02-06T09:34:07.000Z | 2020-02-06T09:34:07.000Z | using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace platformPerformer.sortingmethods {
public class Mergesort_T : platformMethod<int[], int[]> {
public string getName() {
return "T merge sort";
}
public int[] performMethod( int[] input ) {
handleWork( input );
return input;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void handleWork( int[] input ) {
for ( int width = 1; width < input.Length; width++ ) {
for ( int i = 0; i < input.Length; i += width * 2 ) {
//look at [i; i+width[ -> [i+width;i+width*2[;'
if ( i + width < input.Length ) {
merge( input, i, i + width, Math.Min( i + width, input.Length - 2 ), Math.Min( i + (width * 2), input.Length ) );
}
//they are sorted so call merge with that.
}
}
//return input;c
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void merge( int[] arr, int a_start, int a_end, int b_start, int b_end ) {
int oneLenght = a_end - a_start;
int[] buffer = new int[b_end - a_start];
int a_ptr = a_start;
int b_ptr = b_start;
for ( int i = 0; i < oneLenght; i++ ) {
int val;
if ( arr[a_ptr] < arr[b_ptr] ) {
val = arr[a_ptr];
buffer[i] = val;
a_ptr++;
if ( a_ptr >= a_end ) {
//copy the rest from b. OPTIMIZED
copyToLen( buffer, arr, 0, a_ptr - a_start, a_start ); //since we know that b is sorted and that we are out of A,
//then by moving the buffer into the orginal array, we know that we dont have to move around B and that B is sorted,
//and that this buffer is also sorted, meaning we dont have to work with the rest of B.
return;
}
} else {
val = arr[b_ptr];
buffer[i] = val;
b_ptr++;
if ( b_ptr >= b_end ) {
//but before that move a_ptr - a_end to a "new" buffer ???
copyToLen( arr, buffer, a_ptr, a_end - 1, i );
break;
}
}
}
buffer.CopyTo( arr, a_start );
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
//excl dest.
private static void copyToLen( int[] src, int[] dest, int startSrc, int endSrc, int startDst ) {
for ( int i = 0; i < (endSrc - startSrc); i++ ) {
dest[startDst + i] = src[startSrc + i];
}
}
}
}
| 41.92 | 195 | 0.459606 |
75f59bc644cc177cb0a245fefb3454aeea80cf4a | 519 | cs | C# | samples/SampleClient/Scenarios/IScenario.cs | jrunyen/reverse-proxy | a042a2e7dd0d6b5247bac1b0873883f4f1c5dfbe | [
"MIT"
] | 5 | 2020-04-28T13:32:36.000Z | 2022-03-10T06:48:50.000Z | samples/SampleClient/Scenarios/IScenario.cs | jrunyen/reverse-proxy | a042a2e7dd0d6b5247bac1b0873883f4f1c5dfbe | [
"MIT"
] | 1 | 2021-08-18T05:32:44.000Z | 2021-08-18T05:32:44.000Z | samples/SampleClient/Scenarios/IScenario.cs | jrunyen/reverse-proxy | a042a2e7dd0d6b5247bac1b0873883f4f1c5dfbe | [
"MIT"
] | 1 | 2020-11-11T02:22:00.000Z | 2020-11-11T02:22:00.000Z | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Threading;
using System.Threading.Tasks;
namespace SampleClient.Scenarios
{
/// <summary>
/// Interface for the implementation of a scenario that can be executed asynchronously.
/// </summary>
internal interface IScenario
{
/// <summary>
/// Executes the scenario asynchronously.
/// </summary>
Task ExecuteAsync(CommandLineArgs args, CancellationToken cancellation);
}
}
| 25.95 | 91 | 0.680154 |
39c5ac7827cb2f98637e11e2fa5bb27be9ba5388 | 2,305 | js | JavaScript | build/app.min.js | michaelspiss/sphere-volume-monte-carlo | 01c7c0c044cfabf83abaea623e1388ebfd098982 | [
"MIT"
] | null | null | null | build/app.min.js | michaelspiss/sphere-volume-monte-carlo | 01c7c0c044cfabf83abaea623e1388ebfd098982 | [
"MIT"
] | null | null | null | build/app.min.js | michaelspiss/sphere-volume-monte-carlo | 01c7c0c044cfabf83abaea623e1388ebfd098982 | [
"MIT"
] | null | null | null | function getRandomInt(){return Math.floor(1e3*Math.random())/1e3}function testCoordinates(t){for(var e=0;t>e;e++){var a=getRandomInt(),n=getRandomInt(),i=getRandomInt();1>=a*a+n*n+i*i?(k++,diagram.series[1].addPoint([a,n,i],!1,!1,!1)):diagram.series[0].addPoint([a,n,i],!1,!1,!1)}}function resetCalculations(){DisplayN.innerHTML="0",DisplayK.innerHTML="0",DisplayKOverN.innerHTML="0",n=0,k=0,diagram.series[0].setData([],!1,!1,!1),diagram.series[1].setData([],!0,!1,!1)}function startCalculations(){var t=document.getElementById("valNNew").value;if(isNaN(parseInt(t)))return!1;t=parseInt(t),n+=t,testCoordinates(t),DisplayN.innerHTML=n.toString(),DisplayK.innerHTML=k.toString();var e=0==n?0:k/n*8;DisplayKOverN.innerHTML=e.toString(),setTimeout(function(){diagram.redraw()},15)}var n=0,k=0,DisplayN=null,DisplayK=null,DisplayKOverN=null;$(document).ready(function(){DisplayN=document.getElementById("valN"),DisplayK=document.getElementById("valK"),DisplayKOverN=document.getElementById("valKOverN"),document.getElementById("startButton").onclick=function(){startCalculations()},document.getElementById("resetButton").onclick=function(){resetCalculations()}});var diagram;$(function(){var t=new Highcharts.Chart({chart:{renderTo:"diagram",margin:100,events:{},type:"scatter",options3d:{enabled:!0,alpha:5,beta:50,depth:200,viewDistance:5,frame:{bottom:{size:1,color:"rgba(0,0,0,.02)"},back:{size:1,color:"rgba(0,0,0,.04)"},side:{size:1,color:"rgba(0,0,0,.06)"}}}},title:{text:"An eighth of a sphere"},subtitle:{text:"Click and drag to move"},plotOptions:{scatter:{width:1,height:1,depth:1,enableMouseTracking:!1}},yAxis:{min:0,max:1,title:null},xAxis:{min:0,max:1,gridLineWidth:.5},zAxis:{min:0,max:1,showFirstLabel:!1},legend:{enabled:!1},series:[{marker:{radius:2,fillColor:"rgba(44, 62, 80,.2)"},data:[]},{marker:{radius:2,fillColor:"rgba(211, 84, 0,1.0)"},data:[]}]});$(t.container).bind("mousedown.hc touchstart.hc",function(e){e=t.pointer.normalize(e);var a,n,i=e.pageX,o=e.pageY,r=t.options.chart.options3d.alpha,s=t.options.chart.options3d.beta,l=5;$(document).bind({"mousemove.hc touchdrag.hc":function(e){n=s+(i-e.pageX)/l,t.options.chart.options3d.beta=n,a=r+(e.pageY-o)/l,t.options.chart.options3d.alpha=a,t.redraw(!1)},"mouseup touchend":function(){$(document).unbind(".hc")}})}),diagram=t}); | 2,305 | 2,305 | 0.733189 |
fc7a7518e3693d57b34ffbcdf86a8935fe8a6d5d | 532 | sql | SQL | 01-basic-query/10-ddl/ddl-constraint-deferrable.sql | BootcampYoutubeChannel/belajar-rdbms-oraclexe-18c | 217eaa25c0e9bb11ed85b9c607ee96dbb1a8494d | [
"MIT"
] | 1 | 2021-11-15T07:57:38.000Z | 2021-11-15T07:57:38.000Z | 01-basic-query/10-ddl/ddl-constraint-deferrable.sql | BootcampYoutubeChannel/belajar-rdbms-oraclexe-18c | 217eaa25c0e9bb11ed85b9c607ee96dbb1a8494d | [
"MIT"
] | null | null | null | 01-basic-query/10-ddl/ddl-constraint-deferrable.sql | BootcampYoutubeChannel/belajar-rdbms-oraclexe-18c | 217eaa25c0e9bb11ed85b9c607ee96dbb1a8494d | [
"MIT"
] | null | null | null | alter table TEST_CONSTRAINT_CHECK
drop constraint CK_SALDO_ALWAYS_ABS;
alter table TEST_CONSTRAINT_CHECK
add constraint ck_saldo_always_abs check ( SALDO >= 0 )
deferrable initially deferred;
insert into TEST_CONSTRAINT_CHECK(NIK, NAMA, SALDO, JENIS_KELAMIN)
VALUES ('0202023', 'Test invalid saldo', -1, 'L');
insert into TEST_CONSTRAINT_CHECK(NIK, NAMA, SALDO, JENIS_KELAMIN)
VALUES ('0202022', 'Test Valid saldo', 10000, 'L');
select * from TEST_CONSTRAINT_CHECK where NIK in ('0202023', '0202022');
commit;
| 29.555556 | 72 | 0.755639 |
5ffbbf982a52b3c6e200f066d2eca782f1ec393f | 10,596 | c | C | Tools/pmake/src/customs/avail.c | steakknife/pcgeos | 95edd7fad36df400aba9bab1d56e154fc126044a | [
"Apache-2.0"
] | 504 | 2018-11-18T03:35:53.000Z | 2022-03-29T01:02:51.000Z | Tools/pmake/src/customs/avail.c | steakknife/pcgeos | 95edd7fad36df400aba9bab1d56e154fc126044a | [
"Apache-2.0"
] | 96 | 2018-11-19T21:06:50.000Z | 2022-03-06T10:26:48.000Z | Tools/pmake/src/customs/avail.c | steakknife/pcgeos | 95edd7fad36df400aba9bab1d56e154fc126044a | [
"Apache-2.0"
] | 73 | 2018-11-19T20:46:53.000Z | 2022-03-29T00:59:26.000Z | /*-
* avail.c --
* Functions to check the status of the local machine to see
* if it can accept processes.
*
* Copyright (c) 1988, 1989 by the Regents of the University of California
* Copyright (c) 1988, 1989 by Adam de Boor
* Copyright (c) 1989 by Berkeley Softworks
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any non-commercial purpose
* and without fee is hereby granted, provided that the above copyright
* notice appears in all copies. The University of California,
* Berkeley Softworks and Adam de Boor make no representations about
* the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*/
#ifndef lint
static char *rcsid =
"$Id: avail.c,v 1.20 89/11/14 13:45:53 adam Exp $ SPRITE (Berkeley)";
#endif lint
#include "customsInt.h"
#include <stdio.h>
static unsigned long maxLoad = 0.5 * LOADSCALE;
static int minSwapFree=25; /* 75% used swap => not available */
static int minIdle=15*60; /* Keyboard must have been idle at
* least 15 minutes (when this is
* 15 * 60)... */
static int maxImports = 2; /* Largest number of imported jobs */
static Rpc_Event availEvent; /* Event for checking availability */
static struct timeval availInterval; /* Interval at which checks should
* be made for the availability of
* this host. */
static int availCheck; /* Mask of criteria to examine */
int avail_Bias; /* Bias for rating calculation */
/*-
*-----------------------------------------------------------------------
* Avail_Send --
* Send the availability of the local host.
*
* Results:
* None.
*
* Side Effects:
* An availability packet is sent to the master.
*
*-----------------------------------------------------------------------
*/
Boolean
Avail_Send ()
{
Avail avail;
static int sending = 0; /* XXX: A kludge to prevent endless
* recursion. At times, for no reason I've
* been able to determine, the avail event
* will be triggered during the call to
* CUSTOMS_AVAIL (hard to believe since
* the timeout for the avail event is
* twice as long as the total for the
* rpc, but...). Once it starts, it
* continues and the calls never seem to
* complete. To prevent this, we use a
* static flag and don't send anything
* if a call is already being sent. */
if (sending) {
return(FALSE);
} else {
sending = 1;
}
avail.addr = localAddr.sin_addr;
avail.interval = availInterval;
avail.avail = Avail_Local(AVAIL_EVERYTHING, &avail.rating);
if (verbose) {
printf ("Localhost %s available\n", avail.avail ? "not" : "is");
fflush(stdout);
}
if (!Elect_InProgress() &&
(Rpc_Call(udpSocket, &masterAddr, (Rpc_Proc)CUSTOMS_AVAIL,
sizeof(avail), (Rpc_Opaque)&avail,
0, (Rpc_Opaque)0,
CUSTOMSINT_NRETRY, &retryTimeOut) != RPC_SUCCESS)) {
Elect_GetMaster();
}
sending = 0;
return (FALSE);
}
/*-
*-----------------------------------------------------------------------
* AvailSet --
* Set the availability criteria. Returns an OR of bits if the
* parameters are out-of-range.
*
* Results:
* Any of AVAIL_IDLE, AVAIL_SWAP, AVAIL_LOAD and AVAIL_IMPORTS
* or'ed together (or 0 if things are ok).
*
* Side Effects:
* The availabilty criteria are altered.
*
*-----------------------------------------------------------------------
*/
/*ARGSUSED*/
static void
AvailSet (from, msg, len, adPtr, fromRemote)
struct sockaddr_in *from; /* Address of sender */
Rpc_Message msg; /* Message for return */
int len; /* Length of criteria */
Avail_Data *adPtr; /* New criteria */
Boolean fromRemote; /* TRUE if from remote call */
{
int result;
if (!Local(from)) {
Rpc_Error(msg, RPC_ACCESS);
} else if (len != sizeof(Avail_Data)) {
Rpc_Error(msg, RPC_BADARGS);
} else {
/*
* Bounds-check the passed parameters, setting bits in result to
* correspond to bad values.
*/
result = 0;
if ((adPtr->changeMask & AVAIL_IDLE) && (adPtr->idleTime > MAX_IDLE)) {
result |= AVAIL_IDLE;
}
if ((adPtr->changeMask & AVAIL_SWAP) && (adPtr->swapPct > MAX_SWAP)) {
result |= AVAIL_SWAP;
}
if ((adPtr->changeMask & AVAIL_LOAD) &&
(adPtr->loadAvg < MIN_LOAD) &&
(adPtr->loadAvg != 0))
{
result |= AVAIL_LOAD;
}
if ((adPtr->changeMask & AVAIL_IMPORTS) &&
(adPtr->imports < MIN_IMPORTS) &&
(adPtr->imports != 0))
{
result |= AVAIL_IMPORTS;
}
if (result == 0) {
/*
* Everything ok -- change what needs changing.
*/
if (adPtr->changeMask & AVAIL_IDLE) {
minIdle = adPtr->idleTime;
}
if (adPtr->changeMask & AVAIL_SWAP) {
minSwapFree = adPtr->swapPct;
}
if (adPtr->changeMask & AVAIL_LOAD) {
maxLoad = adPtr->loadAvg;
}
if (adPtr->changeMask & AVAIL_IMPORTS) {
maxImports = adPtr->imports;
}
}
/*
* Set return value: changeMask gets error bits. the other fields get
* the current criteria.
*/
adPtr->changeMask = result;
adPtr->idleTime = minIdle;
adPtr->swapPct = minSwapFree;
adPtr->loadAvg = maxLoad;
adPtr->imports = maxImports;
/*
* Only send a reply if the call was actually remote (it's not
* when called from main...)
*/
if (fromRemote) {
Rpc_Return(msg, len, (Rpc_Opaque)adPtr);
}
}
}
/*-
*-----------------------------------------------------------------------
* AvailSetInterval --
* Alter the interval at which availability checks are made.
*
* Results:
* None.
*
* Side Effects:
* The interval in availInterval is changed and availEvent is altered
* to reflect this change.
*
*-----------------------------------------------------------------------
*/
static void
AvailSetInterval (from, msg, len, intervalPtr)
struct sockaddr_in *from;
Rpc_Message msg;
int len;
struct timeval *intervalPtr;
{
if (!Local(from)) {
Rpc_Error(msg, RPC_ACCESS);
} else if (len != sizeof(struct timeval)) {
Rpc_Error(msg, RPC_BADARGS);
} else if (intervalPtr->tv_sec < 5) {
Rpc_Error(msg, RPC_BADARGS);
} else {
availInterval = *intervalPtr;
Rpc_EventReset(availEvent, &availInterval);
Rpc_Return(msg, 0, (Rpc_Opaque)0);
}
}
/*-
*-----------------------------------------------------------------------
* Avail_Init --
* Initialize things for here...
*
* Results:
* None.
*
* Side Effects:
* We exit if can't initialize.
*
*-----------------------------------------------------------------------
*/
void
Avail_Init(criteria, checkTime)
Avail_Data *criteria; /* Initial criteria */
int checkTime; /* Initial check interval */
{
availInterval.tv_sec = checkTime ? checkTime : 10;
availInterval.tv_usec = 0;
availCheck = OS_Init();
availEvent = Rpc_EventCreate(&availInterval, Avail_Send, (Rpc_Opaque)0);
Rpc_ServerCreate(udpSocket, CUSTOMS_AVAILINTV, AvailSetInterval,
Swap_Timeval, Rpc_SwapNull, (Rpc_Opaque)0);
Rpc_ServerCreate(udpSocket, CUSTOMS_SETAVAIL, AvailSet,
Swap_Avail, Swap_Avail, (Rpc_Opaque)TRUE);
AvailSet(&localAddr, (Rpc_Message)0, sizeof(Avail_Data), criteria,
FALSE);
}
/*-
*-----------------------------------------------------------------------
* Avail_Local --
* See if the local host is available for migration
*
* Results:
* 0 if it is, else one of the AVAIL bits indicating which criterion
* wasn't satisfied.
*
* Side Effects:
* None.
*
*-----------------------------------------------------------------------
*/
int
Avail_Local(what, ratingPtr)
int what; /* Mask of things to check */
long *ratingPtr; /* Place to store rating of current availabilty */
{
/*
* Mask out bits the OS module says it can't check.
*/
what &= availCheck;
/*
* Start the rating out with the bias factor. The bias is intended for
* situations where certains machines are noticeably faster than others
* and are to be prefered even if the two appear to be loaded the same.
*/
*ratingPtr = avail_Bias;
/*
* If an minimum idle time was specified, check to make sure the
* keyboard idle time exceeds that.
*/
if ((what & AVAIL_IDLE) && minIdle) {
int idleTime = OS_Idle();
if (idleTime < minIdle) {
if (verbose) {
printf ("Only %d seconds idle (%d min)\n",
idleTime, minIdle);
fflush(stdout);
}
return AVAIL_IDLE;
}
*ratingPtr += idleTime - minIdle;
}
/*
* Either the machine has been idle long enough or the user didn't
* specify an idle time, so now, if the user gave a free swap space
* percentage beyond which the daemon may not go, tally up the total
* free blocks in the swap map and see if it's too few.
*/
if ((what & AVAIL_SWAP) && minSwapFree) {
int swapPct = OS_Swap();
if (swapPct < minSwapFree) {
if (verbose) {
printf ("Only %d%% free swap blocks\n", swapPct);
fflush(stdout);
}
return AVAIL_SWAP;
}
*ratingPtr += swapPct - minSwapFree;
}
/*
* So far so good. Now if the user gave some maximum load average (note
* that it can't be 0) which the daemon may not exceed, check all three
* load averages to make sure that none exceeds the limit.
*/
if ((what & AVAIL_LOAD) && maxLoad > 0) {
unsigned long load = OS_Load();
if (load > maxLoad) {
if (verbose) {
printf ("load: %f\n", (double) load/FSCALE);
}
return AVAIL_LOAD;
}
*ratingPtr += maxLoad - load;
}
/*
* Reduce the rating proportional to the amount of work we've accepted if
* we're not completely full. We weight this heavily in an attempt
* to avoid double allocations by the master (by changing the rating
* drastically, we hope to shift the focus to some other available machine)
*/
if ((what & AVAIL_IMPORTS) && maxImports && (Import_NJobs() >= maxImports))
{
return AVAIL_IMPORTS;
}
*ratingPtr -= Import_NJobs() * 200;
/*
* Great! This machine is available.
*/
return 0;
}
| 29.847887 | 80 | 0.572386 |
90e762e49b1eee536c287fb336a8b1e2e1493b75 | 437 | py | Python | src/cms/pages/migrations/0004_auto_20210121_0953.py | UniversitaDellaCalabria/uniCMS | b0af4e1a767867f0a9b3c135a5c84587e713cb71 | [
"Apache-2.0"
] | 6 | 2021-01-26T17:22:53.000Z | 2022-02-15T10:09:03.000Z | src/cms/pages/migrations/0004_auto_20210121_0953.py | UniversitaDellaCalabria/uniCMS | b0af4e1a767867f0a9b3c135a5c84587e713cb71 | [
"Apache-2.0"
] | 5 | 2020-12-24T14:29:23.000Z | 2021-08-10T10:32:18.000Z | src/cms/pages/migrations/0004_auto_20210121_0953.py | UniversitaDellaCalabria/uniCMS | b0af4e1a767867f0a9b3c135a5c84587e713cb71 | [
"Apache-2.0"
] | 2 | 2020-12-24T14:13:39.000Z | 2020-12-30T16:48:52.000Z | # Generated by Django 3.1.4 on 2021-01-21 09:53
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cmspages', '0003_auto_20210119_1359'),
]
operations = [
migrations.AlterField(
model_name='page',
name='description',
field=models.TextField(blank=True, help_text='Description used for SEO.', null=True),
),
]
| 23 | 97 | 0.617849 |
a7371a7d8744dfc61cc228955eaf4b768396fcf9 | 336 | ps1 | PowerShell | automatic/_output/eventghost/0.4.1.1640/tools/chocolateyInstall.ps1 | kewalaka/chocolatey-packages-2 | 327bbccaa029d0ddec49a33ac479a3ea24249dcf | [
"Apache-2.0"
] | 47 | 2015-02-19T15:32:43.000Z | 2022-03-27T02:41:36.000Z | automatic/_output/eventghost/0.4.1.1640/tools/chocolateyInstall.ps1 | kewalaka/chocolatey-packages-2 | 327bbccaa029d0ddec49a33ac479a3ea24249dcf | [
"Apache-2.0"
] | 564 | 2015-02-18T16:22:09.000Z | 2022-03-15T13:04:24.000Z | automatic/_output/eventghost/0.4.1.1640/tools/chocolateyInstall.ps1 | kewalaka/chocolatey-packages-2 | 327bbccaa029d0ddec49a33ac479a3ea24249dcf | [
"Apache-2.0"
] | 190 | 2015-06-26T12:42:03.000Z | 2022-02-27T17:13:18.000Z | $packageName = 'eventghost'
$installerType = 'exe'
$url = 'http://www.eventghost.org/downloads/EventGhost_0.4.1.r1640_Setup.exe'
$url64 = $url
$silentArgs = '/sp- /verysilent /norestart'
$validExitCodes = @(0)
Install-ChocolateyPackage "$packageName" "$installerType" "$silentArgs" "$url" "$url64" -validExitCodes $validExitCodes
| 37.333333 | 120 | 0.729167 |
68431617da5b0a772380893f60915c95f87eb762 | 144 | html | HTML | _includes/img.html | brandiarchive/brandiarchive.github.com | 5146ed205e4926ff7bfe8e2dcd0354ee01c1384e | [
"MIT"
] | null | null | null | _includes/img.html | brandiarchive/brandiarchive.github.com | 5146ed205e4926ff7bfe8e2dcd0354ee01c1384e | [
"MIT"
] | 2 | 2021-07-02T04:28:11.000Z | 2021-09-28T05:47:30.000Z | _includes/img.html | brandiarchive/brandiarchive.github.com | 5146ed205e4926ff7bfe8e2dcd0354ee01c1384e | [
"MIT"
] | null | null | null | <img src="{{site.url}}/{{ include.file }}" alt="{{include.alt}}" {% if include.border%} style="border:1px solid #ccc;" {%endif%} class="figure"> | 144 | 144 | 0.625 |
bf5d9f6aa3f7ef541bc4125634182069088132d9 | 3,160 | dart | Dart | pal_event_server/lib/src/loggers/intellij/linux/linux_helper.dart | isabella232/taqo-paco | 7302cabc055fd146e557b53f0b8083328b2c10d5 | [
"Apache-2.0"
] | null | null | null | pal_event_server/lib/src/loggers/intellij/linux/linux_helper.dart | isabella232/taqo-paco | 7302cabc055fd146e557b53f0b8083328b2c10d5 | [
"Apache-2.0"
] | 1 | 2021-06-18T14:59:50.000Z | 2021-06-18T14:59:50.000Z | pal_event_server/lib/src/loggers/intellij/linux/linux_helper.dart | isabella232/taqo-paco | 7302cabc055fd146e557b53f0b8083328b2c10d5 | [
"Apache-2.0"
] | null | null | null | // Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import 'dart:io';
import 'package:archive/archive.dart';
import 'package:archive/archive_io.dart';
import 'package:path/path.dart' as path;
const intelliJAssetPath = '/usr/lib/taqo/pal_intellij_plugin.zip';
final intelliJPaths = [
RegExp(r'\.?AndroidStudio\d+\.\d+'),
RegExp(r'\.?IdeaIC\d{4}\.\d+'),
];
void extractIntelliJPlugin(String directory) async {
final zipFile = await File(intelliJAssetPath).readAsBytes();
final pluginPkg = ZipDecoder().decodeBytes(zipFile);
final oldPluginDir = Directory(path.join(directory, 'config', 'plugins'));
final newPluginDir = Directory(directory);
final pluginDir = await newPluginDir.exists() ? newPluginDir : oldPluginDir;
for (var item in pluginPkg) {
final output = path.join(pluginDir.path, item.name);
if (item.isFile) {
final itemBytes = item.content as List<int>;
final f = File(output);
await f.create(recursive: true);
await f.writeAsBytes(itemBytes);
} else {
final d = Directory(output);
await d.create(recursive: true);
}
}
}
void enableIntelliJPlugin() async {
final homeDir = Directory(Platform.environment['HOME']);
final dirsToCheck = [
homeDir,
Directory(path.join(homeDir.path, '.local', 'share')),
Directory(path.join(homeDir.path, '.local', 'share', 'JetBrains')),
];
for (var toCheck in dirsToCheck) {
await for (var dir in toCheck.list()) {
final baseDir = path.basename(dir.path);
for (var idePath in intelliJPaths) {
if (idePath.hasMatch(baseDir)) {
await extractIntelliJPlugin(dir.path);
}
}
}
}
}
void disableIntelliJPlugin() async {
final homeDir = Directory(Platform.environment['HOME']);
final dirsToCheck = [
homeDir,
Directory(path.join(homeDir.path, '.local', 'share')),
Directory(path.join(homeDir.path, '.local', 'share', 'JetBrains')),
];
for (var toCheck in dirsToCheck) {
await for (var dir in toCheck.list()) {
final baseDir = path.basename(dir.path);
for (var idePath in intelliJPaths) {
if (idePath.hasMatch(baseDir)) {
// Older versions of IntelliJ
var d = Directory(
path.join(dir.path, 'config', 'plugins', 'pal_intellij_plugin'));
if (await d.exists()) {
await d.delete(recursive: true);
}
// Newer versions of IntelliJ
d = Directory(path.join(dir.path, 'pal_intellij_plugin'));
if (await d.exists()) {
await d.delete(recursive: true);
}
}
}
}
}
}
| 31.287129 | 79 | 0.653481 |
2f03d4d42c49230bb8f5eb49c22220c7b0c9c59f | 1,396 | java | Java | src/main/java/com/ncu/appstore/interceptor/APPInfoPageFilter.java | 03228/appstore | 5506d364467bebb4affd45af157dfbe0705d80b6 | [
"Apache-2.0"
] | 13 | 2019-09-04T04:54:44.000Z | 2021-12-11T01:26:31.000Z | src/main/java/com/ncu/appstore/interceptor/APPInfoPageFilter.java | 03228/appstore | 5506d364467bebb4affd45af157dfbe0705d80b6 | [
"Apache-2.0"
] | 7 | 2019-11-13T11:27:58.000Z | 2020-10-15T06:06:49.000Z | src/main/java/com/ncu/appstore/interceptor/APPInfoPageFilter.java | 03228/appstore | 5506d364467bebb4affd45af157dfbe0705d80b6 | [
"Apache-2.0"
] | 18 | 2019-08-06T07:12:43.000Z | 2021-12-21T07:20:30.000Z | package com.ncu.appstore.interceptor;
import com.ncu.appstore.common.PageHelper;
import com.ncu.appstore.dao.AppInfoMapper;
import com.ncu.appstore.pojo.AppInfo;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import javax.servlet.*;
import java.io.IOException;
import java.util.List;
/**
* Create by CZM on 2019/8/9
*/
public class APPInfoPageFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
ServletContext context = request.getServletContext();
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);
AppInfoMapper appInfoMapper = ctx.getBean(AppInfoMapper.class);
Integer pageNum = null;
if(request.getParameter("pageNum")!=null){
pageNum = Integer.parseInt(request.getParameter("pageNum"));
}
PageHelper.startPage(pageNum, 5);//开始分页
appInfoMapper.findAllToCheck();
PageHelper.Page endPage = PageHelper.endPage();//分页结束
request.setAttribute("page", endPage );
chain.doFilter(request, response);
}
@Override
public void destroy() {
}
}
| 31.022222 | 132 | 0.729226 |
70b4b7fe4801db2e08d47d5c14f86a2007526d6e | 2,458 | cs | C# | source/Uol.PagSeguro/Configuration/PreApprovalElement.cs | DesignLiquido/pagseguro-dotnet | aad1840388bd012eacc437835721bfad4bb626e6 | [
"Apache-2.0"
] | 14 | 2016-08-09T03:29:03.000Z | 2021-02-18T18:15:04.000Z | source/Uol.PagSeguro/Configuration/PreApprovalElement.cs | marcelopspereira/pagseguro-dotnet | aad1840388bd012eacc437835721bfad4bb626e6 | [
"Apache-2.0"
] | 9 | 2016-11-10T19:39:57.000Z | 2020-11-17T02:42:09.000Z | source/Uol.PagSeguro/Configuration/PreApprovalElement.cs | marcelopspereira/pagseguro-dotnet | aad1840388bd012eacc437835721bfad4bb626e6 | [
"Apache-2.0"
] | 8 | 2016-09-05T18:52:36.000Z | 2020-11-14T17:44:33.000Z | using System.Configuration;
namespace Uol.PagSeguro.Configuration
{
public class PreApprovalElement : ConfigurationElement
{
public const string LinkKey = "Link";
public const string PreApprovalRequestKey = "PreApprovalRequest";
public const string PreApprovalRedirectKey = "PreApprovalRedirect";
public const string PreApprovalNotificationKey = "PreApprovalNotification";
public const string PreApprovalSearchKey = "PreApprovalSearch";
public const string PreApprovalCancelKey = "PreApprovalCancel";
public const string PreApprovalPaymentKey = "PreApprovalPayment";
[ConfigurationProperty(LinkKey, IsRequired = true)]
public TextElement Link
{
get { return (TextElement)this[LinkKey]; }
set { this[LinkKey] = value; }
}
[ConfigurationProperty(PreApprovalRequestKey, IsRequired = true)]
public UrlElement PreApprovalRequest
{
get { return (UrlElement)this[PreApprovalRequestKey]; }
set { this[PreApprovalRequestKey] = value; }
}
[ConfigurationProperty(PreApprovalRedirectKey, IsRequired = true)]
public UrlElement PreApprovalRedirect
{
get { return (UrlElement)this[PreApprovalRedirectKey]; }
set { this[PreApprovalRedirectKey] = value; }
}
[ConfigurationProperty(PreApprovalNotificationKey, IsRequired = true)]
public UrlElement PreApprovalNotification
{
get { return (UrlElement)this[PreApprovalNotificationKey]; }
set { this[PreApprovalNotificationKey] = value; }
}
[ConfigurationProperty(PreApprovalSearchKey, IsRequired = true)]
public UrlElement PreApprovalSearch
{
get { return (UrlElement)this[PreApprovalSearchKey]; }
set { this[PreApprovalSearchKey] = value; }
}
[ConfigurationProperty(PreApprovalCancelKey, IsRequired = true)]
public UrlElement PreApprovalCancel
{
get { return (UrlElement)this[PreApprovalCancelKey]; }
set { this[PreApprovalCancelKey] = value; }
}
[ConfigurationProperty(PreApprovalPaymentKey, IsRequired = true)]
public UrlElement PreApprovalPayment
{
get { return (UrlElement)this[PreApprovalPaymentKey]; }
set { this[PreApprovalPaymentKey] = value; }
}
}
}
| 37.815385 | 83 | 0.655004 |
2dbfa6e29125335cb70f32145e10b70622c32789 | 139 | html | HTML | circle.html | lucasjellema/code-cafe-intro-to-svg | c9f40235d5351eff425e02504822318bcc7b53bc | [
"MIT"
] | null | null | null | circle.html | lucasjellema/code-cafe-intro-to-svg | c9f40235d5351eff425e02504822318bcc7b53bc | [
"MIT"
] | null | null | null | circle.html | lucasjellema/code-cafe-intro-to-svg | c9f40235d5351eff425e02504822318bcc7b53bc | [
"MIT"
] | null | null | null | <!DOCTYPE html>
<html>
<body>
<svg width="400" height="400">
<circle cx="200" cy="200" r="150" />
</svg>
</body>
</html> | 13.9 | 45 | 0.503597 |
64e69d550bbb30bde8aa8dd349cb401d29b450dd | 1,299 | java | Java | hydra/src/main/java/com/theotakutech/eviction/impl/LRUCacheLineEvictionAlgo.java | MarsLeeCN/hydra | c34c06b4f54cd3b1d09a335dcc8df158637dd4da | [
"Apache-2.0"
] | null | null | null | hydra/src/main/java/com/theotakutech/eviction/impl/LRUCacheLineEvictionAlgo.java | MarsLeeCN/hydra | c34c06b4f54cd3b1d09a335dcc8df158637dd4da | [
"Apache-2.0"
] | null | null | null | hydra/src/main/java/com/theotakutech/eviction/impl/LRUCacheLineEvictionAlgo.java | MarsLeeCN/hydra | c34c06b4f54cd3b1d09a335dcc8df158637dd4da | [
"Apache-2.0"
] | null | null | null | package com.theotakutech.eviction.impl;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import com.theotakutech.eviction.EvictionAlgo;
import com.theotakutech.model.entry.Entry;
/**
*
* The least recently used eviction algorithm implementation
*
* @author Mars
*
* {@link EvictionAlgo}
*
* @param <K>
* The key type of K-V cache
* @param <V>
*/
public class LRUCacheLineEvictionAlgo<K, V> implements EvictionAlgo<K, V> {
/**
* Cache keys of entities that stored in one cache set
*/
protected LinkedList<K> keys = new LinkedList<K>();
/**
* How many keys will be evict every time
*/
protected final int evictBuffer;
public LRUCacheLineEvictionAlgo(int evictBuffer) {
super();
this.evictBuffer = evictBuffer;
}
@Override
public Set<K> evict() {
Set<K> willRemove = new HashSet<>();
for (int i = 0; i < evictBuffer && keys.size() > 0; i++) {
keys.add(keys.removeLast());
}
return willRemove;
}
@Override
public void onCached(Entry<K, V> entry) {
onTouched(entry.getKey());
}
@Override
public void onTouched(K key) {
keys.remove(key);
keys.addFirst(key);
}
@Override
public void onRemoved(K key) {
keys.remove(key);
}
}
| 20.296875 | 76 | 0.639723 |
198e500af4267ca77cc07f7a50896384de647598 | 289 | asm | Assembly | programs/oeis/176/A176514.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 22 | 2018-02-06T19:19:31.000Z | 2022-01-17T21:53:31.000Z | programs/oeis/176/A176514.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 41 | 2021-02-22T19:00:34.000Z | 2021-08-28T10:47:47.000Z | programs/oeis/176/A176514.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 5 | 2021-02-24T21:14:16.000Z | 2021-08-09T19:48:05.000Z | ; A176514: Period 6: repeat [3, 1, 1, 3, 2, 1].
; 3,1,1,3,2,1,3,1,1,3,2,1,3,1,1,3,2,1,3,1,1,3,2,1,3,1,1,3,2,1,3,1,1,3,2,1,3,1,1,3,2,1,3,1,1,3,2,1,3,1,1,3,2,1,3,1,1,3,2,1,3,1,1,3,2,1,3,1,1,3,2,1,3,1,1,3,2,1,3,1,1,3,2,1,3,1,1,3,2,1,3,1,1,3,2,1,3,1,1,3
mov $2,$0
mod $0,3
sub $0,3
gcd $0,$2
| 36.125 | 201 | 0.50519 |
ded50fb4dcea31af3f8f71fa958b35bd403811dd | 319 | asm | Assembly | programs/oeis/070/A070460.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 22 | 2018-02-06T19:19:31.000Z | 2022-01-17T21:53:31.000Z | programs/oeis/070/A070460.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 41 | 2021-02-22T19:00:34.000Z | 2021-08-28T10:47:47.000Z | programs/oeis/070/A070460.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 5 | 2021-02-24T21:14:16.000Z | 2021-08-09T19:48:05.000Z | ; A070460: a(n) = n^2 mod 38.
; 0,1,4,9,16,25,36,11,26,5,24,7,30,17,6,35,28,23,20,19,20,23,28,35,6,17,30,7,24,5,26,11,36,25,16,9,4,1,0,1,4,9,16,25,36,11,26,5,24,7,30,17,6,35,28,23,20,19,20,23,28,35,6,17,30,7,24,5,26,11,36,25,16,9,4,1,0,1,4,9,16,25,36,11,26,5,24,7,30,17,6,35,28,23,20,19,20,23,28,35
pow $0,2
mod $0,38
| 53.166667 | 268 | 0.60815 |
3de022c6cd9a40a08ca69e75a92803011f746a60 | 92 | kt | Kotlin | app/src/main/java/id/ghuniyu/sekitar/data/model/Province.kt | iamnubs/sekitarkita-mobile | 46134076f4dbce3a0d71d7a6aa5df136a9922182 | [
"MIT"
] | 10 | 2020-03-23T18:10:43.000Z | 2021-07-20T15:51:35.000Z | app/src/main/java/id/ghuniyu/sekitar/data/model/Province.kt | iamnubs/sekitarkita-mobile | 46134076f4dbce3a0d71d7a6aa5df136a9922182 | [
"MIT"
] | 3 | 2020-03-23T19:42:31.000Z | 2020-03-24T15:19:46.000Z | app/src/main/java/id/ghuniyu/sekitar/data/model/Province.kt | iamnubs/sekitarkita-mobile | 46134076f4dbce3a0d71d7a6aa5df136a9922182 | [
"MIT"
] | 7 | 2020-03-23T18:12:05.000Z | 2020-03-26T03:06:30.000Z | package id.ghuniyu.sekitar.data.model
data class Province(
val attributes: Attributes
) | 18.4 | 37 | 0.782609 |
a7467f28627fe4b880fe876aadd43643d21bd5d3 | 2,796 | swift | Swift | CoreCollections/Classes/Implementation/TableView/ImplementationClasses/TableViewPresenter.swift | skibinalexander/CoreCollections | e97cb51983cbb039dcaf1be874af51b73051e2ed | [
"MIT"
] | 3 | 2019-04-24T07:43:24.000Z | 2020-05-25T13:30:53.000Z | CoreCollections/Classes/Implementation/TableView/ImplementationClasses/TableViewPresenter.swift | skibinalexander/CoreCollections | e97cb51983cbb039dcaf1be874af51b73051e2ed | [
"MIT"
] | null | null | null | CoreCollections/Classes/Implementation/TableView/ImplementationClasses/TableViewPresenter.swift | skibinalexander/CoreCollections | e97cb51983cbb039dcaf1be874af51b73051e2ed | [
"MIT"
] | 1 | 2019-08-08T10:04:44.000Z | 2019-08-08T10:04:44.000Z | //
// CCTableViewPresenter.swift
// Vezu
//
// Created by Пользователь on 24/04/2019.
// Copyright © 2019 VezuAppDevTeam. All rights reserved.
//
import Foundation
// MARK: - BasicTableViewPresenter
open class TableViewPresenter:
TableViewDelegateProtocol,
ContainerViewRefreshOutputProtocol,
ManagerContextViewCallbackProtocol{
// MARK: - Properties
public var manager: ManagerProtocol!
// MARK: - TableViewDelegateProtocol Properties
public var editingStyle: UITableViewCell.EditingStyle = .none
public var shouldIndentWhileEditingRowAt: Bool = false
public var leadingSwipeConfig: ((IndexPath) -> UISwipeActionsConfiguration?)? = nil
public var trailingSwipeConfig: ((IndexPath) -> UISwipeActionsConfiguration?)? = nil
// MARK: - Lifecycle
public init() {
self.manager = Manager(
dataSource: TableViewDataSource(),
delegate: TableViewDelegate(
output: self
),
viewDelegate: self
)
}
open func willDisplay(viewModel: ViewModelCellProtocol) { }
open func didSelect(viewModel: ViewModelCellProtocol) { }
open func didDeselect(viewModel: ViewModelCellProtocol) { }
open func scrollDidChange() { }
open func scrollViewDidEndScrollingAnimation() { }
open func refreshList() {
manager.beginRefresh()
}
}
open class PaginationTableViewPresenter:
TableViewPresenter,
ContainerViewPrefetchOutputProtocol {
open func batchNumberRows(in section: Int) -> Int {
manager.item(index: section).cells.count
}
open func batchList() {}
public func paginationInsertCells(in item: ItemModel, cells: [ModelCellProtocol]) {
if item.cells.count > 0 {
manager.getData().insertCells(in: item, cells: cells, by: item.cells.count - 1)
} else {
manager.getData().replaceCells(in: item, cells: cells, viewCallback: .reloadCollection)
}
}
}
// MARK: - ManagerContextViewCallbackProtocol
public extension TableViewPresenter {
func didUpdateView(with type: ManagerContextViewCallbackType) {
switch type {
case .reloadInSection(let index): manager.getView().reloadCells(in: [index])
default: manager.getView().reloadContainer()
}
}
func didUpdateView(with type: ManagerContextViewCallbackType, for paths: [IndexPath]) {
switch type {
case .insertIntoCollection: manager.getView().insertCells(at: paths)
case .removeFromCollection: manager.getView().removeCells(at: paths)
case .reloadInSection(let index): manager.getView().reloadCells(in: [index])
default: manager.getView().reloadContainer()
}
}
}
| 30.391304 | 99 | 0.66774 |