Dataset Viewer
Auto-converted to Parquet Duplicate
content
stringlengths
40
17.4k
id
int64
0
236
fn connection() -> OciConnection { let database_url = database_url_from_env("OCI_DATABASE_URL"); OciConnection::establish(&database_url).unwrap() }
0
pub unsafe extern "C" fn kdb2_firstkey() -> datum { let mut item: datum = datum{dptr: 0 as *mut libc::c_char, dsize: 0,}; if __cur_db.is_null() { no_open_db(); item.dptr = 0 as *mut libc::c_char; item.dsize = 0 as libc::c_int; return item } return kdb2_dbm_firstkey(__cur_...
1
pub fn argument_error(name: &str, required: usize, passed: usize) -> Error { anyhow!( "Function '{}' required {} argument(s), but passed {}", name, required, passed ) }
2
pub fn pyclass(attr: TokenStream, item: TokenStream) -> TokenStream { let attr = parse_macro_input!(attr); let item = parse_macro_input!(item); derive_impl::pyclass(attr, item).into() }
3
fn create_mesh_buffer_verts( chunk: &Chunk, device: &wgpu::Device, queue: &wgpu::Queue, ) -> MeshBufferVerts { // Calculate total length of buffer e.g. a full chunk of different voxels. This way a new buffer only has to be created when the voxel capacity is changed. let verts = Mesh::verts(chunk); ...
4
pub fn clone(_meta: TokenStream, input: TokenStream) -> TokenStream { // parse the input stream into our async function let func = syn::parse_macro_input!(input as syn::ItemFn); // get attributes (docstrings/examples) for our function let attrs = &func.attrs; // get visibility of function let vis = &func.vi...
5
pub(crate) fn build_query_string(request: &Request, ruma_api: &TokenStream) -> TokenStream { let ruma_serde = quote! { #ruma_api::exports::ruma_serde }; if let Some(field) = request.query_map_field() { let field_name = field.ident.as_ref().expect("expected field to have identifier"); quote!({ ...
6
pub fn skia_rectangle_f32_top(rectangle_ptr: *mut ValueBox<Rect>) -> scalar { rectangle_ptr.with_not_null_return(0.0, |rectangle| rectangle.top()) }
7
fn build_url(host: &str, page: Option<i32>) -> String { match page { Some(p) => format!( "https://api.binaryedge.io/v2/query/domains/subdomain/{}?page={}", host, p ), None => format!( "https://api.binaryedge.io/v2/query/domains/subdomain/{}", h...
8
pub fn import_ruma_api() -> TokenStream { if let Ok(FoundCrate::Name(possibly_renamed)) = crate_name("ruma-api") { let import = Ident::new(&possibly_renamed, Span::call_site()); quote! { ::#import } } else if let Ok(FoundCrate::Name(possibly_renamed)) = crate_name("ruma") { let import = ...
9
pub fn generate(graphics: &Graphics) -> String { let mut document = "".to_owned(); document.push_str(SVG_OPEN); document.push_str("\n"); let graphics_result = gen_graphics(graphics, 1); document.push_str(&graphics_result); document.push_str(SVG_CLOSE); document }
10
pub fn caml_pasta_fq_div(x: ocaml::Pointer<CamlFq>, y: ocaml::Pointer<CamlFq>) -> CamlFq { CamlFq(x.as_ref().0 / y.as_ref().0) }
11
fn subst_op(ctx: &Closure, id: &str, fix: &Imm, o: &Op) -> Op { use crate::lambdal::Op::*; match o { Op2(op, e1, e2) => { let e1 = Box::new(subst_op(ctx, id, fix, e1)); let e2 = Box::new(subst_op(ctx, id, fix, e2)); Op2(*op, e1, e2) } MkArray(sz, n) =>...
12
pub const fn create_default_audio_stream(stream_type: AudioStreamType) -> AudioStream { AudioStream { stream_type: stream_type, source: AudioSettingSource::User, user_volume_level: DEFAULT_VOLUME_LEVEL, user_volume_muted: DEFAULT_VOLUME_MUTED, } }
13
fn system_call(message: SystemCall) -> SystemCall { let addr = task_buffer_addr(); unsafe { let buffer = &mut *(addr as *mut TaskBuffer); buffer.call = Some(message); system_call_raw(); buffer.call.take().unwrap() } }
14
pub fn debug_time<T>(label: impl AsRef<str>, cb: impl FnOnce() -> T) -> T { let label = label.as_ref(); let t0 = std::time::Instant::now(); debug_log(format!("Starting {}...", label)); let ret = cb(); debug_log(format!("Finished {}: {:?}", label, t0.elapsed())); return ret; }
15
fn unit(num: u32, capitalise: bool) -> String { match num { 0 if capitalise => "No more bottles".to_string(), 0 => "no more bottles".to_string(), 1 => "1 bottle".to_string(), _ => num.to_string() + " bottles", } }
16
fn parse_stars(line: &str) -> Star { let u_pos = &line[10..]; let mut pos_parts = u_pos[0..u_pos.find(">").unwrap()].split(","); let u_vel = line.split("velocity=<").nth(1).unwrap(); let mut vel_parts = u_vel[0..u_vel.find(">").unwrap()].split(","); return Star { position: Point { ...
17
pub fn unary_num(t_unary: Token, n_simple_numeric: Node) -> Node { let mut numeric_value = if let Node::Int(int_value) = n_simple_numeric { int_value } else { panic!(); }; if let Token::T_UNARY_NUM(polarty) = t_unary { match polarty.as_ref() { "+" => (), "-" => { numeric_value =...
18
pub fn star2(lines: &Vec<String>) -> String { let days = initialize(lines); let mut guard_map = HashMap::new(); for day in days { guard_map.entry(day.guard_id) .or_insert(vec![]) .push(day); } let mut max_guard_asleep_per_minute = vec![(0, None); 60]; for &guard...
19
fn tab_base_template<A>(state: &State, tab: &Tab, mixin: A) -> Dom where A: FnOnce(DomBuilder<HtmlElement>) -> DomBuilder<HtmlElement> { html!("div", { .class([ &*ROW_STYLE, &*TAB_STYLE, //&*MENU_ITEM_STYLE, ]) .cursor!(state.is_dragging(),...
20
pub fn crate_inherent_impls(tcx: TyCtxt<'_>, (): ()) -> CrateInherentImpls { let mut collect = InherentCollect { tcx, impls_map: Default::default() }; for id in tcx.hir().items() { collect.check_item(id); } collect.impls_map }
21
fn get_common_chars(box_one: &String, box_two: &String) -> String { box_one.chars() .zip(box_two.chars()) .filter(|ch| ch.0 == ch.1) .map(|ch| ch.0) .collect() }
22
fn delete(task: Event, mut todays_list: List) -> List { todays_list.retain(|x| x.2 != task.2); todays_list }
23
fn parseLightInfo(reader: &mut BufReader<&File>, buf: &mut String, lights: &mut Vec<Light>) -> Model { let mut light = Light { lightType: "" as str, radius: 0.0, period: 0, position: Vec3f::new(0.0, 0.0, 0.0), Color: Vec3f::new(0.0, 0.0, 0.0), }; //Firstly, re...
24
fn current_manifest_path() -> ManifestResult { let locate_result = Command::new("cargo").arg("locate-project").output(); let output = match locate_result { Ok(out) => out, Err(e) => { print!("Failure: {:?}", e); panic!("Cargo failure to target project via locate-project")...
25
pub fn formatted_now() -> String { let system_time = SystemTime::now(); let date_time: DateTime<Utc> = system_time.into(); date_time.format("%d/%m/%Y %T").to_string() }
26
fn docker_metric_entry_from_two_stats(time_diff: Duration, first: InstantDockerContainerMetricEntry, second: InstantDockerContainerMetricEntry) -> DockerContainerMetricEntry { let diff = time_diff.num_milliseconds() as f64 / 1000.0; // seconds DockerContainerMetricEntry { name: second.name, sta...
27
pub fn get_temp_folder() -> PathBuf { let temp_dir = mktemp::Temp::new_dir().unwrap(); let path = temp_dir.to_path_buf(); temp_dir.release(); path }
28
fn build_user(email: String, username: String) -> User{ User{ // Using the Field Init Shorthand when Variables and Fields Have the Same Name email, username, active: true, sign_in_count: 1 } }
29
pub fn format_memory_usage(bytes: usize) -> String { format!("{:12}", bytes >> 20) // MB }
30
pub fn calendar(year: Year) -> Calendar{ let mut cal = Calendar::new(); let tz_offset = FixedOffset::east(1 * 60*60); //TODO: Actually depends on daylight saving time (DST) ("sommartid/vintertid") for each date, but it should not matter because there are no events which depends on time. Also, I mix UTC and this timez...
31
pub fn get_path_in_temp(file_path: &str) -> PathBuf { let mut path = get_temp_folder(); path.push(&file_path); path }
32
fn read_time() -> Time { read_line().trim().parse().unwrap() }
33
unsafe fn replace<T, R>(v: &mut T, change: impl FnOnce(T) -> (T, R)) -> R { let value = ptr::read(v); let (new_value, ret) = change(value); ptr::write(v, new_value); ret }
34
async fn index(schema: web::Data<MessageSchema>, req: HttpRequest, gql_request: Request) -> Response { let token = req .headers() .get("Authorization") .and_then(|value| value.to_str().map(|s| MyToken(s.to_string())).ok()); let mut request = gql_request.into_inner(); ...
35
fn to_rust_varstr(s: &str) -> String { use inflector::cases::snakecase::to_snake_case; let s = to_snake_case(s); fixup(s) }
36
pub fn assignable(node: Node) -> Node { println!("DEBUGGING node::assignable: {:?}", node); match node { Node::Ident(ident) => { // name, = *node // @parser.static_env.declare(name) // // node.updated(:lVasgn) // TODO handle appen...
37
pub fn pystruct_sequence_try_from_object(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input); derive_impl::pystruct_sequence_try_from_object(input).into() }
38
fn rules<'r, 'p: 'r, 's: 'r>( s: &mut Solver<'r>, inputs: &'p [TensorProxy], outputs: &'p [TensorProxy], ) -> InferenceResult { check_input_arity(&inputs, 1)?; check_output_arity(&outputs, 1)?; s.equals(&outputs[0].datum_type, &inputs[0].datum_type)?; s.equals(&outputs[0].rank, &inputs[0].ra...
39
pub fn number(n: i64) -> Value { Rc::new(RefCell::new(V { val: Value_::Number(n), computed: true, })) }
40
pub fn digamma<F : special::Gamma>(f: F) -> F { f.digamma() }
41
fn load_descriptor() -> Config { descriptor::load_internal_descriptors(true, false, None) }
42
fn env_var<K: AsRef<std::ffi::OsStr>>(key: K) -> String { env::var(&key).expect(&format!("Unable to find env var {:?}", key.as_ref())) }
43
pub fn global_rng() -> GlobalRng { GLOBAL_RNG_STATE.clone() }
44
fn cef_dir() -> PathBuf { PathBuf::from(env_var("CEF_DIR")) }
45
fn load_histograms() -> Loaded { let mut hist = Histogram::new_with_max(TRACKABLE_MAX, SIGFIG).unwrap(); let mut scaled_hist = Histogram::new_with_bounds(1000, TRACKABLE_MAX * SCALEF, SIGFIG).unwrap(); let mut raw = Histogram::new_with_max(TRACKABLE_MAX, SIGFIG).unwrap(); let mut scaled_raw = Histogram:...
46
pub fn greet(text: &str) -> String { text.to_string() }
47
pub(crate) fn iced_to_op_access(value: iced_x86_rust::OpAccess) -> OpAccess { // SAFETY: the enums are exactly identical unsafe { std::mem::transmute(value as u8) } }
48
fn gen_graphics(graphics: &Graphics, indent_level: usize) -> String { let mut document = "".to_owned(); for node in graphics.get_nodes() { let xml_element = element(node, indent_level); let indent_chars = " ".repeat(indent_level * INDENT_SIZE); document.push_str(&indent_chars); ...
49
pub fn create_file_in_temp(file_name: &str, content: &str) -> PathBuf { let path = get_path_in_temp(&file_name); let mut file = File::create(&path).unwrap(); file.write_all(content.as_bytes()) .expect(&format!("cannot write to file {:?}", path)); path }
50
fn tab_favicon<A>(tab: &Tab, mixin: A) -> Dom where A: FnOnce(DomBuilder<HtmlElement>) -> DomBuilder<HtmlElement> { let favicon_url = tab.favicon_url.clone(); lazy_static! { static ref LOADING_URL: Arc<String> = Arc::new(intern("icons/firefox/tab-loading.png").to_string()); } html!("img...
51
fn content(content: ElementContent, indent_level: usize) -> String { use ElementContent::*; match content { Empty => "".to_owned(), Text(t) => t, Elements(e) => gen_graphics(e.as_ref(), indent_level), } }
52
pub fn clamp<T: Ord> (x: T, a: T, b: T) -> T { match (x.cmp(&a), x.cmp(&b)) { (Ordering::Less, _) => a, (_, Ordering::Greater) => b, _ => x, } }
53
pub fn caml_pasta_fq_sub(x: ocaml::Pointer<CamlFq>, y: ocaml::Pointer<CamlFq>) -> CamlFq { CamlFq(x.as_ref().0 - y.as_ref().0) }
54
pub fn py_freeze(input: TokenStream) -> TokenStream { derive_impl::py_freeze(input.into(), &Compiler).into() }
55
pub(crate) fn make_entity_builder( main: &ECS, components: &[Component], generics: &GenericOutput, ) -> TokenStream { let name = main.as_entity_builder_ident(); let fields = components.iter().map(|comp| { let name = comp.as_ident(); let ty = comp.as_ty(); quote::quote! { #n...
56
fn system_call_put_payload<T: Any>(message: SystemCall, payload: T) -> SystemCall { use core::mem::{size_of}; let addr = task_buffer_addr(); unsafe { let buffer = &mut *(addr as *mut TaskBuffer); buffer.call = Some(message); buffer.payload_length = size_of::<T>(); let paylo...
57
pub fn interpret(expr: &Expr) -> Value { let ctx: Closure = HashMap::new(); eval(&ctx, expr) }
58
pub fn caml_pasta_fq_size() -> CamlBigInteger256 { Fq_params::MODULUS.into() }
59
pub fn create_file<P>(path: P) -> File where P: AsRef<Path> { match File::create(&path) { Err(_) => { println!("cannot create file: {:?}", path.as_ref()); exit(1) } Ok(file) => file, } }
60
pub fn caml_pasta_fq_square(x: ocaml::Pointer<CamlFq>) -> CamlFq { CamlFq(x.as_ref().0.square()) }
61
fn part1(filename: &Path) -> String { Snafu::from( iter_lines(filename) .map(Snafu::from) .map::<isize, _>(Snafu::into) .sum::<isize>(), ) .to_string() }
62
pub fn create_insert(run: Run) -> Insert { Insert(docx_rs::Insert::new(run.take())) }
63
fn mock<T>() -> T { unimplemented!() }
64
pub fn b(b: BuiltIn) -> Value { Rc::new(RefCell::new(V { val: Value_::BuiltIn(b), computed: true, })) }
65
pub fn ln<F : Float>(f: F) -> F { f.ln() }
66
pub fn fatal_error() -> Error { anyhow!("Fatal error!") }
67
pub fn new_cube() -> Tess { let vertices: &[([f32; 3], [f32; 3], [f32; 2])] = &[ // front face ([ 1., -1., 1.], [ 0., 0., 1.], [1., 0.]), // 0 ([ 1., 1., 1.], [ 0., 0., 1.], [1., 1.]), ([-1., -1., 1.], [ 0., 0., 1.], [0., 0.]), ([-1., 1., 1.], [ 0., 0., 1.], [0., 1.]), // back fa...
68
fn subst_imm(ctx: &Closure, id: &str, fix: &Imm, i: &Imm) -> Imm { use crate::lambdal::Imm::*; match i { Bool(b) => Bool(*b), Int(n) => Int(*n), Var(x) => { if x == id { fix.clone() } else { Var(x.clone()) } } ...
69
fn bindgen_prop(header: fuzzers::HeaderC) -> TestResult { match run_predicate_script(header) { Ok(o) => TestResult::from_bool(o.status.success()), Err(e) => { println!("{:?}", e); TestResult::from_bool(false) } } }
70
pub fn caml_pasta_fq_random() -> CamlFq { let fq: Fq = UniformRand::rand(&mut rand::thread_rng()); CamlFq(fq) }
71
pub fn sing(high: u32, low: u32) -> String { (low..(high + 1)) .rev() .map(|x| verse(x)) .collect::<Vec<String>>() .join("\n") }
72
pub fn verse(num: u32) -> String { let prefix = format!("{} of beer on the wall, \ {} of beer.\n", unit(num, true), unit(num, false)); let suffix = match num { 0 => { "Go to the store and buy some more, \ ...
73
fn rdin() -> String{ let mut reader = String::new(); std::io::stdin().read_line(&mut reader).unwrap(); reader = removed(reader.to_lowercase()); // Changes everything to lowercase so it is not a case sensetive program. println!(); return reader; }
74
pub fn assign(lhs_node: Node, token: Token, rhs_node: Node) -> Node { match lhs_node { Node::LVasgn(var_str, mut nodes) => { nodes.push(rhs_node); return Node::LVasgn(var_str, nodes); }, _ => { panic!("node::assign UNIMPL"); } } }
75
pub fn smart_to_total_words() -> TotalWords { let mut words_vec: Vec<Words> = Vec::new(); for i in 1..22 { let words = smart_to_words(i); words_vec.push(words); } TotalWords::new(words_vec) }
76
fn random_with_rng<N, T: Rng>(a: N, b: N, rng: &mut T) -> N where N: SampleUniform + SampleBorrow<N> + Ord + Sized, { match a.cmp(&b) { Ordering::Greater => { let simpler = Uniform::new_inclusive(b, a); simpler.sample(rng) } Ordering::Equal => a, Ordering...
77
pub(crate) fn assignment_expression(i: Input) -> NodeResult { alt(( single::single_assignment_expression, abbreviated::abbreviated_assignment_expression, assignment_with_rescue_modifier, ))(i) }
78
fn reflect(v: &Vec3, n: &Vec3) -> Vec3 { *v - *n * 2.0 * dot(v, n) }
79
pub(crate) fn create_array_iterator_prototype(agent: &Agent) -> Value { let proto = Value::new_object(agent.intrinsics.iterator_prototype.clone()); proto .set( agent, ObjectKey::from("next"), Value::new_builtin_function(agent, next, false), ) .unwrap(...
80
fn get_comments_progress_bar( total_bytes: u64, statistics: &Arc<Statistics>, show_annotated: bool, ) -> Progress { Progress::new( move |statistics| { let num_downloaded = statistics.num_downloaded(); let num_annotated = statistics.num_annotated(); ( ...
81
fn fake_private_key() -> Bip32PrivateKey { Bip32PrivateKey::from_bytes( &[0xb8, 0xf2, 0xbe, 0xce, 0x9b, 0xdf, 0xe2, 0xb0, 0x28, 0x2f, 0x5b, 0xad, 0x70, 0x55, 0x62, 0xac, 0x99, 0x6e, 0xfb, 0x6a, 0xf9, 0x6b, 0x64, 0x8f, 0x44, 0x45, 0xec, 0x44, 0xf4, 0x7a, 0xd9, 0x5c, 0x10, 0xe3, 0xd7, 0x2f, 0x26, ...
82
pub unsafe extern "C" fn kdb2_fetch(mut key: datum) -> datum { let mut item: datum = datum{dptr: 0 as *mut libc::c_char, dsize: 0,}; if __cur_db.is_null() { no_open_db(); item.dptr = 0 as *mut libc::c_char; item.dsize = 0 as libc::c_int; return item } return kdb2_dbm_fetc...
83
pub fn format_pbs_duration(duration: &Duration) -> String { format_duration(duration) }
84
pub fn wrap(_meta: TokenStream, input: TokenStream) -> TokenStream { // parse the input stream into our async function let func = syn::parse_macro_input!(input as syn::ItemFn); // get attributes (docstrings/examples) for our function let attrs = &func.attrs; // get visibility of function let vis = &func.vis...
85
pub fn derive_encode(input: TokenStream) -> TokenStream { // Construct a string representation of the type definition let s = input.to_string(); // Parse the string representation let ast = syn::parse_derive_input(&s).unwrap(); // Build the impl let gen = impl_encode(&ast); // Ret...
86
pub fn create_default_modified_timestamps() -> ModifiedTimestamps { let mut timestamps = HashMap::new(); let stream_types = [ AudioStreamType::Background, AudioStreamType::Media, AudioStreamType::Interruption, AudioStreamType::SystemAgent, AudioStreamType::Communication, ...
87
fn to_rust_typestr(s: &str) -> String { use inflector::cases::pascalcase::to_pascal_case; let s = to_pascal_case(s); fixup(s) }
88
pub fn ap(f: Value, arg: Value) -> Value { Rc::new(RefCell::new(V { val: Value_::Apply(f, arg), computed: false, })) }
89
fn mac_to_string(mac: Option<MacAddr>) -> String { match mac { Some(m) => m.to_string(), None => "Unknown mac address".to_string(), } }
90
pub(crate) fn extract_request_query(request: &Request, ruma_api: &TokenStream) -> TokenStream { let ruma_serde = quote! { #ruma_api::exports::ruma_serde }; if request.query_map_field().is_some() { quote! { let request_query = #ruma_api::try_deserialize!( request, ...
91
const fn null_ble_gatt_svc_def() -> ble_gatt_svc_def { return ble_gatt_svc_def { type_: BLE_GATT_SVC_TYPE_END as u8, uuid: ptr::null(), includes: ptr::null_mut(), characteristics: ptr::null(), }; }
92
fn solve() -> String { compute(1000).to_string() }
93
pub fn caml_pasta_fq_deep_copy(x: CamlFq) -> CamlFq { x }
94
fn element(node: &GraphicNode, indent_level: usize) -> String { let name = node.get_name(); let attrs = gen_attributes(node.get_attributes()); let mut content = content(node.get_content(), indent_level + 1); if content != "" { let indent_chars = " ".repeat(indent_level * INDENT_SIZE); ...
95
pub fn string_compose(parts: Node) -> Node { if is_collapse_string_parts(&parts) {} // TODO DUMMY if let Node::Str(string_value) = parts { return Node::Str(string_value); } if let Node::Nodes(str_nodes) = parts { if let Node::Str(str_value) = (*str_nodes.get(0).unwrap()).clone() { r...
96
fn calculate_metrics(ref_cluster:&ClusterResults, query_clusters: &Vec<&ClusterResults>) -> ExperimentResults{ let mut stability_results = Array2::<f64>::zeros(( ref_cluster.grouped_barcodes.len() ,query_clusters.len() )); let mut purity_results = Array2::<f64>::zeros(( ref_cluster.grouped_barcodes.len() ,query...
97
pub(crate) fn build_request_body(request: &Request, ruma_api: &TokenStream) -> TokenStream { let serde_json = quote! { #ruma_api::exports::serde_json }; if let Some(field) = request.newtype_raw_body_field() { let field_name = field.ident.as_ref().expect("expected field to have an identifier"); ...
98
fn removed(mut string: String) -> String { if let Some('\n')=string.chars().next_back() { string.pop(); } if let Some('\r')=string.chars().next_back() { string.pop(); } string }
99
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
4